forked from openshift/distributed-tracing-qe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request openshift#48 from IshwarKanse/transform
Add test case for Transform processor
- Loading branch information
Showing
9 changed files
with
239 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
apiVersion: chainsaw.kyverno.io/v1alpha1 | ||
kind: Test | ||
metadata: | ||
name: transformprocessor | ||
spec: | ||
namespace: chainsaw-tprocssr | ||
steps: | ||
- name: Create Tempo monolithic instances | ||
try: | ||
- apply: | ||
file: install-tempo.yaml | ||
- assert: | ||
file: install-tempo-assert.yaml | ||
- name: Create OTEL collector instance | ||
try: | ||
- apply: | ||
file: otel-collector.yaml | ||
- assert: | ||
file: otel-collector-assert.yaml | ||
- name: Generate and send traces to the OTEL collector | ||
try: | ||
- apply: | ||
file: generate-traces.yaml | ||
- assert: | ||
file: generate-traces-assert.yaml | ||
- name: Verify traces in the Tempo instances | ||
try: | ||
- apply: | ||
file: verify-traces.yaml | ||
- assert: | ||
file: verify-traces-assert.yaml |
7 changes: 7 additions & 0 deletions
7
tests/e2e-otel/transformprocessor/generate-traces-assert.yaml
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,7 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: generate-traces-green | ||
namespace: chainsaw-tprocssr | ||
status: | ||
succeeded: 1 |
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,20 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: generate-traces-green | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: telemetrygen | ||
image: ghcr.io/open-telemetry/opentelemetry-collector-contrib/telemetrygen:v0.92.0 | ||
args: | ||
- traces | ||
- --otlp-endpoint=tprocssr-collector.chainsaw-tprocssr.svc:4317 | ||
- --otlp-insecure=true | ||
- --traces=1 | ||
- --service=green | ||
- --otlp-attributes=X-Tenant="green" | ||
- --otlp-attributes=generator="green-1" | ||
restartPolicy: Never | ||
backoffLimit: 4 |
52 changes: 52 additions & 0 deletions
52
tests/e2e-otel/transformprocessor/install-tempo-assert.yaml
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,52 @@ | ||
apiVersion: apps/v1 | ||
kind: StatefulSet | ||
metadata: | ||
name: tempo-tprocssr | ||
namespace: chainsaw-tprocssr | ||
status: | ||
availableReplicas: 1 | ||
readyReplicas: 1 | ||
replicas: 1 | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Pod | ||
metadata: | ||
name: tempo-tprocssr-0 | ||
namespace: chainsaw-tprocssr | ||
status: | ||
containerStatuses: | ||
- name: tempo | ||
ready: true | ||
started: true | ||
- name: tempo-query | ||
ready: true | ||
started: true | ||
phase: Running | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: tempo-tprocssr-jaegerui | ||
namespace: chainsaw-tprocssr | ||
spec: | ||
ports: | ||
- name: jaeger-grpc | ||
port: 16685 | ||
protocol: TCP | ||
targetPort: jaeger-grpc | ||
- name: jaeger-ui | ||
port: 16686 | ||
protocol: TCP | ||
targetPort: jaeger-ui | ||
- name: jaeger-metrics | ||
port: 16687 | ||
protocol: TCP | ||
targetPort: jaeger-metrics | ||
selector: | ||
app.kubernetes.io/component: tempo | ||
app.kubernetes.io/instance: tprocssr | ||
app.kubernetes.io/managed-by: tempo-operator | ||
app.kubernetes.io/name: tempo-monolithic | ||
|
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,9 @@ | ||
apiVersion: tempo.grafana.com/v1alpha1 | ||
kind: TempoMonolithic | ||
metadata: | ||
name: tprocssr | ||
spec: | ||
jaegerui: | ||
enabled: true | ||
route: | ||
enabled: true |
28 changes: 28 additions & 0 deletions
28
tests/e2e-otel/transformprocessor/otel-collector-assert.yaml
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 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: tprocssr-collector | ||
namespace: chainsaw-tprocssr | ||
status: | ||
availableReplicas: 1 | ||
readyReplicas: 1 | ||
replicas: 1 | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: tprocssr-collector | ||
namespace: chainsaw-tprocssr | ||
spec: | ||
ports: | ||
- appProtocol: grpc | ||
name: otlp-grpc | ||
port: 4317 | ||
protocol: TCP | ||
targetPort: 4317 | ||
selector: | ||
app.kubernetes.io/component: opentelemetry-collector | ||
app.kubernetes.io/instance: chainsaw-tprocssr.tprocssr | ||
app.kubernetes.io/managed-by: opentelemetry-operator | ||
app.kubernetes.io/part-of: opentelemetry |
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,43 @@ | ||
apiVersion: opentelemetry.io/v1beta1 | ||
kind: OpenTelemetryCollector | ||
metadata: | ||
name: tprocssr | ||
spec: | ||
image: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-contrib:0.103.1 | ||
config: | ||
receivers: | ||
otlp: | ||
protocols: | ||
grpc: {} | ||
|
||
exporters: | ||
otlp: | ||
endpoint: tempo-tprocssr.chainsaw-tprocssr.svc:4317 | ||
tls: | ||
insecure: true | ||
|
||
processors: | ||
transform: | ||
error_mode: ignore | ||
trace_statements: | ||
- context: resource | ||
statements: | ||
- keep_keys(attributes, ["service.name", "X-Tenant", "otel.library.name"]) | ||
- set(attributes["X-Tenant"], "blue") where attributes["X-Tenant"] == "green" | ||
- limit(attributes, 100, []) | ||
- truncate_all(attributes, 4096) | ||
- context: span | ||
statements: | ||
- set(attributes["net.peer.ip"], "5.6.7.8") where attributes["net.peer.ip"] == "1.2.3.4" | ||
- set(attributes["peer.service"], "modified-server") where attributes["peer.service"] == "telemetrygen-server" | ||
- set(attributes["peer.service"], "modified-client") where attributes["peer.service"] == "telemetrygen-client" | ||
- set(name, "modified-operation") where name == "okey-dokey" | ||
- limit(attributes, 100, []) | ||
- truncate_all(attributes, 4096) | ||
|
||
service: | ||
pipelines: | ||
traces: | ||
receivers: [otlp] | ||
processors: [transform] | ||
exporters: [otlp] |
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,7 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: verify-traces | ||
namespace: chainsaw-tprocssr | ||
status: | ||
succeeded: 1 |
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,42 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: verify-traces | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: verify-traces-green | ||
image: ghcr.io/grafana/tempo-operator/test-utils:main | ||
command: | ||
- /bin/bash | ||
- -eux | ||
- -c | ||
args: | ||
- | | ||
TRACE_JSON=$(curl -s -G http://tempo-tprocssr-jaegerui.chainsaw-tprocssr.svc:16686/api/traces --data-urlencode "service=green") | ||
VALIDATE=$(echo $TRACE_JSON | jq ' | ||
.data[] | | ||
select( | ||
.spans[] | | ||
( | ||
(.operationName == "modified-operation") and | ||
(.tags[] | select(.key == "net.peer.ip" and .value == "5.6.7.8")) and | ||
(.tags[] | select(.key == "peer.service" and .value == "modified-client")) | ||
) | ||
) and | ||
( | ||
.processes[] | | ||
( | ||
(.tags[] | select(.key == "X-Tenant" and .value == "blue")) and | ||
(.tags[] | select(.key == "otel.library.name" and .value == "telemetrygen")) | ||
) | ||
) | ||
') | ||
if [ -n "$VALIDATE" ]; then | ||
echo "Validation passed: The trace values match the transform processor settings." | ||
else | ||
echo "Validation failed: The trace values do not match the transform processor settings." | ||
exit 1 | ||
fi | ||
restartPolicy: Never |