From 5b1883802e4e30e130944ad0c272aebc8911c987 Mon Sep 17 00:00:00 2001 From: Jithin Devasia Date: Mon, 7 Jun 2021 21:20:06 +0530 Subject: [PATCH] Added fission upgrade workflow (#2050) * Adding upgrade workflow file * Update upgrade_test.yaml * Update push_pr.yaml * Update upgrade_test.yaml * adding kube A * Update upgrade_test.yaml * adding script for upgrade testing * adding fission cli from soource * changing order * correcting typo * adding fission fn * restructirung upgrade test scripts * restructirung upgrade test scripts * adding fission cli build * script arrangment * script arrangment * changing job name * adding supporting scripts * adding supporting scripts * adding supporting scripts * script re-ordered * script re-ordered * script modifcation * moved scripts under /test * separated function test blocks * added a sleep * reverting main workflow changes * added stable version installation step * added stable version installation step * stable fn test * adding latest version build * adding latest version build * adding new tests * adding new tests * adding new tests * adding new tests * adding new tests * adding new tests * adding new tests * adding new tests * adding new stable release * adding new stable release * disabling skaffold build and using docker build * disabling skaffold build and using docker build * disabling skaffold build and using docker build * disabling skaffold build and using docker build * fission upgrade using helm * fission upgrade using helm * fission upgrade using helm * fission upgrade using helm * fission upgrade using helm * fission upgrade using helm * fission upgrade using helm * fission upgrade using helm * adding helm upgrade with dependency update * cleanup scripts * added crd deletion step before helm upgrade * added crd deletion step before helm upgrade * added crd deletion step before helm upgrade * adding run tests * added test apache deployment * change in repo name * helm list added * changed pullpolicy * troubleshooting * troubleshooting * troubleshooting * troubleshooting * troubleshooting * troubleshooting * removed hardcoded enteries from helm charts * fixing alignment * cleanup * cleanup * cleanup * cleanup * cleanup * removed temp files [cleanup] * removed timeout * adding preupgradechecks image build * adding fission object creation after upgrade * removing fissin object creation after upgrading... * workflow step split-up * workflow step split-up * workflow step split-up * workflow step split-up * workflow step split-up * workflow step split-up * workflow step split-up * workflow step split-up * workflow step split-up * workflow step split-up * workflow step split-up * workflow step split-up * workflow step split-up * workflow step split-up * workflow step split-up * workflow step split-up * workflow step split-up * workflow step split-up * workflow step split-up * workflow step split-up * workflow step split-up * workflow step split-up * workflow step split-up * clean-up * clean-up * output formatting * added a sleep to re-create resources * added a sleep to re-create resources * added a sleep to re-create resources * excluded examples from upgrade work flow * removed helm stable update step from workflow * removed helm stable update step from workflow * added pr corrections * typo correction * troubleshooting * troubleshooting * troubleshooting * pr corrections * pr corrections * pr corrections * removed sleep after helm upgrade * fixing typo * remvoed sleep after fn creation * clean-up * clean-up * added workflow_dispatch * added workflow_dispatch * added workflow_dispatch * added workflow_dispatch Co-authored-by: Jithindevasia Co-authored-by: Sanket Sudake --- .github/workflows/upgrade_test.yaml | 53 ++++++++++++ test/upgrade_test/fission_objects.sh | 116 +++++++++++++++++++++++++++ 2 files changed, 169 insertions(+) create mode 100644 .github/workflows/upgrade_test.yaml create mode 100644 test/upgrade_test/fission_objects.sh diff --git a/.github/workflows/upgrade_test.yaml b/.github/workflows/upgrade_test.yaml new file mode 100644 index 00000000..e9947440 --- /dev/null +++ b/.github/workflows/upgrade_test.yaml @@ -0,0 +1,53 @@ +name: Upgrade functionality test + +on: [workflow_dispatch] + +jobs: + + upgrade-functionality-test: + runs-on: ubuntu-latest + steps: + - name: Checkout action sources + uses: actions/checkout@v2.3.4 + + - name: Setup go + uses: actions/setup-go@v2.1.3 + with: + go-version: '1.15.12' + + - name: Setup Helm + uses: Azure/setup-helm@v1 + with: + version: v3.3.4 + + - name: Setup Kind Clutser + uses: engineerd/setup-kind@v0.5.0 + with: + config: kind.yaml + + - name: Setup kubectl & fetch node information + run: | + kubectl cluster-info --context kind-kind + kind get kubeconfig --internal >$HOME/.kube/config + kubectl get nodes + + - name: Dump system info + run: | + source ./test/upgrade_test/fission_objects.sh dump_system_info + + - name: Install and configure previous stable fission + run: | + source ./test/upgrade_test/fission_objects.sh install_stable_release \ + && create_fission_objects \ + && test_fission_objects + + - name: Upgrade fission to latest + run: | + source ./test/upgrade_test/fission_objects.sh build_docker_images \ + && kind_image_load \ + && install_current_release \ + && install_fission_cli + + - name: Test previously created fission objects with new release + run: | + source ./test/upgrade_test/fission_objects.sh test_fission_objects \ No newline at end of file diff --git a/test/upgrade_test/fission_objects.sh b/test/upgrade_test/fission_objects.sh new file mode 100644 index 00000000..341d8264 --- /dev/null +++ b/test/upgrade_test/fission_objects.sh @@ -0,0 +1,116 @@ +#!/bin/bash +set -eu + +ns="f-ns" +ROOT=$(pwd) +REPO="docker.io/library" +PREV_STABLE_VERSION=1.12.0 +HELM_VARS_LATEST_RELEASE="helmVars=repository=docker.io/library,image=fission-bundle,pullPolicy=IfNotPresent,imageTag=latest,fetcher.image=docker.io/library/fetcher,fetcher.imageTag=latest,postInstallReportImage=reporter,preUpgradeChecksImage=preupgradechecks" + +getVersion () { + echo $(git rev-parse HEAD) +} + +getDate () { + echo $(date -u +'%Y-%m-%dT%H:%M:%SZ') +} + +getGitCommit () { + echo $(git rev-parse HEAD) +} + +dump_system_info () { + echo "System Info" + go version + docker version + kubectl version + helm version +} + +install_stable_release () { + echo "Creating namespace $ns" + kubectl create ns $ns + echo "Installing Fission $PREV_STABLE_VERSION" + helm install \ + --namespace $ns \ + --name-template fission \ + https://github.com/fission/fission/releases/download/${PREV_STABLE_VERSION}/fission-all-${PREV_STABLE_VERSION}.tgz + mkdir temp && cd temp && curl -Lo fission https://github.com/fission/fission/releases/download/${PREV_STABLE_VERSION}/fission-cli-linux && chmod +x fission && sudo mv fission /usr/local/bin/ && cd .. && rm -rf temp + sleep 10 # This sleep is required here to become all pods active. + } + +create_fission_objects () { + echo "-----------------#########################################--------------------" + echo " Preparing for fission object creation" + echo "-----------------#########################################--------------------" + echo "Creating function environment." + if fission env create --name nodejs --image fission/node-env:latest + then + echo "Successfully created function environment" + else + echo "Environemnt creation failed" + fi + + echo "Creating function" + curl -LO https://raw.githubusercontent.com/fission/examples/master/nodejs/hello.js + if fission function create --name hello --env nodejs --code hello.js + then + echo "Successfully created function" + else + echo "Function creation failed" + exit + fi +} + +test_fission_objects () { + echo "-----------------###############################--------------------" + echo " Running fission object tests" + echo "-----------------###############################--------------------" + if fission function test --name hello + then + echo "----------------------**********************-------------------------" + echo " Test success" + echo "----------------------**********************-------------------------" + else + echo "----------------------**********************-------------------------" + echo " Test failed" + echo "----------------------**********************-------------------------" + fi +} + +build_docker_images () { + echo "Building new docker images" + docker build -t fission-bundle -f cmd/fission-bundle/Dockerfile.fission-bundle . + docker build -t fetcher -f cmd/fetcher/Dockerfile.fission-fetcher . + docker build -t builder -f cmd/builder/Dockerfile.fission-builder . + docker build -t reporter -f cmd/reporter/Dockerfile.reporter . + docker build -t preupgradechecks -f cmd/preupgradechecks/Dockerfile.fission-preupgradechecks . +} + +kind_image_load () { + echo "Loading Docker images into Kind cluster." + kind load docker-image fission-bundle --name kind + kind load docker-image fetcher --name kind + kind load docker-image builder --name kind + kind load docker-image reporter --name kind + kind load docker-image preupgradechecks --name kind + } + +install_fission_cli () { + echo "Installing new Fission cli" + go build -ldflags \ + "-X github.com/fission/fission/pkg/info.GitCommit=$(getGitCommit) \ + -X github.com/fission/fission/pkg/info.BuildDate=$(getDate) \ + -X github.com/fission/fission/pkg/info.Version=$(getVersion)" \ + -o fission ./cmd/fission-cli/main.go + chmod +x fission && sudo mv fission /usr/local/bin/ +} + +install_current_release () { + echo "Running Fission upgrade" + helm dependency update $ROOT/charts/fission-all + kubectl replace -k crds/v1 + helm upgrade --namespace $ns --set $HELM_VARS_LATEST_RELEASE fission $ROOT/charts/fission-all +} + +"$@" \ No newline at end of file