diff --git a/charts/zipkin/ci/dependencies-values.yaml b/charts/zipkin/ci/dependencies-values.yaml new file mode 100644 index 0000000..e659958 --- /dev/null +++ b/charts/zipkin/ci/dependencies-values.yaml @@ -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 diff --git a/charts/zipkin/templates/tests/test-connection.yaml b/charts/zipkin/templates/tests/test-connection.yaml index 58e7167..8a44bc8 100644 --- a/charts/zipkin/templates/tests/test-connection.yaml +++ b/charts/zipkin/templates/tests/test-connection.yaml @@ -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. diff --git a/charts/zipkin/values.schema.json b/charts/zipkin/values.schema.json index 3fedc53..28272ac 100644 --- a/charts/zipkin/values.schema.json +++ b/charts/zipkin/values.schema.json @@ -65,6 +65,9 @@ "fullnameOverride": { "type": "string" }, + "global": { + "type": "object" + }, "image": { "type": "object", "properties": { diff --git a/charts/zipkin/values.yaml b/charts/zipkin/values.yaml index 6d1ea37..12d66b5 100644 --- a/charts/zipkin/values.yaml +++ b/charts/zipkin/values.yaml @@ -129,3 +129,6 @@ extraServicePorts: [] # targetPort: 9410 # protocol: TCP # name: scribe + +# global variables to use in values. typically used in tests. +global: {}