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

Actually e2e test java #3381

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ KUSTOMIZE_VERSION ?= v5.0.3
CONTROLLER_TOOLS_VERSION ?= v0.16.1
GOLANGCI_LINT_VERSION ?= v1.57.2
KIND_VERSION ?= v0.20.0
CHAINSAW_VERSION ?= v0.2.8
CHAINSAW_VERSION ?= v0.2.11
Copy link
Member

Choose a reason for hiding this comment

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

this version does not work on go 1.22. I would wait with updating before we upgrade the go version

Copy link
Contributor

Choose a reason for hiding this comment

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

If that's a concern for us, we should install it by downloading the release binary instead. Our supported Go version shouldn't get in the way of tooling upgrades.


.PHONY: install-tools
install-tools: kustomize golangci-lint kind controller-gen envtest crdoc kind operator-sdk chainsaw
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ spec:
traces:
receivers: [otlp]
exporters: [debug]
metrics:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

java auto inst can send metrics too, why not accept them :)

Copy link
Member

Choose a reason for hiding this comment

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

+1

receivers: [otlp]
exporters: [debug]
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ spec:
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: http://localhost:4317
- name: OTEL_EXPORTER_OTLP_TIMEOUT
value: "20"
value: "20000"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is to account for the collector not being ready fast enough

Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if it's not ready? Shouldn't this work correctly either way?

- name: OTEL_TRACES_SAMPLER
value: parentbased_traceidratio
- name: OTEL_TRACES_SAMPLER_ARG
value: "0.85"
value: always_on
Copy link
Contributor Author

Choose a reason for hiding this comment

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

don't want our test data to be sampled

- name: SPLUNK_TRACE_RESPONSE_HEADER_ENABLED
value: "true"
exporter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ spec:
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: http://localhost:4317
- name: OTEL_EXPORTER_OTLP_TIMEOUT
value: "20"
value: "20000"
- name: OTEL_TRACES_SAMPLER
value: parentbased_traceidratio
- name: OTEL_TRACES_SAMPLER_ARG
value: "0.85"
value: always_on
- name: SPLUNK_TRACE_RESPONSE_HEADER_ENABLED
value: "true"
- name: OTEL_SERVICE_NAME
Expand Down Expand Up @@ -81,11 +79,9 @@ spec:
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: http://localhost:4317
- name: OTEL_EXPORTER_OTLP_TIMEOUT
value: "20"
value: "20000"
- name: OTEL_TRACES_SAMPLER
value: parentbased_traceidratio
- name: OTEL_TRACES_SAMPLER_ARG
value: "0.85"
value: always_on
- name: SPLUNK_TRACE_RESPONSE_HEADER_ENABLED
value: "true"
- name: OTEL_SERVICE_NAME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ spec:
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: http://localhost:4317
- name: OTEL_EXPORTER_OTLP_TIMEOUT
value: "20"
value: "20000"
- name: OTEL_TRACES_SAMPLER
value: parentbased_traceidratio
- name: OTEL_TRACES_SAMPLER_ARG
value: "0.85"
value: always_on
- name: SPLUNK_TRACE_RESPONSE_HEADER_ENABLED
value: "true"
- name: OTEL_SERVICE_NAME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,37 @@ spec:
catch:
- podLogs:
selector: app=my-java-multi
- name: "wait for app to be ready"
try:
- sleep:
duration: 5s
- name: Make a request to the app
try:
- script:
content: |
#!/bin/bash
# set -ex
pod=$(kubectl get pods -n $NAMESPACE | awk '{print $1}' | tail -n 1)
kubectl get --raw /api/v1/namespaces/$NAMESPACE/pods/${pod}:8080/proxy/
Copy link
Member

Choose a reason for hiding this comment

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

this is new to me :)

@IshwarKanse does it work on OCP?

Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at this, I really wonder if we shouldn't use e2e_framework and/or terratest for these tests. The main problem is really getting data out of the cluster, as we don't have a remote we can easily query. I can think of a few solutions to do this in kind, but they won't work on OpenShift. It'd be best if these could simply be Go tests we could run on a host against any cluster.

Copy link
Contributor

Choose a reason for hiding this comment

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

This can be implemented natively using Chainsaw
and avoid using the script. https://github.com/kyverno/chainsaw/blob/main/testdata/e2e/examples/proxy/chainsaw-test.yaml

We were also discussing on implementing some kind of custom store in Chainsaw which gathers all the signals and would be useful for asserting. https://docs.google.com/document/d/1G4uDMrC3okF2q2qyNYTg2qj7yxNBjSTGgn8pBEXEeiw/edit#heading=h.8mm7ay5rgjs6

@eddycharly Do we have any decision on what custom store we can use for testing observability data. ?

check:
($error): ~
($stdout): Hello World!
- name: "wait for the telemetry to be there"
try:
- sleep:
duration: 5s
- name: Check the sidecar has sent request data successfully
try:
- script:
content: |
#!/bin/bash
# set -ex
pod=$(kubectl get pods -n $NAMESPACE | awk '{print $1}' | tail -n 1)
kubectl get --raw /api/v1/namespaces/$NAMESPACE/pods/${pod}:8888/proxy/metrics
check:
($error): ~
# TODO: Check that the number is non-zero and that failed is zero
(wildcard('*otelcol_exporter_sent_spans*', $stdout)): true
catch:
- podLogs:
selector: app=my-java-multi
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ spec:
traces:
receivers: [otlp]
exporters: [debug]
metrics:
receivers: [otlp]
exporters: [debug]
mode: sidecar
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,9 @@ spec:
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: http://localhost:4317
- name: OTEL_EXPORTER_OTLP_TIMEOUT
value: "20"
value: "20000"
- name: OTEL_TRACES_SAMPLER
value: parentbased_traceidratio
- name: OTEL_TRACES_SAMPLER_ARG
value: "0.85"
value: always_on
- name: SPLUNK_TRACE_RESPONSE_HEADER_ENABLED
value: "true"
exporter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ spec:
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: http://localhost:4317
- name: OTEL_EXPORTER_OTLP_TIMEOUT
value: "20"
value: "20000"
- name: OTEL_TRACES_SAMPLER
value: parentbased_traceidratio
- name: OTEL_TRACES_SAMPLER_ARG
value: "0.85"
value: always_on
- name: SPLUNK_TRACE_RESPONSE_HEADER_ENABLED
value: "true"
- name: OTEL_SERVICE_NAME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,40 @@ spec:
catch:
- podLogs:
selector: app=my-java-other-ns
- name: "wait for app to be ready"
try:
- sleep:
duration: 5s
- name: Make a request to the app
try:
- script:
content: |
#!/bin/bash
# set -ex
pod=$(kubectl get pods -n $NAMESPACE | awk '{print $1}' | tail -n 1)
kubectl get --raw /api/v1/namespaces/$NAMESPACE/pods/${pod}:8080/proxy/
check:
($error): ~
($stdout): Hello World!
- name: "wait for the telemetry to be there"
try:
- sleep:
duration: 5s
- name: Check the sidecar has sent request data successfully
try:
- script:
content: |
#!/bin/bash
# set -ex
pod=$(kubectl get pods -n $NAMESPACE | awk '{print $1}' | tail -n 1)
kubectl get --raw /api/v1/namespaces/$NAMESPACE/pods/${pod}:8888/proxy/metrics
check:
($error): ~
# TODO: Check that the number is non-zero and that failed is zero
(wildcard('*otelcol_exporter_sent_spans*', $stdout)): true
catch:
- podLogs:
selector: app=my-java-other-ns
- name: step-04
try:
- delete:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ spec:
traces:
receivers: [otlp]
exporters: [debug]
metrics:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

i was going to attempt the TLS test, but it seemed way too hard to do on a first-pass

receivers: [otlp]
exporters: [debug]
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ spec:
traces:
receivers: [otlp]
exporters: [debug]
metrics:
receivers: [otlp]
exporters: [debug]
mode: sidecar
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,16 @@ spec:
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: http://localhost:4317
- name: OTEL_EXPORTER_OTLP_TIMEOUT
value: "20"
value: "20000"
- name: OTEL_TRACES_SAMPLER
value: parentbased_traceidratio
- name: OTEL_TRACES_SAMPLER_ARG
value: "0.85"
value: always_on
- name: SPLUNK_TRACE_RESPONSE_HEADER_ENABLED
value: "true"
exporter:
endpoint: http://localhost:4317
propagators:
- jaeger
- b3
sampler:
type: parentbased_traceidratio
argument: "0.25"
java:
env:
- name: OTEL_JAVAAGENT_DEBUG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,9 @@ spec:
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: http://localhost:4317
- name: OTEL_EXPORTER_OTLP_TIMEOUT
value: "20"
value: "20000"
- name: OTEL_TRACES_SAMPLER
value: parentbased_traceidratio
- name: OTEL_TRACES_SAMPLER_ARG
value: "0.85"
value: always_on
- name: SPLUNK_TRACE_RESPONSE_HEADER_ENABLED
value: "true"
- name: OTEL_SERVICE_NAME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,38 @@ spec:
file: 01-assert.yaml
catch:
- podLogs:
selector: app=my-java
selector: app=my-java
- name: "wait for app to be ready"
try:
- sleep:
duration: 5s
- name: Make a request to the app
try:
- script:
content: |
#!/bin/bash
# set -ex
pod=$(kubectl get pods -n $NAMESPACE | awk '{print $1}' | tail -n 1)
kubectl get --raw /api/v1/namespaces/$NAMESPACE/pods/${pod}:8080/proxy/
check:
($error): ~
($stdout): Hello World!
- name: "wait for the telemetry to be there"
try:
- sleep:
duration: 3s
- name: Check the sidecar has sent request data successfully
try:
- script:
content: |
#!/bin/bash
# set -ex
pod=$(kubectl get pods -n $NAMESPACE | awk '{print $1}' | tail -n 1)
kubectl get --raw /api/v1/namespaces/$NAMESPACE/pods/${pod}:8888/proxy/metrics
check:
($error): ~
# TODO: Check that the number is non-zero and that failed is zero
(wildcard('*otelcol_exporter_sent_spans*', $stdout)): true
catch:
- podLogs:
selector: app=my-java
Loading