Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Как мы автоматизировали интеграционное тестиров...

Как мы автоматизировали интеграционное тестирование с Gonkey и не пожалели. Паша Егорычев, Кирилл Поляков

В современном мире микросервисов и API-first подхода интеграционное тестирование становится неотъемлемой частью процесса разработки. А значит, нужно задумываться об упрощении и автоматизации этого этапа для уменьшения времени выхода сервиса в эксплуатацию.

В этом докладе мы рассматриваем Gonkey — инструмент для автоматизированного тестирования API, написанный на языке Go и разработанный в Lamoda Tech.

Вы узнаете:
- Как и зачем появился Gonkey (и почему он так называется?)
- Как устроена архитектура Gonkey?
- О деталях реализации и почему framework написан на Golang?
- Как тестируются сложные интеграционые сценарии

Доклад будет полезен всем, кто хочет упростить подход к тестированию и хочет самостоятельно написать свой framework.

Avatar for Lamoda Tech

Lamoda Tech

May 06, 2025
Tweet

More Decks by Lamoda Tech

Other Decks in Technology

Transcript

  1. 4

  2. 5

  3. 7

  4. 8

  5. 9

  6. 11

  7. 13

  8. 15

  9. 16

  10. 17

  11. 18

  12. 20

  13. 22

  14. 24

  15. 25

  16. 26

  17. 27

  18. 28

  19. 29

  20. 30

  21. 31

  22. 32

  23. 33

  24. 34

  25. 36

  26. 38

  27. 39

  28. 40

  29. 41

  30. 42

  31. 43

  32. 44

  33. 45

  34. 46

  35. 47

  36. 48

  37. 49

  38. 50

  39. 52

  40. 53 - name: "Создание заказа. БД" method: POST path: /jsonrpc/v2/orders.create

    request: > { "id": "550e8400-e29b-41d4-a716-446655440000", "params": { "checkout_type": "FULL", "platform": "site", "country": "ru, ... } } response: 200: > { "id": "550e8400-e29b-41d4-a716-446655440000", "result": { "order_nr": "RU-123", "checkout_type": "FULL", "platform": "site", ... } } dbQuery: | SELECT order_nr, country FROM orders platform = `site` dbResponse: - `{“orderNr":”RU-123", "country": "ru"}`
  41. 54 - name: "Создание заказа. Параметризация" method: POST path: /jsonrpc/v2/orders.create

    request: > { "id": "550e8400-e29b-41d4-a716-446655440000", "params": { "checkout_type": {{ .checkout }}, "platform": {{ .platform }}, "country": "ru", ... } } response: 200: > { "id": "550e8400-e29b-41d4-a716-446655440000", "result": { "order_nr": "RU-123", "checkout_type": {{ .checkout }}, "platform": {{ .platform }}, "country": "ru", ... } } cases: - requestArgs: checkout: "FULL" platform: "site" responseArgs: 200: checkout: ”FULL' platform: "site" - requestArgs: checkout: "express" platform: "mobile" responseArgs: 200: checkout : "express" platform: "mobile"
  42. 55 - name: "Создание заказа. Моки" method: POST path: /jsonrpc/v2/orders.create

    mocks: payment: strategy: uriVary basePath: /json-rpc/v2 uris: orders.create: calls: 1 strategy: constant statusCode: 200 body: > { "id": "7c497e8d-b3e3-4921-bfb4-0b4472179fde", "result": {…} } requestConstraints: - kind: bodyMatchesJSON body: > { "method": "orders.create", "params": {…} }
  43. 56 - name: "Создание заказа. Моки. Повторные запросы. Конкурентно" method:

    POST path: /jsonrpc/v2/orders.create ... mocks: payment: strategy: uriVary basePath: /jsonrpc/v2 uris: orders.create: calls: 2 strategy: sequence sequence: - strategy: constant body: > { "error": { "code": 101, "message" : "Got some error" } } - strategy: file filename: mocks_data/payment/success.json
  44. 57 - name: "Создание заказа. Моки. Повторные запросы. Конкурентно" method:

    POST path: /jsonrpc/v2/orders.create ... mocks: payment: strategy: basedOnRequest uris: - strategy: file filename: mocks_data/payment/yellow_success.json requestConstraints: - kind: bodyMatchesJSON body: > { "params": { ”payment_method": ”yellow", } } - strategy: file filename: mocks_data/payment/blue_fail.json requestConstraints: - kind: bodyMatchesJSON body: > { "params": { ”payment_method": ”blue", } }
  45. 58 • API requester • API checker • Yaml parser

    • Cases (table testing) • Simple mocks • Simple postgres fixtures Gonkey v1.0 • API requester • API checker • Yaml parser • Cases (table testing) • Complex mocks strategies • Fixture templating and linking • Allure reports • Db checker • CLI runner • Soap requester • Variables • Mysql, Aerospike, Redis support Gonkey v1.21.8
  46. 60

  47. 61

  48. 62

  49. 63

  50. 64