Skip to content

Commit b385810

Browse files
committed
don't modify the existing chainsaw test
1 parent 6e3d2a0 commit b385810

8 files changed

+126
-7
lines changed

tests/e2e/env-vars/00-install-instrumentation.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,3 @@ metadata:
55
spec:
66
exporter:
77
endpoint: http://localhost:4317
8-
defaults:
9-
useLabelsForResourceAttributes: true
10-

tests/e2e/env-vars/01-assert.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ spec:
2121
apiVersion: v1
2222
fieldPath: status.podIP
2323
- name: OTEL_SERVICE_NAME
24-
value: my-app
24+
value: my-deploy
2525
- name: OTEL_EXPORTER_OTLP_ENDPOINT
2626
value: http://localhost:4317
2727
- name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME
@@ -36,7 +36,6 @@ spec:
3636
fieldPath: spec.nodeName
3737
- name: OTEL_RESOURCE_ATTRIBUTES
3838
value:
39-
( contains(@, 'foo=bar') ): true
4039
( contains(@, 'k8s.container.name=myapp') ): true
4140
( contains(@, 'k8s.pod.name=$(OTEL_RESOURCE_ATTRIBUTES_POD_NAME)') ): true
4241
( contains(@, 'k8s.replicaset.name=my-deploy-') ): true

tests/e2e/env-vars/01-deployment.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ spec:
1111
metadata:
1212
labels:
1313
app: my-deploy
14-
app.kubernetes.io/name: my-app
1514
annotations:
1615
sidecar.opentelemetry.io/inject: "true"
1716
instrumentation.opentelemetry.io/inject-sdk: "true"
18-
resource.opentelemetry.io/foo: "bar"
1917
spec:
2018
containers:
2119
- name: myapp
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: opentelemetry.io/v1alpha1
2+
kind: OpenTelemetryCollector
3+
metadata:
4+
name: sidecar
5+
spec:
6+
config: |
7+
receivers:
8+
otlp:
9+
protocols:
10+
grpc:
11+
http:
12+
processors:
13+
14+
exporters:
15+
debug:
16+
17+
service:
18+
pipelines:
19+
traces:
20+
receivers: [otlp]
21+
exporters: [debug]
22+
mode: sidecar
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
apiVersion: opentelemetry.io/v1alpha1
2+
kind: Instrumentation
3+
metadata:
4+
name: sdk-only
5+
spec:
6+
exporter:
7+
endpoint: http://localhost:4317
8+
defaults:
9+
useLabelsForResourceAttributes: true
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
apiVersion: v1
2+
kind: Pod
3+
metadata:
4+
annotations:
5+
instrumentation.opentelemetry.io/inject-sdk: "true"
6+
sidecar.opentelemetry.io/inject: "true"
7+
labels:
8+
app: my-deploy
9+
spec:
10+
(containers[?name == 'myapp']):
11+
- name: myapp
12+
env:
13+
- name: OTEL_NODE_IP
14+
valueFrom:
15+
fieldRef:
16+
apiVersion: v1
17+
fieldPath: status.hostIP
18+
- name: OTEL_POD_IP
19+
valueFrom:
20+
fieldRef:
21+
apiVersion: v1
22+
fieldPath: status.podIP
23+
- name: OTEL_SERVICE_NAME
24+
value: my-app
25+
- name: OTEL_EXPORTER_OTLP_ENDPOINT
26+
value: http://localhost:4317
27+
- name: OTEL_RESOURCE_ATTRIBUTES_POD_NAME
28+
valueFrom:
29+
fieldRef:
30+
apiVersion: v1
31+
fieldPath: metadata.name
32+
- name: OTEL_RESOURCE_ATTRIBUTES_NODE_NAME
33+
valueFrom:
34+
fieldRef:
35+
apiVersion: v1
36+
fieldPath: spec.nodeName
37+
- name: OTEL_RESOURCE_ATTRIBUTES
38+
value:
39+
( contains(@, 'foo=bar') ): true
40+
( contains(@, 'k8s.container.name=myapp') ): true
41+
( contains(@, 'k8s.pod.name=$(OTEL_RESOURCE_ATTRIBUTES_POD_NAME)') ): true
42+
( contains(@, 'k8s.replicaset.name=my-deploy-') ): true
43+
( contains(@, 'k8s.deployment.name=my-deploy') ): true
44+
( contains(@, concat('k8s.namespace.name=', $namespace)) ): true
45+
( contains(@, 'k8s.node.name=$(OTEL_RESOURCE_ATTRIBUTES_NODE_NAME)') ): true
46+
( contains(@, join('', ['service.instance.id=', $namespace, '.$(OTEL_RESOURCE_ATTRIBUTES_POD_NAME).myapp']) ) ): true
47+
( contains(@, 'service.version=main') ): true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: my-deploy
5+
spec:
6+
selector:
7+
matchLabels:
8+
app: my-deploy
9+
replicas: 1
10+
template:
11+
metadata:
12+
labels:
13+
app: my-deploy
14+
app.kubernetes.io/name: my-app
15+
annotations:
16+
sidecar.opentelemetry.io/inject: "true"
17+
instrumentation.opentelemetry.io/inject-sdk: "true"
18+
resource.opentelemetry.io/foo: "bar"
19+
spec:
20+
containers:
21+
- name: myapp
22+
image: ghcr.io/open-telemetry/opentelemetry-operator/e2e-test-app-python:main
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json
2+
apiVersion: chainsaw.kyverno.io/v1alpha1
3+
kind: Test
4+
metadata:
5+
creationTimestamp: null
6+
name: env-vars
7+
spec:
8+
steps:
9+
- name: step-00
10+
try:
11+
- apply:
12+
file: 00-install-collector.yaml
13+
- apply:
14+
file: 00-install-instrumentation.yaml
15+
# Deployment
16+
- name: step-01
17+
try:
18+
- apply:
19+
file: 01-deployment.yaml
20+
- assert:
21+
file: 01-assert.yaml
22+
catch:
23+
- podLogs:
24+
selector: app=my-deploy

0 commit comments

Comments
 (0)