diff --git a/.golangci.yml b/.golangci.yml index 1d614a9..0342585 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -98,6 +98,11 @@ linters: - gosec text: G204 + - path: ^util/compare_http\.go$ + linters: + - gocritic + text: "ifElseChain:" + - path: ^docker/harness/(harness|service)\.go$ linters: - goconst diff --git a/cli/data/called-at-least-once/minimal-mocked-called-at-least-once.env.yml b/cli/data/called-at-least-once/minimal-mocked-called-at-least-once.env.yml index 088adf6..5dc0ef8 100644 --- a/cli/data/called-at-least-once/minimal-mocked-called-at-least-once.env.yml +++ b/cli/data/called-at-least-once/minimal-mocked-called-at-least-once.env.yml @@ -15,4 +15,4 @@ spec: path: /healthz then: http: - status: 200 + status_code: 200 diff --git a/cli/data/called-at-least-once/minimal-mocked-called-at-least-once.test.yml b/cli/data/called-at-least-once/minimal-mocked-called-at-least-once.test.yml index a96db0a..8ca57ad 100644 --- a/cli/data/called-at-least-once/minimal-mocked-called-at-least-once.test.yml +++ b/cli/data/called-at-least-once/minimal-mocked-called-at-least-once.test.yml @@ -9,7 +9,7 @@ spec: url: http://127.0.0.1:8083/healthz expect: http: - status: 200 + status_code: 200 calls: - service_id: minimal-mocked-called-at-least-once http: diff --git a/cli/data/called-at-least-once/minimal-mocked-called-at-least-once.yml b/cli/data/called-at-least-once/minimal-mocked-called-at-least-once.yml index 04ed538..c41cd5f 100644 --- a/cli/data/called-at-least-once/minimal-mocked-called-at-least-once.yml +++ b/cli/data/called-at-least-once/minimal-mocked-called-at-least-once.yml @@ -11,11 +11,16 @@ summary: http: method: GET url: http://127.0.0.1:8083/healthz + headers: + "E2engine-Test-Execution-Id": + - "c1079d334b1a17b4a5fa7588a90d045ed01ea241c53ab51afa0d8b8620837e7b" response: http: status_code: 200 - expected_calls: + calls: - service_id: minimal-mocked-called-at-least-once + count: 1 http: method: GET path: /healthz + response_status_code: 200 diff --git a/cli/data/called-at-least-once/misspelled-called-at-least-once.env.yml b/cli/data/called-at-least-once/misspelled-fails-validation.env.yml similarity index 75% rename from cli/data/called-at-least-once/misspelled-called-at-least-once.env.yml rename to cli/data/called-at-least-once/misspelled-fails-validation.env.yml index 015442c..9c28311 100644 --- a/cli/data/called-at-least-once/misspelled-called-at-least-once.env.yml +++ b/cli/data/called-at-least-once/misspelled-fails-validation.env.yml @@ -1,10 +1,10 @@ kind: Environment version: 1.0.0 -name: misspelled-called-at-least-once +name: misspelled-fails-validation description: one mocked HTTP service that returns 200 OK for /healthz spec: services: - - id: misspelled-called-at-least-once + - id: spelled-correctly kind: http mode: mocked address: 127.0.0.1:8083 @@ -15,4 +15,4 @@ spec: path: /healthz then: http: - status: 200 + status_code: 200 diff --git a/cli/data/called-at-least-once/misspelled-called-at-least-once.test.yml b/cli/data/called-at-least-once/misspelled-fails-validation.test.yml similarity index 61% rename from cli/data/called-at-least-once/misspelled-called-at-least-once.test.yml rename to cli/data/called-at-least-once/misspelled-fails-validation.test.yml index 5b04a8c..421e9cd 100644 --- a/cli/data/called-at-least-once/misspelled-called-at-least-once.test.yml +++ b/cli/data/called-at-least-once/misspelled-fails-validation.test.yml @@ -1,7 +1,7 @@ kind: Test version: 1.0.0 -name: misspelled-called-at-least-once -description: misspelled service is called at least once (calls count is not specified) +name: misspelled-fails-validation +description: validation fails because the service_id in the expect.calls is misspelled spec: request: http: @@ -9,7 +9,7 @@ spec: url: http://127.0.0.1:8083/healthz expect: http: - status: 200 + status_code: 200 calls: - service_id: misspelled http: diff --git a/cli/data/called-at-least-once/misspelled-called-at-least-once.yml b/cli/data/called-at-least-once/misspelled-fails-validation.yml similarity index 63% rename from cli/data/called-at-least-once/misspelled-called-at-least-once.yml rename to cli/data/called-at-least-once/misspelled-fails-validation.yml index 9ab2a0f..70c2e3e 100644 --- a/cli/data/called-at-least-once/misspelled-called-at-least-once.yml +++ b/cli/data/called-at-least-once/misspelled-fails-validation.yml @@ -3,17 +3,8 @@ started_at: 2026-08-19T15:16:47.974744Z finished_at: 2026-08-19T15:16:47.993394Z status: error environment_id: 7398ab887149ec5aa583c564a659a0b0a933ef27bacb675b081a2a752d8a3896 -environment_name: misspelled-called-at-least-once +environment_name: misspelled-fails-validation test_id: ae619f9418f89041a5f6e0e952eae9fb9495e2c271b66739ffd6fae46f9ff30a -test_name: misspelled-called-at-least-once +test_name: misspelled-fails-validation summary: error: "invalid test execution input, environment.service.id: misspelled, validation: expected call references unknown environment service" - request: - http: - method: GET - url: http://127.0.0.1:8083/healthz - expected_calls: - - service_id: misspelled - http: - method: GET - path: /healthz diff --git a/cli/data/called-at-least-once/one-of-two-mocked-not-called.env.yml b/cli/data/called-at-least-once/one-of-two-mocked-not-called.env.yml index fdbb491..2dd911f 100644 --- a/cli/data/called-at-least-once/one-of-two-mocked-not-called.env.yml +++ b/cli/data/called-at-least-once/one-of-two-mocked-not-called.env.yml @@ -15,7 +15,7 @@ spec: path: /healthz then: http: - status: 200 + status_code: 200 - id: not-called kind: http @@ -28,4 +28,4 @@ spec: path: /healthz then: http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/data/called-at-least-once/one-of-two-mocked-not-called.test.yml b/cli/data/called-at-least-once/one-of-two-mocked-not-called.test.yml index 1881698..e5c2811 100644 --- a/cli/data/called-at-least-once/one-of-two-mocked-not-called.test.yml +++ b/cli/data/called-at-least-once/one-of-two-mocked-not-called.test.yml @@ -10,7 +10,7 @@ spec: expect: http: - status: 200 + status_code: 200 calls: - service_id: not-called diff --git a/cli/data/called-at-least-once/one-of-two-mocked-not-called.yml b/cli/data/called-at-least-once/one-of-two-mocked-not-called.yml index e90d49b..a4175f5 100644 --- a/cli/data/called-at-least-once/one-of-two-mocked-not-called.yml +++ b/cli/data/called-at-least-once/one-of-two-mocked-not-called.yml @@ -11,14 +11,19 @@ summary: http: method: GET url: http://127.0.0.1:8082/healthz + headers: + "E2engine-Test-Execution-Id": + - "c1079d334b1a17b4a5fa7588a90d045ed01ea241c53ab51afa0d8b8620837e7b" response: http: status_code: 200 - expected_calls: - - service_id: not-called + calls: + - service_id: called + count: 1 http: method: GET path: /healthz + response_status_code: 200 deviations: - field: calls.not-called.count expected: "at least 1" diff --git a/cli/data/crud-test/gateway-calls-entitlements.test.yml b/cli/data/crud-test/gateway-calls-entitlements.test.yml index c52d91c..d341bbd 100644 --- a/cli/data/crud-test/gateway-calls-entitlements.test.yml +++ b/cli/data/crud-test/gateway-calls-entitlements.test.yml @@ -9,14 +9,19 @@ spec: request: http: method: GET - url: http://127.0.0.1:8082/check + url: http://127.0.0.1:9000/check expect: http: - status: 200 - body: '{"status":"ok"}' + status_code: 200 + body_json: '{"status":"ok"}' calls: - service_id: entitlements count: 1 http: method: GET - path: /healthz \ No newline at end of file + path: /healthz + headers: + "Accept-Encoding": + - gzip + "E2Engine-Test-Execution-Id": + - operator: nonempty diff --git a/cli/data/crud-test/http-real-mocked.yml b/cli/data/crud-test/http-real-mocked.yml index 75b80ff..7cad837 100644 --- a/cli/data/crud-test/http-real-mocked.yml +++ b/cli/data/crud-test/http-real-mocked.yml @@ -10,14 +10,18 @@ summary: request: http: method: GET - url: http://127.0.0.1:8082/check + url: http://127.0.0.1:9000/check + headers: + "E2engine-Test-Execution-Id": + - "c1079d334b1a17b4a5fa7588a90d045ed01ea241c53ab51afa0d8b8620837e7b" response: http: status_code: 200 body_json: '{"status":"ok"}' - expected_calls: + calls: - service_id: entitlements count: 1 http: method: GET - path: /healthz \ No newline at end of file + path: /healthz + response_status_code: 200 diff --git a/cli/data/crud-test/real-with-mocked-dependency.env.yml b/cli/data/crud-test/real-with-mocked-dependency.env.yml index b344382..8e950f7 100644 --- a/cli/data/crud-test/real-with-mocked-dependency.env.yml +++ b/cli/data/crud-test/real-with-mocked-dependency.env.yml @@ -20,8 +20,8 @@ spec: path: /healthz then: http: - status: 200 + status_code: 200 headers: Content-Type: - application/json - body: '{"status":"ok"}' \ No newline at end of file + body_json: '{"status":"ok"}' \ No newline at end of file diff --git a/cli/data/crud-testsuite/e2e.tse.yml b/cli/data/crud-testsuite/e2e.tse.yml index 8b11b76..fd9b049 100644 --- a/cli/data/crud-testsuite/e2e.tse.yml +++ b/cli/data/crud-testsuite/e2e.tse.yml @@ -23,21 +23,21 @@ tests: request: http: method: GET - url: http://127.0.0.1:8082/check + url: http://127.0.0.1:9000/check + headers: + "E2engine-Test-Execution-Id": + - "c1079d334b1a17b4a5fa7588a90d045ed01ea241c53ab51afa0d8b8620837e7b" response: http: status_code: 200 body_json: '{"status":"ok"}' - expected_calls: + calls: - service_id: entitlements count: 1 http: method: GET path: /healthz - - service_id: gateway - http: - method: GET - path: /check + response_status_code: 200 - id: f5497dfbbf8392b4828f5323c07e4b5cc8026790caca7b3065350413bebbd4e3 started_at: 2026-08-19T15:16:47.974744Z finished_at: 2026-08-19T15:16:47.993394Z @@ -50,20 +50,18 @@ tests: request: http: method: GET - url: http://127.0.0.1:8082/error + url: http://127.0.0.1:9000/error + headers: + "E2engine-Test-Execution-Id": + - "c1079d334b1a17b4a5fa7588a90d045ed01ea241c53ab51afa0d8b8620837e7b" response: http: status_code: 500 body_json: '{"error":"simulated error response"}' - expected_calls: - - service_id: gateway - http: - method: GET - path: /error deviations: - field: status_code expected: "200" actual: "500" - - field: body + - field: body_json expected: '{"status":"ok"}' actual: '{"error":"simulated error response"}' \ No newline at end of file diff --git a/cli/data/crud-testsuite/gateway-calls-entitlements.test.yml b/cli/data/crud-testsuite/gateway-calls-entitlements.test.yml index 719a81b..70f4146 100644 --- a/cli/data/crud-testsuite/gateway-calls-entitlements.test.yml +++ b/cli/data/crud-testsuite/gateway-calls-entitlements.test.yml @@ -9,18 +9,14 @@ spec: request: http: method: GET - url: http://127.0.0.1:8082/check + url: http://127.0.0.1:9000/check expect: http: - status: 200 - body: '{"status":"ok"}' + status_code: 200 + body_json: '{"status":"ok"}' calls: - service_id: entitlements count: 1 http: method: GET path: /healthz - - service_id: gateway - http: - method: GET - path: /check \ No newline at end of file diff --git a/cli/data/crud-testsuite/gateway-error.te.yml b/cli/data/crud-testsuite/gateway-error.te.yml index 11f2fb8..ee9c82c 100644 --- a/cli/data/crud-testsuite/gateway-error.te.yml +++ b/cli/data/crud-testsuite/gateway-error.te.yml @@ -10,20 +10,18 @@ summary: request: http: method: GET - url: http://127.0.0.1:8082/error + url: http://127.0.0.1:9000/error + headers: + "E2engine-Test-Execution-Id": + - "c1079d334b1a17b4a5fa7588a90d045ed01ea241c53ab51afa0d8b8620837e7b" response: http: status_code: 500 body_json: '{"error":"simulated error response"}' - expected_calls: - - service_id: gateway - http: - method: GET - path: /error deviations: - field: status_code expected: "200" actual: "500" - - field: body + - field: body_json expected: '{"status":"ok"}' actual: '{"error":"simulated error response"}' \ No newline at end of file diff --git a/cli/data/crud-testsuite/gateway-error.test.yml b/cli/data/crud-testsuite/gateway-error.test.yml index 283b5b6..b4b2f91 100644 --- a/cli/data/crud-testsuite/gateway-error.test.yml +++ b/cli/data/crud-testsuite/gateway-error.test.yml @@ -8,13 +8,8 @@ spec: request: http: method: GET - url: http://127.0.0.1:8082/error + url: http://127.0.0.1:9000/error expect: http: - status: 200 - body: '{"status":"ok"}' - calls: - - service_id: gateway - http: - method: GET - path: /error + status_code: 200 + body_json: '{"status":"ok"}' diff --git a/cli/data/crud-testsuite/http-real-mocked.te.yml b/cli/data/crud-testsuite/http-real-mocked.te.yml index 1739b4e..7cad837 100644 --- a/cli/data/crud-testsuite/http-real-mocked.te.yml +++ b/cli/data/crud-testsuite/http-real-mocked.te.yml @@ -10,18 +10,18 @@ summary: request: http: method: GET - url: http://127.0.0.1:8082/check + url: http://127.0.0.1:9000/check + headers: + "E2engine-Test-Execution-Id": + - "c1079d334b1a17b4a5fa7588a90d045ed01ea241c53ab51afa0d8b8620837e7b" response: http: status_code: 200 body_json: '{"status":"ok"}' - expected_calls: + calls: - service_id: entitlements count: 1 http: method: GET path: /healthz - - service_id: gateway - http: - method: GET - path: /check + response_status_code: 200 diff --git a/cli/data/crud-testsuite/real-with-mocked-dependency.env.yml b/cli/data/crud-testsuite/real-with-mocked-dependency.env.yml index b344382..8e950f7 100644 --- a/cli/data/crud-testsuite/real-with-mocked-dependency.env.yml +++ b/cli/data/crud-testsuite/real-with-mocked-dependency.env.yml @@ -20,8 +20,8 @@ spec: path: /healthz then: http: - status: 200 + status_code: 200 headers: Content-Type: - application/json - body: '{"status":"ok"}' \ No newline at end of file + body_json: '{"status":"ok"}' \ No newline at end of file diff --git a/cli/data/direct/direct-mocked-grpc.env.json b/cli/data/direct/direct-mocked-grpc.env.json index 2cfc0b7..7073257 100644 --- a/cli/data/direct/direct-mocked-grpc.env.json +++ b/cli/data/direct/direct-mocked-grpc.env.json @@ -41,9 +41,11 @@ { "when": { "grpc": { + "service": "entitlements.v1.EntitlementsService", "method": "CheckEntitlement", "message": { - "customer_id": "customer-1" + "operator": "equals", + "value": "{\"customer_id\": \"customer-1\"}" } } }, diff --git a/cli/data/direct/direct-mocked-grpc.env.yml b/cli/data/direct/direct-mocked-grpc.env.yml index 0228aed..4513323 100644 --- a/cli/data/direct/direct-mocked-grpc.env.yml +++ b/cli/data/direct/direct-mocked-grpc.env.yml @@ -25,9 +25,9 @@ spec: fixtures: - when: grpc: + service: entitlements.v1.EntitlementsService method: CheckEntitlement - message: - customer_id: customer-1 + message: '{"customer_id": "customer-1"}' then: grpc: status: OK diff --git a/cli/data/direct/direct-mocked-grpc.json b/cli/data/direct/direct-mocked-grpc.json index c42afee..bf54021 100644 --- a/cli/data/direct/direct-mocked-grpc.json +++ b/cli/data/direct/direct-mocked-grpc.json @@ -10,6 +10,7 @@ "summary": { "request": { "grpc": { + "target": "127.0.0.1:8083", "service": "entitlements.v1.EntitlementsService", "service_id": "direct-mocked-grpc", "method": "CheckEntitlement", @@ -23,23 +24,17 @@ "status": "OK", "message": { "entitled": true - }, - "metadata": { - "content-type": [ - "application/grpc" - ] } } }, - "expected_calls": [ + "calls": [ { "service_id": "direct-mocked-grpc", + "count": 1, "grpc": { "service": "entitlements.v1.EntitlementsService", "method": "CheckEntitlement", - "message": { - "customer_id": "customer-1" - } + "response_status": "OK" } } ] diff --git a/cli/data/direct/direct-mocked-grpc.test.json b/cli/data/direct/direct-mocked-grpc.test.json index 096b92d..405f2ce 100644 --- a/cli/data/direct/direct-mocked-grpc.test.json +++ b/cli/data/direct/direct-mocked-grpc.test.json @@ -1,5 +1,5 @@ { - "kind": "test", + "kind": "Test", "version": "1.0.0", "name": "direct-mocked-grpc", "description": "direct-mocked-grpc service is called at least once (calls count is not specified)", @@ -25,7 +25,8 @@ "service": "entitlements.v1.EntitlementsService", "method": "CheckEntitlement", "message": { - "customer_id": "customer-1" + "operator": "equals", + "value": "{\"customer_id\": \"customer-1\"}" } } } diff --git a/cli/data/direct/direct-mocked-grpc.test.yml b/cli/data/direct/direct-mocked-grpc.test.yml index e059197..b10d38b 100644 --- a/cli/data/direct/direct-mocked-grpc.test.yml +++ b/cli/data/direct/direct-mocked-grpc.test.yml @@ -20,5 +20,4 @@ spec: grpc: service: entitlements.v1.EntitlementsService method: CheckEntitlement - message: - customer_id: customer-1 \ No newline at end of file + message: '{"customer_id": "customer-1"}' \ No newline at end of file diff --git a/cli/data/direct/direct-mocked-grpc.yml b/cli/data/direct/direct-mocked-grpc.yml index 177afa7..075fec0 100644 --- a/cli/data/direct/direct-mocked-grpc.yml +++ b/cli/data/direct/direct-mocked-grpc.yml @@ -9,9 +9,13 @@ test_name: direct-mocked-grpc summary: request: grpc: + target: 127.0.0.1:8083 service: entitlements.v1.EntitlementsService service_id: direct-mocked-grpc method: CheckEntitlement + metadata: + "e2engine-test-execution-id": + - "c1079d334b1a17b4a5fa7588a90d045ed01ea241c53ab51afa0d8b8620837e7b" message: customer_id: customer-1 response: @@ -19,13 +23,10 @@ summary: status: OK message: entitled: true - metadata: - "content-type": - - "application/grpc" - expected_calls: + calls: - service_id: direct-mocked-grpc + count: 1 grpc: service: entitlements.v1.EntitlementsService method: CheckEntitlement - message: - customer_id: customer-1 \ No newline at end of file + response_status: OK \ No newline at end of file diff --git a/cli/data/direct/direct-mocked-http.env.json b/cli/data/direct/direct-mocked-http.env.json index 7641964..05678af 100644 --- a/cli/data/direct/direct-mocked-http.env.json +++ b/cli/data/direct/direct-mocked-http.env.json @@ -20,7 +20,7 @@ }, "then": { "http": { - "status": 200 + "status_code": 200 } } } diff --git a/cli/data/direct/direct-mocked-http.env.yml b/cli/data/direct/direct-mocked-http.env.yml index c90e5d0..32a9cc2 100644 --- a/cli/data/direct/direct-mocked-http.env.yml +++ b/cli/data/direct/direct-mocked-http.env.yml @@ -15,4 +15,4 @@ spec: path: /healthz then: http: - status: 200 + status_code: 200 diff --git a/cli/data/direct/direct-mocked-http.json b/cli/data/direct/direct-mocked-http.json index 8903a3a..ffcff16 100644 --- a/cli/data/direct/direct-mocked-http.json +++ b/cli/data/direct/direct-mocked-http.json @@ -19,12 +19,14 @@ "status_code": 200 } }, - "expected_calls": [ + "calls": [ { "service_id": "direct-mocked-http", + "count": 1, "http": { "method": "GET", - "path": "/healthz" + "path": "/healthz", + "response_status_code": 200 } } ] diff --git a/cli/data/direct/direct-mocked-http.test.json b/cli/data/direct/direct-mocked-http.test.json index 26fee81..97b24df 100644 --- a/cli/data/direct/direct-mocked-http.test.json +++ b/cli/data/direct/direct-mocked-http.test.json @@ -1,5 +1,5 @@ { - "kind": "test", + "kind": "Test", "version": "1.0.0", "name": "direct-mocked-http", "description": "direct-mocked-http service is called at least once (calls count is not specified)", @@ -12,7 +12,7 @@ }, "expect": { "http": { - "status": 200 + "status_code": 200 }, "calls": [ { diff --git a/cli/data/direct/direct-mocked-http.test.yml b/cli/data/direct/direct-mocked-http.test.yml index 21af721..7351347 100644 --- a/cli/data/direct/direct-mocked-http.test.yml +++ b/cli/data/direct/direct-mocked-http.test.yml @@ -9,7 +9,7 @@ spec: url: http://127.0.0.1:8083/healthz expect: http: - status: 200 + status_code: 200 calls: - service_id: direct-mocked-http http: diff --git a/cli/data/direct/direct-mocked-http.yml b/cli/data/direct/direct-mocked-http.yml index dc7174a..096386a 100644 --- a/cli/data/direct/direct-mocked-http.yml +++ b/cli/data/direct/direct-mocked-http.yml @@ -11,11 +11,16 @@ summary: http: method: GET url: http://127.0.0.1:8083/healthz + headers: + "E2engine-Test-Execution-Id": + - "c1079d334b1a17b4a5fa7588a90d045ed01ea241c53ab51afa0d8b8620837e7b" response: http: status_code: 200 - expected_calls: + calls: - service_id: direct-mocked-http + count: 1 http: method: GET path: /healthz + response_status_code: 200 diff --git a/cli/data/direct/direct-real-grpc.json b/cli/data/direct/direct-real-grpc.json index c3a00bd..4917d01 100644 --- a/cli/data/direct/direct-real-grpc.json +++ b/cli/data/direct/direct-real-grpc.json @@ -10,6 +10,7 @@ "summary": { "request": { "grpc": { + "target": "127.0.0.1:8083", "service": "ok.v1.OKService", "service_id": "direct-real-grpc", "method": "OK" @@ -25,12 +26,19 @@ } } }, - "expected_calls": [ + "calls": [ { "service_id": "direct-real-grpc", + "count": 1, "grpc": { "service": "ok.v1.OKService", - "method": "OK" + "method": "OK", + "response_status": "OK", + "metadata": { + "content-type": [ + "application/grpc" + ] + } } } ] diff --git a/cli/data/direct/direct-real-grpc.test.json b/cli/data/direct/direct-real-grpc.test.json index 045585c..0bc7b1f 100644 --- a/cli/data/direct/direct-real-grpc.test.json +++ b/cli/data/direct/direct-real-grpc.test.json @@ -1,5 +1,5 @@ { - "kind": "test", + "kind": "Test", "version": "1.0.0", "name": "direct-real-grpc", "description": "direct-real-grpc service is called at least once (calls count is not specified)", @@ -13,14 +13,26 @@ }, "expect": { "grpc": { - "status": "OK" + "status": "OK", + "metadata": { + "content-type": [ + "application/grpc" + ] + } }, "calls": [ { "service_id": "direct-real-grpc", + "count": 1, "grpc": { "service": "ok.v1.OKService", - "method": "OK" + "method": "OK", + "metadata": { + "content-type": [ + "application/grpc" + ] + }, + "response_status": "OK" } } ] diff --git a/cli/data/direct/direct-real-grpc.test.yml b/cli/data/direct/direct-real-grpc.test.yml index 405f5a1..bfdf7a0 100644 --- a/cli/data/direct/direct-real-grpc.test.yml +++ b/cli/data/direct/direct-real-grpc.test.yml @@ -13,8 +13,16 @@ spec: expect: grpc: status: OK + metadata: + "content-type": + - "application/grpc" calls: - service_id: direct-real-grpc + count: 1 grpc: service: ok.v1.OKService method: OK + metadata: + "content-type": + - "application/grpc" + response_status: OK \ No newline at end of file diff --git a/cli/data/direct/direct-real-grpc.yml b/cli/data/direct/direct-real-grpc.yml index 8c83b88..c6bc1c4 100644 --- a/cli/data/direct/direct-real-grpc.yml +++ b/cli/data/direct/direct-real-grpc.yml @@ -9,17 +9,28 @@ test_name: direct-real-grpc summary: request: grpc: + target: 127.0.0.1:8083 service: ok.v1.OKService service_id: direct-real-grpc method: OK + metadata: + "e2engine-test-execution-id": + - "c1079d334b1a17b4a5fa7588a90d045ed01ea241c53ab51afa0d8b8620837e7b" response: grpc: status: OK metadata: "content-type": - "application/grpc" - expected_calls: + message: + : null + calls: - service_id: direct-real-grpc + count: 1 grpc: service: ok.v1.OKService method: OK + response_status: OK + metadata: + "content-type": + - "application/grpc" diff --git a/cli/data/direct/direct-real-http.json b/cli/data/direct/direct-real-http.json index fed44ff..da4a0c4 100644 --- a/cli/data/direct/direct-real-http.json +++ b/cli/data/direct/direct-real-http.json @@ -19,12 +19,14 @@ "status_code": 200 } }, - "expected_calls": [ + "calls": [ { "service_id": "direct-real-http", + "count": 1, "http": { "method": "GET", - "path": "/ok" + "path": "/ok", + "response_status_code": 200 } } ] diff --git a/cli/data/direct/direct-real-http.test.json b/cli/data/direct/direct-real-http.test.json index c031c2b..8919958 100644 --- a/cli/data/direct/direct-real-http.test.json +++ b/cli/data/direct/direct-real-http.test.json @@ -1,5 +1,5 @@ { - "kind": "test", + "kind": "Test", "version": "1.0.0", "name": "direct-real-http", "description": "direct-real-http service is called at least once (calls count is not specified)", @@ -12,7 +12,7 @@ }, "expect": { "http": { - "status": 200 + "status_code": 200 }, "calls": [ { diff --git a/cli/data/direct/direct-real-http.test.yml b/cli/data/direct/direct-real-http.test.yml index 36bdbd3..7feb822 100644 --- a/cli/data/direct/direct-real-http.test.yml +++ b/cli/data/direct/direct-real-http.test.yml @@ -9,7 +9,7 @@ spec: url: http://127.0.0.1:8083/ok expect: http: - status: 200 + status_code: 200 calls: - service_id: direct-real-http http: diff --git a/cli/data/direct/direct-real-http.yml b/cli/data/direct/direct-real-http.yml index d8c043e..e5e26a2 100644 --- a/cli/data/direct/direct-real-http.yml +++ b/cli/data/direct/direct-real-http.yml @@ -11,11 +11,16 @@ summary: http: method: GET url: http://127.0.0.1:8083/ok + headers: + "E2engine-Test-Execution-Id": + - "c1079d334b1a17b4a5fa7588a90d045ed01ea241c53ab51afa0d8b8620837e7b" response: http: status_code: 200 - expected_calls: + calls: - service_id: direct-real-http + count: 1 http: method: GET path: /ok + response_status_code: 200 diff --git a/cli/data/fixture-miss/fixture-miss-grpc-message.env.yml b/cli/data/fixture-miss/fixture-miss-grpc-message.env.yml index 87655f6..f690d76 100644 --- a/cli/data/fixture-miss/fixture-miss-grpc-message.env.yml +++ b/cli/data/fixture-miss/fixture-miss-grpc-message.env.yml @@ -34,9 +34,9 @@ spec: fixtures: - when: grpc: + service: entitlements.v1.EntitlementsService method: CheckEntitlement - message: - customer_id: customer-1 + message: '{"customer_id": "customer-1"}' then: grpc: status: OK diff --git a/cli/data/fixture-miss/fixture-miss-grpc-message.test.yml b/cli/data/fixture-miss/fixture-miss-grpc-message.test.yml index 0ee9306..8a79cdf 100644 --- a/cli/data/fixture-miss/fixture-miss-grpc-message.test.yml +++ b/cli/data/fixture-miss/fixture-miss-grpc-message.test.yml @@ -12,13 +12,12 @@ spec: url: http://127.0.0.1:8082/check expect: http: - status: 200 - body: '{"status":"ok"}' + status_code: 200 + body_json: '{"status":"ok"}' calls: - service_id: entitlements count: 1 grpc: service: entitlements.v1.EntitlementsService method: CheckEntitlement - message: - customer_id: customer-2 \ No newline at end of file + message: '{"customer_id": "customer-2"}' \ No newline at end of file diff --git a/cli/data/fixture-miss/fixture-miss-grpc-message.yml b/cli/data/fixture-miss/fixture-miss-grpc-message.yml index a0cd603..e85080d 100644 --- a/cli/data/fixture-miss/fixture-miss-grpc-message.yml +++ b/cli/data/fixture-miss/fixture-miss-grpc-message.yml @@ -11,13 +11,16 @@ summary: http: method: GET url: http://127.0.0.1:8082/check + headers: + "E2engine-Test-Execution-Id": + - "c1079d334b1a17b4a5fa7588a90d045ed01ea241c53ab51afa0d8b8620837e7b" response: http: status_code: 502 - body_text: dependency returned non-ok status + body_json: "dependency returned non-ok status\n" - expected_calls: + calls: - service_id: entitlements count: 1 grpc: @@ -25,13 +28,20 @@ summary: method: CheckEntitlement message: customer_id: customer-2 + response_status: Unimplemented + - service_id: gateway + count: 1 + http: + method: GET + path: /check + response_status_code: 502 deviations: - field: status_code expected: "200" actual: "502" - - field: body + - field: body_json expected: '{"status":"ok"}' actual: | dependency returned non-ok status diff --git a/cli/data/fixture-miss/fixture-miss-grpc-method.env.yml b/cli/data/fixture-miss/fixture-miss-grpc-method.env.yml index e234f00..974d492 100644 --- a/cli/data/fixture-miss/fixture-miss-grpc-method.env.yml +++ b/cli/data/fixture-miss/fixture-miss-grpc-method.env.yml @@ -43,9 +43,9 @@ spec: fixtures: - when: grpc: + service: entitlements.v1.EntitlementsService method: CheckEntitlement - message: - customer_id: customer-1 + message: '{"customer_id": "customer-1"}' then: grpc: status: OK diff --git a/cli/data/fixture-miss/fixture-miss-grpc-method.test.yml b/cli/data/fixture-miss/fixture-miss-grpc-method.test.yml index 4c45d60..edbab19 100644 --- a/cli/data/fixture-miss/fixture-miss-grpc-method.test.yml +++ b/cli/data/fixture-miss/fixture-miss-grpc-method.test.yml @@ -12,13 +12,12 @@ spec: url: http://127.0.0.1:8082/check expect: http: - status: 200 - body: '{"status":"ok"}' + status_code: 200 + body_json: '{"status":"ok"}' calls: - service_id: entitlements count: 1 grpc: service: entitlements.v1.EntitlementsService method: UnknownMethod - message: - customer_id: customer-1 \ No newline at end of file + message: '{"customer_id": "customer-1"}' \ No newline at end of file diff --git a/cli/data/fixture-miss/fixture-miss-grpc-method.yml b/cli/data/fixture-miss/fixture-miss-grpc-method.yml index 78ac52c..912981c 100644 --- a/cli/data/fixture-miss/fixture-miss-grpc-method.yml +++ b/cli/data/fixture-miss/fixture-miss-grpc-method.yml @@ -11,13 +11,16 @@ summary: http: method: GET url: http://127.0.0.1:8082/check + headers: + "E2engine-Test-Execution-Id": + - "c1079d334b1a17b4a5fa7588a90d045ed01ea241c53ab51afa0d8b8620837e7b" response: http: status_code: 502 - body_text: dependency returned non-ok status + body_json: "dependency returned non-ok status\n" - expected_calls: + calls: - service_id: entitlements count: 1 grpc: @@ -25,13 +28,20 @@ summary: method: UnknownMethod message: customer_id: customer-1 + response_status: Unimplemented + - service_id: gateway + count: 1 + http: + method: GET + path: /check + response_status_code: 502 deviations: - field: status_code expected: "200" actual: "502" - - field: body + - field: body_json expected: '{"status":"ok"}' actual: | dependency returned non-ok status diff --git a/cli/data/fixture-miss/fixture-miss-http-body.env.yml b/cli/data/fixture-miss/fixture-miss-http-body.env.yml index b1095c5..5e813df 100644 --- a/cli/data/fixture-miss/fixture-miss-http-body.env.yml +++ b/cli/data/fixture-miss/fixture-miss-http-body.env.yml @@ -18,8 +18,8 @@ spec: http: method: POST path: /healthz - body: '{"customer_id":"customer-2"}' + body_json: '{"customer_id":"customer-2"}' then: http: - status: 200 - body: '{"status":"ok"}' \ No newline at end of file + status_code: 200 + body_json: '{"status":"ok"}' \ No newline at end of file diff --git a/cli/data/fixture-miss/fixture-miss-http-body.test.yml b/cli/data/fixture-miss/fixture-miss-http-body.test.yml index c4a71a9..22b45a6 100644 --- a/cli/data/fixture-miss/fixture-miss-http-body.test.yml +++ b/cli/data/fixture-miss/fixture-miss-http-body.test.yml @@ -12,12 +12,12 @@ spec: url: http://127.0.0.1:8082/check expect: http: - status: 200 - body: '{"status":"ok"}' + status_code: 200 + body_json: '{"status":"ok"}' calls: - service_id: entitlements count: 1 http: method: POST path: /healthz - body: '{"customer_id":"customer-2"}' \ No newline at end of file + body_json: '{"customer_id":"customer-2"}' \ No newline at end of file diff --git a/cli/data/fixture-miss/fixture-miss-http-body.yml b/cli/data/fixture-miss/fixture-miss-http-body.yml index 4b4fc85..94c3a57 100644 --- a/cli/data/fixture-miss/fixture-miss-http-body.yml +++ b/cli/data/fixture-miss/fixture-miss-http-body.yml @@ -11,26 +11,36 @@ summary: http: method: GET url: http://127.0.0.1:8082/check + headers: + "E2engine-Test-Execution-Id": + - "c1079d334b1a17b4a5fa7588a90d045ed01ea241c53ab51afa0d8b8620837e7b" response: http: status_code: 502 - body_text: dependency returned non-200 status + body_json: "dependency returned non-200 status\n" - expected_calls: + calls: - service_id: entitlements count: 1 http: method: POST path: /healthz body_json: '{"customer_id":"customer-2"}' + response_status_code: 501 + - service_id: gateway + count: 1 + http: + method: GET + path: /check + response_status_code: 502 deviations: - field: status_code expected: "200" actual: "502" - - field: body + - field: body_json expected: '{"status":"ok"}' actual: | dependency returned non-200 status diff --git a/cli/data/fixture-miss/fixture-miss-http-path-multiple.env.yml b/cli/data/fixture-miss/fixture-miss-http-path-multiple.env.yml index eaf68b9..1002fd9 100644 --- a/cli/data/fixture-miss/fixture-miss-http-path-multiple.env.yml +++ b/cli/data/fixture-miss/fixture-miss-http-path-multiple.env.yml @@ -20,30 +20,30 @@ spec: path: /miss then: http: - status: 200 + status_code: 200 headers: Content-Type: - application/json - body: '{"status":"ok"}' + body_json: '{"status":"ok"}' - when: http: method: GET path: /miss2 then: http: - status: 200 + status_code: 200 headers: Content-Type: - application/json - body: '{"status":"ok"}' + body_json: '{"status":"ok"}' - when: http: method: GET path: /miss3 then: http: - status: 200 + status_code: 200 headers: Content-Type: - application/json - body: '{"status":"ok"}' \ No newline at end of file + body_json: '{"status":"ok"}' \ No newline at end of file diff --git a/cli/data/fixture-miss/fixture-miss-http-path-multiple.test.yml b/cli/data/fixture-miss/fixture-miss-http-path-multiple.test.yml index 2dd1c51..a18c8d7 100644 --- a/cli/data/fixture-miss/fixture-miss-http-path-multiple.test.yml +++ b/cli/data/fixture-miss/fixture-miss-http-path-multiple.test.yml @@ -12,8 +12,8 @@ spec: url: http://127.0.0.1:8082/check expect: http: - status: 200 - body: '{"status":"ok"}' + status_code: 200 + body_json: '{"status":"ok"}' calls: - service_id: entitlements count: 1 diff --git a/cli/data/fixture-miss/fixture-miss-http-path-multiple.yml b/cli/data/fixture-miss/fixture-miss-http-path-multiple.yml index 4c16cca..aca2643 100644 --- a/cli/data/fixture-miss/fixture-miss-http-path-multiple.yml +++ b/cli/data/fixture-miss/fixture-miss-http-path-multiple.yml @@ -11,25 +11,35 @@ summary: http: method: GET url: http://127.0.0.1:8082/check + headers: + "E2engine-Test-Execution-Id": + - "c1079d334b1a17b4a5fa7588a90d045ed01ea241c53ab51afa0d8b8620837e7b" response: http: status_code: 502 - body_text: dependency returned non-200 status + body_json: "dependency returned non-200 status\n" - expected_calls: + calls: - service_id: entitlements count: 1 http: method: GET path: /healthz + response_status_code: 501 + - service_id: gateway + count: 1 + http: + method: GET + path: /check + response_status_code: 502 deviations: - field: status_code expected: "200" actual: "502" - - field: body + - field: body_json expected: '{"status":"ok"}' actual: | dependency returned non-200 status diff --git a/cli/data/fixture-miss/fixture-miss-http-path.env.yml b/cli/data/fixture-miss/fixture-miss-http-path.env.yml index a1559a8..b95a633 100644 --- a/cli/data/fixture-miss/fixture-miss-http-path.env.yml +++ b/cli/data/fixture-miss/fixture-miss-http-path.env.yml @@ -20,8 +20,8 @@ spec: path: /miss then: http: - status: 200 + status_code: 200 headers: Content-Type: - application/json - body: '{"status":"ok"}' \ No newline at end of file + body_json: '{"status":"ok"}' \ No newline at end of file diff --git a/cli/data/fixture-miss/fixture-miss-http-path.test.yml b/cli/data/fixture-miss/fixture-miss-http-path.test.yml index ca6a5be..3b098df 100644 --- a/cli/data/fixture-miss/fixture-miss-http-path.test.yml +++ b/cli/data/fixture-miss/fixture-miss-http-path.test.yml @@ -12,8 +12,8 @@ spec: url: http://127.0.0.1:8082/check expect: http: - status: 200 - body: '{"status":"ok"}' + status_code: 200 + body_json: '{"status":"ok"}' calls: - service_id: entitlements count: 1 diff --git a/cli/data/fixture-miss/fixture-miss-http-path.yml b/cli/data/fixture-miss/fixture-miss-http-path.yml index 60af79a..36ff5f0 100644 --- a/cli/data/fixture-miss/fixture-miss-http-path.yml +++ b/cli/data/fixture-miss/fixture-miss-http-path.yml @@ -11,25 +11,35 @@ summary: http: method: GET url: http://127.0.0.1:8082/check + headers: + "E2engine-Test-Execution-Id": + - "c1079d334b1a17b4a5fa7588a90d045ed01ea241c53ab51afa0d8b8620837e7b" response: http: status_code: 502 - body_text: dependency returned non-200 status + body_json: "dependency returned non-200 status\n" - expected_calls: + calls: - service_id: entitlements count: 1 http: method: GET path: /healthz + response_status_code: 501 + - service_id: gateway + count: 1 + http: + method: GET + path: /check + response_status_code: 502 deviations: - field: status_code expected: "200" actual: "502" - - field: body + - field: body_json expected: '{"status":"ok"}' actual: | dependency returned non-200 status diff --git a/cli/data/real-not-calling-dependency/real-not-calling-dependency.test.yml b/cli/data/real-not-calling-dependency/real-not-calling-dependency.test.yml index af037b1..ba64bc5 100644 --- a/cli/data/real-not-calling-dependency/real-not-calling-dependency.test.yml +++ b/cli/data/real-not-calling-dependency/real-not-calling-dependency.test.yml @@ -9,7 +9,7 @@ spec: url: http://127.0.0.1:8082/ok expect: http: - status: 200 + status_code: 200 calls: - service_id: dependency count: 1 diff --git a/cli/data/real-not-calling-dependency/real-not-calling-dependency.yml b/cli/data/real-not-calling-dependency/real-not-calling-dependency.yml index 26d0dd4..9ccd748 100644 --- a/cli/data/real-not-calling-dependency/real-not-calling-dependency.yml +++ b/cli/data/real-not-calling-dependency/real-not-calling-dependency.yml @@ -8,13 +8,3 @@ test_id: ae619f9418f89041a5f6e0e952eae9fb9495e2c271b66739ffd6fae46f9ff30a test_name: real-not-calling-dependency summary: error: "invalid test execution input, environment.service.id: dependency, validation: expected call references unknown environment service" - request: - http: - method: GET - url: http://127.0.0.1:8082/ok - expected_calls: - - service_id: dependency - count: 1 - http: - method: GET - path: /dependency diff --git a/cli/data/transport-kind/gateway-calls-entitlements.test.yml b/cli/data/transport-kind/gateway-calls-entitlements.test.yml index c52d91c..ef5301b 100644 --- a/cli/data/transport-kind/gateway-calls-entitlements.test.yml +++ b/cli/data/transport-kind/gateway-calls-entitlements.test.yml @@ -12,8 +12,8 @@ spec: url: http://127.0.0.1:8082/check expect: http: - status: 200 - body: '{"status":"ok"}' + status_code: 200 + body_json: '{"status":"ok"}' calls: - service_id: entitlements count: 1 diff --git a/cli/data/transport-kind/http-real-mocked.yml b/cli/data/transport-kind/http-real-mocked.yml index 75b80ff..11e46d3 100644 --- a/cli/data/transport-kind/http-real-mocked.yml +++ b/cli/data/transport-kind/http-real-mocked.yml @@ -11,13 +11,23 @@ summary: http: method: GET url: http://127.0.0.1:8082/check + headers: + "E2engine-Test-Execution-Id": + - "c1079d334b1a17b4a5fa7588a90d045ed01ea241c53ab51afa0d8b8620837e7b" response: http: status_code: 200 body_json: '{"status":"ok"}' - expected_calls: + calls: - service_id: entitlements count: 1 http: method: GET - path: /healthz \ No newline at end of file + path: /healthz + response_status_code: 200 + - service_id: gateway + count: 1 + http: + method: GET + path: /check + response_status_code: 200 \ No newline at end of file diff --git a/cli/data/transport-kind/real-with-mocked-dependency.env.yml b/cli/data/transport-kind/real-with-mocked-dependency.env.yml index b344382..8e950f7 100644 --- a/cli/data/transport-kind/real-with-mocked-dependency.env.yml +++ b/cli/data/transport-kind/real-with-mocked-dependency.env.yml @@ -20,8 +20,8 @@ spec: path: /healthz then: http: - status: 200 + status_code: 200 headers: Content-Type: - application/json - body: '{"status":"ok"}' \ No newline at end of file + body_json: '{"status":"ok"}' \ No newline at end of file diff --git a/cli/data/transport-kind/socket-grpc-error.yml b/cli/data/transport-kind/socket-grpc-error.yml index 197d64a..fe5208a 100644 --- a/cli/data/transport-kind/socket-grpc-error.yml +++ b/cli/data/transport-kind/socket-grpc-error.yml @@ -8,13 +8,3 @@ test_id: ae619f9418f89041a5f6e0e952eae9fb9495e2c271b66739ffd6fae46f9ff30a test_name: socket-grpc-error summary: error: "the specified path is inaccessible, file.path: ../services/ok-grpc/missing.proto, cause: stat ../services/ok-grpc/missing.proto: no such file or directory" - request: - grpc: - target: 127.0.0.1:8083 - service: ok.v1.OKService - method: OK - expected_calls: - - service_id: socket-grpc-error - grpc: - service: ok.v1.OKService - method: OK \ No newline at end of file diff --git a/cli/data/unknown-service-in-expected-calls/unknown-service-in-expected-calls.env.yml b/cli/data/unknown-service-in-expected-calls/unknown-service-in-expected-calls.env.yml index 4425bfd..e96bde2 100644 --- a/cli/data/unknown-service-in-expected-calls/unknown-service-in-expected-calls.env.yml +++ b/cli/data/unknown-service-in-expected-calls/unknown-service-in-expected-calls.env.yml @@ -15,4 +15,4 @@ spec: path: /healthz then: http: - status: 200 + status_code: 200 diff --git a/cli/data/unknown-service-in-expected-calls/unknown-service-in-expected-calls.test.yml b/cli/data/unknown-service-in-expected-calls/unknown-service-in-expected-calls.test.yml index 04a00e9..4b722a6 100644 --- a/cli/data/unknown-service-in-expected-calls/unknown-service-in-expected-calls.test.yml +++ b/cli/data/unknown-service-in-expected-calls/unknown-service-in-expected-calls.test.yml @@ -9,7 +9,7 @@ spec: url: http://127.0.0.1:8083/healthz expect: http: - status: 200 + status_code: 200 calls: - service_id: not-called count: 1 diff --git a/cli/data/unknown-service-in-expected-calls/unknown-service-in-expected-calls.yml b/cli/data/unknown-service-in-expected-calls/unknown-service-in-expected-calls.yml index 40ac871..daf4522 100644 --- a/cli/data/unknown-service-in-expected-calls/unknown-service-in-expected-calls.yml +++ b/cli/data/unknown-service-in-expected-calls/unknown-service-in-expected-calls.yml @@ -8,13 +8,3 @@ test_id: ae619f9418f89041a5f6e0e952eae9fb9495e2c271b66739ffd6fae46f9ff30a test_name: unknown-service-in-expected-calls summary: error: "invalid test execution input, environment.service.id: not-called, validation: expected call references unknown environment service" - request: - http: - method: GET - url: http://127.0.0.1:8083/healthz - expected_calls: - - service_id: not-called - count: 1 - http: - method: GET - path: /healthz diff --git a/cli/data/validate-environment/grpc-fixture-empty-method.yml b/cli/data/validate-environment/grpc-fixture-empty-method.yml index 91dd95a..eabfc3f 100644 --- a/cli/data/validate-environment/grpc-fixture-empty-method.yml +++ b/cli/data/validate-environment/grpc-fixture-empty-method.yml @@ -19,6 +19,7 @@ spec: fixtures: - when: grpc: + service: Service method: "" then: grpc: diff --git a/cli/data/validate-environment/grpc-fixture-invalid-status.yml b/cli/data/validate-environment/grpc-fixture-invalid-status.yml index 1dde9af..4b8c6b8 100644 --- a/cli/data/validate-environment/grpc-fixture-invalid-status.yml +++ b/cli/data/validate-environment/grpc-fixture-invalid-status.yml @@ -19,6 +19,7 @@ spec: fixtures: - when: grpc: + service: Service method: Call then: grpc: diff --git a/cli/data/validate-environment/grpc-fixture-missing-grpc-then.yml b/cli/data/validate-environment/grpc-fixture-missing-grpc-then.yml index aa51c30..8c23b76 100644 --- a/cli/data/validate-environment/grpc-fixture-missing-grpc-then.yml +++ b/cli/data/validate-environment/grpc-fixture-missing-grpc-then.yml @@ -18,5 +18,6 @@ spec: fixtures: - when: grpc: + service: TestService method: Check then: {} \ No newline at end of file diff --git a/cli/data/validate-environment/grpc-fixture-on-http-service.yml b/cli/data/validate-environment/grpc-fixture-on-http-service.yml index 5f46254..d531c60 100644 --- a/cli/data/validate-environment/grpc-fixture-on-http-service.yml +++ b/cli/data/validate-environment/grpc-fixture-on-http-service.yml @@ -15,9 +15,10 @@ spec: method: GET path: /healthz grpc: + service: Service method: Check then: http: - status: 200 + status_code: 200 grpc: status: OK \ No newline at end of file diff --git a/cli/data/validate-environment/grpc-internal-empty-field-name.yml b/cli/data/validate-environment/grpc-internal-empty-field-name.yml index 4a94273..942be53 100644 --- a/cli/data/validate-environment/grpc-internal-empty-field-name.yml +++ b/cli/data/validate-environment/grpc-internal-empty-field-name.yml @@ -22,6 +22,7 @@ spec: fixtures: - when: grpc: + service: Service method: Call then: grpc: diff --git a/cli/data/validate-environment/grpc-internal-empty-method-name.yml b/cli/data/validate-environment/grpc-internal-empty-method-name.yml index 54812b6..6cfb6d2 100644 --- a/cli/data/validate-environment/grpc-internal-empty-method-name.yml +++ b/cli/data/validate-environment/grpc-internal-empty-method-name.yml @@ -19,6 +19,7 @@ spec: fixtures: - when: grpc: + service: Service method: Call then: grpc: diff --git a/cli/data/validate-environment/grpc-internal-empty-package.yml b/cli/data/validate-environment/grpc-internal-empty-package.yml index f8b3815..097683f 100644 --- a/cli/data/validate-environment/grpc-internal-empty-package.yml +++ b/cli/data/validate-environment/grpc-internal-empty-package.yml @@ -19,6 +19,7 @@ spec: fixtures: - when: grpc: + service: Service method: Call then: grpc: diff --git a/cli/data/validate-environment/grpc-internal-empty-service.yml b/cli/data/validate-environment/grpc-internal-empty-service.yml index 8586963..455017f 100644 --- a/cli/data/validate-environment/grpc-internal-empty-service.yml +++ b/cli/data/validate-environment/grpc-internal-empty-service.yml @@ -19,6 +19,7 @@ spec: fixtures: - when: grpc: + service: Service method: Call then: grpc: diff --git a/cli/data/validate-environment/grpc-internal-invalid-field-type.yml b/cli/data/validate-environment/grpc-internal-invalid-field-type.yml index 7d91fa7..0e25d1c 100644 --- a/cli/data/validate-environment/grpc-internal-invalid-field-type.yml +++ b/cli/data/validate-environment/grpc-internal-invalid-field-type.yml @@ -22,6 +22,7 @@ spec: fixtures: - when: grpc: + service: Service method: Call then: grpc: diff --git a/cli/data/validate-environment/grpc-internal-without-methods.yml b/cli/data/validate-environment/grpc-internal-without-methods.yml index 6669271..975eddd 100644 --- a/cli/data/validate-environment/grpc-internal-without-methods.yml +++ b/cli/data/validate-environment/grpc-internal-without-methods.yml @@ -18,6 +18,7 @@ spec: fixtures: - when: grpc: + service: OKService method: OK then: grpc: diff --git a/cli/data/validate-environment/grpc-proto-both-external-and-internal.yml b/cli/data/validate-environment/grpc-proto-both-external-and-internal.yml index 5966a75..e56bbb6 100644 --- a/cli/data/validate-environment/grpc-proto-both-external-and-internal.yml +++ b/cli/data/validate-environment/grpc-proto-both-external-and-internal.yml @@ -24,6 +24,7 @@ spec: fixtures: - when: grpc: + service: OKService method: OK then: grpc: diff --git a/cli/data/validate-environment/grpc-proto-neither-external-nor-internal.yml b/cli/data/validate-environment/grpc-proto-neither-external-nor-internal.yml index bc213f6..ac7a0d3 100644 --- a/cli/data/validate-environment/grpc-proto-neither-external-nor-internal.yml +++ b/cli/data/validate-environment/grpc-proto-neither-external-nor-internal.yml @@ -14,6 +14,7 @@ spec: fixtures: - when: grpc: + service: OKService method: OK then: grpc: diff --git a/cli/data/validate-environment/http-fixture-empty-path.yml b/cli/data/validate-environment/http-fixture-empty-path.yml index bd9f6d3..d530410 100644 --- a/cli/data/validate-environment/http-fixture-empty-path.yml +++ b/cli/data/validate-environment/http-fixture-empty-path.yml @@ -16,4 +16,4 @@ spec: path: "" then: http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-environment/http-fixture-invalid-method.yml b/cli/data/validate-environment/http-fixture-invalid-method.yml index 54f5b6f..c7d452c 100644 --- a/cli/data/validate-environment/http-fixture-invalid-method.yml +++ b/cli/data/validate-environment/http-fixture-invalid-method.yml @@ -16,4 +16,4 @@ spec: path: /healthz then: http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-environment/http-fixture-invalid-request-json.yml b/cli/data/validate-environment/http-fixture-invalid-request-json.yml index f17cb9f..416ef00 100644 --- a/cli/data/validate-environment/http-fixture-invalid-request-json.yml +++ b/cli/data/validate-environment/http-fixture-invalid-request-json.yml @@ -14,7 +14,7 @@ spec: http: method: POST path: /check - body: '{"broken":' + body_json: '{"broken":' then: http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-environment/http-fixture-invalid-response-json.yml b/cli/data/validate-environment/http-fixture-invalid-response-json.yml index 25a0a51..13c111f 100644 --- a/cli/data/validate-environment/http-fixture-invalid-response-json.yml +++ b/cli/data/validate-environment/http-fixture-invalid-response-json.yml @@ -16,5 +16,5 @@ spec: path: /healthz then: http: - status: 200 - body: '{"broken":' \ No newline at end of file + status_code: 200 + body_json: '{"broken":' \ No newline at end of file diff --git a/cli/data/validate-environment/http-fixture-missing-http-when.yml b/cli/data/validate-environment/http-fixture-missing-http-when.yml index ce8f1dc..6a35861 100644 --- a/cli/data/validate-environment/http-fixture-missing-http-when.yml +++ b/cli/data/validate-environment/http-fixture-missing-http-when.yml @@ -13,4 +13,4 @@ spec: - when: {} then: http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-environment/http-fixture-on-grpc-service.yml b/cli/data/validate-environment/http-fixture-on-grpc-service.yml index 4b522a6..72604a6 100644 --- a/cli/data/validate-environment/http-fixture-on-grpc-service.yml +++ b/cli/data/validate-environment/http-fixture-on-grpc-service.yml @@ -18,6 +18,7 @@ spec: fixtures: - when: grpc: + service: TestService method: Check http: method: GET @@ -26,4 +27,4 @@ spec: grpc: status: OK http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-environment/mocked-with-target.yml b/cli/data/validate-environment/mocked-with-target.yml index 17def0a..009ceac 100644 --- a/cli/data/validate-environment/mocked-with-target.yml +++ b/cli/data/validate-environment/mocked-with-target.yml @@ -17,4 +17,4 @@ spec: path: /healthz then: http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-environment/real-http-with-fixtures.yml b/cli/data/validate-environment/real-http-with-fixtures.yml index 3178a94..6236dcd 100644 --- a/cli/data/validate-environment/real-http-with-fixtures.yml +++ b/cli/data/validate-environment/real-http-with-fixtures.yml @@ -17,4 +17,4 @@ spec: path: /healthz then: http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-expected-calls/expected-call-unknown-service.env.yml b/cli/data/validate-expected-calls/expected-call-unknown-service.env.yml index 2fd9abb..566879a 100644 --- a/cli/data/validate-expected-calls/expected-call-unknown-service.env.yml +++ b/cli/data/validate-expected-calls/expected-call-unknown-service.env.yml @@ -16,4 +16,4 @@ spec: path: /healthz then: http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-expected-calls/expected-call-unknown-service.test.yml b/cli/data/validate-expected-calls/expected-call-unknown-service.test.yml index 3d0d3e4..f9d2311 100644 --- a/cli/data/validate-expected-calls/expected-call-unknown-service.test.yml +++ b/cli/data/validate-expected-calls/expected-call-unknown-service.test.yml @@ -11,7 +11,7 @@ spec: expect: http: - status: 200 + status_code: 200 calls: - service_id: missing-service diff --git a/cli/data/validate-expected-calls/expected-call-unknown-service.yml b/cli/data/validate-expected-calls/expected-call-unknown-service.yml index c7a9db3..3a5bf77 100644 --- a/cli/data/validate-expected-calls/expected-call-unknown-service.yml +++ b/cli/data/validate-expected-calls/expected-call-unknown-service.yml @@ -8,12 +8,3 @@ test_id: ae619f9418f89041a5f6e0e952eae9fb9495e2c271b66739ffd6fae46f9ff30a test_name: expected-call-unknown-service summary: error: "invalid test execution input, environment.service.id: missing-service, validation: expected call references unknown environment service" - request: - http: - method: GET - url: http://127.0.0.1:8082/healthz - expected_calls: - - service_id: missing-service - http: - method: GET - path: /healthz diff --git a/cli/data/validate-expected-calls/expected-calls-twice.env.yml b/cli/data/validate-expected-calls/expected-calls-twice.env.yml index 4e76353..acac561 100644 --- a/cli/data/validate-expected-calls/expected-calls-twice.env.yml +++ b/cli/data/validate-expected-calls/expected-calls-twice.env.yml @@ -15,4 +15,4 @@ spec: path: /healthz then: http: - status: 200 + status_code: 200 diff --git a/cli/data/validate-expected-calls/expected-calls-twice.test.yml b/cli/data/validate-expected-calls/expected-calls-twice.test.yml index 90be189..09f160a 100644 --- a/cli/data/validate-expected-calls/expected-calls-twice.test.yml +++ b/cli/data/validate-expected-calls/expected-calls-twice.test.yml @@ -9,7 +9,7 @@ spec: url: http://127.0.0.1:8083/healthz expect: http: - status: 200 + status_code: 200 calls: - service_id: expected-calls-twice count: 2 diff --git a/cli/data/validate-expected-calls/expected-calls-twice.yml b/cli/data/validate-expected-calls/expected-calls-twice.yml index e549b07..51d7fa8 100644 --- a/cli/data/validate-expected-calls/expected-calls-twice.yml +++ b/cli/data/validate-expected-calls/expected-calls-twice.yml @@ -11,15 +11,19 @@ summary: http: method: GET url: http://127.0.0.1:8083/healthz + headers: + "E2engine-Test-Execution-Id": + - "c1079d334b1a17b4a5fa7588a90d045ed01ea241c53ab51afa0d8b8620837e7b" response: http: status_code: 200 - expected_calls: + calls: - service_id: expected-calls-twice - count: 2 + count: 1 http: method: GET path: /healthz + response_status_code: 200 deviations: - field: calls.expected-calls-twice.count expected: "2" diff --git a/cli/data/validate-expected-calls/expected-grpc-call-to-http-service.env.yml b/cli/data/validate-expected-calls/expected-grpc-call-to-http-service.env.yml index 52c6600..60a2011 100644 --- a/cli/data/validate-expected-calls/expected-grpc-call-to-http-service.env.yml +++ b/cli/data/validate-expected-calls/expected-grpc-call-to-http-service.env.yml @@ -16,4 +16,4 @@ spec: path: /healthz then: http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-expected-calls/expected-grpc-call-to-http-service.test.yml b/cli/data/validate-expected-calls/expected-grpc-call-to-http-service.test.yml index 88b670f..dadd2aa 100644 --- a/cli/data/validate-expected-calls/expected-grpc-call-to-http-service.test.yml +++ b/cli/data/validate-expected-calls/expected-grpc-call-to-http-service.test.yml @@ -11,7 +11,7 @@ spec: expect: http: - status: 200 + status_code: 200 calls: - service_id: http-dependency diff --git a/cli/data/validate-expected-calls/expected-grpc-call-to-http-service.yml b/cli/data/validate-expected-calls/expected-grpc-call-to-http-service.yml index 7b0f9e1..3156e63 100644 --- a/cli/data/validate-expected-calls/expected-grpc-call-to-http-service.yml +++ b/cli/data/validate-expected-calls/expected-grpc-call-to-http-service.yml @@ -8,12 +8,3 @@ test_id: ae619f9418f89041a5f6e0e952eae9fb9495e2c271b66739ffd6fae46f9ff30a test_name: expected-grpc-call-to-http-service summary: error: "invalid test execution input, environment.service.id: http-dependency, environment.service.kind: http, validation: expected gRPC call references non-gRPC service" - request: - http: - method: GET - url: http://127.0.0.1:8082/healthz - expected_calls: - - service_id: http-dependency - grpc: - service: example.Dependency - method: Check diff --git a/cli/data/validate-expected-calls/expected-http-call-to-grpc-service.env.yml b/cli/data/validate-expected-calls/expected-http-call-to-grpc-service.env.yml index 54ea4cf..c807321 100644 --- a/cli/data/validate-expected-calls/expected-http-call-to-grpc-service.env.yml +++ b/cli/data/validate-expected-calls/expected-http-call-to-grpc-service.env.yml @@ -16,7 +16,7 @@ spec: path: /healthz then: http: - status: 200 + status_code: 200 - id: grpc-dependency kind: grpc @@ -31,6 +31,7 @@ spec: fixtures: - when: grpc: + service: example.Dependency method: Check then: grpc: diff --git a/cli/data/validate-expected-calls/expected-http-call-to-grpc-service.test.yml b/cli/data/validate-expected-calls/expected-http-call-to-grpc-service.test.yml index cdbbab4..aa1756e 100644 --- a/cli/data/validate-expected-calls/expected-http-call-to-grpc-service.test.yml +++ b/cli/data/validate-expected-calls/expected-http-call-to-grpc-service.test.yml @@ -11,7 +11,7 @@ spec: expect: http: - status: 200 + status_code: 200 calls: - service_id: grpc-dependency diff --git a/cli/data/validate-expected-calls/expected-http-call-to-grpc-service.yml b/cli/data/validate-expected-calls/expected-http-call-to-grpc-service.yml index 817a194..32e9947 100644 --- a/cli/data/validate-expected-calls/expected-http-call-to-grpc-service.yml +++ b/cli/data/validate-expected-calls/expected-http-call-to-grpc-service.yml @@ -8,12 +8,3 @@ test_id: ae619f9418f89041a5f6e0e952eae9fb9495e2c271b66739ffd6fae46f9ff30a test_name: expected-http-call-to-grpc-service summary: error: "invalid test execution input, environment.service.id: grpc-dependency, environment.service.kind: grpc, validation: expected HTTP call references non-HTTP service" - request: - http: - method: GET - url: http://127.0.0.1:8082/healthz - expected_calls: - - service_id: grpc-dependency - http: - method: GET - path: /healthz diff --git a/cli/data/validate-expected-calls/wrong-call-params.env.yml b/cli/data/validate-expected-calls/wrong-call-params.env.yml index 2b6d797..8f67947 100644 --- a/cli/data/validate-expected-calls/wrong-call-params.env.yml +++ b/cli/data/validate-expected-calls/wrong-call-params.env.yml @@ -15,4 +15,4 @@ spec: path: /healthz then: http: - status: 200 + status_code: 200 diff --git a/cli/data/validate-expected-calls/wrong-call-params.test.yml b/cli/data/validate-expected-calls/wrong-call-params.test.yml index c3de3d8..c2a39a5 100644 --- a/cli/data/validate-expected-calls/wrong-call-params.test.yml +++ b/cli/data/validate-expected-calls/wrong-call-params.test.yml @@ -9,7 +9,7 @@ spec: url: http://127.0.0.1:8083/healthz expect: http: - status: 201 + status_code: 201 calls: - service_id: wrong-call-params count: 1 diff --git a/cli/data/validate-expected-calls/wrong-call-params.yml b/cli/data/validate-expected-calls/wrong-call-params.yml index 4a19c58..0a7c0b5 100644 --- a/cli/data/validate-expected-calls/wrong-call-params.yml +++ b/cli/data/validate-expected-calls/wrong-call-params.yml @@ -11,15 +11,19 @@ summary: http: method: GET url: http://127.0.0.1:8083/healthz + headers: + "E2engine-Test-Execution-Id": + - "c1079d334b1a17b4a5fa7588a90d045ed01ea241c53ab51afa0d8b8620837e7b" response: http: status_code: 200 - expected_calls: + calls: - service_id: wrong-call-params count: 1 http: - method: POST + method: GET path: /healthz + response_status_code: 200 deviations: - field: status_code expected: "201" diff --git a/cli/data/validate-test/call-count-omitted-valid.yml b/cli/data/validate-test/call-count-omitted-valid.yml index 375dd61..52f120c 100644 --- a/cli/data/validate-test/call-count-omitted-valid.yml +++ b/cli/data/validate-test/call-count-omitted-valid.yml @@ -10,7 +10,7 @@ spec: expect: http: - status: 200 + status_code: 200 calls: - service_id: dependency diff --git a/cli/data/validate-test/call-count-zero.yml b/cli/data/validate-test/call-count-zero.yml index 82e76ac..bef4800 100644 --- a/cli/data/validate-test/call-count-zero.yml +++ b/cli/data/validate-test/call-count-zero.yml @@ -10,7 +10,7 @@ spec: expect: http: - status: 200 + status_code: 200 calls: - service_id: dependency diff --git a/cli/data/validate-test/call-http-and-grpc.yml b/cli/data/validate-test/call-http-and-grpc.yml index d1dc630..13cbd65 100644 --- a/cli/data/validate-test/call-http-and-grpc.yml +++ b/cli/data/validate-test/call-http-and-grpc.yml @@ -10,7 +10,7 @@ spec: expect: http: - status: 200 + status_code: 200 calls: - service_id: dependency diff --git a/cli/data/validate-test/call-http-empty-path.yml b/cli/data/validate-test/call-http-empty-path.yml index de81c6e..ce6360a 100644 --- a/cli/data/validate-test/call-http-empty-path.yml +++ b/cli/data/validate-test/call-http-empty-path.yml @@ -10,7 +10,7 @@ spec: expect: http: - status: 200 + status_code: 200 calls: - service_id: dependency diff --git a/cli/data/validate-test/call-http-invalid-json.yml b/cli/data/validate-test/call-http-invalid-json.yml index 7e27274..6b5436f 100644 --- a/cli/data/validate-test/call-http-invalid-json.yml +++ b/cli/data/validate-test/call-http-invalid-json.yml @@ -10,11 +10,11 @@ spec: expect: http: - status: 200 + status_code: 200 calls: - service_id: dependency http: method: POST path: /check - body: '{"broken":' \ No newline at end of file + body_json: '{"broken":' \ No newline at end of file diff --git a/cli/data/validate-test/call-http-invalid-method.yml b/cli/data/validate-test/call-http-invalid-method.yml index 3a3f722..e6c38df 100644 --- a/cli/data/validate-test/call-http-invalid-method.yml +++ b/cli/data/validate-test/call-http-invalid-method.yml @@ -10,7 +10,7 @@ spec: expect: http: - status: 200 + status_code: 200 calls: - service_id: dependency diff --git a/cli/data/validate-test/call-negative-count.yml b/cli/data/validate-test/call-negative-count.yml index cf8bdce..fe74c17 100644 --- a/cli/data/validate-test/call-negative-count.yml +++ b/cli/data/validate-test/call-negative-count.yml @@ -10,7 +10,7 @@ spec: expect: http: - status: 200 + status_code: 200 calls: - service_id: dependency diff --git a/cli/data/validate-test/call-no-protocol.yml b/cli/data/validate-test/call-no-protocol.yml index 0a34002..f8924e6 100644 --- a/cli/data/validate-test/call-no-protocol.yml +++ b/cli/data/validate-test/call-no-protocol.yml @@ -10,7 +10,7 @@ spec: expect: http: - status: 200 + status_code: 200 calls: - service_id: dependency diff --git a/cli/data/validate-test/call-service-id-too-long.yml b/cli/data/validate-test/call-service-id-too-long.yml index afd9d08..d89b82a 100644 --- a/cli/data/validate-test/call-service-id-too-long.yml +++ b/cli/data/validate-test/call-service-id-too-long.yml @@ -10,7 +10,7 @@ spec: expect: http: - status: 200 + status_code: 200 calls: - service_id: abaaaaaaaaaaaaabaaaaaaaaaaaaabaaaaaaaaaaaaabaaaaaaaaaaaaabaaaaaaaaaaaaabaaaaaaaaaaaaabaaaaaaaaaaaaabaaaaaaaaaaaaabaaaaaaaaaaaaabaaaaaaaaaaaaabaaaaaaaaaaaaabaaaaaaaaaaaaabaaaaaaaaaaaaabaaaaaaaaaaaaaaaaa diff --git a/cli/data/validate-test/call-service-id-too-short.yml b/cli/data/validate-test/call-service-id-too-short.yml index 9c30714..1d40b70 100644 --- a/cli/data/validate-test/call-service-id-too-short.yml +++ b/cli/data/validate-test/call-service-id-too-short.yml @@ -10,7 +10,7 @@ spec: expect: http: - status: 200 + status_code: 200 calls: - service_id: ab diff --git a/cli/data/validate-test/duplicate-tag.yml b/cli/data/validate-test/duplicate-tag.yml index 15b5b33..cef6954 100644 --- a/cli/data/validate-test/duplicate-tag.yml +++ b/cli/data/validate-test/duplicate-tag.yml @@ -14,4 +14,4 @@ spec: expect: http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-test/empty-tag.yml b/cli/data/validate-test/empty-tag.yml index 14269be..5ced86a 100644 --- a/cli/data/validate-test/empty-tag.yml +++ b/cli/data/validate-test/empty-tag.yml @@ -13,4 +13,4 @@ spec: expect: http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-test/expect-http-and-grpc.yml b/cli/data/validate-test/expect-http-and-grpc.yml index a1a1988..7f5fec5 100644 --- a/cli/data/validate-test/expect-http-and-grpc.yml +++ b/cli/data/validate-test/expect-http-and-grpc.yml @@ -10,6 +10,6 @@ spec: expect: http: - status: 200 + status_code: 200 grpc: status: OK \ No newline at end of file diff --git a/cli/data/validate-test/grpc-call-all-optional-fields-valid.yml b/cli/data/validate-test/grpc-call-all-optional-fields-valid.yml index 39dc8cd..82d9a13 100644 --- a/cli/data/validate-test/grpc-call-all-optional-fields-valid.yml +++ b/cli/data/validate-test/grpc-call-all-optional-fields-valid.yml @@ -21,5 +21,4 @@ spec: metadata: authorization: - token - message: - value: test \ No newline at end of file + message: '{"value": "test"}' \ No newline at end of file diff --git a/cli/data/validate-test/grpc-expect-message-valid.yml b/cli/data/validate-test/grpc-expect-message-valid.yml index 88cb62e..1c67dcc 100644 --- a/cli/data/validate-test/grpc-expect-message-valid.yml +++ b/cli/data/validate-test/grpc-expect-message-valid.yml @@ -12,5 +12,4 @@ spec: expect: grpc: status: OK - message: - value: test \ No newline at end of file + message: '{"value": "test"}' \ No newline at end of file diff --git a/cli/data/validate-test/http-call-all-optional-fields-valid.yml b/cli/data/validate-test/http-call-all-optional-fields-valid.yml index e0f5b86..0d4b78b 100644 --- a/cli/data/validate-test/http-call-all-optional-fields-valid.yml +++ b/cli/data/validate-test/http-call-all-optional-fields-valid.yml @@ -10,7 +10,7 @@ spec: expect: http: - status: 200 + status_code: 200 calls: - service_id: dependency count: 1 @@ -23,4 +23,4 @@ spec: headers: Content-Type: - application/json - body: '{"value":"test"}' \ No newline at end of file + body_json: '{"value":"test"}' \ No newline at end of file diff --git a/cli/data/validate-test/http-expect-invalid-json.yml b/cli/data/validate-test/http-expect-invalid-json.yml index a6b8fd5..52e6d8c 100644 --- a/cli/data/validate-test/http-expect-invalid-json.yml +++ b/cli/data/validate-test/http-expect-invalid-json.yml @@ -10,5 +10,5 @@ spec: expect: http: - status: 200 - body: '{"broken":' \ No newline at end of file + status_code: 200 + body_json: '{"broken":' \ No newline at end of file diff --git a/cli/data/validate-test/http-expect-status-max.yml b/cli/data/validate-test/http-expect-status-max.yml index 5faa6a8..9f8996f 100644 --- a/cli/data/validate-test/http-expect-status-max.yml +++ b/cli/data/validate-test/http-expect-status-max.yml @@ -10,4 +10,4 @@ spec: expect: http: - status: 599 \ No newline at end of file + status_code: 599 \ No newline at end of file diff --git a/cli/data/validate-test/http-expect-status-min.yml b/cli/data/validate-test/http-expect-status-min.yml index 1afc6b8..2cf3672 100644 --- a/cli/data/validate-test/http-expect-status-min.yml +++ b/cli/data/validate-test/http-expect-status-min.yml @@ -10,4 +10,4 @@ spec: expect: http: - status: 100 \ No newline at end of file + status_code: 100 \ No newline at end of file diff --git a/cli/data/validate-test/http-expect-status-too-high.yml b/cli/data/validate-test/http-expect-status-too-high.yml index 14d5025..34b6fd2 100644 --- a/cli/data/validate-test/http-expect-status-too-high.yml +++ b/cli/data/validate-test/http-expect-status-too-high.yml @@ -10,4 +10,4 @@ spec: expect: http: - status: 600 \ No newline at end of file + status_code: 600 \ No newline at end of file diff --git a/cli/data/validate-test/http-expect-status-too-low.yml b/cli/data/validate-test/http-expect-status-too-low.yml index 3c85a49..c218529 100644 --- a/cli/data/validate-test/http-expect-status-too-low.yml +++ b/cli/data/validate-test/http-expect-status-too-low.yml @@ -10,4 +10,4 @@ spec: expect: http: - status: 99 \ No newline at end of file + status_code: 99 \ No newline at end of file diff --git a/cli/data/validate-test/http-expect-valid-json-null.yml b/cli/data/validate-test/http-expect-valid-json-null.yml index 2bd258f..998f6ec 100644 --- a/cli/data/validate-test/http-expect-valid-json-null.yml +++ b/cli/data/validate-test/http-expect-valid-json-null.yml @@ -10,5 +10,5 @@ spec: expect: http: - status: 200 - body: 'null' \ No newline at end of file + status_code: 200 + body_json: 'null' \ No newline at end of file diff --git a/cli/data/validate-test/http-request-all-optional-fields-valid.yml b/cli/data/validate-test/http-request-all-optional-fields-valid.yml index 84745f7..5e0ebc3 100644 --- a/cli/data/validate-test/http-request-all-optional-fields-valid.yml +++ b/cli/data/validate-test/http-request-all-optional-fields-valid.yml @@ -8,12 +8,13 @@ spec: method: POST url: http://localhost/test query: - key: value + key: + - value headers: Content-Type: - application/json - body: '{"value":"test"}' + body_json: '{"value":"test"}' expect: http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-test/http-request-empty-url.yml b/cli/data/validate-test/http-request-empty-url.yml index c0d7b86..62fd8ee 100644 --- a/cli/data/validate-test/http-request-empty-url.yml +++ b/cli/data/validate-test/http-request-empty-url.yml @@ -10,4 +10,4 @@ spec: expect: http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-test/http-request-invalid-json.yml b/cli/data/validate-test/http-request-invalid-json.yml index cedbe33..8cf9772 100644 --- a/cli/data/validate-test/http-request-invalid-json.yml +++ b/cli/data/validate-test/http-request-invalid-json.yml @@ -7,8 +7,8 @@ spec: http: method: POST url: http://127.0.0.1:8080/check - body: '{"broken":' + body_json: '{"broken":' expect: http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-test/http-request-invalid-method.yml b/cli/data/validate-test/http-request-invalid-method.yml index 61a1ef5..e322222 100644 --- a/cli/data/validate-test/http-request-invalid-method.yml +++ b/cli/data/validate-test/http-request-invalid-method.yml @@ -10,4 +10,4 @@ spec: expect: http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-test/http-request-invalid-scheme.yml b/cli/data/validate-test/http-request-invalid-scheme.yml index 975ddd6..69c1b66 100644 --- a/cli/data/validate-test/http-request-invalid-scheme.yml +++ b/cli/data/validate-test/http-request-invalid-scheme.yml @@ -10,4 +10,4 @@ spec: expect: http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-test/http-request-invalid-url.yml b/cli/data/validate-test/http-request-invalid-url.yml index 962f93b..76d4e37 100644 --- a/cli/data/validate-test/http-request-invalid-url.yml +++ b/cli/data/validate-test/http-request-invalid-url.yml @@ -10,4 +10,4 @@ spec: expect: http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-test/http-request-no-host.yml b/cli/data/validate-test/http-request-no-host.yml index c775098..3fafedd 100644 --- a/cli/data/validate-test/http-request-no-host.yml +++ b/cli/data/validate-test/http-request-no-host.yml @@ -10,4 +10,4 @@ spec: expect: http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-test/http-request-valid-json-array.yml b/cli/data/validate-test/http-request-valid-json-array.yml index bb0da5b..a956dcd 100644 --- a/cli/data/validate-test/http-request-valid-json-array.yml +++ b/cli/data/validate-test/http-request-valid-json-array.yml @@ -11,4 +11,4 @@ spec: expect: http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-test/http-request-valid-json-scalar.yml b/cli/data/validate-test/http-request-valid-json-scalar.yml index 165958b..bf1712f 100644 --- a/cli/data/validate-test/http-request-valid-json-scalar.yml +++ b/cli/data/validate-test/http-request-valid-json-scalar.yml @@ -11,4 +11,4 @@ spec: expect: http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-test/http-url-http.yml b/cli/data/validate-test/http-url-http.yml index 2c3fdb1..3bd8502 100644 --- a/cli/data/validate-test/http-url-http.yml +++ b/cli/data/validate-test/http-url-http.yml @@ -10,4 +10,4 @@ spec: expect: http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-test/http-url-https.yml b/cli/data/validate-test/http-url-https.yml index 5ba54fc..b6f2210 100644 --- a/cli/data/validate-test/http-url-https.yml +++ b/cli/data/validate-test/http-url-https.yml @@ -10,4 +10,4 @@ spec: expect: http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-test/request-http-and-grpc.yml b/cli/data/validate-test/request-http-and-grpc.yml index 7e6f73d..0797b7e 100644 --- a/cli/data/validate-test/request-http-and-grpc.yml +++ b/cli/data/validate-test/request-http-and-grpc.yml @@ -15,4 +15,4 @@ spec: expect: http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-test/request-missing.yml b/cli/data/validate-test/request-missing.yml index e101719..1052d64 100644 --- a/cli/data/validate-test/request-missing.yml +++ b/cli/data/validate-test/request-missing.yml @@ -6,4 +6,4 @@ spec: request: {} expect: http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-test/service-id-max-length.yml b/cli/data/validate-test/service-id-max-length.yml index e0a25f0..cc3ac4d 100644 --- a/cli/data/validate-test/service-id-max-length.yml +++ b/cli/data/validate-test/service-id-max-length.yml @@ -10,7 +10,7 @@ spec: expect: http: - status: 200 + status_code: 200 calls: - service_id: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa diff --git a/cli/data/validate-test/service-id-min-length.yml b/cli/data/validate-test/service-id-min-length.yml index 24531e5..dfe9a7e 100644 --- a/cli/data/validate-test/service-id-min-length.yml +++ b/cli/data/validate-test/service-id-min-length.yml @@ -10,7 +10,7 @@ spec: expect: http: - status: 200 + status_code: 200 calls: - service_id: abc diff --git a/cli/data/validate-test/tag-max-length.yml b/cli/data/validate-test/tag-max-length.yml index 6b17309..dadc8a6 100644 --- a/cli/data/validate-test/tag-max-length.yml +++ b/cli/data/validate-test/tag-max-length.yml @@ -13,4 +13,4 @@ spec: expect: http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-test/tag-min-length.yml b/cli/data/validate-test/tag-min-length.yml index 4306728..3f1c3af 100644 --- a/cli/data/validate-test/tag-min-length.yml +++ b/cli/data/validate-test/tag-min-length.yml @@ -13,4 +13,4 @@ spec: expect: http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-test/tag-too-long.yml b/cli/data/validate-test/tag-too-long.yml index fa8705a..aba8416 100644 --- a/cli/data/validate-test/tag-too-long.yml +++ b/cli/data/validate-test/tag-too-long.yml @@ -13,4 +13,4 @@ spec: expect: http: - status: 200 \ No newline at end of file + status_code: 200 \ No newline at end of file diff --git a/cli/tests/called_at_least_once_test.go b/cli/tests/called_at_least_once_test.go index 3a1a649..9db6d90 100644 --- a/cli/tests/called_at_least_once_test.go +++ b/cli/tests/called_at_least_once_test.go @@ -5,26 +5,38 @@ import ( "path" "testing" - "github.com/e2engine/core/model" - "github.com/e2engine/tests/cli/harness" - "github.com/e2engine/tests/util" ) func TestServiceCalledAtLeastOnce(t *testing.T) { dataDir := "../data/called-at-least-once" tests := []struct { - name string + name string + checkParams func(id string) *checkTestExecutionParams }{ { name: "minimal-mocked-called-at-least-once", + checkParams: func(id string) *checkTestExecutionParams { + return &checkTestExecutionParams{ + useHTTPRequestHeaders: map[string]string{ + "E2engine-Test-Execution-Id": id, + }, + } + }, }, { - name: "misspelled-called-at-least-once", + name: "misspelled-fails-validation", }, { name: "one-of-two-mocked-not-called", + checkParams: func(id string) *checkTestExecutionParams { + return &checkTestExecutionParams{ + useHTTPRequestHeaders: map[string]string{ + "E2engine-Test-Execution-Id": id, + }, + } + }, }, } @@ -62,17 +74,20 @@ func TestServiceCalledAtLeastOnce(t *testing.T) { // get testexecution by ID actualTestExecution := h.GetTestExecution(ctx, testExecutionID) - expectedTestExecution := util.Load[model.TestExecution]( + if test.checkParams == nil { + test.checkParams = func(id string) *checkTestExecutionParams { + return nil + } + } + checkTestExecution( t, + testExecutionID, + environmentID, + testID, path.Join(dataDir, test.name+".yml"), + &actualTestExecution, + test.checkParams(testExecutionID), ) - expectedTestExecution.ID = testExecutionID - expectedTestExecution.TestID = testID - expectedTestExecution.EnvironmentID = environmentID - expectedTestExecution.StartedAt = actualTestExecution.StartedAt - expectedTestExecution.FinishedAt = actualTestExecution.FinishedAt - - util.AssertEqualTestExecutions(t, &expectedTestExecution, &actualTestExecution) }) } } diff --git a/cli/tests/crud_test_test.go b/cli/tests/crud_test_test.go index 7fe9e27..509eae5 100644 --- a/cli/tests/crud_test_test.go +++ b/cli/tests/crud_test_test.go @@ -101,6 +101,7 @@ func TestCRUDTest(t *testing.T) { }) // execute test, expect success + t.Setenv("E2ENGINE_RUNNER_WORKER_REPORTER_DUMP_PAYLOAD", "true") testExecutionID := h.RunTest( ctx, testID, @@ -113,12 +114,18 @@ func TestCRUDTest(t *testing.T) { t.Fatalf("Expected 1 test execution, got: %d", len(executions2)) } + params := &checkTestExecutionParams{ + useHTTPRequestHeaders: map[string]string{ + "E2engine-Test-Execution-Id": testExecutionID, + }, + } + actualExecution2 := executions2[0] - checkTestExecution(t, testExecutionID, environmentID, testID, execSpecPath, &actualExecution2) + checkTestExecution(t, testExecutionID, environmentID, testID, execSpecPath, &actualExecution2, params) // get testexecution by ID actualTestExecution4 := h.GetTestExecution(ctx, testExecutionID) - checkTestExecution(t, testExecutionID, environmentID, testID, execSpecPath, &actualTestExecution4) + checkTestExecution(t, testExecutionID, environmentID, testID, execSpecPath, &actualTestExecution4, params) // delete testexecution by ID h.DeleteTestExecution(ctx, testExecutionID, "") diff --git a/cli/tests/direct_crud_testsuite_test.go b/cli/tests/direct_crud_testsuite_test.go index c0a64cc..d61164e 100644 --- a/cli/tests/direct_crud_testsuite_test.go +++ b/cli/tests/direct_crud_testsuite_test.go @@ -5,6 +5,7 @@ import ( "path" "sort" "testing" + "time" "github.com/e2engine/tests/cli/harness" ) @@ -96,6 +97,10 @@ func TestDirectCRUDTestSuite(t *testing.T) { gateway.Stop(t) }) + time.Sleep(1 * time.Second) // wait for service to start + + t.Setenv("E2ENGINE_RUNNER_WORKER_REPORTER_DUMP_PAYLOAD", "true") + // execute testsuite tseID := h.RunTestSuite( ctx, @@ -110,11 +115,30 @@ func TestDirectCRUDTestSuite(t *testing.T) { } actualTSE2 := tses2[0] - checkTestSuiteExecution(t, tseID, environmentID, tsID, tseSpecPath, &actualTSE2, true) + checkTestSuiteExecution(t, tseID, environmentID, tsID, tseSpecPath, &actualTSE2, true, nil) // get testsuite execution by ID actualTSE4 := h.GetTestSuiteExecution(ctx, tseID) - checkTestSuiteExecution(t, tseID, environmentID, tsID, tseSpecPath, &actualTSE4, false) + + const executionIDHeader = "E2engine-Test-Execution-Id" + getExecutionIDHeader := func(headers map[string][]string) string { + values, ok := headers[executionIDHeader] + if !ok || len(values) == 0 { + t.Fatalf("Expected HTTP request header %q to be present", executionIDHeader) + } + return values[0] + } + + useExecutionIDHeaders := make(map[string]string, len(actualTSE4.Tests)) + for _, test := range actualTSE4.Tests { + useExecutionIDHeaders[test.TestName] = + getExecutionIDHeader(test.Summary.Request.HTTP.Headers) + } + + params2 := &checkTestSuiteExecutionParams{ + useHTTPRequestExecutionIDHeaders: useExecutionIDHeaders, + } + checkTestSuiteExecution(t, tseID, environmentID, tsID, tseSpecPath, &actualTSE4, false, params2) // list test executions, expect 2 tes5 := h.ListTestExecutions(ctx) @@ -129,10 +153,38 @@ func TestDirectCRUDTestSuite(t *testing.T) { // compare test executions actualTE5 := tes5[0] - checkTestExecution(t, actualTE5.ID, environmentID, test1ID, te1SpecPath, &actualTE5) + checkTestExecution( + t, + actualTE5.ID, + environmentID, + test1ID, + te1SpecPath, + &actualTE5, + &checkTestExecutionParams{ + useHTTPRequestHeaders: map[string]string{ + executionIDHeader: getExecutionIDHeader( + actualTE5.Summary.Request.HTTP.Headers, + ), + }, + }, + ) actualTE6 := tes5[1] - checkTestExecution(t, actualTE6.ID, environmentID, test2ID, te2SpecPath, &actualTE6) + checkTestExecution( + t, + actualTE6.ID, + environmentID, + test2ID, + te2SpecPath, + &actualTE6, + &checkTestExecutionParams{ + useHTTPRequestHeaders: map[string]string{ + executionIDHeader: getExecutionIDHeader( + actualTE6.Summary.Request.HTTP.Headers, + ), + }, + }, + ) // delete testsuite execution by ID h.DeleteTestSuiteExecution(ctx, tseID, "") diff --git a/cli/tests/direct_test.go b/cli/tests/direct_test.go index 2d6361e..062d82e 100644 --- a/cli/tests/direct_test.go +++ b/cli/tests/direct_test.go @@ -5,10 +5,7 @@ import ( "path" "testing" - "github.com/e2engine/core/model" - "github.com/e2engine/tests/cli/harness" - "github.com/e2engine/tests/util" ) func TestDirect(t *testing.T) { @@ -20,26 +17,55 @@ func TestDirect(t *testing.T) { } tests := []struct { - name string - services []string + name string + services []string + checkParams func(id string) *checkTestExecutionParams }{ { name: "direct-mocked-http", + checkParams: func(id string) *checkTestExecutionParams { + return &checkTestExecutionParams{ + useHTTPRequestHeaders: map[string]string{ + "E2engine-Test-Execution-Id": id, + }, + } + }, }, { name: "direct-mocked-grpc", + checkParams: func(id string) *checkTestExecutionParams { + return &checkTestExecutionParams{ + useGRPCRequestMetadata: map[string]string{ + "e2engine-test-execution-id": id, + }, + } + }, }, { name: "direct-real-http", services: []string{ "ok-http", }, + checkParams: func(id string) *checkTestExecutionParams { + return &checkTestExecutionParams{ + useHTTPRequestHeaders: map[string]string{ + "E2engine-Test-Execution-Id": id, + }, + } + }, }, { name: "direct-real-grpc", services: []string{ "ok-grpc", }, + checkParams: func(id string) *checkTestExecutionParams { + return &checkTestExecutionParams{ + useGRPCRequestMetadata: map[string]string{ + "e2engine-test-execution-id": id, + }, + } + }, }, } @@ -90,6 +116,7 @@ func TestDirect(t *testing.T) { ), ) + t.Setenv("E2ENGINE_RUNNER_WORKER_REPORTER_DUMP_PAYLOAD", "true") testExecutionID := h.RunTest( ctx, testID, @@ -101,24 +128,20 @@ func TestDirect(t *testing.T) { testExecutionID, ) - expectedTestExecution := util.Load[model.TestExecution]( - t, - path.Join( - dataDir, - test.name+"."+format, - ), - ) - - expectedTestExecution.ID = testExecutionID - expectedTestExecution.TestID = testID - expectedTestExecution.EnvironmentID = environmentID - expectedTestExecution.StartedAt = actualTestExecution.StartedAt - expectedTestExecution.FinishedAt = actualTestExecution.FinishedAt + if test.checkParams == nil { + test.checkParams = func(id string) *checkTestExecutionParams { + return nil + } + } - util.AssertEqualTestExecutions( + checkTestExecution( t, - &expectedTestExecution, + testExecutionID, + environmentID, + testID, + path.Join(dataDir, test.name+".yml"), &actualTestExecution, + test.checkParams(testExecutionID), ) }) } diff --git a/cli/tests/fixture_miss_test.go b/cli/tests/fixture_miss_test.go index 7b7ac54..5654a16 100644 --- a/cli/tests/fixture_miss_test.go +++ b/cli/tests/fixture_miss_test.go @@ -5,38 +5,71 @@ import ( "path" "testing" - "github.com/e2engine/core/model" - "github.com/e2engine/tests/cli/harness" - "github.com/e2engine/tests/util" ) func TestFixtureMiss(t *testing.T) { dataDir := "../data/fixture-miss" tests := []struct { - name string - services []string + name string + services []string + checkParams func(id string) *checkTestExecutionParams }{ { name: "fixture-miss-http-path", services: []string{"gateway-http-path"}, + checkParams: func(id string) *checkTestExecutionParams { + return &checkTestExecutionParams{ + useHTTPRequestHeaders: map[string]string{ + "E2engine-Test-Execution-Id": id, + }, + } + }, }, { name: "fixture-miss-http-body", services: []string{"gateway-http-body"}, + checkParams: func(id string) *checkTestExecutionParams { + return &checkTestExecutionParams{ + useHTTPRequestHeaders: map[string]string{ + "E2engine-Test-Execution-Id": id, + }, + } + }, }, { name: "fixture-miss-grpc-message", services: []string{"gateway-grpc-message"}, + checkParams: func(id string) *checkTestExecutionParams { + return &checkTestExecutionParams{ + useHTTPRequestHeaders: map[string]string{ + "E2engine-Test-Execution-Id": id, + }, + } + }, }, { name: "fixture-miss-grpc-method", services: []string{"gateway-grpc-method"}, + checkParams: func(id string) *checkTestExecutionParams { + return &checkTestExecutionParams{ + useHTTPRequestHeaders: map[string]string{ + "E2engine-Test-Execution-Id": id, + }, + } + }, }, { name: "fixture-miss-http-path-multiple", services: []string{"gateway-http-path"}, + checkParams: func(id string) *checkTestExecutionParams { + return &checkTestExecutionParams{ + useHTTPRequestHeaders: map[string]string{ + "E2engine-Test-Execution-Id": id, + }, + } + }, }, } @@ -73,6 +106,7 @@ func TestFixtureMiss(t *testing.T) { ) // execute test + t.Setenv("E2ENGINE_RUNNER_WORKER_REPORTER_DUMP_PAYLOAD", "true") testExecutionID := h.RunTest( ctx, testID, @@ -82,17 +116,21 @@ func TestFixtureMiss(t *testing.T) { // get testexecution by ID actualTestExecution := h.GetTestExecution(ctx, testExecutionID) - expectedTestExecution := util.Load[model.TestExecution]( + if test.checkParams == nil { + test.checkParams = func(id string) *checkTestExecutionParams { + return nil + } + } + + checkTestExecution( t, + testExecutionID, + environmentID, + testID, path.Join(dataDir, test.name+".yml"), + &actualTestExecution, + test.checkParams(testExecutionID), ) - expectedTestExecution.ID = testExecutionID - expectedTestExecution.TestID = testID - expectedTestExecution.EnvironmentID = environmentID - expectedTestExecution.StartedAt = actualTestExecution.StartedAt - expectedTestExecution.FinishedAt = actualTestExecution.FinishedAt - - util.AssertEqualTestExecutions(t, &expectedTestExecution, &actualTestExecution) }) } } diff --git a/cli/tests/main_test.go b/cli/tests/main_test.go index 16782f2..a111b57 100644 --- a/cli/tests/main_test.go +++ b/cli/tests/main_test.go @@ -50,8 +50,16 @@ func checkTestSuite(t *testing.T, id, path string, actual *model.TestSuite) { util.AssertEqualTestSuites(t, &expected, actual) } +type checkTestExecutionParams struct { + useHTTPRequestHeaders map[string]string + useGRPCRequestMetadata map[string]string +} + func checkTestExecution( - t *testing.T, id, envID, testID, path string, actual *model.TestExecution, + t *testing.T, + id, envID, testID, path string, + actual *model.TestExecution, + params *checkTestExecutionParams, ) { t.Helper() @@ -62,11 +70,33 @@ func checkTestExecution( expected.StartedAt = actual.StartedAt expected.FinishedAt = actual.FinishedAt + if params != nil { + if len(params.useHTTPRequestHeaders) > 0 { + for k, v := range params.useHTTPRequestHeaders { + expected.Summary.Request.HTTP.Headers[k] = []string{v} + } + } + if len(params.useGRPCRequestMetadata) > 0 { + for k, v := range params.useGRPCRequestMetadata { + expected.Summary.Request.GRPC.Metadata[k] = []string{v} + } + } + } + util.AssertEqualTestExecutions(t, &expected, actual) } +type checkTestSuiteExecutionParams struct { + useHTTPRequestHeaders map[string]string + useHTTPRequestExecutionIDHeaders map[string]string // test name -> received header value +} + func checkTestSuiteExecution( - t *testing.T, id, envID, tsID, path string, actual *model.TestSuiteExecution, skipTests bool, + t *testing.T, + id, envID, tsID, path string, + actual *model.TestSuiteExecution, + skipTests bool, + params *checkTestSuiteExecutionParams, ) { t.Helper() @@ -77,6 +107,23 @@ func checkTestSuiteExecution( expected.StartedAt = actual.StartedAt expected.FinishedAt = actual.FinishedAt + if params != nil { + if len(params.useHTTPRequestHeaders) > 0 { + for k, v := range params.useHTTPRequestHeaders { + for _, test := range expected.Tests { + test.Summary.Request.HTTP.Headers[k] = []string{v} + } + } + } + + for i := range expected.Tests { + if executionID, ok := params.useHTTPRequestExecutionIDHeaders[expected.Tests[i].TestName]; ok { + expected.Tests[i].Summary.Request.HTTP.Headers["E2engine-Test-Execution-Id"] = + []string{executionID} + } + } + } + util.AssertEqualTestSuiteExecutions(t, &expected, actual) if skipTests { diff --git a/cli/tests/socket_crud_testsuite_test.go b/cli/tests/socket_crud_testsuite_test.go index 49f9e5e..b571953 100644 --- a/cli/tests/socket_crud_testsuite_test.go +++ b/cli/tests/socket_crud_testsuite_test.go @@ -98,6 +98,8 @@ func TestSocketCRUDTestSuite(t *testing.T) { }) // execute testsuite + t.Setenv("E2ENGINE_RUNNER_WORKER_REPORTER_DUMP_PAYLOAD", "true") + tseID := h.RunTestSuite( ctx, tsID, @@ -111,11 +113,29 @@ func TestSocketCRUDTestSuite(t *testing.T) { } actualTSE2 := tses2[0] - checkTestSuiteExecution(t, tseID, environmentID, tsID, tseSpecPath, &actualTSE2, true) + checkTestSuiteExecution(t, tseID, environmentID, tsID, tseSpecPath, &actualTSE2, true, nil) // get testsuite execution by ID actualTSE4 := h.GetTestSuiteExecution(ctx, tseID) - checkTestSuiteExecution(t, tseID, environmentID, tsID, tseSpecPath, &actualTSE4, false) + const executionIDHeader = "E2engine-Test-Execution-Id" + getExecutionIDHeader := func(headers map[string][]string) string { + values, ok := headers[executionIDHeader] + if !ok || len(values) == 0 { + t.Fatalf("Expected HTTP request header %q to be present", executionIDHeader) + } + return values[0] + } + + useExecutionIDHeaders := make(map[string]string, len(actualTSE4.Tests)) + for _, test := range actualTSE4.Tests { + useExecutionIDHeaders[test.TestName] = + getExecutionIDHeader(test.Summary.Request.HTTP.Headers) + } + + params2 := &checkTestSuiteExecutionParams{ + useHTTPRequestExecutionIDHeaders: useExecutionIDHeaders, + } + checkTestSuiteExecution(t, tseID, environmentID, tsID, tseSpecPath, &actualTSE4, false, params2) // list test executions, expect 2 tes5 := h.ListTestExecutions(ctx) @@ -130,11 +150,38 @@ func TestSocketCRUDTestSuite(t *testing.T) { // compare test executions actualTE5 := tes5[0] - checkTestExecution(t, actualTE5.ID, environmentID, test1ID, te1SpecPath, &actualTE5) + checkTestExecution( + t, + actualTE5.ID, + environmentID, + test1ID, + te1SpecPath, + &actualTE5, + &checkTestExecutionParams{ + useHTTPRequestHeaders: map[string]string{ + executionIDHeader: getExecutionIDHeader( + actualTE5.Summary.Request.HTTP.Headers, + ), + }, + }, + ) actualTE6 := tes5[1] - checkTestExecution(t, actualTE6.ID, environmentID, test2ID, te2SpecPath, &actualTE6) - + checkTestExecution( + t, + actualTE6.ID, + environmentID, + test2ID, + te2SpecPath, + &actualTE6, + &checkTestExecutionParams{ + useHTTPRequestHeaders: map[string]string{ + executionIDHeader: getExecutionIDHeader( + actualTE6.Summary.Request.HTTP.Headers, + ), + }, + }, + ) // delete testsuite execution by ID h.DeleteTestSuiteExecution(ctx, tseID, "") diff --git a/cli/tests/transport_kind_test.go b/cli/tests/transport_kind_test.go index aec7786..724a85e 100644 --- a/cli/tests/transport_kind_test.go +++ b/cli/tests/transport_kind_test.go @@ -32,6 +32,8 @@ func TestTransportKind(t *testing.T) { captureLogs bool crashRunner bool allowExpiry bool + e2engineHeader bool + e2engineHeader2 bool }{ { name: "default", // direct transport kind is default @@ -42,6 +44,8 @@ func TestTransportKind(t *testing.T) { services: []Service{ {Name: "gateway-http-path"}, }, + e2engineHeader: true, + e2engineHeader2: true, }, { name: "direct", @@ -54,6 +58,8 @@ func TestTransportKind(t *testing.T) { services: []Service{ {Name: "gateway-http-path"}, }, + e2engineHeader: true, + e2engineHeader2: true, }, { name: "socket", @@ -67,6 +73,8 @@ func TestTransportKind(t *testing.T) { services: []Service{ {Name: "gateway-http-path"}, }, + e2engineHeader: true, + e2engineHeader2: true, }, { name: "socket, long", @@ -81,7 +89,9 @@ func TestTransportKind(t *testing.T) { services: []Service{ {Name: "gateway-http-path", Args: []string{"2"}}, }, - long: true, + long: true, + e2engineHeader: true, + e2engineHeader2: true, }, { name: "socket, grpc, error", @@ -138,6 +148,8 @@ func TestTransportKind(t *testing.T) { services: []Service{ {Name: "gateway-http-path"}, }, + e2engineHeader: true, + e2engineHeader2: true, }, } @@ -206,6 +218,8 @@ func TestTransportKind(t *testing.T) { path.Join(dataDir, test.testSpec+".test.yml"), ) + t.Setenv("E2ENGINE_RUNNER_WORKER_REPORTER_DUMP_PAYLOAD", "true") + // execute test testExecutionID := h.RunTest( ctx, @@ -271,6 +285,10 @@ func TestTransportKind(t *testing.T) { expectedTestExecution2.EnvironmentID = environmentID expectedTestExecution2.StartedAt = actualTestExecution2.StartedAt expectedTestExecution2.FinishedAt = actualTestExecution2.FinishedAt + if test.e2engineHeader2 { + expectedTestExecution2.Summary.Request.HTTP.Headers["E2engine-Test-Execution-Id"] = + []string{testExecutionID} + } util.AssertEqualTestExecutions( t, diff --git a/cli/tests/validate_environment_test.go b/cli/tests/validate_environment_test.go index ae3f964..2e6408f 100644 --- a/cli/tests/validate_environment_test.go +++ b/cli/tests/validate_environment_test.go @@ -141,7 +141,7 @@ func TestValidateEnvironment(t *testing.T) { { name: "http-with-proto", stdout: "", - stderr: "invalid spec, spec.kind: environment, validation: proto spec not allowed for HTTP service", + stderr: "invalid spec, spec.kind: environment, validation: proto spec is not allowed for HTTP service", expectError: true, }, { @@ -268,25 +268,25 @@ func TestValidateEnvironment(t *testing.T) { { name: "http-fixture-status-too-low", stdout: "", - stderr: "invalid environment spec, fields: Spec.Services[0].Fixtures[0].Then.HTTP.Status", + stderr: "invalid environment spec, fields: Spec.Services[0].Fixtures[0].Then.HTTP.StatusCode", expectError: true, }, { name: "http-fixture-status-too-high", stdout: "", - stderr: "invalid environment spec, fields: Spec.Services[0].Fixtures[0].Then.HTTP.Status", + stderr: "invalid environment spec, fields: Spec.Services[0].Fixtures[0].Then.HTTP.StatusCode", expectError: true, }, { name: "http-fixture-invalid-request-json", stdout: "", - stderr: "invalid environment spec, fields: Spec.Services[0].Fixtures[0].When.HTTP.Body", + stderr: "invalid environment spec, fields: Spec.Services[0].Fixtures[0].When.HTTP.BodyJSON", expectError: true, }, { name: "http-fixture-invalid-response-json", stdout: "", - stderr: "invalid environment spec, fields: Spec.Services[0].Fixtures[0].Then.HTTP.Body", + stderr: "invalid environment spec, fields: Spec.Services[0].Fixtures[0].Then.HTTP.BodyJSON", expectError: true, }, { diff --git a/cli/tests/validate_expected_calls_test.go b/cli/tests/validate_expected_calls_test.go index aee1d22..7d1e386 100644 --- a/cli/tests/validate_expected_calls_test.go +++ b/cli/tests/validate_expected_calls_test.go @@ -5,17 +5,15 @@ import ( "path" "testing" - "github.com/e2engine/core/model" - "github.com/e2engine/tests/cli/harness" - "github.com/e2engine/tests/util" ) func TestValidateExpectedCalls(t *testing.T) { dataDir := "../data/validate-expected-calls" tests := []struct { - name string + name string + checkParams func(id string) *checkTestExecutionParams }{ { name: "expected-call-unknown-service", @@ -28,9 +26,23 @@ func TestValidateExpectedCalls(t *testing.T) { }, { name: "expected-calls-twice", + checkParams: func(id string) *checkTestExecutionParams { + return &checkTestExecutionParams{ + useHTTPRequestHeaders: map[string]string{ + "E2engine-Test-Execution-Id": id, + }, + } + }, }, { name: "wrong-call-params", + checkParams: func(id string) *checkTestExecutionParams { + return &checkTestExecutionParams{ + useHTTPRequestHeaders: map[string]string{ + "E2engine-Test-Execution-Id": id, + }, + } + }, }, } @@ -68,17 +80,20 @@ func TestValidateExpectedCalls(t *testing.T) { // get testexecution by ID actualTestExecution := h.GetTestExecution(ctx, testExecutionID) - expectedTestExecution := util.Load[model.TestExecution]( + if test.checkParams == nil { + test.checkParams = func(id string) *checkTestExecutionParams { + return nil + } + } + checkTestExecution( t, + testExecutionID, + environmentID, + testID, path.Join(dataDir, test.name+".yml"), + &actualTestExecution, + test.checkParams(testExecutionID), ) - expectedTestExecution.ID = testExecutionID - expectedTestExecution.TestID = testID - expectedTestExecution.EnvironmentID = environmentID - expectedTestExecution.StartedAt = actualTestExecution.StartedAt - expectedTestExecution.FinishedAt = actualTestExecution.FinishedAt - - util.AssertEqualTestExecutions(t, &expectedTestExecution, &actualTestExecution) }) } } diff --git a/cli/tests/validate_test_test.go b/cli/tests/validate_test_test.go index ae78b19..e76bd4a 100644 --- a/cli/tests/validate_test_test.go +++ b/cli/tests/validate_test_test.go @@ -98,25 +98,25 @@ func TestValidateTest(t *testing.T) { { name: "http-request-invalid-json", stdout: "", - stderr: "invalid test spec, fields: Spec.Request.HTTP.Body", + stderr: "invalid test spec, fields: Spec.Request.HTTP.BodyJSON", expectError: true, }, { name: "http-expect-status-too-low", stdout: "", - stderr: "invalid test spec, fields: Spec.Expect.HTTP.Status", + stderr: "invalid test spec, fields: Spec.Expect.HTTP.StatusCode", expectError: true, }, { name: "http-expect-status-too-high", stdout: "", - stderr: "invalid test spec, fields: Spec.Expect.HTTP.Status", + stderr: "invalid test spec, fields: Spec.Expect.HTTP.StatusCode", expectError: true, }, { name: "http-expect-invalid-json", stdout: "", - stderr: "invalid test spec, fields: Spec.Expect.HTTP.Body", + stderr: "invalid test spec, fields: Spec.Expect.HTTP.BodyJSON", expectError: true, }, { @@ -188,7 +188,7 @@ func TestValidateTest(t *testing.T) { { name: "call-http-invalid-json", stdout: "", - stderr: "invalid test spec, fields: Spec.Expect.Calls[0].HTTP.Body", + stderr: "invalid test spec, fields: Spec.Expect.Calls[0].HTTP.BodyJSON", expectError: true, }, { diff --git a/docker/data/direct/direct-mocked-grpc.env.yml b/docker/data/direct/direct-mocked-grpc.env.yml index 0228aed..4513323 100644 --- a/docker/data/direct/direct-mocked-grpc.env.yml +++ b/docker/data/direct/direct-mocked-grpc.env.yml @@ -25,9 +25,9 @@ spec: fixtures: - when: grpc: + service: entitlements.v1.EntitlementsService method: CheckEntitlement - message: - customer_id: customer-1 + message: '{"customer_id": "customer-1"}' then: grpc: status: OK diff --git a/docker/data/direct/direct-mocked-grpc.test.yml b/docker/data/direct/direct-mocked-grpc.test.yml index e059197..b1f8352 100644 --- a/docker/data/direct/direct-mocked-grpc.test.yml +++ b/docker/data/direct/direct-mocked-grpc.test.yml @@ -15,10 +15,12 @@ spec: expect: grpc: status: OK + metadata: + "content-type": + - "application/grpc" calls: - service_id: direct-mocked-grpc grpc: service: entitlements.v1.EntitlementsService method: CheckEntitlement - message: - customer_id: customer-1 \ No newline at end of file + message: '{"customer_id": "customer-1"}' \ No newline at end of file diff --git a/docker/data/direct/direct-mocked-grpc.yml b/docker/data/direct/direct-mocked-grpc.yml index 177afa7..1ee8083 100644 --- a/docker/data/direct/direct-mocked-grpc.yml +++ b/docker/data/direct/direct-mocked-grpc.yml @@ -9,9 +9,13 @@ test_name: direct-mocked-grpc summary: request: grpc: + target: "127.0.0.1:8083" service: entitlements.v1.EntitlementsService service_id: direct-mocked-grpc method: CheckEntitlement + metadata: + "e2engine-test-execution-id": + - "c1079d334b1a17b4a5fa7588a90d045ed01ea241c53ab51afa0d8b8620837e7b" message: customer_id: customer-1 response: @@ -22,10 +26,12 @@ summary: metadata: "content-type": - "application/grpc" - expected_calls: + calls: - service_id: direct-mocked-grpc + count: 1 grpc: service: entitlements.v1.EntitlementsService method: CheckEntitlement message: - customer_id: customer-1 \ No newline at end of file + customer_id: customer-1 + response_status: OK \ No newline at end of file diff --git a/docker/data/direct/direct-mocked-http.env.yml b/docker/data/direct/direct-mocked-http.env.yml index c90e5d0..32a9cc2 100644 --- a/docker/data/direct/direct-mocked-http.env.yml +++ b/docker/data/direct/direct-mocked-http.env.yml @@ -15,4 +15,4 @@ spec: path: /healthz then: http: - status: 200 + status_code: 200 diff --git a/docker/data/direct/direct-mocked-http.test.yml b/docker/data/direct/direct-mocked-http.test.yml index 21af721..7351347 100644 --- a/docker/data/direct/direct-mocked-http.test.yml +++ b/docker/data/direct/direct-mocked-http.test.yml @@ -9,7 +9,7 @@ spec: url: http://127.0.0.1:8083/healthz expect: http: - status: 200 + status_code: 200 calls: - service_id: direct-mocked-http http: diff --git a/docker/data/direct/direct-mocked-http.yml b/docker/data/direct/direct-mocked-http.yml index dc7174a..096386a 100644 --- a/docker/data/direct/direct-mocked-http.yml +++ b/docker/data/direct/direct-mocked-http.yml @@ -11,11 +11,16 @@ summary: http: method: GET url: http://127.0.0.1:8083/healthz + headers: + "E2engine-Test-Execution-Id": + - "c1079d334b1a17b4a5fa7588a90d045ed01ea241c53ab51afa0d8b8620837e7b" response: http: status_code: 200 - expected_calls: + calls: - service_id: direct-mocked-http + count: 1 http: method: GET path: /healthz + response_status_code: 200 diff --git a/docker/data/direct/direct-real-http.test.yml b/docker/data/direct/direct-real-http.test.yml index 36bdbd3..7feb822 100644 --- a/docker/data/direct/direct-real-http.test.yml +++ b/docker/data/direct/direct-real-http.test.yml @@ -9,7 +9,7 @@ spec: url: http://127.0.0.1:8083/ok expect: http: - status: 200 + status_code: 200 calls: - service_id: direct-real-http http: diff --git a/docker/data/direct/direct-real-http.yml b/docker/data/direct/direct-real-http.yml index d8c043e..e5e26a2 100644 --- a/docker/data/direct/direct-real-http.yml +++ b/docker/data/direct/direct-real-http.yml @@ -11,11 +11,16 @@ summary: http: method: GET url: http://127.0.0.1:8083/ok + headers: + "E2engine-Test-Execution-Id": + - "c1079d334b1a17b4a5fa7588a90d045ed01ea241c53ab51afa0d8b8620837e7b" response: http: status_code: 200 - expected_calls: + calls: - service_id: direct-real-http + count: 1 http: method: GET path: /ok + response_status_code: 200 diff --git a/docker/harness/harness.go b/docker/harness/harness.go index 458941b..83940f8 100644 --- a/docker/harness/harness.go +++ b/docker/harness/harness.go @@ -148,6 +148,7 @@ func (h *Harness) RunCommand( "-v", h.dataVolume + ":/testdata", "-e", "E2ENGINE_CONFIG_PATH=" + containerConfigPath, "-e", "E2ENGINE_DATA_DIR=/testdata", + "-e", "E2ENGINE_RUNNER_WORKER_REPORTER_DUMP_PAYLOAD=true", } args = append(args, "e2engine:local") diff --git a/docker/tests/direct_test.go b/docker/tests/direct_test.go index 3a75eab..79b2486 100644 --- a/docker/tests/direct_test.go +++ b/docker/tests/direct_test.go @@ -15,20 +15,25 @@ func TestDirect(t *testing.T) { dataDir := "../data/direct" tests := []struct { - name string - services []string + name string + services []string + httpHeader bool + grpcMetadata bool }{ { - name: "direct-mocked-http", + name: "direct-mocked-http", + httpHeader: true, }, { - name: "direct-mocked-grpc", + name: "direct-mocked-grpc", + grpcMetadata: true, }, { name: "direct-real-http", services: []string{ "ok-http", }, + httpHeader: true, }, } @@ -100,6 +105,14 @@ func TestDirect(t *testing.T) { expectedTestExecution.EnvironmentID = environmentID expectedTestExecution.StartedAt = actualTestExecution.StartedAt expectedTestExecution.FinishedAt = actualTestExecution.FinishedAt + if test.httpHeader { + expectedTestExecution.Summary.Request.HTTP.Headers["E2engine-Test-Execution-Id"] = + []string{testExecutionID} + } + if test.grpcMetadata { + expectedTestExecution.Summary.Request.GRPC.Metadata["e2engine-test-execution-id"] = + []string{testExecutionID} + } util.AssertEqualTestExecutions( t, diff --git a/go.mod b/go.mod index 7c1ade4..a87d763 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/e2engine/tests go 1.27 require ( - github.com/e2engine/core v0.2.0 + github.com/e2engine/core v0.2.1 github.com/e2engine/instrumentation-go/grpc v0.1.1 github.com/e2engine/instrumentation-go/http v0.1.1 google.golang.org/grpc v1.84.0 @@ -16,8 +16,8 @@ require ( github.com/ygrebnov/errorc v0.6.1 // indirect github.com/ygrebnov/keys v0.2.0 // indirect github.com/ygrebnov/model v0.7.5 // indirect - golang.org/x/net v0.59.0 // indirect - golang.org/x/sys v0.48.0 // indirect - golang.org/x/text v0.42.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20260928230214-8a89bd6388cc // indirect + golang.org/x/net v0.61.0 // indirect + golang.org/x/sys v0.49.0 // indirect + golang.org/x/text v0.43.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20261012220534-4341edf3f941 // indirect ) diff --git a/go.sum b/go.sum index c118eba..5fc60fc 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/e2engine/core v0.2.0 h1:yjSKpI/qSscwGAK3/7Eje26BLhQKo7a5T1Ubm4q/hOo= -github.com/e2engine/core v0.2.0/go.mod h1:JM4y6XlRsLgYSFXph1T8qPU+Cp5s+WkQYlaJUBvnTzA= +github.com/e2engine/core v0.2.1 h1:U0K4Ak4RheCxVX9+pLUyF/k8mrRB9rb0ruxxa6JWUX4= +github.com/e2engine/core v0.2.1/go.mod h1:8oN/239uuU+jNNA+CxDF7h68HKh0cL+vON9D/mcqN/Y= github.com/e2engine/instrumentation-go v0.1.1 h1:pkOQIQWWkGqHdU1F/b0tCtpFyNDc09kKebYZElHZS9k= github.com/e2engine/instrumentation-go v0.1.1/go.mod h1:zpWF7koAp+vFqYAfOx3mOJFn4GpLtzetguAs8n7+wIE= github.com/e2engine/instrumentation-go/grpc v0.1.1 h1:0sqxF3oCdxdVaJwzTshaf79VMXglVHJQ1bLte7vnH14= @@ -16,16 +16,16 @@ github.com/ygrebnov/keys v0.2.0 h1:KQSQG1la9WkTW59WbB3CK1yhxZ92el2ZJfV1XtlHTp0= github.com/ygrebnov/keys v0.2.0/go.mod h1:4IfRPgv7tFSlToKzHtA9MPMwXP0+HRJ0Kk8XSrvhDvQ= github.com/ygrebnov/model v0.7.5 h1:9i7Xz5vxYQXeJW06gTE9/In49f0lEDhulmsBKhsQxWw= github.com/ygrebnov/model v0.7.5/go.mod h1:qYRz8F/yrt01bPyANAlN0Oqi1fwpgvvl21hjW/NK6N0= -golang.org/x/net v0.59.0 h1:5zfYln+w5XCxwrnMMJPufRgNoXEaGxl0wo5GqPXyues= -golang.org/x/net v0.59.0/go.mod h1:2DA/G1UfVbCpQPeWTmMPGY7Cs2PkBkwu743bVX5PIVg= -golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo= -golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og= -golang.org/x/text v0.42.0 h1:JbOZXgfeCPU9gacVtYliJqOhD+zhrEqK4LfdpmlUZqI= -golang.org/x/text v0.42.0/go.mod h1:ojzP1Z+2QtioaF8DTtO8K5q7JWVVYwZKenzujK0Zd0E= +golang.org/x/net v0.61.0 h1:RR+6j/BTBCrggOLugxa+66R8FvoN6MHlzDlZIbN9YFw= +golang.org/x/net v0.61.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI= +golang.org/x/sys v0.49.0 h1:XbzkgYJHdqh/8m2Uu0W/dQv8nktxx4BFHp1M0gROTXA= +golang.org/x/sys v0.49.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og= +golang.org/x/text v0.43.0 h1:1QivrlhwAsnMOcqgOdl9my7s9OyZl8O5/UGUTJVXoWc= +golang.org/x/text v0.43.0/go.mod h1:hbSIYA/amXcRXTFSZqh8tWHEoqRvvbKPJ2uz/KU+a+s= gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4= gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E= -google.golang.org/genproto/googleapis/rpc v0.0.0-20260928230214-8a89bd6388cc h1:4bNTbnb44EqGVy9HaQxSY2jnafSUdgV3qHtedvNpDKg= -google.golang.org/genproto/googleapis/rpc v0.0.0-20260928230214-8a89bd6388cc/go.mod h1:OaIUM3+LpYcK2GXM4FTmhWoIq371Owdr+Cc7/BsYHHc= +google.golang.org/genproto/googleapis/rpc v0.0.0-20261012220534-4341edf3f941 h1:QG6hS4zFplRZvOQedzei4t2pT/zkQc3VR1u+S9/rcAw= +google.golang.org/genproto/googleapis/rpc v0.0.0-20261012220534-4341edf3f941/go.mod h1:OaIUM3+LpYcK2GXM4FTmhWoIq371Owdr+Cc7/BsYHHc= google.golang.org/grpc v1.84.0 h1:soMyaPJ8pAak5PIQ0DGBUir0XRo2fRoMqhNWMLlLxO0= google.golang.org/grpc v1.84.0/go.mod h1:ljCht0DrxQrXBDRTZp52Qxh3Ffk8CdYm2sj4O2QN2C0= google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc= diff --git a/util/compare_environments.go b/util/compare_environments.go index 3b34191..539b1bd 100644 --- a/util/compare_environments.go +++ b/util/compare_environments.go @@ -7,6 +7,7 @@ import ( "testing" "github.com/e2engine/core/model" + "github.com/e2engine/core/model/matcher" ) func AssertEqualEnvironments(t *testing.T, expected, actual *model.Environment) { @@ -133,7 +134,7 @@ func assertEqualServiceSpec( ) } - assertEqualServiceDefaults( + assertEqualRequestDefaults( t, prefix("RequestDefaults"), expected.RequestDefaults, @@ -167,11 +168,11 @@ func assertEqualServiceSpec( } } -func assertEqualServiceDefaults( +func assertEqualRequestDefaults( t *testing.T, path string, expected, - actual *model.ServiceDefaults, + actual *model.RequestDefaults, ) { t.Helper() @@ -454,14 +455,14 @@ func assertEqualFixtureWhen( ) { t.Helper() - assertEqualHTTPFixtureWhen( + assertEqualHTTPRequestPattern( t, path+".HTTP", expected.HTTP, actual.HTTP, ) - assertEqualGRPCFixtureWhen( + assertEqualGRPCRequestPattern( t, path+".GRPC", expected.GRPC, @@ -477,14 +478,14 @@ func assertEqualFixtureThen( ) { t.Helper() - assertEqualHTTPFixtureThen( + assertEqualHTTPResponse( t, path+".HTTP", expected.HTTP, actual.HTTP, ) - assertEqualGRPCFixtureThen( + assertEqualGRPCResponse( t, path+".GRPC", expected.GRPC, @@ -492,186 +493,67 @@ func assertEqualFixtureThen( ) } -func assertEqualHTTPFixtureWhen( - t *testing.T, - path string, - expected, - actual *model.HTTPFixtureWhen, -) { - t.Helper() - - if expected == nil && actual == nil { - return - } - if expected == nil { - t.Errorf("Expected %s nil, got %+v", path, actual) - return - } - if actual == nil { - t.Errorf("Expected %s %+v, got nil", path, expected) - return - } - - if expected.Method != actual.Method { - t.Errorf( - "Expected %s.Method %q, got %q", - path, - expected.Method, - actual.Method, - ) - } - - if expected.Path != actual.Path { - t.Errorf( - "Expected %s.Path %q, got %q", - path, - expected.Path, - actual.Path, - ) - } - - assertEqualStringSliceMap( - t, - path+".Headers", - expected.Headers, - actual.Headers, - ) - - if expected.Body != actual.Body { - t.Errorf( - "Expected %s.Body %q, got %q", - path, - expected.Body, - actual.Body, - ) - } -} +const dateHeaderKey = "Date" -func assertEqualHTTPFixtureThen( +func assertEqualStringSliceMap( t *testing.T, path string, expected, - actual *model.HTTPFixtureThen, + actual map[string][]string, ) { t.Helper() - if expected == nil && actual == nil { - return - } - if expected == nil { - t.Errorf("Expected %s nil, got %+v", path, actual) - return - } - if actual == nil { - t.Errorf("Expected %s %+v, got nil", path, expected) - return - } - - if expected.Status != actual.Status { - t.Errorf( - "Expected %s.Status %d, got %d", - path, - expected.Status, - actual.Status, - ) - } - - assertEqualStringSliceMap( - t, - path+".Headers", - expected.Headers, - actual.Headers, - ) - - if expected.Body != actual.Body { + if len(expected) != len(actual) { t.Errorf( - "Expected %s.Body %q, got %q", + "Expected %s length %d, got %d", path, - expected.Body, - actual.Body, + len(expected), + len(actual), ) - } -} - -func assertEqualGRPCFixtureWhen( - t *testing.T, - path string, - expected, - actual *model.GRPCFixtureWhen, -) { - t.Helper() - - if expected == nil && actual == nil { - return - } - if expected == nil { - t.Errorf("Expected %s nil, got %+v", path, actual) return } - if actual == nil { - t.Errorf("Expected %s %+v, got nil", path, expected) - return - } - - if expected.Method != actual.Method { - t.Errorf( - "Expected %s.Method %q, got %q", - path, - expected.Method, - actual.Method, - ) - } - - assertEqualJSONValue( - t, - path+".Message", - expected.Message, - actual.Message, - ) -} -func assertEqualGRPCFixtureThen( - t *testing.T, - path string, - expected, - actual *model.GRPCFixtureThen, -) { - t.Helper() + for key, expectedValues := range expected { + actualValues, ok := actual[key] + if !ok { + t.Errorf("Expected %s[%q] to exist", path, key) + continue + } - if expected == nil && actual == nil { - return - } - if expected == nil { - t.Errorf("Expected %s nil, got %+v", path, actual) - return - } - if actual == nil { - t.Errorf("Expected %s %+v, got nil", path, expected) - return - } + if len(expectedValues) != len(actualValues) { + t.Errorf( + "Expected %s[%q] length %d, got %d", + path, + key, + len(expectedValues), + len(actualValues), + ) + continue + } - if expected.Status != actual.Status { - t.Errorf( - "Expected %s.Status %q, got %q", - path, - expected.Status, - actual.Status, - ) + if key == dateHeaderKey { + continue // TODO: replace with check. + } + for i := range expectedValues { + if expectedValues[i] != actualValues[i] { + t.Errorf( + "Expected %s[%q][%d] %q, got %q", + path, + key, + i, + expectedValues[i], + actualValues[i], + ) + } + } } - - assertEqualJSONValue( - t, - path+".Message", - expected.Message, - actual.Message, - ) } -func assertEqualStringSliceMap( +func assertEqualStringMatcherSliceMap( t *testing.T, path string, expected, - actual map[string][]string, + actual map[string][]matcher.String, ) { t.Helper() @@ -703,7 +585,7 @@ func assertEqualStringSliceMap( continue } - if key == "Date" { + if key == dateHeaderKey { continue // TODO: replace with check. } for i := range expectedValues { diff --git a/util/compare_grpc.go b/util/compare_grpc.go new file mode 100644 index 0000000..82cd2fd --- /dev/null +++ b/util/compare_grpc.go @@ -0,0 +1,210 @@ +package util + +import ( + "testing" + + "github.com/e2engine/core/model" +) + +func assertEqualGRPCRequest( + t *testing.T, + path string, + expected, + actual *model.GRPCRequest, +) { + t.Helper() + + if expected == nil && actual == nil { + return + } + if expected == nil { + t.Errorf("Expected %s nil, got %+v", path, actual) + return + } + if actual == nil { + t.Errorf("Expected %s %+v, got nil", path, expected) + return + } + + if expected.Target != actual.Target { + t.Errorf( + "Expected %s.Target %q, got %q", + path, + expected.Target, + actual.Target, + ) + } + + if expected.Service != actual.Service { + t.Errorf( + "Expected %s.Service %q, got %q", + path, + expected.Service, + actual.Service, + ) + } + + if expected.Method != actual.Method { + t.Errorf( + "Expected %s.Method %q, got %q", + path, + expected.Method, + actual.Method, + ) + } + + assertEqualStringSliceMap( + t, + path+".Metadata", + expected.Metadata, + actual.Metadata, + ) + + assertEqualJSONValue( + t, + path+".Message", + expected.Message, + actual.Message, + ) +} + +func assertEqualGRPCRequestPattern( + t *testing.T, + path string, + expected, + actual *model.GRPCRequestPattern, +) { + t.Helper() + + if expected == nil && actual == nil { + return + } + if expected == nil { + t.Errorf("Expected %s nil, got %+v", path, actual) + return + } + if actual == nil { + t.Errorf("Expected %s %+v, got nil", path, expected) + return + } + + if expected.Service != actual.Service { + t.Errorf( + "Expected %s.Service %q, got %q", + path, + expected.Service, + actual.Service, + ) + } + + if expected.Method != actual.Method { + t.Errorf( + "Expected %s.Method %q, got %q", + path, + expected.Method, + actual.Method, + ) + } + + assertEqualStringMatcherSliceMap( + t, + path+".Metadata", + expected.Metadata, + actual.Metadata, + ) + + assertEqualJSONValue( + t, + path+".Message", + expected.Message, + actual.Message, + ) +} + +func assertEqualGRPCResponsePattern( + t *testing.T, + path string, + expected, + actual *model.GRPCResponsePattern, +) { + t.Helper() + + if expected == nil && actual == nil { + return + } + if expected == nil { + t.Errorf("Expected %s nil, got %+v", path, actual) + return + } + if actual == nil { + t.Errorf("Expected %s %+v, got nil", path, expected) + return + } + + if expected.Status != actual.Status { + t.Errorf( + "Expected %s.Status %q, got %q", + path, + expected.Status, + actual.Status, + ) + } + + assertEqualStringMatcherSliceMap( + t, + path+".Metadata", + expected.Metadata, + actual.Metadata, + ) + + assertEqualJSONValue( + t, + path+".Message", + expected.Message, + actual.Message, + ) +} + +func assertEqualGRPCResponse( + t *testing.T, + path string, + expected, + actual *model.GRPCResponse, +) { + t.Helper() + + if expected == nil && actual == nil { + return + } + if expected == nil { + t.Errorf("Expected %s nil, got %+v", path, actual) + return + } + if actual == nil { + t.Errorf("Expected %s %+v, got nil", path, expected) + return + } + + if expected.Status != actual.Status { + t.Errorf( + "Expected %s.Status %q, got %q", + path, + expected.Status, + actual.Status, + ) + } + + assertEqualStringSliceMap( + t, + path+".Metadata", + expected.Metadata, + actual.Metadata, + ) + + assertEqualJSONValue( + t, + path+".Message", + expected.Message, + actual.Message, + ) +} diff --git a/util/compare_http.go b/util/compare_http.go new file mode 100644 index 0000000..4a127a4 --- /dev/null +++ b/util/compare_http.go @@ -0,0 +1,278 @@ +package util + +import ( + "testing" + + "github.com/e2engine/core/model" + "github.com/e2engine/core/model/matcher" +) + +func assertEqualHTTPRequest( + t *testing.T, + path string, + expected, + actual *model.HTTPRequest, +) { + t.Helper() + + if expected == nil && actual == nil { + return + } + if expected == nil { + t.Errorf("Expected %s nil, got %+v", path, actual) + return + } + if actual == nil { + t.Errorf("Expected %s %+v, got nil", path, expected) + return + } + + if expected.Method != actual.Method { + t.Errorf( + "Expected %s.Method %q, got %q", + path, + expected.Method, + actual.Method, + ) + } + + if expected.URL != actual.URL { + t.Errorf( + "Expected %s.URL %q, got %q", + path, + expected.URL, + actual.URL, + ) + } + + assertEqualStringSliceMap( + t, + path+".Query", + expected.Query, + actual.Query, + ) + + assertEqualStringSliceMap( + t, + path+".Headers", + expected.Headers, + actual.Headers, + ) + + if expected.Body != actual.Body { + t.Errorf( + "Expected %s.Body %q, got %q", + path, + expected.Body, + actual.Body, + ) + } + + if expected.BodyJSON != actual.BodyJSON { + t.Errorf( + "Expected %s.BodyJSON %q, got %q", + path, + expected.BodyJSON, + actual.BodyJSON, + ) + } +} + +func assertEqualHTTPRequestPattern( + t *testing.T, + path string, + expected, + actual *model.HTTPRequestPattern, +) { + t.Helper() + + if expected == nil && actual == nil { + return + } + if expected == nil { + t.Errorf("Expected %s nil, got %+v", path, actual) + return + } + if actual == nil { + t.Errorf("Expected %s %+v, got nil", path, expected) + return + } + + if expected.Method != actual.Method { + t.Errorf( + "Expected %s.Method %q, got %q", + path, + expected.Method, + actual.Method, + ) + } + + if expected.Path != actual.Path { + t.Errorf( + "Expected %s.Path %q, got %q", + path, + expected.Path, + actual.Path, + ) + } + + assertEqualStringSliceMap( + t, + path+".Query", + expected.Query, + actual.Query, + ) + + assertEqualStringMatcherSliceMap( + t, + path+".Headers", + expected.Headers, + actual.Headers, + ) + + assertEqualPtrStringMatcher( + t, + path+".Body", + expected.Body, + actual.Body, + ) + + assertEqualPtrStringMatcher( + t, + path+".BodyJSON", + expected.BodyJSON, + actual.BodyJSON, + ) +} + +func assertEqualPtrStringMatcher( + t *testing.T, + path string, + expected, + actual *matcher.String, +) { + t.Helper() + + if expected == nil && actual == nil { + return + } + + if expected == nil { + t.Errorf("Expected %s nil, got %s", path, *actual) + } else if actual == nil { + t.Errorf("Expected %s %s, got nil", path, *expected) + } else if *expected != *actual { + t.Errorf( + "Expected %s %s, got %s", + path, + *expected, + *actual, + ) + } +} + +func assertEqualHTTPResponsePattern( + t *testing.T, + path string, + expected, + actual *model.HTTPResponsePattern, +) { + t.Helper() + + if expected == nil && actual == nil { + return + } + if expected == nil { + t.Errorf("Expected %s nil, got %+v", path, actual) + return + } + if actual == nil { + t.Errorf("Expected %s %+v, got nil", path, expected) + return + } + + if expected.StatusCode != actual.StatusCode { + t.Errorf( + "Expected %s.StatusCode %d, got %d", + path, + expected.StatusCode, + actual.StatusCode, + ) + } + + assertEqualStringMatcherSliceMap( + t, + path+".Headers", + expected.Headers, + actual.Headers, + ) + + assertEqualPtrStringMatcher( + t, + path+".Body", + expected.Body, + actual.Body, + ) + + assertEqualPtrStringMatcher( + t, + path+".BodyJSON", + expected.BodyJSON, + actual.BodyJSON, + ) +} + +func assertEqualHTTPResponse( + t *testing.T, + path string, + expected, + actual *model.HTTPResponse, +) { + t.Helper() + + if expected == nil && actual == nil { + return + } + if expected == nil { + t.Errorf("Expected %s nil, got %+v", path, actual) + return + } + if actual == nil { + t.Errorf("Expected %s %+v, got nil", path, expected) + return + } + + if expected.StatusCode != actual.StatusCode { + t.Errorf( + "Expected %s.StatusCode %d, got %d", + path, + expected.StatusCode, + actual.StatusCode, + ) + } + + assertEqualStringSliceMap( + t, + path+".Headers", + expected.Headers, + actual.Headers, + ) + + if expected.Body != actual.Body { + t.Errorf( + "Expected %s.Body %q, got %q", + path, + expected.Body, + actual.Body, + ) + } + + if expected.BodyJSON != actual.BodyJSON { + t.Errorf( + "Expected %s.BodyJSON %q, got %q", + path, + expected.BodyJSON, + actual.BodyJSON, + ) + } +} diff --git a/util/compare_testexecutions.go b/util/compare_testexecutions.go index de8eeb2..eb914ab 100644 --- a/util/compare_testexecutions.go +++ b/util/compare_testexecutions.go @@ -2,7 +2,6 @@ package util import ( "strconv" - "strings" "testing" "github.com/e2engine/core/model" @@ -86,11 +85,11 @@ func assertEqualTestExecutionSummary( actual.Response, ) - assertEqualTestExecutionExpectedCallsSummary( + assertEqualAllServiceObservedCalls( t, - "Summary.ExpectedCalls", - expected.ExpectedCalls, - actual.ExpectedCalls, + "Summary.Calls", + expected.Calls, + actual.Calls, ) assertEqualTestExecutionDeviations( @@ -123,7 +122,7 @@ func assertEqualTestExecutionRequestSummary( switch { case expected.HTTP != nil && actual.HTTP != nil: - assertEqualTestExecutionHTTPRequestSummary( + assertEqualHTTPRequest( t, path+".HTTP", expected.HTTP, @@ -137,7 +136,7 @@ func assertEqualTestExecutionRequestSummary( switch { case expected.GRPC != nil && actual.GRPC != nil: - assertEqualTestExecutionGRPCRequestSummary( + assertEqualGRPCRequest( t, path+".GRPC", expected.GRPC, @@ -150,47 +149,6 @@ func assertEqualTestExecutionRequestSummary( } } -func assertEqualTestExecutionHTTPRequestSummary( - t *testing.T, - path string, - expected, - actual *model.TestExecutionHTTPRequestSummary, -) { - t.Helper() - - if expected.Method != actual.Method { - t.Errorf("Expected %s.Method %q, got %q", path, expected.Method, actual.Method) - } - if expected.URL != actual.URL { - t.Errorf("Expected %s.URL %q, got %q", path, expected.URL, actual.URL) - } - - assertEqualStringSliceMap(t, path+".Headers", expected.Headers, actual.Headers) - - if expected.BodyJSON != actual.BodyJSON { - t.Errorf("Expected %s.BodyJSON %q, got %q", path, expected.BodyJSON, actual.BodyJSON) - } -} - -func assertEqualTestExecutionGRPCRequestSummary( - t *testing.T, - path string, - expected, - actual *model.TestExecutionGRPCRequestSummary, -) { - t.Helper() - - if expected.Service != actual.Service { - t.Errorf("Expected %s.Service %q, got %q", path, expected.Service, actual.Service) - } - if expected.Method != actual.Method { - t.Errorf("Expected %s.Method %q, got %q", path, expected.Method, actual.Method) - } - - assertEqualStringSliceMap(t, path+".Metadata", expected.Metadata, actual.Metadata) - assertEqualJSONValue(t, path+".Message", expected.Message, actual.Message) -} - func assertEqualTestExecutionResponseSummary( t *testing.T, path string, @@ -213,7 +171,7 @@ func assertEqualTestExecutionResponseSummary( switch { case expected.HTTP != nil && actual.HTTP != nil: - assertEqualTestExecutionHTTPResponseSummary( + assertEqualHTTPResponse( t, path+".HTTP", expected.HTTP, @@ -227,7 +185,7 @@ func assertEqualTestExecutionResponseSummary( switch { case expected.GRPC != nil && actual.GRPC != nil: - assertEqualTestExecutionGRPCResponseSummary( + assertEqualGRPCResponse( t, path+".GRPC", expected.GRPC, @@ -240,46 +198,11 @@ func assertEqualTestExecutionResponseSummary( } } -func assertEqualTestExecutionHTTPResponseSummary( - t *testing.T, - path string, - expected, - actual *model.TestExecutionHTTPResponseSummary, -) { - t.Helper() - - if expected.StatusCode != actual.StatusCode { - t.Errorf("Expected %s.StatusCode %d, got %d", path, expected.StatusCode, actual.StatusCode) - } - if expected.BodyJSON != actual.BodyJSON { - t.Errorf("Expected %s.BodyJSON %q, got %q", path, expected.BodyJSON, actual.BodyJSON) - } - if expected.BodyText != strings.TrimSpace(actual.BodyText) { - t.Errorf("Expected %s.BodyText %q, got %q", path, expected.BodyText, actual.BodyText) - } -} - -func assertEqualTestExecutionGRPCResponseSummary( - t *testing.T, - path string, - expected, - actual *model.TestExecutionGRPCResponseSummary, -) { - t.Helper() - - if expected.Status != actual.Status { - t.Errorf("Expected %s.Status %q, got %q", path, expected.Status, actual.Status) - } - - assertEqualStringSliceMap(t, path+".Metadata", expected.Metadata, actual.Metadata) - assertEqualJSONValue(t, path+".Message", expected.Message, actual.Message) -} - -func assertEqualTestExecutionExpectedCallsSummary( +func assertEqualAllServiceObservedCalls( t *testing.T, path string, expected, - actual []model.TestExecutionCallExpectationSummary, + actual []model.ServiceObservedCalls, ) { t.Helper() @@ -294,7 +217,7 @@ func assertEqualTestExecutionExpectedCallsSummary( } for i := range expected { - assertEqualTestExecutionCallExpectationSummary( + assertEqualServiceObservedCalls( t, path+"["+strconv.Itoa(i)+"]", &expected[i], @@ -303,11 +226,11 @@ func assertEqualTestExecutionExpectedCallsSummary( } } -func assertEqualTestExecutionCallExpectationSummary( +func assertEqualServiceObservedCalls( t *testing.T, path string, expected, - actual *model.TestExecutionCallExpectationSummary, + actual *model.ServiceObservedCalls, ) { t.Helper() @@ -315,16 +238,18 @@ func assertEqualTestExecutionCallExpectationSummary( t.Errorf("Expected %s.ServiceID %q, got %q", path, expected.ServiceID, actual.ServiceID) } - assertEqualIntPointer(t, path+".Count", expected.Count, actual.Count) + if expected.Count != actual.Count { + t.Errorf("Expected %s.Count %d, got %d", path, expected.Count, actual.Count) + } - assertEqualTestExecutionHTTPCallExpectationSummary( + assertEqualHTTPServiceObservedCall( t, path+".HTTP", expected.HTTP, actual.HTTP, ) - assertEqualTestExecutionGRPCCallExpectationSummary( + assertEqualGRPCServiceObservedCall( t, path+".GRPC", expected.GRPC, @@ -332,11 +257,11 @@ func assertEqualTestExecutionCallExpectationSummary( ) } -func assertEqualTestExecutionHTTPCallExpectationSummary( +func assertEqualHTTPServiceObservedCall( t *testing.T, path string, expected, - actual *model.TestExecutionHTTPCallExpectationSummary, + actual *model.HTTPServiceObservedCall, ) { t.Helper() @@ -359,19 +284,19 @@ func assertEqualTestExecutionHTTPCallExpectationSummary( t.Errorf("Expected %s.Path %q, got %q", path, expected.Path, actual.Path) } - assertEqualStringSliceMap(t, path+".Query", expected.Query, actual.Query) - assertEqualStringSliceMap(t, path+".Headers", expected.Headers, actual.Headers) - - if expected.BodyJSON != strings.TrimSpace(actual.BodyJSON) { - t.Errorf("Expected %s.BodyJSON %q, got %q", path, expected.BodyJSON, actual.BodyJSON) - } + assertEqualIntPointer( + t, + path+".ResponseStatusCode", + expected.ResponseStatusCode, + actual.ResponseStatusCode, + ) } -func assertEqualTestExecutionGRPCCallExpectationSummary( +func assertEqualGRPCServiceObservedCall( t *testing.T, path string, expected, - actual *model.TestExecutionGRPCCallExpectationSummary, + actual *model.GRPCServiceObservedCall, ) { t.Helper() @@ -393,20 +318,9 @@ func assertEqualTestExecutionGRPCCallExpectationSummary( if expected.Method != actual.Method { t.Errorf("Expected %s.Method %q, got %q", path, expected.Method, actual.Method) } - - assertEqualStringSliceMap( - t, - path+".Metadata", - expected.Metadata, - actual.Metadata, - ) - - assertEqualJSONValue( - t, - path+".Message", - expected.Message, - actual.Message, - ) + if expected.ResponseStatus != actual.ResponseStatus { + t.Errorf("Expected %s.ResponseStatus %q, got %q", path, expected.ResponseStatus, actual.ResponseStatus) + } } func assertEqualTestExecutionDeviations( diff --git a/util/compare_tests.go b/util/compare_tests.go index 90d3576..5ba90ef 100644 --- a/util/compare_tests.go +++ b/util/compare_tests.go @@ -59,8 +59,8 @@ func assertEqualRequestSpec( ) { t.Helper() - assertEqualHTTPRequestSpec(t, path+".HTTP", expected.HTTP, actual.HTTP) - assertEqualGRPCRequestSpec(t, path+".GRPC", expected.GRPC, actual.GRPC) + assertEqualHTTPRequest(t, path+".HTTP", expected.HTTP, actual.HTTP) + assertEqualGRPCRequest(t, path+".GRPC", expected.GRPC, actual.GRPC) } func assertEqualExpectSpec( @@ -71,8 +71,8 @@ func assertEqualExpectSpec( ) { t.Helper() - assertEqualHTTPExpectSpec(t, path+".HTTP", expected.HTTP, actual.HTTP) - assertEqualGRPCExpectSpec(t, path+".GRPC", expected.GRPC, actual.GRPC) + assertEqualHTTPResponsePattern(t, path+".HTTP", expected.HTTP, actual.HTTP) + assertEqualGRPCResponsePattern(t, path+".GRPC", expected.GRPC, actual.GRPC) if len(expected.Calls) != len(actual.Calls) { t.Errorf( @@ -85,7 +85,7 @@ func assertEqualExpectSpec( } for i := range expected.Calls { - assertEqualCallExpectation( + assertEqualServiceExpectedCalls( t, path+".Calls["+strconv.Itoa(i)+"]", &expected.Calls[i], @@ -94,11 +94,11 @@ func assertEqualExpectSpec( } } -func assertEqualCallExpectation( +func assertEqualServiceExpectedCalls( t *testing.T, path string, expected, - actual *model.CallExpectation, + actual *model.ServiceExpectedCalls, ) { t.Helper() @@ -112,323 +112,8 @@ func assertEqualCallExpectation( } assertEqualIntPointer(t, path+".Count", expected.Count, actual.Count) - assertEqualHTTPCallExpectation(t, path+".HTTP", expected.HTTP, actual.HTTP) - assertEqualGRPCCallExpectation(t, path+".GRPC", expected.GRPC, actual.GRPC) -} - -func assertEqualHTTPCallExpectation( - t *testing.T, - path string, - expected, - actual *model.HTTPCallExpectation, -) { - t.Helper() - - if expected == nil && actual == nil { - return - } - if expected == nil { - t.Errorf("Expected %s nil, got %+v", path, actual) - return - } - if actual == nil { - t.Errorf("Expected %s %+v, got nil", path, expected) - return - } - - if expected.Method != actual.Method { - t.Errorf( - "Expected %s.Method %q, got %q", - path, - expected.Method, - actual.Method, - ) - } - - if expected.Path != actual.Path { - t.Errorf( - "Expected %s.Path %q, got %q", - path, - expected.Path, - actual.Path, - ) - } - - assertEqualStringSliceMap( - t, - path+".Query", - expected.Query, - actual.Query, - ) - - assertEqualStringSliceMap( - t, - path+".Headers", - expected.Headers, - actual.Headers, - ) - - if expected.Body != actual.Body { - t.Errorf( - "Expected %s.Body %q, got %q", - path, - expected.Body, - actual.Body, - ) - } -} - -func assertEqualGRPCCallExpectation( - t *testing.T, - path string, - expected, - actual *model.GRPCCallExpectation, -) { - t.Helper() - - if expected == nil && actual == nil { - return - } - if expected == nil { - t.Errorf("Expected %s nil, got %+v", path, actual) - return - } - if actual == nil { - t.Errorf("Expected %s %+v, got nil", path, expected) - return - } - - if expected.Service != actual.Service { - t.Errorf( - "Expected %s.Service %q, got %q", - path, - expected.Service, - actual.Service, - ) - } - - if expected.Method != actual.Method { - t.Errorf( - "Expected %s.Method %q, got %q", - path, - expected.Method, - actual.Method, - ) - } - - assertEqualStringSliceMap( - t, - path+".Metadata", - expected.Metadata, - actual.Metadata, - ) - - assertEqualJSONValue( - t, - path+".Message", - expected.Message, - actual.Message, - ) -} - -func assertEqualHTTPRequestSpec( - t *testing.T, - path string, - expected, - actual *model.HTTPRequestSpec, -) { - t.Helper() - - if expected == nil && actual == nil { - return - } - if expected == nil { - t.Errorf("Expected %s nil, got %+v", path, actual) - return - } - if actual == nil { - t.Errorf("Expected %s %+v, got nil", path, expected) - return - } - - if expected.Method != actual.Method { - t.Errorf( - "Expected %s.Method %q, got %q", - path, - expected.Method, - actual.Method, - ) - } - - if expected.URL != actual.URL { - t.Errorf( - "Expected %s.URL %q, got %q", - path, - expected.URL, - actual.URL, - ) - } - - assertEqualStringMap( - t, - path+".Query", - expected.Query, - actual.Query, - ) - - assertEqualStringSliceMap( - t, - path+".Headers", - expected.Headers, - actual.Headers, - ) - - if expected.Body != actual.Body { - t.Errorf( - "Expected %s.Body %q, got %q", - path, - expected.Body, - actual.Body, - ) - } -} - -func assertEqualHTTPExpectSpec( - t *testing.T, - path string, - expected, - actual *model.HTTPExpectSpec, -) { - t.Helper() - - if expected == nil && actual == nil { - return - } - if expected == nil { - t.Errorf("Expected %s nil, got %+v", path, actual) - return - } - if actual == nil { - t.Errorf("Expected %s %+v, got nil", path, expected) - return - } - - if expected.Status != actual.Status { - t.Errorf( - "Expected %s.Status %d, got %d", - path, - expected.Status, - actual.Status, - ) - } - - if expected.Body != actual.Body { - t.Errorf( - "Expected %s.Body %q, got %q", - path, - expected.Body, - actual.Body, - ) - } -} - -func assertEqualGRPCRequestSpec( - t *testing.T, - path string, - expected, - actual *model.GRPCRequestSpec, -) { - t.Helper() - - if expected == nil && actual == nil { - return - } - if expected == nil { - t.Errorf("Expected %s nil, got %+v", path, actual) - return - } - if actual == nil { - t.Errorf("Expected %s %+v, got nil", path, expected) - return - } - - if expected.Target != actual.Target { - t.Errorf( - "Expected %s.Target %q, got %q", - path, - expected.Target, - actual.Target, - ) - } - - if expected.Service != actual.Service { - t.Errorf( - "Expected %s.Service %q, got %q", - path, - expected.Service, - actual.Service, - ) - } - - if expected.Method != actual.Method { - t.Errorf( - "Expected %s.Method %q, got %q", - path, - expected.Method, - actual.Method, - ) - } - - assertEqualStringSliceMap( - t, - path+".Metadata", - expected.Metadata, - actual.Metadata, - ) - - assertEqualJSONValue( - t, - path+".Message", - expected.Message, - actual.Message, - ) -} - -func assertEqualGRPCExpectSpec( - t *testing.T, - path string, - expected, - actual *model.GRPCExpectSpec, -) { - t.Helper() - - if expected == nil && actual == nil { - return - } - if expected == nil { - t.Errorf("Expected %s nil, got %+v", path, actual) - return - } - if actual == nil { - t.Errorf("Expected %s %+v, got nil", path, expected) - return - } - - if expected.Status != actual.Status { - t.Errorf( - "Expected %s.Status %q, got %q", - path, - expected.Status, - actual.Status, - ) - } - - assertEqualJSONValue( - t, - path+".Message", - expected.Message, - actual.Message, - ) + assertEqualHTTPRequestPattern(t, path+".HTTP", expected.HTTP, actual.HTTP) + assertEqualGRPCRequestPattern(t, path+".GRPC", expected.GRPC, actual.GRPC) } func assertEqualIntPointer( @@ -491,44 +176,3 @@ func assertEqualStringSlice( } } } - -func assertEqualStringMap( - t *testing.T, - path string, - expected, - actual map[string]string, -) { - t.Helper() - - if len(expected) != len(actual) { - t.Errorf( - "Expected %s length %d, got %d", - path, - len(expected), - len(actual), - ) - return - } - - for key, expectedValue := range expected { - actualValue, ok := actual[key] - if !ok { - t.Errorf( - "Expected %s[%q] to exist", - path, - key, - ) - continue - } - - if expectedValue != actualValue { - t.Errorf( - "Expected %s[%q] %q, got %q", - path, - key, - expectedValue, - actualValue, - ) - } - } -}