-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add tests Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de> * Create logs dir Signed-off-by: Juraci Paixão Kröhling <juraci@kroehling.de>
- Loading branch information
1 parent
c0766b8
commit b0734e4
Showing
14 changed files
with
273 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
_build | ||
test/logs | ||
*.pid |
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,13 @@ | ||
# Tests | ||
|
||
The tests are a bunch of shell scripts that, for each distribution: | ||
|
||
- prepare the environment, such as installing tools like `tracegen` | ||
- start the distribution | ||
- create a data point (a trace, for now) | ||
- check whether the data point was received | ||
- stop the distribution | ||
|
||
In the future, we might add more scenarios to the tests. | ||
|
||
In the output, pay attention to the general outcome of each distribution's test. While you might see warnings or errors in the logs, they are not indicative of a failure. If you see a "PASS: sidecar", it means that the tests (eventually) passed. If you do NOT see this, check the logs for clues. |
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,2 @@ | ||
#!/bin/bash | ||
|
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,23 @@ | ||
extensions: | ||
health_check: | ||
|
||
receivers: | ||
otlp: | ||
protocols: | ||
grpc: | ||
|
||
processors: | ||
|
||
exporters: | ||
otlp: | ||
endpoint: example.com:4317 # this will fail, but the process shouldn't die because of it | ||
|
||
service: | ||
extensions: [health_check] | ||
pipelines: | ||
traces: | ||
receivers: | ||
- otlp | ||
processors: [] | ||
exporters: | ||
- otlp |
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,32 @@ | ||
extensions: | ||
health_check: | ||
|
||
receivers: | ||
otlp: | ||
protocols: | ||
grpc: | ||
jaeger: | ||
protocols: | ||
thrift_binary: | ||
thrift_compact: | ||
grpc: | ||
zipkin: | ||
|
||
processors: | ||
|
||
exporters: | ||
otlp: | ||
endpoint: example:4317 # this will fail to connect, but it shouldn't break the process | ||
|
||
service: | ||
extensions: [health_check] | ||
pipelines: | ||
traces: | ||
receivers: | ||
- jaeger | ||
- otlp | ||
- zipkin | ||
processors: [] | ||
exporters: | ||
- otlp | ||
|
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,21 @@ | ||
#!/bin/bash | ||
|
||
while getopts d:s:b:g: flag | ||
do | ||
case "${flag}" in | ||
d) distribution=${OPTARG};; | ||
esac | ||
done | ||
if [[ -z $distribution ]]; then | ||
echo "Distributioon to test not provided. Use '-d' to specify the names of the distribution to test. Ex.:" | ||
echo "$0 -d tracing" | ||
exit 1 | ||
fi | ||
|
||
tracegen -otlp-endpoint localhost:4317 -otlp-insecure -service e2e-test &>> ./test/logs/tracegen-${distribution}.log | ||
if [ $? != 0 ]; then | ||
echo "Failed to generate a trace." | ||
exit 1 | ||
fi | ||
|
||
echo "✅ Traces generated." |
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,3 @@ | ||
#!/bin/bash | ||
|
||
go install "github.com/open-telemetry/opentelemetry-collector-contrib/tracegen@v0.46.0" |
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,52 @@ | ||
#!/bin/bash | ||
|
||
while getopts d:s:b:g: flag | ||
do | ||
case "${flag}" in | ||
d) distribution=${OPTARG};; | ||
esac | ||
done | ||
if [[ -z $distribution ]]; then | ||
echo "Distributioon to test not provided. Use '-d' to specify the names of the distribution to test. Ex.:" | ||
echo "$0 -d tracing" | ||
exit 1 | ||
fi | ||
|
||
max_retries=50 | ||
|
||
# start the distribution | ||
./distributions/${distribution}/_build/otelcol --config test/config/${distribution}.yaml > ./test/logs/otelcol-${distribution}.log 2>&1 & | ||
pid=$! | ||
|
||
retries=0 | ||
while true | ||
do | ||
kill -0 "${pid}" >/dev/null 2>&1 | ||
if [ $? != 0 ]; then | ||
echo "❌ FAIL. The Grafana Labs '${distribution}' distribution of the OpenTelemetry Collector isn't running. Startup log:" | ||
failed=true | ||
exit 1 | ||
fi | ||
|
||
curl -s localhost:13133 | grep "Server available" > /dev/null | ||
if [ $? == 0 ]; then | ||
echo "✅ The Grafana Labs '${distribution}' distribution of the OpenTelemetry Collector started." | ||
echo "${pid}" > "otelcol-${distribution}.pid" | ||
break | ||
fi | ||
|
||
echo "Server still unavailable" >> ./test/logs/test-${distribution}.log | ||
|
||
let "retries++" | ||
if [ "$retries" -gt "$max_retries" ]; then | ||
echo "❌ FAIL. Server wasn't up after about 5s." | ||
|
||
kill "${pid}" | ||
if [ $? != 0 ]; then | ||
echo "Failed to stop the running instance. Return code: $? . Skipping tests." | ||
exit 8 | ||
fi | ||
exit 16 | ||
fi | ||
sleep 0.1s | ||
done |
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,27 @@ | ||
#!/bin/bash | ||
|
||
while getopts d:s:b:g: flag | ||
do | ||
case "${flag}" in | ||
d) distribution=${OPTARG};; | ||
esac | ||
done | ||
if [[ -z $distribution ]]; then | ||
echo "Distributioon to test not provided. Use '-d' to specify the names of the distribution to test. Ex.:" | ||
echo "$0 -d tracing" | ||
exit 1 | ||
fi | ||
|
||
pid=$(cat otelcol-${distribution}.pid) | ||
kill "${pid}" | ||
if [ $? != 0 ]; then | ||
echo "Failed to stop the running instance. Return code: $? . Skipping tests." | ||
exit 2 | ||
fi | ||
|
||
while kill -0 ${pid} | ||
do | ||
sleep 0.1s | ||
done | ||
|
||
echo "✅ Grafana Labs '${distribution}' distribution of the OpenTelemetry Collector stopped." |
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,21 @@ | ||
#!/bin/bash | ||
|
||
while getopts d:s:b:g: flag | ||
do | ||
case "${flag}" in | ||
d) distributions=${OPTARG};; | ||
esac | ||
done | ||
|
||
if [[ -z $distributions ]]; then | ||
echo "List of distributions to test not provided. Use '-d' to specify the names of the distributions to test. Ex.:" | ||
echo "$0 -d sidecar,tracing" | ||
exit 1 | ||
fi | ||
|
||
echo "Distributions to test: $distributions"; | ||
|
||
for distribution in $(echo "$distributions" | tr "," "\n") | ||
do | ||
./test/test.sh -d "${distribution}" | ||
done |
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,69 @@ | ||
#!/bin/bash | ||
|
||
while getopts d:s:b:g: flag | ||
do | ||
case "${flag}" in | ||
d) distribution=${OPTARG};; | ||
esac | ||
done | ||
if [[ -z $distribution ]]; then | ||
echo "Distributioon to test not provided. Use '-d' to specify the names of the distribution to test. Ex.:" | ||
echo "$0 -d tracing" | ||
exit 1 | ||
fi | ||
|
||
# register the teardown function before we can use it in the trap | ||
function teardown { | ||
## tear down | ||
echo "🔧 Tearing down..." | ||
./test/stop-otelcol.sh -d ${distribution} | ||
|
||
mkdir -p ./test/logs | ||
|
||
echo "🪵 Grafana Labs '${distribution}' distribution of the OpenTelemetry Collector logs" | ||
cat ./test/logs/otelcol-${distribution}.log | ||
|
||
echo "🪵 Test logs" | ||
cat ./test/logs/test-${distribution}.log | ||
} | ||
|
||
## setup | ||
echo "🔧 Setting up..." | ||
for st in ./test/install-tracegen.sh | ||
do | ||
./${st} | ||
rc=$? | ||
if [ $rc != 0 ]; then | ||
exit $rc | ||
fi | ||
done | ||
|
||
# from this point and on, we run the teardown before we exit | ||
trap teardown EXIT | ||
|
||
## test | ||
echo "🔧 Starting Grafana Labs '${distribution}' distribution of the OpenTelemetry Collector..." | ||
./test/start-otelcol.sh -d ${distribution} | ||
rc=$? | ||
if [ $rc != 0 ]; then | ||
exit $rc | ||
fi | ||
|
||
## generate a trace | ||
echo "🔧 Generating trace..." | ||
./test/generate-trace.sh -d ${distribution} | ||
rc=$? | ||
if [ $rc != 0 ]; then | ||
exit $rc | ||
fi | ||
|
||
## check that a trace was received | ||
echo "🔧 Checking for existence of a trace..." | ||
./test/check-trace.sh -d ${distribution} | ||
rc=$? | ||
if [ $rc != 0 ]; then | ||
exit $rc | ||
fi | ||
|
||
echo "✅ PASS: '${distribution}'" | ||
exit 0 |