Skip to content

Commit

Permalink
chore(smoketest): clean up scripts for relative paths, shellcheck hin…
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewazores authored Nov 1, 2023
1 parent 0675fbc commit 446493e
Show file tree
Hide file tree
Showing 21 changed files with 33 additions and 71 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,14 @@ To run similar smoketest scenarios in a Kubernetes/OpenShift cluster, do:

```bash
$ cd smoketest/k8s
$ sh smoketest.sh kind # This launches a kind k8s cluster, otherwise skip this if you have another cluster accessible via kubectl/oc.
$ bash smoketest.bash kind # This launches a kind k8s cluster, otherwise skip this if you have another cluster accessible via kubectl/oc.
```

If you get an error during the 'ensuring node image' step while creating cluster "kind", manually pull the podman image by running the command `podman pull docker.io/kindest/node@IMAGE_DIGEST` where IMAGE_DIGEST is the sha256 of the image. Then rerun `sh smoketest.sh kind`.
If you get an error during the 'ensuring node image' step while creating cluster "kind", manually pull the podman image by running the command `podman pull docker.io/kindest/node@IMAGE_DIGEST` where IMAGE_DIGEST is the sha256 of the image. Then rerun `bash smoketest.bash kind`.

Generate k8s yaml configurations and apply them to create k8s objects. You can optionally port-forward to the cluster's services to access the Cryostat application from `localhost`.

```bash
$ sh smoketest.sh generate apply
$ sh smoketest.sh forward # if you need to use port-forwarding to get access to the cluster's services
$ bash smoketest.bash generate apply
$ bash smoketest.bash forward # if you need to use port-forwarding to get access to the cluster's services
```
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/sh
#!/usr/bin/env bash

awslocal s3 mb s3://archivedrecordings
2 changes: 1 addition & 1 deletion smoketest/compose/s3-localstack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ services:
PORT_WEB_UI: 4577
volumes:
- localstack_data:/etc/localstack/init/ready.d:z
# this buckets.sh hook script isn't working for some reason. In the meantime, after spinning up the localstack instance, do:
# 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
labels:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/bin/sh
#!/usr/bin/env bash

set -x
set -e

HOSTSFILE="${HOSTSFILE:-~/.hosts}"

cleanup() {
podman-compose --in-pod=1 \
-f ./smoketest/compose/db.yml \
Expand All @@ -13,7 +15,7 @@ cleanup() {
-f ./smoketest/compose/cryostat.yml \
down --volumes --remove-orphans
# podman kill hoster || true
> ~/.hosts
truncate -s 0 "${HOSTSFILE}"
}
trap cleanup EXIT
cleanup
Expand All @@ -32,13 +34,10 @@ cleanup
# dvdarias/docker-hoster

setupUserHosts() {
> ~/.hosts
echo "localhost s3" >> ~/.hosts
echo "localhost db" >> ~/.hosts
echo "localhost db-viewer" >> ~/.hosts
echo "localhost cryostat" >> ~/.hosts
echo "localhost vertx-fib-demo-1" >> ~/.hosts
echo "localhost quarkus-test-agent" >> ~/.hosts
truncate -s 0 "${HOSTSFILE}"
for svc in s3 db db-viewer cryostat vertx-fib-demo-1 quarkus-test-agent; do
echo "localhost ${svc}" >> "${HOSTSFILE}"
done
}
setupUserHosts

Expand Down
4 changes: 0 additions & 4 deletions smoketest/k8s/cryostat-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ metadata:
io.cryostat.jmxHost: localhost
io.cryostat.jmxPort: "0"
io.cryostat.jmxUrl: service:jmx:rmi:///jndi/rmi://localhost:0/jmxrmi
kompose.cmd: kompose convert -o ./ -f ./../compose/db_k8s.yml -f ./../compose/s3-minio.yml -f ./../compose/cryostat_k8s.yml -f ./../compose/sample-apps.yml --build local
kompose.service.expose: cryostat3
kompose.version: 1.30.0 (9d8dcb518)
creationTimestamp: null
labels:
io.kompose.service: cryostat
Expand All @@ -27,9 +25,7 @@ spec:
io.cryostat.jmxHost: localhost
io.cryostat.jmxPort: "0"
io.cryostat.jmxUrl: service:jmx:rmi:///jndi/rmi://localhost:0/jmxrmi
kompose.cmd: kompose convert -o ./ -f ./../compose/db_k8s.yml -f ./../compose/s3-minio.yml -f ./../compose/cryostat_k8s.yml -f ./../compose/sample-apps.yml --build local
kompose.service.expose: cryostat3
kompose.version: 1.30.0 (9d8dcb518)
creationTimestamp: null
labels:
io.kompose.network/compose-default: "true"
Expand Down
2 changes: 0 additions & 2 deletions smoketest/k8s/cryostat-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ metadata:
io.cryostat.jmxHost: localhost
io.cryostat.jmxPort: "0"
io.cryostat.jmxUrl: service:jmx:rmi:///jndi/rmi://localhost:0/jmxrmi
kompose.cmd: kompose convert -o ./ -f ./../compose/db_k8s.yml -f ./../compose/s3-minio.yml -f ./../compose/cryostat_k8s.yml -f ./../compose/sample-apps.yml --build local
kompose.service.expose: cryostat3
kompose.version: 1.30.0 (9d8dcb518)
creationTimestamp: null
labels:
io.kompose.service: cryostat
Expand Down
2 changes: 0 additions & 2 deletions smoketest/k8s/cryostat-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ metadata:
io.cryostat.jmxHost: localhost
io.cryostat.jmxPort: "0"
io.cryostat.jmxUrl: service:jmx:rmi:///jndi/rmi://localhost:0/jmxrmi
kompose.cmd: kompose convert -o ./ -f ./../compose/db_k8s.yml -f ./../compose/s3-minio.yml -f ./../compose/cryostat_k8s.yml -f ./../compose/sample-apps.yml --build local
kompose.service.expose: cryostat3
kompose.version: 1.30.0 (9d8dcb518)
creationTimestamp: null
labels:
io.kompose.service: cryostat
Expand Down
6 changes: 0 additions & 6 deletions smoketest/k8s/db-deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert -o ./ -f ./../compose/db_k8s.yml -f ./../compose/s3-minio.yml -f ./../compose/cryostat_k8s.yml -f ./../compose/sample-apps.yml --build local
kompose.version: 1.30.0 (9d8dcb518)
creationTimestamp: null
labels:
io.kompose.service: db
Expand All @@ -18,9 +15,6 @@ spec:
type: Recreate
template:
metadata:
annotations:
kompose.cmd: kompose convert -o ./ -f ./../compose/db_k8s.yml -f ./../compose/s3-minio.yml -f ./../compose/cryostat_k8s.yml -f ./../compose/sample-apps.yml --build local
kompose.version: 1.30.0 (9d8dcb518)
creationTimestamp: null
labels:
io.kompose.network/compose-default: "true"
Expand Down
3 changes: 0 additions & 3 deletions smoketest/k8s/db-service.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.cmd: kompose convert -o ./ -f ./../compose/db_k8s.yml -f ./../compose/s3-minio.yml -f ./../compose/cryostat_k8s.yml -f ./../compose/sample-apps.yml --build local
kompose.version: 1.30.0 (9d8dcb518)
creationTimestamp: null
labels:
io.kompose.service: db
Expand Down
4 changes: 0 additions & 4 deletions smoketest/k8s/db-viewer-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert -o ./ -f ./../compose/db_k8s.yml -f ./../compose/s3-minio.yml -f ./../compose/cryostat_k8s.yml -f ./../compose/sample-apps.yml --build local
kompose.service.expose: pgadmin
kompose.version: 1.30.0 (9d8dcb518)
creationTimestamp: null
labels:
io.kompose.service: db-viewer
Expand All @@ -20,9 +18,7 @@ spec:
template:
metadata:
annotations:
kompose.cmd: kompose convert -o ./ -f ./../compose/db_k8s.yml -f ./../compose/s3-minio.yml -f ./../compose/cryostat_k8s.yml -f ./../compose/sample-apps.yml --build local
kompose.service.expose: pgadmin
kompose.version: 1.30.0 (9d8dcb518)
creationTimestamp: null
labels:
io.kompose.network/compose-default: "true"
Expand Down
2 changes: 0 additions & 2 deletions smoketest/k8s/db-viewer-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kompose.cmd: kompose convert -o ./ -f ./../compose/db_k8s.yml -f ./../compose/s3-minio.yml -f ./../compose/cryostat_k8s.yml -f ./../compose/sample-apps.yml --build local
kompose.service.expose: pgadmin
kompose.version: 1.30.0 (9d8dcb518)
creationTimestamp: null
labels:
io.kompose.service: db-viewer
Expand Down
2 changes: 0 additions & 2 deletions smoketest/k8s/db-viewer-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ apiVersion: v1
kind: Service
metadata:
annotations:
kompose.cmd: kompose convert -o ./ -f ./../compose/db_k8s.yml -f ./../compose/s3-minio.yml -f ./../compose/cryostat_k8s.yml -f ./../compose/sample-apps.yml --build local
kompose.service.expose: pgadmin
kompose.version: 1.30.0 (9d8dcb518)
creationTimestamp: null
labels:
io.kompose.service: db-viewer
Expand Down
12 changes: 8 additions & 4 deletions smoketest/k8s/generate.sh → smoketest/k8s/generate.bash
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
cat > db-configmap.yaml <<< "apiVersion: v1
#!/usr/bin/env bash

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

cat > "${DIR}/db-configmap.yaml" <<< "apiVersion: v1
kind: ConfigMap
metadata:
name: pgadmin-config
data:
servers.json: |
$(cat ./../compose/servers.json | yq)"
$(yq < "${DIR}/../compose/servers.json")"

yq -i '.spec.template.spec.volumes += {"name": "serverjson", "configMap": {"name": "pgadmin-config", "items": [{"key": "servers.json", "path": "servers.json"}]}}' ./db-viewer-deployment.yaml
yq -i '.spec.template.spec.containers[0].volumeMounts += {"mountPath": "/pgadmin4/servers.json", "name": "serverjson", "subPath": "servers.json"}' ./db-viewer-deployment.yaml
yq -i '.spec.template.spec.volumes += {"name": "serverjson", "configMap": {"name": "pgadmin-config", "items": [{"key": "servers.json", "path": "servers.json"}]}}' "${DIR}/db-viewer-deployment.yaml"
yq -i '.spec.template.spec.containers[0].volumeMounts += {"mountPath": "/pgadmin4/servers.json", "name": "serverjson", "subPath": "servers.json"}' "${DIR}/db-viewer-deployment.yaml"
6 changes: 0 additions & 6 deletions smoketest/k8s/quarkus-test-agent-deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert -o ./ -f ./../compose/db_k8s.yml -f ./../compose/s3-minio.yml -f ./../compose/cryostat_k8s.yml -f ./../compose/sample-apps.yml --build local
kompose.version: 1.30.0 (9d8dcb518)
creationTimestamp: null
labels:
io.kompose.service: quarkus-test-agent
Expand All @@ -17,9 +14,6 @@ spec:
strategy: {}
template:
metadata:
annotations:
kompose.cmd: kompose convert -o ./ -f ./../compose/db_k8s.yml -f ./../compose/s3-minio.yml -f ./../compose/cryostat_k8s.yml -f ./../compose/sample-apps.yml --build local
kompose.version: 1.30.0 (9d8dcb518)
creationTimestamp: null
labels:
io.kompose.network/compose-default: "true"
Expand Down
3 changes: 0 additions & 3 deletions smoketest/k8s/quarkus-test-agent-service.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
apiVersion: v1
kind: Service
metadata:
annotations:
kompose.cmd: kompose convert -o ./ -f ./../compose/db_k8s.yml -f ./../compose/s3-minio.yml -f ./../compose/cryostat_k8s.yml -f ./../compose/sample-apps.yml --build local
kompose.version: 1.30.0 (9d8dcb518)
creationTimestamp: null
labels:
io.kompose.service: quarkus-test-agent
Expand Down
4 changes: 0 additions & 4 deletions smoketest/k8s/s3-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert -o ./ -f ./../compose/db_k8s.yml -f ./../compose/s3-minio.yml -f ./../compose/cryostat_k8s.yml -f ./../compose/sample-apps.yml --build local
kompose.service.expose: minio
kompose.version: 1.30.0 (9d8dcb518)
creationTimestamp: null
labels:
io.kompose.service: s3
Expand All @@ -20,9 +18,7 @@ spec:
template:
metadata:
annotations:
kompose.cmd: kompose convert -o ./ -f ./../compose/db_k8s.yml -f ./../compose/s3-minio.yml -f ./../compose/cryostat_k8s.yml -f ./../compose/sample-apps.yml --build local
kompose.service.expose: minio
kompose.version: 1.30.0 (9d8dcb518)
creationTimestamp: null
labels:
io.kompose.network/compose-default: "true"
Expand Down
2 changes: 0 additions & 2 deletions smoketest/k8s/s3-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kompose.cmd: kompose convert -o ./ -f ./../compose/db_k8s.yml -f ./../compose/s3-minio.yml -f ./../compose/cryostat_k8s.yml -f ./../compose/sample-apps.yml --build local
kompose.service.expose: minio
kompose.version: 1.30.0 (9d8dcb518)
creationTimestamp: null
labels:
io.kompose.service: s3
Expand Down
2 changes: 0 additions & 2 deletions smoketest/k8s/s3-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ apiVersion: v1
kind: Service
metadata:
annotations:
kompose.cmd: kompose convert -o ./ -f ./../compose/db_k8s.yml -f ./../compose/s3-minio.yml -f ./../compose/cryostat_k8s.yml -f ./../compose/sample-apps.yml --build local
kompose.service.expose: minio
kompose.version: 1.30.0 (9d8dcb518)
creationTimestamp: null
labels:
io.kompose.service: s3
Expand Down
4 changes: 0 additions & 4 deletions smoketest/k8s/sample-app-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ metadata:
io.cryostat.discovery: "true"
io.cryostat.jmxHost: sample-app
io.cryostat.jmxPort: "9093"
kompose.cmd: kompose convert -o ./ -f ./../compose/db_k8s.yml -f ./../compose/s3-minio.yml -f ./../compose/cryostat_k8s.yml -f ./../compose/sample-apps.yml --build local
kompose.version: 1.30.0 (9d8dcb518)
creationTimestamp: null
labels:
io.kompose.service: sample-app
Expand All @@ -24,8 +22,6 @@ spec:
io.cryostat.discovery: "true"
io.cryostat.jmxHost: sample-app
io.cryostat.jmxPort: "9093"
kompose.cmd: kompose convert -o ./ -f ./../compose/db_k8s.yml -f ./../compose/s3-minio.yml -f ./../compose/cryostat_k8s.yml -f ./../compose/sample-apps.yml --build local
kompose.version: 1.30.0 (9d8dcb518)
creationTimestamp: null
labels:
io.kompose.network/compose-default: "true"
Expand Down
2 changes: 0 additions & 2 deletions smoketest/k8s/sample-app-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ metadata:
io.cryostat.discovery: "true"
io.cryostat.jmxHost: sample-app
io.cryostat.jmxPort: "9093"
kompose.cmd: kompose convert -o ./ -f ./../compose/db_k8s.yml -f ./../compose/s3-minio.yml -f ./../compose/cryostat_k8s.yml -f ./../compose/sample-apps.yml --build local
kompose.version: 1.30.0 (9d8dcb518)
creationTimestamp: null
labels:
io.kompose.service: sample-app
Expand Down
15 changes: 11 additions & 4 deletions smoketest/k8s/smoketest.sh → smoketest/k8s/smoketest.bash
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

set -xe

Expand All @@ -24,9 +24,16 @@ while [ "$#" -ne 0 ]; do
cleanKind
;;
generate)
sh "./../../db/build.sh"
kompose convert -o "./" -f "./../compose/db_k8s.yml" -f "./../compose/s3-minio.yml" -f "./../compose/cryostat_k8s.yml" -f "./../compose/sample-apps.yml" --build local
sh generate.sh
sh "${DIR}/../../db/build.sh"
kompose convert \
--with-kompose-annotation=false \
-o "${DIR}" \
-f "${DIR}/../compose/db_k8s.yml" \
-f "${DIR}/../compose/s3-minio.yml" \
-f "${DIR}/../compose/cryostat_k8s.yml" \
-f "${DIR}/../compose/sample-apps.yml" \
--build local
bash "${DIR}/generate.bash"
;;
apply)
kubectl apply -f "./*.yaml"
Expand Down

0 comments on commit 446493e

Please sign in to comment.