Skip to content

Commit

Permalink
chore: improve scripts for semi-manual testing
Browse files Browse the repository at this point in the history
  • Loading branch information
basti1302 committed May 22, 2024
1 parent ac05424 commit 2558dce
Show file tree
Hide file tree
Showing 14 changed files with 157 additions and 55 deletions.
7 changes: 7 additions & 0 deletions test-resources/bin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Test Scripts
============

The scripts in this folder are meant for running semi-manual tests.
They deploy the operator and applications under monitoring - this part is automated via scripts.
Whether the instrumentation was successful or not needs to be verified manually.
This can also be tested in a fully automated way by the tests in `test/e2e`.
16 changes: 16 additions & 0 deletions test-resources/bin/ensure-namespace-exists.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: Copyright 2024 Dash0 Inc.
# SPDX-License-Identifier: Apache-2.0

set -euo pipefail

target_namespace=${1:-default}

if [[ "${target_namespace}" == default ]]; then
exit 0
fi

if ! kubectl get ns ${target_namespace} &> /dev/null; then
kubectl create ns ${target_namespace}
fi
13 changes: 10 additions & 3 deletions test-resources/bin/test-cleanup.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: Copyright 2024 Dash0 Inc.
# SPDX-License-Identifier: Apache-2.0

set -euo pipefail


cd "$(dirname ${BASH_SOURCE})"/../..

kubectl delete -k config/samples || true
target_namespace=${1:-default}

kubectl delete -n ${target_namespace} -k config/samples || true
make uninstall || true
make undeploy || true
test-resources/node.js/express/undeploy.sh
test-resources/collector/undeploy.sh
test-resources/node.js/express/undeploy.sh ${target_namespace}
test-resources/collector/undeploy.sh ${target_namespace}
39 changes: 25 additions & 14 deletions test-resources/bin/test-roundtrip-01-aum-cr-operator.sh
Original file line number Diff line number Diff line change
@@ -1,44 +1,55 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: Copyright 2024 Dash0 Inc.
# SPDX-License-Identifier: Apache-2.0

set -euo pipefail

cd "$(dirname ${BASH_SOURCE})"/../..

echo Make sure cert-manager is deployed as well:
echo test-resources/cert-manager/deploy.sh
if ! kubectl get ns cert-manager &> /dev/null; then
echo cert-manager namespace not found, deploying cert-manager
test-resources/cert-manager/deploy.sh
fi

target_namespace=${1:-default}

echo "STEP 1: creating target namespace (if necessary)"
test-resources/bin/ensure-namespace-exists.sh ${target_namespace}

echo STEP 1: remove old test resources
test-resources/bin/test-cleanup.sh
echo "STEP 2: remove old test resources"
test-resources/bin/test-cleanup.sh ${target_namespace}
echo
echo

echo STEP 2: deploy the collector
test-resources/collector/deploy.sh
echo "STEP 3: deploy the collector to namespace ${target_namespace}"
test-resources/collector/deploy.sh ${target_namespace}
echo
echo

echo STEP 3: rebuild the operator image
echo "STEP 4: rebuild the operator image"
make docker-build
echo
echo

echo STEP 4: deploy application under monitoring
test-resources/node.js/express/build-and-deploy.sh
echo "STEP 5: deploy application under monitoring"
test-resources/node.js/express/build-and-deploy.sh ${target_namespace}
echo
echo

echo STEP 5: install the custom resource definition
echo "STEP 6: install the custom resource definition"
make install
echo
echo

sleep 5

echo STEP 6: deploy the Dash0 custom resource to the target namespace
kubectl apply -k config/samples
echo "STEP 7: deploy the Dash0 custom resource to namespace ${target_namespace}"
kubectl apply -n ${target_namespace} -k config/samples
echo
echo

sleep 5

echo STEP 7: deploy the Dash0 operator
make deploy
echo "STEP 8: deploy the Dash0 operator"
make deploy
37 changes: 24 additions & 13 deletions test-resources/bin/test-roundtrip-02-aum-operator-cr.sh
Original file line number Diff line number Diff line change
@@ -1,44 +1,55 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: Copyright 2024 Dash0 Inc.
# SPDX-License-Identifier: Apache-2.0

set -euo pipefail

cd "$(dirname ${BASH_SOURCE})"/../..

echo Make sure cert-manager is deployed as well:
echo test-resources/cert-manager/deploy.sh
if ! kubectl get ns cert-manager &> /dev/null; then
echo cert-manager namespace not found, deploying cert-manager
test-resources/cert-manager/deploy.sh
fi

target_namespace=${1:-default}

echo "STEP 1: creating target namespace (if necessary)"
test-resources/bin/ensure-namespace-exists.sh ${target_namespace}

echo STEP 1: remove old test resources
test-resources/bin/test-cleanup.sh
echo "STEP 2: remove old test resources"
test-resources/bin/test-cleanup.sh ${target_namespace}
echo
echo

echo STEP 2: deploy the collector
test-resources/collector/deploy.sh
echo "STEP 3: deploy the collector to namespace ${target_namespace}"
test-resources/collector/deploy.sh ${target_namespace}
echo
echo

echo STEP 3: rebuild the operator image
echo "STEP 4: rebuild the operator image"
make docker-build
echo
echo

echo STEP 4: deploy application under monitoring
test-resources/node.js/express/build-and-deploy.sh
echo "STEP 5: deploy application under monitoring"
test-resources/node.js/express/build-and-deploy.sh ${target_namespace}
echo
echo

echo STEP 5: install the custom resource definition
echo "STEP 6: install the custom resource definition"
make install
echo
echo

sleep 5

echo STEP 6: deploy the Dash0 operator
echo "STEP 7: deploy the Dash0 operator"
make deploy
echo
echo

sleep 5

echo STEP 7: deploy the Dash0 custom resource to the target namespace
kubectl apply -k config/samples
echo "STEP 8: deploy the Dash0 custom resource to namespace ${target_namespace}"
kubectl apply -n ${target_namespace} -k config/samples
37 changes: 24 additions & 13 deletions test-resources/bin/test-roundtrip-03-operator-cr-aum.sh
Original file line number Diff line number Diff line change
@@ -1,46 +1,57 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: Copyright 2024 Dash0 Inc.
# SPDX-License-Identifier: Apache-2.0

set -euo pipefail

cd "$(dirname ${BASH_SOURCE})"/../..

echo Make sure cert-manager is deployed as well:
echo test-resources/cert-manager/deploy.sh
if ! kubectl get ns cert-manager &> /dev/null; then
echo cert-manager namespace not found, deploying cert-manager
test-resources/cert-manager/deploy.sh
fi

target_namespace=${1:-default}

echo "STEP 1: creating target namespace (if necessary)"
test-resources/bin/ensure-namespace-exists.sh ${target_namespace}

echo STEP 1: remove old test resources
test-resources/bin/test-cleanup.sh
echo "STEP 2: remove old test resources"
test-resources/bin/test-cleanup.sh ${target_namespace}
echo
echo

echo STEP 2: deploy the collector
test-resources/collector/deploy.sh
echo "STEP 3: deploy the collector to namespace ${target_namespace}"
test-resources/collector/deploy.sh ${target_namespace}
echo
echo

echo STEP 3: rebuild the operator image
echo "STEP 4: rebuild the operator image"
make docker-build
echo
echo

echo STEP 4: install the custom resource definition
echo "STEP 5: install the custom resource definition"
make install
echo
echo

sleep 5

echo STEP 5: deploy the Dash0 operator
echo "STEP 6: deploy the Dash0 operator"
make deploy
echo
echo

sleep 5

echo STEP 6: deploy the Dash0 custom resource to the target namespace
kubectl apply -k config/samples
echo "STEP 7: deploy the Dash0 custom resource to namespace ${target_namespace}"
kubectl apply -n ${target_namespace} -k config/samples
echo
echo

sleep 5

echo STEP 7: deploy application under monitoring
test-resources/node.js/express/build-and-deploy.sh
echo "STEP 8: deploy application under monitoring"
test-resources/node.js/express/build-and-deploy.sh ${target_namespace}
11 changes: 7 additions & 4 deletions test-resources/cert-manager/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: Copyright 2024 Dash0 Inc.
# SPDX-License-Identifier: Apache-2.0

set -euo pipefail

cd "$(dirname ${BASH_SOURCE})"


echo undeploying
echo "removing any left-overs from previous cert-manager installations (if any)"
./undeploy.sh

echo deploying cert-manager
echo "deploying cert-manager and waiting for it to become ready, this might take up to five minutes"
helm install \
cert-manager jetstack/cert-manager \
--namespace cert-manager \
--create-namespace \
--version v1.14.5 \
--set installCRDs=true \
--timeout 10s
--timeout 5m
7 changes: 6 additions & 1 deletion test-resources/cert-manager/undeploy.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: Copyright 2024 Dash0 Inc.
# SPDX-License-Identifier: Apache-2.0

set -euo pipefail

cd "$(dirname ${BASH_SOURCE})"
Expand All @@ -7,4 +11,5 @@ helm uninstall \
cert-manager \
--namespace cert-manager \
--ignore-not-found
kubectl delete namespace cert-manager --ignore-not-found

kubectl delete namespace cert-manager --ignore-not-found
13 changes: 10 additions & 3 deletions test-resources/collector/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: Copyright 2024 Dash0 Inc.
# SPDX-License-Identifier: Apache-2.0

set -euo pipefail

cd "$(dirname ${BASH_SOURCE})"
Expand All @@ -8,12 +12,15 @@ if [[ ! -f values.yaml ]]; then
exit 1
fi

# TODO deploy to a Dash0-specific namespace
target_namespace=${1:-default}

# helm repo add open-telemetry https://open-telemetry.github.io/opentelemetry-helm-charts
helm uninstall dash0-opentelemetry-collector-daemonset --ignore-not-found

./undeploy.sh ${target_namespace}

helm install \
dash0-opentelemetry-collector-daemonset \
open-telemetry/opentelemetry-collector \
--namespace ${target_namespace} \
--values values.yaml \
--set image.repository="otel/opentelemetry-collector-k8s"
--set image.repository="otel/opentelemetry-collector-k8s"
8 changes: 7 additions & 1 deletion test-resources/collector/undeploy.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: Copyright 2024 Dash0 Inc.
# SPDX-License-Identifier: Apache-2.0

set -euo pipefail

cd "$(dirname ${BASH_SOURCE})"

helm uninstall dash0-opentelemetry-collector-daemonset --ignore-not-found
target_namespace=${1:-default}

helm uninstall dash0-opentelemetry-collector-daemonset --namespace ${target_namespace} --ignore-not-found
3 changes: 3 additions & 0 deletions test-resources/node.js/express/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: Copyright 2024 Dash0 Inc.
# SPDX-License-Identifier: Apache-2.0

ARG NODE_VERSION=20.13.1
ARG ALPINE_VERSION=3.19

Expand Down
10 changes: 8 additions & 2 deletions test-resources/node.js/express/build-and-deploy.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: Copyright 2024 Dash0 Inc.
# SPDX-License-Identifier: Apache-2.0

set -euo pipefail

cd "$(dirname ${BASH_SOURCE})"

target_namespace=${1:-default}

if [[ -z ${SKIP_DOCKER_BUILD:-} ]]; then
docker build . -t dash0-operator-nodejs-20-express-test-app
fi

kubectl delete -f deploy.yaml || true
kubectl apply -f deploy.yaml
./undeploy.sh ${target_namespace}
kubectl apply -n ${target_namespace} -f deploy.yaml
3 changes: 3 additions & 0 deletions test-resources/node.js/express/deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-FileCopyrightText: Copyright 2024 Dash0 Inc.
# SPDX-License-Identifier: Apache-2.0

apiVersion: v1
kind: Service
metadata:
Expand Down
8 changes: 7 additions & 1 deletion test-resources/node.js/express/undeploy.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#!/usr/bin/env bash

# SPDX-FileCopyrightText: Copyright 2024 Dash0 Inc.
# SPDX-License-Identifier: Apache-2.0

set -euo pipefail

cd "$(dirname ${BASH_SOURCE})"

kubectl delete -f deploy.yaml || true
target_namespace=${1:-default}

kubectl delete -n ${target_namespace} -f deploy.yaml || true

0 comments on commit 2558dce

Please sign in to comment.