|
| 1 | +name: Backup and restore test |
| 2 | + |
| 3 | +on: |
| 4 | + # Allow manual execution on any branch |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + target-cloud: |
| 8 | + description: >- |
| 9 | + The cloud to target for the run. |
| 10 | + Leave blank to use the default cloud. |
| 11 | + type: choice |
| 12 | + options: |
| 13 | + - "" |
| 14 | + - arcus |
| 15 | + - leafcloud |
| 16 | + |
| 17 | +jobs: |
| 18 | + # Tests that a backup and restore re-adopts all the existing platforms correctly |
| 19 | + # |
| 20 | + # Note that success() and failure() consider *all previous steps*, and continue-on-failure |
| 21 | + # prevents the job from being marked as failed if that step fails |
| 22 | + # This means that in order to get the execution flow that we want while still resulting in a |
| 23 | + # failed job when required, we need to use step ids and the conclusions of specific steps |
| 24 | + test_backup_restore: |
| 25 | + runs-on: ubuntu-latest |
| 26 | + steps: |
| 27 | + # We need to check out the code under test first in order to use local actions |
| 28 | + - name: Checkout code under test |
| 29 | + uses: actions/checkout@v3 |
| 30 | + |
| 31 | + - name: Set up Azimuth environment |
| 32 | + uses: ./.github/actions/setup |
| 33 | + with: |
| 34 | + os-clouds: ${{ secrets.OS_CLOUDS }} |
| 35 | + repository: ${{ github.repository }} |
| 36 | + ref: ${{ github.ref }} |
| 37 | + target-cloud: ${{ inputs.target-cloud || vars.TARGET_CLOUD }} |
| 38 | + install-mode: ha |
| 39 | + environment-prefix: ci-restore |
| 40 | + # GitHub terminates jobs after 6 hours |
| 41 | + # We don't want jobs to acquire the lock then get timed out before they can finish |
| 42 | + # So wait a maximum of 3 hours to acquire the lock, leaving 3 hours for other tasks in the job |
| 43 | + timeout-minutes: 180 |
| 44 | + |
| 45 | + - name: Generate S3 credentials for Velero |
| 46 | + run: | |
| 47 | + set -e |
| 48 | + source ci.env |
| 49 | + source ./bin/activate "$AZIMUTH_CONFIG_ENVIRONMENT" "$AZIMUTH_ENVIRONMENT" |
| 50 | + VELERO_S3_ACCESS_KEY="$(openstack ec2 credentials create -f value -c access)" |
| 51 | + VELERO_S3_SECRET_KEY="$(openstack ec2 credentials show -f value -c secret $VELERO_S3_ACCESS_KEY)" |
| 52 | + cat >> ci.env <<EOF |
| 53 | + export VELERO_S3_ACCESS_KEY="$VELERO_S3_ACCESS_KEY" |
| 54 | + export VELERO_S3_SECRET_KEY="$VELERO_S3_SECRET_KEY" |
| 55 | + EOF |
| 56 | +
|
| 57 | + - name: Provision Azimuth |
| 58 | + uses: ./.github/actions/provision |
| 59 | + |
| 60 | + - name: Generate test suite |
| 61 | + id: generate-tests |
| 62 | + run: | |
| 63 | + set -e |
| 64 | + source ./ci.env |
| 65 | + source ./bin/activate "$AZIMUTH_CONFIG_ENVIRONMENT" "$AZIMUTH_ENVIRONMENT" |
| 66 | + ansible-playbook stackhpc.azimuth_ops.generate_tests -e @extra-vars.yml |
| 67 | +
|
| 68 | + - name: Create test platforms |
| 69 | + id: tests-create |
| 70 | + run: | |
| 71 | + set -e |
| 72 | + source ./ci.env |
| 73 | + source ./bin/activate "$AZIMUTH_CONFIG_ENVIRONMENT" "$AZIMUTH_ENVIRONMENT" |
| 74 | + ./bin/run-tests --include create --outputdir reports/create |
| 75 | +
|
| 76 | + - name: Verify test platforms |
| 77 | + run: | |
| 78 | + set -e |
| 79 | + source ./ci.env |
| 80 | + source ./bin/activate "$AZIMUTH_CONFIG_ENVIRONMENT" "$AZIMUTH_ENVIRONMENT" |
| 81 | + ./bin/run-tests --include verify --outputdir reports/verify-create |
| 82 | + if: ${{ !cancelled() && contains(fromJSON('["success", "failure"]'), steps.tests-create.conclusion) }} |
| 83 | + |
| 84 | + - name: Create a backup |
| 85 | + id: backup-create |
| 86 | + run: | |
| 87 | + set -e |
| 88 | + source ./ci.env |
| 89 | + source ./bin/activate "$AZIMUTH_CONFIG_ENVIRONMENT" "$AZIMUTH_ENVIRONMENT" |
| 90 | + ./bin/seed-ssh -- \ |
| 91 | + velero backup create $AZIMUTH_ENVIRONMENT \ |
| 92 | + --kubeconfig ./kubeconfig-azimuth-$AZIMUTH_ENVIRONMENT.yaml \ |
| 93 | + --from-schedule default \ |
| 94 | + --wait |
| 95 | + if: ${{ !cancelled() && steps.generate-tests.conclusion == 'success' }} |
| 96 | + |
| 97 | + - name: Create pre-restore debug bundle |
| 98 | + run: | |
| 99 | + set -e |
| 100 | + source ./ci.env |
| 101 | + source ./bin/activate "$AZIMUTH_CONFIG_ENVIRONMENT" "$AZIMUTH_ENVIRONMENT" |
| 102 | + ./bin/create-debug-bundle |
| 103 | + if: ${{ !cancelled() }} |
| 104 | + |
| 105 | + - name: Upload pre-restore debug bundle |
| 106 | + uses: actions/upload-artifact@v3 |
| 107 | + with: |
| 108 | + name: azimuth-pre-restore-debug-bundle |
| 109 | + path: debug-bundle.tar.gz |
| 110 | + if: ${{ !cancelled() }} |
| 111 | + |
| 112 | + - name: Destroy Azimuth |
| 113 | + id: azimuth-destroy |
| 114 | + run: | |
| 115 | + set -e |
| 116 | + source ./ci.env |
| 117 | + source ./bin/activate "$AZIMUTH_CONFIG_ENVIRONMENT" "$AZIMUTH_ENVIRONMENT" |
| 118 | + ansible-playbook stackhpc.azimuth_ops.destroy -e @extra-vars.yml |
| 119 | + if: ${{ !cancelled() && steps.backup-create.conclusion == 'success' }} |
| 120 | + |
| 121 | + - name: Restore from backup |
| 122 | + id: backup-restore |
| 123 | + run: | |
| 124 | + set -e |
| 125 | + source ./ci.env |
| 126 | + source ./bin/activate "$AZIMUTH_CONFIG_ENVIRONMENT" "$AZIMUTH_ENVIRONMENT" |
| 127 | + ansible-playbook stackhpc.azimuth_ops.restore \ |
| 128 | + -e @extra-vars.yml \ |
| 129 | + -e velero_restore_backup_name=$AZIMUTH_ENVIRONMENT |
| 130 | + if: ${{ !cancelled() && steps.azimuth-destroy.conclusion == 'success' }} |
| 131 | + |
| 132 | + - name: Verify test platforms post restore |
| 133 | + run: | |
| 134 | + set -e |
| 135 | + source ./ci.env |
| 136 | + source ./bin/activate "$AZIMUTH_CONFIG_ENVIRONMENT" "$AZIMUTH_ENVIRONMENT" |
| 137 | + ./bin/run-tests --include verify --outputdir reports/verify-post-restore |
| 138 | + if: ${{ !cancelled() && steps.backup-restore.conclusion == 'success' }} |
| 139 | + |
| 140 | + - name: Delete test platforms |
| 141 | + run: | |
| 142 | + set -e |
| 143 | + source ./ci.env |
| 144 | + source ./bin/activate "$AZIMUTH_CONFIG_ENVIRONMENT" "$AZIMUTH_ENVIRONMENT" |
| 145 | + ./bin/run-tests --include delete --outputdir reports/delete |
| 146 | + if: ${{ always() }} |
| 147 | + |
| 148 | + - name: Delete backup |
| 149 | + run: | |
| 150 | + set -e |
| 151 | + source ./ci.env |
| 152 | + source ./bin/activate "$AZIMUTH_CONFIG_ENVIRONMENT" "$AZIMUTH_ENVIRONMENT" |
| 153 | + ./bin/seed-ssh -- \ |
| 154 | + velero backup delete $AZIMUTH_ENVIRONMENT \ |
| 155 | + --kubeconfig ./kubeconfig-azimuth-$AZIMUTH_ENVIRONMENT.yaml \ |
| 156 | + --confirm |
| 157 | + if: ${{ always() }} |
| 158 | + |
| 159 | + - name: Upload test report artifacts |
| 160 | + uses: actions/upload-artifact@v3 |
| 161 | + with: |
| 162 | + name: azimuth-restore-test-reports |
| 163 | + path: reports/* |
| 164 | + if: ${{ always() }} |
| 165 | + |
| 166 | + - name: Create debug bundle |
| 167 | + run: | |
| 168 | + set -e |
| 169 | + source ./ci.env |
| 170 | + source ./bin/activate "$AZIMUTH_CONFIG_ENVIRONMENT" "$AZIMUTH_ENVIRONMENT" |
| 171 | + ./bin/create-debug-bundle |
| 172 | + if: ${{ always() }} |
| 173 | + |
| 174 | + - name: Upload debug bundle |
| 175 | + uses: actions/upload-artifact@v3 |
| 176 | + with: |
| 177 | + name: azimuth-restore-debug-bundle |
| 178 | + path: debug-bundle.tar.gz |
| 179 | + if: ${{ always() }} |
| 180 | + |
| 181 | + - name: Destroy Azimuth |
| 182 | + uses: ./.github/actions/destroy |
| 183 | + if: ${{ always() }} |
| 184 | + |
| 185 | + - name: Delete Velero S3 credentials |
| 186 | + run: | |
| 187 | + set -e |
| 188 | + source ./ci.env |
| 189 | + source ./bin/activate "$AZIMUTH_CONFIG_ENVIRONMENT" "$AZIMUTH_ENVIRONMENT" |
| 190 | + openstack ec2 credentials delete $VELERO_S3_ACCESS_KEY |
| 191 | + if: ${{ always() }} |
0 commit comments