Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Chore] Add e2e test case for OTEL Kafka receiver and exporter. #2274

Merged
merged 1 commit into from
Dec 8, 2023

Conversation

IshwarKanse
Copy link
Contributor

@IshwarKanse IshwarKanse commented Oct 25, 2023

Testing:

This e2e case tests the Kafka receiver and exporter.

$ kuttl test --timeout=180 --test=kafka tests/e2e-openshift
2023/12/08 08:15:36 kutt-test config testdirs is overridden with args: [ tests/e2e-openshift ]
=== RUN   kuttl
    harness.go:462: starting setup
    harness.go:252: running tests using configured kubeconfig.
I1208 08:15:37.940200    8630 request.go:682] Waited for 1.024173085s due to client-side throttling, not priority and fairness, request: GET:https://api.crc.testing:6443/apis/console.openshift.io/v1?timeout=32s
    harness.go:275: Successful connection to cluster at: https://api.crc.testing:6443
    harness.go:360: running tests
    harness.go:73: going to run test suite with timeout of 180 seconds for each step
    harness.go:372: testsuite: tests/e2e-openshift has 5 tests
=== RUN   kuttl/harness
=== RUN   kuttl/harness/kafka
=== PAUSE kuttl/harness/kafka
=== CONT  kuttl/harness/kafka
    logger.go:42: 08:15:43 | kafka | Ignoring check_traces.sh as it does not match file name regexp: ^(\d+)-(?:[^\.]+)(?:\.yaml)?$
    logger.go:42: 08:15:43 | kafka | Creating namespace: kuttl-test-inviting-cat
    logger.go:42: 08:15:43 | kafka/0-create-kafka-instance | starting test step 0-create-kafka-instance
    logger.go:42: 08:15:46 | kafka/0-create-kafka-instance | Namespace:/kuttl-kafka created
    logger.go:42: 08:15:46 | kafka/0-create-kafka-instance | Kafka:kuttl-kafka/my-cluster created
    logger.go:42: 08:16:55 | kafka/0-create-kafka-instance | test step completed 0-create-kafka-instance
    logger.go:42: 08:16:55 | kafka/1-create-kafka-topics | starting test step 1-create-kafka-topics
I1208 08:16:56.870412    8630 request.go:682] Waited for 1.047991813s due to client-side throttling, not priority and fairness, request: GET:https://api.crc.testing:6443/apis/project.openshift.io/v1?timeout=32s
    logger.go:42: 08:16:58 | kafka/1-create-kafka-topics | KafkaTopic:kuttl-kafka/otlp-spans created
    logger.go:42: 08:16:59 | kafka/1-create-kafka-topics | test step completed 1-create-kafka-topics
    logger.go:42: 08:16:59 | kafka/2-otel-kakfa-receiver | starting test step 2-otel-kakfa-receiver
    logger.go:42: 08:17:01 | kafka/2-otel-kakfa-receiver | OpenTelemetryCollector:kuttl-kafka/kafka-receiver created
    logger.go:42: 08:17:05 | kafka/2-otel-kakfa-receiver | test step completed 2-otel-kakfa-receiver
    logger.go:42: 08:17:05 | kafka/3-otel-kakfa-exporter | starting test step 3-otel-kakfa-exporter
I1208 08:17:06.913834    8630 request.go:682] Waited for 1.398868555s due to client-side throttling, not priority and fairness, request: GET:https://api.crc.testing:6443/apis/operators.coreos.com/v1?timeout=32s
    logger.go:42: 08:17:07 | kafka/3-otel-kakfa-exporter | OpenTelemetryCollector:kuttl-kafka/kafka-exporter created
    logger.go:42: 08:17:11 | kafka/3-otel-kakfa-exporter | test step completed 3-otel-kakfa-exporter
    logger.go:42: 08:17:11 | kafka/4-generate-traces | starting test step 4-generate-traces
    logger.go:42: 08:17:14 | kafka/4-generate-traces | Job:kuttl-test-inviting-cat/telemetrygen-traces created
    logger.go:42: 08:17:52 | kafka/4-generate-traces | test step completed 4-generate-traces
    logger.go:42: 08:17:52 | kafka/5- | starting test step 5-
I1208 08:17:53.448738    8630 request.go:682] Waited for 1.048192256s due to client-side throttling, not priority and fairness, request: GET:https://api.crc.testing:6443/apis/packages.operators.coreos.com/v1?timeout=32s
    logger.go:42: 08:17:54 | kafka/5- | running command: [sh -c ./tests/e2e-openshift/kafka/check_traces.sh]
    logger.go:42: 08:17:54 | kafka/5- | "-> service.name: Str("kafka")" found in kafka-receiver-collector-6c8857c54c-mf6xx
    logger.go:42: 08:17:54 | kafka/5- | "-> test: Str(kuttl-kafka)" found in kafka-receiver-collector-6c8857c54c-mf6xx
    logger.go:42: 08:17:54 | kafka/5- | Traces with service name Kafka and attribute test=kuttl-kafka found.
    logger.go:42: 08:17:54 | kafka/5- | test step completed 5-
    logger.go:42: 08:17:54 | kafka | kafka events from ns kuttl-test-inviting-cat:
    logger.go:42: 08:17:54 | kafka | 2023-12-08 08:17:14 +0530 IST	Normal	Pod telemetrygen-traces-kfdfn		Scheduled	Successfully assigned kuttl-test-inviting-cat/telemetrygen-traces-kfdfn to crc-mmwz7-master-0		
    logger.go:42: 08:17:54 | kafka | 2023-12-08 08:17:14 +0530 IST	Normal	Job.batch telemetrygen-traces		SuccessfulCreate	Created pod: telemetrygen-traces-kfdfn		
    logger.go:42: 08:17:54 | kafka | 2023-12-08 08:17:16 +0530 IST	Normal	Pod telemetrygen-traces-kfdfn		AddedInterface	Add eth0 [10.217.0.147/23] from openshift-sdn		
    logger.go:42: 08:17:54 | kafka | 2023-12-08 08:17:16 +0530 IST	Normal	Pod telemetrygen-traces-kfdfn.spec.containers{telemetrygen-traces}		Pulling	Pulling image "ghcr.io/open-telemetry/opentelemetry-collector-contrib/telemetrygen:latest"		
    logger.go:42: 08:17:54 | kafka | 2023-12-08 08:17:17 +0530 IST	Normal	Pod telemetrygen-traces-kfdfn.spec.containers{telemetrygen-traces}		Pulled	Successfully pulled image "ghcr.io/open-telemetry/opentelemetry-collector-contrib/telemetrygen:latest" in 892.634803ms (892.646228ms including waiting)		
    logger.go:42: 08:17:54 | kafka | 2023-12-08 08:17:17 +0530 IST	Normal	Pod telemetrygen-traces-kfdfn.spec.containers{telemetrygen-traces}		Created	Created container telemetrygen-traces		
    logger.go:42: 08:17:54 | kafka | 2023-12-08 08:17:17 +0530 IST	Normal	Pod telemetrygen-traces-kfdfn.spec.containers{telemetrygen-traces}		Started	Started container telemetrygen-traces		
    logger.go:42: 08:17:54 | kafka | 2023-12-08 08:17:52 +0530 IST	Normal	Job.batch telemetrygen-traces		Completed	Job completed		
    logger.go:42: 08:17:55 | kafka | Deleting namespace: kuttl-test-inviting-cat
=== CONT  kuttl
    harness.go:405: run tests finished
    harness.go:513: cleaning up
    harness.go:570: removing temp folder: ""
--- PASS: kuttl (144.28s)
    --- PASS: kuttl/harness (0.00s)
        --- PASS: kuttl/harness/kafka (137.36s)
PASS

@IshwarKanse IshwarKanse requested a review from a team October 25, 2023 11:39
@swiatekm
Copy link
Contributor

I'm not sure whether the use case you're testing against is in scope for the operator. Don't get me wrong, this seems like a useful test if you wanted to verify end-to-end that sending telemetry through Kafka in K8s works as expected. But the operator has nothing to do with Kafka directly, so I'm not convinced we should be on the hook for failures in this kind of test.

WDYT @open-telemetry/operator-approvers ?

@jaronoff97
Copy link
Contributor

jaronoff97 commented Oct 25, 2023

adding to the SIG agenda for tomorrow

@IshwarKanse
Copy link
Contributor Author

cc @pavolloffay @iblancasa, this test case pertains to the Kafka support we're implementing. Given that the Kafka receiver and exporter are part of opentelemetry-collector-contrib, I concur with @swiatekm-sumo: this test case falls outside the scope of operator. It's worth noting that this test case is part of the e2e-openshift test suite and isn't executed within the project's CI pipeline but will be executed by OpenShift CI. Nevertheless, it serves as a valuable check for Kafka support, helping us identify any potential regressions in the feature. I'd appreciate hearing your thoughts on this. BTW I can move it to https://github.com/openshift/distributed-tracing-qe and run it with the OCP CI jobs, if the SIG decides not to include it in the project repository.

@bryan-aguilar
Copy link
Contributor

What is the expectation of the Operator maintainers if and when this test case fails?

@IshwarKanse
Copy link
Contributor Author

IshwarKanse commented Oct 27, 2023

@bryan-aguilar The e2e-openshift test suite is not run as part of the operator repo's CI. The test cases are OpenShift specific and the Operator maintainers wouldn't need to act upon any failures. If there is any regression in this Kafka feature, we need to reach out in https://github.com/open-telemetry/opentelemetry-collector-contrib to get it fixed.

@IshwarKanse
Copy link
Contributor Author

@pavolloffay @jaronoff97 Do we have any update from SIG, is it fine if we merge this in the e2e-openshift test suite ?

@pavolloffay
Copy link
Member

I don't mind merging this as it is tested in a separate OpenShift CI. However I would prefer to keep the test scoped to only Kafka - do not use Jaeger and prometheus.

@IshwarKanse
Copy link
Contributor Author

@pavolloffay Updated the test and removed dependency on Jaeger and Prometheus.

@IshwarKanse
Copy link
Contributor Author

$ kuttl test --timeout=180 --test=kafka tests/e2e-openshift/
2023/12/06 14:00:00 kutt-test config testdirs is overridden with args: [ tests/e2e-openshift/ ]
=== RUN   kuttl
    harness.go:462: starting setup
    harness.go:252: running tests using configured kubeconfig.
    harness.go:275: Successful connection to cluster at: https://api.REDACTED.openshift.com:6443
    harness.go:360: running tests
    harness.go:73: going to run test suite with timeout of 180 seconds for each step
    harness.go:372: testsuite: tests/e2e-openshift/ has 5 tests
=== RUN   kuttl/harness
=== RUN   kuttl/harness/kafka
=== PAUSE kuttl/harness/kafka
=== CONT  kuttl/harness/kafka
    logger.go:42: 14:00:02 | kafka | Ignoring check_traces.sh as it does not match file name regexp: ^(\d+)-(?:[^\.]+)(?:\.yaml)?$
    logger.go:42: 14:00:02 | kafka | Creating namespace: kuttl-test-kind-alpaca
    logger.go:42: 14:00:02 | kafka/0-create-kafka-instance | starting test step 0-create-kafka-instance
    logger.go:42: 14:00:04 | kafka/0-create-kafka-instance | Namespace:/kuttl-kafka created
    logger.go:42: 14:00:04 | kafka/0-create-kafka-instance | Kafka:kuttl-kafka/my-cluster created
    logger.go:42: 14:01:14 | kafka/0-create-kafka-instance | test step completed 0-create-kafka-instance
    logger.go:42: 14:01:14 | kafka/1-create-kafka-topics | starting test step 1-create-kafka-topics
    logger.go:42: 14:01:15 | kafka/1-create-kafka-topics | KafkaTopic:kuttl-kafka/otlp-spans created
    logger.go:42: 14:01:15 | kafka/1-create-kafka-topics | test step completed 1-create-kafka-topics
    logger.go:42: 14:01:15 | kafka/2-otel-kakfa-receiver | starting test step 2-otel-kakfa-receiver
    logger.go:42: 14:01:16 | kafka/2-otel-kakfa-receiver | OpenTelemetryCollector:kuttl-kafka/kafka-receiver created
    logger.go:42: 14:01:20 | kafka/2-otel-kakfa-receiver | test step completed 2-otel-kakfa-receiver
    logger.go:42: 14:01:20 | kafka/3-otel-kakfa-exporter | starting test step 3-otel-kakfa-exporter
    logger.go:42: 14:01:21 | kafka/3-otel-kakfa-exporter | OpenTelemetryCollector:kuttl-kafka/kafka-exporter created
    logger.go:42: 14:01:26 | kafka/3-otel-kakfa-exporter | test step completed 3-otel-kakfa-exporter
    logger.go:42: 14:01:26 | kafka/4-generate-traces | starting test step 4-generate-traces
    logger.go:42: 14:01:27 | kafka/4-generate-traces | Job:kuttl-test-kind-alpaca/telemetrygen-traces created
    logger.go:42: 14:02:03 | kafka/4-generate-traces | test step completed 4-generate-traces
    logger.go:42: 14:02:03 | kafka/5- | starting test step 5-
    logger.go:42: 14:02:04 | kafka/5- | running command: [sh -c ./tests/e2e-openshift/kafka/check_traces.sh]
    logger.go:42: 14:02:05 | kafka/5- | Searching in pod: kafka-receiver-collector-7df9bb6ddc-7w78g
    logger.go:42: 14:02:06 | kafka/5- | "Name           : lets-go" found in kafka-receiver-collector-7df9bb6ddc-7w78g
    logger.go:42: 14:02:07 | kafka/5- | "Name           : okey-dokey" found in kafka-receiver-collector-7df9bb6ddc-7w78g
    logger.go:42: 14:02:07 | kafka/5- | Both Spans were found in the pod logs.
    logger.go:42: 14:02:07 | kafka/5- | test step completed 5-
    logger.go:42: 14:02:07 | kafka | kafka events from ns kuttl-test-kind-alpaca:
    logger.go:42: 14:02:07 | kafka | 2023-12-06 14:01:27 +0530 IST	Normal	Pod telemetrygen-traces-9zc2m	Binding	Scheduled	Successfully assigned kuttl-test-kind-alpaca/telemetrygen-traces-9zc2m to ip-10-0-66-86.us-east-2.compute.internal	default-scheduler	
    logger.go:42: 14:02:07 | kafka | 2023-12-06 14:01:27 +0530 IST	Normal	Job.batch telemetrygen-traces		SuccessfulCreate	Created pod: telemetrygen-traces-9zc2m	job-controller	
    logger.go:42: 14:02:07 | kafka | 2023-12-06 14:01:29 +0530 IST	Normal	Pod telemetrygen-traces-9zc2m		AddedInterface	Add eth0 [10.131.0.107/23] from openshift-sdn		
    logger.go:42: 14:02:07 | kafka | 2023-12-06 14:01:29 +0530 IST	Normal	Pod telemetrygen-traces-9zc2m.spec.containers{telemetrygen-traces}		Pulling	Pulling image "ghcr.io/open-telemetry/opentelemetry-collector-contrib/telemetrygen:latest"	kubelet	
    logger.go:42: 14:02:07 | kafka | 2023-12-06 14:01:29 +0530 IST	Normal	Pod telemetrygen-traces-9zc2m.spec.containers{telemetrygen-traces}		Pulled	Successfully pulled image "ghcr.io/open-telemetry/opentelemetry-collector-contrib/telemetrygen:latest" in 190.23783ms (190.245652ms including waiting)kubelet	
    logger.go:42: 14:02:07 | kafka | 2023-12-06 14:01:29 +0530 IST	Normal	Pod telemetrygen-traces-9zc2m.spec.containers{telemetrygen-traces}		Created	Created container telemetrygen-traces	kubelet	
    logger.go:42: 14:02:07 | kafka | 2023-12-06 14:01:29 +0530 IST	Normal	Pod telemetrygen-traces-9zc2m.spec.containers{telemetrygen-traces}		Started	Started container telemetrygen-traces	kubelet	
    logger.go:42: 14:02:07 | kafka | 2023-12-06 14:02:03 +0530 IST	Normal	Job.batch telemetrygen-traces		Completed	Job completed	job-controller	
    logger.go:42: 14:02:09 | kafka | Deleting namespace: kuttl-test-kind-alpaca
=== CONT  kuttl
    harness.go:405: run tests finished
    harness.go:513: cleaning up
    harness.go:570: removing temp folder: ""
--- PASS: kuttl (135.94s)
    --- PASS: kuttl/harness (0.00s)
        --- PASS: kuttl/harness/kafka (133.46s)
PASS

LABEL_SELECTOR="app.kubernetes.io/instance=kuttl-kafka.kafka-receiver"

# Define the search strings
SEARCH_STRING1="Name : lets-go"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is the assertion working? Does it check the kafka stdout that contains traces? If that is the case is there a way to control attributes/service name/operation name of trace generator and use the same string in assertion?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its from the OTEL collector which has kafka receiver and exporting the traces via the debug exporter. https://github.com/open-telemetry/opentelemetry-operator/pull/2274/files#diff-712c49955ef631e30d16b4371d67b239c8793bba5aa500cbbe4d694fcebcf8d9R14 The script searches for the receiver otel pod and check the logs which the debug exporter has generated for the presence of traces.

Telemetrygen --> OTEL with OTLP receiver and Kafka exporter -->> Kafka instance -->> OTEL with Kafka receiver and debug exporter -->> Script checks the pods logs.

With this we do not have to ship the traces to a telemetry store and can test both the Kafka receiver and exporter in test case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want we can check other attributes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The format is not json for the debug exporter. https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/debugexporter/README.md#detailed-verbosity It would be nice if it can print json.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach is fine but I would prefer to assert on the attributes or service name that is explicitly set in the telemetrygen

      --telemetry-attributes map[string]string   Custom telemetry attributes to use. The value is expected in the format "key=\"value\"". Flag may be repeated to set multiple attributes (e.g --telemetry-attributes "key1=\"value1\"" --telemetry-attributes "key2=\"value2\"")

      --service string                           Service name to use (default "telemetrygen")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll change the assert and update the PR.

Copy link
Contributor Author

@IshwarKanse IshwarKanse Dec 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated and added the following attribute and service name to Telemetrygen:

        - "--otlp-attributes=test=\"kuttl-kafka\""
        - "--service=\"kafka\""

And check the same from the assert script:

logger.go:42: 08:17:54 | kafka/5- | running command: [sh -c ./tests/e2e-openshift/kafka/check_traces.sh]
logger.go:42: 08:17:54 | kafka/5- | "-> service.name: Str("kafka")" found in kafka-receiver-collector-6c8857c54c-mf6xx
logger.go:42: 08:17:54 | kafka/5- | "-> test: Str(kuttl-kafka)" found in kafka-receiver-collector-6c8857c54c-mf6xx
logger.go:42: 08:17:54 | kafka/5- | Traces with service name Kafka and attribute test=kuttl-kafka found.
logger.go:42: 08:17:54 | kafka/5- | test step completed 5-

@pavolloffay pavolloffay merged commit abcc30b into open-telemetry:main Dec 8, 2023
27 checks passed
@IshwarKanse IshwarKanse deleted the kafka branch April 11, 2024 09:08
ItielOlenick pushed a commit to ItielOlenick/opentelemetry-operator that referenced this pull request May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants