Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(scripts): add scripts to ease local chart testing #196

Merged
merged 11 commits into from
Sep 17, 2024
3 changes: 1 addition & 2 deletions .github/workflows/chart-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ jobs:
cat <(echo '#!/usr/bin/env bash') <(echo 'exec .helm "${@//--reuse-values/--reset-then-reuse-values}"') | sudo tee $HELM_LOCATION
sudo chmod +x $HELM_LOCATION

kubectl create ns $TEST_NAMESPACE
ct install --target-branch ${TARGET_BRANCH} --upgrade --namespace=$TEST_NAMESPACE --config ct.yaml --debug
bash ct.bash --upgrade

helm-unittest:
runs-on: ubuntu-latest
Expand Down
13 changes: 13 additions & 0 deletions ct.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

set -xe

TEST_NAMESPACE="${TEST_NAMESPACE:-helm-test}"

function cleanup() {
kubectl delete ns "${TEST_NAMESPACE}"
andrewazores marked this conversation as resolved.
Show resolved Hide resolved
}
trap cleanup EXIT

kubectl create ns "${TEST_NAMESPACE}"
ct install --remote "${REMOTE:-origin}" --target-branch "${TARGET_BRANCH:-main}" --namespace="${TEST_NAMESPACE}" --config ct.yaml --debug "$@"
andrewazores marked this conversation as resolved.
Show resolved Hide resolved
23 changes: 23 additions & 0 deletions k8s-test.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

set -xe

TEST_NAMESPACE="${TEST_NAMESPACE:-k8s-test}"
RELEASE_NAME="${RELEASE_NAME:-cryostat-k8s-test}"

if [ "${CREATE_CLUSTER:-true}" = "true" ]; then
kind create cluster
fi

kubectl create ns "${TEST_NAMESPACE}"
function cleanup() {
kubectl delete ns "${TEST_NAMESPACE}"
if [ "${CREATE_CLUSTER:-true}" = "true" ]; then
kind delete cluster
fi
}
trap cleanup EXIT
andrewazores marked this conversation as resolved.
Show resolved Hide resolved

helm install --namespace "${TEST_NAMESPACE}" "${RELEASE_NAME}" ./charts/cryostat
kubectl wait --timeout=2m --for=condition=Ready=true --namespace "${TEST_NAMESPACE}" pod -l app.kubernetes.io/name=cryostat
helm test --namespace "${TEST_NAMESPACE}" "${RELEASE_NAME}"