Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(e2e): add kafka tests for on our internal tracetesting/dogfood …
…tests (#3089) * wip * Adding dogfood tests for Kafka trigger
- Loading branch information
1 parent
6278220
commit 18d8df8
Showing
7 changed files
with
197 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ results/ | |
config.yml | ||
.env | ||
tracetesting-env.yaml | ||
tracetesting-vars.yaml |
64 changes: 64 additions & 0 deletions
64
testing/server-tracetesting/features/kafka_test/01_create_kafka_test.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
type: Test | ||
spec: | ||
id: dvsf860sdv | ||
name: Create Kafka Test | ||
description: Test step of 'Kafka Test Feature - Test Suite' | ||
trigger: | ||
type: http | ||
httpRequest: | ||
url: ${var:TARGET_URL}/api/tests | ||
method: POST | ||
headers: | ||
- key: Content-Type | ||
value: application/json | ||
body: | | ||
{ | ||
"type": "Test", | ||
"spec": { | ||
"name": "Import a Pokemon reading a Stream", | ||
"trigger": { | ||
"type": "kafka", | ||
"kafka": { | ||
"brokerUrls": ["${var:DEMO_APP_KAFKA_BROKER}"], | ||
"topic": "pokemon", | ||
"headers": [], | ||
"messageKey": "snorlax-key", | ||
"messageValue": "{\"id\": 143}" | ||
} | ||
}, | ||
"specs": [ | ||
{ | ||
"selector":"span[tracetest.span.type=\"messaging\" name=\"pokemon process\" messaging.system=\"kafka\" messaging.destination=\"pokemon\" messaging.destination_kind=\"topic\" messaging.operation=\"process\"]", | ||
"assertions": ["attr:messaging.system = \"kafka\""], | ||
"name": "A message was received from Kafka stream" | ||
}, | ||
{ | ||
"selector":"span[tracetest.span.type=\"general\" name=\"import pokemon\"]", | ||
"assertions": ["attr:name = \"import pokemon\""], | ||
"name": "Import Pokemon use case was triggered" | ||
} | ||
] | ||
} | ||
} | ||
specs: | ||
- name: Tracetest API returned a valid HTTP code for test creation | ||
selector: span[name = "Tracetest trigger"] | ||
assertions: | ||
- attr:tracetest.selected_spans.count = 1 | ||
- attr:tracetest.response.status = 201 | ||
- name: Tracetest API endpoint 'POST /api/tests' was called once | ||
selector: span[name="POST /api/tests" tracetest.span.type="http"] | ||
assertions: | ||
- attr:tracetest.selected_spans.count = 1 | ||
- name: Just one test was added into the database | ||
selector: span[name = "exec INSERT"] | ||
assertions: | ||
- attr:tracetest.selected_spans.count = 1 | ||
- name: The test was added on the correct database table | ||
selector: span[name = "exec INSERT"]:first | ||
assertions: | ||
- attr:sql.query contains "INSERT INTO tests" | ||
outputs: | ||
- name: KAFKA_TEST_ID | ||
selector: span[name = "Tracetest trigger"] | ||
value: attr:tracetest.response.body | json_path '$.spec.id' |
28 changes: 28 additions & 0 deletions
28
testing/server-tracetesting/features/kafka_test/02_list_kafka_test.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
type: Test | ||
spec: | ||
id: jkbd86ads | ||
name: List Kafka Test | ||
description: Test step of 'Kafka Test Feature - Test Suite' | ||
trigger: | ||
type: http | ||
httpRequest: | ||
url: ${var:TARGET_URL}/api/tests | ||
method: GET | ||
headers: | ||
- key: Content-Type | ||
value: application/json | ||
specs: | ||
- name: Tracetest API listed the test last test created | ||
selector: span[name = "Tracetest trigger"] | ||
assertions: | ||
- attr:tracetest.selected_spans.count = 1 | ||
- attr:tracetest.response.status = 200 | ||
- attr:tracetest.response.body | json_path '$.items[*].spec.id' contains var:KAFKA_TEST_ID # check if the test is listed | ||
- name: Tracetest API endpoint 'GET /api/tests' was called once | ||
selector: span[name="GET /api/tests" tracetest.span.type="http"] | ||
assertions: | ||
- attr:tracetest.selected_spans.count = 1 | ||
- name: Two queries were executed on the database, one for counting and another for listing | ||
selector: span[name = "query SELECT"] | ||
assertions: | ||
- attr:tracetest.selected_spans.count = 2 |
44 changes: 44 additions & 0 deletions
44
testing/server-tracetesting/features/kafka_test/03_run_kafka_test.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
type: Test | ||
spec: | ||
id: as8d7da8s6 | ||
name: Run Kafka Test | ||
description: Test step of 'Kafka Test Feature - Test Suite' | ||
trigger: | ||
type: http | ||
httpRequest: | ||
url: ${var:TARGET_URL}/api/tests/${var:KAFKA_TEST_ID}/run | ||
method: POST | ||
headers: | ||
- key: Content-Type | ||
value: application/json | ||
body: '{}' | ||
specs: | ||
- name: Tracetest API started to run the test correctly | ||
selector: span[name = "Tracetest trigger"] | ||
assertions: | ||
- attr:tracetest.selected_spans.count = 1 | ||
- attr:tracetest.response.status = 200 | ||
- name: Tracetest API endpoint 'POST /api/tests/{testId}/run' was called once | ||
selector: span[name = "POST /api/tests/{testId}/run" tracetest.span.type = "http"] | ||
assertions: | ||
- attr:tracetest.selected_spans.count = 1 | ||
- name: The test trigger was executed correctly | ||
selector: span[name = "Trigger test"] | ||
assertions: | ||
- attr:tracetest.selected_spans.count = 1 | ||
- attr:tracetest.run.trigger.test_id = "${var:KAFKA_TEST_ID}" | ||
- attr:tracetest.run.trigger.type = "kafka" | ||
- name: The trace poller was started | ||
selector: span[name = "Fetch trace"] | ||
assertions: | ||
- attr:tracetest.selected_spans.count > 0 | ||
- attr:tracetest.run.trace_poller.test_id = "${var:KAFKA_TEST_ID}" | ||
- name: The trace poller finished with success | ||
selector: span[name = "Fetch trace"]:last | ||
assertions: | ||
- attr:tracetest.run.trace_poller.succesful = "true" | ||
- name: All assertions were validated and passed | ||
selector: span[name = "Execute assertions"] | ||
assertions: | ||
- attr:tracetest.selected_spans.count = 1 | ||
- attr:tracetest.run.assertion_runner.all_assertions_passed = "true" |
29 changes: 29 additions & 0 deletions
29
testing/server-tracetesting/features/kafka_test/04_delete_kafka_test.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
type: Test | ||
spec: | ||
id: asd978dfg | ||
name: Delete Kafka Test | ||
description: Test step of 'Kafka Test Feature - Test Suite' | ||
trigger: | ||
type: http | ||
httpRequest: | ||
url: ${var:TARGET_URL}/api/tests/${var:KAFKA_TEST_ID} | ||
method: DELETE | ||
headers: | ||
- key: Content-Type | ||
value: application/json | ||
specs: | ||
- name: Tracetest API deleted the test last test created | ||
selector: span[name = "Tracetest trigger"] | ||
assertions: | ||
- attr:tracetest.selected_spans.count = 1 | ||
- attr:tracetest.response.status = 204 | ||
- name: Tracetest API endpoint 'DELETE /api/tests/{id}' was called once | ||
selector: span[name="DELETE /api/tests/{id}" tracetest.span.type="http"] | ||
assertions: | ||
- attr:tracetest.selected_spans.count = 1 | ||
- name: All test entities were deleted | ||
selector: span[name = "exec DELETE"] | ||
assertions: | ||
# must delete test and runs. That's why we need 2 deletes | ||
- attr:tracetest.selected_spans.count = 4 |
14 changes: 14 additions & 0 deletions
14
testing/server-tracetesting/features/kafka_test/_test_suite.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
type: TestSuite | ||
spec: | ||
id: kajwb6asd | ||
name: Kafka Test Feature | ||
description: Sequence of tests to validate if our Kafka Test feature is working as expected | ||
steps: | ||
# create a Kafka Test | ||
- ./01_create_kafka_test.yml | ||
# check if this test is listed on API | ||
- ./02_list_kafka_test.yml | ||
# run test | ||
- ./03_run_kafka_test.yml | ||
# delete test | ||
- ./04_delete_kafka_test.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters