From b95522d637eb1f6a45a65b1c6dc7636b81207d01 Mon Sep 17 00:00:00 2001 From: Yash Gorana Date: Mon, 26 Feb 2024 18:00:16 +0530 Subject: [PATCH] [tox] add helm upgrade test --- .github/workflows/pr-tests-helm-upgrade.yml | 32 ++++++++++++++ packages/grid/scripts/helm_upgrade.sh | 48 +++++++++++++++++++++ tox.ini | 12 ++++++ 3 files changed, 92 insertions(+) create mode 100644 .github/workflows/pr-tests-helm-upgrade.yml create mode 100644 packages/grid/scripts/helm_upgrade.sh diff --git a/.github/workflows/pr-tests-helm-upgrade.yml b/.github/workflows/pr-tests-helm-upgrade.yml new file mode 100644 index 00000000000..6a9a85aab20 --- /dev/null +++ b/.github/workflows/pr-tests-helm-upgrade.yml @@ -0,0 +1,32 @@ +name: PR Tests - Helm Upgrade + +on: + pull_request: + branches: + - dev + paths: + - packages/grid/helm/syft/** + + workflow_dispatch: + inputs: + none: + description: "Run helm upgrade" + required: false + +jobs: + pr-tests-helm-upgrade: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install Dependencies + if: steps.changes.outputs.syft == 'true' + run: | + pip install --upgrade tox + + - name: Upgrade helm on latest beta + run: | + tox -e dev.k8s.start + tox -e syft.test.helm.upgrade + tox -e dev.k8s.destroy diff --git a/packages/grid/scripts/helm_upgrade.sh b/packages/grid/scripts/helm_upgrade.sh new file mode 100644 index 00000000000..41e588d1c10 --- /dev/null +++ b/packages/grid/scripts/helm_upgrade.sh @@ -0,0 +1,48 @@ +#! /bin/bash + +set -e + +HELM_REPO="openmined/syft" +DOMAIN_NAME="test-domain" +KUBE_NAMESPACE="syft" +KUBE_CONTEXT=${KUBE_CONTEXT:-"k3d-syft-dev"} + +UPGRADE_TYPE=$1 + +PROD="openmined/syft" +BETA="openmined/syft --devel" +DEV="./helm/syft" + +if [ "$UPGRADE_TYPE" == "ProdToDev" ]; then + INSTALL_SOURCE=$PROD # latest published prod + UPGRADE_SOURCE=$BETA # latest published beta + INSTALL_ARGS="" + UPGRADE_ARGS="" +elif [ "$UPGRADE_TYPE" == "BetaToDev" ]; then + INSTALL_SOURCE=$BETA # latest published beta + UPGRADE_SOURCE=$DEV # local chart + INSTALL_ARGS="" + UPGRADE_ARGS="" +else + echo Invalid upgrade type $UPGRADE_TYPE + exit 1 +fi + +kubectl config use-context $KUBE_CONTEXT +kubectl delete namespace syft || true +helm repo add openmined https://openmined.github.io/PySyft/helm +helm repo update openmined + +echo Installing syft... $FROM_CMD +helm install $DOMAIN_NAME $INSTALL_SOURCE $INSTALL_ARGS --namespace $KUBE_NAMESPACE --create-namespace +helm ls -A + +WAIT_TIME=5 bash ./scripts/wait_for.sh service backend --namespace $KUBE_NAMESPACE +WAIT_TIME=5 bash ./scripts/wait_for.sh pod default-pool-0 --namespace $KUBE_NAMESPACE + +echo Upgrading syft... $TO_CMD +helm upgrade $DOMAIN_NAME $UPGRADE_SOURCE $UPGRADE_ARGS --namespace $KUBE_NAMESPACE +helm ls -A + +echo "Post-upgrade sleep" && sleep 5 +WAIT_TIME=5 bash ./scripts/wait_for.sh service backend --namespace $KUBE_NAMESPACE diff --git a/tox.ini b/tox.ini index 0a368808cac..743f05e84f0 100644 --- a/tox.ini +++ b/tox.ini @@ -28,6 +28,7 @@ envlist = syft.build.helm syft.package.helm syft.test.helm + syft.test.helm.upgrade syft.protocol.check syftcli.test.unit syftcli.publish @@ -916,6 +917,17 @@ commands = bash -c "k3d cluster delete syft || true" bash -c "docker volume rm k3d-syft-images --force || true" +[testenv:syft.test.helm.upgrade] +description = Test helm upgrade +changedir = {toxinidir}/packages/grid/ +passenv=HOME,USER,KUBE_CONTEXT +setenv = + UPGRADE_TYPE = {env:UPGRADE_PATH:ProdToDev} +allowlist_externals = + bash +commands = + bash ./scripts/helm_upgrade.sh {env:UPGRADE_TYPE} + [testenv:syftcli.test.unit] description = Syft CLI Unit Tests deps =