From 61d2799bac92da49501adf24406050ea665fcac0 Mon Sep 17 00:00:00 2001 From: Vicente Cheng Date: Mon, 30 Sep 2024 17:54:14 +0800 Subject: [PATCH] ci: test parallel Signed-off-by: Vicente Cheng --- .github/workflows/basic-ci.yaml | 90 +++++++++++++++++++++++++++++---- ci/scripts/deploy_ndm.sh | 6 ++- 2 files changed, 86 insertions(+), 10 deletions(-) diff --git a/.github/workflows/basic-ci.yaml b/.github/workflows/basic-ci.yaml index 908df020..7d60890f 100644 --- a/.github/workflows/basic-ci.yaml +++ b/.github/workflows/basic-ci.yaml @@ -25,7 +25,7 @@ jobs: run: | make validate make validate-ci - main_jobs: + job-new-installation: needs: validation runs-on: - self-hosted @@ -42,9 +42,81 @@ jobs: - name: "Local Deployment (Harvester+Longhorn+Node-Disk-Manager) for testing" id: vm_deploy run: | - rm -rf ndm-vagrant-k3s - git clone https://github.com/bk201/vagrant-k3s ndm-vagrant-k3s - pushd ndm-vagrant-k3s + rm -rf ndm-new-vagrant-k3s + git clone https://github.com/bk201/vagrant-k3s ndm-new-vagrant-k3s + pushd ndm-new-vagrant-k3s + yq e -i ".cluster_size = 1" settings.yaml + ./new-cluster.sh + echo "VM_DEPLOYED=true" >> "$GITHUB_ENV" + yq e -i ".longhorn_version = \"1.7.1\"" settings.yaml + ./scripts/deploy_longhorn.sh + popd + - name: "Patch Image target" + run: | + ./ci/scripts/patch-ttl-repo.sh + echo "NDM override result as below:" + cat ci/charts/ndm-override.yaml + - name: "Deploy NDM" + run: | + pushd ndm-new-vagrant-k3s + cp ../ci/scripts/deploy_ndm.sh ./deploy_ndm.sh + cp ../ci/charts/ndm-override.yaml ./ndm-override.yaml + ./deploy_ndm.sh + popd + - name: "Add disk" + run: | + pushd ndm-new-vagrant-k3s + ./scripts/attach-disk.sh node1 test-fresh-installation + sleep 30 + popd + - name: "Run Basic Test" + id: basic-test + run: | + pushd ndm-new-vagrant-k3s + vagrant ssh-config node1 > ../ssh-config + cp kubeconfig ../kubeconfig + popd + echo Running integration tests + NDM_HOME=`pwd` go test -v ./tests/... + - name: "Get NDM logs" + if: always() + run: | + if [ ${{ env.VM_DEPLOYED }} != 'true' ]; then + echo "VM is not deployed, skip getting logs" + exit 0 + fi + ./ci/scripts/get-debug-info.sh + - name: "Tear Down / Cleanup" + if: always() + run: | + if [ ${{ env.VM_DEPLOYED }} != 'true' ]; then + echo "VM is not deployed, skip VM destroy" + exit 0 + fi + pushd ndm-new-vagrant-k3s + vagrant destroy -f --parallel + popd + + jobs-upgrade: + needs: validation + runs-on: + - self-hosted + - golang + steps: + - name: "Clone and check" + uses: actions/checkout@v3 + - name: "Build the Image for the Integration Test" + run: | + BUILD_FOR_CI=true make + ./ci/scripts/patch-ttl-repo.sh + echo "NDM override result as below:" + cat ci/charts/ndm-override.yaml + - name: "Local Deployment (Harvester+Longhorn+Node-Disk-Manager) for testing" + id: vm_deploy + run: | + rm -rf ndm-upgrade-vagrant-k3s + git clone https://github.com/bk201/vagrant-k3s ndm-upgrade-vagrant-k3s + pushd ndm-upgrade-vagrant-k3s yq e -i ".cluster_size = 1" settings.yaml ./new-cluster.sh echo "VM_DEPLOYED=true" >> "$GITHUB_ENV" @@ -55,8 +127,8 @@ jobs: popd - name: "Add disk" run: | - pushd ndm-vagrant-k3s - ./scripts/attach-disk.sh node1 + pushd ndm-upgrade-vagrant-k3s + ./scripts/attach-disk.sh node1 test-upgrade sleep 30 popd - name: "Patch Image target (for upgrade)" @@ -66,14 +138,14 @@ jobs: cat ci/charts/ndm-override.yaml - name: "Upgrade NDM" run: | - pushd ndm-vagrant-k3s + pushd ndm-upgrade-vagrant-k3s cp ../ci/scripts/upgrade_ndm.sh ./upgrade_ndm.sh ./upgrade_ndm.sh popd - name: "Run Basic Test" id: basic-test run: | - pushd ndm-vagrant-k3s + pushd ndm-upgrade-vagrant-k3s vagrant ssh-config node1 > ../ssh-config cp kubeconfig ../kubeconfig popd @@ -94,6 +166,6 @@ jobs: echo "VM is not deployed, skip VM destroy" exit 0 fi - pushd ndm-vagrant-k3s + pushd ndm-upgrade-vagrant-k3s vagrant destroy -f --parallel popd diff --git a/ci/scripts/deploy_ndm.sh b/ci/scripts/deploy_ndm.sh index 06739f0c..99bd360b 100755 --- a/ci/scripts/deploy_ndm.sh +++ b/ci/scripts/deploy_ndm.sh @@ -73,10 +73,14 @@ ensure_longhorn_ready pushd $TOP_DIR -cat >> ndm-override.yaml << 'EOF' +cat >> ndm-override.yaml.default << 'EOF' autoProvisionFilter: [/dev/sd*] EOF +if [ ! -f ndm-override.yaml ]; then + mv ndm-override.yaml.default ndm-override.yaml +fi + $HELM pull harvester-node-disk-manager --repo https://charts.harvesterhci.io --untar $HELM install -f $TOP_DIR/ndm-override.yaml harvester-node-disk-manager ./harvester-node-disk-manager --create-namespace -n harvester-system