Skip to content

Commit 4be630b

Browse files
Adds dependencies test (#17)
This adds a dependencies test, which will need further refactoring to support storage types that require dependency-aggregation. However, this works and keeps the first pass small. Signed-off-by: Adrian Cole <[email protected]>
1 parent f80f8b4 commit 4be630b

File tree

4 files changed

+70
-1
lines changed

4 files changed

+70
-1
lines changed
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
global:
3+
testDependencies: true
4+
5+
# extra containers are in the same pod, so this means zipkin is accessible to
6+
# the example services by localhost (default)
7+
extraContainers:
8+
- name: frontend
9+
image: 'ghcr.io/openzipkin/brave-example:armeria'
10+
command: ['start-frontend']
11+
ports:
12+
- containerPort: 8081
13+
env:
14+
- name: 'ZIPKIN_BASEURL'
15+
value: 'http://localhost:9411/'
16+
- name: 'BACKEND_ENDPOINT'
17+
value: 'http://localhost:9000/api'
18+
readinessProbe:
19+
httpGet:
20+
path: /health
21+
port: 8081
22+
initialDelaySeconds: 5
23+
periodSeconds: 5
24+
- name: backend
25+
image: 'ghcr.io/openzipkin/brave-example:armeria'
26+
command: ['start-backend']
27+
ports:
28+
- containerPort: 9000
29+
env:
30+
- name: 'ZIPKIN_BASEURL'
31+
value: 'http://localhost:9411/'
32+
readinessProbe:
33+
httpGet:
34+
path: /health
35+
port: 9000
36+
initialDelaySeconds: 5
37+
periodSeconds: 5
38+
39+
# test-connection runs in a different pod, so it can't hit the frontend unless
40+
# we expose a service port.
41+
extraServicePorts:
42+
- port: 8081
43+
targetPort: 8081
44+
protocol: TCP
45+
name: frontend

charts/zipkin/templates/tests/test-connection.yaml

+19-1
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,31 @@ spec:
1616
# Make sure zipkin registered in Eureka at startup
1717
args: [ 'wget -q --spider http://{{ include "zipkin.fullname" . }}:8761/eureka/v2/apps/ZIPKIN' ]
1818
{{- end }}
19+
{{ if .Values.global.testDependencies }}
20+
- name: get-frontend
21+
image: "ghcr.io/openzipkin/alpine:3.19.1"
22+
command: [ '/bin/sh', '-c' ]
23+
args: # Get the frontend service 3 times, after it is ready
24+
- >
25+
while ! wget -q --spider http://{{ include "zipkin.fullname" . }}:8081/health;do sleep 1; done &&
26+
for i in 1 2 3;do wget -q --spider http://{{ include "zipkin.fullname" . }}:8081; done
27+
- name: get-dependencies
28+
image: 'ghcr.io/openzipkin/alpine:3.19.1'
29+
command: [ '/bin/sh', '-c' ]
30+
args: # Sleep for the trace to process, then get dependencies based on it
31+
- >
32+
echo '[{"parent":"frontend","child":"backend","callCount":3}]' > want.json &&
33+
sleep 3 &&
34+
wget -qO have.json --header "b3: 0" http://{{ include "zipkin.fullname" . }}:{{ .Values.service.port }}/api/v2/dependencies?endTs=$(( $(date +%s) * 1000 )) &&
35+
diff -b want.json have.json
36+
{{ end }}
1937
- name: get-api
2038
image: "ghcr.io/openzipkin/alpine:3.19.1"
2139
command: [ '/bin/sh', '-c' ]
2240
# Get an arbitrary API endpoint using the ClusterIP and service port
2341
args: [ 'wget -q --spider --header "b3: cafebabecafebabe-cafebabecafebabe-1" http://{{ include "zipkin.fullname" . }}:{{ .Values.service.port }}/api/v2/services' ]
2442
{{- if .Values.zipkin.selfTracing.enabled }}
25-
- name: get-trace
43+
- name: get-self-trace
2644
image: 'ghcr.io/openzipkin/alpine:3.19.1'
2745
command: [ '/bin/sh', '-c' ]
2846
# If self-tracing, sleep for the trace to process. Then, get it by the constant ID passed above.

charts/zipkin/values.schema.json

+3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
"fullnameOverride": {
6666
"type": "string"
6767
},
68+
"global": {
69+
"type": "object"
70+
},
6871
"image": {
6972
"type": "object",
7073
"properties": {

charts/zipkin/values.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -129,3 +129,6 @@ extraServicePorts: []
129129
# targetPort: 9410
130130
# protocol: TCP
131131
# name: scribe
132+
133+
# global variables to use in values. typically used in tests.
134+
global: {}

0 commit comments

Comments
 (0)