1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
|
#!/bin/bash
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0
set -e
# To run tests in a local dev environment:
# - make sure docker is running
# - set BUILD_DIR to the top level build directory,
[ -z "${BUILD_DIR}" ] && export BUILD_DIR="${HOME}/build"
export CERT_DIR=../cert
export TEST_BIN_DIR="${BUILD_DIR}/functional/otlp/"
# SELINUX
# https://docs.docker.com/storage/bind-mounts/#configure-the-selinux-label
USE_MOUNT_OPTION=""
if [ -x "$(command -v getenforce)" ]; then
SELINUXSTATUS=$(getenforce);
if [ "${SELINUXSTATUS}" == "Enforcing" ]; then
echo "Detected SELINUX"
USE_MOUNT_OPTION=":z"
fi;
fi
#
# Prepare docker image
#
docker build -t otelcpp-func-test .
echo "REPORT:" > report.log
#
# Exercising HTTP functional tests
#
export TEST_EXECUTABLE="func_otlp_http"
export TEST_URL="localhost:4318/v1/traces"
#
# MODE 'NONE'
#
export SERVER_MODE="none"
./run_test_mode.sh
#
# MODE 'HTTP'
#
echo ""
echo "###############################################################"
echo "Starting otelcol --config otel-config-http.yaml"
echo "###############################################################"
echo ""
docker run -d \
-v `pwd`/otel-docker-config-http.yaml:/otel-cpp/otel-config.yaml${USE_MOUNT_OPTION} \
-p 4318:4318 \
--name otelcpp-test-http \
otelcpp-func-test
sleep 5;
export SERVER_MODE="http"
./run_test_mode.sh
echo ""
echo "###############################################################"
echo "Stopping otelcol (http)"
echo "###############################################################"
echo ""
docker stop otelcpp-test-http
docker rm otelcpp-test-http
#
# MODE 'SSL'
#
echo ""
echo "###############################################################"
echo "Starting otelcol --config otel-config-https.yaml"
echo "###############################################################"
echo ""
docker run -d \
-v `pwd`/otel-docker-config-https.yaml:/otel-cpp/otel-config.yaml${USE_MOUNT_OPTION} \
-v `pwd`/../cert/ca.pem:/otel-cpp/ca.pem${USE_MOUNT_OPTION} \
-v `pwd`/../cert/server_cert.pem:/otel-cpp/server_cert.pem${USE_MOUNT_OPTION} \
-v `pwd`/../cert/server_cert-key.pem:/otel-cpp/server_cert-key.pem${USE_MOUNT_OPTION} \
-p 4318:4318 \
--name otelcpp-test-https \
otelcpp-func-test
sleep 5;
export SERVER_MODE="https"
./run_test_mode.sh
echo ""
echo "###############################################################"
echo "Stopping otelcol (https)"
echo "###############################################################"
echo ""
docker stop otelcpp-test-https
docker rm otelcpp-test-https
#
# Exercising gRPC functional tests
#
export TEST_EXECUTABLE="func_otlp_grpc"
export TEST_URL="localhost:4317"
#
# MODE 'SSL'
#
echo ""
echo "###############################################################"
echo "Starting otelcol --config otel-config-https-mtls.yaml"
echo "###############################################################"
echo ""
docker run -d \
-v `pwd`/otel-docker-config-https-mtls.yaml:/otel-cpp/otel-config.yaml${USE_MOUNT_OPTION} \
-v `pwd`/../cert/ca.pem:/otel-cpp/ca.pem${USE_MOUNT_OPTION} \
-v `pwd`/../cert/client_cert.pem:/otel-cpp/client_cert.pem${USE_MOUNT_OPTION} \
-v `pwd`/../cert/server_cert.pem:/otel-cpp/server_cert.pem${USE_MOUNT_OPTION} \
-v `pwd`/../cert/server_cert-key.pem:/otel-cpp/server_cert-key.pem${USE_MOUNT_OPTION} \
-p 4317:4317 \
--name otelcpp-test-grpc-mtls \
otelcpp-func-test
sleep 5;
export SERVER_MODE="https"
./run_test_mode.sh
echo ""
echo "###############################################################"
echo "Stopping otelcol (https / mTLS)"
echo "###############################################################"
echo ""
docker stop otelcpp-test-grpc-mtls
docker rm otelcpp-test-grpc-mtls
echo ""
echo "###############################################################"
echo "TEST REPORT"
echo "###############################################################"
echo ""
cat report.log
export PASSED_COUNT=`grep -c "PASSED" report.log`
export FAILED_COUNT=`grep -c "FAILED" report.log`
echo ""
echo "###############################################################"
echo "TEST VERDICT: ${PASSED_COUNT} PASSED, ${FAILED_COUNT} FAILED"
echo "###############################################################"
echo ""
if [ "${FAILED_COUNT}" != "0" ]; then
#
# CI FAILED
#
exit 1
fi;
#
# CI PASSED
#
exit 0
|