Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Cloud-native apps REST API testing: our story by Kirill Shepitko from Neotech Development at 68th Devclub.lv

1,343 views

Published on

“We have an internal framework (open-sourced now) that we use to test our cloud-native apps’ REST API, which is based on an interesting combination of Docker, Testcontainers, Wiremock and Cucumber – such solution makes it easy to use for both – QA engineers and business people. We are happy to share our experience in REST API testing – a path from 0 tests and problems to full coverage and nice test reports.”
(Language – English)

Kirill is a Software Architect for multiple teams in Neotech Development, continuously exploring new tech to improve team skillset and efficiency. Working in software development for almost 18 years.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Cloud-native apps REST API testing: our story by Kirill Shepitko from Neotech Development at 68th Devclub.lv

  1. 1. Cloud-native apps REST API testing Kirill Shepitko
  2. 2. Who We Are & What We Do neotech.lv www.neotech.lvneotechlv neotechlv
  3. 3. How We Do It
  4. 4. How We Deliver It
  5. 5. •Relies on IaaS •Scalable, resilient, self-healing, stateless •Containerized What is a cloud-native app? «Cloud native is an approach to building and running applications that fully exploit the advantages of the cloud computing model.» Source: What are Cloud-Native Applications? - Pivotal
  6. 6. Test pyramid Unit tests Integration tests Acceptance tests UI tests 5% 5% 10% 80% • UI – 5% • Acceptance – 5% • Integration – 10% • Unit – 80%
  7. 7. Our test pyramid Unit tests Integration tests Acceptance tests UI tests 0% 0% 20% 80% • UI – 0% • Acceptance – 0% • Integration – 20% • Unit – 80%
  8. 8. Problems we had Contract broken Deployment is broken
  9. 9. What we needed • REST API acceptance tests • Tests should test REST contracts • Tests should be fast • Should be able to mimic correspondent systems • Should be able to detect the deployment problems • Should be lightweight enough to run tests on dev machines • Should have nice reporting
  10. 10. REST API contract testing
  11. 11. Existing Frameworks’ Issues Great for a “Hello world” app Lots of very similar contracts (maintain it!) Tests are generated Lot of code to write
  12. 12. How Spring Cloud Contract Works 1. Write contract 2. Verify contract from producer side (automated) 3. Publish service stubs to artifactory (there’s a plugin) 4. Write a test on client side, using stubs
  13. 13. Writing Spring Cloud Contract • Groovy • YAML • Pact JSON • Spring REST docs
  14. 14. Spring Cloud Contract for Polyglots
  15. 15. The Solution Describe REST endpoints Create scenario (pact) Author test steps Run tests
  16. 16. Imagine a sample app…
  17. 17. How we test REST API
  18. 18. Before Tests Manually start up the app ecosystem 1 Pull Swagger specs 2 Save Swagger specs to tests Git repo 3
  19. 19. Test Flow Generate REST clients 1 Run tests • Launch ecosystem via TestContainers • Launch mocks • Run scenarios 2 Generate reports 3
  20. 20. Benefits • Scenario is a contract • WireMock is useful for mocks and trouble emulation • Test steps and mocks can be reused • Easy to bring up the whole app ecosystem • REST client generation approach is polyglot • Great reports
  21. 21. Lessons Learned • QA needs a faster solution • REST client may be stale • Supporting different test profiles • Regenerating REST clients on the fly
  22. 22. Updated Test Flow Start up the app ecosystem and download Swagger JSON 1 Generate REST clients (Git- ignored) 2 Run tests • Launch ecosystem again • Launch mocks • Run scenarios 3 Generate reports 4
  23. 23. Docker-compose Is a God Local development Tests REST client generation
  24. 24. Problems • No clear boundary between contract and acceptance testing • TestContainers bind the solution to JUnit 4 • Springfox (generates Swagger spec) is quite limited
  25. 25. Alternative to Compose: K8s plugin for Jenkins Cons: • Can't really run tests locally • Tests configs are partially moved to pipeline definition • Bound to Jenkins
  26. 26. Swagger
  27. 27. Scenario
  28. 28. Generated REST client in use
  29. 29. Service mock
  30. 30. Allure report: overview
  31. 31. Allure report: graphs
  32. 32. Allure report: behaviours
  33. 33. Real performance
  34. 34. Our framework is open-source https://github.com/neotechlv
  35. 35. Thank you for listening!

×