Skip to content

Commit

Permalink
Adds dependencies test (#17)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
codefromthecrypt authored Feb 21, 2024
1 parent f80f8b4 commit 4be630b
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 1 deletion.
45 changes: 45 additions & 0 deletions charts/zipkin/ci/dependencies-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
global:
testDependencies: true

# extra containers are in the same pod, so this means zipkin is accessible to
# the example services by localhost (default)
extraContainers:
- name: frontend
image: 'ghcr.io/openzipkin/brave-example:armeria'
command: ['start-frontend']
ports:
- containerPort: 8081
env:
- name: 'ZIPKIN_BASEURL'
value: 'http://localhost:9411/'
- name: 'BACKEND_ENDPOINT'
value: 'http://localhost:9000/api'
readinessProbe:
httpGet:
path: /health
port: 8081
initialDelaySeconds: 5
periodSeconds: 5
- name: backend
image: 'ghcr.io/openzipkin/brave-example:armeria'
command: ['start-backend']
ports:
- containerPort: 9000
env:
- name: 'ZIPKIN_BASEURL'
value: 'http://localhost:9411/'
readinessProbe:
httpGet:
path: /health
port: 9000
initialDelaySeconds: 5
periodSeconds: 5

# test-connection runs in a different pod, so it can't hit the frontend unless
# we expose a service port.
extraServicePorts:
- port: 8081
targetPort: 8081
protocol: TCP
name: frontend
20 changes: 19 additions & 1 deletion charts/zipkin/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,31 @@ spec:
# Make sure zipkin registered in Eureka at startup
args: [ 'wget -q --spider http://{{ include "zipkin.fullname" . }}:8761/eureka/v2/apps/ZIPKIN' ]
{{- end }}
{{ if .Values.global.testDependencies }}
- name: get-frontend
image: "ghcr.io/openzipkin/alpine:3.19.1"
command: [ '/bin/sh', '-c' ]
args: # Get the frontend service 3 times, after it is ready
- >
while ! wget -q --spider http://{{ include "zipkin.fullname" . }}:8081/health;do sleep 1; done &&
for i in 1 2 3;do wget -q --spider http://{{ include "zipkin.fullname" . }}:8081; done
- name: get-dependencies
image: 'ghcr.io/openzipkin/alpine:3.19.1'
command: [ '/bin/sh', '-c' ]
args: # Sleep for the trace to process, then get dependencies based on it
- >
echo '[{"parent":"frontend","child":"backend","callCount":3}]' > want.json &&
sleep 3 &&
wget -qO have.json --header "b3: 0" http://{{ include "zipkin.fullname" . }}:{{ .Values.service.port }}/api/v2/dependencies?endTs=$(( $(date +%s) * 1000 )) &&
diff -b want.json have.json
{{ end }}
- name: get-api
image: "ghcr.io/openzipkin/alpine:3.19.1"
command: [ '/bin/sh', '-c' ]
# Get an arbitrary API endpoint using the ClusterIP and service port
args: [ 'wget -q --spider --header "b3: cafebabecafebabe-cafebabecafebabe-1" http://{{ include "zipkin.fullname" . }}:{{ .Values.service.port }}/api/v2/services' ]
{{- if .Values.zipkin.selfTracing.enabled }}
- name: get-trace
- name: get-self-trace
image: 'ghcr.io/openzipkin/alpine:3.19.1'
command: [ '/bin/sh', '-c' ]
# If self-tracing, sleep for the trace to process. Then, get it by the constant ID passed above.
Expand Down
3 changes: 3 additions & 0 deletions charts/zipkin/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
"fullnameOverride": {
"type": "string"
},
"global": {
"type": "object"
},
"image": {
"type": "object",
"properties": {
Expand Down
3 changes: 3 additions & 0 deletions charts/zipkin/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,6 @@ extraServicePorts: []
# targetPort: 9410
# protocol: TCP
# name: scribe

# global variables to use in values. typically used in tests.
global: {}

0 comments on commit 4be630b

Please sign in to comment.