Skip to content

Commit

Permalink
test(smoketest): remove unmaintained k8s and pods smoketests (#292)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores authored Feb 21, 2024
1 parent e2f72e0 commit 850f91a
Show file tree
Hide file tree
Showing 54 changed files with 92 additions and 1,116 deletions.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ Fixes: #<issue number>
*This change is helpful because users may want to...*

## How to manually test:
1. *Run CRYOSTAT_IMAGE=quay.io... sh smoketest.sh...*
1. *Run CRYOSTAT_IMAGE=quay.io... bash smoketest.bash...*
2. *...*
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
27 changes: 27 additions & 0 deletions compose/localstack_buckets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

createBucket() {
awslocal s3 mb "s3://${1}"
}

createBuckets() {
for name in "$@"; do
createBucket "${name}" &
done
}

names=()
for i in $(echo "$CRYOSTAT_BUCKETS" | tr ',' '\n'); do
len="${#i}"
if [ "${len}" -lt 3 ]; then
echo "Bucket names must be at least 3 characters"
exit 1
fi
if [ "${len}" -gt 63 ]; then
echo "Bucket names must be at most 63 characters"
exit 1
fi
names+=("${i}")
done

createBuckets "${names[@]}"
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,9 @@ services:
environment:
SERVICES: s3
START_WEB: 1
DEFAULT_REGION: us-east-1
PORT_WEB_UI: 4577
CRYOSTAT_BUCKETS: ${PRECREATE_BUCKETS}
volumes:
- localstack_data:/etc/localstack/init/ready.d:z
# this buckets.bash hook script isn't working for some reason. In the meantime, after spinning up the localstack instance, do:
# $ podman exec -it cryostat3_s3_1 /bin/bash
# $ awslocal s3 mb s3://archivedrecordings
- localstack_cfg:/etc/localstack/init/ready.d:z
labels:
kompose.service.expose: "s3"
restart: always
Expand All @@ -38,5 +34,5 @@ services:
timeout: 5s

volumes:
localstack_data:
driver: local
localstack_cfg:
external: true
2 changes: 1 addition & 1 deletion smoketest/compose/s3-minio.yml → compose/s3-minio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ services:
environment:
MINIO_ROOT_USER: minioroot
MINIO_ROOT_PASSWORD: minioroot
MINIO_DEFAULT_BUCKETS: archivedrecordings
MINIO_DEFAULT_BUCKETS: ${PRECREATE_BUCKETS}
volumes:
- minio_data:/data
- minio_certs:/certs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ services:
image: ${STORAGE_IMAGE:-quay.io/cryostat/cryostat-storage:latest}
hostname: s3
environment:
CRYOSTAT_BUCKETS: archivedrecordings,archivedreports
CRYOSTAT_BUCKETS: ${PRECREATE_BUCKETS}
CRYOSTAT_ACCESS_KEY: access_key
CRYOSTAT_SECRET_KEY: secret_key
DATA_DIR: /data
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
93 changes: 58 additions & 35 deletions smoketest.bash
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
#!/usr/bin/env bash

if ! command -v yq; then
if ! command -v yq >/dev/null 2>&1 ; then
echo "No 'yq' found"
exit 1
fi

DIR="$(dirname "$(readlink -f "$0")")"

FILES=(
"${DIR}/smoketest/compose/db.yml"
"${DIR}/compose/db.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
PRECREATE_BUCKETS=${PRECREATE_BUCKETS:-archivedrecordings,archivedreports}

CRYOSTAT_HTTP_PORT=${CRYOSTAT_HTTP_PORT:-8080}
USE_PROXY=${USE_PROXY:-true}
DEPLOY_GRAFANA=true
DEPLOY_GRAFANA=${DEPLOY_GRAFANA:-true}
DRY_RUN=${DRY_RUN:-false}

display_usage() {
echo "Usage:"
Expand All @@ -33,11 +36,12 @@ display_usage() {
echo -e "\t-X\t\t\t\t\t\tdeploy additional development aid tools."
echo -e "\t-c [podman|docker]\t\t\t\tUse Podman or Docker Container Engine (default \"podman\")."
echo -e "\t-b\t\t\t\t\t\tOpen a Browser tab for each running service's first mapped port (ex. auth proxy login, database viewer)"
echo -e "\t-n\t\t\t\t\t\tDo Not apply configuration changes, instead emit the compose YAML that would have been used to stdout."
}

s3=seaweed
ce=podman
while getopts "hs:prGtOVXcb" opt; do
while getopts "hs:prGtOVXcbn" opt; do
case $opt in
h)
display_usage
Expand All @@ -53,7 +57,7 @@ while getopts "hs:prGtOVXcb" opt; do
DEPLOY_GRAFANA=false
;;
t)
FILES+=("${DIR}/smoketest/compose/sample-apps.yml")
FILES+=("${DIR}/compose/sample-apps.yml")
;;
O)
PULL_IMAGES=false
Expand All @@ -62,7 +66,7 @@ while getopts "hs:prGtOVXcb" opt; do
KEEP_VOLUMES=true
;;
X)
FILES+=("${DIR}/smoketest/compose/db-viewer.yml")
FILES+=("${DIR}/compose/db-viewer.yml")
;;
c)
ce="${OPTARG}"
Expand All @@ -71,7 +75,10 @@ while getopts "hs:prGtOVXcb" opt; do
OPEN_TABS=true
;;
r)
FILES+=('./smoketest/compose/reports.yml')
FILES+=('./compose/reports.yml')
;;
n)
DRY_RUN=true
;;
*)
display_usage
Expand All @@ -82,29 +89,30 @@ done

if [ "${DEPLOY_GRAFANA}" = "true" ]; then
FILES+=(
"${DIR}/smoketest/compose/cryostat-grafana.yml"
"${DIR}/smoketest/compose/jfr-datasource.yml"
"${DIR}/compose/cryostat-grafana.yml"
"${DIR}/compose/jfr-datasource.yml"
)
fi


if [ "${USE_PROXY}" = "true" ]; then
FILES+=("${DIR}/smoketest/compose/auth_proxy.yml")
FILES+=("${DIR}/compose/auth_proxy.yml")
CRYOSTAT_HTTP_PORT=8181
GRAFANA_DASHBOARD_EXT_URL=http://localhost:8080/grafana/
else
FILES+=("${DIR}/smoketest/compose/no_proxy.yml" "${DIR}/smoketest/compose/s3_no_proxy.yml")
FILES+=("${DIR}/compose/no_proxy.yml" "${DIR}/compose/s3_no_proxy.yml")
if [ "${DEPLOY_GRAFANA}" = "true" ]; then
FILES+=("${DIR}/smoketest/compose/grafana_no_proxy.yml")
FILES+=("${DIR}/compose/grafana_no_proxy.yml")
fi
GRAFANA_DASHBOARD_EXT_URL=http://grafana:3000/
fi
export CRYOSTAT_HTTP_PORT
export GRAFANA_DASHBOARD_EXT_URL

s3Manifest="${DIR}/smoketest/compose/s3-${s3}.yml"
s3Manifest="${DIR}/compose/s3-${s3}.yml"
STORAGE_PORT="$(yq '.services.*.expose[0]' "${s3Manifest}" | grep -v null)"
export STORAGE_PORT
export PRECREATE_BUCKETS

if [ ! -f "${s3Manifest}" ]; then
echo "Unknown S3 selection: ${s3}"
Expand All @@ -120,24 +128,34 @@ unshift() {
}

if [ "${ce}" = "podman" ]; then
unshift FILES "${DIR}/smoketest/compose/cryostat.yml"
unshift FILES "${DIR}/compose/cryostat.yml"
container_engine="podman"
elif [ "${ce}" = "docker" ]; then
unshift FILES "${DIR}/smoketest/compose/cryostat_docker.yml"
unshift FILES "${DIR}/compose/cryostat_docker.yml"
container_engine="docker"
else
echo "Unknown Container Engine selection: ${ce}"
display_usage
exit 2
fi

set -xe
if [ ! "${DRY_RUN}" = "true" ]; then
set -xe
fi

CMD=()
for file in "${FILES[@]}"; do
CMD+=(-f "${file}")
done

if [ "${DRY_RUN}" = "true" ]; then
set +xe
docker-compose \
"${CMD[@]}" \
config
exit 0
fi

PIDS=()

HOSTSFILE="${HOSTSFILE:-$HOME/.hosts}"
Expand All @@ -151,9 +169,14 @@ cleanup() {
docker-compose \
"${CMD[@]}" \
down "${downFlags[@]}"
${container_engine} rm proxy_cfg_helper || true
${container_engine} volume rm auth_proxy_cfg || true
# podman kill hoster || true
if [ "${USE_PROXY}" = "true" ]; then
${container_engine} rm proxy_cfg_helper || true
${container_engine} volume rm auth_proxy_cfg || true
fi
if [ "${s3}" = "localstack" ]; then
${container_engine} rm localstack_cfg_helper || true
${container_engine} volume rm localstack_cfg || true
fi
truncate -s 0 "${HOSTSFILE}"
for i in "${PIDS[@]}"; do
kill -0 "${i}" && kill "${i}"
Expand All @@ -169,27 +192,24 @@ createProxyCfgVolume() {
local cfg
cfg="$(mktemp)"
chmod 644 "${cfg}"
envsubst '$STORAGE_PORT' < "${DIR}/smoketest/compose/auth_proxy_alpha_config.yaml" > "${cfg}"
"${container_engine}" cp "${DIR}/smoketest/compose/auth_proxy_htpasswd" proxy_cfg_helper:/tmp/auth_proxy_htpasswd
envsubst '$STORAGE_PORT' < "${DIR}/compose/auth_proxy_alpha_config.yaml" > "${cfg}"
"${container_engine}" cp "${DIR}/compose/auth_proxy_htpasswd" proxy_cfg_helper:/tmp/auth_proxy_htpasswd
"${container_engine}" cp "${cfg}" proxy_cfg_helper:/tmp/auth_proxy_alpha_config.yaml
}
if [ "${USE_PROXY}" = "true" ]; then
createProxyCfgVolume
fi

createLocalstackCfgVolume() {
"${container_engine}" volume create localstack_cfg
"${container_engine}" container create --name localstack_cfg_helper -v localstack_cfg:/tmp busybox
"${container_engine}" cp "${DIR}/compose/localstack_buckets.sh" localstack_cfg_helper:/tmp
}
if [ "${s3}" = "localstack" ]; then
createLocalstackCfgVolume
fi

setupUserHosts() {
# FIXME this is broken: it puts the containers' bridge-internal IP addresses
# into the user hosts file, but these IPs are in a subnet not reachable from the host.
# podman run \
# --detach \
# --rm \
# --name hoster \
# --user=0 \
# --security-opt label=disable \
# -v "${XDG_RUNTIME_DIR}/podman/podman.sock:/tmp/docker.sock:Z" \
# -v "${HOME}/.hosts:/tmp/hosts" \
# dvdarias/docker-hoster
#
# This requires https://github.com/figiel/hosts to work. See README.
truncate -s 0 "${HOSTSFILE}"
for file in "${FILES[@]}" ; do
Expand Down Expand Up @@ -269,4 +289,7 @@ fi

docker-compose \
"${CMD[@]}" \
up
up \
--renew-anon-volumes \
--remove-orphans \
--abort-on-container-exit
58 changes: 0 additions & 58 deletions smoketest/compose/db_k8s.yml

This file was deleted.

3 changes: 0 additions & 3 deletions smoketest/compose/localstack/buckets.bash

This file was deleted.

Loading

0 comments on commit 850f91a

Please sign in to comment.