generated from honeycombio/.github
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
maint: adding proper smoke test(s) (#310)
## Which problem is this PR solving? - Closes #78 ## Description of the changes Set up a smoke test, details included in the new make targets below: - `smokey_cluster_create`: Create kind cluster - `smokey_collector_install`: Install collector via helm with new collector values, including a filter processor that only keeps echoserver spans from pods with a response code of 405 - `smokey_agent_install`: Install agent via helm with new agent values, including usage of a local image (installed if not available in the shell) and export to the collector - `smokey_echo_job`: Install echoserver and run a job that sends a POST request expecting a 405 response - `smokey_copy_output`: After a short wait, copy output from the newly created file saved with telemetry from collector - `smokey_verify_output`: Make assertions via the new `verify.bats` bats test (similar to previous tests on other distros and in go auto-instrumentation) that the output contains the expected span and attributes - `smoke`: Do all of the things above - `unsmoke`: Tear it all down when done Also updated PR, main, and release workflows to run the new smoke test. ## How to verify that this has the expected result - Run `make smoke` and get a bunch of passing tests - also check out the (git ignored) json file that contains the remaining span that's being tested. `make unsmoke` to spin it down. --------- Co-authored-by: Mike Goldsmth <goldsmith.mike@gmail.com> Co-authored-by: Jamie Danielson <jamiedanielson@honeycomb.io> Co-authored-by: JamieDanielson <jamieedanielson@gmail.com>
- Loading branch information
1 parent
6cc757c
commit 9b5bfcd
Showing
10 changed files
with
349 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
honeycomb: | ||
apiKey: "bogosity" # we'll be sending to a Collector in smoke tests | ||
endpoint: "http://$OTEL_COLLECTOR_IP:4317" | ||
|
||
image: | ||
repository: hny/network-agent | ||
# use local image for testing instead of helm chart default | ||
tag: local | ||
|
||
extraEnvVars: | ||
- name: OTEL_RESOURCE_ATTRIBUTES | ||
value: "environment=smokey" | ||
- name: INCLUDE_REQUEST_URL | ||
value: "true" | ||
- name: HTTP_HEADERS | ||
value: "User-Agent,Traceparent,X-Custom-Header" | ||
- name: OTEL_EXPORTER_OTLP_INSECURE | ||
value: "true" | ||
- name: LOG_LEVEL | ||
value: "DEBUG" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
mode: "statefulset" | ||
|
||
config: | ||
receivers: | ||
jaeger: null | ||
prometheus: null | ||
zipkin: null | ||
otlp: | ||
protocols: | ||
http: | ||
endpoint: ${env:MY_POD_IP}:4318 | ||
grpc: | ||
endpoint: ${env:MY_POD_IP}:4317 | ||
|
||
processors: | ||
filter/echoonly: | ||
spans: | ||
include: | ||
match_type: strict | ||
attributes: | ||
- key: destination.k8s.namespace.name | ||
value: echoserver | ||
exclude: | ||
match_type: strict | ||
attributes: | ||
- key: destination.k8s.resource.type | ||
value: service | ||
|
||
exporters: | ||
debug: | ||
verbosity: detailed | ||
file/trace: | ||
path: /tmp/trace.json | ||
rotation: | ||
|
||
service: | ||
pipelines: | ||
metrics: null | ||
logs: null | ||
traces: | ||
receivers: | ||
- otlp | ||
processors: | ||
- filter/echoonly | ||
exporters: | ||
- file/trace | ||
- debug | ||
|
||
|
||
image: | ||
repository: otel/opentelemetry-collector-contrib | ||
tag: "latest" | ||
|
||
command: | ||
name: otelcol-contrib | ||
|
||
extraVolumes: | ||
- name: filevolume | ||
emptyDir: {} | ||
extraVolumeMounts: | ||
- mountPath: /tmp | ||
name: filevolume | ||
|
||
extraContainers: | ||
- name: filecp | ||
image: busybox | ||
command: ["sh", "-c", "sleep 36000"] | ||
volumeMounts: | ||
- name: filevolume | ||
mountPath: /tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
apiVersion: batch/v1 | ||
kind: Job | ||
metadata: | ||
name: smoke-job | ||
namespace: echoserver | ||
spec: | ||
template: | ||
metadata: | ||
annotations: | ||
workload: job | ||
labels: | ||
app: smoke | ||
spec: | ||
shareProcessNamespace: true | ||
restartPolicy: Never | ||
schedulerName: default-scheduler | ||
securityContext: {} | ||
terminationGracePeriodSeconds: 30 | ||
containers: | ||
- name: smoke-curl | ||
image: docker.io/curlimages/curl | ||
imagePullPolicy: IfNotPresent | ||
args: | ||
- --verbose | ||
- --data | ||
- 'message=heygirl' | ||
- --header | ||
- 'X-ECHO-CODE: 405' | ||
- http://echoserver |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# UTILITY FUNCS | ||
|
||
# Span names for a given scope | ||
# Arguments: $1 - scope name | ||
span_names_for() { | ||
spans_from_scope_named $1 | jq '.name' | ||
} | ||
|
||
# Attributes for a given scope | ||
# Arguments: $1 - scope name | ||
span_attributes_for() { | ||
spans_from_scope_named $1 | \ | ||
jq ".attributes[]" | ||
} | ||
|
||
# All resource attributes | ||
resource_attributes_received() { | ||
spans_received | jq ".resource.attributes[]?" | ||
} | ||
|
||
# Spans for a given scope | ||
# Arguments: $1 - scope name | ||
spans_from_scope_named() { | ||
spans_received | jq ".scopeSpans[] | select(.scope.name == \"$1\").spans[]" | ||
} | ||
|
||
# All spans received | ||
spans_received() { | ||
json_output | jq ".resourceSpans[]?" | ||
} | ||
|
||
# the output of the log file produced by the collector | ||
json_output() { | ||
cat "${BATS_TEST_DIRNAME}/traces-orig.json" | ||
} | ||
|
||
# ASSERTION HELPERS | ||
|
||
# Fail and display details if the expected and actual values do not | ||
# equal. Details include both values. | ||
# | ||
# Inspired by bats-assert * bats-support, but dramatically simplified | ||
# Arguments: | ||
# $1 - actual result | ||
# $2 - expected result | ||
assert_equal() { | ||
if [[ $1 != "$2" ]]; then | ||
{ | ||
echo | ||
echo "-- 💥 values are not equal 💥 --" | ||
echo "expected : $2" | ||
echo "actual : $1" | ||
echo "--" | ||
echo | ||
} >&2 # output error to STDERR | ||
return 1 | ||
fi | ||
} | ||
|
||
# Fail and display details if the actual value is empty. | ||
# Arguments: $1 - actual result | ||
assert_not_empty() { | ||
EMPTY=(\"\") | ||
if [[ "$1" == "${EMPTY}" ]]; then | ||
{ | ||
echo | ||
echo "-- 💥 value is empty 💥 --" | ||
echo "value : $1" | ||
echo "--" | ||
echo | ||
} >&2 # output error to STDERR | ||
return 1 | ||
fi | ||
} |
Oops, something went wrong.