Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds dependencies test #17

Merged
merged 2 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

used a global here as cycling through a list of objects to pick if "frontend" is there, is quite complicated in helm. maps are easier than lists

- 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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The follow-up is.. we'll need a conditional here to invoke the dependencies cron job synchronously, when elasticsearch.

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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes I code go ;)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
diff -b want.json have.json
diff -b want.json got.json

Just kidding

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha true.. I'm not that go ;)

{{ 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: {}
Loading