Skip to content

Commit

Permalink
Add Namespace instrumentation e2e + uninstrumentation e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
damemi committed Dec 30, 2024
1 parent cc95664 commit 97d3821
Show file tree
Hide file tree
Showing 7 changed files with 343 additions and 17 deletions.
10 changes: 10 additions & 0 deletions tests/e2e/source/01-sources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ kind: Source
metadata:
name: frontend
namespace: default
labels:
odigos.io/e2e: source
spec:
workload:
name: frontend
Expand All @@ -14,6 +16,8 @@ kind: Source
metadata:
name: coupon
namespace: default
labels:
odigos.io/e2e: source
spec:
workload:
name: coupon
Expand All @@ -25,6 +29,8 @@ kind: Source
metadata:
name: inventory
namespace: default
labels:
odigos.io/e2e: source
spec:
workload:
name: inventory
Expand All @@ -36,6 +42,8 @@ kind: Source
metadata:
name: pricing
namespace: default
labels:
odigos.io/e2e: source
spec:
workload:
name: pricing
Expand All @@ -47,6 +55,8 @@ kind: Source
metadata:
name: membership
namespace: default
labels:
odigos.io/e2e: source
spec:
workload:
name: membership
Expand Down
12 changes: 12 additions & 0 deletions tests/e2e/source/02-source-ns.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: odigos.io/v1alpha1
kind: Source
metadata:
name: default
namespace: default
labels:
odigos.io/e2e: source
spec:
workload:
name: default
namespace: default
kind: Namespace
282 changes: 265 additions & 17 deletions tests/e2e/source/chainsaw-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,23 @@ spec:

- name: Install Demo App
try:
- script:
timeout: 200s
content: |
if [ "$MODE" != "cross-cloud-tests" ]; then
docker pull keyval/odigos-demo-inventory:v0.1
docker pull keyval/odigos-demo-membership:v0.1
docker pull keyval/odigos-demo-coupon:v0.1
docker pull keyval/odigos-demo-inventory:v0.1
docker pull keyval/odigos-demo-frontend:v0.2
kind load docker-image keyval/odigos-demo-inventory:v0.1
kind load docker-image keyval/odigos-demo-membership:v0.1
kind load docker-image keyval/odigos-demo-coupon:v0.1
kind load docker-image keyval/odigos-demo-inventory:v0.1
kind load docker-image keyval/odigos-demo-frontend:v0.2
else
echo "Skipping docker pull and kind load for cross-cloud-tests mode"
fi
# - script:
# timeout: 200s
# content: |
# if [ "$MODE" != "cross-cloud-tests" ]; then
# docker pull keyval/odigos-demo-inventory:v0.1
# docker pull keyval/odigos-demo-membership:v0.1
# docker pull keyval/odigos-demo-coupon:v0.1
# docker pull keyval/odigos-demo-inventory:v0.1
# docker pull keyval/odigos-demo-frontend:v0.2
# kind load docker-image keyval/odigos-demo-inventory:v0.1
# kind load docker-image keyval/odigos-demo-membership:v0.1
# kind load docker-image keyval/odigos-demo-coupon:v0.1
# kind load docker-image keyval/odigos-demo-inventory:v0.1
# kind load docker-image keyval/odigos-demo-frontend:v0.2
# else
# echo "Skipping docker pull and kind load for cross-cloud-tests mode"
# fi
- apply:
file: ../../common/apply/install-simple-demo.yaml
- script:
Expand Down Expand Up @@ -148,3 +148,251 @@ spec:
- podLogs:
name: odiglet
namespace: odigos-system
- name: Uninstrument individual deployments
try:
- delete:
ref:
apiVersion: odigos.io/v1alpha1
kind: Source
namespace: default
labels:
odigos.io/e2e: source
expect:
- match:
apiVersion: odigos.io/v1alpha1
kind: InstrumentationConfig
metadata:
name: deployment-coupon
namespace: default
check:
($error != null): true
- match:
apiVersion: odigos.io/v1alpha1
kind: InstrumentationConfig
metadata:
name: deployment-frontend
namespace: default
check:
($error != null): true
- match:
apiVersion: odigos.io/v1alpha1
kind: InstrumentationConfig
metadata:
name: deployment-inventory
namespace: default
check:
($error != null): true
- match:
apiVersion: odigos.io/v1alpha1
kind: InstrumentationConfig
metadata:
name: deployment-membership
namespace: default
check:
($error != null): true
- match:
apiVersion: odigos.io/v1alpha1
kind: InstrumentationConfig
metadata:
name: deployment-pricing
namespace: default
check:
($error != null): true
- match:
apiVersion: odigos.io/v1alpha1
kind: InstrumentedApplication
metadata:
name: deployment-coupon
namespace: default
check:
($error != null): true
- match:
apiVersion: odigos.io/v1alpha1
kind: InstrumentedApplication
metadata:
name: deployment-frontend
namespace: default
check:
($error != null): true
- match:
apiVersion: odigos.io/v1alpha1
kind: InstrumentedApplication
metadata:
name: deployment-inventory
namespace: default
check:
($error != null): true
- match:
apiVersion: odigos.io/v1alpha1
kind: InstrumentedApplication
metadata:
name: deployment-membership
namespace: default
check:
($error != null): true
- match:
apiVersion: odigos.io/v1alpha1
kind: InstrumentedApplication
metadata:
name: deployment-pricing
namespace: default
check:
($error != null): true
- name: Instrument Namespace
try:
- apply:
file: 02-source-ns.yaml
- name: Assert Runtime Detected
try:
- assert:
timeout: 2m
file: ../../common/assert/simple-demo-runtime-detected.yaml
- name: Generate Traffic
try:
- script:
timeout: 300s
content: |
# Apply the job
kubectl apply -f ../../common/apply/generate-traffic-job.yaml
# Wait for the job to complete
job_name=$(kubectl get -f ../../common/apply/generate-traffic-job.yaml -o=jsonpath='{.metadata.name}')
kubectl wait --for=condition=complete job/$job_name
# Delete the job
kubectl delete -f ../../common/apply/generate-traffic-job.yaml
while true; do
# wait for traces to be available
sleep 8
# Run the wait-for-trace script
echo "Running TraceQL test at $(date)"
../../common/traceql_runner.sh tracesql/wait-for-trace-2.yaml
if [ $? -eq 0 ]; then
break
else
../../common/flush_traces.sh
sleep 5
fi
done
- name: Verify Trace - Context Propagation
try:
- script:
timeout: 30s
content: |
../../common/traceql_runner.sh tracesql/context-propagation-2.yaml
catch:
- podLogs:
name: odiglet
namespace: odigos-system
- name: Verify Trace - Resource Attributes
try:
- script:
content: |
../../common/traceql_runner.sh tracesql/resource-attributes-2.yaml
catch:
- podLogs:
name: odiglet
namespace: odigos-system
- name: Verify Trace - Span Attributes
try:
- script:
timeout: 60s
content: |
../../common/traceql_runner.sh tracesql/span-attributes-2.yaml
catch:
- podLogs:
name: odiglet
namespace: odigos-system
- name: Uninstrument namespace
try:
- delete:
ref:
apiVersion: odigos.io/v1alpha1
kind: Source
namespace: default
labels:
odigos.io/e2e: source
expect:
- match:
apiVersion: odigos.io/v1alpha1
kind: InstrumentationConfig
metadata:
name: deployment-coupon
namespace: default
check:
($error != null): true
- match:
apiVersion: odigos.io/v1alpha1
kind: InstrumentationConfig
metadata:
name: deployment-frontend
namespace: default
check:
($error != null): true
- match:
apiVersion: odigos.io/v1alpha1
kind: InstrumentationConfig
metadata:
name: deployment-inventory
namespace: default
check:
($error != null): true
- match:
apiVersion: odigos.io/v1alpha1
kind: InstrumentationConfig
metadata:
name: deployment-membership
namespace: default
check:
($error != null): true
- match:
apiVersion: odigos.io/v1alpha1
kind: InstrumentationConfig
metadata:
name: deployment-pricing
namespace: default
check:
($error != null): true
- match:
apiVersion: odigos.io/v1alpha1
kind: InstrumentedApplication
metadata:
name: deployment-coupon
namespace: default
check:
($error != null): true
- match:
apiVersion: odigos.io/v1alpha1
kind: InstrumentedApplication
metadata:
name: deployment-frontend
namespace: default
check:
($error != null): true
- match:
apiVersion: odigos.io/v1alpha1
kind: InstrumentedApplication
metadata:
name: deployment-inventory
namespace: default
check:
($error != null): true
- match:
apiVersion: odigos.io/v1alpha1
kind: InstrumentedApplication
metadata:
name: deployment-membership
namespace: default
check:
($error != null): true
- match:
apiVersion: odigos.io/v1alpha1
kind: InstrumentedApplication
metadata:
name: deployment-pricing
namespace: default
check:
($error != null): true
13 changes: 13 additions & 0 deletions tests/e2e/source/tracesql/context-propagation-2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: e2e.tests.odigos.io/v1
kind: TraceTest
description: This test checks if the context propagation is working correctly between different languages
query: |
{ resource.service.name = "frontend" && resource.telemetry.sdk.language = "java" &&
span.http.request.method = "POST" && span.http.route = "/buy" && span:kind = server }
>> (
{ resource.service.name = "pricing" && resource.telemetry.sdk.language = "dotnet" } &&
{ resource.service.name = "inventory" && resource.telemetry.sdk.language = "python" } &&
({ resource.service.name = "coupon" && resource.telemetry.sdk.language = "nodejs" }
>> { resource.service.name = "membership" && resource.telemetry.sdk.language = "go" }))
expected:
count: 2
14 changes: 14 additions & 0 deletions tests/e2e/source/tracesql/resource-attributes-2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: e2e.tests.odigos.io/v1
kind: TraceTest
description: |
This test check the following resource attributes:
A. odigos.version attribute exists on all spans and has the correct value
B. Kubernetes attributes are correctly set on all spans
At the time of writing this test, TraceQL api does not support not equal to nil so we use regex instead.
query: |
{ resource.odigos.version !~ ".*" ||
resource.k8s.deployment.name !~ ".*" ||
resource.k8s.node.name !~ "(kind-control-plane|aks-.*)" ||
resource.k8s.pod.name !~ ".*" }
expected:
count: 0
Loading

0 comments on commit 97d3821

Please sign in to comment.