Skip to content

Commit

Permalink
test(smoketest): auth proxy is optional (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores authored Jan 3, 2024
1 parent a27c227 commit 55dc509
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 18 deletions.
35 changes: 27 additions & 8 deletions smoketest.bash
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,21 @@ DIR="$(dirname "$(readlink -f "$0")")"

FILES=(
"${DIR}/smoketest/compose/db.yml"
"${DIR}/smoketest/compose/auth_proxy.yml"
)

USE_USERHOSTS=${USE_USERHOSTS:-true}
PULL_IMAGES=${PULL_IMAGES:-true}
KEEP_VOLUMES=${KEEP_VOLUMES:-false}
OPEN_TABS=${OPEN_TABS:-false}

CRYOSTAT_HTTP_PORT=8080
USE_PROXY=${USE_PROXY:-true}

display_usage() {
echo "Usage:"
echo -e "\t-h\t\t\t\t\t\tprint this Help text."
echo -e "\t-O\t\t\t\t\t\tOffline mode, do not attempt to pull container images."
echo -e "\t-p\t\t\t\t\t\tDisable auth Proxy."
echo -e "\t-s [minio|seaweed|cloudserver|localstack]\tS3 implementation to spin up (default \"minio\")."
echo -e "\t-g\t\t\t\t\t\tinclude Grafana dashboard and jfr-datasource in deployment."
echo -e "\t-t\t\t\t\t\t\tinclude sample applications for Testing."
Expand All @@ -32,12 +35,15 @@ display_usage() {

s3=minio
ce=podman
while getopts "hs:gtOVXcb" opt; do
while getopts "hs:pgtOVXcb" opt; do
case $opt in
h)
display_usage
exit 0
;;
p)
USE_PROXY=false
;;
s)
s3="${OPTARG}"
;;
Expand Down Expand Up @@ -68,6 +74,13 @@ while getopts "hs:gtOVXcb" opt; do
;;
esac
done
export CRYOSTAT_HTTP_PORT
if [ "${USE_PROXY}" = "true" ]; then
FILES+=("${DIR}/smoketest/compose/auth_proxy.yml")
CRYOSTAT_HTTP_PORT=8181
else
FILES+=("${DIR}/smoketest/compose/no_proxy.yml")
fi

s3Manifest="${DIR}/smoketest/compose/s3-${s3}.yml"

Expand All @@ -78,11 +91,17 @@ if [ ! -f "${s3Manifest}" ]; then
fi
FILES+=("${s3Manifest}")

unshift() {
local -n ary=$1;
shift;
ary=("$@" "${ary[@]}");
}

if [ "${ce}" = "podman" ]; then
FILES+=("${DIR}/smoketest/compose/cryostat.yml")
unshift FILES "${DIR}/smoketest/compose/cryostat.yml"
container_engine="podman"
elif [ "${ce}" = "docker" ]; then
FILES+=("${DIR}/smoketest/compose/cryostat_docker.yml")
unshift FILES "${DIR}/smoketest/compose/cryostat_docker.yml"
container_engine="docker"
else
echo "Unknown Container Engine selection: ${ce}"
Expand Down Expand Up @@ -147,7 +166,7 @@ setupUserHosts() {
truncate -s 0 "${HOSTSFILE}"
for file in "${FILES[@]}" ; do
local hosts
hosts="$(yq '.services.*.hostname' "${file}" | grep -v null | sed -e 's/^/localhost /')"
hosts="$(yq '.services.*.hostname' "${file}" | { grep -v null || test $? = 1 ; } | sed -e 's/^/localhost /')"
echo "${hosts}" >> "${HOSTSFILE}"
done
}
Expand All @@ -169,14 +188,14 @@ openBrowserTabs() {
local host
local port
if [ "${USE_USERHOSTS}" = "true" ]; then
host="$(echo "${yaml}" | yq ".[${i}].host" | grep -v null)"
host="$(echo "${yaml}" | yq ".[${i}].host" | { grep -v null || test $? = 1 ; } )"
if [ "${host}" = "auth" ]; then
host="localhost"
fi
else
host="localhost"
fi
port="$(echo "${yaml}" | yq ".[${i}].ports[0]" | grep -v null | cut -d: -f1)"
port="$(echo "${yaml}" | yq ".[${i}].ports[0]" | { grep -v null || test $? = 1 ; } | envsubst | cut -d: -f1)"
if [ -n "${host}" ] && [ -n "${port}" ]; then
urls+=("http://${host}:${port}")
fi
Expand Down Expand Up @@ -212,7 +231,7 @@ fi
if [ "${PULL_IMAGES}" = "true" ]; then
IMAGES=()
for file in "${FILES[@]}" ; do
images="$(yq '.services.*.image' "${file}" | grep -v null)"
images="$(yq '.services.*.image' "${file}" | { grep -v null || test $? = 1; })"
for img in ${images}; do
IMAGES+=("$(eval echo "${img}")")
done
Expand Down
8 changes: 8 additions & 0 deletions smoketest/compose/auth_proxy.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
version: "3"
services:
cryostat:
expose:
- "${CRYOSTAT_HTTP_PORT}"
environment:
QUARKUS_HTTP_PROXY_PROXY_ADDRESS_FORWARDING: 'true'
QUARKUS_HTTP_PROXY_ALLOW_X_FORWARDED: 'true'
QUARKUS_HTTP_PROXY_ENABLE_FORWARDED_HOST: 'true'
QUARKUS_HTTP_PROXY_ENABLE_FORWARDED_PREFIX: 'true'
QUARKUS_HTTP_PROXY_TRUSTED_PROXIES: localhost:8080,auth:8080
healthcheck:
test: curl --fail http://cryostat:8181/health/liveness || exit 1
interval: 10s
retries: 3
start_period: 30s
timeout: 5s
auth:
# the proxy does not actually depend on cryostat being up, but we use this
# to ensure that when the smoketest tries to open the auth login page in a
Expand Down
5 changes: 2 additions & 3 deletions smoketest/compose/cryostat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ services:
- label:disable
hostname: cryostat3
user: "1000"
expose:
- "8181"
labels:
kompose.service.expose: "cryostat3"
io.cryostat.discovery: "true"
Expand All @@ -28,12 +26,13 @@ services:
io.cryostat.jmxUrl: "service:jmx:rmi:///jndi/rmi://localhost:0/jmxrmi"
environment:
QUARKUS_HTTP_HOST: "cryostat"
QUARKUS_HTTP_PORT: ${CRYOSTAT_HTTP_PORT}
CRYOSTAT_DISCOVERY_PODMAN_ENABLED: "true"
CRYOSTAT_DISCOVERY_JDP_ENABLED: "true"
JAVA_OPTS_APPEND: "-XX:+FlightRecorder -XX:StartFlightRecording=name=onstart,settings=default,disk=true,maxage=5m -Dcom.sun.management.jmxremote.autodiscovery=true -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9091 -Dcom.sun.management.jmxremote.rmi.port=9091 -Djava.rmi.server.hostname=127.0.0.1 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.local.only=false"
restart: unless-stopped
healthcheck:
test: curl --fail http://cryostat:8181/health/liveness || exit 1
test: curl --fail http://cryostat:${CRYOSTAT_HTTP_PORT}/health/liveness || exit 1
interval: 10s
retries: 3
start_period: 30s
Expand Down
8 changes: 8 additions & 0 deletions smoketest/compose/no_proxy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: "3"
services:
cryostat:
hostname: cryostat3
ports:
- ${CRYOSTAT_HTTP_PORT}:${CRYOSTAT_HTTP_PORT}
expose:
- ${CRYOSTAT_HTTP_PORT}
14 changes: 7 additions & 7 deletions smoketest/compose/sample-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: "3"
services:
sample-app-1:
depends_on:
auth:
cryostat:
condition: service_healthy
image: ${VERTX_FIB_DEMO_IMAGE:-quay.io/andrewazores/vertx-fib-demo:0.13.0}
hostname: vertx-fib-demo-1
Expand All @@ -15,7 +15,7 @@ services:
CRYOSTAT_AGENT_WEBSERVER_HOST: "sample-app-1"
CRYOSTAT_AGENT_WEBSERVER_PORT: "8910"
CRYOSTAT_AGENT_CALLBACK: "http://sample-app-1:8910/"
CRYOSTAT_AGENT_BASEURI: "http://auth:8080/"
CRYOSTAT_AGENT_BASEURI: "http://cryostat:${CRYOSTAT_HTTP_PORT}/"
CRYOSTAT_AGENT_TRUST_ALL: "true"
CRYOSTAT_AGENT_AUTHORIZATION: Basic dXNlcjpwYXNz
ports:
Expand All @@ -33,7 +33,7 @@ services:
timeout: 5s
sample-app-2:
depends_on:
auth:
cryostat:
condition: service_healthy
image: ${VERTX_FIB_DEMO_IMAGE:-quay.io/andrewazores/vertx-fib-demo:0.13.0}
hostname: vertx-fib-demo-2
Expand All @@ -47,7 +47,7 @@ services:
CRYOSTAT_AGENT_WEBSERVER_HOST: "sample-app-2"
CRYOSTAT_AGENT_WEBSERVER_PORT: "8911"
CRYOSTAT_AGENT_CALLBACK: "http://sample-app-2:8911/"
CRYOSTAT_AGENT_BASEURI: "http://auth:8080/"
CRYOSTAT_AGENT_BASEURI: "http://cryostat:${CRYOSTAT_HTTP_PORT}/"
CRYOSTAT_AGENT_TRUST_ALL: "true"
CRYOSTAT_AGENT_AUTHORIZATION: "Basic dXNlcjpwYXNz"
ports:
Expand All @@ -61,7 +61,7 @@ services:
timeout: 5s
sample-app-3:
depends_on:
auth:
cryostat:
condition: service_healthy
image: ${VERTX_FIB_DEMO_IMAGE:-quay.io/andrewazores/vertx-fib-demo:0.13.0}
hostname: vertx-fib-demo-3
Expand All @@ -76,7 +76,7 @@ services:
CRYOSTAT_AGENT_WEBSERVER_HOST: "sample-app-3"
CRYOSTAT_AGENT_WEBSERVER_PORT: "8910"
CRYOSTAT_AGENT_CALLBACK: "http://sample-app-3:8912/"
CRYOSTAT_AGENT_BASEURI: "http://auth:8080/"
CRYOSTAT_AGENT_BASEURI: "http://cryostat:${CRYOSTAT_HTTP_PORT}/"
CRYOSTAT_AGENT_TRUST_ALL: "true"
CRYOSTAT_AGENT_AUTHORIZATION: "Basic dXNlcjpwYXNz"
ports:
Expand Down Expand Up @@ -104,7 +104,7 @@ services:
CRYOSTAT_AGENT_WEBSERVER_HOST: quarkus-test-agent
CRYOSTAT_AGENT_WEBSERVER_PORT: 9977
CRYOSTAT_AGENT_CALLBACK: http://quarkus-test-agent:9977/
CRYOSTAT_AGENT_BASEURI: http://auth:8080/
CRYOSTAT_AGENT_BASEURI: http://cryostat:${CRYOSTAT_HTTP_PORT}/
CRYOSTAT_AGENT_BASEURI_RANGE: public
CRYOSTAT_AGENT_SSL_TRUST_ALL: "true"
CRYOSTAT_AGENT_SSL_VERIFY_HOSTNAME: "false"
Expand Down

0 comments on commit 55dc509

Please sign in to comment.