From dee4aea73f42c5fd42271a4c64946e8966f74676 Mon Sep 17 00:00:00 2001 From: Yaroslav Grebnov Date: Sat, 17 Oct 2026 13:59:45 +0200 Subject: [PATCH 1/6] Use updated routing --- ...inimal-mocked-called-at-least-once.env.yml | 2 +- .../misspelled-fails-validation.env.yml | 2 +- .../one-of-two-mocked-not-called.env.yml | 4 +- .../real-with-mocked-dependency.env.yml | 6 +- .../real-with-mocked-dependency.env.yml | 6 +- cli/data/direct/direct-mocked-grpc.env.json | 2 +- cli/data/direct/direct-mocked-grpc.env.yml | 2 +- cli/data/direct/direct-mocked-http.env.json | 2 +- cli/data/direct/direct-mocked-http.env.yml | 2 +- cli/data/direct/direct-real-grpc.env.json | 4 +- cli/data/direct/direct-real-grpc.env.yml | 4 +- cli/data/direct/direct-real-http.env.json | 4 +- cli/data/direct/direct-real-http.env.yml | 4 +- .../fixture-miss-grpc-message.env.yml | 6 +- .../fixture-miss-grpc-method.env.yml | 6 +- .../fixture-miss-http-body.env.yml | 6 +- .../fixture-miss-http-path-multiple.env.yml | 6 +- .../fixture-miss-http-path.env.yml | 6 +- .../real-not-calling-dependency.env.yml | 4 +- cli/data/routing/real-grpc-target.env.yml | 15 + cli/data/routing/real-grpc-target.test.yml | 28 ++ cli/data/routing/real-grpc-target.yml | 35 +++ cli/data/routing/real-http-target.env.yml | 11 + cli/data/routing/real-http-target.test.yml | 17 + cli/data/routing/real-http-target.yml | 26 ++ .../real-with-mocked-dependency.env.yml | 6 +- .../transport-kind/socket-grpc-error.env.yml | 4 +- .../unknown-service-in-expected-calls.env.yml | 2 +- .../duplicate-service-address.yml | 8 +- .../duplicate-service-id.yml | 8 +- .../grpc-external-empty-service.yml | 4 +- .../grpc-external-file-and-buf-module.yml | 2 +- ...c-external-neither-file-nor-buf-module.yml | 2 +- .../grpc-fixture-empty-method.yml | 2 +- .../grpc-fixture-invalid-status.yml | 2 +- .../grpc-fixture-missing-grpc-then.yml | 2 +- .../grpc-fixture-missing-grpc-when.yml | 2 +- .../grpc-fixture-on-http-service.yml | 2 +- .../grpc-internal-empty-field-name.yml | 2 +- .../grpc-internal-empty-method-name.yml | 2 +- .../grpc-internal-empty-package.yml | 2 +- .../grpc-internal-empty-service.yml | 2 +- .../grpc-internal-invalid-field-type.yml | 2 +- .../grpc-internal-without-methods.yml | 2 +- .../grpc-proto-both-external-and-internal.yml | 2 +- ...pc-proto-neither-external-nor-internal.yml | 2 +- .../grpc-without-proto.yml | 2 +- .../http-fixture-empty-path.yml | 2 +- .../http-fixture-invalid-method.yml | 2 +- .../http-fixture-invalid-path.yml | 2 +- .../http-fixture-invalid-request-json.yml | 2 +- .../http-fixture-invalid-response-json.yml | 2 +- .../http-fixture-missing-http-then.yml | 2 +- .../http-fixture-missing-http-when.yml | 2 +- .../http-fixture-on-grpc-service.yml | 2 +- .../http-fixture-status-too-high.yml | 2 +- .../http-fixture-status-too-low.yml | 2 +- .../validate-environment/http-with-proto.yml | 2 +- .../invalid-grpc-target.yml | 4 +- .../invalid-service-kind.yml | 2 +- .../invalid-service-mode.yml | 2 +- ...e-address.yml => invalid-service-port.yml} | 2 +- .../invalid-service-target.yml | 4 +- .../mocked-with-target.yml | 4 +- .../mocked-without-fixtures.yml | 2 +- .../real-grpc-with-http-target.yml | 16 - .../real-grpc-with-internal-proto.yml | 2 +- .../real-grpc-without-target.yml | 2 +- .../real-http-with-fixtures.yml | 4 +- .../real-http-with-grpc-target.yml | 12 - .../real-http-without-target.yml | 2 +- .../service-id-too-long.yml | 2 +- .../service-id-too-short.yml | 2 +- .../expected-call-unknown-service.env.yml | 2 +- .../expected-calls-twice.env.yml | 2 +- ...expected-grpc-call-to-http-service.env.yml | 2 +- ...expected-http-call-to-grpc-service.env.yml | 4 +- .../wrong-call-params.env.yml | 2 +- cli/harness/harness.go | 14 +- cli/tests/routing_test.go | 297 ++++++++++++++++++ go.mod | 2 + go.sum | 2 - util/compare_environments.go | 27 +- 83 files changed, 552 insertions(+), 160 deletions(-) create mode 100644 cli/data/routing/real-grpc-target.env.yml create mode 100644 cli/data/routing/real-grpc-target.test.yml create mode 100644 cli/data/routing/real-grpc-target.yml create mode 100644 cli/data/routing/real-http-target.env.yml create mode 100644 cli/data/routing/real-http-target.test.yml create mode 100644 cli/data/routing/real-http-target.yml rename cli/data/validate-environment/{invalid-service-address.yml => invalid-service-port.yml} (83%) delete mode 100644 cli/data/validate-environment/real-grpc-with-http-target.yml delete mode 100644 cli/data/validate-environment/real-http-with-grpc-target.yml create mode 100644 cli/tests/routing_test.go 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 5dc0ef8..c80fecb 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 @@ -7,7 +7,7 @@ spec: - id: minimal-mocked-called-at-least-once kind: http mode: mocked - address: 127.0.0.1:8083 + e2engine_port: 8083 fixtures: - when: http: diff --git a/cli/data/called-at-least-once/misspelled-fails-validation.env.yml b/cli/data/called-at-least-once/misspelled-fails-validation.env.yml index 9c28311..4d7ce47 100644 --- a/cli/data/called-at-least-once/misspelled-fails-validation.env.yml +++ b/cli/data/called-at-least-once/misspelled-fails-validation.env.yml @@ -7,7 +7,7 @@ spec: - id: spelled-correctly kind: http mode: mocked - address: 127.0.0.1:8083 + e2engine_port: 8083 fixtures: - when: http: 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 2dd911f..af165df 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 @@ -7,7 +7,7 @@ spec: - id: called kind: http mode: mocked - address: 127.0.0.1:8082 + e2engine_port: 8082 fixtures: - when: http: @@ -20,7 +20,7 @@ spec: - id: not-called kind: http mode: mocked - address: 127.0.0.1:8083 + e2engine_port: 8083 fixtures: - when: http: 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 8e950f7..f4a65ba 100644 --- a/cli/data/crud-test/real-with-mocked-dependency.env.yml +++ b/cli/data/crud-test/real-with-mocked-dependency.env.yml @@ -7,12 +7,12 @@ spec: - id: gateway kind: http mode: real - address: 127.0.0.1:8082 - http_target: http://127.0.0.1:9000 + e2engine_port: 8082 + target: http://127.0.0.1:9000 - id: entitlements kind: http mode: mocked - address: 127.0.0.1:8083 + e2engine_port: 8083 fixtures: - when: http: 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 8e950f7..f4a65ba 100644 --- a/cli/data/crud-testsuite/real-with-mocked-dependency.env.yml +++ b/cli/data/crud-testsuite/real-with-mocked-dependency.env.yml @@ -7,12 +7,12 @@ spec: - id: gateway kind: http mode: real - address: 127.0.0.1:8082 - http_target: http://127.0.0.1:9000 + e2engine_port: 8082 + target: http://127.0.0.1:9000 - id: entitlements kind: http mode: mocked - address: 127.0.0.1:8083 + e2engine_port: 8083 fixtures: - when: http: diff --git a/cli/data/direct/direct-mocked-grpc.env.json b/cli/data/direct/direct-mocked-grpc.env.json index 7073257..8252e2a 100644 --- a/cli/data/direct/direct-mocked-grpc.env.json +++ b/cli/data/direct/direct-mocked-grpc.env.json @@ -9,7 +9,7 @@ "id": "direct-mocked-grpc", "kind": "grpc", "mode": "mocked", - "address": "127.0.0.1:8083", + "e2engine_port": 8083, "proto": { "internal": { "package": "entitlements.v1", diff --git a/cli/data/direct/direct-mocked-grpc.env.yml b/cli/data/direct/direct-mocked-grpc.env.yml index 4513323..d7dcaf0 100644 --- a/cli/data/direct/direct-mocked-grpc.env.yml +++ b/cli/data/direct/direct-mocked-grpc.env.yml @@ -7,7 +7,7 @@ spec: - id: direct-mocked-grpc kind: grpc mode: mocked - address: 127.0.0.1:8083 + e2engine_port: 8083 proto: internal: package: entitlements.v1 diff --git a/cli/data/direct/direct-mocked-http.env.json b/cli/data/direct/direct-mocked-http.env.json index 05678af..17e22ff 100644 --- a/cli/data/direct/direct-mocked-http.env.json +++ b/cli/data/direct/direct-mocked-http.env.json @@ -9,7 +9,7 @@ "id": "direct-mocked-http", "kind": "http", "mode": "mocked", - "address": "127.0.0.1:8083", + "e2engine_port": 8083, "fixtures": [ { "when": { diff --git a/cli/data/direct/direct-mocked-http.env.yml b/cli/data/direct/direct-mocked-http.env.yml index 32a9cc2..6170940 100644 --- a/cli/data/direct/direct-mocked-http.env.yml +++ b/cli/data/direct/direct-mocked-http.env.yml @@ -7,7 +7,7 @@ spec: - id: direct-mocked-http kind: http mode: mocked - address: 127.0.0.1:8083 + e2engine_port: 8083 fixtures: - when: http: diff --git a/cli/data/direct/direct-real-grpc.env.json b/cli/data/direct/direct-real-grpc.env.json index 82030b1..4a3f574 100644 --- a/cli/data/direct/direct-real-grpc.env.json +++ b/cli/data/direct/direct-real-grpc.env.json @@ -9,8 +9,8 @@ "id": "direct-real-grpc", "kind": "grpc", "mode": "real", - "address": "127.0.0.1:8083", - "grpc_target": "127.0.0.1:9000", + "e2engine_port": 8083, + "target": "127.0.0.1:9000", "proto": { "external": { "file": "../../services/ok-grpc/ok.proto", diff --git a/cli/data/direct/direct-real-grpc.env.yml b/cli/data/direct/direct-real-grpc.env.yml index 73424a0..43f4fcb 100644 --- a/cli/data/direct/direct-real-grpc.env.yml +++ b/cli/data/direct/direct-real-grpc.env.yml @@ -7,8 +7,8 @@ spec: - id: direct-real-grpc kind: grpc mode: real - address: 127.0.0.1:8083 - grpc_target: 127.0.0.1:9000 + e2engine_port: 8083 + target: 127.0.0.1:9000 proto: external: file: ../../services/ok-grpc/ok.proto diff --git a/cli/data/direct/direct-real-http.env.json b/cli/data/direct/direct-real-http.env.json index 3f12909..f424a81 100644 --- a/cli/data/direct/direct-real-http.env.json +++ b/cli/data/direct/direct-real-http.env.json @@ -9,8 +9,8 @@ "id": "direct-real-http", "kind": "http", "mode": "real", - "address": "127.0.0.1:8083", - "http_target": "http://127.0.0.1:9000" + "e2engine_port": 8083, + "target": "http://127.0.0.1:9000" } ] } diff --git a/cli/data/direct/direct-real-http.env.yml b/cli/data/direct/direct-real-http.env.yml index c3ee734..c17cb5b 100644 --- a/cli/data/direct/direct-real-http.env.yml +++ b/cli/data/direct/direct-real-http.env.yml @@ -7,5 +7,5 @@ spec: - id: direct-real-http kind: http mode: real - address: 127.0.0.1:8083 - http_target: http://127.0.0.1:9000 + e2engine_port: 8083 + target: http://127.0.0.1:9000 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 f690d76..6b4c8ba 100644 --- a/cli/data/fixture-miss/fixture-miss-grpc-message.env.yml +++ b/cli/data/fixture-miss/fixture-miss-grpc-message.env.yml @@ -8,13 +8,13 @@ spec: - id: gateway kind: http mode: real - address: 127.0.0.1:8082 - http_target: http://127.0.0.1:9000 + e2engine_port: 8082 + target: http://127.0.0.1:9000 - id: entitlements kind: grpc mode: mocked - address: 127.0.0.1:8083 + e2engine_port: 8083 proto: internal: 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 974d492..eb3ca1b 100644 --- a/cli/data/fixture-miss/fixture-miss-grpc-method.env.yml +++ b/cli/data/fixture-miss/fixture-miss-grpc-method.env.yml @@ -8,13 +8,13 @@ spec: - id: gateway kind: http mode: real - address: 127.0.0.1:8082 - http_target: http://127.0.0.1:9000 + e2engine_port: 8082 + target: http://127.0.0.1:9000 - id: entitlements kind: grpc mode: mocked - address: 127.0.0.1:8083 + e2engine_port: 8083 proto: internal: 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 5e813df..daddd0e 100644 --- a/cli/data/fixture-miss/fixture-miss-http-body.env.yml +++ b/cli/data/fixture-miss/fixture-miss-http-body.env.yml @@ -7,12 +7,12 @@ spec: - id: gateway kind: http mode: real - address: 127.0.0.1:8082 - http_target: http://127.0.0.1:9000 + e2engine_port: 8082 + target: http://127.0.0.1:9000 - id: entitlements kind: http mode: mocked - address: 127.0.0.1:8083 + e2engine_port: 8083 fixtures: - when: http: 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 1002fd9..e4cab29 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 @@ -7,12 +7,12 @@ spec: - id: gateway kind: http mode: real - address: 127.0.0.1:8082 - http_target: http://127.0.0.1:9000 + e2engine_port: 8082 + target: http://127.0.0.1:9000 - id: entitlements kind: http mode: mocked - address: 127.0.0.1:8083 + e2engine_port: 8083 fixtures: - when: http: 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 b95a633..70f2a05 100644 --- a/cli/data/fixture-miss/fixture-miss-http-path.env.yml +++ b/cli/data/fixture-miss/fixture-miss-http-path.env.yml @@ -7,12 +7,12 @@ spec: - id: gateway kind: http mode: real - address: 127.0.0.1:8082 - http_target: http://127.0.0.1:9000 + e2engine_port: 8082 + target: http://127.0.0.1:9000 - id: entitlements kind: http mode: mocked - address: 127.0.0.1:8083 + e2engine_port: 8083 fixtures: - when: http: diff --git a/cli/data/real-not-calling-dependency/real-not-calling-dependency.env.yml b/cli/data/real-not-calling-dependency/real-not-calling-dependency.env.yml index 99222b6..e0bf994 100644 --- a/cli/data/real-not-calling-dependency/real-not-calling-dependency.env.yml +++ b/cli/data/real-not-calling-dependency/real-not-calling-dependency.env.yml @@ -7,5 +7,5 @@ spec: - id: real-not-calling-dependency kind: http mode: real - address: 127.0.0.1:8082 - http_target: http://127.0.0.1:9000 + e2engine_port: 8082 + target: http://127.0.0.1:9000 diff --git a/cli/data/routing/real-grpc-target.env.yml b/cli/data/routing/real-grpc-target.env.yml new file mode 100644 index 0000000..bcad306 --- /dev/null +++ b/cli/data/routing/real-grpc-target.env.yml @@ -0,0 +1,15 @@ +kind: Environment +version: 1.0.0 +name: real-grpc-target +description: real gRPC service with mapped target +spec: + services: + - id: gateway + kind: grpc + mode: real + e2engine_port: 8083 + target: gateway-host:9000 + proto: + external: + file: ../../services/ok-grpc/ok.proto + service: ok.v1.OKService diff --git a/cli/data/routing/real-grpc-target.test.yml b/cli/data/routing/real-grpc-target.test.yml new file mode 100644 index 0000000..ea709d0 --- /dev/null +++ b/cli/data/routing/real-grpc-target.test.yml @@ -0,0 +1,28 @@ +kind: Test +version: 1.0.0 +name: real-grpc-target +description: real-grpc-target service is called + +spec: + request: + grpc: + target: gateway-host:8083 + service: ok.v1.OKService + method: OK + + expect: + grpc: + status: OK + metadata: + "content-type": + - "application/grpc" + calls: + - service_id: gateway + 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/routing/real-grpc-target.yml b/cli/data/routing/real-grpc-target.yml new file mode 100644 index 0000000..ae01753 --- /dev/null +++ b/cli/data/routing/real-grpc-target.yml @@ -0,0 +1,35 @@ +id: f5497dfbbf8392b4828f5323c07e4b5cc8026790caca7b3065350413bebbd4e3 +started_at: 2026-08-19T15:16:47.974744Z +finished_at: 2026-08-19T15:16:47.993394Z +status: passed +environment_id: 7398ab887149ec5aa583c564a659a0b0a933ef27bacb675b081a2a752d8a3896 +environment_name: real-grpc-target +test_id: ae619f9418f89041a5f6e0e952eae9fb9495e2c271b66739ffd6fae46f9ff30a +test_name: real-grpc-target +summary: + request: + grpc: + target: 127.0.0.1:8083 + service: ok.v1.OKService + method: OK + metadata: + "e2engine-test-execution-id": + - "c1079d334b1a17b4a5fa7588a90d045ed01ea241c53ab51afa0d8b8620837e7b" + response: + grpc: + status: OK + metadata: + "content-type": + - "application/grpc" + message: + : null + calls: + - service_id: gateway + count: 1 + grpc: + service: ok.v1.OKService + method: OK + response_status: OK + metadata: + "content-type": + - "application/grpc" diff --git a/cli/data/routing/real-http-target.env.yml b/cli/data/routing/real-http-target.env.yml new file mode 100644 index 0000000..94fb10e --- /dev/null +++ b/cli/data/routing/real-http-target.env.yml @@ -0,0 +1,11 @@ +kind: Environment +version: 1.0.0 +name: real-http-target +description: real HTTP service with mapped target +spec: + services: + - id: gateway + kind: http + mode: real + e2engine_port: 8083 + target: http://gateway-host:9000 \ No newline at end of file diff --git a/cli/data/routing/real-http-target.test.yml b/cli/data/routing/real-http-target.test.yml new file mode 100644 index 0000000..64170ef --- /dev/null +++ b/cli/data/routing/real-http-target.test.yml @@ -0,0 +1,17 @@ +kind: Test +version: 1.0.0 +name: real-http-target +description: real-http-target service is called +spec: + request: + http: + method: GET + url: http://gateway-host:8083/ok + expect: + http: + status_code: 200 + calls: + - service_id: gateway + http: + method: GET + path: /ok \ No newline at end of file diff --git a/cli/data/routing/real-http-target.yml b/cli/data/routing/real-http-target.yml new file mode 100644 index 0000000..cb67459 --- /dev/null +++ b/cli/data/routing/real-http-target.yml @@ -0,0 +1,26 @@ +id: f5497dfbbf8392b4828f5323c07e4b5cc8026790caca7b3065350413bebbd4e3 +started_at: 2026-08-19T15:16:47.974744Z +finished_at: 2026-08-19T15:16:47.993394Z +status: passed +environment_id: 7398ab887149ec5aa583c564a659a0b0a933ef27bacb675b081a2a752d8a3896 +environment_name: real-http-target +test_id: ae619f9418f89041a5f6e0e952eae9fb9495e2c271b66739ffd6fae46f9ff30a +test_name: real-http-target +summary: + request: + http: + method: GET + url: http://127.0.0.1:8083/ok + headers: + "E2engine-Test-Execution-Id": + - "c1079d334b1a17b4a5fa7588a90d045ed01ea241c53ab51afa0d8b8620837e7b" + response: + http: + status_code: 200 + calls: + - service_id: gateway + count: 1 + http: + method: GET + path: /ok + response_status_code: 200 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 8e950f7..f4a65ba 100644 --- a/cli/data/transport-kind/real-with-mocked-dependency.env.yml +++ b/cli/data/transport-kind/real-with-mocked-dependency.env.yml @@ -7,12 +7,12 @@ spec: - id: gateway kind: http mode: real - address: 127.0.0.1:8082 - http_target: http://127.0.0.1:9000 + e2engine_port: 8082 + target: http://127.0.0.1:9000 - id: entitlements kind: http mode: mocked - address: 127.0.0.1:8083 + e2engine_port: 8083 fixtures: - when: http: diff --git a/cli/data/transport-kind/socket-grpc-error.env.yml b/cli/data/transport-kind/socket-grpc-error.env.yml index e234de0..51f2a79 100644 --- a/cli/data/transport-kind/socket-grpc-error.env.yml +++ b/cli/data/transport-kind/socket-grpc-error.env.yml @@ -7,8 +7,8 @@ spec: - id: socket-grpc-error kind: grpc mode: real - address: 127.0.0.1:8083 - grpc_target: 127.0.0.1:9000 + e2engine_port: 8083 + target: 127.0.0.1:9000 proto: external: file: ../services/ok-grpc/missing.proto 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 e96bde2..86eac4d 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 @@ -7,7 +7,7 @@ spec: - id: unknown-service-in-expected-calls kind: http mode: mocked - address: 127.0.0.1:8083 + e2engine_port: 8083 fixtures: - when: http: diff --git a/cli/data/validate-environment/duplicate-service-address.yml b/cli/data/validate-environment/duplicate-service-address.yml index e47eaa7..887c692 100644 --- a/cli/data/validate-environment/duplicate-service-address.yml +++ b/cli/data/validate-environment/duplicate-service-address.yml @@ -7,11 +7,11 @@ spec: - id: service-one kind: http mode: real - address: 127.0.0.1:8081 - http_target: http://127.0.0.1:9001 + e2engine_port: 8081 + target: http://127.0.0.1:9001 - id: service-two kind: http mode: real - address: 127.0.0.1:8081 - http_target: http://127.0.0.1:9002 \ No newline at end of file + e2engine_port: 8081 + target: http://127.0.0.1:9002 \ No newline at end of file diff --git a/cli/data/validate-environment/duplicate-service-id.yml b/cli/data/validate-environment/duplicate-service-id.yml index 1f1f8e4..fd33200 100644 --- a/cli/data/validate-environment/duplicate-service-id.yml +++ b/cli/data/validate-environment/duplicate-service-id.yml @@ -7,11 +7,11 @@ spec: - id: service kind: http mode: real - address: 127.0.0.1:8081 - http_target: http://127.0.0.1:9001 + e2engine_port: 8081 + target: http://127.0.0.1:9001 - id: service kind: http mode: real - address: 127.0.0.1:8082 - http_target: http://127.0.0.1:9002 \ No newline at end of file + e2engine_port: 8082 + target: http://127.0.0.1:9002 \ No newline at end of file diff --git a/cli/data/validate-environment/grpc-external-empty-service.yml b/cli/data/validate-environment/grpc-external-empty-service.yml index 9f2bcc6..49885de 100644 --- a/cli/data/validate-environment/grpc-external-empty-service.yml +++ b/cli/data/validate-environment/grpc-external-empty-service.yml @@ -7,8 +7,8 @@ spec: - id: service kind: grpc mode: real - address: 127.0.0.1:8081 - grpc_target: 127.0.0.1:8082 + e2engine_port: 8081 + target: 127.0.0.1:8082 proto: external: file: service.proto diff --git a/cli/data/validate-environment/grpc-external-file-and-buf-module.yml b/cli/data/validate-environment/grpc-external-file-and-buf-module.yml index 73764d3..3ef4ad5 100644 --- a/cli/data/validate-environment/grpc-external-file-and-buf-module.yml +++ b/cli/data/validate-environment/grpc-external-file-and-buf-module.yml @@ -7,7 +7,7 @@ spec: - id: grpc-service kind: grpc mode: real - address: 127.0.0.1:8083 + e2engine_port: 8083 proto: external: diff --git a/cli/data/validate-environment/grpc-external-neither-file-nor-buf-module.yml b/cli/data/validate-environment/grpc-external-neither-file-nor-buf-module.yml index 68abe51..0f0967f 100644 --- a/cli/data/validate-environment/grpc-external-neither-file-nor-buf-module.yml +++ b/cli/data/validate-environment/grpc-external-neither-file-nor-buf-module.yml @@ -7,7 +7,7 @@ spec: - id: grpc-service kind: grpc mode: real - address: 127.0.0.1:8083 + e2engine_port: 8083 proto: external: diff --git a/cli/data/validate-environment/grpc-fixture-empty-method.yml b/cli/data/validate-environment/grpc-fixture-empty-method.yml index eabfc3f..705d1a1 100644 --- a/cli/data/validate-environment/grpc-fixture-empty-method.yml +++ b/cli/data/validate-environment/grpc-fixture-empty-method.yml @@ -7,7 +7,7 @@ spec: - id: service kind: grpc mode: mocked - address: 127.0.0.1:8081 + e2engine_port: 8081 proto: internal: package: test diff --git a/cli/data/validate-environment/grpc-fixture-invalid-status.yml b/cli/data/validate-environment/grpc-fixture-invalid-status.yml index 4b8c6b8..95e07cc 100644 --- a/cli/data/validate-environment/grpc-fixture-invalid-status.yml +++ b/cli/data/validate-environment/grpc-fixture-invalid-status.yml @@ -7,7 +7,7 @@ spec: - id: service kind: grpc mode: mocked - address: 127.0.0.1:8081 + e2engine_port: 8081 proto: internal: package: test 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 8c23b76..94fabcb 100644 --- a/cli/data/validate-environment/grpc-fixture-missing-grpc-then.yml +++ b/cli/data/validate-environment/grpc-fixture-missing-grpc-then.yml @@ -7,7 +7,7 @@ spec: - id: service kind: grpc mode: mocked - address: 127.0.0.1:8081 + e2engine_port: 8081 proto: internal: package: test.v1 diff --git a/cli/data/validate-environment/grpc-fixture-missing-grpc-when.yml b/cli/data/validate-environment/grpc-fixture-missing-grpc-when.yml index 8cfd413..aa4df25 100644 --- a/cli/data/validate-environment/grpc-fixture-missing-grpc-when.yml +++ b/cli/data/validate-environment/grpc-fixture-missing-grpc-when.yml @@ -7,7 +7,7 @@ spec: - id: service kind: grpc mode: mocked - address: 127.0.0.1:8081 + e2engine_port: 8081 proto: internal: package: test.v1 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 d531c60..79af0e1 100644 --- a/cli/data/validate-environment/grpc-fixture-on-http-service.yml +++ b/cli/data/validate-environment/grpc-fixture-on-http-service.yml @@ -7,7 +7,7 @@ spec: - id: service kind: http mode: mocked - address: 127.0.0.1:8081 + e2engine_port: 8081 fixtures: - when: 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 942be53..328049b 100644 --- a/cli/data/validate-environment/grpc-internal-empty-field-name.yml +++ b/cli/data/validate-environment/grpc-internal-empty-field-name.yml @@ -7,7 +7,7 @@ spec: - id: service kind: grpc mode: mocked - address: 127.0.0.1:8081 + e2engine_port: 8081 proto: internal: package: test 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 6cfb6d2..ef60474 100644 --- a/cli/data/validate-environment/grpc-internal-empty-method-name.yml +++ b/cli/data/validate-environment/grpc-internal-empty-method-name.yml @@ -7,7 +7,7 @@ spec: - id: service kind: grpc mode: mocked - address: 127.0.0.1:8081 + e2engine_port: 8081 proto: internal: package: test diff --git a/cli/data/validate-environment/grpc-internal-empty-package.yml b/cli/data/validate-environment/grpc-internal-empty-package.yml index 097683f..1c3651f 100644 --- a/cli/data/validate-environment/grpc-internal-empty-package.yml +++ b/cli/data/validate-environment/grpc-internal-empty-package.yml @@ -7,7 +7,7 @@ spec: - id: service kind: grpc mode: mocked - address: 127.0.0.1:8081 + e2engine_port: 8081 proto: internal: package: "" diff --git a/cli/data/validate-environment/grpc-internal-empty-service.yml b/cli/data/validate-environment/grpc-internal-empty-service.yml index 455017f..665629f 100644 --- a/cli/data/validate-environment/grpc-internal-empty-service.yml +++ b/cli/data/validate-environment/grpc-internal-empty-service.yml @@ -7,7 +7,7 @@ spec: - id: service kind: grpc mode: mocked - address: 127.0.0.1:8081 + e2engine_port: 8081 proto: internal: package: test 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 0e25d1c..f35f31c 100644 --- a/cli/data/validate-environment/grpc-internal-invalid-field-type.yml +++ b/cli/data/validate-environment/grpc-internal-invalid-field-type.yml @@ -7,7 +7,7 @@ spec: - id: service kind: grpc mode: mocked - address: 127.0.0.1:8081 + e2engine_port: 8081 proto: internal: package: test diff --git a/cli/data/validate-environment/grpc-internal-without-methods.yml b/cli/data/validate-environment/grpc-internal-without-methods.yml index 975eddd..08e9e9b 100644 --- a/cli/data/validate-environment/grpc-internal-without-methods.yml +++ b/cli/data/validate-environment/grpc-internal-without-methods.yml @@ -7,7 +7,7 @@ spec: - id: grpc-service kind: grpc mode: mocked - address: 127.0.0.1:8083 + e2engine_port: 8083 proto: internal: 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 e56bbb6..ffad3f9 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 @@ -7,7 +7,7 @@ spec: - id: grpc-service kind: grpc mode: mocked - address: 127.0.0.1:8083 + e2engine_port: 8083 proto: external: 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 ac7a0d3..e5b6b8d 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 @@ -7,7 +7,7 @@ spec: - id: grpc-service kind: grpc mode: mocked - address: 127.0.0.1:8083 + e2engine_port: 8083 proto: {} diff --git a/cli/data/validate-environment/grpc-without-proto.yml b/cli/data/validate-environment/grpc-without-proto.yml index 61e38d6..43e5667 100644 --- a/cli/data/validate-environment/grpc-without-proto.yml +++ b/cli/data/validate-environment/grpc-without-proto.yml @@ -7,4 +7,4 @@ spec: - id: service kind: grpc mode: real - address: 127.0.0.1:8081 \ No newline at end of file + e2engine_port: 8081 \ No newline at end of file diff --git a/cli/data/validate-environment/http-fixture-empty-path.yml b/cli/data/validate-environment/http-fixture-empty-path.yml index d530410..baf7600 100644 --- a/cli/data/validate-environment/http-fixture-empty-path.yml +++ b/cli/data/validate-environment/http-fixture-empty-path.yml @@ -7,7 +7,7 @@ spec: - id: service kind: http mode: mocked - address: 127.0.0.1:8081 + e2engine_port: 8081 fixtures: - when: diff --git a/cli/data/validate-environment/http-fixture-invalid-method.yml b/cli/data/validate-environment/http-fixture-invalid-method.yml index c7d452c..8f6a0b5 100644 --- a/cli/data/validate-environment/http-fixture-invalid-method.yml +++ b/cli/data/validate-environment/http-fixture-invalid-method.yml @@ -7,7 +7,7 @@ spec: - id: service kind: http mode: mocked - address: 127.0.0.1:8081 + e2engine_port: 8081 fixtures: - when: diff --git a/cli/data/validate-environment/http-fixture-invalid-path.yml b/cli/data/validate-environment/http-fixture-invalid-path.yml index 93a8cd4..1c27ca2 100644 --- a/cli/data/validate-environment/http-fixture-invalid-path.yml +++ b/cli/data/validate-environment/http-fixture-invalid-path.yml @@ -7,7 +7,7 @@ spec: - id: service kind: http mode: mocked - address: 127.0.0.1:8081 + e2engine_port: 8081 fixtures: - when: http: 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 416ef00..9e97056 100644 --- a/cli/data/validate-environment/http-fixture-invalid-request-json.yml +++ b/cli/data/validate-environment/http-fixture-invalid-request-json.yml @@ -7,7 +7,7 @@ spec: - id: service kind: http mode: mocked - address: 127.0.0.1:8081 + e2engine_port: 8081 fixtures: - when: 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 13c111f..6f49250 100644 --- a/cli/data/validate-environment/http-fixture-invalid-response-json.yml +++ b/cli/data/validate-environment/http-fixture-invalid-response-json.yml @@ -7,7 +7,7 @@ spec: - id: service kind: http mode: mocked - address: 127.0.0.1:8081 + e2engine_port: 8081 fixtures: - when: diff --git a/cli/data/validate-environment/http-fixture-missing-http-then.yml b/cli/data/validate-environment/http-fixture-missing-http-then.yml index 0459cbc..34e2a76 100644 --- a/cli/data/validate-environment/http-fixture-missing-http-then.yml +++ b/cli/data/validate-environment/http-fixture-missing-http-then.yml @@ -7,7 +7,7 @@ spec: - id: service kind: http mode: mocked - address: 127.0.0.1:8081 + e2engine_port: 8081 fixtures: - when: 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 6a35861..863c3ee 100644 --- a/cli/data/validate-environment/http-fixture-missing-http-when.yml +++ b/cli/data/validate-environment/http-fixture-missing-http-when.yml @@ -7,7 +7,7 @@ spec: - id: service kind: http mode: mocked - address: 127.0.0.1:8081 + e2engine_port: 8081 fixtures: - when: {} 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 72604a6..3f61562 100644 --- a/cli/data/validate-environment/http-fixture-on-grpc-service.yml +++ b/cli/data/validate-environment/http-fixture-on-grpc-service.yml @@ -7,7 +7,7 @@ spec: - id: service kind: grpc mode: mocked - address: 127.0.0.1:8081 + e2engine_port: 8081 proto: internal: package: test.v1 diff --git a/cli/data/validate-environment/http-fixture-status-too-high.yml b/cli/data/validate-environment/http-fixture-status-too-high.yml index c53e530..94a13b6 100644 --- a/cli/data/validate-environment/http-fixture-status-too-high.yml +++ b/cli/data/validate-environment/http-fixture-status-too-high.yml @@ -7,7 +7,7 @@ spec: - id: service kind: http mode: mocked - address: 127.0.0.1:8081 + e2engine_port: 8081 fixtures: - when: diff --git a/cli/data/validate-environment/http-fixture-status-too-low.yml b/cli/data/validate-environment/http-fixture-status-too-low.yml index e4fcd2c..47dd920 100644 --- a/cli/data/validate-environment/http-fixture-status-too-low.yml +++ b/cli/data/validate-environment/http-fixture-status-too-low.yml @@ -7,7 +7,7 @@ spec: - id: service kind: http mode: mocked - address: 127.0.0.1:8081 + e2engine_port: 8081 fixtures: - when: diff --git a/cli/data/validate-environment/http-with-proto.yml b/cli/data/validate-environment/http-with-proto.yml index 091cdd1..3aa99e5 100644 --- a/cli/data/validate-environment/http-with-proto.yml +++ b/cli/data/validate-environment/http-with-proto.yml @@ -7,7 +7,7 @@ spec: - id: service kind: http mode: real - address: 127.0.0.1:8081 + e2engine_port: 8081 target: 127.0.0.1:9001 proto: buf_module: example diff --git a/cli/data/validate-environment/invalid-grpc-target.yml b/cli/data/validate-environment/invalid-grpc-target.yml index aeeef1e..ca3b1b5 100644 --- a/cli/data/validate-environment/invalid-grpc-target.yml +++ b/cli/data/validate-environment/invalid-grpc-target.yml @@ -7,5 +7,5 @@ spec: - id: service kind: grpc mode: real - address: 127.0.0.1:8081 - grpc_target: invalid \ No newline at end of file + e2engine_port: 8081 + target: invalid \ No newline at end of file diff --git a/cli/data/validate-environment/invalid-service-kind.yml b/cli/data/validate-environment/invalid-service-kind.yml index 6a66059..d60d77f 100644 --- a/cli/data/validate-environment/invalid-service-kind.yml +++ b/cli/data/validate-environment/invalid-service-kind.yml @@ -7,5 +7,5 @@ spec: - id: service kind: websocket mode: real - address: 127.0.0.1:8081 + e2engine_port: 8081 target: 127.0.0.1:9001 \ No newline at end of file diff --git a/cli/data/validate-environment/invalid-service-mode.yml b/cli/data/validate-environment/invalid-service-mode.yml index 0d45405..59a5ba1 100644 --- a/cli/data/validate-environment/invalid-service-mode.yml +++ b/cli/data/validate-environment/invalid-service-mode.yml @@ -7,4 +7,4 @@ spec: - id: service kind: http mode: proxy - address: 127.0.0.1:8081 \ No newline at end of file + e2engine_port: 8081 \ No newline at end of file diff --git a/cli/data/validate-environment/invalid-service-address.yml b/cli/data/validate-environment/invalid-service-port.yml similarity index 83% rename from cli/data/validate-environment/invalid-service-address.yml rename to cli/data/validate-environment/invalid-service-port.yml index 9b2e541..dbab231 100644 --- a/cli/data/validate-environment/invalid-service-address.yml +++ b/cli/data/validate-environment/invalid-service-port.yml @@ -7,5 +7,5 @@ spec: - id: service kind: http mode: real - address: not-an-address + e2engine_port: not-a-port target: 127.0.0.1:9001 \ No newline at end of file diff --git a/cli/data/validate-environment/invalid-service-target.yml b/cli/data/validate-environment/invalid-service-target.yml index ba7b74b..70d80d2 100644 --- a/cli/data/validate-environment/invalid-service-target.yml +++ b/cli/data/validate-environment/invalid-service-target.yml @@ -7,5 +7,5 @@ spec: - id: service kind: http mode: real - address: 127.0.0.1:8081 - http_target: not-an-address \ No newline at end of file + e2engine_port: 8081 + target: not-an-address \ 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 009ceac..f1abec6 100644 --- a/cli/data/validate-environment/mocked-with-target.yml +++ b/cli/data/validate-environment/mocked-with-target.yml @@ -7,8 +7,8 @@ spec: - id: service kind: http mode: mocked - address: 127.0.0.1:8081 - http_target: http://127.0.0.1:9001 + e2engine_port: 127.0.0.1:8081 + target: http://127.0.0.1:9001 fixtures: - when: diff --git a/cli/data/validate-environment/mocked-without-fixtures.yml b/cli/data/validate-environment/mocked-without-fixtures.yml index 720432b..eed9c7b 100644 --- a/cli/data/validate-environment/mocked-without-fixtures.yml +++ b/cli/data/validate-environment/mocked-without-fixtures.yml @@ -7,4 +7,4 @@ spec: - id: service kind: http mode: mocked - address: 127.0.0.1:8081 \ No newline at end of file + e2engine_port: 8081 \ No newline at end of file diff --git a/cli/data/validate-environment/real-grpc-with-http-target.yml b/cli/data/validate-environment/real-grpc-with-http-target.yml deleted file mode 100644 index f8a8c09..0000000 --- a/cli/data/validate-environment/real-grpc-with-http-target.yml +++ /dev/null @@ -1,16 +0,0 @@ -kind: Environment -version: 1.0.0 -name: real-grpc-with-http-target - -spec: - services: - - id: service - kind: grpc - mode: real - address: 127.0.0.1:8081 - http_target: http://127.0.0.1:8082 - grpc_target: 127.0.0.1:8083 - proto: - external: - file: service.proto - service: Service \ No newline at end of file diff --git a/cli/data/validate-environment/real-grpc-with-internal-proto.yml b/cli/data/validate-environment/real-grpc-with-internal-proto.yml index 5c779a6..1475f2e 100644 --- a/cli/data/validate-environment/real-grpc-with-internal-proto.yml +++ b/cli/data/validate-environment/real-grpc-with-internal-proto.yml @@ -7,7 +7,7 @@ spec: - id: grpc-service kind: grpc mode: real - address: 127.0.0.1:8083 + e2engine_port: 8083 proto: internal: diff --git a/cli/data/validate-environment/real-grpc-without-target.yml b/cli/data/validate-environment/real-grpc-without-target.yml index be5c5cf..6d2059f 100644 --- a/cli/data/validate-environment/real-grpc-without-target.yml +++ b/cli/data/validate-environment/real-grpc-without-target.yml @@ -7,7 +7,7 @@ spec: - id: service kind: grpc mode: real - address: 127.0.0.1:8081 + e2engine_port: 8081 proto: external: file: service.proto diff --git a/cli/data/validate-environment/real-http-with-fixtures.yml b/cli/data/validate-environment/real-http-with-fixtures.yml index 6236dcd..8ce7eaf 100644 --- a/cli/data/validate-environment/real-http-with-fixtures.yml +++ b/cli/data/validate-environment/real-http-with-fixtures.yml @@ -7,8 +7,8 @@ spec: - id: service kind: http mode: real - address: 127.0.0.1:8081 - http_target: http://127.0.0.1:9001 + e2engine_port: 8081 + target: http://127.0.0.1:9001 fixtures: - when: diff --git a/cli/data/validate-environment/real-http-with-grpc-target.yml b/cli/data/validate-environment/real-http-with-grpc-target.yml deleted file mode 100644 index 976403b..0000000 --- a/cli/data/validate-environment/real-http-with-grpc-target.yml +++ /dev/null @@ -1,12 +0,0 @@ -kind: Environment -version: 1.0.0 -name: real-http-with-grpc-target - -spec: - services: - - id: service - kind: http - mode: real - address: 127.0.0.1:8081 - http_target: http://127.0.0.1:8082 - grpc_target: 127.0.0.1:8083 \ No newline at end of file diff --git a/cli/data/validate-environment/real-http-without-target.yml b/cli/data/validate-environment/real-http-without-target.yml index cfb7b65..3066632 100644 --- a/cli/data/validate-environment/real-http-without-target.yml +++ b/cli/data/validate-environment/real-http-without-target.yml @@ -7,4 +7,4 @@ spec: - id: service kind: http mode: real - address: 127.0.0.1:8081 \ No newline at end of file + e2engine_port: 8081 \ No newline at end of file diff --git a/cli/data/validate-environment/service-id-too-long.yml b/cli/data/validate-environment/service-id-too-long.yml index 6d6b71b..1ef07dd 100644 --- a/cli/data/validate-environment/service-id-too-long.yml +++ b/cli/data/validate-environment/service-id-too-long.yml @@ -7,5 +7,5 @@ spec: - id: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa kind: http mode: real - address: 127.0.0.1:8081 + e2engine_port: 8081 target: 127.0.0.1:9001 \ No newline at end of file diff --git a/cli/data/validate-environment/service-id-too-short.yml b/cli/data/validate-environment/service-id-too-short.yml index d5364d8..c71ae29 100644 --- a/cli/data/validate-environment/service-id-too-short.yml +++ b/cli/data/validate-environment/service-id-too-short.yml @@ -7,5 +7,5 @@ spec: - id: ab kind: http mode: real - address: 127.0.0.1:8081 + e2engine_port: 8081 target: 127.0.0.1:9001 \ 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 566879a..93c903d 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 @@ -8,7 +8,7 @@ spec: - id: known-service kind: http mode: mocked - address: 127.0.0.1:8082 + e2engine_port: 8082 fixtures: - when: http: 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 acac561..fdeaf0f 100644 --- a/cli/data/validate-expected-calls/expected-calls-twice.env.yml +++ b/cli/data/validate-expected-calls/expected-calls-twice.env.yml @@ -7,7 +7,7 @@ spec: - id: expected-calls-twice kind: http mode: mocked - address: 127.0.0.1:8083 + e2engine_port: 8083 fixtures: - when: http: 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 60a2011..c5a6448 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 @@ -8,7 +8,7 @@ spec: - id: http-dependency kind: http mode: mocked - address: 127.0.0.1:8082 + e2engine_port: 8082 fixtures: - when: http: 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 c807321..8eeb32a 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 @@ -8,7 +8,7 @@ spec: - id: entry kind: http mode: mocked - address: 127.0.0.1:8082 + e2engine_port: 8082 fixtures: - when: http: @@ -21,7 +21,7 @@ spec: - id: grpc-dependency kind: grpc mode: mocked - address: 127.0.0.1:9090 + e2engine_port: 9090 proto: internal: package: example 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 8f67947..bd221dc 100644 --- a/cli/data/validate-expected-calls/wrong-call-params.env.yml +++ b/cli/data/validate-expected-calls/wrong-call-params.env.yml @@ -7,7 +7,7 @@ spec: - id: wrong-call-params kind: http mode: mocked - address: 127.0.0.1:8083 + e2engine_port: 8083 fixtures: - when: http: diff --git a/cli/harness/harness.go b/cli/harness/harness.go index 8d160c5..01ed206 100644 --- a/cli/harness/harness.go +++ b/cli/harness/harness.go @@ -139,10 +139,10 @@ func (h *Harness) GetTestSuiteExecution(ctx context.Context, ref string) model.T return get[model.TestSuiteExecution](ctx, h, ref, "testsuiteexecution") } -func (h *Harness) RunTest(ctx context.Context, testRef, envRef string) string { +func (h *Harness) RunTest(ctx context.Context, testRef, envRef string, args ...string) string { h.t.Helper() - return run(ctx, h, "test", testRef, envRef) + return run(ctx, h, "test", testRef, envRef, args...) } func (h *Harness) RunTestSuite(ctx context.Context, tsRef, envRef string) string { @@ -282,15 +282,15 @@ func get[T any](ctx context.Context, h *Harness, ref, kind string) T { return result } -func run(ctx context.Context, h *Harness, kind, testRef, envRef string) string { +func run(ctx context.Context, h *Harness, kind, testRef, envRef string, args ...string) string { h.t.Helper() + runArgs := []string{"run", kind, testRef, envRef} + runArgs = append(runArgs, args...) + stdout, stderr, err := h.RunCommand( ctx, - "run", - kind, - testRef, - envRef, + runArgs..., ) if err != nil { h.t.Fatalf("Unexpected RunCommand error: %v, stderr: %s", err, stderr) diff --git a/cli/tests/routing_test.go b/cli/tests/routing_test.go new file mode 100644 index 0000000..bd083ef --- /dev/null +++ b/cli/tests/routing_test.go @@ -0,0 +1,297 @@ +package tests + +import ( + "context" + "path" + "testing" + + "github.com/e2engine/tests/cli/harness" +) + +// Routing tests intentionally invoke E2Engine's proxy directly to verify +// hostname resolution and upstream forwarding without requiring a SUT. + +func TestRouting(t *testing.T) { + dataDir := "../data/routing" + + tests := []struct { + name string + specName string + services []string + env map[string]string + checkParams func(id string) *checkTestExecutionParams + listenInterface string + }{ + { + name: "real-http-target", + specName: "real-http-target", + services: []string{ + "ok-http", + }, + checkParams: func(id string) *checkTestExecutionParams { + return &checkTestExecutionParams{ + useHTTPRequestHeaders: map[string]string{ + "E2engine-Test-Execution-Id": id, + }, + } + }, + }, + { + name: "real-grpc-target", + specName: "real-grpc-target", + services: []string{ + "ok-grpc", + }, + checkParams: func(id string) *checkTestExecutionParams { + return &checkTestExecutionParams{ + useGRPCRequestMetadata: map[string]string{ + "e2engine-test-execution-id": id, + }, + } + }, + }, + { + name: "real-http-target-socket", + specName: "real-http-target", + services: []string{ + "ok-http", + }, + env: map[string]string{ + "E2ENGINE_TRANSPORT_KIND": "socket", + "E2ENGINE_TRANSPORT_ADDRESS": "127.0.0.1:19001", + }, + checkParams: func(id string) *checkTestExecutionParams { + return &checkTestExecutionParams{ + useHTTPRequestHeaders: map[string]string{ + "E2engine-Test-Execution-Id": id, + }, + } + }, + }, + { + name: "real-grpc-target-socket", + specName: "real-grpc-target", + services: []string{ + "ok-grpc", + }, + env: map[string]string{ + "E2ENGINE_TRANSPORT_KIND": "socket", + "E2ENGINE_TRANSPORT_ADDRESS": "127.0.0.1:19002", + }, + checkParams: func(id string) *checkTestExecutionParams { + return &checkTestExecutionParams{ + useGRPCRequestMetadata: map[string]string{ + "e2engine-test-execution-id": id, + }, + } + }, + }, + { + name: "real-http-listen-loopback", + specName: "real-http-target", + services: []string{"ok-http"}, + listenInterface: "127.0.0.1", + checkParams: func(id string) *checkTestExecutionParams { + return &checkTestExecutionParams{ + useHTTPRequestHeaders: map[string]string{ + "E2engine-Test-Execution-Id": id, + }, + } + }, + }, + { + name: "real-http-listen-all", + specName: "real-http-target", + services: []string{"ok-http"}, + listenInterface: "0.0.0.0", + checkParams: func(id string) *checkTestExecutionParams { + return &checkTestExecutionParams{ + useHTTPRequestHeaders: map[string]string{ + "E2engine-Test-Execution-Id": id, + }, + } + }, + }, + { + name: "real-http-listen-all-socket", + specName: "real-http-target", + services: []string{"ok-http"}, + listenInterface: "0.0.0.0", + env: map[string]string{ + "E2ENGINE_TRANSPORT_KIND": "socket", + "E2ENGINE_TRANSPORT_ADDRESS": "127.0.0.1:19002", + }, + checkParams: func(id string) *checkTestExecutionParams { + return &checkTestExecutionParams{ + useHTTPRequestHeaders: map[string]string{ + "E2engine-Test-Execution-Id": id, + }, + } + }, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + ctx, cancel := context.WithTimeout( + context.Background(), + defaultTestTimeout, + ) + defer cancel() + + serviceCtx, serviceCancel := context.WithCancel( + context.Background(), + ) + t.Cleanup(serviceCancel) + + for key, value := range test.env { + t.Setenv(key, value) + } + + h := harness.New( + t, + "../bin/cli", + "", + path.Join(t.TempDir(), "data"), + ) + + for _, service := range test.services { + s := h.StartService(serviceCtx, service) + t.Cleanup(func() { + s.Stop(t) + }) + } + + environmentID := h.CreateEnvironment( + ctx, + test.specName, + path.Join( + dataDir, + test.specName+".env.yml", + ), + ) + + testID := h.CreateTest( + ctx, + test.specName, + path.Join( + dataDir, + test.specName+".test.yml", + ), + ) + + t.Setenv("E2ENGINE_RUNNER_WORKER_REPORTER_DUMP_PAYLOAD", "true") + + args := []string{ + "--host", + "gateway-host=127.0.0.1", + } + + if test.listenInterface != "" { + args = append( + args, + "--listen-interface", + test.listenInterface, + ) + } + + testExecutionID := h.RunTest( + ctx, + testID, + environmentID, + args..., + ) + + actualTestExecution := h.GetTestExecution( + ctx, + testExecutionID, + ) + + var checkParams *checkTestExecutionParams + + if test.checkParams != nil { + checkParams = test.checkParams(testExecutionID) + } + + checkTestExecution( + t, + testExecutionID, + environmentID, + testID, + path.Join(dataDir, test.specName+".yml"), + &actualTestExecution, + checkParams, + ) + }) + } +} + + +func TestRouting_InvalidListenInterface(t *testing.T) { + dataDir := "../data/routing" + + ctx, cancel := context.WithTimeout( + context.Background(), + defaultTestTimeout, + ) + defer cancel() + + serviceCtx, serviceCancel := context.WithCancel( + context.Background(), + ) + t.Cleanup(serviceCancel) + + h := harness.New( + t, + "../bin/cli", + "", + path.Join(t.TempDir(), "data"), + ) + + s := h.StartService(serviceCtx, "ok-http") + t.Cleanup(func() { + s.Stop(t) + }) + + environmentID := h.CreateEnvironment( + ctx, + "real-http-target", + path.Join( + dataDir, + "real-http-target.env.yml", + ), + ) + + testID := h.CreateTest( + ctx, + "real-http-target", + path.Join( + dataDir, + "real-http-target.test.yml", + ), + ) + + stdout, stderr, err := h.RunCommand( + ctx, + "run", + "test", + "--listen-interface", + "not-an-ip-address", + testID, + environmentID, + ) + if err == nil { + t.Fatalf("expected error due to invalid listen interface, but got none. stdout: %s, stderr: %s", stdout, stderr) + } + + expectedStderr := "cannot initialize service, cause: cannot load config, " + + "cause: - Field \"Runtime.E2EngineListenInterface\": " + + "rule \"ip\": invalid E2Engine listen interface IP address\n" + if stderr != expectedStderr { + t.Fatalf("incorrect stderr, got: %s, want: %s", stderr, expectedStderr) + } + + if stdout != "" { + t.Fatalf("expected no stdout output, got: %s", stdout) + } +} \ No newline at end of file diff --git a/go.mod b/go.mod index a87d763..41d790a 100644 --- a/go.mod +++ b/go.mod @@ -21,3 +21,5 @@ require ( golang.org/x/text v0.43.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20261012220534-4341edf3f941 // indirect ) + +replace github.com/e2engine/core => ../core diff --git a/go.sum b/go.sum index 5fc60fc..3edb841 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,3 @@ -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= diff --git a/util/compare_environments.go b/util/compare_environments.go index 539b1bd..e5293ef 100644 --- a/util/compare_environments.go +++ b/util/compare_environments.go @@ -107,30 +107,21 @@ func assertEqualServiceSpec( ) } - if expected.Address != actual.Address { + if expected.E2EnginePort != actual.E2EnginePort { t.Errorf( - "Expected %s %q, got %q", - prefix("Address"), - expected.Address, - actual.Address, - ) - } - - if expected.HTTPTarget != actual.HTTPTarget { - t.Errorf( - "Expected %s %q, got %q", - prefix("HTTPTarget"), - expected.HTTPTarget, - actual.HTTPTarget, + "Expected %s %d, got %d", + prefix("E2EnginePort"), + expected.E2EnginePort, + actual.E2EnginePort, ) } - if expected.GRPCTarget != actual.GRPCTarget { + if expected.Target != actual.Target { t.Errorf( "Expected %s %q, got %q", - prefix("GRPCTarget"), - expected.GRPCTarget, - actual.GRPCTarget, + prefix("Target"), + expected.Target, + actual.Target, ) } From bc844f71abd88cc8fb3bd6dcf2950d017b918703 Mon Sep 17 00:00:00 2001 From: Yaroslav Grebnov Date: Thu, 12 Nov 2026 22:13:41 +0100 Subject: [PATCH 2/6] Use updated core models and telemetry --- Makefile | 16 +- README.md | 5 +- cli/data/transport-kind/socket-grpc-error.yml | 2 +- .../grpc-target-invalid-address.yml | 15 + .../grpc-with-http-headers.yml | 19 + .../http-fixture-request-both-bodies.yml | 24 ++ .../http-fixture-response-both-bodies.yml | 20 + .../http-target-invalid-port.yml | 11 + .../http-target-with-query.yml | 11 + .../http-target-with-userinfo.yml | 11 + .../http-with-grpc-metadata.yml | 15 + .../invalid-service-port.json | 16 + .../mocked-with-target.yml | 2 +- .../service-port-too-high.yml | 11 + .../service-port-too-low.yml | 11 + .../valid-mocked-http.yml | 19 + .../validate-environment/valid-real-http.yml | 11 + .../validate-test/grpc-request-empty-host.yml | 14 + .../grpc-request-invalid-port.yml | 14 + .../validate-test/http-call-both-bodies.yml | 25 ++ .../validate-test/http-call-invalid-path.yml | 19 + .../validate-test/http-expect-both-bodies.yml | 19 + .../http-request-both-bodies.yml | 15 + .../http-request-url-invalid-port.yml | 13 + .../http-request-url-with-query.yml | 13 + .../http-request-url-with-userinfo.yml | 13 + cli/data/validate-testsuite/all-selectors.yml | 4 +- cli/data/validate-testsuite/duplicate-id.yml | 4 +- .../validate-testsuite/id-valid-length.yml | 8 + cli/data/validate-testsuite/ids-and-names.yml | 2 +- .../invalid-resource-id.yml | 9 + .../invalid-resource-version.yml | 8 + .../resource-description-too-short.yml | 9 + ...-length.yml => resource-name-too-long.yml} | 7 +- ...length.yml => resource-name-too-short.yml} | 6 +- .../same-value-across-selectors.yml | 12 + cli/harness/service.go | 1 + cli/harness/telemetry.go | 42 ++ cli/tests/config_test.go | 5 +- cli/tests/socket_config_test.go | 60 +++ cli/tests/telemetry_test.go | 287 ++++++++++++++ cli/tests/validate_environment_test.go | 373 ++++++++++++++---- cli/tests/validate_test_test.go | 228 +++++++++-- cli/tests/validate_testsuite_test.go | 110 ++++-- docker/data/direct/direct-mocked-grpc.env.yml | 2 +- docker/data/direct/direct-mocked-http.env.yml | 2 +- docker/data/direct/direct-real-http.env.yml | 4 +- go.mod | 4 +- go.sum | 2 + services/telemetry-http/main.go | 248 ++++++++++++ 50 files changed, 1646 insertions(+), 155 deletions(-) create mode 100644 cli/data/validate-environment/grpc-target-invalid-address.yml create mode 100644 cli/data/validate-environment/grpc-with-http-headers.yml create mode 100644 cli/data/validate-environment/http-fixture-request-both-bodies.yml create mode 100644 cli/data/validate-environment/http-fixture-response-both-bodies.yml create mode 100644 cli/data/validate-environment/http-target-invalid-port.yml create mode 100644 cli/data/validate-environment/http-target-with-query.yml create mode 100644 cli/data/validate-environment/http-target-with-userinfo.yml create mode 100644 cli/data/validate-environment/http-with-grpc-metadata.yml create mode 100644 cli/data/validate-environment/invalid-service-port.json create mode 100644 cli/data/validate-environment/service-port-too-high.yml create mode 100644 cli/data/validate-environment/service-port-too-low.yml create mode 100644 cli/data/validate-environment/valid-mocked-http.yml create mode 100644 cli/data/validate-environment/valid-real-http.yml create mode 100644 cli/data/validate-test/grpc-request-empty-host.yml create mode 100644 cli/data/validate-test/grpc-request-invalid-port.yml create mode 100644 cli/data/validate-test/http-call-both-bodies.yml create mode 100644 cli/data/validate-test/http-call-invalid-path.yml create mode 100644 cli/data/validate-test/http-expect-both-bodies.yml create mode 100644 cli/data/validate-test/http-request-both-bodies.yml create mode 100644 cli/data/validate-test/http-request-url-invalid-port.yml create mode 100644 cli/data/validate-test/http-request-url-with-query.yml create mode 100644 cli/data/validate-test/http-request-url-with-userinfo.yml create mode 100644 cli/data/validate-testsuite/id-valid-length.yml create mode 100644 cli/data/validate-testsuite/invalid-resource-id.yml create mode 100644 cli/data/validate-testsuite/invalid-resource-version.yml create mode 100644 cli/data/validate-testsuite/resource-description-too-short.yml rename cli/data/validate-testsuite/{id-max-length.yml => resource-name-too-long.yml} (61%) rename cli/data/validate-testsuite/{id-min-length.yml => resource-name-too-short.yml} (57%) create mode 100644 cli/data/validate-testsuite/same-value-across-selectors.yml create mode 100644 cli/harness/telemetry.go create mode 100644 cli/tests/socket_config_test.go create mode 100644 cli/tests/telemetry_test.go create mode 100644 services/telemetry-http/main.go diff --git a/Makefile b/Makefile index 22456a0..7fff48d 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,8 @@ endif CLI_BIN_NAME := e2engine-$(GOOS)-$(GOARCH)$(shell [ "$(GOOS)" = windows ] && echo .exe) CLI_BIN := $(ROOT_PATH)cli/bin/cli +CLI_VERSION ?= v0.0.0-e2e +CLI_TELEMETRY_BASE_URL ?= http://127.0.0.1:39091 .PHONY: build-cli build-cli: @@ -38,7 +40,7 @@ build-cli: cd $(CLI_SRC); \ mkdir -p $(dir $(CLI_BIN)); \ echo "Building $(CLI_BIN_NAME) binary..."; \ - $(MAKE) build-cli; \ + $(MAKE) build-cli VERSION=$(CLI_VERSION) TELEMETRY_BASE_URL=$(CLI_TELEMETRY_BASE_URL); \ cp bin/$(CLI_BIN_NAME) $(CLI_BIN) @echo "$(CLI_BIN) built successfully" @@ -81,6 +83,12 @@ build-ok-grpc-service: @go build -o $(SERVICES_BIN_PATH)/ok-grpc ./services/ok-grpc @echo "Ok gRPC service built successfully at $(SERVICES_BIN_PATH)/ok-grpc" +.PHONY: build-telemetry-http-service +build-telemetry-http-service: + @echo "Building telemetry HTTP service..." + @go build -o $(SERVICES_BIN_PATH)/telemetry-http ./services/telemetry-http + @echo "Telemetry HTTP service built successfully at $(SERVICES_BIN_PATH)/telemetry-http" + .PHONY: protoc-ok-service protoc-ok-service: @echo "Generating protobuf code for ok service..." @@ -143,6 +151,7 @@ build: build-cli \ build-gateway-grpc-method-service \ build-ok-http-service \ build-ok-grpc-service \ + build-telemetry-http-service \ build-image \ build-ok-http-image @echo "All test binaries and images built successfully." @@ -158,9 +167,10 @@ test-cli: build-cli \ build-gateway-grpc-message-service \ build-gateway-grpc-method-service \ build-ok-http-service \ - build-ok-grpc-service + build-ok-grpc-service \ + build-telemetry-http-service @echo "Running CLI tests..." - @go test ./cli/... -count=1 + @E2ENGINE_TELEMETRY_DISABLED=1 go test ./cli/... -count=1 .PHONY: test-docker test-docker: build-image \ diff --git a/README.md b/README.md index 0edf401..5625fc7 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ The CLI, Docker images, and helper service binaries required by the tests are bu | Real-to-mocked dependencies | Real HTTP/gRPC services calling mocked dependencies with captured calls | | Call expectations | Required calls, expected call counts, unmatched call parameters, and missing expected dependencies | | Execution results | Passed, failed, and error terminal states with persisted execution summaries | +| Telemetry | CLI opt-out, installation registration and reuse, authenticated events, outcome mapping, and best-effort failures against a standalone HTTP mock | | Runner lifecycle | Direct execution waits for completion; socket executions run asynchronously and sequentially | | Docker | CLI execution in containers, mounted configuration and persistent data, mocked HTTP/gRPC execution, and communication with real services over a Docker network | @@ -33,7 +34,7 @@ The E2E suite focuses on behavior across component boundaries. Exhaustive field- ```text cli/ CLI E2E tests, harness, test data, and generated CLI binary docker/ Docker E2E tests, harness, configuration, and test data -services/ Helper HTTP/gRPC services, generated service binaries, and reusable service Dockerfile +services/ Helper HTTP/gRPC services, the telemetry HTTP mock, generated service binaries, and the reusable service Dockerfile util/ Shared E2E comparison and test utilities ``` @@ -119,4 +120,4 @@ This repository is part of E2Engine. ## License -Licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE). \ No newline at end of file +Licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE). diff --git a/cli/data/transport-kind/socket-grpc-error.yml b/cli/data/transport-kind/socket-grpc-error.yml index fe5208a..d8cd618 100644 --- a/cli/data/transport-kind/socket-grpc-error.yml +++ b/cli/data/transport-kind/socket-grpc-error.yml @@ -7,4 +7,4 @@ environment_name: socket-grpc-error 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" + error: "the specified path is inaccessible, file.path: ../services/ok-grpc/missing.proto" diff --git a/cli/data/validate-environment/grpc-target-invalid-address.yml b/cli/data/validate-environment/grpc-target-invalid-address.yml new file mode 100644 index 0000000..05794dd --- /dev/null +++ b/cli/data/validate-environment/grpc-target-invalid-address.yml @@ -0,0 +1,15 @@ +kind: Environment +version: 1.0.0 +name: grpc-target-invalid-address + +spec: + services: + - id: service + kind: grpc + mode: real + e2engine_port: 8080 + target: invalid-address + proto: + external: + file: service.proto + service: example.Service \ No newline at end of file diff --git a/cli/data/validate-environment/grpc-with-http-headers.yml b/cli/data/validate-environment/grpc-with-http-headers.yml new file mode 100644 index 0000000..af2f66d --- /dev/null +++ b/cli/data/validate-environment/grpc-with-http-headers.yml @@ -0,0 +1,19 @@ +kind: Environment +version: 1.0.0 +name: grpc-with-http-headers + +spec: + services: + - id: service + kind: grpc + mode: real + e2engine_port: 8080 + target: 127.0.0.1:9001 + request_defaults: + headers: + X-Test: + - value + proto: + external: + file: service.proto + service: example.Service \ No newline at end of file diff --git a/cli/data/validate-environment/http-fixture-request-both-bodies.yml b/cli/data/validate-environment/http-fixture-request-both-bodies.yml new file mode 100644 index 0000000..a2db53e --- /dev/null +++ b/cli/data/validate-environment/http-fixture-request-both-bodies.yml @@ -0,0 +1,24 @@ +kind: Environment +version: 1.0.0 +name: http-fixture-request-both-bodies + +spec: + services: + - id: service + kind: http + mode: mocked + e2engine_port: 8080 + fixtures: + - when: + http: + method: POST + path: /test + body: + operator: equals + value: hello + body_json: + operator: equals + value: '{"message":"hello"}' + then: + http: + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-environment/http-fixture-response-both-bodies.yml b/cli/data/validate-environment/http-fixture-response-both-bodies.yml new file mode 100644 index 0000000..731fd68 --- /dev/null +++ b/cli/data/validate-environment/http-fixture-response-both-bodies.yml @@ -0,0 +1,20 @@ +kind: Environment +version: 1.0.0 +name: http-fixture-response-both-bodies + +spec: + services: + - id: service + kind: http + mode: mocked + e2engine_port: 8080 + fixtures: + - when: + http: + method: GET + path: /test + then: + http: + status_code: 200 + body: hello + body_json: '{"message":"hello"}' \ No newline at end of file diff --git a/cli/data/validate-environment/http-target-invalid-port.yml b/cli/data/validate-environment/http-target-invalid-port.yml new file mode 100644 index 0000000..6ddf9e5 --- /dev/null +++ b/cli/data/validate-environment/http-target-invalid-port.yml @@ -0,0 +1,11 @@ +kind: Environment +version: 1.0.0 +name: http-target-invalid-port + +spec: + services: + - id: service + kind: http + mode: real + e2engine_port: 8080 + target: http://127.0.0.1:99999 \ No newline at end of file diff --git a/cli/data/validate-environment/http-target-with-query.yml b/cli/data/validate-environment/http-target-with-query.yml new file mode 100644 index 0000000..abc8948 --- /dev/null +++ b/cli/data/validate-environment/http-target-with-query.yml @@ -0,0 +1,11 @@ +kind: Environment +version: 1.0.0 +name: http-target-with-query + +spec: + services: + - id: service + kind: http + mode: real + e2engine_port: 8080 + target: http://127.0.0.1:9001?debug=true \ No newline at end of file diff --git a/cli/data/validate-environment/http-target-with-userinfo.yml b/cli/data/validate-environment/http-target-with-userinfo.yml new file mode 100644 index 0000000..ca40959 --- /dev/null +++ b/cli/data/validate-environment/http-target-with-userinfo.yml @@ -0,0 +1,11 @@ +kind: Environment +version: 1.0.0 +name: http-target-with-userinfo + +spec: + services: + - id: service + kind: http + mode: real + e2engine_port: 8080 + target: http://user:password@127.0.0.1:9001 \ No newline at end of file diff --git a/cli/data/validate-environment/http-with-grpc-metadata.yml b/cli/data/validate-environment/http-with-grpc-metadata.yml new file mode 100644 index 0000000..814ed3a --- /dev/null +++ b/cli/data/validate-environment/http-with-grpc-metadata.yml @@ -0,0 +1,15 @@ +kind: Environment +version: 1.0.0 +name: http-with-grpc-metadata + +spec: + services: + - id: service + kind: http + mode: real + e2engine_port: 8080 + target: http://127.0.0.1:9001 + request_defaults: + metadata: + authorization: + - token \ No newline at end of file diff --git a/cli/data/validate-environment/invalid-service-port.json b/cli/data/validate-environment/invalid-service-port.json new file mode 100644 index 0000000..a17f7ea --- /dev/null +++ b/cli/data/validate-environment/invalid-service-port.json @@ -0,0 +1,16 @@ +{ + "kind": "Environment", + "version": "1.0.0", + "name": "invalid-service-address", + "spec": { + "services": [ + { + "id": "service", + "kind": "http", + "mode": "real", + "e2engine_port": "not-a-port", + "target": "127.0.0.1:9001" + } + ] + } +} diff --git a/cli/data/validate-environment/mocked-with-target.yml b/cli/data/validate-environment/mocked-with-target.yml index f1abec6..2ccfc15 100644 --- a/cli/data/validate-environment/mocked-with-target.yml +++ b/cli/data/validate-environment/mocked-with-target.yml @@ -7,7 +7,7 @@ spec: - id: service kind: http mode: mocked - e2engine_port: 127.0.0.1:8081 + e2engine_port: 8081 target: http://127.0.0.1:9001 fixtures: diff --git a/cli/data/validate-environment/service-port-too-high.yml b/cli/data/validate-environment/service-port-too-high.yml new file mode 100644 index 0000000..9bcb48f --- /dev/null +++ b/cli/data/validate-environment/service-port-too-high.yml @@ -0,0 +1,11 @@ +kind: Environment +version: 1.0.0 +name: service-port-too-high + +spec: + services: + - id: service + kind: http + mode: real + e2engine_port: 65536 + target: http://127.0.0.1:9001 \ No newline at end of file diff --git a/cli/data/validate-environment/service-port-too-low.yml b/cli/data/validate-environment/service-port-too-low.yml new file mode 100644 index 0000000..8185c37 --- /dev/null +++ b/cli/data/validate-environment/service-port-too-low.yml @@ -0,0 +1,11 @@ +kind: Environment +version: 1.0.0 +name: service-port-too-low + +spec: + services: + - id: service + kind: http + mode: real + e2engine_port: 0 + target: http://127.0.0.1:9001 \ No newline at end of file diff --git a/cli/data/validate-environment/valid-mocked-http.yml b/cli/data/validate-environment/valid-mocked-http.yml new file mode 100644 index 0000000..0a29c82 --- /dev/null +++ b/cli/data/validate-environment/valid-mocked-http.yml @@ -0,0 +1,19 @@ +kind: Environment +version: 1.0.0 +name: valid-mocked-http + +spec: + services: + - id: service + kind: http + mode: mocked + e2engine_port: 8080 + fixtures: + - when: + http: + method: GET + path: /health + then: + http: + status_code: 200 + body: OK \ No newline at end of file diff --git a/cli/data/validate-environment/valid-real-http.yml b/cli/data/validate-environment/valid-real-http.yml new file mode 100644 index 0000000..b57e7c4 --- /dev/null +++ b/cli/data/validate-environment/valid-real-http.yml @@ -0,0 +1,11 @@ +kind: Environment +version: 1.0.0 +name: valid-real-http + +spec: + services: + - id: service + kind: http + mode: real + e2engine_port: 8080 + target: http://127.0.0.1:9001 \ No newline at end of file diff --git a/cli/data/validate-test/grpc-request-empty-host.yml b/cli/data/validate-test/grpc-request-empty-host.yml new file mode 100644 index 0000000..c44b7d5 --- /dev/null +++ b/cli/data/validate-test/grpc-request-empty-host.yml @@ -0,0 +1,14 @@ +kind: Test +version: 1.0.0 +name: grpc-request-empty-host + +spec: + request: + grpc: + target: ":9001" + service: example.Service + method: Get + + expect: + grpc: + status: OK \ No newline at end of file diff --git a/cli/data/validate-test/grpc-request-invalid-port.yml b/cli/data/validate-test/grpc-request-invalid-port.yml new file mode 100644 index 0000000..f567d9a --- /dev/null +++ b/cli/data/validate-test/grpc-request-invalid-port.yml @@ -0,0 +1,14 @@ +kind: Test +version: 1.0.0 +name: grpc-request-invalid-port + +spec: + request: + grpc: + target: 127.0.0.1:0 + service: example.Service + method: Get + + expect: + grpc: + status: OK \ No newline at end of file diff --git a/cli/data/validate-test/http-call-both-bodies.yml b/cli/data/validate-test/http-call-both-bodies.yml new file mode 100644 index 0000000..d658fa9 --- /dev/null +++ b/cli/data/validate-test/http-call-both-bodies.yml @@ -0,0 +1,25 @@ +kind: Test +version: 1.0.0 +name: http-call-both-bodies + +spec: + request: + http: + method: GET + url: http://127.0.0.1:8080/test + + expect: + http: + status_code: 200 + + calls: + - service_id: service + http: + method: POST + path: /payment + body: + operator: equals + value: hello + body_json: + operator: equals + value: '{"amount":100}' \ No newline at end of file diff --git a/cli/data/validate-test/http-call-invalid-path.yml b/cli/data/validate-test/http-call-invalid-path.yml new file mode 100644 index 0000000..f3d5841 --- /dev/null +++ b/cli/data/validate-test/http-call-invalid-path.yml @@ -0,0 +1,19 @@ +kind: Test +version: 1.0.0 +name: http-call-invalid-path + +spec: + request: + http: + method: GET + url: http://127.0.0.1:8080/test + + expect: + http: + status_code: 200 + + calls: + - service_id: service + http: + method: GET + path: /payment?debug=true \ No newline at end of file diff --git a/cli/data/validate-test/http-expect-both-bodies.yml b/cli/data/validate-test/http-expect-both-bodies.yml new file mode 100644 index 0000000..8f8a744 --- /dev/null +++ b/cli/data/validate-test/http-expect-both-bodies.yml @@ -0,0 +1,19 @@ +kind: Test +version: 1.0.0 +name: http-expect-both-bodies + +spec: + request: + http: + method: GET + url: http://127.0.0.1:8080/test + + expect: + http: + status_code: 200 + body: + operator: equals + value: hello + body_json: + operator: equals + value: '{"message":"hello"}' \ No newline at end of file diff --git a/cli/data/validate-test/http-request-both-bodies.yml b/cli/data/validate-test/http-request-both-bodies.yml new file mode 100644 index 0000000..862013a --- /dev/null +++ b/cli/data/validate-test/http-request-both-bodies.yml @@ -0,0 +1,15 @@ +kind: Test +version: 1.0.0 +name: http-request-both-bodies + +spec: + request: + http: + method: POST + url: http://127.0.0.1:8080/test + body: hello + body_json: '{"message":"hello"}' + + expect: + http: + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-test/http-request-url-invalid-port.yml b/cli/data/validate-test/http-request-url-invalid-port.yml new file mode 100644 index 0000000..8db478f --- /dev/null +++ b/cli/data/validate-test/http-request-url-invalid-port.yml @@ -0,0 +1,13 @@ +kind: Test +version: 1.0.0 +name: http-request-url-invalid-port + +spec: + request: + http: + method: GET + url: http://127.0.0.1:99999/test + + expect: + http: + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-test/http-request-url-with-query.yml b/cli/data/validate-test/http-request-url-with-query.yml new file mode 100644 index 0000000..41d4b90 --- /dev/null +++ b/cli/data/validate-test/http-request-url-with-query.yml @@ -0,0 +1,13 @@ +kind: Test +version: 1.0.0 +name: http-request-url-with-query + +spec: + request: + http: + method: GET + url: http://127.0.0.1:8080/test?debug=true + + expect: + http: + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-test/http-request-url-with-userinfo.yml b/cli/data/validate-test/http-request-url-with-userinfo.yml new file mode 100644 index 0000000..d1e8a9f --- /dev/null +++ b/cli/data/validate-test/http-request-url-with-userinfo.yml @@ -0,0 +1,13 @@ +kind: Test +version: 1.0.0 +name: http-request-url-with-userinfo + +spec: + request: + http: + method: GET + url: http://user:password@127.0.0.1:8080/test + + expect: + http: + status_code: 200 \ No newline at end of file diff --git a/cli/data/validate-testsuite/all-selectors.yml b/cli/data/validate-testsuite/all-selectors.yml index b7e17f3..200da62 100644 --- a/cli/data/validate-testsuite/all-selectors.yml +++ b/cli/data/validate-testsuite/all-selectors.yml @@ -5,8 +5,8 @@ name: all-selectors spec: selectors: ids: - - abc - - def + - 7398ab887149ec5aa583c564a659a0b0a933ef27bacb675b081a2a752d8a3896 + - 7398ab887149ec5aa583c564a659a0b0a933ef27bacb675b081a2a752d8a3897 names: - healthz - checkout diff --git a/cli/data/validate-testsuite/duplicate-id.yml b/cli/data/validate-testsuite/duplicate-id.yml index 6e74523..3a9b85b 100644 --- a/cli/data/validate-testsuite/duplicate-id.yml +++ b/cli/data/validate-testsuite/duplicate-id.yml @@ -5,5 +5,5 @@ name: duplicate-id spec: selectors: ids: - - id - - id \ No newline at end of file + - 7398ab887149ec5aa583c564a659a0b0a933ef27bacb675b081a2a752d8a3896 + - 7398ab887149ec5aa583c564a659a0b0a933ef27bacb675b081a2a752d8a3896 \ No newline at end of file diff --git a/cli/data/validate-testsuite/id-valid-length.yml b/cli/data/validate-testsuite/id-valid-length.yml new file mode 100644 index 0000000..e554a6e --- /dev/null +++ b/cli/data/validate-testsuite/id-valid-length.yml @@ -0,0 +1,8 @@ +kind: TestSuite +version: 1.0.0 +name: id-min-length + +spec: + selectors: + ids: + - 7398ab887149ec5aa583c564a659a0b0a933ef27bacb675b081a2a752d8a3896 \ No newline at end of file diff --git a/cli/data/validate-testsuite/ids-and-names.yml b/cli/data/validate-testsuite/ids-and-names.yml index a1af999..c0f5cdb 100644 --- a/cli/data/validate-testsuite/ids-and-names.yml +++ b/cli/data/validate-testsuite/ids-and-names.yml @@ -5,6 +5,6 @@ name: ids-and-names spec: selectors: ids: - - abc + - 7398ab887149ec5aa583c564a659a0b0a933ef27bacb675b081a2a752d8a3896 names: - healthz \ No newline at end of file diff --git a/cli/data/validate-testsuite/invalid-resource-id.yml b/cli/data/validate-testsuite/invalid-resource-id.yml new file mode 100644 index 0000000..5b12a55 --- /dev/null +++ b/cli/data/validate-testsuite/invalid-resource-id.yml @@ -0,0 +1,9 @@ +kind: TestSuite +id: invalid +version: 1.0.0 +name: invalid-resource-id + +spec: + selectors: + tags: + - smoke \ No newline at end of file diff --git a/cli/data/validate-testsuite/invalid-resource-version.yml b/cli/data/validate-testsuite/invalid-resource-version.yml new file mode 100644 index 0000000..8f84d9e --- /dev/null +++ b/cli/data/validate-testsuite/invalid-resource-version.yml @@ -0,0 +1,8 @@ +kind: TestSuite +version: invalid +name: invalid-resource-version + +spec: + selectors: + tags: + - smoke \ No newline at end of file diff --git a/cli/data/validate-testsuite/resource-description-too-short.yml b/cli/data/validate-testsuite/resource-description-too-short.yml new file mode 100644 index 0000000..181c880 --- /dev/null +++ b/cli/data/validate-testsuite/resource-description-too-short.yml @@ -0,0 +1,9 @@ +kind: TestSuite +version: 1.0.0 +name: resource-description-too-short +description: ab + +spec: + selectors: + tags: + - smoke \ No newline at end of file diff --git a/cli/data/validate-testsuite/id-max-length.yml b/cli/data/validate-testsuite/resource-name-too-long.yml similarity index 61% rename from cli/data/validate-testsuite/id-max-length.yml rename to cli/data/validate-testsuite/resource-name-too-long.yml index ad2fda7..27e283f 100644 --- a/cli/data/validate-testsuite/id-max-length.yml +++ b/cli/data/validate-testsuite/resource-name-too-long.yml @@ -1,8 +1,7 @@ kind: TestSuite version: 1.0.0 -name: id-max-length - +name: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa spec: selectors: - ids: - - aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \ No newline at end of file + tags: + - smoke \ No newline at end of file diff --git a/cli/data/validate-testsuite/id-min-length.yml b/cli/data/validate-testsuite/resource-name-too-short.yml similarity index 57% rename from cli/data/validate-testsuite/id-min-length.yml rename to cli/data/validate-testsuite/resource-name-too-short.yml index 561d79f..ed39bad 100644 --- a/cli/data/validate-testsuite/id-min-length.yml +++ b/cli/data/validate-testsuite/resource-name-too-short.yml @@ -1,8 +1,8 @@ kind: TestSuite version: 1.0.0 -name: id-min-length +name: ab spec: selectors: - ids: - - a \ No newline at end of file + tags: + - smoke \ No newline at end of file diff --git a/cli/data/validate-testsuite/same-value-across-selectors.yml b/cli/data/validate-testsuite/same-value-across-selectors.yml new file mode 100644 index 0000000..d8dce32 --- /dev/null +++ b/cli/data/validate-testsuite/same-value-across-selectors.yml @@ -0,0 +1,12 @@ +kind: TestSuite +version: 1.0.0 +name: same-value-across-selectors + +spec: + selectors: + ids: + - 7398ab887149ec5aa583c564a659a0b0a933ef27bacb675b081a2a752d8a3896 + names: + - 7398ab887149ec5aa583c564a659a0b0a933ef27bacb675b081a2a752d8a3896 + tags: + - 7398ab887149ec5aa583c564a659a0b0a933ef27bacb675b081a2a752d8a3896 \ No newline at end of file diff --git a/cli/harness/service.go b/cli/harness/service.go index ba297ea..936ba52 100644 --- a/cli/harness/service.go +++ b/cli/harness/service.go @@ -82,6 +82,7 @@ var serviceAddresses = map[string]string{ "gateway-grpc-method": defaultServiceAddress, "ok-http": defaultServiceAddress, "ok-grpc": defaultServiceAddress, + "telemetry-http": "127.0.0.1:39091", } func (h *Harness) StartService( diff --git a/cli/harness/telemetry.go b/cli/harness/telemetry.go new file mode 100644 index 0000000..7e01d85 --- /dev/null +++ b/cli/harness/telemetry.go @@ -0,0 +1,42 @@ +package harness + +import ( + "bufio" + "encoding/json" + "os" + "testing" + "time" +) + +type TelemetryRequestRecord struct { + ReceivedAt time.Time `json:"received_at"` + Method string `json:"method"` + Path string `json:"path"` + ContentType string `json:"content_type,omitempty"` + Authorization string `json:"authorization,omitempty"` + Body json.RawMessage `json:"body,omitempty"` +} + +func ReadTelemetryRequestRecords(t *testing.T, path string) []TelemetryRequestRecord { + t.Helper() + + file, err := os.Open(path) + if err != nil { + t.Fatalf("Open telemetry request records: %v", err) + } + defer file.Close() + + var records []TelemetryRequestRecord + scanner := bufio.NewScanner(file) + for scanner.Scan() { + var record TelemetryRequestRecord + if err := json.Unmarshal(scanner.Bytes(), &record); err != nil { + t.Fatalf("Decode telemetry request record: %v", err) + } + records = append(records, record) + } + if err := scanner.Err(); err != nil { + t.Fatalf("Read telemetry request records: %v", err) + } + return records +} diff --git a/cli/tests/config_test.go b/cli/tests/config_test.go index 2d14d8e..6d75f1c 100644 --- a/cli/tests/config_test.go +++ b/cli/tests/config_test.go @@ -57,7 +57,7 @@ func TestConfig(t *testing.T) { name: "socket transport kind with address", env: map[string]string{ "E2ENGINE_TRANSPORT_KIND": "socket", - "E2ENGINE_TRANSPORT_ADDRESS": "localhost:1234", + "E2ENGINE_TRANSPORT_ADDRESS": "127.0.0.1:1234", }, expectedStdout: "[]", }, @@ -84,8 +84,7 @@ func TestConfig(t *testing.T) { "cause: cannot load config, " + "cause: cannot initialize configuration object, " + "cause: - Field \"Transport.Address\": rule \"networkaddress\": " + - "invalid spec, validation: network address must be in host:port form, " + - "cause: address invalid_address: missing port in address", + "network address must be in host:port form", }, { name: "workers pool size", diff --git a/cli/tests/socket_config_test.go b/cli/tests/socket_config_test.go new file mode 100644 index 0000000..f0c9e81 --- /dev/null +++ b/cli/tests/socket_config_test.go @@ -0,0 +1,60 @@ +package tests + +/* +func TestSocketConfig_Validate(t *testing.T) { + tests := []struct { + name string + address string + }{ + {"invalid format", "invalid"}, + {"hostname", "localhost:1234"}, + {"all interfaces", "0.0.0.0:1234"}, + {"private IP", "192.168.1.10:1234"}, + {"empty host", ":1234"}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + modellib.Validate(context.Background(), &SocketConfig{) + + receiver, err := NewReceiver( + &ReceiverConfig{ + MaxMessageSize: 1024, + ReadTimeout: time.Second, + }, + tt.address, + ) + + if receiver != nil { + t.Error("expected nil receiver") + } + + if !errors.Is(err, ErrInvalidListenAddress) { + t.Fatalf( + "error = %v, want %v", + err, + ErrInvalidListenAddress, + ) + } + }) + } + } + + func TestNewReceiverIPv6Loopback(t *testing.T) { + receiver, err := NewReceiver( + &ReceiverConfig{ + MaxMessageSize: 1024, + ReadTimeout: time.Second, + }, + "[::1]:0", + ) + + if err != nil { + t.Fatalf("NewReceiver() error = %v", err) + } + + if receiver == nil { + t.Fatal("expected non-nil receiver") + } + } + */ diff --git a/cli/tests/telemetry_test.go b/cli/tests/telemetry_test.go new file mode 100644 index 0000000..7d2e93e --- /dev/null +++ b/cli/tests/telemetry_test.go @@ -0,0 +1,287 @@ +package tests + +import ( + "context" + "encoding/json" + "os" + "path/filepath" + "runtime" + "strings" + "testing" + "time" + + "github.com/e2engine/tests/cli/harness" +) + +const ( + testInstallationID = "AAAAAAAAAAAAAAAAAAAAAA" + testInstallationToken = "et_AAAAAAAAAAAAAAAAAAAAAA.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + testCLIVersion = "v0.0.0-e2e" +) + +type installationFile struct { + Version int `json:"version"` + ID string `json:"installation_id"` + Token string `json:"token"` +} + +type telemetryEventsRequest struct { + Events []telemetryEvent `json:"events"` +} + +type telemetryEvent struct { + ID string `json:"id"` + SchemaVersion int `json:"schema_version"` + SessionID string `json:"session_id"` + Timestamp time.Time `json:"timestamp"` + + Source string `json:"source"` + Operation string `json:"operation"` + Outcome string `json:"outcome"` + DurationMS int64 `json:"duration_ms"` + + ErrorCategory string `json:"error_category,omitempty"` + ErrorCode string `json:"error_code,omitempty"` + + OS string `json:"os"` + Arch string `json:"arch"` + Version string `json:"version"` +} + +type telemetryTest struct { + h *harness.Harness + ctx context.Context + recordsPath string + installationPath string +} + +func setupTelemetryTest(t *testing.T, serviceArgs ...string) *telemetryTest { + t.Helper() + + ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) + t.Cleanup(cancel) + + profileDir := t.TempDir() + configDir := filepath.Join(profileDir, "config") + t.Setenv("HOME", profileDir) + t.Setenv("XDG_CONFIG_HOME", configDir) + t.Setenv("APPDATA", configDir) + t.Setenv("E2ENGINE_TELEMETRY_DISABLED", "0") + + resolvedConfigDir, err := os.UserConfigDir() + if err != nil { + t.Fatalf("Resolve user configuration directory: %v", err) + } + installationDir := filepath.Join(resolvedConfigDir, "e2engine") + if err := os.MkdirAll(installationDir, 0o700); err != nil { + t.Fatalf("Create private E2Engine configuration directory: %v", err) + } + if err := os.Chmod(installationDir, 0o700); err != nil { + t.Fatalf("Secure E2Engine configuration directory: %v", err) + } + + recordsPath := filepath.Join(t.TempDir(), "telemetry-requests.jsonl") + args := append([]string{"-records", recordsPath}, serviceArgs...) + + serviceCtx, serviceCancel := context.WithCancel(context.Background()) + t.Cleanup(serviceCancel) + + h := harness.New(t, "../bin/cli", "", filepath.Join(t.TempDir(), "data")) + process := h.StartService(serviceCtx, "telemetry-http", args...) + t.Cleanup(func() { + process.Stop(t) + }) + + return &telemetryTest{ + h: h, + ctx: ctx, + recordsPath: recordsPath, + installationPath: filepath.Join(installationDir, "installation.json"), + } +} + +func (e *telemetryTest) runSuccess(t *testing.T, args ...string) { + t.Helper() + stdout, stderr, err := e.h.RunCommand(e.ctx, args...) + if err != nil { + t.Fatalf("RunCommand(%v): %v\nstdout: %s\nstderr: %s", args, err, stdout, stderr) + } +} + +func decodeEventRequest(t *testing.T, record harness.TelemetryRequestRecord) telemetryEvent { + t.Helper() + if record.Method != "POST" || record.Path != "/v1/events" { + t.Fatalf("Unexpected event request: method=%q path=%q", record.Method, record.Path) + } + if record.Authorization != "Bearer "+testInstallationToken { + t.Fatalf("Authorization = %q", record.Authorization) + } + if !strings.HasPrefix(record.ContentType, "application/json") { + t.Fatalf("Content-Type = %q", record.ContentType) + } + + var request telemetryEventsRequest + if err := json.Unmarshal(record.Body, &request); err != nil { + t.Fatalf("Decode events request: %v", err) + } + if len(request.Events) != 1 { + t.Fatalf("Event count = %d, want 1", len(request.Events)) + } + return request.Events[0] +} + +func TestTelemetryRegistrationSubmissionAndReuse(t *testing.T) { + test := setupTelemetryTest(t) + + test.runSuccess(t, "get", "environments", "-o", "yaml") + test.runSuccess(t, "get", "environments", "-o", "yaml") + + records := harness.ReadTelemetryRequestRecords(t, test.recordsPath) + if len(records) != 3 { + t.Fatalf("Request count = %d, want 3: %#v", len(records), records) + } + registration := records[0] + if registration.Method != "POST" || registration.Path != "/v1/installations" { + t.Fatalf("Unexpected registration request: method=%q path=%q", registration.Method, registration.Path) + } + if registration.Authorization != "" { + t.Fatalf("Registration Authorization = %q", registration.Authorization) + } + if !strings.HasPrefix(registration.ContentType, "application/json") || len(registration.Body) != 0 { + t.Fatalf("Unexpected registration content: Content-Type=%q body=%q", registration.ContentType, registration.Body) + } + + data, err := os.ReadFile(test.installationPath) + if err != nil { + t.Fatalf("Read installation file: %v", err) + } + var installation installationFile + if err := json.Unmarshal(data, &installation); err != nil { + t.Fatalf("Decode installation file: %v", err) + } + if installation.Version != 1 || installation.ID != testInstallationID || installation.Token != testInstallationToken { + t.Fatalf("Installation file = %#v", installation) + } + if runtime.GOOS != "windows" { + info, err := os.Stat(test.installationPath) + if err != nil { + t.Fatal(err) + } + if info.Mode().Perm() != 0o600 { + t.Fatalf("Installation file permissions = %o, want 600", info.Mode().Perm()) + } + } + entries, err := os.ReadDir(filepath.Dir(test.installationPath)) + if err != nil { + t.Fatal(err) + } + for _, entry := range entries { + if strings.HasPrefix(entry.Name(), ".installation-") { + t.Fatalf("Temporary installation file remains: %q", entry.Name()) + } + } + + first := decodeEventRequest(t, records[1]) + second := decodeEventRequest(t, records[2]) + for index, event := range []telemetryEvent{first, second} { + if event.ID == "" || event.SessionID == "" || event.Timestamp.IsZero() { + t.Errorf("Event %d has missing identity or timestamp: %#v", index, event) + } + if event.SchemaVersion != 1 || event.Source != "cli" || event.Operation != "environment.list" || event.Outcome != "success" { + t.Errorf("Event %d has unexpected contract values: %#v", index, event) + } + if event.DurationMS < 0 || event.OS != runtime.GOOS || event.Arch != runtime.GOARCH || event.Version != testCLIVersion { + t.Errorf("Event %d has unexpected runtime values: %#v", index, event) + } + if event.ErrorCategory != "" || event.ErrorCode != "" { + t.Errorf("Event %d has error metadata for successful operation: %#v", index, event) + } + } + if first.ID == second.ID { + t.Error("CLI invocations reused an event ID") + } + if first.SessionID == second.SessionID { + t.Error("Separate CLI invocations reused a session ID") + } +} + +func TestTelemetryErrorEvent(t *testing.T) { + test := setupTelemetryTest(t) + + stdout, stderr, err := test.h.RunCommand(test.ctx, "get", "environment", "missing-environment") + if err == nil { + t.Fatalf("Expected command error\nstdout: %s\nstderr: %s", stdout, stderr) + } + + records := harness.ReadTelemetryRequestRecords(t, test.recordsPath) + if len(records) != 2 { + t.Fatalf("Request count = %d, want 2", len(records)) + } + event := decodeEventRequest(t, records[1]) + if event.Operation != "environment.get" || event.Outcome != "error" || + event.ErrorCategory != "not_found" || event.ErrorCode != "resource_not_found" { + t.Fatalf("Error event = %#v", event) + } + if strings.Contains(string(records[1].Body), "missing-environment") { + t.Fatal("Telemetry event contains the requested resource reference") + } +} + +func TestTelemetryDisabled(t *testing.T) { + test := setupTelemetryTest(t) + t.Setenv("E2ENGINE_TELEMETRY_DISABLED", "1") + + test.runSuccess(t, "get", "environments", "-o", "yaml") + + if records := harness.ReadTelemetryRequestRecords(t, test.recordsPath); len(records) != 0 { + t.Fatalf("Disabled telemetry sent requests: %#v", records) + } + if _, err := os.Stat(test.installationPath); !os.IsNotExist(err) { + t.Fatalf("Disabled telemetry created installation file: %v", err) + } +} + +func TestTelemetryRegistrationFailureIsBestEffort(t *testing.T) { + test := setupTelemetryTest(t, "-registration-status", "500") + + test.runSuccess(t, "get", "environments", "-o", "yaml") + + records := harness.ReadTelemetryRequestRecords(t, test.recordsPath) + if len(records) != 1 || records[0].Path != "/v1/installations" { + t.Fatalf("Requests after registration failure = %#v", records) + } + if _, err := os.Stat(test.installationPath); !os.IsNotExist(err) { + t.Fatalf("Registration failure created installation file: %v", err) + } +} + +func TestTelemetrySubmissionFailureIsBestEffortAndCredentialsAreReused(t *testing.T) { + test := setupTelemetryTest(t, "-events-status", "500") + + test.runSuccess(t, "get", "environments", "-o", "yaml") + test.runSuccess(t, "get", "environments", "-o", "yaml") + + records := harness.ReadTelemetryRequestRecords(t, test.recordsPath) + if len(records) != 3 { + t.Fatalf("Request count = %d, want one registration and two event attempts", len(records)) + } + if records[0].Path != "/v1/installations" || records[1].Path != "/v1/events" || records[2].Path != "/v1/events" { + t.Fatalf("Unexpected request sequence: %#v", records) + } + if _, err := os.Stat(test.installationPath); err != nil { + t.Fatalf("Event failure did not preserve credentials: %v", err) + } +} + +func TestTelemetryUnsupportedCommandDoesNotInitialize(t *testing.T) { + test := setupTelemetryTest(t) + + test.runSuccess(t, "version") + + if records := harness.ReadTelemetryRequestRecords(t, test.recordsPath); len(records) != 0 { + t.Fatalf("Unsupported command sent telemetry requests: %#v", records) + } + if _, err := os.Stat(test.installationPath); !os.IsNotExist(err) { + t.Fatalf("Unsupported command created installation file: %v", err) + } +} diff --git a/cli/tests/validate_environment_test.go b/cli/tests/validate_environment_test.go index 2e6408f..00c2e08 100644 --- a/cli/tests/validate_environment_test.go +++ b/cli/tests/validate_environment_test.go @@ -20,194 +20,244 @@ func TestValidateEnvironment(t *testing.T) { name: "invalid-resource-kind", stdout: "", stderr: "invalid spec, spec.kind: environment, " + - "validation: invalid resource kind", + "fields: Kind, " + + "validation: invalid kind", expectError: true, }, { name: "invalid-resource-id", stdout: "", - stderr: "invalid environment spec, fields: ID", + stderr: "invalid spec, spec.kind: environment, " + + "fields: ID, " + + "validation: value must contain exactly 64 lowercase alphanumeric characters", expectError: true, }, { name: "resource-name-too-short", stdout: "", - stderr: "invalid environment spec, fields: Name", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Name, " + + "validation: rule constraint violated, " + + "rule.name: min, rule.param.name: length, rule.param.value: 3", expectError: true, }, { name: "resource-name-too-long", stdout: "", - stderr: "invalid environment spec, fields: Name", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Name, " + + "validation: rule constraint violated, " + + "rule.name: max, rule.param.name: length, rule.param.value: 200", expectError: true, }, { name: "invalid-resource-version", stdout: "", - stderr: "invalid environment spec, fields: Version", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Version, " + + "validation: rule constraint violated, rule.name: semver", expectError: true, }, { name: "resource-description-too-short", stdout: "", - stderr: "invalid environment spec, fields: Description", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Description, " + + "validation: rule constraint violated, " + + "rule.name: min, rule.param.name: length, rule.param.value: 3", expectError: true, }, { name: "no-services", stdout: "", stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services, " + "validation: environment spec must contain at least one service", expectError: true, }, { name: "duplicate-service-id", stdout: "", - stderr: "invalid spec, spec.kind: environment, environment.service.id: service, " + + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[1].ID, " + "validation: service ids must be unique", expectError: true, }, { name: "duplicate-service-address", stdout: "", - stderr: "invalid spec, spec.kind: environment, environment.service.id: service-two, " + - "environment.service.listen.address: 127.0.0.1:8081, " + - "validation: service addresses must be unique", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[1].E2EnginePort, " + + "validation: E2Engine ports must be unique within an environment", expectError: true, }, { name: "service-id-too-short", stdout: "", - stderr: "invalid environment spec, fields: Spec.Services[0].ID", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].ID, " + + "validation: rule constraint violated, " + + "rule.name: min, rule.param.name: length, rule.param.value: 3", expectError: true, }, { name: "service-id-too-long", stdout: "", - stderr: "invalid environment spec, fields: Spec.Services[0].ID", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].ID, " + + "validation: rule constraint violated, " + + "rule.name: max, rule.param.name: length, rule.param.value: 200", expectError: true, }, { name: "invalid-service-kind", stdout: "", - stderr: "invalid environment spec, fields: Spec.Services[0].Kind", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Kind, " + + "validation: rule constraint violated, " + + "rule.name: oneof, rule.param.name: allowed, rule.param.value: http,grpc", expectError: true, }, { name: "invalid-service-mode", stdout: "", - stderr: "invalid environment spec, fields: Spec.Services[0].Mode", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Mode, " + + "validation: rule constraint violated, " + + "rule.name: oneof, rule.param.name: allowed, rule.param.value: real,mocked", expectError: true, }, { - name: "invalid-service-address", + name: "invalid-service-port", stdout: "", - stderr: "invalid environment spec, fields: Spec.Services[0].Address", + stderr: "invalid spec, spec.kind: environment, " + + "validation: line 10: cannot unmarshal !!str `not-a-port` into int", expectError: true, }, { name: "invalid-service-target", stdout: "", - stderr: "invalid environment spec, fields: Spec.Services[0].HTTPTarget", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Target, " + + "validation: target must be a valid HTTP URL", expectError: true, }, { name: "invalid-grpc-target", stdout: "", - stderr: "invalid environment spec, fields: Spec.Services[0].GRPCTarget", - expectError: true, - }, - { - name: "real-http-with-grpc-target", - stdout: "", - stderr: "invalid spec, spec.kind: environment, validation: " + - "GRPC target is not allowed for HTTP service", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Proto, " + + "validation: proto spec is required for GRPC service", expectError: true, }, { name: "real-grpc-without-target", stdout: "", - stderr: "invalid spec, spec.kind: environment, validation: " + - "target is required for real service", - expectError: true, - }, - { - name: "real-grpc-with-http-target", - stdout: "", - stderr: "invalid spec, spec.kind: environment, validation: " + - "HTTP target is not allowed for GRPC service", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Target, " + + "validation: target is required for real service", expectError: true, }, { name: "http-with-proto", stdout: "", - stderr: "invalid spec, spec.kind: environment, validation: proto spec is not allowed for HTTP service", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Proto, " + + "validation: proto spec is not allowed for HTTP service", expectError: true, }, { name: "grpc-without-proto", stdout: "", - stderr: "invalid spec, spec.kind: environment, validation: proto spec is required for GRPC service", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Proto, " + + "validation: proto spec is required for GRPC service", expectError: true, }, { name: "grpc-external-empty-service", stdout: "", - stderr: "invalid environment spec, fields: Spec.Services[0].Proto.External.Service", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Proto.External.Service, " + + "validation: rule constraint violated, " + + "rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { name: "grpc-internal-empty-package", stdout: "", - stderr: "invalid environment spec, fields: Spec.Services[0].Proto.Internal.Package", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Proto.Internal.Package, " + + "validation: rule constraint violated, " + + "rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { name: "grpc-internal-empty-service", stdout: "", - stderr: "invalid environment spec, fields: Spec.Services[0].Proto.Internal.Service", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Proto.Internal.Service, " + + "validation: rule constraint violated, " + + "rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { name: "grpc-internal-empty-method-name", stdout: "", - stderr: "invalid environment spec, fields: Spec.Services[0].Proto.Internal.Methods[0].Name", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Proto.Internal.Methods[0].Name, " + + "validation: rule constraint violated, " + + "rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { name: "grpc-internal-empty-field-name", stdout: "", - stderr: "invalid environment spec, fields: Spec.Services[0].Proto.Internal.Methods[0].Request.Fields[0].Name", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Proto.Internal.Methods[0].Request.Fields[0].Name, " + + "validation: rule constraint violated, " + + "rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { name: "grpc-internal-invalid-field-type", stdout: "", - stderr: "invalid environment spec, fields: Spec.Services[0].Proto.Internal.Methods[0].Request.Fields[0].Type", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Proto.Internal.Methods[0].Request.Fields[0].Type, " + + "validation: rule constraint violated, " + + "rule.name: oneof, rule.param.name: allowed, " + + "rule.param.value: string,bool,int32,int64,uint32,uint64,float,double,bytes", expectError: true, }, { name: "mocked-without-fixtures", stdout: "", - stderr: "invalid spec, spec.kind: environment, validation: mocked service must have at least one fixture", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Mode, Spec.Services[0].Fixtures, " + + "validation: mocked service must contain at least one fixture", expectError: true, }, { name: "mocked-with-target", stdout: "", - stderr: "invalid spec, spec.kind: environment, validation: mocked service must not have a target", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Mode, Spec.Services[0].Target, " + + "validation: target is not allowed for mocked service", expectError: true, }, { name: "real-http-without-target", stdout: "", - stderr: "invalid spec, spec.kind: environment, validation: target is required for real service", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Target, " + + "validation: target is required for real service", expectError: true, }, { name: "real-http-with-fixtures", stdout: "", stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Mode, Spec.Services[0].Fixtures, " + "validation: fixtures are not allowed for real service", expectError: true, }, @@ -215,6 +265,7 @@ func TestValidateEnvironment(t *testing.T) { name: "http-fixture-missing-http-when", stdout: "", stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Fixtures[0].When.HTTP, Spec.Services[0].Fixtures[0].Then.HTTP, " + "validation: HTTP service fixture must contain HTTP when and then", expectError: true, }, @@ -222,6 +273,7 @@ func TestValidateEnvironment(t *testing.T) { name: "http-fixture-missing-http-then", stdout: "", stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Fixtures[0].When.HTTP, Spec.Services[0].Fixtures[0].Then.HTTP, " + "validation: HTTP service fixture must contain HTTP when and then", expectError: true, }, @@ -229,6 +281,7 @@ func TestValidateEnvironment(t *testing.T) { name: "grpc-fixture-on-http-service", stdout: "", stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Fixtures[0].When.GRPC, Spec.Services[0].Fixtures[0].Then.GRPC, " + "validation: gRPC fixture is not allowed for HTTP service", expectError: true, }, @@ -236,6 +289,7 @@ func TestValidateEnvironment(t *testing.T) { name: "grpc-fixture-missing-grpc-when", stdout: "", stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Fixtures[0].When.GRPC, Spec.Services[0].Fixtures[0].Then.GRPC, " + "validation: gRPC service fixture must contain gRPC when and then", expectError: true, }, @@ -243,6 +297,7 @@ func TestValidateEnvironment(t *testing.T) { name: "grpc-fixture-missing-grpc-then", stdout: "", stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Fixtures[0].When.GRPC, Spec.Services[0].Fixtures[0].Then.GRPC, " + "validation: gRPC service fixture must contain gRPC when and then", expectError: true, }, @@ -250,108 +305,225 @@ func TestValidateEnvironment(t *testing.T) { name: "http-fixture-on-grpc-service", stdout: "", stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Fixtures[0].When.HTTP, Spec.Services[0].Fixtures[0].Then.HTTP, " + "validation: HTTP fixture is not allowed for gRPC service", expectError: true, }, { name: "http-fixture-invalid-method", stdout: "", - stderr: "invalid environment spec, fields: Spec.Services[0].Fixtures[0].When.HTTP.Method", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Fixtures[0].When.HTTP.Method, " + + "validation: rule constraint violated, " + + "rule.name: oneof, rule.param.name: allowed, " + + "rule.param.value: GET,POST,PUT,DELETE,PATCH,OPTIONS,HEAD", expectError: true, }, { name: "http-fixture-empty-path", stdout: "", - stderr: "invalid environment spec, fields: Spec.Services[0].Fixtures[0].When.HTTP.Path", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Fixtures[0].When.HTTP.Path, " + + "validation: rule constraint violated, " + + "rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { name: "http-fixture-status-too-low", stdout: "", - stderr: "invalid environment spec, fields: Spec.Services[0].Fixtures[0].Then.HTTP.StatusCode", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Fixtures[0].Then.HTTP.StatusCode, " + + "validation: rule constraint violated, " + + "rule.name: min, rule.param.name: value, rule.param.value: 100", expectError: true, }, { name: "http-fixture-status-too-high", stdout: "", - stderr: "invalid environment spec, fields: Spec.Services[0].Fixtures[0].Then.HTTP.StatusCode", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Fixtures[0].Then.HTTP.StatusCode, " + + "validation: rule constraint violated, " + + "rule.name: min, rule.param.name: value, rule.param.value: 100", expectError: true, }, { name: "http-fixture-invalid-request-json", stdout: "", - stderr: "invalid environment spec, fields: Spec.Services[0].Fixtures[0].When.HTTP.BodyJSON", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Fixtures[0].When.HTTP.BodyJSON, " + + "validation: value must contain valid JSON", expectError: true, }, { name: "http-fixture-invalid-response-json", stdout: "", - stderr: "invalid environment spec, fields: Spec.Services[0].Fixtures[0].Then.HTTP.BodyJSON", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Fixtures[0].Then.HTTP.BodyJSON, " + + "validation: value must contain valid JSON", expectError: true, }, { name: "grpc-proto-both-external-and-internal", stdout: "", - stderr: "invalid spec, spec.kind: environment, validation: exactly one of external or " + - "internal proto spec must be provided for GRPC service", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Proto.External, Spec.Services[0].Proto.Internal, " + + "validation: exactly one of external or internal proto spec must be provided for GRPC service", expectError: true, }, { name: "grpc-proto-neither-external-nor-internal", stdout: "", - stderr: "invalid spec, spec.kind: environment, validation: exactly one of external or " + - "internal proto spec must be provided for GRPC service", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Proto.External, Spec.Services[0].Proto.Internal, " + + "validation: exactly one of external or internal proto spec must be provided for GRPC service", expectError: true, }, { name: "grpc-external-neither-file-nor-buf-module", stdout: "", - stderr: "invalid spec, spec.kind: environment, validation: exactly one of file or " + - "buf_module must be provided for external GRPC proto spec", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Proto.External.File, Spec.Services[0].Proto.External.BufModule, " + + "validation: exactly one of file or buf_module must be provided for external GRPC proto spec", expectError: true, }, { name: "grpc-external-file-and-buf-module", stdout: "", - stderr: "invalid spec, spec.kind: environment, validation: exactly one of file or " + - "buf_module must be provided for external GRPC proto spec", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Proto.External.File, Spec.Services[0].Proto.External.BufModule, " + + "validation: exactly one of file or buf_module must be provided for external GRPC proto spec", expectError: true, }, { name: "real-grpc-with-internal-proto", stdout: "", - stderr: "invalid spec, spec.kind: environment, validation: internal proto spec " + - "is not allowed for real GRPC service", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Mode, Spec.Services[0].Proto.Internal, " + + "validation: internal proto spec is not allowed for real GRPC service", expectError: true, }, { name: "grpc-internal-without-methods", stdout: "", - stderr: "invalid spec, spec.kind: environment, validation: internal proto spec " + - "must contain at least one method", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Proto.Internal.Methods, " + + "validation: internal proto spec must contain at least one method", expectError: true, }, { name: "grpc-fixture-empty-method", stdout: "", - stderr: "invalid environment spec, fields: Spec.Services[0].Fixtures[0].When.GRPC.Method", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Fixtures[0].When.GRPC.Method, " + + "validation: rule constraint violated, rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { name: "grpc-fixture-invalid-status", stdout: "", - stderr: "invalid environment spec, fields: Spec.Services[0].Fixtures[0].Then.GRPC.Status", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Fixtures[0].Then.GRPC.Status, " + + "validation: rule constraint violated, " + + "rule.name: oneof, rule.param.name: allowed, " + + "rule.param.value: OK,Canceled,Unknown,InvalidArgument,DeadlineExceeded,NotFound," + + "AlreadyExists,PermissionDenied,ResourceExhausted,FailedPrecondition,Aborted,OutOfRange," + + "Unimplemented,Internal,Unavailable,DataLoss,Unauthenticated", + expectError: true, + }, + { + name: "http-with-grpc-metadata", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].RequestDefaults.Metadata, " + + "validation: metadata is not allowed for HTTP service", + expectError: true, + }, + { + name: "grpc-with-http-headers", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].RequestDefaults.Headers, " + + "validation: headers are not allowed for GRPC service", + expectError: true, + }, + { + name: "service-port-too-low", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].E2EnginePort, " + + "validation: rule constraint violated, " + + "rule.name: min, rule.param.name: value, rule.param.value: 1", + expectError: true, + }, + { + name: "service-port-too-high", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].E2EnginePort, " + + "validation: rule constraint violated, " + + "rule.name: max, rule.param.name: value, rule.param.value: 65535", + expectError: true, + }, + { + name: "http-target-with-userinfo", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Target, " + + "validation: target URL must not contain user info", + expectError: true, + }, + { + name: "http-target-with-query", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Target, " + + "validation: target URL must not contain query parameters or fragment", + expectError: true, + }, + { + name: "http-target-invalid-port", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Target, " + + "validation: target URL port must be an integer between 1 and 65535", + expectError: true, + }, + { + name: "grpc-target-invalid-address", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Target, " + + "validation: network address must be in host:port form", + expectError: true, + }, + { + name: "http-fixture-request-both-bodies", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Fixtures[0].When.HTTP, " + + "validation: HTTP request pattern cannot have both body and body_json set", expectError: true, }, { - name: "grpc-fixture-invalid-path", + name: "http-fixture-response-both-bodies", stdout: "", - stderr: "the specified path is inaccessible, " + - "file.path: ../data/validate-environment/grpc-fixture-invalid-path.yml, " + - "cause: open ../data/validate-environment/grpc-fixture-invalid-path.yml: " + - "no such file or directory", + stderr: "invalid spec, spec.kind: environment, " + + "fields: Spec.Services[0].Fixtures[0].Then.HTTP, " + + "validation: HTTP response cannot have both body and body_json set", expectError: true, }, + { + name: "valid-real-http", + stdout: "Environment spec is valid", + stderr: "", + expectError: false, + }, + { + name: "valid-mocked-http", + stdout: "Environment spec is valid", + stderr: "", + expectError: false, + }, } for _, tt := range tests { @@ -396,3 +568,64 @@ func TestValidateEnvironment(t *testing.T) { }) } } + +func TestValidateEnvironment_JSON(t *testing.T) { + tests := []struct { + name string + stdout string + stderr string + expectError bool + }{ + { + name: "invalid-service-port", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + + "fields: spec.services.0.e2engine_port, " + + "validation: json: cannot unmarshal string into " + + "Go struct field Environment.spec.services.0.e2engine_port of type int", + expectError: true, + }, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) + defer cancel() + + h := harness.New(t, "../bin/cli", "", "") + + stdout, stderr, err := h.RunCommand( + ctx, + "validate", + "environment", + filepath.Join("../data/validate-environment/", tt.name+".json"), + ) + + if tt.expectError { + if err == nil { + t.Fatalf( + "Expected an error but got none\nstdout: %s\nstderr: %s", + stdout, + stderr, + ) + } + } else { + if err != nil { + t.Fatalf( + "RunCommand failed: %v\nstdout: %s\nstderr: %s", + err, + stdout, + stderr, + ) + } + } + + if strings.TrimSpace(stdout) != strings.TrimSpace(tt.stdout) { + t.Errorf("Expected stdout: %q, got: %q", tt.stdout, stdout) + } + if strings.TrimSpace(stderr) != strings.TrimSpace(tt.stderr) { + t.Errorf("Expected stderr: %q, got: %q", tt.stderr, stderr) + } + }) + } +} \ No newline at end of file diff --git a/cli/tests/validate_test_test.go b/cli/tests/validate_test_test.go index e76bd4a..459956a 100644 --- a/cli/tests/validate_test_test.go +++ b/cli/tests/validate_test_test.go @@ -20,187 +20,268 @@ func TestValidateTest(t *testing.T) { name: "invalid-resource-kind", stdout: "", stderr: "invalid spec, spec.kind: test, " + - "validation: invalid resource kind", + "fields: Kind, " + + "validation: invalid kind", expectError: true, }, { name: "request-missing", stdout: "", - stderr: "invalid spec, spec.kind: test\nrequest must contain exactly one of http or grpc", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Request.HTTP, Spec.Request.GRPC, " + + "validation: request must contain exactly one of http or grpc", expectError: true, }, { name: "request-http-and-grpc", stdout: "", - stderr: "invalid spec, spec.kind: test\nrequest must contain exactly one of http or grpc", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Request.HTTP, Spec.Request.GRPC, " + + "validation: request must contain exactly one of http or grpc", expectError: true, }, { name: "expect-missing", stdout: "", - stderr: "invalid spec, spec.kind: test\nexpect must contain exactly one of http or grpc", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Expect.HTTP, Spec.Expect.GRPC, " + + "validation: expect must contain exactly one of http or grpc", expectError: true, }, { name: "expect-http-and-grpc", stdout: "", - stderr: "invalid spec, spec.kind: test\nexpect must contain exactly one of http or grpc", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Expect.HTTP, Spec.Expect.GRPC, " + + "validation: expect must contain exactly one of http or grpc", expectError: true, }, { name: "request-expect-protocol-mismatch", stdout: "", - stderr: "invalid spec, spec.kind: test\nrequest and expect protocols must match", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Request.HTTP, Spec.Expect.HTTP, " + + "validation: request and expect protocols must match", expectError: true, }, { name: "empty-tag", stdout: "", - stderr: "invalid test spec, fields: Spec.Tags[0]", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Tags[0], " + + "validation: rule constraint violated, " + + "rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { name: "tag-too-long", stdout: "", - stderr: "invalid test spec, fields: Spec.Tags[0]", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Tags[0], " + + "validation: rule constraint violated, " + + "rule.name: max, rule.param.name: length, rule.param.value: 200", expectError: true, }, { name: "http-request-invalid-method", stdout: "", - stderr: "invalid test spec, fields: Spec.Request.HTTP.Method", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Request.HTTP.Method, " + + "validation: rule constraint violated, " + + "rule.name: oneof, rule.param.name: allowed, " + + "rule.param.value: GET,POST,PUT,DELETE,PATCH,OPTIONS,HEAD", expectError: true, }, { name: "http-request-empty-url", stdout: "", - stderr: "invalid test spec, fields: Spec.Request.HTTP.URL", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Request.HTTP.URL, " + + "validation: target must be a valid HTTP URL", expectError: true, }, { name: "http-request-invalid-url", stdout: "", - stderr: "invalid spec, spec.kind: test\ninvalid HTTP request URL, cause: parse \"http://[::1\": missing ']' in host", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Request.HTTP.URL, " + + "validation: target must be a valid HTTP URL", expectError: true, }, { name: "http-request-invalid-scheme", stdout: "", - stderr: "invalid spec, spec.kind: test\nHTTP request URL scheme must be http or https", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Request.HTTP.URL, " + + "validation: target URL scheme must be http or https", expectError: true, }, { name: "http-request-no-host", stdout: "", - stderr: "invalid spec, spec.kind: test\nHTTP request URL must contain a host", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Request.HTTP.URL, " + + "validation: target URL host must not be empty", expectError: true, }, { name: "http-request-invalid-json", stdout: "", - stderr: "invalid test spec, fields: Spec.Request.HTTP.BodyJSON", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Request.HTTP.BodyJSON, " + + "validation: value must contain valid JSON", expectError: true, }, { name: "http-expect-status-too-low", stdout: "", - stderr: "invalid test spec, fields: Spec.Expect.HTTP.StatusCode", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Expect.HTTP.StatusCode, " + + "validation: rule constraint violated, " + + "rule.name: min, rule.param.name: value, rule.param.value: 100", expectError: true, }, { name: "http-expect-status-too-high", stdout: "", - stderr: "invalid test spec, fields: Spec.Expect.HTTP.StatusCode", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Expect.HTTP.StatusCode, " + + "validation: rule constraint violated, " + + "rule.name: max, rule.param.name: value, rule.param.value: 599", expectError: true, }, { name: "http-expect-invalid-json", stdout: "", - stderr: "invalid test spec, fields: Spec.Expect.HTTP.BodyJSON", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Expect.HTTP.BodyJSON, " + + "validation: value must contain valid JSON", expectError: true, }, { name: "grpc-request-invalid-target", stdout: "", - stderr: "invalid test spec, fields: Spec.Request.GRPC.Target", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Request.GRPC.Target, " + + "validation: network address must be in host:port form", expectError: true, }, { name: "grpc-request-empty-service", stdout: "", - stderr: "invalid test spec, fields: Spec.Request.GRPC.Service", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Request.GRPC.Service, " + + "validation: rule constraint violated, " + + "rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { name: "grpc-request-empty-method", stdout: "", - stderr: "invalid test spec, fields: Spec.Request.GRPC.Method", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Request.GRPC.Method, " + + "validation: rule constraint violated, " + + "rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { name: "grpc-expect-empty-status", stdout: "", - stderr: "invalid test spec, fields: Spec.Expect.GRPC.Status", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Expect.GRPC.Status, " + + "validation: rule constraint violated, " + + "rule.name: oneof, rule.param.name: allowed, " + + "rule.param.value: OK,Canceled,Unknown,InvalidArgument,DeadlineExceeded,NotFound," + + "AlreadyExists,PermissionDenied,ResourceExhausted,FailedPrecondition,Aborted," + + "OutOfRange,Unimplemented,Internal,Unavailable,DataLoss,Unauthenticated", expectError: true, }, { name: "call-no-protocol", stdout: "", - stderr: "invalid spec, spec.kind: test\ncall expectation must contain exactly one of http or grpc", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Expect.Calls[0], " + + "validation: call expectation must contain exactly one of http or grpc", expectError: true, }, { name: "call-http-and-grpc", stdout: "", - stderr: "invalid spec, spec.kind: test\ncall expectation must contain exactly one of http or grpc", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Expect.Calls[0], " + + "validation: call expectation must contain exactly one of http or grpc", expectError: true, }, { name: "call-service-id-too-short", stdout: "", - stderr: "invalid test spec, fields: Spec.Expect.Calls[0].ServiceID", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Expect.Calls[0].ServiceID, " + + "validation: rule constraint violated, " + + "rule.name: min, rule.param.name: length, rule.param.value: 3", expectError: true, }, { name: "call-service-id-too-long", stdout: "", - stderr: "invalid test spec, fields: Spec.Expect.Calls[0].ServiceID", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Expect.Calls[0].ServiceID, " + + "validation: rule constraint violated, " + + "rule.name: max, rule.param.name: length, rule.param.value: 200", expectError: true, }, { name: "call-negative-count", stdout: "", - stderr: "invalid test spec, fields: Spec.Expect.Calls[0].Count", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Expect.Calls[0].Count, " + + "validation: rule constraint violated, " + + "rule.name: min, rule.param.name: value, rule.param.value: 0", expectError: true, }, { name: "call-http-invalid-method", stdout: "", - stderr: "invalid test spec, fields: Spec.Expect.Calls[0].HTTP.Method", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Expect.Calls[0].HTTP.Method, " + + "validation: rule constraint violated, " + + "rule.name: oneof, rule.param.name: allowed, " + + "rule.param.value: GET,POST,PUT,DELETE,PATCH,OPTIONS,HEAD", expectError: true, }, { name: "call-http-empty-path", stdout: "", - stderr: "invalid test spec, fields: Spec.Expect.Calls[0].HTTP.Path", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Expect.Calls[0].HTTP.Path, " + + "validation: rule constraint violated, " + + "rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { name: "call-http-invalid-json", stdout: "", - stderr: "invalid test spec, fields: Spec.Expect.Calls[0].HTTP.BodyJSON", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Expect.Calls[0].HTTP.BodyJSON, " + + "validation: value must contain valid JSON", expectError: true, }, { name: "call-grpc-empty-service", stdout: "", - stderr: "invalid test spec, fields: Spec.Expect.Calls[0].GRPC.Service", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Expect.Calls[0].GRPC.Service, " + + "validation: rule constraint violated, " + + "rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { name: "call-grpc-empty-method", stdout: "", - stderr: "invalid test spec, fields: Spec.Expect.Calls[0].GRPC.Method", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Expect.Calls[0].GRPC.Method, " + + "validation: rule constraint violated, " + + "rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { @@ -235,8 +316,9 @@ func TestValidateTest(t *testing.T) { }, { name: "duplicate-tag", - stderr: "invalid spec, spec.kind: test\ntest tags must be unique, " + - "test.tag: tag", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Tags[1], " + + "validation: test tags must be unique, test.tag: tag", expectError: true, }, { @@ -296,7 +378,13 @@ func TestValidateTest(t *testing.T) { { name: "grpc-expect-invalid-status", stdout: "", - stderr: "invalid test spec, fields: Spec.Expect.GRPC.Status", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Expect.GRPC.Status, " + + "validation: rule constraint violated, " + + "rule.name: oneof, rule.param.name: allowed, " + + "rule.param.value: OK,Canceled,Unknown,InvalidArgument,DeadlineExceeded,NotFound," + + "AlreadyExists,PermissionDenied,ResourceExhausted,FailedPrecondition,Aborted," + + "OutOfRange,Unimplemented,Internal,Unavailable,DataLoss,Unauthenticated", expectError: true, }, { @@ -347,6 +435,78 @@ func TestValidateTest(t *testing.T) { stderr: "", expectError: false, }, + { + name: "http-request-both-bodies", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Request.HTTP, " + + "validation: HTTP request cannot have both body and body_json set", + expectError: true, + }, + { + name: "http-expect-both-bodies", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Expect.HTTP, " + + "validation: HTTP response pattern cannot have both body and body_json set", + expectError: true, + }, + { + name: "http-call-both-bodies", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Expect.Calls[0], " + + "validation: HTTP request pattern cannot have both body and body_json set", + expectError: true, + }, + { + name: "http-call-invalid-path", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Expect.Calls[0], " + + "validation: invalid HTTP request path", + expectError: true, + }, + { + name: "http-request-url-with-userinfo", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Request.HTTP.URL, " + + "validation: target URL must not contain user info", + expectError: true, + }, + { + name: "http-request-url-with-query", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Request.HTTP.URL, " + + "validation: target URL must not contain query parameters or fragment", + expectError: true, + }, + { + name: "http-request-url-invalid-port", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Request.HTTP.URL, " + + "validation: target URL port must be an integer between 1 and 65535", + expectError: true, + }, + { + name: "grpc-request-invalid-port", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Request.GRPC.Target, " + + "validation: network address port must be an integer between 1 and 65535", + expectError: true, + }, + { + name: "grpc-request-empty-host", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + + "fields: Spec.Request.GRPC.Target, " + + "validation: network address host must not be empty", + expectError: true, + }, } for _, tt := range tests { diff --git a/cli/tests/validate_testsuite_test.go b/cli/tests/validate_testsuite_test.go index 5456eda..7a625c2 100644 --- a/cli/tests/validate_testsuite_test.go +++ b/cli/tests/validate_testsuite_test.go @@ -19,60 +19,72 @@ func TestValidateTestSuite(t *testing.T) { { name: "invalid-resource-kind", stdout: "", - stderr: "invalid spec, spec.kind: testsuite, " + - "validation: invalid resource kind", + stderr: "invalid spec, spec.kind: " + + "testsuite, fields: Kind, validation: invalid kind", expectError: true, }, { name: "no-selectors", stdout: "", - stderr: "invalid spec, spec.kind: testsuite\ntest selectors spec must contain at least one of ids, names, or tags", + stderr: "invalid spec, spec.kind: testsuite, " + + "fields: Spec.Selectors.IDs, Spec.Selectors.Names, Spec.Selectors.Tags, " + + "validation: test selectors spec must contain at least one of ids, names, or tags", expectError: true, }, { name: "empty-id", stdout: "", - stderr: "invalid testsuite spec, fields: Spec.Selectors.IDs[0]", + stderr: "invalid spec, spec.kind: testsuite, " + + "fields: Spec.Selectors.IDs[0], " + + "validation: value must contain exactly 64 lowercase alphanumeric characters", expectError: true, }, { name: "id-too-long", stdout: "", - stderr: "invalid testsuite spec, fields: Spec.Selectors.IDs[0]", + stderr: "invalid spec, spec.kind: testsuite, " + + "fields: Spec.Selectors.IDs[0], " + + "validation: value must contain exactly 64 lowercase alphanumeric characters", expectError: true, }, { name: "empty-name", stdout: "", - stderr: "invalid testsuite spec, fields: Spec.Selectors.Names[0]", + stderr: "invalid spec, spec.kind: testsuite, " + + "fields: Spec.Selectors.Names[0], " + + "validation: rule constraint violated, " + + "rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { name: "name-too-long", stdout: "", - stderr: "invalid testsuite spec, fields: Spec.Selectors.Names[0]", + stderr: "invalid spec, spec.kind: testsuite, " + + "fields: Spec.Selectors.Names[0], " + + "validation: rule constraint violated, " + + "rule.name: max, rule.param.name: length, rule.param.value: 200", expectError: true, }, { name: "empty-tag", stdout: "", - stderr: "invalid testsuite spec, fields: Spec.Selectors.Tags[0]", + stderr: "invalid spec, spec.kind: testsuite, " + + "fields: Spec.Selectors.Tags[0], " + + "validation: rule constraint violated, " + + "rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { name: "tag-too-long", stdout: "", - stderr: "invalid testsuite spec, fields: Spec.Selectors.Tags[0]", + stderr: "invalid spec, spec.kind: testsuite, " + + "fields: Spec.Selectors.Tags[0], " + + "validation: rule constraint violated, " + + "rule.name: max, rule.param.name: length, rule.param.value: 200", expectError: true, }, { - name: "id-min-length", - stdout: "Testsuite spec is valid", - stderr: "", - expectError: false, - }, - { - name: "id-max-length", + name: "id-valid-length", stdout: "Testsuite spec is valid", stderr: "", expectError: false, @@ -122,24 +134,78 @@ func TestValidateTestSuite(t *testing.T) { { name: "duplicate-id", stdout: "", - stderr: "invalid spec, spec.kind: testsuite\ntest selectors must be unique, " + - "testsuite.selector: ids, value: id", + stderr: "invalid spec, spec.kind: testsuite, " + + "fields: Spec.Selectors.IDs[1], " + + "validation: test selectors must be unique, " + + "testsuite.selector: ids, " + + "value: 7398ab887149ec5aa583c564a659a0b0a933ef27bacb675b081a2a752d8a3896", expectError: true, }, { name: "duplicate-name", stdout: "", - stderr: "invalid spec, spec.kind: testsuite\ntest selectors must be unique, " + - "testsuite.selector: names, value: test", + stderr: "invalid spec, spec.kind: testsuite, " + + "fields: Spec.Selectors.Names[1], " + + "validation: test selectors must be unique, testsuite.selector: names, value: test", expectError: true, }, { name: "duplicate-tag", stdout: "", - stderr: "invalid spec, spec.kind: testsuite\ntest selectors must be unique, " + - "testsuite.selector: tags, value: tag", + stderr: "invalid spec, spec.kind: testsuite, " + + "fields: Spec.Selectors.Tags[1], " + + "validation: test selectors must be unique, testsuite.selector: tags, value: tag", + expectError: true, + }, + { + name: "invalid-resource-id", + stdout: "", + stderr: "invalid spec, spec.kind: testsuite, " + + "fields: ID, " + + "validation: value must contain exactly 64 lowercase alphanumeric characters", + expectError: true, + }, + { + name: "resource-name-too-short", + stdout: "", + stderr: "invalid spec, spec.kind: testsuite, " + + "fields: Name, " + + "validation: rule constraint violated, " + + "rule.name: min, rule.param.name: length, rule.param.value: 3", expectError: true, }, + { + name: "resource-name-too-long", + stdout: "", + stderr: "invalid spec, spec.kind: testsuite, " + + "fields: Name, " + + "validation: rule constraint violated, " + + "rule.name: max, rule.param.name: length, rule.param.value: 200", + expectError: true, + }, + { + name: "invalid-resource-version", + stdout: "", + stderr: "invalid spec, spec.kind: testsuite, " + + "fields: Version, " + + "validation: rule constraint violated, rule.name: semver", + expectError: true, + }, + { + name: "resource-description-too-short", + stdout: "", + stderr: "invalid spec, spec.kind: testsuite, " + + "fields: Description, " + + "validation: rule constraint violated, " + + "rule.name: min, rule.param.name: length, rule.param.value: 3", + expectError: true, + }, + { + name: "same-value-across-selectors", + stdout: "Testsuite spec is valid", + stderr: "", + expectError: false, + }, } for _, tt := range tests { diff --git a/docker/data/direct/direct-mocked-grpc.env.yml b/docker/data/direct/direct-mocked-grpc.env.yml index 4513323..d7dcaf0 100644 --- a/docker/data/direct/direct-mocked-grpc.env.yml +++ b/docker/data/direct/direct-mocked-grpc.env.yml @@ -7,7 +7,7 @@ spec: - id: direct-mocked-grpc kind: grpc mode: mocked - address: 127.0.0.1:8083 + e2engine_port: 8083 proto: internal: package: entitlements.v1 diff --git a/docker/data/direct/direct-mocked-http.env.yml b/docker/data/direct/direct-mocked-http.env.yml index 32a9cc2..6170940 100644 --- a/docker/data/direct/direct-mocked-http.env.yml +++ b/docker/data/direct/direct-mocked-http.env.yml @@ -7,7 +7,7 @@ spec: - id: direct-mocked-http kind: http mode: mocked - address: 127.0.0.1:8083 + e2engine_port: 8083 fixtures: - when: http: diff --git a/docker/data/direct/direct-real-http.env.yml b/docker/data/direct/direct-real-http.env.yml index b6e0750..15e5081 100644 --- a/docker/data/direct/direct-real-http.env.yml +++ b/docker/data/direct/direct-real-http.env.yml @@ -7,5 +7,5 @@ spec: - id: direct-real-http kind: http mode: real - address: 127.0.0.1:8083 - http_target: http://ok-http:9000 + e2engine_port: 8083 + target: http://ok-http:9000 diff --git a/go.mod b/go.mod index 41d790a..4d45c6e 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.1 + github.com/e2engine/core v0.3.0 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 @@ -21,5 +21,3 @@ require ( golang.org/x/text v0.43.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20261012220534-4341edf3f941 // indirect ) - -replace github.com/e2engine/core => ../core diff --git a/go.sum b/go.sum index 3edb841..da79171 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/e2engine/core v0.3.0 h1:hx7THwTfc9wYtFOW7sE9kfLNFOG8ff/2tD+lD4pvzmM= +github.com/e2engine/core v0.3.0/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= diff --git a/services/telemetry-http/main.go b/services/telemetry-http/main.go new file mode 100644 index 0000000..c835bcf --- /dev/null +++ b/services/telemetry-http/main.go @@ -0,0 +1,248 @@ +package main + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "flag" + "fmt" + "io" + "log" + "net/http" + "os" + "os/signal" + "strings" + "sync" + "syscall" + "time" +) + +const ( + defaultAddress = "127.0.0.1:39091" + + installationID = "AAAAAAAAAAAAAAAAAAAAAA" + installationToken = "et_AAAAAAAAAAAAAAAAAAAAAA.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + + maxRequestBodyBytes = 64 * 1024 +) + +type options struct { + address string + recordsPath string + registrationStatus int + registrationBody string + eventsStatus int + expectedBearerToken string + shutdownTimeout time.Duration +} + +type requestRecord struct { + ReceivedAt time.Time `json:"received_at"` + Method string `json:"method"` + Path string `json:"path"` + ContentType string `json:"content_type,omitempty"` + Authorization string `json:"authorization,omitempty"` + Body json.RawMessage `json:"body,omitempty"` +} + +type recorder struct { + mu sync.Mutex + file *os.File +} + +func newRecorder(path string) (*recorder, error) { + if strings.TrimSpace(path) == "" { + return nil, errors.New("records path is required") + } + + file, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o600) + if err != nil { + return nil, fmt.Errorf("open records file: %w", err) + } + + return &recorder{file: file}, nil +} + +func (r *recorder) record(request *http.Request, body []byte) error { + r.mu.Lock() + defer r.mu.Unlock() + + record := requestRecord{ + ReceivedAt: time.Now().UTC(), + Method: request.Method, + Path: request.URL.Path, + ContentType: request.Header.Get("Content-Type"), + Authorization: request.Header.Get("Authorization"), + } + if len(body) > 0 { + record.Body = append(json.RawMessage(nil), body...) + } + + if err := json.NewEncoder(r.file).Encode(record); err != nil { + return fmt.Errorf("write request record: %w", err) + } + if err := r.file.Sync(); err != nil { + return fmt.Errorf("sync request record: %w", err) + } + return nil +} + +func (r *recorder) close() error { + r.mu.Lock() + defer r.mu.Unlock() + return r.file.Close() +} + +type server struct { + options options + recorder *recorder +} + +func (s *server) routes() http.Handler { + mux := http.NewServeMux() + mux.HandleFunc("GET /health", s.health) + mux.HandleFunc("POST /v1/installations", s.createInstallation) + mux.HandleFunc("POST /v1/events", s.createEvents) + return mux +} + +func (s *server) health(writer http.ResponseWriter, _ *http.Request) { + writer.WriteHeader(http.StatusOK) +} + +func (s *server) createInstallation(writer http.ResponseWriter, request *http.Request) { + body, ok := s.readBody(writer, request) + if !ok { + return + } + if err := s.recorder.record(request, body); err != nil { + http.Error(writer, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) + return + } + + if s.options.registrationStatus != http.StatusCreated { + writer.WriteHeader(s.options.registrationStatus) + return + } + + bodyValue := s.options.registrationBody + if bodyValue == "" { + bodyValue = `{"id":"` + installationID + `","token":"` + installationToken + `"}` + } + writer.Header().Set("Content-Type", "application/json") + writer.WriteHeader(http.StatusCreated) + _, _ = io.WriteString(writer, bodyValue) +} + +func (s *server) createEvents(writer http.ResponseWriter, request *http.Request) { + body, ok := s.readBody(writer, request) + if !ok { + return + } + if err := s.recorder.record(request, body); err != nil { + http.Error(writer, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError) + return + } + + if request.Header.Get("Authorization") != "Bearer "+s.options.expectedBearerToken { + writer.WriteHeader(http.StatusUnauthorized) + return + } + if !validEventsBody(body) { + writer.WriteHeader(http.StatusBadRequest) + return + } + + writer.WriteHeader(s.options.eventsStatus) +} + +func (s *server) readBody(writer http.ResponseWriter, request *http.Request) ([]byte, bool) { + body, err := io.ReadAll(io.LimitReader(request.Body, maxRequestBodyBytes+1)) + if err != nil { + writer.WriteHeader(http.StatusBadRequest) + return nil, false + } + if len(body) > maxRequestBodyBytes { + writer.WriteHeader(http.StatusRequestEntityTooLarge) + return nil, false + } + return body, true +} + +func validEventsBody(body []byte) bool { + var value struct { + Events []json.RawMessage `json:"events"` + } + decoder := json.NewDecoder(bytes.NewReader(body)) + decoder.DisallowUnknownFields() + if err := decoder.Decode(&value); err != nil { + return false + } + if err := decoder.Decode(new(any)); err != io.EOF { + return false + } + return len(value.Events) > 0 && len(value.Events) <= 25 +} + +func parseOptions() options { + var value options + flag.StringVar(&value.address, "address", defaultAddress, "HTTP listen address") + flag.StringVar(&value.recordsPath, "records", "", "JSONL request records path") + flag.IntVar(&value.registrationStatus, "registration-status", http.StatusCreated, "registration response status") + flag.StringVar(&value.registrationBody, "registration-body", "", "registration response body override") + flag.IntVar(&value.eventsStatus, "events-status", http.StatusNoContent, "events response status") + flag.StringVar(&value.expectedBearerToken, "expected-token", installationToken, "expected bearer token") + flag.DurationVar(&value.shutdownTimeout, "shutdown-timeout", 2*time.Second, "graceful shutdown timeout") + flag.Parse() + return value +} + +func run() error { + value := parseOptions() + records, err := newRecorder(value.recordsPath) + if err != nil { + return err + } + defer func() { _ = records.close() }() + + handler := (&server{options: value, recorder: records}).routes() + httpServer := &http.Server{ + Addr: value.address, + Handler: handler, + ReadHeaderTimeout: 2 * time.Second, + } + + ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) + defer stop() + + serverErr := make(chan error, 1) + go func() { + serverErr <- httpServer.ListenAndServe() + }() + + select { + case err := <-serverErr: + if errors.Is(err, http.ErrServerClosed) { + return nil + } + return err + case <-ctx.Done(): + } + + shutdownCtx, cancel := context.WithTimeout(context.Background(), value.shutdownTimeout) + defer cancel() + if err := httpServer.Shutdown(shutdownCtx); err != nil { + return fmt.Errorf("shut down HTTP server: %w", err) + } + if err := <-serverErr; !errors.Is(err, http.ErrServerClosed) { + return err + } + return nil +} + +func main() { + if err := run(); err != nil { + log.Fatal(err) + } +} From 4bc24c8a23c86d16c6994a24dcf4985db1437972 Mon Sep 17 00:00:00 2001 From: Yaroslav Grebnov Date: Wed, 18 Nov 2026 11:43:28 +0100 Subject: [PATCH 3/6] Add mcp tests --- .github/workflows/build.yml | 14 +- .gitignore | 4 +- Makefile | 104 ++++------ README.md | 62 +++--- cli/harness/config_test.go | 47 +++++ cli/harness/harness.go | 49 ++++- cli/harness/telemetry_option_test.go | 47 +++++ cli/tests/routing_test.go | 21 +- cli/tests/socket_config_test.go | 2 +- cli/tests/telemetry_test.go | 39 ++-- cli/tests/transport_kind_test.go | 34 +++- cli/tests/validate_environment_test.go | 194 +++++++++---------- cli/tests/validate_test_test.go | 186 +++++++++--------- cli/tests/validate_testsuite_test.go | 42 ++-- docker/harness/harness.go | 78 +++++--- docker/harness/telemetry_test.go | 41 ++++ docker/tests/telemetry_test.go | 110 +++++++++++ go.mod | 28 ++- go.sum | 60 ++++-- mcp/bin/.gitkeep | 0 mcp/harness/harness.go | 120 ++++++++++++ mcp/tests/telemetry_test.go | 258 +++++++++++++++++++++++++ mcp/tests/tools_test.go | 223 +++++++++++++++++++++ 23 files changed, 1369 insertions(+), 394 deletions(-) create mode 100644 cli/harness/config_test.go create mode 100644 cli/harness/telemetry_option_test.go create mode 100644 docker/harness/telemetry_test.go create mode 100644 docker/tests/telemetry_test.go create mode 100644 mcp/bin/.gitkeep create mode 100644 mcp/harness/harness.go create mode 100644 mcp/tests/telemetry_test.go create mode 100644 mcp/tests/tools_test.go diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 74d6991..62b0001 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: build +name: lint on: pull_request: @@ -6,18 +6,22 @@ on: - main workflow_dispatch: +permissions: + contents: read + jobs: - build: + lint: runs-on: ubuntu-latest steps: - - name: Checkout + - name: Checkout tests uses: actions/checkout@v7 - name: Setup Go uses: actions/setup-go@v7 with: go-version: "1.27.x" + cache-dependency-path: '**/go.sum' - - name: Verify - run: make verify + - name: Lint + run: make lint diff --git a/.gitignore b/.gitignore index 6ab8433..23d127b 100644 --- a/.gitignore +++ b/.gitignore @@ -12,9 +12,11 @@ vendor/ /cli/bin/* !/cli/bin/.gitkeep +/mcp/bin/* +!/mcp/bin/.gitkeep /services/bin/* !/services/bin/.gitkeep /services/docker-bin/* !/services/docker-bin/.gitkeep /docker/testdata/* -!/docker/testdata/.gitkeep \ No newline at end of file +!/docker/testdata/.gitkeep diff --git a/Makefile b/Makefile index 7fff48d..f4fe142 100644 --- a/Makefile +++ b/Makefile @@ -9,40 +9,13 @@ export PATH := $(ROOT_PATH)tools/bin:$(PATH) include $(ROOT_PATH)tools/tools.mk -BUILD_DIR := $(ROOT_PATH)build - -CLI_REPO ?= https://github.com/e2engine/cli.git -CLI_REF ?= main - -CLI_SRC := $(BUILD_DIR)/cli - -GOOS ?= $(shell uname -s | tr '[:upper:]' '[:lower:]') GOARCH ?= $(shell uname -m) ifeq ($(GOARCH), x86_64) override GOARCH = amd64 endif -CLI_BIN_NAME := e2engine-$(GOOS)-$(GOARCH)$(shell [ "$(GOOS)" = windows ] && echo .exe) -CLI_BIN := $(ROOT_PATH)cli/bin/cli -CLI_VERSION ?= v0.0.0-e2e -CLI_TELEMETRY_BASE_URL ?= http://127.0.0.1:39091 - -.PHONY: build-cli -build-cli: - @echo "Building e2engine-cli..." - @rm -rf $(BUILD_DIR) - @set -e; \ - trap 'rm -rf "$(BUILD_DIR)"' EXIT; \ - echo "Cloning CLI repository..."; \ - git clone $(CLI_REPO) $(CLI_SRC); \ - git -C $(CLI_SRC) checkout $(CLI_REF); \ - echo "Preparing e2engine-cli module..."; \ - cd $(CLI_SRC); \ - mkdir -p $(dir $(CLI_BIN)); \ - echo "Building $(CLI_BIN_NAME) binary..."; \ - $(MAKE) build-cli VERSION=$(CLI_VERSION) TELEMETRY_BASE_URL=$(CLI_TELEMETRY_BASE_URL); \ - cp bin/$(CLI_BIN_NAME) $(CLI_BIN) - @echo "$(CLI_BIN) built successfully" +CLI_BIN := $(ROOT_PATH)cli/bin/cli +MCP_BIN := $(ROOT_PATH)mcp/bin/mcp SERVICES_BIN_PATH ?= $(ROOT_PATH)services/bin @@ -100,24 +73,6 @@ protoc-ok-service: services/ok-grpc/ok.proto @echo "Protobuf code generated successfully for ok service." -.PHONY: build-image -build-image: - @echo "Checking Docker availability..." - @docker info >/dev/null 2>&1 || (echo "Docker is not available" && exit 1) - @echo "Building e2engine Docker image..." - @rm -rf $(BUILD_DIR) - @set -e; \ - trap 'rm -rf "$(BUILD_DIR)"' EXIT; \ - echo "Cloning CLI repository..."; \ - git clone $(CLI_REPO) $(CLI_SRC); \ - git -C $(CLI_SRC) checkout $(CLI_REF); \ - echo "Preparing e2engine-cli module..."; \ - cd $(CLI_SRC); \ - echo "Building e2engine Docker image..."; \ - $(MAKE) build-image - @echo "e2engine:local image built successfully" - - DOCKER_SERVICES_BIN_PATH := $(ROOT_PATH)services/docker-bin .PHONY: build-ok-http-image @@ -137,6 +92,18 @@ build-ok-http-image: services @echo "ok-http image built successfully" +.PHONY: build-telemetry-http-image +build-telemetry-http-image: + @CGO_ENABLED=0 GOOS=linux GOARCH=$(GOARCH) go build \ + -o $(DOCKER_SERVICES_BIN_PATH)/telemetry-http ./services/telemetry-http + @docker buildx build \ + --platform linux/$(GOARCH) \ + --load \ + --build-arg SERVICE=telemetry-http \ + -t e2engine-test-telemetry-http:local \ + -f services/Dockerfile \ + services + .PHONY: lint lint: install-golangci-lint @@ -144,36 +111,47 @@ lint: install-golangci-lint $(GOLANGCI_LINT) run .PHONY: build -build: build-cli \ - build-gateway-http-path-service \ +build: build-gateway-http-path-service \ build-gateway-http-body-service \ build-gateway-grpc-message-service \ build-gateway-grpc-method-service \ build-ok-http-service \ build-ok-grpc-service \ build-telemetry-http-service \ - build-image \ - build-ok-http-image - @echo "All test binaries and images built successfully." + build-ok-http-image \ + build-telemetry-http-image + @echo "All test helper binaries and images built successfully." .PHONY: verify -verify: lint build +verify: lint test-cli-prebuilt test-docker-prebuilt test-mcp-prebuilt @echo "All verifications passed successfully." -.PHONY: test-cli -test-cli: build-cli \ - build-gateway-http-path-service \ +.PHONY: test-cli-prebuilt +test-cli-prebuilt: build-gateway-http-path-service \ build-gateway-http-body-service \ build-gateway-grpc-message-service \ build-gateway-grpc-method-service \ build-ok-http-service \ build-ok-grpc-service \ build-telemetry-http-service - @echo "Running CLI tests..." - @E2ENGINE_TELEMETRY_DISABLED=1 go test ./cli/... -count=1 - -.PHONY: test-docker -test-docker: build-image \ - build-ok-http-image - @echo "Running tests with Docker image..." + @test -x $(CLI_BIN) || { echo "Prebuilt CLI binary not found or not executable: $(CLI_BIN)"; exit 1; } + @echo "Running CLI tests with prebuilt binary..." + @go test ./cli/... -count=1 + +.PHONY: check-cli-image +check-cli-image: + @docker image inspect e2engine:local >/dev/null 2>&1 || { echo "Prebuilt CLI Docker image not found: e2engine:local"; exit 1; } + +.PHONY: test-docker-prebuilt +test-docker-prebuilt: check-cli-image \ + build-ok-http-image \ + build-telemetry-http-image + @echo "Running tests with prebuilt Docker image..." @go test ./docker/... -count=1 + +.PHONY: test-mcp-prebuilt +test-mcp-prebuilt: export GOFLAGS=-mod=mod +test-mcp-prebuilt: build-telemetry-http-service + @test -x $(MCP_BIN) || { echo "Prebuilt MCP binary not found or not executable: $(MCP_BIN)"; exit 1; } + @echo "Running MCP tests with prebuilt binary..." + @go test ./mcp/... -count=1 diff --git a/README.md b/README.md index 5625fc7..be20438 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ End-to-end test suite for E2Engine. Part of [E2Engine](https://e2engine.dev), an open-source platform for declarative end-to-end testing. -This repository verifies E2Engine through its public interfaces using the CLI, Docker, real and mocked HTTP/gRPC services, direct and socket transports, persistence, and asynchronous execution flows. +This repository verifies E2Engine through its public interfaces using the CLI, MCP, Docker, real and mocked HTTP/gRPC services, direct and socket transports, persistence, and asynchronous execution flows. -The CLI, Docker images, and helper service binaries required by the tests are built locally by the Makefile before the corresponding test suites run. +Candidate CLI and MCP binaries and the CLI Docker image are built in their owning repositories. This Makefile builds the test helper services and consumes the candidate artifacts. ## Coverage @@ -23,7 +23,8 @@ The CLI, Docker images, and helper service binaries required by the tests are bu | Real-to-mocked dependencies | Real HTTP/gRPC services calling mocked dependencies with captured calls | | Call expectations | Required calls, expected call counts, unmatched call parameters, and missing expected dependencies | | Execution results | Passed, failed, and error terminal states with persisted execution summaries | -| Telemetry | CLI opt-out, installation registration and reuse, authenticated events, outcome mapping, and best-effort failures against a standalone HTTP mock | +| Telemetry | CLI opt-out, installation registration and reuse, authenticated events, outcome mapping, and best-effort failures against a standalone HTTP mock; Docker registration and authenticated event reuse against the mock container | +| MCP | All environment, test, and test-suite tools over stdio: successful operations and application errors, persistence across process restarts, and telemetry behavior | | Runner lifecycle | Direct execution waits for completion; socket executions run asynchronously and sequentially | | Docker | CLI execution in containers, mounted configuration and persistent data, mocked HTTP/gRPC execution, and communication with real services over a Docker network | @@ -33,40 +34,53 @@ The E2E suite focuses on behavior across component boundaries. Exhaustive field- ```text cli/ CLI E2E tests, harness, test data, and generated CLI binary +mcp/ MCP E2E tests, stdio harness, and generated MCP binary docker/ Docker E2E tests, harness, configuration, and test data services/ Helper HTTP/gRPC services, the telemetry HTTP mock, generated service binaries, and the reusable service Dockerfile util/ Shared E2E comparison and test utilities ``` -Generated binaries are written to cli/bin/ and services/bin/ and are not committed. Docker tests use locally built E2Engine and helper service images. +Candidate binaries are placed in cli/bin/ and mcp/bin/; test helper binaries are written to services/bin/. None is committed. Docker tests use the prebuilt E2Engine image and locally built helper service images. ## Development -Run the CLI E2E test suite: +Build the candidate CLI binary in the CLI checkout, then run the CLI suite: ```bash -make test-cli +make -C ../cli build-cli-e2e E2E_CLI_PATH="$(pwd)/cli/bin/cli" +make test-cli-prebuilt ``` -Run the Docker E2E test suite: +Build the candidate Docker image from the same CLI checkout, then run the Docker suite: ```bash -make test-docker +make -C ../cli build-image-e2e +make test-docker-prebuilt ``` -Run the linter: +The image target creates `e2engine:local` with the telemetry mock address +`http://telemetry-http:9000`. Docker tests build their own helper service images. + +Build the candidate MCP binary in the MCP checkout, then run the MCP suite: ```bash -make lint +make -C ../mcp build-e2e E2E_MCP_PATH="$(pwd)/mcp/bin/mcp" +make test-mcp-prebuilt ``` -Run the complete verification suite: +MCP builds with local module replacements need the corresponding sibling +checkouts. The MCP suite uses a standalone telemetry HTTP mock and a temporary +user profile; it does not contact AWS. + +Run all three suites and the linter after building the candidate artifacts: ```bash make verify ``` -The test targets build the binaries and Docker images required by their respective suites before running the tests. +`make build` builds only the test repository's helper binaries and images. +The prebuilt test targets build their own helper prerequisites and check that +the supplied CLI/MCP binaries or CLI image exist. ## Stable branch @@ -77,18 +91,22 @@ Downstream CI, such as the CLI build, should use `stable` rather than `main`. Th Changes are promoted in the following order: 1. Update dependencies and tests on `main`. -2. Run the complete test repository CI and ensure it passes. +2. Build candidate CLI and MCP binaries and the CLI image locally, then run + `make verify`. Ensure the tests repository lint CI passes. 3. Promote `main` to `stable`: ```bash git switch main git pull --ff-only -# after main CI is green +# after local E2E verification and main lint CI are green git push origin main:stable ``` -The `stable` branch must always point to a commit from main that has already passed CI; promotion should only fast-forward the branch and must not create new commits. +The `stable` branch must always point to a commit from main that has passed +lint CI and local E2E verification. Promotion should only fast-forward the +branch and must not create new commits. CLI and MCP CI build their own +candidate artifacts and run the corresponding prebuilt suites from `stable`. 4. Update downstream repositories that depend on the new versions. @@ -106,17 +124,11 @@ tests/stable downstream repository update ``` -## E2Engine - -This repository is part of E2Engine. +## Links -- [core](https://github.com/e2engine/core) — core domain model, execution logic, and public APIs -- [repository](https://github.com/e2engine/repository) — persistence implementations -- [runner-local](https://github.com/e2engine/runner-local) — local test execution -- [cli](https://github.com/e2engine/cli) — command-line interface -- [tests](https://github.com/e2engine/tests) — end-to-end tests for E2Engine -- [demo](https://github.com/e2engine/demo) — executable demonstration system and E2Engine usage examples -- [instrumentation-go](https://github.com/e2engine/instrumentation-go) — Go instrumentation library for E2Engine +- [E2Engine website](https://e2engine.dev) +- [E2Engine documentation](https://e2engine.dev/docs) +- [E2Engine on GitHub](https://github.com/e2engine) ## License diff --git a/cli/harness/config_test.go b/cli/harness/config_test.go new file mode 100644 index 0000000..1ad4133 --- /dev/null +++ b/cli/harness/config_test.go @@ -0,0 +1,47 @@ +package harness + +import ( + "os" + "path/filepath" + "runtime" + "testing" +) + +func TestNewCopiesConfigFixturePrivately(t *testing.T) { + sourcePath := filepath.Join(t.TempDir(), "config.yml") + contents := []byte("output:\n list_max_size: 4\n") + if err := os.WriteFile(sourcePath, contents, 0o644); err != nil { + t.Fatal(err) + } + if err := os.Chmod(sourcePath, 0o644); err != nil { + t.Fatal(err) + } + + h := New(t, "unused-cli", sourcePath, "") + if h.configPath == sourcePath { + t.Fatal("harness reused the checked-in config fixture") + } + got, err := os.ReadFile(h.configPath) + if err != nil { + t.Fatal(err) + } + if string(got) != string(contents) { + t.Fatalf("private config contents = %q, want %q", got, contents) + } + if runtime.GOOS != "windows" { + privateInfo, err := os.Stat(h.configPath) + if err != nil { + t.Fatal(err) + } + if privateInfo.Mode().Perm() != 0o600 { + t.Fatalf("private config permissions = %o, want 600", privateInfo.Mode().Perm()) + } + sourceInfo, err := os.Stat(sourcePath) + if err != nil { + t.Fatal(err) + } + if sourceInfo.Mode().Perm() != 0o644 { + t.Fatalf("source config permissions changed to %o", sourceInfo.Mode().Perm()) + } + } +} diff --git a/cli/harness/harness.go b/cli/harness/harness.go index 01ed206..13947b5 100644 --- a/cli/harness/harness.go +++ b/cli/harness/harness.go @@ -3,7 +3,9 @@ package harness import ( "bytes" "context" + "os" "os/exec" + "path/filepath" "regexp" "strings" "testing" @@ -13,25 +15,51 @@ import ( ) type Harness struct { - t *testing.T - cliPath string - configPath string - dataDir string + t *testing.T + cliPath string + configPath string + dataDir string + telemetryEnabled bool } -func New(t *testing.T, cliPath, configPath, dataDir string) *Harness { +// Option configures a test harness. +type Option func(*Harness) + +// WithTelemetryEnabled allows the CLI process to initialize and send telemetry. +func WithTelemetryEnabled() Option { + return func(h *Harness) { + h.telemetryEnabled = true + } +} + +func New(t *testing.T, cliPath, configPath, dataDir string, options ...Option) *Harness { + t.Helper() if configPath == "" { configPath = "../config/empty-config.yml" } + configData, err := os.ReadFile(configPath) + if err != nil { + t.Fatalf("read CLI config fixture %q: %v", configPath, err) + } + privateConfigPath := filepath.Join(t.TempDir(), filepath.Base(configPath)) + // #nosec G703 -- the destination is under t.TempDir and uses filepath.Base. + if err := os.WriteFile(privateConfigPath, configData, 0o600); err != nil { + t.Fatalf("create private CLI config fixture: %v", err) + } + configPath = privateConfigPath t.Setenv("E2ENGINE_CONFIG_PATH", configPath) - return &Harness{ + h := &Harness{ t: t, cliPath: cliPath, configPath: configPath, dataDir: dataDir, } + for _, option := range options { + option(h) + } + return h } func (h *Harness) RunCommand( @@ -44,11 +72,17 @@ func (h *Harness) RunCommand( h.t.Setenv("E2ENGINE_DATA_DIR", h.dataDir) } + // #nosec G702 -- this test harness invokes a supplied binary directly without a shell. cmd := exec.CommandContext( ctx, h.cliPath, args..., ) + disabled := "1" + if h.telemetryEnabled { + disabled = "0" + } + cmd.Env = append(os.Environ(), "E2ENGINE_TELEMETRY_DISABLED="+disabled) var stdoutBuf bytes.Buffer var stderrBuf bytes.Buffer @@ -285,7 +319,8 @@ func get[T any](ctx context.Context, h *Harness, ref, kind string) T { func run(ctx context.Context, h *Harness, kind, testRef, envRef string, args ...string) string { h.t.Helper() - runArgs := []string{"run", kind, testRef, envRef} + runArgs := make([]string, 0, 4+len(args)) + runArgs = append(runArgs, "run", kind, testRef, envRef) runArgs = append(runArgs, args...) stdout, stderr, err := h.RunCommand( diff --git a/cli/harness/telemetry_option_test.go b/cli/harness/telemetry_option_test.go new file mode 100644 index 0000000..76903ad --- /dev/null +++ b/cli/harness/telemetry_option_test.go @@ -0,0 +1,47 @@ +package harness + +import ( + "context" + "fmt" + "os" + "testing" +) + +func TestTelemetryOption(t *testing.T) { + tests := []struct { + name string + inherited string + option Option + want string + }{ + {name: "disabled by default", inherited: "0", want: "1"}, + {name: "explicitly enabled", inherited: "1", option: WithTelemetryEnabled(), want: "0"}, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + t.Setenv("E2ENGINE_HARNESS_CHILD", "1") + t.Setenv("E2ENGINE_TELEMETRY_DISABLED", test.inherited) + var options []Option + if test.option != nil { + options = append(options, test.option) + } + h := New(t, os.Args[0], "", "", options...) + stdout, stderr, err := h.RunCommand(context.Background(), "-test.run=TestTelemetryOptionChild") + if err != nil { + t.Fatalf("run helper process: %v\nstderr: %s", err, stderr) + } + if stdout != test.want { + t.Fatalf("child telemetry disabled = %q, want %q", stdout, test.want) + } + }) + } +} + +func TestTelemetryOptionChild(t *testing.T) { + if os.Getenv("E2ENGINE_HARNESS_CHILD") != "1" { + return + } + _, _ = fmt.Fprint(os.Stdout, os.Getenv("E2ENGINE_TELEMETRY_DISABLED")) + os.Exit(0) +} diff --git a/cli/tests/routing_test.go b/cli/tests/routing_test.go index bd083ef..6390c04 100644 --- a/cli/tests/routing_test.go +++ b/cli/tests/routing_test.go @@ -15,15 +15,15 @@ func TestRouting(t *testing.T) { dataDir := "../data/routing" tests := []struct { - name string - specName string - services []string - env map[string]string - checkParams func(id string) *checkTestExecutionParams + name string + specName string + services []string + env map[string]string + checkParams func(id string) *checkTestExecutionParams listenInterface string }{ { - name: "real-http-target", + name: "real-http-target", specName: "real-http-target", services: []string{ "ok-http", @@ -37,7 +37,7 @@ func TestRouting(t *testing.T) { }, }, { - name: "real-grpc-target", + name: "real-grpc-target", specName: "real-grpc-target", services: []string{ "ok-grpc", @@ -51,7 +51,7 @@ func TestRouting(t *testing.T) { }, }, { - name: "real-http-target-socket", + name: "real-http-target-socket", specName: "real-http-target", services: []string{ "ok-http", @@ -69,7 +69,7 @@ func TestRouting(t *testing.T) { }, }, { - name: "real-grpc-target-socket", + name: "real-grpc-target-socket", specName: "real-grpc-target", services: []string{ "ok-grpc", @@ -226,7 +226,6 @@ func TestRouting(t *testing.T) { } } - func TestRouting_InvalidListenInterface(t *testing.T) { dataDir := "../data/routing" @@ -294,4 +293,4 @@ func TestRouting_InvalidListenInterface(t *testing.T) { if stdout != "" { t.Fatalf("expected no stdout output, got: %s", stdout) } -} \ No newline at end of file +} diff --git a/cli/tests/socket_config_test.go b/cli/tests/socket_config_test.go index f0c9e81..44922f7 100644 --- a/cli/tests/socket_config_test.go +++ b/cli/tests/socket_config_test.go @@ -57,4 +57,4 @@ func TestSocketConfig_Validate(t *testing.T) { t.Fatal("expected non-nil receiver") } } - */ +*/ diff --git a/cli/tests/telemetry_test.go b/cli/tests/telemetry_test.go index 7d2e93e..63b87c5 100644 --- a/cli/tests/telemetry_test.go +++ b/cli/tests/telemetry_test.go @@ -55,7 +55,7 @@ type telemetryTest struct { installationPath string } -func setupTelemetryTest(t *testing.T, serviceArgs ...string) *telemetryTest { +func setupTelemetryTest(t *testing.T, telemetryEnabled bool, serviceArgs ...string) *telemetryTest { t.Helper() ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) @@ -66,18 +66,18 @@ func setupTelemetryTest(t *testing.T, serviceArgs ...string) *telemetryTest { t.Setenv("HOME", profileDir) t.Setenv("XDG_CONFIG_HOME", configDir) t.Setenv("APPDATA", configDir) - t.Setenv("E2ENGINE_TELEMETRY_DISABLED", "0") resolvedConfigDir, err := os.UserConfigDir() if err != nil { t.Fatalf("Resolve user configuration directory: %v", err) } installationDir := filepath.Join(resolvedConfigDir, "e2engine") - if err := os.MkdirAll(installationDir, 0o700); err != nil { - t.Fatalf("Create private E2Engine configuration directory: %v", err) + if _, err := os.Lstat(installationDir); !os.IsNotExist(err) { + t.Fatalf("E2Engine configuration directory is not absent before CLI startup: %v", err) } - if err := os.Chmod(installationDir, 0o700); err != nil { - t.Fatalf("Secure E2Engine configuration directory: %v", err) + configPath := filepath.Join(profileDir, "empty-config.yml") + if err := os.WriteFile(configPath, nil, 0o600); err != nil { + t.Fatalf("Create private empty CLI config: %v", err) } recordsPath := filepath.Join(t.TempDir(), "telemetry-requests.jsonl") @@ -86,7 +86,11 @@ func setupTelemetryTest(t *testing.T, serviceArgs ...string) *telemetryTest { serviceCtx, serviceCancel := context.WithCancel(context.Background()) t.Cleanup(serviceCancel) - h := harness.New(t, "../bin/cli", "", filepath.Join(t.TempDir(), "data")) + var options []harness.Option + if telemetryEnabled { + options = append(options, harness.WithTelemetryEnabled()) + } + h := harness.New(t, "../bin/cli", configPath, filepath.Join(t.TempDir(), "data"), options...) process := h.StartService(serviceCtx, "telemetry-http", args...) t.Cleanup(func() { process.Stop(t) @@ -131,7 +135,7 @@ func decodeEventRequest(t *testing.T, record harness.TelemetryRequestRecord) tel } func TestTelemetryRegistrationSubmissionAndReuse(t *testing.T) { - test := setupTelemetryTest(t) + test := setupTelemetryTest(t, true) test.runSuccess(t, "get", "environments", "-o", "yaml") test.runSuccess(t, "get", "environments", "-o", "yaml") @@ -163,6 +167,14 @@ func TestTelemetryRegistrationSubmissionAndReuse(t *testing.T) { t.Fatalf("Installation file = %#v", installation) } if runtime.GOOS != "windows" { + dirInfo, err := os.Stat(filepath.Dir(test.installationPath)) + if err != nil { + t.Fatal(err) + } + if dirInfo.Mode().Perm() != 0o700 { + t.Fatalf("E2Engine configuration directory permissions = %o, want 700", dirInfo.Mode().Perm()) + } + info, err := os.Stat(test.installationPath) if err != nil { t.Fatal(err) @@ -206,7 +218,7 @@ func TestTelemetryRegistrationSubmissionAndReuse(t *testing.T) { } func TestTelemetryErrorEvent(t *testing.T) { - test := setupTelemetryTest(t) + test := setupTelemetryTest(t, true) stdout, stderr, err := test.h.RunCommand(test.ctx, "get", "environment", "missing-environment") if err == nil { @@ -228,8 +240,7 @@ func TestTelemetryErrorEvent(t *testing.T) { } func TestTelemetryDisabled(t *testing.T) { - test := setupTelemetryTest(t) - t.Setenv("E2ENGINE_TELEMETRY_DISABLED", "1") + test := setupTelemetryTest(t, false) test.runSuccess(t, "get", "environments", "-o", "yaml") @@ -242,7 +253,7 @@ func TestTelemetryDisabled(t *testing.T) { } func TestTelemetryRegistrationFailureIsBestEffort(t *testing.T) { - test := setupTelemetryTest(t, "-registration-status", "500") + test := setupTelemetryTest(t, true, "-registration-status", "500") test.runSuccess(t, "get", "environments", "-o", "yaml") @@ -256,7 +267,7 @@ func TestTelemetryRegistrationFailureIsBestEffort(t *testing.T) { } func TestTelemetrySubmissionFailureIsBestEffortAndCredentialsAreReused(t *testing.T) { - test := setupTelemetryTest(t, "-events-status", "500") + test := setupTelemetryTest(t, true, "-events-status", "500") test.runSuccess(t, "get", "environments", "-o", "yaml") test.runSuccess(t, "get", "environments", "-o", "yaml") @@ -274,7 +285,7 @@ func TestTelemetrySubmissionFailureIsBestEffortAndCredentialsAreReused(t *testin } func TestTelemetryUnsupportedCommandDoesNotInitialize(t *testing.T) { - test := setupTelemetryTest(t) + test := setupTelemetryTest(t, true) test.runSuccess(t, "version") diff --git a/cli/tests/transport_kind_test.go b/cli/tests/transport_kind_test.go index 724a85e..4ef948f 100644 --- a/cli/tests/transport_kind_test.go +++ b/cli/tests/transport_kind_test.go @@ -172,6 +172,7 @@ func TestTransportKind(t *testing.T) { t.Setenv("E2ENGINE_LOGGER_SINKS_0_LEVEL", "-4") // TODO: "debug" string should be acceptable t.Setenv("E2ENGINE_LOGGER_SINKS_0_PATH", path.Join(tempDir, "e2engine.log")) t.Setenv("E2ENGINE_LOGGER_SINKS_0_FORMAT", "text") + t.Setenv("E2ENGINE_LOGGER_SINKS_0_TIMESTAMP_FORMAT", "rfc3339nano") t.Setenv("E2ENGINE_LOGGER_SINKS_0_QUEUE_SIZE", "100") t.Setenv("E2ENGINE_LOGGER_SINKS_0_BUFFER_SIZE", "1024") t.Setenv("E2ENGINE_LOGGER_SINKS_0_FLUSH_INTERVAL", "10ms") @@ -344,19 +345,25 @@ func readRunnerPid(t *testing.T, logPath string) (int, bool) { continue } - const prefix = `pid="` + const prefix = `pid=` start := strings.Index(line, prefix) if start == -1 { continue } start += len(prefix) - end := strings.IndexByte(line[start:], '"') + value := strings.TrimPrefix(line[start:], `"`) + end := strings.IndexFunc(value, func(r rune) bool { + return r < '0' || r > '9' + }) if end == -1 { + end = len(value) + } + if end == 0 { continue } - pid, err := strconv.Atoi(line[start : start+end]) + pid, err := strconv.Atoi(value[:end]) if err != nil { t.Fatalf("Failed to parse runner PID: %v", err) } @@ -371,6 +378,27 @@ func readRunnerPid(t *testing.T, logPath string) (int, bool) { return 0, false } +func TestReadRunnerPid(t *testing.T) { + for _, test := range []struct { + name string + line string + }{ + {name: "numeric field", line: `2026-11-17 DEBUG Started internal-runner, pid=1234`}, + {name: "quoted field", line: `2026-11-17 DEBUG Started internal-runner, pid="1234"`}, + } { + t.Run(test.name, func(t *testing.T) { + logPath := path.Join(t.TempDir(), "e2engine.log") + if err := os.WriteFile(logPath, []byte(test.line+"\n"), 0o600); err != nil { + t.Fatal(err) + } + pid, ok := readRunnerPid(t, logPath) + if !ok || pid != 1234 { + t.Fatalf("readRunnerPid() = (%d, %t), want (1234, true)", pid, ok) + } + }) + } +} + func TestDirectTransportWaitsForExecution(t *testing.T) { ctx, cancel := context.WithTimeout( context.Background(), diff --git a/cli/tests/validate_environment_test.go b/cli/tests/validate_environment_test.go index 00c2e08..ca1d10e 100644 --- a/cli/tests/validate_environment_test.go +++ b/cli/tests/validate_environment_test.go @@ -25,43 +25,43 @@ func TestValidateEnvironment(t *testing.T) { expectError: true, }, { - name: "invalid-resource-id", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "invalid-resource-id", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: ID, " + "validation: value must contain exactly 64 lowercase alphanumeric characters", expectError: true, }, { - name: "resource-name-too-short", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "resource-name-too-short", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Name, " + "validation: rule constraint violated, " + "rule.name: min, rule.param.name: length, rule.param.value: 3", expectError: true, }, { - name: "resource-name-too-long", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "resource-name-too-long", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Name, " + "validation: rule constraint violated, " + "rule.name: max, rule.param.name: length, rule.param.value: 200", expectError: true, }, { - name: "invalid-resource-version", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "invalid-resource-version", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Version, " + "validation: rule constraint violated, rule.name: semver", expectError: true, }, { - name: "resource-description-too-short", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "resource-description-too-short", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Description, " + "validation: rule constraint violated, " + "rule.name: min, rule.param.name: length, rule.param.value: 3", @@ -92,60 +92,60 @@ func TestValidateEnvironment(t *testing.T) { expectError: true, }, { - name: "service-id-too-short", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "service-id-too-short", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Spec.Services[0].ID, " + "validation: rule constraint violated, " + "rule.name: min, rule.param.name: length, rule.param.value: 3", expectError: true, }, { - name: "service-id-too-long", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "service-id-too-long", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Spec.Services[0].ID, " + "validation: rule constraint violated, " + "rule.name: max, rule.param.name: length, rule.param.value: 200", expectError: true, }, { - name: "invalid-service-kind", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "invalid-service-kind", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Spec.Services[0].Kind, " + "validation: rule constraint violated, " + "rule.name: oneof, rule.param.name: allowed, rule.param.value: http,grpc", expectError: true, }, { - name: "invalid-service-mode", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "invalid-service-mode", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Spec.Services[0].Mode, " + "validation: rule constraint violated, " + "rule.name: oneof, rule.param.name: allowed, rule.param.value: real,mocked", expectError: true, }, { - name: "invalid-service-port", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "invalid-service-port", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "validation: line 10: cannot unmarshal !!str `not-a-port` into int", expectError: true, }, { - name: "invalid-service-target", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "invalid-service-target", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Spec.Services[0].Target, " + "validation: target must be a valid HTTP URL", expectError: true, }, { - name: "invalid-grpc-target", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "invalid-grpc-target", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Spec.Services[0].Proto, " + "validation: proto spec is required for GRPC service", expectError: true, @@ -159,70 +159,70 @@ func TestValidateEnvironment(t *testing.T) { expectError: true, }, { - name: "http-with-proto", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "http-with-proto", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Spec.Services[0].Proto, " + "validation: proto spec is not allowed for HTTP service", expectError: true, }, { - name: "grpc-without-proto", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "grpc-without-proto", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Spec.Services[0].Proto, " + "validation: proto spec is required for GRPC service", expectError: true, }, { - name: "grpc-external-empty-service", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "grpc-external-empty-service", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Spec.Services[0].Proto.External.Service, " + "validation: rule constraint violated, " + "rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { - name: "grpc-internal-empty-package", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "grpc-internal-empty-package", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Spec.Services[0].Proto.Internal.Package, " + "validation: rule constraint violated, " + "rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { - name: "grpc-internal-empty-service", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "grpc-internal-empty-service", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Spec.Services[0].Proto.Internal.Service, " + "validation: rule constraint violated, " + "rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { - name: "grpc-internal-empty-method-name", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "grpc-internal-empty-method-name", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Spec.Services[0].Proto.Internal.Methods[0].Name, " + "validation: rule constraint violated, " + "rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { - name: "grpc-internal-empty-field-name", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "grpc-internal-empty-field-name", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Spec.Services[0].Proto.Internal.Methods[0].Request.Fields[0].Name, " + "validation: rule constraint violated, " + "rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { - name: "grpc-internal-invalid-field-type", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "grpc-internal-invalid-field-type", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Spec.Services[0].Proto.Internal.Methods[0].Request.Fields[0].Type, " + "validation: rule constraint violated, " + "rule.name: oneof, rule.param.name: allowed, " + @@ -230,25 +230,25 @@ func TestValidateEnvironment(t *testing.T) { expectError: true, }, { - name: "mocked-without-fixtures", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "mocked-without-fixtures", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Spec.Services[0].Mode, Spec.Services[0].Fixtures, " + "validation: mocked service must contain at least one fixture", expectError: true, }, { - name: "mocked-with-target", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "mocked-with-target", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Spec.Services[0].Mode, Spec.Services[0].Target, " + "validation: target is not allowed for mocked service", expectError: true, }, { - name: "real-http-without-target", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "real-http-without-target", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Spec.Services[0].Target, " + "validation: target is required for real service", expectError: true, @@ -310,9 +310,9 @@ func TestValidateEnvironment(t *testing.T) { expectError: true, }, { - name: "http-fixture-invalid-method", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "http-fixture-invalid-method", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Spec.Services[0].Fixtures[0].When.HTTP.Method, " + "validation: rule constraint violated, " + "rule.name: oneof, rule.param.name: allowed, " + @@ -320,44 +320,44 @@ func TestValidateEnvironment(t *testing.T) { expectError: true, }, { - name: "http-fixture-empty-path", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "http-fixture-empty-path", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Spec.Services[0].Fixtures[0].When.HTTP.Path, " + "validation: rule constraint violated, " + "rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { - name: "http-fixture-status-too-low", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "http-fixture-status-too-low", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Spec.Services[0].Fixtures[0].Then.HTTP.StatusCode, " + "validation: rule constraint violated, " + "rule.name: min, rule.param.name: value, rule.param.value: 100", expectError: true, }, { - name: "http-fixture-status-too-high", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "http-fixture-status-too-high", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Spec.Services[0].Fixtures[0].Then.HTTP.StatusCode, " + "validation: rule constraint violated, " + "rule.name: min, rule.param.name: value, rule.param.value: 100", expectError: true, }, { - name: "http-fixture-invalid-request-json", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "http-fixture-invalid-request-json", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Spec.Services[0].Fixtures[0].When.HTTP.BodyJSON, " + "validation: value must contain valid JSON", expectError: true, }, { - name: "http-fixture-invalid-response-json", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "http-fixture-invalid-response-json", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Spec.Services[0].Fixtures[0].Then.HTTP.BodyJSON, " + "validation: value must contain valid JSON", expectError: true, @@ -411,17 +411,17 @@ func TestValidateEnvironment(t *testing.T) { expectError: true, }, { - name: "grpc-fixture-empty-method", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "grpc-fixture-empty-method", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Spec.Services[0].Fixtures[0].When.GRPC.Method, " + "validation: rule constraint violated, rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { - name: "grpc-fixture-invalid-status", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "grpc-fixture-invalid-status", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: Spec.Services[0].Fixtures[0].Then.GRPC.Status, " + "validation: rule constraint violated, " + "rule.name: oneof, rule.param.name: allowed, " + @@ -577,9 +577,9 @@ func TestValidateEnvironment_JSON(t *testing.T) { expectError bool }{ { - name: "invalid-service-port", - stdout: "", - stderr: "invalid spec, spec.kind: environment, " + + name: "invalid-service-port", + stdout: "", + stderr: "invalid spec, spec.kind: environment, " + "fields: spec.services.0.e2engine_port, " + "validation: json: cannot unmarshal string into " + "Go struct field Environment.spec.services.0.e2engine_port of type int", @@ -628,4 +628,4 @@ func TestValidateEnvironment_JSON(t *testing.T) { } }) } -} \ No newline at end of file +} diff --git a/cli/tests/validate_test_test.go b/cli/tests/validate_test_test.go index 459956a..c0f9668 100644 --- a/cli/tests/validate_test_test.go +++ b/cli/tests/validate_test_test.go @@ -25,67 +25,67 @@ func TestValidateTest(t *testing.T) { expectError: true, }, { - name: "request-missing", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "request-missing", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Request.HTTP, Spec.Request.GRPC, " + "validation: request must contain exactly one of http or grpc", expectError: true, }, { - name: "request-http-and-grpc", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "request-http-and-grpc", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Request.HTTP, Spec.Request.GRPC, " + "validation: request must contain exactly one of http or grpc", expectError: true, }, { - name: "expect-missing", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "expect-missing", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Expect.HTTP, Spec.Expect.GRPC, " + "validation: expect must contain exactly one of http or grpc", expectError: true, }, { - name: "expect-http-and-grpc", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "expect-http-and-grpc", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Expect.HTTP, Spec.Expect.GRPC, " + "validation: expect must contain exactly one of http or grpc", expectError: true, }, { - name: "request-expect-protocol-mismatch", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "request-expect-protocol-mismatch", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Request.HTTP, Spec.Expect.HTTP, " + "validation: request and expect protocols must match", expectError: true, }, { - name: "empty-tag", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "empty-tag", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Tags[0], " + "validation: rule constraint violated, " + "rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { - name: "tag-too-long", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "tag-too-long", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Tags[0], " + "validation: rule constraint violated, " + "rule.name: max, rule.param.name: length, rule.param.value: 200", expectError: true, }, { - name: "http-request-invalid-method", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "http-request-invalid-method", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Request.HTTP.Method, " + "validation: rule constraint violated, " + "rule.name: oneof, rule.param.name: allowed, " + @@ -93,101 +93,101 @@ func TestValidateTest(t *testing.T) { expectError: true, }, { - name: "http-request-empty-url", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "http-request-empty-url", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Request.HTTP.URL, " + "validation: target must be a valid HTTP URL", expectError: true, }, { - name: "http-request-invalid-url", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "http-request-invalid-url", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Request.HTTP.URL, " + "validation: target must be a valid HTTP URL", expectError: true, }, { - name: "http-request-invalid-scheme", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "http-request-invalid-scheme", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Request.HTTP.URL, " + "validation: target URL scheme must be http or https", expectError: true, }, { - name: "http-request-no-host", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "http-request-no-host", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Request.HTTP.URL, " + "validation: target URL host must not be empty", expectError: true, }, { - name: "http-request-invalid-json", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "http-request-invalid-json", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Request.HTTP.BodyJSON, " + "validation: value must contain valid JSON", expectError: true, }, { - name: "http-expect-status-too-low", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "http-expect-status-too-low", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Expect.HTTP.StatusCode, " + "validation: rule constraint violated, " + "rule.name: min, rule.param.name: value, rule.param.value: 100", expectError: true, }, { - name: "http-expect-status-too-high", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "http-expect-status-too-high", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Expect.HTTP.StatusCode, " + "validation: rule constraint violated, " + "rule.name: max, rule.param.name: value, rule.param.value: 599", expectError: true, }, { - name: "http-expect-invalid-json", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "http-expect-invalid-json", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Expect.HTTP.BodyJSON, " + "validation: value must contain valid JSON", expectError: true, }, { - name: "grpc-request-invalid-target", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "grpc-request-invalid-target", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Request.GRPC.Target, " + "validation: network address must be in host:port form", expectError: true, }, { - name: "grpc-request-empty-service", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "grpc-request-empty-service", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Request.GRPC.Service, " + "validation: rule constraint violated, " + "rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { - name: "grpc-request-empty-method", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "grpc-request-empty-method", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Request.GRPC.Method, " + "validation: rule constraint violated, " + "rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { - name: "grpc-expect-empty-status", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "grpc-expect-empty-status", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Expect.GRPC.Status, " + "validation: rule constraint violated, " + "rule.name: oneof, rule.param.name: allowed, " + @@ -197,52 +197,52 @@ func TestValidateTest(t *testing.T) { expectError: true, }, { - name: "call-no-protocol", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "call-no-protocol", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Expect.Calls[0], " + "validation: call expectation must contain exactly one of http or grpc", expectError: true, }, { - name: "call-http-and-grpc", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "call-http-and-grpc", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Expect.Calls[0], " + "validation: call expectation must contain exactly one of http or grpc", expectError: true, }, { - name: "call-service-id-too-short", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "call-service-id-too-short", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Expect.Calls[0].ServiceID, " + "validation: rule constraint violated, " + "rule.name: min, rule.param.name: length, rule.param.value: 3", expectError: true, }, { - name: "call-service-id-too-long", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "call-service-id-too-long", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Expect.Calls[0].ServiceID, " + "validation: rule constraint violated, " + "rule.name: max, rule.param.name: length, rule.param.value: 200", expectError: true, }, { - name: "call-negative-count", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "call-negative-count", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Expect.Calls[0].Count, " + "validation: rule constraint violated, " + "rule.name: min, rule.param.name: value, rule.param.value: 0", expectError: true, }, { - name: "call-http-invalid-method", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "call-http-invalid-method", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Expect.Calls[0].HTTP.Method, " + "validation: rule constraint violated, " + "rule.name: oneof, rule.param.name: allowed, " + @@ -250,35 +250,35 @@ func TestValidateTest(t *testing.T) { expectError: true, }, { - name: "call-http-empty-path", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "call-http-empty-path", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Expect.Calls[0].HTTP.Path, " + "validation: rule constraint violated, " + "rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { - name: "call-http-invalid-json", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "call-http-invalid-json", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Expect.Calls[0].HTTP.BodyJSON, " + "validation: value must contain valid JSON", expectError: true, }, { - name: "call-grpc-empty-service", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "call-grpc-empty-service", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Expect.Calls[0].GRPC.Service, " + "validation: rule constraint violated, " + "rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { - name: "call-grpc-empty-method", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "call-grpc-empty-method", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Expect.Calls[0].GRPC.Method, " + "validation: rule constraint violated, " + "rule.name: min, rule.param.name: length, rule.param.value: 1", @@ -376,9 +376,9 @@ func TestValidateTest(t *testing.T) { expectError: false, }, { - name: "grpc-expect-invalid-status", - stdout: "", - stderr: "invalid spec, spec.kind: test, " + + name: "grpc-expect-invalid-status", + stdout: "", + stderr: "invalid spec, spec.kind: test, " + "fields: Spec.Expect.GRPC.Status, " + "validation: rule constraint violated, " + "rule.name: oneof, rule.param.name: allowed, " + diff --git a/cli/tests/validate_testsuite_test.go b/cli/tests/validate_testsuite_test.go index 7a625c2..e564367 100644 --- a/cli/tests/validate_testsuite_test.go +++ b/cli/tests/validate_testsuite_test.go @@ -24,60 +24,60 @@ func TestValidateTestSuite(t *testing.T) { expectError: true, }, { - name: "no-selectors", - stdout: "", - stderr: "invalid spec, spec.kind: testsuite, " + + name: "no-selectors", + stdout: "", + stderr: "invalid spec, spec.kind: testsuite, " + "fields: Spec.Selectors.IDs, Spec.Selectors.Names, Spec.Selectors.Tags, " + "validation: test selectors spec must contain at least one of ids, names, or tags", expectError: true, }, { - name: "empty-id", - stdout: "", - stderr: "invalid spec, spec.kind: testsuite, " + + name: "empty-id", + stdout: "", + stderr: "invalid spec, spec.kind: testsuite, " + "fields: Spec.Selectors.IDs[0], " + "validation: value must contain exactly 64 lowercase alphanumeric characters", expectError: true, }, { - name: "id-too-long", - stdout: "", - stderr: "invalid spec, spec.kind: testsuite, " + + name: "id-too-long", + stdout: "", + stderr: "invalid spec, spec.kind: testsuite, " + "fields: Spec.Selectors.IDs[0], " + "validation: value must contain exactly 64 lowercase alphanumeric characters", expectError: true, }, { - name: "empty-name", - stdout: "", - stderr: "invalid spec, spec.kind: testsuite, " + + name: "empty-name", + stdout: "", + stderr: "invalid spec, spec.kind: testsuite, " + "fields: Spec.Selectors.Names[0], " + "validation: rule constraint violated, " + "rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { - name: "name-too-long", - stdout: "", - stderr: "invalid spec, spec.kind: testsuite, " + + name: "name-too-long", + stdout: "", + stderr: "invalid spec, spec.kind: testsuite, " + "fields: Spec.Selectors.Names[0], " + "validation: rule constraint violated, " + "rule.name: max, rule.param.name: length, rule.param.value: 200", expectError: true, }, { - name: "empty-tag", - stdout: "", - stderr: "invalid spec, spec.kind: testsuite, " + + name: "empty-tag", + stdout: "", + stderr: "invalid spec, spec.kind: testsuite, " + "fields: Spec.Selectors.Tags[0], " + "validation: rule constraint violated, " + "rule.name: min, rule.param.name: length, rule.param.value: 1", expectError: true, }, { - name: "tag-too-long", - stdout: "", - stderr: "invalid spec, spec.kind: testsuite, " + + name: "tag-too-long", + stdout: "", + stderr: "invalid spec, spec.kind: testsuite, " + "fields: Spec.Selectors.Tags[0], " + "validation: rule constraint violated, " + "rule.name: max, rule.param.name: length, rule.param.value: 200", diff --git a/docker/harness/harness.go b/docker/harness/harness.go index 83940f8..59d0d66 100644 --- a/docker/harness/harness.go +++ b/docker/harness/harness.go @@ -3,6 +3,7 @@ package harness import ( "bytes" "context" + "os" "os/exec" "path/filepath" "regexp" @@ -14,21 +15,42 @@ import ( ) type Harness struct { - t *testing.T - configPath string - dataDir string - dataVolume string - network string + t *testing.T + configPath string + dataDir string + dataVolume string + network string + telemetryEnabled bool } -func New(t *testing.T, configPath, network string) *Harness { +// Option configures a test harness. +type Option func(*Harness) + +// WithTelemetryEnabled allows the container to initialize and send telemetry. +func WithTelemetryEnabled() Option { + return func(h *Harness) { + h.telemetryEnabled = true + } +} + +func New(t *testing.T, configPath, network string, options ...Option) *Harness { t.Helper() if configPath == "" { configPath = "../config/empty-config.yml" } + configData, err := os.ReadFile(configPath) + if err != nil { + t.Fatalf("read Docker config fixture %q: %v", configPath, err) + } + privateConfigPath := filepath.Join(t.TempDir(), filepath.Base(configPath)) + // #nosec G703 -- the destination is under t.TempDir and uses filepath.Base. + if errWrite := os.WriteFile(privateConfigPath, configData, 0o600); errWrite != nil { + t.Fatalf("create private Docker config fixture: %v", errWrite) + } + configPath = privateConfigPath - configPath, err := filepath.Abs(configPath) + configPath, err = filepath.Abs(configPath) if err != nil { t.Fatalf("Failed to resolve config path %q: %v", configPath, err) } @@ -121,13 +143,17 @@ func New(t *testing.T, configPath, network string) *Harness { } }) - return &Harness{ + h := &Harness{ t: t, configPath: configPath, dataDir: dataDir, dataVolume: dataVolume, network: network, } + for _, option := range options { + option(h) + } + return h } func (h *Harness) RunCommand( @@ -135,7 +161,20 @@ func (h *Harness) RunCommand( commandArgs ...string, ) (stdout, stderr string, err error) { h.t.Helper() + cmd := exec.CommandContext(ctx, "docker", h.commandArgs(commandArgs...)...) + + var stdoutBuf bytes.Buffer + var stderrBuf bytes.Buffer + + cmd.Stdout = &stdoutBuf + cmd.Stderr = &stderrBuf + + err = cmd.Run() + return stdoutBuf.String(), stderrBuf.String(), err +} + +func (h *Harness) commandArgs(commandArgs ...string) []string { containerConfigDir := "/config" containerConfigPath := containerConfigDir + "/" + filepath.Base(h.configPath) @@ -147,24 +186,17 @@ func (h *Harness) RunCommand( "-v", h.dataDir + ":/data", "-v", h.dataVolume + ":/testdata", "-e", "E2ENGINE_CONFIG_PATH=" + containerConfigPath, - "-e", "E2ENGINE_DATA_DIR=/testdata", + "-e", "E2ENGINE_DATA_DIR=/testdata/e2engine", "-e", "E2ENGINE_RUNNER_WORKER_REPORTER_DUMP_PAYLOAD=true", } - - args = append(args, "e2engine:local") + disabled := "1" + if h.telemetryEnabled { + disabled = "0" + args = append(args, "-e", "XDG_CONFIG_HOME=/testdata/config") + } + args = append(args, "-e", "E2ENGINE_TELEMETRY_DISABLED="+disabled, "e2engine:local") args = append(args, commandArgs...) - - cmd := exec.CommandContext(ctx, "docker", args...) - - var stdoutBuf bytes.Buffer - var stderrBuf bytes.Buffer - - cmd.Stdout = &stdoutBuf - cmd.Stderr = &stderrBuf - - err = cmd.Run() - - return stdoutBuf.String(), stderrBuf.String(), err + return args } func (h *Harness) ListEnvironments(ctx context.Context) []model.Environment { diff --git a/docker/harness/telemetry_test.go b/docker/harness/telemetry_test.go new file mode 100644 index 0000000..00b4943 --- /dev/null +++ b/docker/harness/telemetry_test.go @@ -0,0 +1,41 @@ +package harness + +import ( + "strings" + "testing" +) + +func TestTelemetryOption(t *testing.T) { + tests := []struct { + name string + option Option + wantEnv string + }{ + {name: "disabled by default", wantEnv: "E2ENGINE_TELEMETRY_DISABLED=1"}, + {name: "explicitly enabled", option: WithTelemetryEnabled(), wantEnv: "E2ENGINE_TELEMETRY_DISABLED=0"}, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + h := &Harness{ + configPath: "/tmp/config.yml", + dataDir: "/tmp/data", + dataVolume: "e2engine-test-data", + network: "e2engine-test-network", + } + if test.option != nil { + test.option(h) + } + args := h.commandArgs("version") + var telemetrySettings []string + for i := 0; i+1 < len(args); i++ { + if args[i] == "-e" && strings.HasPrefix(args[i+1], "E2ENGINE_TELEMETRY_DISABLED=") { + telemetrySettings = append(telemetrySettings, args[i+1]) + } + } + if len(telemetrySettings) != 1 || telemetrySettings[0] != test.wantEnv { + t.Fatalf("container telemetry settings = %v, want [%s]", telemetrySettings, test.wantEnv) + } + }) + } +} diff --git a/docker/tests/telemetry_test.go b/docker/tests/telemetry_test.go new file mode 100644 index 0000000..df8e63d --- /dev/null +++ b/docker/tests/telemetry_test.go @@ -0,0 +1,110 @@ +package tests + +import ( + "bufio" + "context" + "encoding/json" + "os" + "os/exec" + "path/filepath" + "strings" + "testing" + "time" + + "github.com/e2engine/tests/docker/harness" +) + +const dockerTelemetryToken = "et_AAAAAAAAAAAAAAAAAAAAAA.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" + +type telemetryRecord struct { + Method string `json:"method"` + Path string `json:"path"` + Authorization string `json:"authorization"` + ContentType string `json:"content_type"` + Body json.RawMessage `json:"body"` +} + +type telemetryEvent struct { + ID string `json:"id"` + SchemaVersion int `json:"schema_version"` + SessionID string `json:"session_id"` + Timestamp time.Time `json:"timestamp"` + Source string `json:"source"` + Operation string `json:"operation"` + Outcome string `json:"outcome"` + Version string `json:"version"` +} + +func TestTelemetryRegistrationSubmissionAndReuse(t *testing.T) { + ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) + defer cancel() + + h := harness.New(t, "", "e2engine-telemetry-network", harness.WithTelemetryEnabled()) + service := h.StartService(ctx, "telemetry-http", "-address", ":9000", "-records", "/requests.jsonl") + t.Cleanup(func() { service.Stop(t) }) + + for range 2 { + stdout, stderr, err := h.RunCommand(ctx, "get", "environments", "-o", "yaml") + if err != nil { + t.Fatalf("list environments: %v\nstdout: %s\nstderr: %s", err, stdout, stderr) + } + } + + recordsPath := filepath.Join(t.TempDir(), "requests.jsonl") + if output, err := exec.CommandContext(ctx, "docker", "cp", "telemetry-http:/requests.jsonl", recordsPath).CombinedOutput(); err != nil { + t.Fatalf("copy telemetry requests from mock container: %v\noutput: %s", err, output) + } + file, err := os.Open(recordsPath) + if err != nil { + t.Fatal(err) + } + defer file.Close() + + var records []telemetryRecord + scanner := bufio.NewScanner(file) + for scanner.Scan() { + var record telemetryRecord + if err := json.Unmarshal(scanner.Bytes(), &record); err != nil { + t.Fatalf("decode telemetry request record: %v", err) + } + records = append(records, record) + } + if err := scanner.Err(); err != nil { + t.Fatalf("read telemetry request records: %v", err) + } + if len(records) != 3 { + t.Fatalf("telemetry request count = %d, want one registration and two events", len(records)) + } + if records[0].Method != "POST" || records[0].Path != "/v1/installations" || records[0].Authorization != "" { + t.Fatalf("registration request = %#v", records[0]) + } + + events := make([]telemetryEvent, 0, len(records)-1) + for _, record := range records[1:] { + if record.Method != "POST" || record.Path != "/v1/events" || + record.Authorization != "Bearer "+dockerTelemetryToken || + !strings.HasPrefix(record.ContentType, "application/json") { + t.Fatalf("event request has unexpected method, path, authorization or content type: %#v", record) + } + var request struct { + Events []telemetryEvent `json:"events"` + } + if err := json.Unmarshal(record.Body, &request); err != nil { + t.Fatalf("decode event request: %v", err) + } + if len(request.Events) != 1 { + t.Fatalf("events in request = %d, want 1", len(request.Events)) + } + event := request.Events[0] + if event.ID == "" || event.SessionID == "" || event.Timestamp.IsZero() || + event.SchemaVersion != 1 || event.Source != "cli" || + event.Operation != "environment.list" || event.Outcome != "success" || + event.Version != "v0.0.0-e2e" { + t.Fatalf("unexpected telemetry event: %#v", event) + } + events = append(events, event) + } + if events[0].ID == events[1].ID || events[0].SessionID == events[1].SessionID { + t.Fatalf("separate CLI invocations reused event or session ID: %#v", events) + } +} diff --git a/go.mod b/go.mod index 4d45c6e..b1072c3 100644 --- a/go.mod +++ b/go.mod @@ -3,21 +3,29 @@ module github.com/e2engine/tests go 1.27 require ( - github.com/e2engine/core v0.3.0 - 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 + github.com/e2engine/core v0.3.1 + github.com/e2engine/instrumentation-go/grpc v0.2.1 + github.com/e2engine/instrumentation-go/http v0.2.2 + github.com/modelcontextprotocol/go-sdk v1.8.0 + google.golang.org/grpc v1.85.0 google.golang.org/protobuf v1.36.12 gopkg.in/yaml.v3 v3.0.1 ) require ( - github.com/e2engine/instrumentation-go v0.1.1 // indirect + github.com/e2engine/instrumentation-go v0.2.3 // indirect + github.com/google/jsonschema-go v0.4.3 // indirect + github.com/segmentio/asm v1.1.3 // indirect + github.com/segmentio/encoding v0.5.4 // indirect 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.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 + github.com/ygrebnov/model v0.8.1 // indirect + github.com/yosida95/uritemplate/v3 v3.0.2 // indirect + golang.org/x/net v0.62.0 // indirect + golang.org/x/oauth2 v0.36.0 // indirect + golang.org/x/sync v0.25.0 // indirect + golang.org/x/sys v0.50.0 // indirect + golang.org/x/text v0.44.0 // indirect + golang.org/x/time v0.15.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20261110000943-09e21b237f2c // indirect ) diff --git a/go.sum b/go.sum index da79171..00e488b 100644 --- a/go.sum +++ b/go.sum @@ -1,33 +1,53 @@ -github.com/e2engine/core v0.3.0 h1:hx7THwTfc9wYtFOW7sE9kfLNFOG8ff/2tD+lD4pvzmM= -github.com/e2engine/core v0.3.0/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= -github.com/e2engine/instrumentation-go/grpc v0.1.1/go.mod h1:l74IeAGD1lOKbrc/rqQJ3qHvrQF1rvefC50v8unCo1U= -github.com/e2engine/instrumentation-go/http v0.1.1 h1:Xu+yRVgv6jsq7eBLzeOeccwM0dyNz2ga1ybaXNUFhTk= -github.com/e2engine/instrumentation-go/http v0.1.1/go.mod h1:dFgPXV8kq17HHTecABNLaAio8td8LtdiNj9cZYS6Kng= +github.com/e2engine/core v0.3.1 h1:18Jhe5KlMCzw/wJRp7yybEKmzd5IALHhuOyqhl72Vb4= +github.com/e2engine/core v0.3.1/go.mod h1:QcayHlh4J9gTOJGJrs5Ca4NTZ5MLaOA+EvswFdjq+W8= +github.com/e2engine/instrumentation-go v0.2.3 h1:Al7SoAIiMHiJ4zxj71JYiFCE9MKgpXFGHxlZCHmbe+0= +github.com/e2engine/instrumentation-go v0.2.3/go.mod h1:DyUxzrRZBCzOk+toAmxex+Xn09fYhutsCRUfNUgS8kQ= +github.com/e2engine/instrumentation-go/grpc v0.2.1 h1:GB+ZDt/36/gtI1MjVD9agT/RdL9tDBVocAaZUD/rBGU= +github.com/e2engine/instrumentation-go/grpc v0.2.1/go.mod h1:iEvQmwSHqSijbqIPpSKI0f2ui/OjIC3pZizgbrhszVY= +github.com/e2engine/instrumentation-go/http v0.2.2 h1:/C0lWgchf/E+gWFdLjPui85w2X3wc8sRNqxqqwdBYGg= +github.com/e2engine/instrumentation-go/http v0.2.2/go.mod h1:F2Tafqfg3h0LDMFlzjkLHpiirF1Kzcx5zmH4OgB8vkk= +github.com/golang-jwt/jwt/v5 v5.3.1 h1:kYf81DTWFe7t+1VvL7eS+jKFVWaUnK9cB1qbwn63YCY= +github.com/golang-jwt/jwt/v5 v5.3.1/go.mod h1:fxCRLWMO43lRc8nhHWY6LGqRcf+1gQWArsqaEUEa5bE= github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= +github.com/google/jsonschema-go v0.4.3 h1:/DBOLZTfDow7pe2GmaJNhltueGTtDKICi8V8p+DQPd0= +github.com/google/jsonschema-go v0.4.3/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE= +github.com/modelcontextprotocol/go-sdk v1.8.0 h1:KIvahhYqwtbeniWVPs3TcXEA7b8jEtwfBpOTAI+Urx4= +github.com/modelcontextprotocol/go-sdk v1.8.0/go.mod h1:dL7u98E/zjJTGzEq+j30jQ8K2k1mb6LeAH4inEcSGts= +github.com/segmentio/asm v1.1.3 h1:WM03sfUOENvvKexOLp+pCqgb/WDjsi7EK8gIsICtzhc= +github.com/segmentio/asm v1.1.3/go.mod h1:Ld3L4ZXGNcSLRg4JBsZ3//1+f/TjYl0Mzen/DQy1EJg= +github.com/segmentio/encoding v0.5.4 h1:OW1VRern8Nw6ITAtwSZ7Idrl3MXCFwXHPgqESYfvNt0= +github.com/segmentio/encoding v0.5.4/go.mod h1:HS1ZKa3kSN32ZHVZ7ZLPLXWvOVIiZtyJnO1gPH1sKt0= github.com/ygrebnov/errorc v0.6.1 h1:ICww1JOesR0HyE3cVWMr0SBmB8RV1XSmGwB5yVP1SqE= github.com/ygrebnov/errorc v0.6.1/go.mod h1:akitMzADmnm0i1X5fSJfBqiTqCzckka9sgukTRQN5ns= 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.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= +github.com/ygrebnov/model v0.8.1 h1:KvnS97b/q3Z1GKSHSDYlfHoL3bNDR+ZT9Kf4yc1WnIE= +github.com/ygrebnov/model v0.8.1/go.mod h1:WEMMqdGYF45Kfce0pAe0poiF9hu+PONRSHd2L9li3tw= +github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4= +github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4= +golang.org/x/net v0.62.0 h1:18ELalfM5+XNRwzM2nYqXsZQ9ByS1uhj2O/U7+5jqRY= +golang.org/x/net v0.62.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI= +golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs= +golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q= +golang.org/x/sync v0.25.0 h1:dJnifr0nMV8/SBnBvdo4eSGGnrc3O4FFx6IqvtLcmRs= +golang.org/x/sync v0.25.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0= +golang.org/x/sys v0.50.0 h1:dkKZEFTEKaLr1sjhs0WiKqoi8Jj5nHbS3Njmx1UoMJs= +golang.org/x/sys v0.50.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og= +golang.org/x/text v0.44.0 h1:YItdp/mQNGnsmrgpcdA5yQ3bnRxCfo/Tj/iByGW9GGo= +golang.org/x/text v0.44.0/go.mod h1:S4FR1waQ9LbjQTls97SyRjDaUUVkaM+cXwwuG/G+MwY= +golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U= +golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno= +golang.org/x/tools v0.52.0 h1:ryxg4U63oaUYk7uOLTF37n43f4qgtGvqV4Ioit1BaEs= +golang.org/x/tools v0.52.0/go.mod h1:ItcP5UNaVGG+Yc4eIYmaFLNJ4soEopkx5Y2d4lcEurs= 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-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/genproto/googleapis/rpc v0.0.0-20261110000943-09e21b237f2c h1:XXChExL+Tm7Ubp0x0VXUEncPLHrkXIgoVWqnxmKNbAA= +google.golang.org/genproto/googleapis/rpc v0.0.0-20261110000943-09e21b237f2c/go.mod h1:OaIUM3+LpYcK2GXM4FTmhWoIq371Owdr+Cc7/BsYHHc= +google.golang.org/grpc v1.85.0 h1:BPBCfuVRQ1qvBhKDOq9uvQllMvO59rKsYhXpp7Dd8vw= +google.golang.org/grpc v1.85.0/go.mod h1:0rQrOD58yjal/0EaVbGBANindixsCZNQPDV3VKtaKuQ= google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc= google.golang.org/protobuf v1.36.12/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= diff --git a/mcp/bin/.gitkeep b/mcp/bin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/mcp/harness/harness.go b/mcp/harness/harness.go new file mode 100644 index 0000000..b5ec211 --- /dev/null +++ b/mcp/harness/harness.go @@ -0,0 +1,120 @@ +package harness + +import ( + "bytes" + "context" + "os" + "os/exec" + "path/filepath" + "sync" + "testing" + "time" + + "github.com/modelcontextprotocol/go-sdk/mcp" +) + +const testTimeout = 60 * time.Second + +type Options struct { + DataDir string + ProfileDir string + TelemetryEnabled bool +} + +type Harness struct { + Session *mcp.ClientSession + Context context.Context + DataDir string + ProfileDir string + stderr lockedBuffer + cancel context.CancelFunc +} + +type lockedBuffer struct { + mu sync.Mutex + bytes.Buffer +} + +func (b *lockedBuffer) Write(data []byte) (int, error) { + b.mu.Lock() + defer b.mu.Unlock() + return b.Buffer.Write(data) +} + +func (b *lockedBuffer) String() string { + b.mu.Lock() + defer b.mu.Unlock() + return b.Buffer.String() +} + +func New(t *testing.T, options Options) *Harness { + t.Helper() + + if options.DataDir == "" { + options.DataDir = t.TempDir() + } + if options.ProfileDir == "" { + options.ProfileDir = t.TempDir() + } + configPath := filepath.Join(options.ProfileDir, "mcp-config.yml") + if err := os.WriteFile(configPath, []byte("{}\n"), 0o600); err != nil { + t.Fatalf("create private MCP config: %v", err) + } + + ctx, cancel := context.WithTimeout(context.Background(), testTimeout) + path, err := filepath.Abs("../bin/mcp") + if err != nil { + cancel() + t.Fatal(err) + } + h := &Harness{ + Context: ctx, + DataDir: options.DataDir, + ProfileDir: options.ProfileDir, + cancel: cancel, + } + cmd := exec.CommandContext(ctx, path) + disabled := "1" + if options.TelemetryEnabled { + disabled = "0" + } + configDir := filepath.Join(options.ProfileDir, "config") + cmd.Env = append(os.Environ(), + "HOME="+options.ProfileDir, + "XDG_CONFIG_HOME="+configDir, + "APPDATA="+configDir, + "E2ENGINE_DATA_DIR="+options.DataDir, + "E2ENGINE_MCP_CONFIG_PATH="+configPath, + "E2ENGINE_MCP_TELEMETRY_DISABLED="+disabled, + "E2ENGINE_TELEMETRY_DISABLED="+disabled, + ) + cmd.Stderr = &h.stderr + client := mcp.NewClient(&mcp.Implementation{Name: "e2engine-tests", Version: "v0.0.0-e2e"}, nil) + h.Session, err = client.Connect(ctx, &mcp.CommandTransport{Command: cmd}, nil) + if err != nil { + cancel() + t.Fatalf("connect to MCP binary: %v\nstderr: %s", err, h.stderr.String()) + } + t.Cleanup(func() { + if err := h.Close(); err != nil { + t.Errorf("close MCP session: %v\nstderr: %s", err, h.stderr.String()) + } + }) + return h +} + +func (h *Harness) Close() error { + err := h.Session.Close() + h.cancel() + return err +} + +func (h *Harness) CallTool(name string, arguments map[string]any) (*mcp.CallToolResult, error) { + return h.Session.CallTool(h.Context, &mcp.CallToolParams{Name: name, Arguments: arguments}) +} + +func (h *Harness) ListTools() (*mcp.ListToolsResult, error) { + return h.Session.ListTools(h.Context, &mcp.ListToolsParams{}) +} + +func (h *Harness) Stderr() string { return h.stderr.String() } diff --git a/mcp/tests/telemetry_test.go b/mcp/tests/telemetry_test.go new file mode 100644 index 0000000..c81321e --- /dev/null +++ b/mcp/tests/telemetry_test.go @@ -0,0 +1,258 @@ +package tests + +import ( + "bufio" + "bytes" + "context" + "encoding/json" + "net/http" + "os" + "os/exec" + "path/filepath" + "runtime" + "strings" + "testing" + "time" + + "github.com/e2engine/tests/mcp/harness" +) + +const ( + telemetryAddress = "127.0.0.1:39093" + telemetryToken = "et_AAAAAAAAAAAAAAAAAAAAAA.AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" +) + +type telemetryRecord struct { + Method string `json:"method"` + Path string `json:"path"` + ContentType string `json:"content_type"` + Authorization string `json:"authorization"` + Body json.RawMessage `json:"body"` +} + +type telemetryEvent struct { + ID string `json:"id"` + SessionID string `json:"session_id"` + SchemaVersion int `json:"schema_version"` + Timestamp time.Time `json:"timestamp"` + Source string `json:"source"` + Operation string `json:"operation"` + Outcome string `json:"outcome"` + ErrorCategory string `json:"error_category"` + ErrorCode string `json:"error_code"` + OS string `json:"os"` + Arch string `json:"arch"` + Version string `json:"version"` +} + +type telemetryFixture struct { + options harness.Options + recordsPath string + installationPath string +} + +func startTelemetryFixture(t *testing.T, enabled bool, mockArgs ...string) telemetryFixture { + t.Helper() + profileDir := t.TempDir() + configDir := filepath.Join(profileDir, "config") + t.Setenv("HOME", profileDir) + t.Setenv("XDG_CONFIG_HOME", configDir) + t.Setenv("APPDATA", configDir) + userConfigDir, err := os.UserConfigDir() + if err != nil { + t.Fatalf("resolve isolated user config directory: %v", err) + } + installationPath := filepath.Join(userConfigDir, "e2engine", "installation.json") + recordsPath := filepath.Join(t.TempDir(), "requests.jsonl") + args := append([]string{"-address", telemetryAddress, "-records", recordsPath}, mockArgs...) + mockCtx, cancelMock := context.WithCancel(context.Background()) + cmd := exec.CommandContext(mockCtx, "../../services/bin/telemetry-http", args...) + var stderr bytes.Buffer + cmd.Stderr = &stderr + if err := cmd.Start(); err != nil { + cancelMock() + t.Fatalf("start telemetry HTTP mock: %v", err) + } + t.Cleanup(func() { + defer cancelMock() + if cmd.Process == nil { + return + } + if err := cmd.Process.Signal(os.Interrupt); err != nil { + _ = cmd.Process.Kill() + } + if err := cmd.Wait(); err != nil { + t.Errorf("telemetry HTTP mock exited: %v\nstderr: %s", err, stderr.String()) + } + }) + client := &http.Client{Timeout: 100 * time.Millisecond} + request, err := http.NewRequestWithContext(t.Context(), http.MethodGet, "http://"+telemetryAddress+"/health", nil) + if err != nil { + t.Fatalf("create telemetry health request: %v", err) + } + deadline := time.Now().Add(5 * time.Second) + for { + response, err := client.Do(request) + if err == nil { + _ = response.Body.Close() + if response.StatusCode == http.StatusOK { + break + } + } + if time.Now().After(deadline) { + t.Fatalf("telemetry HTTP mock did not become ready: %v\nstderr: %s", err, stderr.String()) + } + time.Sleep(25 * time.Millisecond) + } + return telemetryFixture{ + options: harness.Options{ + DataDir: t.TempDir(), ProfileDir: profileDir, TelemetryEnabled: enabled, + }, + recordsPath: recordsPath, installationPath: installationPath, + } +} + +func (f telemetryFixture) records(t *testing.T) []telemetryRecord { + t.Helper() + file, err := os.Open(f.recordsPath) + if err != nil { + t.Fatalf("open telemetry request records: %v", err) + } + defer file.Close() + var records []telemetryRecord + scanner := bufio.NewScanner(file) + for scanner.Scan() { + var record telemetryRecord + if err := json.Unmarshal(scanner.Bytes(), &record); err != nil { + t.Fatalf("decode telemetry request record: %v", err) + } + records = append(records, record) + } + if err := scanner.Err(); err != nil { + t.Fatalf("read telemetry request records: %v", err) + } + return records +} + +func eventFromRecord(t *testing.T, record telemetryRecord) telemetryEvent { + t.Helper() + if record.Method != "POST" || record.Path != "/v1/events" { + t.Fatalf("event request = %s %s", record.Method, record.Path) + } + if record.Authorization != "Bearer "+telemetryToken || !strings.HasPrefix(record.ContentType, "application/json") { + t.Fatalf("event request has unexpected authentication or content type: %#v", record) + } + var request struct { + Events []telemetryEvent `json:"events"` + } + if err := json.Unmarshal(record.Body, &request); err != nil { + t.Fatalf("decode telemetry events: %v", err) + } + if len(request.Events) != 1 { + t.Fatalf("events per request = %d, want 1", len(request.Events)) + } + return request.Events[0] +} + +func TestMCPTelemetryRegistrationAndReuse(t *testing.T) { + fixture := startTelemetryFixture(t, true) + first := harness.New(t, fixture.options) + callSuccess(t, first, "environment_list", nil) + callError(t, first, "environment_get", map[string]any{"ref": "missing-environment"}, "not found") + if err := first.Close(); err != nil { + t.Fatalf("close first MCP process: %v", err) + } + second := harness.New(t, fixture.options) + callSuccess(t, second, "environment_list", nil) + + records := fixture.records(t) + if len(records) != 4 { + t.Fatalf("telemetry requests = %d, want registration and three events: %#v", len(records), records) + } + if records[0].Method != "POST" || records[0].Path != "/v1/installations" || records[0].Authorization != "" { + t.Fatalf("registration request = %#v", records[0]) + } + data, err := os.ReadFile(fixture.installationPath) + if err != nil { + t.Fatalf("read shared installation credentials: %v", err) + } + var installation struct { + Version int `json:"version"` + ID string `json:"installation_id"` + Token string `json:"token"` + } + if err := json.Unmarshal(data, &installation); err != nil { + t.Fatalf("decode installation credentials: %v", err) + } + if installation.Version != 1 || installation.ID == "" || installation.Token != telemetryToken { + t.Fatalf("unexpected installation credentials: version=%d id=%q token matches=%v", installation.Version, installation.ID, installation.Token == telemetryToken) + } + if runtime.GOOS != "windows" { + if info, err := os.Stat(fixture.installationPath); err != nil || info.Mode().Perm() != 0o600 { + t.Fatalf("installation file permissions: info=%v err=%v", info, err) + } + } + events := make([]telemetryEvent, 0, len(records)-1) + for _, record := range records[1:] { + events = append(events, eventFromRecord(t, record)) + } + for i, event := range events { + if event.ID == "" || event.SessionID == "" || event.Timestamp.IsZero() || event.SchemaVersion != 1 || + event.Source != "mcp" || event.OS != runtime.GOOS || event.Arch != runtime.GOARCH || event.Version != "v0.0.0-e2e" { + t.Errorf("event %d has unexpected identity or runtime fields: %#v", i, event) + } + } + if events[0].Operation != "environment.list" || events[0].Outcome != "success" || + events[1].Operation != "environment.get" || events[1].Outcome != "error" || + events[1].ErrorCategory != "not_found" || events[1].ErrorCode != "resource_not_found" || + events[2].Operation != "environment.list" || events[2].Outcome != "success" { + t.Fatalf("unexpected telemetry outcomes: %#v", events) + } + if events[0].ID == events[1].ID || events[0].SessionID != events[1].SessionID || events[0].SessionID == events[2].SessionID { + t.Fatalf("MCP event/session identity mismatch: %#v", events) + } + if strings.Contains(string(records[2].Body), "missing-environment") { + t.Fatal("event payload contains requested resource reference") + } +} + +func TestMCPTelemetryDisabled(t *testing.T) { + fixture := startTelemetryFixture(t, false) + h := harness.New(t, fixture.options) + callSuccess(t, h, "environment_list", nil) + if records := fixture.records(t); len(records) != 0 { + t.Fatalf("disabled telemetry sent requests: %#v", records) + } + if _, err := os.Stat(fixture.installationPath); !os.IsNotExist(err) { + t.Fatalf("disabled telemetry created credentials: %v", err) + } +} + +func TestMCPTelemetryRegistrationFailureIsBestEffort(t *testing.T) { + fixture := startTelemetryFixture(t, true, "-registration-status", "500") + h := harness.New(t, fixture.options) + callSuccess(t, h, "environment_list", nil) + records := fixture.records(t) + if len(records) != 1 || records[0].Path != "/v1/installations" { + t.Fatalf("requests after failed registration = %#v", records) + } + if _, err := os.Stat(fixture.installationPath); !os.IsNotExist(err) { + t.Fatalf("failed registration created credentials: %v", err) + } +} + +func TestMCPTelemetrySubmissionFailureIsBestEffort(t *testing.T) { + fixture := startTelemetryFixture(t, true, "-events-status", "500") + h := harness.New(t, fixture.options) + for range 2 { + callSuccess(t, h, "environment_list", nil) + } + records := fixture.records(t) + if len(records) != 3 || records[0].Path != "/v1/installations" || + records[1].Path != "/v1/events" || records[2].Path != "/v1/events" { + t.Fatalf("requests after failed event sends = %#v", records) + } + if _, err := os.Stat(fixture.installationPath); err != nil { + t.Fatalf("failed event send lost credentials: %v", err) + } +} diff --git a/mcp/tests/tools_test.go b/mcp/tests/tools_test.go new file mode 100644 index 0000000..3b986a3 --- /dev/null +++ b/mcp/tests/tools_test.go @@ -0,0 +1,223 @@ +package tests + +import ( + "encoding/json" + "slices" + "strings" + "testing" + + "github.com/modelcontextprotocol/go-sdk/mcp" + + "github.com/e2engine/tests/mcp/harness" +) + +type resourceCase struct { + name string + listField string + createArgs map[string]any +} + +func resourceCases() []resourceCase { + return []resourceCase{ + { + name: "environment", listField: "environments", + createArgs: map[string]any{ + "name": "e2e-environment", "description": "MCP E2E environment", + "services": []any{map[string]any{ + "id": "e2e-http", "kind": "http", "mode": "real", + "e2engine_port": 8080, "target": "http://127.0.0.1:8080", + }}, + }, + }, + { + name: "test", listField: "tests", + createArgs: map[string]any{ + "name": "e2e-test", "tags": []string{"e2e"}, + "request": map[string]any{"http": map[string]any{"method": "GET", "url": "http://127.0.0.1:8080/health"}}, + "expect": map[string]any{"http": map[string]any{"status_code": 200}}, + }, + }, + { + name: "testsuite", listField: "test_suites", + createArgs: map[string]any{ + "name": "e2e-suite", "selectors": map[string]any{"tags": []string{"e2e"}}, + }, + }, + } +} + +func callSuccess(t *testing.T, h *harness.Harness, name string, args map[string]any) map[string]any { + t.Helper() + result, err := h.CallTool(name, args) + if err != nil { + t.Fatalf("%s transport error: %v\nstderr: %s", name, err, h.Stderr()) + } + if result.IsError { + content, _ := json.Marshal(result.Content) + t.Fatalf("%s returned tool error: %s\nstderr: %s", name, content, h.Stderr()) + } + data, err := json.Marshal(result.StructuredContent) + if err != nil { + t.Fatalf("marshal %s structured content: %v", name, err) + } + var value map[string]any + if err := json.Unmarshal(data, &value); err != nil { + t.Fatalf("decode %s structured content: %v", name, err) + } + if value == nil { + t.Fatalf("%s returned no structured content", name) + } + return value +} + +func callError(t *testing.T, h *harness.Harness, name string, args map[string]any, want string) { + t.Helper() + result, err := h.CallTool(name, args) + if err != nil { + t.Fatalf("%s transport error instead of tool error: %v\nstderr: %s", name, err, h.Stderr()) + } + if !result.IsError || len(result.Content) == 0 { + t.Fatalf("%s result = %#v, want a tool error with content", name, result) + } + for _, content := range result.Content { + if text, ok := content.(*mcp.TextContent); ok && strings.Contains(strings.ToLower(text.Text), want) { + return + } + } + content, _ := json.Marshal(result.Content) + t.Fatalf("%s error = %s, want text containing %q", name, content, want) +} + +func stringField(t *testing.T, value map[string]any, field string) string { + t.Helper() + got, ok := value[field].(string) + if !ok || got == "" { + t.Fatalf("%s = %#v, want nonempty string", field, value[field]) + } + return got +} + +func listContainsID(t *testing.T, value map[string]any, field, id string) bool { + t.Helper() + items, ok := value[field].([]any) + if !ok { + t.Fatalf("%s = %#v, want array", field, value[field]) + } + for _, item := range items { + object, ok := item.(map[string]any) + if !ok { + t.Fatalf("%s item = %#v, want object", field, item) + } + if object["id"] == id { + return true + } + } + return false +} + +func TestMCPTools(t *testing.T) { + h := harness.New(t, harness.Options{}) + tools, err := h.ListTools() + if err != nil { + t.Fatalf("ListTools: %v\nstderr: %s", err, h.Stderr()) + } + names := make([]string, 0, len(tools.Tools)) + for _, tool := range tools.Tools { + names = append(names, tool.Name) + } + slices.Sort(names) + resources := resourceCases() + want := make([]string, 0, len(resources)*4) + for _, resource := range resources { + for _, operation := range []string{"create", "delete", "get", "list"} { + want = append(want, resource.name+"_"+operation) + } + } + if !slices.Equal(names, want) { + t.Fatalf("MCP tools = %v, want %v", names, want) + } + + for _, resource := range resources { + t.Run(resource.name, func(t *testing.T) { + list := resource.name + "_list" + create := resource.name + "_create" + get := resource.name + "_get" + deleteTool := resource.name + "_delete" + + t.Run("list empty", func(t *testing.T) { + value := callSuccess(t, h, list, nil) + if items, ok := value[resource.listField].([]any); !ok || len(items) != 0 { + t.Fatalf("%s = %#v, want empty array", resource.listField, value[resource.listField]) + } + }) + t.Run("list invalid page size", func(t *testing.T) { + callError(t, h, list, map[string]any{"page_size": 101}, "invalid request parameters") + }) + + var id string + t.Run("create", func(t *testing.T) { + value := callSuccess(t, h, create, resource.createArgs) + id = stringField(t, value, "id") + if value["name"] != resource.createArgs["name"] { + t.Fatalf("created name = %#v, want %#v", value["name"], resource.createArgs["name"]) + } + stringField(t, value, "version") + }) + t.Run("create duplicate", func(t *testing.T) { + callError(t, h, create, resource.createArgs, "already exists") + }) + t.Run("get", func(t *testing.T) { + value := callSuccess(t, h, get, map[string]any{"ref": id}) + if value["id"] != id || value["name"] != resource.createArgs["name"] { + t.Fatalf("get result = %#v, want id %q and name %q", value, id, resource.createArgs["name"]) + } + }) + t.Run("get missing", func(t *testing.T) { + callError(t, h, get, map[string]any{"ref": "missing-resource"}, "not found") + }) + t.Run("list created", func(t *testing.T) { + value := callSuccess(t, h, list, nil) + if !listContainsID(t, value, resource.listField, id) { + t.Fatalf("%s did not contain created ID %q: %#v", list, id, value) + } + }) + t.Run("delete", func(t *testing.T) { + value := callSuccess(t, h, deleteTool, map[string]any{"ref": id}) + if value["id"] != id { + t.Fatalf("deleted ID = %#v, want %q", value["id"], id) + } + }) + t.Run("delete missing", func(t *testing.T) { + callError(t, h, deleteTool, map[string]any{"ref": id}, "not found") + }) + t.Run("list after delete", func(t *testing.T) { + value := callSuccess(t, h, list, nil) + if listContainsID(t, value, resource.listField, id) { + t.Fatalf("%s still contains deleted ID %q", list, id) + } + }) + }) + } +} + +func TestMCPPersistenceAcrossProcessRestart(t *testing.T) { + options := harness.Options{DataDir: t.TempDir(), ProfileDir: t.TempDir()} + first := harness.New(t, options) + name := "restart-environment" + created := callSuccess(t, first, "environment_create", map[string]any{ + "name": name, + "services": []any{map[string]any{ + "id": "e2e-http", "kind": "http", "mode": "real", + "e2engine_port": 8080, "target": "http://127.0.0.1:8080", + }}, + }) + id := stringField(t, created, "id") + if err := first.Close(); err != nil { + t.Fatalf("close first MCP process: %v", err) + } + second := harness.New(t, options) + loaded := callSuccess(t, second, "environment_get", map[string]any{"ref": id}) + if loaded["id"] != id || loaded["name"] != name { + t.Fatalf("loaded environment = %#v, want id %q, name %q", loaded, id, name) + } +} From 7633559834790bd956b161051c4fe21eeb158f22 Mon Sep 17 00:00:00 2001 From: Yaroslav Grebnov Date: Mon, 30 Nov 2026 18:38:43 +0100 Subject: [PATCH 4/6] Bump dependencies --- go.mod | 18 +++++++++--------- go.sum | 36 ++++++++++++++++++------------------ 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/go.mod b/go.mod index b1072c3..76da8ee 100644 --- a/go.mod +++ b/go.mod @@ -3,10 +3,10 @@ module github.com/e2engine/tests go 1.27 require ( - github.com/e2engine/core v0.3.1 + github.com/e2engine/core v0.3.3 github.com/e2engine/instrumentation-go/grpc v0.2.1 github.com/e2engine/instrumentation-go/http v0.2.2 - github.com/modelcontextprotocol/go-sdk v1.8.0 + github.com/modelcontextprotocol/go-sdk v1.9.0 google.golang.org/grpc v1.85.0 google.golang.org/protobuf v1.36.12 gopkg.in/yaml.v3 v3.0.1 @@ -15,17 +15,17 @@ require ( require ( github.com/e2engine/instrumentation-go v0.2.3 // indirect github.com/google/jsonschema-go v0.4.3 // indirect - github.com/segmentio/asm v1.1.3 // indirect + github.com/segmentio/asm v1.2.1 // indirect github.com/segmentio/encoding v0.5.4 // indirect - github.com/ygrebnov/errorc v0.6.1 // indirect + github.com/ygrebnov/errorc v0.7.0 // indirect github.com/ygrebnov/keys v0.2.0 // indirect - github.com/ygrebnov/model v0.8.1 // indirect + github.com/ygrebnov/model v0.9.0 // indirect github.com/yosida95/uritemplate/v3 v3.0.2 // indirect - golang.org/x/net v0.62.0 // indirect - golang.org/x/oauth2 v0.36.0 // indirect + golang.org/x/net v0.63.0 // indirect + golang.org/x/oauth2 v0.38.0 // indirect golang.org/x/sync v0.25.0 // indirect golang.org/x/sys v0.50.0 // indirect golang.org/x/text v0.44.0 // indirect - golang.org/x/time v0.15.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20261110000943-09e21b237f2c // indirect + golang.org/x/time v0.16.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20261123191846-1e707ab9fbc2 // indirect ) diff --git a/go.sum b/go.sum index 00e488b..fb93fd1 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/e2engine/core v0.3.1 h1:18Jhe5KlMCzw/wJRp7yybEKmzd5IALHhuOyqhl72Vb4= -github.com/e2engine/core v0.3.1/go.mod h1:QcayHlh4J9gTOJGJrs5Ca4NTZ5MLaOA+EvswFdjq+W8= +github.com/e2engine/core v0.3.3 h1:uoh7xn6786eurWwtJajq7meoClhOyV/49k/OEZy79do= +github.com/e2engine/core v0.3.3/go.mod h1:WzxdDsUl8qH/xk7WcPymatQqdZCwR6LaXgxIEIC6tV4= github.com/e2engine/instrumentation-go v0.2.3 h1:Al7SoAIiMHiJ4zxj71JYiFCE9MKgpXFGHxlZCHmbe+0= github.com/e2engine/instrumentation-go v0.2.3/go.mod h1:DyUxzrRZBCzOk+toAmxex+Xn09fYhutsCRUfNUgS8kQ= github.com/e2engine/instrumentation-go/grpc v0.2.1 h1:GB+ZDt/36/gtI1MjVD9agT/RdL9tDBVocAaZUD/rBGU= @@ -14,38 +14,38 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/jsonschema-go v0.4.3 h1:/DBOLZTfDow7pe2GmaJNhltueGTtDKICi8V8p+DQPd0= github.com/google/jsonschema-go v0.4.3/go.mod h1:r5quNTdLOYEz95Ru18zA0ydNbBuYoo9tgaYcxEYhJVE= -github.com/modelcontextprotocol/go-sdk v1.8.0 h1:KIvahhYqwtbeniWVPs3TcXEA7b8jEtwfBpOTAI+Urx4= -github.com/modelcontextprotocol/go-sdk v1.8.0/go.mod h1:dL7u98E/zjJTGzEq+j30jQ8K2k1mb6LeAH4inEcSGts= -github.com/segmentio/asm v1.1.3 h1:WM03sfUOENvvKexOLp+pCqgb/WDjsi7EK8gIsICtzhc= -github.com/segmentio/asm v1.1.3/go.mod h1:Ld3L4ZXGNcSLRg4JBsZ3//1+f/TjYl0Mzen/DQy1EJg= +github.com/modelcontextprotocol/go-sdk v1.9.0 h1:XVjBrIMg82x7ff2bqwSPgRThLp4TC1lGTX74Ofaie1g= +github.com/modelcontextprotocol/go-sdk v1.9.0/go.mod h1:dL7u98E/zjJTGzEq+j30jQ8K2k1mb6LeAH4inEcSGts= +github.com/segmentio/asm v1.2.1 h1:DTNbBqs57ioxAD4PrArqftgypG4/qNpXoJx8TVXxPR0= +github.com/segmentio/asm v1.2.1/go.mod h1:BqMnlJP91P8d+4ibuonYZw9mfnzI9HfxselHZr5aAcs= github.com/segmentio/encoding v0.5.4 h1:OW1VRern8Nw6ITAtwSZ7Idrl3MXCFwXHPgqESYfvNt0= github.com/segmentio/encoding v0.5.4/go.mod h1:HS1ZKa3kSN32ZHVZ7ZLPLXWvOVIiZtyJnO1gPH1sKt0= -github.com/ygrebnov/errorc v0.6.1 h1:ICww1JOesR0HyE3cVWMr0SBmB8RV1XSmGwB5yVP1SqE= -github.com/ygrebnov/errorc v0.6.1/go.mod h1:akitMzADmnm0i1X5fSJfBqiTqCzckka9sgukTRQN5ns= +github.com/ygrebnov/errorc v0.7.0 h1:UBk753h/SNWfX9W6Byp+zckIdybXJ/ixc+VWukpQfdQ= +github.com/ygrebnov/errorc v0.7.0/go.mod h1:akitMzADmnm0i1X5fSJfBqiTqCzckka9sgukTRQN5ns= 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.8.1 h1:KvnS97b/q3Z1GKSHSDYlfHoL3bNDR+ZT9Kf4yc1WnIE= -github.com/ygrebnov/model v0.8.1/go.mod h1:WEMMqdGYF45Kfce0pAe0poiF9hu+PONRSHd2L9li3tw= +github.com/ygrebnov/model v0.9.0 h1:G6QaYVcm9Nqyed/lPzkWfQ543ol9D0C8Yjz9gVUDy9Q= +github.com/ygrebnov/model v0.9.0/go.mod h1:KA8zospuMg3/LbNc+Lgh+8nEz1uR9nv8SN4Vxxt2ruM= github.com/yosida95/uritemplate/v3 v3.0.2 h1:Ed3Oyj9yrmi9087+NczuL5BwkIc4wvTb5zIM+UJPGz4= github.com/yosida95/uritemplate/v3 v3.0.2/go.mod h1:ILOh0sOhIJR3+L/8afwt/kE++YT040gmv5BQTMR2HP4= -golang.org/x/net v0.62.0 h1:18ELalfM5+XNRwzM2nYqXsZQ9ByS1uhj2O/U7+5jqRY= -golang.org/x/net v0.62.0/go.mod h1:WgDCOTH8iwtB66T4/GfI94AHo/hhdb7Hah9NDseQfiI= -golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs= -golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q= +golang.org/x/net v0.63.0 h1:HCoTmNh9EpD1PpK8gBNFY4gcTY4N+KQEO8ylfIKqFJ0= +golang.org/x/net v0.63.0/go.mod h1:15JLg3IX1bLjHK264EZQEbIpTiR/KVLuo9CTRWd0pig= +golang.org/x/oauth2 v0.38.0 h1:uW7XQbcu1eoiQS7uMJvLOjPMl04bTbmY1VeRPxvbspI= +golang.org/x/oauth2 v0.38.0/go.mod h1:IxwZNxUULJmpBFf9K/9NTMSIfZZuvuTy1gGxhigP/58= golang.org/x/sync v0.25.0 h1:dJnifr0nMV8/SBnBvdo4eSGGnrc3O4FFx6IqvtLcmRs= golang.org/x/sync v0.25.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0= golang.org/x/sys v0.50.0 h1:dkKZEFTEKaLr1sjhs0WiKqoi8Jj5nHbS3Njmx1UoMJs= golang.org/x/sys v0.50.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og= golang.org/x/text v0.44.0 h1:YItdp/mQNGnsmrgpcdA5yQ3bnRxCfo/Tj/iByGW9GGo= golang.org/x/text v0.44.0/go.mod h1:S4FR1waQ9LbjQTls97SyRjDaUUVkaM+cXwwuG/G+MwY= -golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U= -golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno= +golang.org/x/time v0.16.0 h1:vMb6ptszcQMkcwiRTAuNNU50gom6++Q/6gY2hDM6VDE= +golang.org/x/time v0.16.0/go.mod h1:rVKOqvZeKvrDKTQiAHJ7wmwP0RzleSphoEA9RcdLA0s= golang.org/x/tools v0.52.0 h1:ryxg4U63oaUYk7uOLTF37n43f4qgtGvqV4Ioit1BaEs= golang.org/x/tools v0.52.0/go.mod h1:ItcP5UNaVGG+Yc4eIYmaFLNJ4soEopkx5Y2d4lcEurs= 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-20261110000943-09e21b237f2c h1:XXChExL+Tm7Ubp0x0VXUEncPLHrkXIgoVWqnxmKNbAA= -google.golang.org/genproto/googleapis/rpc v0.0.0-20261110000943-09e21b237f2c/go.mod h1:OaIUM3+LpYcK2GXM4FTmhWoIq371Owdr+Cc7/BsYHHc= +google.golang.org/genproto/googleapis/rpc v0.0.0-20261123191846-1e707ab9fbc2 h1:FCWn4wv5of/ooWpbWDIeOXqI3+h2MGnV7SvvcJ8f+bQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20261123191846-1e707ab9fbc2/go.mod h1:OaIUM3+LpYcK2GXM4FTmhWoIq371Owdr+Cc7/BsYHHc= google.golang.org/grpc v1.85.0 h1:BPBCfuVRQ1qvBhKDOq9uvQllMvO59rKsYhXpp7Dd8vw= google.golang.org/grpc v1.85.0/go.mod h1:0rQrOD58yjal/0EaVbGBANindixsCZNQPDV3VKtaKuQ= google.golang.org/protobuf v1.36.12 h1:pJOKDDOyeXErUroCihFAd5LQuwXBSpVnKGrj5o/fwxc= From 4d256de48b21aca983a567fe09150315415a2557 Mon Sep 17 00:00:00 2001 From: Yaroslav Grebnov Date: Mon, 30 Nov 2026 18:46:38 +0100 Subject: [PATCH 5/6] Update tools --- .golangci.yml | 4 +++ Makefile | 7 +++- tools/go.mod | 48 ++++++++++++++----------- tools/go.sum | 95 +++++++++++++++++++++++++++----------------------- tools/tools.go | 10 ------ tools/tools.mk | 25 ++++++++++--- 6 files changed, 108 insertions(+), 81 deletions(-) delete mode 100644 tools/tools.go diff --git a/.golangci.yml b/.golangci.yml index 0342585..369ee75 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -93,6 +93,10 @@ linters: linters: - noctx + - path: ^cli/harness/service\.go$ + linters: + - errcheck + - path: ^(cli|docker)/harness/(harness|service)\.go$ linters: - gosec diff --git a/Makefile b/Makefile index f4fe142..fc9c48f 100644 --- a/Makefile +++ b/Makefile @@ -110,6 +110,11 @@ lint: install-golangci-lint @echo "Running linter..." $(GOLANGCI_LINT) run +.PHONY: vulncheck +vulncheck: install-govulncheck + @echo "Checking for known vulnerabilities..." + $(GOVULNCHECK) ./... + .PHONY: build build: build-gateway-http-path-service \ build-gateway-http-body-service \ @@ -123,7 +128,7 @@ build: build-gateway-http-path-service \ @echo "All test helper binaries and images built successfully." .PHONY: verify -verify: lint test-cli-prebuilt test-docker-prebuilt test-mcp-prebuilt +verify: lint vulncheck test-cli-prebuilt test-docker-prebuilt test-mcp-prebuilt @echo "All verifications passed successfully." .PHONY: test-cli-prebuilt diff --git a/tools/go.mod b/tools/go.mod index 09b0078..43ad831 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -2,7 +2,10 @@ module tools go 1.27 -require github.com/golangci/golangci-lint/v2 v2.14.0 +tool ( + github.com/golangci/golangci-lint/v2/cmd/golangci-lint + golang.org/x/vuln/cmd/govulncheck +) require ( 4d63.com/gocheckcompilerdirectives v1.4.0 // indirect @@ -40,7 +43,7 @@ require ( github.com/blizzy78/varnamelen v0.8.0 // indirect github.com/bombsimon/wsl/v4 v4.7.0 // indirect github.com/bombsimon/wsl/v5 v5.9.0 // indirect - github.com/breml/bidichk v0.3.3 // indirect + github.com/breml/bidichk v0.3.4 // indirect github.com/breml/errchkjson v0.4.1 // indirect github.com/butuzov/ireturn v0.4.1 // indirect github.com/butuzov/mirror v1.3.3 // indirect @@ -59,7 +62,7 @@ require ( github.com/clipperhouse/uax29/v2 v2.7.0 // indirect github.com/curioswitch/go-reassign v0.3.0 // indirect github.com/daixiang0/gci v0.13.7 // indirect - github.com/dave/dst v0.27.3 // indirect + github.com/dave/dst v0.28.0 // indirect github.com/denis-tingaikin/go-header v0.5.0 // indirect github.com/dlclark/regexp2/v2 v2.2.1 // indirect github.com/ettle/strcase v0.2.0 // indirect @@ -84,15 +87,16 @@ require ( github.com/gofrs/flock v0.13.1 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/golangci/asciicheck v0.5.0 // indirect - github.com/golangci/canonicalheader v0.0.0-20260827115959-a25c71c521f6 // indirect + github.com/golangci/canonicalheader v0.0.0-20260928145534-e18e5c5a078f // indirect github.com/golangci/dupl v0.0.0-20260401084720-c99c5cf5c202 // indirect github.com/golangci/go-printf-func-name v0.1.1 // indirect github.com/golangci/gofmt v0.0.0-20260820135601-e84e05053792 // indirect - github.com/golangci/golines v0.15.0 // indirect + github.com/golangci/golangci-lint/v2 v2.15.0 // indirect + github.com/golangci/golines v0.16.0 // indirect github.com/golangci/misspell v0.8.0 // indirect github.com/golangci/plugin-module-register v0.1.2 // indirect github.com/golangci/revgrep v0.8.0 // indirect - github.com/golangci/rowserrcheck v0.0.0-20260419091836-c5f79b8a11ba // indirect + github.com/golangci/rowserrcheck v0.0.0-20261005233414-e0740d52dee8 // indirect github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e // indirect github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e // indirect github.com/google/go-cmp v0.7.0 // indirect @@ -111,10 +115,10 @@ require ( github.com/jjti/go-spancheck v0.6.5 // indirect github.com/julz/importas v0.2.0 // indirect github.com/karamaru-alpha/copyloopvar v1.2.2 // indirect - github.com/kisielk/errcheck v1.20.0 // indirect + github.com/kisielk/errcheck v1.30.0 // indirect github.com/kkHAIKE/contextcheck v1.1.6 // indirect github.com/kulti/thelper v0.7.1 // indirect - github.com/kunwardeep/paralleltest v1.0.15 // indirect + github.com/kunwardeep/paralleltest v1.0.16 // indirect github.com/ldez/exptostd v0.4.5 // indirect github.com/ldez/gomoddirectives v0.10.0 // indirect github.com/ldez/grignotin v0.10.1 // indirect @@ -130,18 +134,18 @@ require ( github.com/maratori/testableexamples v1.0.1 // indirect github.com/maratori/testpackage v1.1.2 // indirect github.com/matoous/godox v1.1.0 // indirect - github.com/mattn/go-colorable v0.1.15 // indirect + github.com/mattn/go-colorable v0.1.16 // indirect github.com/mattn/go-isatty v0.0.22 // indirect github.com/mattn/go-runewidth v0.0.24 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect - github.com/mgechev/revive v1.17.0 // indirect + github.com/mgechev/revive v1.17.1 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/moricho/tparallel v0.3.2 // indirect github.com/muesli/cancelreader v0.2.2 // indirect github.com/nakabonne/nestif v0.3.1 // indirect - github.com/nishanths/exhaustive v0.13.0 // indirect - github.com/nishanths/predeclared v0.2.2 // indirect + github.com/nishanths/exhaustive v0.15.0 // indirect + github.com/nishanths/predeclared v0.3.0 // indirect github.com/nunnatsa/ginkgolinter v0.24.0 // indirect github.com/pelletier/go-toml v1.9.5 // indirect github.com/pelletier/go-toml/v2 v2.4.3 // indirect @@ -182,13 +186,13 @@ require ( github.com/subosito/gotenv v1.4.1 // indirect github.com/tetafro/godot v1.5.6 // indirect github.com/timakin/bodyclose v0.0.0-20260723120731-857993a2939c // indirect - github.com/timonwong/loggercheck v0.12.0 // indirect - github.com/tomarrell/wrapcheck/v2 v2.12.0 // indirect + github.com/timonwong/loggercheck v0.13.0 // indirect + github.com/tomarrell/wrapcheck/v2 v2.13.0 // indirect github.com/tommy-muehle/go-mnd/v2 v2.5.1 // indirect github.com/ultraware/funlen v0.2.0 // indirect github.com/ultraware/whitespace v0.2.0 // indirect - github.com/uudashr/gocognit v1.2.1 // indirect - github.com/uudashr/iface v1.5.1 // indirect + github.com/uudashr/gocognit v1.3.0 // indirect + github.com/uudashr/iface v1.5.3 // indirect github.com/xen0n/gosmopolitan v1.3.0 // indirect github.com/xo/terminfo v1.0.0 // indirect github.com/yagipy/maintidx v1.0.0 // indirect @@ -203,16 +207,18 @@ require ( go.uber.org/zap v1.27.0 // indirect go.yaml.in/yaml/v3 v3.0.5 // indirect golang.org/x/exp/typeparams v0.0.0-20260811152304-ee035b5b010f // indirect - golang.org/x/mod v0.41.0 // indirect - golang.org/x/sync v0.23.0 // indirect - golang.org/x/sys v0.48.0 // indirect + golang.org/x/mod v0.43.0 // indirect + golang.org/x/sync v0.25.0 // indirect + golang.org/x/sys v0.50.0 // indirect + golang.org/x/telemetry v0.0.0-20261116191925-e77a43154acb // indirect golang.org/x/text v0.41.0 // indirect - golang.org/x/tools v0.50.0 // indirect + golang.org/x/tools v0.53.0 // indirect + golang.org/x/vuln v1.10.0 // indirect google.golang.org/protobuf v1.36.12 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - honnef.co/go/tools v0.8.1 // indirect + honnef.co/go/tools v0.8.2 // indirect mvdan.cc/gofumpt v0.12.0 // indirect mvdan.cc/unparam v0.0.0-20260823230713-2fa3d841b0c8 // indirect ) diff --git a/tools/go.sum b/tools/go.sum index e3fb495..59d7d90 100644 --- a/tools/go.sum +++ b/tools/go.sum @@ -114,8 +114,8 @@ github.com/bombsimon/wsl/v4 v4.7.0 h1:1Ilm9JBPRczjyUs6hvOPKvd7VL1Q++PL8M0SXBDf+j github.com/bombsimon/wsl/v4 v4.7.0/go.mod h1:uV/+6BkffuzSAVYD+yGyld1AChO7/EuLrCF/8xTiapg= github.com/bombsimon/wsl/v5 v5.9.0 h1:WCrgZ7RQnZO5oEwbVTlYgBdU3wL294kR1BSWV8vTfsU= github.com/bombsimon/wsl/v5 v5.9.0/go.mod h1:kjo4HiAV5FDkHC8/uzJq9mBffEEd6WT/nvN7DoMovDM= -github.com/breml/bidichk v0.3.3 h1:WSM67ztRusf1sMoqH6/c4OBCUlRVTKq+CbSeo0R17sE= -github.com/breml/bidichk v0.3.3/go.mod h1:ISbsut8OnjB367j5NseXEGGgO/th206dVa427kR8YTE= +github.com/breml/bidichk v0.3.4 h1:70G6w80G6GDZTUURHTC5gBKVjMLMw2736CzXquSf5Ek= +github.com/breml/bidichk v0.3.4/go.mod h1:GOHprnh4i0V7HrvWjtbvbpicTUcqoYt9zYESKcJkk4M= github.com/breml/errchkjson v0.4.1 h1:keFSS8D7A2T0haP9kzZTi7o26r7kE3vymjZNeNDRDwg= github.com/breml/errchkjson v0.4.1/go.mod h1:a23OvR6Qvcl7DG/Z4o0el6BRAjKnaReoPQFciAl9U3s= github.com/butuzov/ireturn v0.4.1 h1:vWb3NO4t77iku/sjCQ/2pHTQeOmxEhjIriJqRLg1Y+I= @@ -161,8 +161,8 @@ github.com/curioswitch/go-reassign v0.3.0 h1:dh3kpQHuADL3cobV/sSGETA8DOv457dwl+f github.com/curioswitch/go-reassign v0.3.0/go.mod h1:nApPCCTtqLJN/s8HfItCcKV0jIPwluBOvZP+dsJGA88= github.com/daixiang0/gci v0.13.7 h1:+0bG5eK9vlI08J+J/NWGbWPTNiXPG4WhNLJOkSxWITQ= github.com/daixiang0/gci v0.13.7/go.mod h1:812WVN6JLFY9S6Tv76twqmNqevN0pa3SX3nih0brVzQ= -github.com/dave/dst v0.27.3 h1:P1HPoMza3cMEquVf9kKy8yXsFirry4zEnWOdYPOoIzY= -github.com/dave/dst v0.27.3/go.mod h1:jHh6EOibnHgcUW3WjKHisiooEkYwqpHLBSX1iOBhEyc= +github.com/dave/dst v0.28.0 h1:EIEuRC5XmVKuZF2OeyMahXX9ARVt6Xxr8vI0WtIY7K8= +github.com/dave/dst v0.28.0/go.mod h1:C4mfimBeSHfsgskhR/mUYSE05s2ih+PW6g9FP3c49tE= github.com/dave/jennifer v1.7.1 h1:B4jJJDHelWcDhlRQxWeo0Npa/pYKBLrirAQoTN45txo= github.com/dave/jennifer v1.7.1/go.mod h1:nXbxhEmQfOZhWml3D1cDK5M1FLnMSozpbFN/m3RmGZc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -273,32 +273,34 @@ github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golangci/asciicheck v0.5.0 h1:jczN/BorERZwK8oiFBOGvlGPknhvq0bjnysTj4nUfo0= github.com/golangci/asciicheck v0.5.0/go.mod h1:5RMNAInbNFw2krqN6ibBxN/zfRFa9S6tA1nPdM0l8qQ= -github.com/golangci/canonicalheader v0.0.0-20260827115959-a25c71c521f6 h1:fVLolA3dG6s0brGetsiDAtcnpMSwVa2LqXJEw/9RJG4= -github.com/golangci/canonicalheader v0.0.0-20260827115959-a25c71c521f6/go.mod h1:1xo+NFW5S+bEf2DKXhaxuzvcDN5AR6o/KMwvqC5Mkpo= +github.com/golangci/canonicalheader v0.0.0-20260928145534-e18e5c5a078f h1:pOnwRNeWLPkADfkgqKcCP7RPQAS9OIzffaBaktRsKnk= +github.com/golangci/canonicalheader v0.0.0-20260928145534-e18e5c5a078f/go.mod h1:aXo+AVSX0pC3TRo2wAfR92YwBKfG6C2eal+omjKXwYw= github.com/golangci/dupl v0.0.0-20260401084720-c99c5cf5c202 h1:CbTB8KpqnViI6lIXxp03Oclc4VFHi3K4BWC1TacsZ+A= github.com/golangci/dupl v0.0.0-20260401084720-c99c5cf5c202/go.mod h1:NUw9Zr2Sy7+HxzdjIULge71wI6yEg1lWQr7Evcu8K0E= github.com/golangci/go-printf-func-name v0.1.1 h1:hIYTFJqAGp1iwoIfsNTpoq1xZAarogrvjO9AfiW3B4U= github.com/golangci/go-printf-func-name v0.1.1/go.mod h1:Es64MpWEZbh0UBtTAICOZiB+miW53w/K9Or/4QogJss= github.com/golangci/gofmt v0.0.0-20260820135601-e84e05053792 h1:WL8YKrt3UbOBqSRU7GpP5BTtQTMWtVtj+mfPijgZeIg= github.com/golangci/gofmt v0.0.0-20260820135601-e84e05053792/go.mod h1:te5hX0dW4C5r6YbXs+6ysNr8Q5UTmdIqGbb+mlFiYmA= -github.com/golangci/golangci-lint/v2 v2.14.0 h1:ot8QffRa4LzAAEgtvNYrVs9esxQ7xoTwoAv6uhp4ngA= -github.com/golangci/golangci-lint/v2 v2.14.0/go.mod h1:amHimCzNDP1GfVno3hIiNssjvqXmuW+CPZAHOdR4cIc= -github.com/golangci/golines v0.15.0 h1:Qnph25g8Y1c5fdo1X7GaRDGgnMHgnxh4Gk4VfPTtRx0= -github.com/golangci/golines v0.15.0/go.mod h1:AZjXd23tbHMpowhtnGlj9KCNsysj72aeZVVHnVcZx10= +github.com/golangci/golangci-lint/v2 v2.15.0 h1:w94zf8HAYI7hm3164kwKsvZRuqXvY+YxeFoTbu1OLg8= +github.com/golangci/golangci-lint/v2 v2.15.0/go.mod h1:/FRI304IxqDVhX2o3ZZ0qp8Vvz8egJdzCY5A4GjvmTU= +github.com/golangci/golines v0.16.0 h1:xKdwzRvwzLd7V131B/dv90vUiEoTA0vQybdeqperPOg= +github.com/golangci/golines v0.16.0/go.mod h1:mCMgRQHiCvuALJOeaNtylu09zbzvS9Ka01dfvLLJios= github.com/golangci/misspell v0.8.0 h1:qvxQhiE2/5z+BVRo1kwYA8yGz+lOlu5Jfvtx2b04Jbg= github.com/golangci/misspell v0.8.0/go.mod h1:WZyyI2P3hxPY2UVHs3cS8YcllAeyfquQcKfdeE9AFVg= github.com/golangci/plugin-module-register v0.1.2 h1:e5WM6PO6NIAEcij3B053CohVp3HIYbzSuP53UAYgOpg= github.com/golangci/plugin-module-register v0.1.2/go.mod h1:1+QGTsKBvAIvPvoY/os+G5eoqxWn70HYDm2uvUyGuVw= github.com/golangci/revgrep v0.8.0 h1:EZBctwbVd0aMeRnNUsFogoyayvKHyxlV3CdUA46FX2s= github.com/golangci/revgrep v0.8.0/go.mod h1:U4R/s9dlXZsg8uJmaR1GrloUr14D7qDl8gi2iPXJH8k= -github.com/golangci/rowserrcheck v0.0.0-20260419091836-c5f79b8a11ba h1:lqtcnSMDuuJdu/LrKWi5RJzpSNLOJXYe/nzQutTI5kg= -github.com/golangci/rowserrcheck v0.0.0-20260419091836-c5f79b8a11ba/go.mod h1:sCBNcpRmhJCtbFGz49+IM3ETTFf7QdJ30AeYCd43NKk= +github.com/golangci/rowserrcheck v0.0.0-20261005233414-e0740d52dee8 h1:oN042y1yEcpldrqY81puyNA4ZjQZJzt0U/t7HyYrMic= +github.com/golangci/rowserrcheck v0.0.0-20261005233414-e0740d52dee8/go.mod h1:T1Bg58Sk3N352aBbPLJPpHykFWxEEwV3o4/Enn+PPU8= github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e h1:ai0EfmVYE2bRA5htgAG9r7s3tHsfjIhN98WshBTJ9jM= github.com/golangci/swaggoswag v0.0.0-20250504205917-77f2aca3143e/go.mod h1:Vrn4B5oR9qRwM+f54koyeH3yzphlecwERs0el27Fr/s= github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e h1:gD6P7NEo7Eqtt0ssnqSJNNndxe69DOQ24A5h7+i3KpM= github.com/golangci/unconvert v0.0.0-20250410112200-a129a6e6413e/go.mod h1:h+wZwLjUTJnm/P2rwlbJdRPZXOzaT36/FwnPnY2inzc= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/go-cmdtest v0.4.1-0.20220921163831-55ab3332a786 h1:rcv+Ippz6RAtvaGgKxc+8FQIpxHgsF+HBzPyYL2cyVU= +github.com/google/go-cmdtest v0.4.1-0.20220921163831-55ab3332a786/go.mod h1:apVn/GCasLZUVpAJ6oWAuyP7Ne7CEsQbTnc0plM3m+o= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -324,6 +326,7 @@ github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20260802141513-ef3492d7dac3 h1:LMLX+LgTNWpfvCBdFebv6EsYotImrt/Ppc5cXIriCSo= github.com/google/pprof v0.0.0-20260802141513-ef3492d7dac3/go.mod h1:jl5iWTm0/hd5PjEYEOuwAJ57L/CibdZfrqZ5XA5GrCk= +github.com/google/renameio v0.1.0 h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= @@ -376,8 +379,8 @@ github.com/julz/importas v0.2.0 h1:y+MJN/UdL63QbFJHws9BVC5RpA2iq0kpjrFajTGivjQ= github.com/julz/importas v0.2.0/go.mod h1:pThlt589EnCYtMnmhmRYY/qn9lCf/frPOK+WMx3xiJY= github.com/karamaru-alpha/copyloopvar v1.2.2 h1:yfNQvP9YaGQR7VaWLYcfZUlRP2eo2vhExWKxD/fP6q0= github.com/karamaru-alpha/copyloopvar v1.2.2/go.mod h1:oY4rGZqZ879JkJMtX3RRkcXRkmUvH0x35ykgaKgsgJY= -github.com/kisielk/errcheck v1.20.0 h1:9rwHBNKzd4wkDWcROy3DvFGNqEPlkxBg305rvk7HabI= -github.com/kisielk/errcheck v1.20.0/go.mod h1:O+f80MKNwX8Oor2jwgpeQ9An7uJm+hRSgT+h22knRJU= +github.com/kisielk/errcheck v1.30.0 h1:ZIxNDAfAd4larXHTceoZP/dYPAB90dHg1OYhA2sVh5k= +github.com/kisielk/errcheck v1.30.0/go.mod h1:uiCAInmFuyOje4VDdbQSP9mgqf5gORYSXrDf19XilsI= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkHAIKE/contextcheck v1.1.6 h1:7HIyRcnyzxL9Lz06NGhiKvenXq7Zw6Q0UQu/ttjfJCE= github.com/kkHAIKE/contextcheck v1.1.6/go.mod h1:3dDbMRNBFaq8HFXWC1JyvDSPm43CmE6IuHam8Wr0rkg= @@ -393,8 +396,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kulti/thelper v0.7.1 h1:fI8QITAoFVLx+y+vSyuLBP+rcVIB8jKooNSCT2EiI98= github.com/kulti/thelper v0.7.1/go.mod h1:NsMjfQEy6sd+9Kfw8kCP61W1I0nerGSYSFnGaxQkcbs= -github.com/kunwardeep/paralleltest v1.0.15 h1:ZMk4Qt306tHIgKISHWFJAO1IDQJLc6uDyJMLyncOb6w= -github.com/kunwardeep/paralleltest v1.0.15/go.mod h1:di4moFqtfz3ToSKxhNjhOZL+696QtJGCFe132CbBLGk= +github.com/kunwardeep/paralleltest v1.0.16 h1:I0gQkLNgfigjpxWAGhx7PYj3VpswzfGrSV/715t6g+o= +github.com/kunwardeep/paralleltest v1.0.16/go.mod h1:di4moFqtfz3ToSKxhNjhOZL+696QtJGCFe132CbBLGk= github.com/ldez/exptostd v0.4.5 h1:kv2ZGUVI6VwRfp/+bcQ6Nbx0ghFWcGIKInkG/oFn1aQ= github.com/ldez/exptostd v0.4.5/go.mod h1:QRjHRMXJrCTIm9WxVNH6VW7oN7KrGSht69bIRwvdFsM= github.com/ldez/gomoddirectives v0.10.0 h1:Zb23rfMMkG21B6pZ9OfESzemByP5Qr7YvWcXQZE/S3Q= @@ -427,16 +430,16 @@ github.com/matoous/godox v1.1.0 h1:W5mqwbyWrwZv6OQ5Z1a/DHGMOvXYCBP3+Ht7KMoJhq4= github.com/matoous/godox v1.1.0/go.mod h1:jgE/3fUXiTurkdHOLT5WEkThTSuE7yxHv5iWPa80afs= github.com/matryer/is v1.4.0 h1:sosSmIWwkYITGrxZ25ULNDeKiMNzFSr4V/eqBQP0PeE= github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU= -github.com/mattn/go-colorable v0.1.15 h1:+u9SLTRGnXv73cEsnsmoZBom+dMU88B2M0aDcWy0/jY= -github.com/mattn/go-colorable v0.1.15/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= +github.com/mattn/go-colorable v0.1.16 h1:+2YjeAe7xP1OQbZW1jERPWWCDLlNqFNCvjiqGiAt84A= +github.com/mattn/go-colorable v0.1.16/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.22 h1:j8l17JJ9i6VGPUFUYoTUKPSgKe/83EYU2zBC7YNKMw4= github.com/mattn/go-isatty v0.0.22/go.mod h1:ZXfXG4SQHsB/w3ZeOYbR0PrPwLy+n6xiMrJlRFqopa4= github.com/mattn/go-runewidth v0.0.24 h1:cpokDiIn0MGnhdHwuWnJBITySJ20QyNGnY2kR/ay2DU= github.com/mattn/go-runewidth v0.0.24/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/mgechev/revive v1.17.0 h1:hwTTVC3svSv9X2FA2hiYT17Uws+lfxDWhPxzBZZCREg= -github.com/mgechev/revive v1.17.0/go.mod h1:uiVNUF8ruVh4WHm/aPs7kKEeuo+m6oO3tuOfniyzP/g= +github.com/mgechev/revive v1.17.1 h1:z8hV0L3uJ6yrwOMnJbkc5qBJpxXa2AxYKFKERGJyA4s= +github.com/mgechev/revive v1.17.1/go.mod h1:FRd64pJwWSEE6j8ESoaX0PixPzjh2rpNSfckbEu3rIE= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= @@ -454,10 +457,10 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nakabonne/nestif v0.3.1 h1:wm28nZjhQY5HyYPx+weN3Q65k6ilSBxDb8v5S81B81U= github.com/nakabonne/nestif v0.3.1/go.mod h1:9EtoZochLn5iUprVDmDjqGKPofoUEBL8U4Ngq6aY7OE= -github.com/nishanths/exhaustive v0.13.0 h1:Rof0axOSNQaaPaPmLK5RxcRrJV2Vcv+vfUmuRy+2EAM= -github.com/nishanths/exhaustive v0.13.0/go.mod h1:3/adQjJgvD/UFHHSYBjpK9Wbz8DOvf0FBtzx+zI0Rlo= -github.com/nishanths/predeclared v0.2.2 h1:V2EPdZPliZymNAn79T8RkNApBjMmVKh5XRpLm/w98Vk= -github.com/nishanths/predeclared v0.2.2/go.mod h1:RROzoN6TnGQupbC+lqggsOlcgysk3LMK/HI84Mp280c= +github.com/nishanths/exhaustive v0.15.0 h1:uFjiO/WvrwQG+ojSZ+vtl/jAFbqA2oAtfpUWK/iKQ8M= +github.com/nishanths/exhaustive v0.15.0/go.mod h1:2by9rYmg9FnsnLQC4Ixig4fQaWxRsY7RluxJuAu9sa0= +github.com/nishanths/predeclared v0.3.0 h1:W3i3JK/DZS5h7QwsEIyU8ler4Z2vwEwQSxNrZzhnlfk= +github.com/nishanths/predeclared v0.3.0/go.mod h1:gN4uryPExDME/zmZdqkKIPSAqcfprj316ZDI6UTqz70= github.com/nunnatsa/ginkgolinter v0.24.0 h1:Mp0EagluLFP98JatP6nqp/gGEoljNG97uf9AcxcBVy8= github.com/nunnatsa/ginkgolinter v0.24.0/go.mod h1:2ZMRuzX6+3XXyY6UZOwb6n+MCocVGbkIsDBC4vuWz5c= github.com/onsi/ginkgo/v2 v2.32.1 h1:6tlvcDm/3sE8lGJbZ4+d4mO3RLy24/tQWOFzVSQNIfw= @@ -585,20 +588,20 @@ github.com/tetafro/godot v1.5.6 h1:IEkrFCwXaYHlOn4mGzGS3F3dkP6m9t0jpwqBFPIkKiA= github.com/tetafro/godot v1.5.6/go.mod h1:eOkMrVQurDui411nBY2FA05EYH01r14LuWY/NrVDVcU= github.com/timakin/bodyclose v0.0.0-20260723120731-857993a2939c h1:d/FUP8GD4QiY/rdFzZmBu3KqL9eBNVzMu7W/5pGkaMM= github.com/timakin/bodyclose v0.0.0-20260723120731-857993a2939c/go.mod h1:sDHLK7rb/59v/ZxZ7KtymgcoxuUMxjXq8gtu9VMOK8M= -github.com/timonwong/loggercheck v0.12.0 h1:7Cb9XGLJZSWYNjgL459DIhpSiEHupD+MLQ6vaN2Pl3g= -github.com/timonwong/loggercheck v0.12.0/go.mod h1:Wa6Y+SJHQR01mViZlLLY5GAZVOWOLNMbkXddMjFWQCs= -github.com/tomarrell/wrapcheck/v2 v2.12.0 h1:H/qQ1aNWz/eeIhxKAFvkfIA+N7YDvq6TWVFL27Of9is= -github.com/tomarrell/wrapcheck/v2 v2.12.0/go.mod h1:AQhQuZd0p7b6rfW+vUwHm5OMCGgp63moQ9Qr/0BpIWo= +github.com/timonwong/loggercheck v0.13.0 h1:6amIOmLLPFYt24rXUbNWzcJeNGuJc+3c31tZtO85VHs= +github.com/timonwong/loggercheck v0.13.0/go.mod h1:thn3allpox0fI5JeUWTCwiwp45peQxCZZHkHuA1Oc6I= +github.com/tomarrell/wrapcheck/v2 v2.13.0 h1:jYbLNs8PDkzGCY6d5LUzJdY7Bq//CTlb2HxZGV5z0JY= +github.com/tomarrell/wrapcheck/v2 v2.13.0/go.mod h1:AQhQuZd0p7b6rfW+vUwHm5OMCGgp63moQ9Qr/0BpIWo= github.com/tommy-muehle/go-mnd/v2 v2.5.1 h1:NowYhSdyE/1zwK9QCLeRb6USWdoif80Ie+v+yU8u1Zw= github.com/tommy-muehle/go-mnd/v2 v2.5.1/go.mod h1:WsUAkMJMYww6l/ufffCD3m+P7LEvr8TnZn9lwVDlgzw= github.com/ultraware/funlen v0.2.0 h1:gCHmCn+d2/1SemTdYMiKLAHFYxTYz7z9VIDRaTGyLkI= github.com/ultraware/funlen v0.2.0/go.mod h1:ZE0q4TsJ8T1SQcjmkhN/w+MceuatI6pBFSxxyteHIJA= github.com/ultraware/whitespace v0.2.0 h1:TYowo2m9Nfj1baEQBjuHzvMRbp19i+RCcRYrSWoFa+g= github.com/ultraware/whitespace v0.2.0/go.mod h1:XcP1RLD81eV4BW8UhQlpaR+SDc2givTvyI8a586WjW8= -github.com/uudashr/gocognit v1.2.1 h1:CSJynt5txTnORn/DkhiB4mZjwPuifyASC8/6Q0I/QS4= -github.com/uudashr/gocognit v1.2.1/go.mod h1:acaubQc6xYlXFEMb9nWX2dYBzJ/bIjEkc1zzvyIZg5Q= -github.com/uudashr/iface v1.5.1 h1:BS3yrgaT55s3dAtJoxuTnsZNbsejq/mVuzp49YDyfBA= -github.com/uudashr/iface v1.5.1/go.mod h1:5UWoT6SvTdTww/KToRj6clO+n4Kg3/NrAQvgOB+5Ggw= +github.com/uudashr/gocognit v1.3.0 h1:Xdw5JwAoYmX3WAB+wsXY3nxEwdw7+MWAnM0wCAAv7A4= +github.com/uudashr/gocognit v1.3.0/go.mod h1:acaubQc6xYlXFEMb9nWX2dYBzJ/bIjEkc1zzvyIZg5Q= +github.com/uudashr/iface v1.5.3 h1:N61bzr11L7BHP6Rct+C6zQePHjSTMeyVBq+s03uB/Ds= +github.com/uudashr/iface v1.5.3/go.mod h1:5UWoT6SvTdTww/KToRj6clO+n4Kg3/NrAQvgOB+5Ggw= github.com/xen0n/gosmopolitan v1.3.0 h1:zAZI1zefvo7gcpbCOrPSHJZJYA9ZgLfJqtKzZ5pHqQM= github.com/xen0n/gosmopolitan v1.3.0/go.mod h1:rckfr5T6o4lBtM1ga7mLGKZmLxswUoH1zxHgNXOsEt4= github.com/xo/terminfo v1.0.0 h1:2ZpYzqWzyyytjk3TP6aJVDhkMAkc99/1xKQdA3TDTBY= @@ -688,8 +691,8 @@ golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.41.0 h1:qJmnOUb4YB+FsEuM3HcWucdZASCPGhsX6uljO6pog0c= -golang.org/x/mod v0.41.0/go.mod h1:Ek9pY8RKWXwsWvd3rQiHYtMqkjSUV+s1Rj7j4H5Ur6o= +golang.org/x/mod v0.43.0 h1:MFuq5J6s35W9D3IjkwyWc9vHh0nENOrt5K8Iof4ofmg= +golang.org/x/mod v0.43.0/go.mod h1:4ec1JnuyBz5+FIVhg86UsA39YG8BpnrZdJYSNHmGzHY= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -724,8 +727,8 @@ golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qx golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -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/net v0.63.0 h1:HCoTmNh9EpD1PpK8gBNFY4gcTY4N+KQEO8ylfIKqFJ0= +golang.org/x/net v0.63.0/go.mod h1:15JLg3IX1bLjHK264EZQEbIpTiR/KVLuo9CTRWd0pig= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -745,8 +748,8 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.23.0 h1:KameEIfc1IkluZyXWLn39Wd4tURc6GbCiISGiZm2bQk= -golang.org/x/sync v0.23.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0= +golang.org/x/sync v0.25.0 h1:dJnifr0nMV8/SBnBvdo4eSGGnrc3O4FFx6IqvtLcmRs= +golang.org/x/sync v0.25.0/go.mod h1:sUUOizhqBxiL6pEWpqNLUiaJn1ShEbZ6BBqskPbjZm0= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -790,8 +793,10 @@ golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -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/sys v0.50.0 h1:dkKZEFTEKaLr1sjhs0WiKqoi8Jj5nHbS3Njmx1UoMJs= +golang.org/x/sys v0.50.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og= +golang.org/x/telemetry v0.0.0-20261116191925-e77a43154acb h1:juaHO1dWannznOvpnfdTIjkqPDBsG9OcdkOBTBlcUCA= +golang.org/x/telemetry v0.0.0-20261116191925-e77a43154acb/go.mod h1:frnW8knEsfI9dILitAKHe8/iQ1ycXgpvIjQ/xz9QFYk= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= @@ -855,12 +860,14 @@ golang.org/x/tools v0.1.1-0.20210302220138-2ac05c832e1a/go.mod h1:9bzcO0MWcOuT0t golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.50.0 h1:c2ifzfcuY7L90lZ2aKd8S4K2NpASF08SZx9ZuJkHmSU= -golang.org/x/tools v0.50.0/go.mod h1:7ulVMw3831Mwi5EZD6RomGyffr4VFjuNYXf2BbCEAV0= +golang.org/x/tools v0.53.0 h1:T3bIVp3zjHG9/aEiFk6BXxFh5/Vcbk7JA5hRq1cG8IU= +golang.org/x/tools v0.53.0/go.mod h1:vg+Vrb7y5mTTtxZLTdbTK8G745wcaLcsCtgCWgQONCI= golang.org/x/tools/go/expect v0.1.1-deprecated h1:jpBZDwmgPhXsKZC6WhL20P4b/wmnpsEAGHaNy0n/rJM= golang.org/x/tools/go/expect v0.1.1-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/bVUSGBlGQU67vpBeOrBY= golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated h1:1h2MnaIAIXISqTFKdENegdpAgUXz6NrPEsbIeWaBRvM= golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated/go.mod h1:RVAQXBGNv1ib0J382/DPCRS/BPnsGebyM1Gj5VSDpG8= +golang.org/x/vuln v1.10.0 h1:W/Im35AGknunDiqBysVe9VoMfaeTJE7lptrD+1s//aE= +golang.org/x/vuln v1.10.0/go.mod h1:kNpckBWtSQiR+USd0ZgdhJCCWf/ZXOl1+n3Wybcj8eE= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -966,8 +973,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.8.1 h1:+JKf3xJ1ni4CwrhVg4/pqsfPGP6vNAXcKbMXJodYx3w= -honnef.co/go/tools v0.8.1/go.mod h1:XA+OnlRA9EDh/ukGvXMNSZNKGwFQJ+5dER0ioUkOxks= +honnef.co/go/tools v0.8.2 h1:+jPbCzuYxYrcoOvCecYUFDj+XJQRmzIhJmlbpps21Zk= +honnef.co/go/tools v0.8.2/go.mod h1:xG1Q4n+mg3bKZrO6RWFA9jFlkqplflmDRHGeuexiLDs= mvdan.cc/gofumpt v0.12.0 h1:1Lbudkz2kpM9Cjz2pL4M19u7q+GaEhCTNf7N9mfpcho= mvdan.cc/gofumpt v0.12.0/go.mod h1:SmBHHrljiZu/uoypeKup3rFzP6eoC9UwCp2iH5E3jZA= mvdan.cc/unparam v0.0.0-20260823230713-2fa3d841b0c8 h1:Re1NRyLpiAt9kB+ImaaoapwWiQXrKwER4tY8fLOkDew= diff --git a/tools/tools.go b/tools/tools.go deleted file mode 100644 index 963d21e..0000000 --- a/tools/tools.go +++ /dev/null @@ -1,10 +0,0 @@ -//go:build tools - -// This file is for managing Go programs version with `go.mod`, which allows -// them to be kept up-to-date through tools like Dependabot. - -package tools - -import ( - _ "github.com/golangci/golangci-lint/v2/cmd/golangci-lint" -) diff --git a/tools/tools.mk b/tools/tools.mk index 9127a68..e3887e5 100644 --- a/tools/tools.mk +++ b/tools/tools.mk @@ -2,26 +2,38 @@ # The tools are installed in a local bin directory, making it easy to manage # project-specific tool versions without affecting the system-wide installation. -TOOLS_DIR ?= $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) -BIN_DIR ?= $(TOOLS_DIR)/bin +TOOLS_DIR ?= $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST)))) +TOOLS_MOD_FILE := $(TOOLS_DIR)/go.mod +BIN_DIR ?= $(TOOLS_DIR)/bin +# Detect OS and architecture OS := $(shell uname -s | tr A-Z a-z) ARCH := $(shell uname -m) GOLANGCI_LINT_VERSION ?= $(shell go -C $(TOOLS_DIR) list -m -f '{{.Version}}' github.com/golangci/golangci-lint/v2) +GOVULNCHECK_VERSION ?= $(shell go -C $(TOOLS_DIR) list -m -f '{{.Version}}' golang.org/x/vuln) GOLANGCI_LINT := $(BIN_DIR)/golangci-lint-$(OS)-$(ARCH)-$(GOLANGCI_LINT_VERSION) - -GOLANGCI_LINT_LINK := $(BIN_DIR)/golangci-lint +GOVULNCHECK := $(BIN_DIR)/govulncheck-$(OS)-$(ARCH)-$(GOVULNCHECK_VERSION) $(GOLANGCI_LINT): $(call go-install-tool,$@,github.com/golangci/golangci-lint/v2/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION)) +$(GOVULNCHECK): + $(call go-install-tool,$@,golang.org/x/vuln/cmd/govulncheck,$(GOVULNCHECK_VERSION)) + +GOLANGCI_LINT_LINK := $(BIN_DIR)/golangci-lint +GOVULNCHECK_LINK := $(BIN_DIR)/govulncheck + .PHONY: $(GOLANGCI_LINT_LINK) $(GOLANGCI_LINT_LINK): $(GOLANGCI_LINT) $(call create-symlink,$(GOLANGCI_LINT),$(GOLANGCI_LINT_LINK)) -TOOLS := install-golangci-lint +.PHONY: $(GOVULNCHECK_LINK) +$(GOVULNCHECK_LINK): $(GOVULNCHECK) + $(call create-symlink,$(GOVULNCHECK),$(GOVULNCHECK_LINK)) + +TOOLS := install-golangci-lint install-govulncheck .PHONY: install-tools install-tools: $(TOOLS) @@ -29,6 +41,9 @@ install-tools: $(TOOLS) .PHONY: install-golangci-lint install-golangci-lint: $(GOLANGCI_LINT) $(GOLANGCI_LINT_LINK) +.PHONY: install-govulncheck +install-govulncheck: $(GOVULNCHECK) $(GOVULNCHECK_LINK) + .PHONY: clean-tools clean-tools: rm -rf $(BIN_DIR)/* From b6d5169dbd48da32129269ecfbcd10942a10229a Mon Sep 17 00:00:00 2001 From: Yaroslav Grebnov Date: Tue, 1 Dec 2026 17:08:20 +0100 Subject: [PATCH 6/6] Update MCP tests harness --- README.md | 2 +- mcp/harness/harness.go | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index be20438..75b5728 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ make test-mcp-prebuilt MCP builds with local module replacements need the corresponding sibling checkouts. The MCP suite uses a standalone telemetry HTTP mock and a temporary -user profile; it does not contact AWS. +user profile; it does not contact production service. Run all three suites and the linter after building the candidate artifacts: diff --git a/mcp/harness/harness.go b/mcp/harness/harness.go index b5ec211..fbe0b8e 100644 --- a/mcp/harness/harness.go +++ b/mcp/harness/harness.go @@ -56,6 +56,11 @@ func New(t *testing.T, options Options) *Harness { if options.ProfileDir == "" { options.ProfileDir = t.TempDir() } + for _, dir := range []string{options.DataDir, options.ProfileDir} { + if err := os.Chmod(dir, 0o700); err != nil { + t.Fatalf("make MCP test directory private %q: %v", dir, err) + } + } configPath := filepath.Join(options.ProfileDir, "mcp-config.yml") if err := os.WriteFile(configPath, []byte("{}\n"), 0o600); err != nil { t.Fatalf("create private MCP config: %v", err)