Backup and Restore tests are tracked in Qase #729
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Docker Rancher Setup, Chart Installation & E2E Tests | |
| on: | |
| push: | |
| pull_request: | |
| branches: | |
| - 'main' | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '0 0 * * *' # Runs daily at 12:00 AM UTC (5:30 AM IST) | |
| jobs: | |
| setup_rancher: | |
| name: Setup Rancher - Tag - ${{ matrix.tag }} | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| tag: ['v2.11-head', 'v2.12-head', 'head'] # Rancher version tags | |
| fail-fast: false | |
| # This expression sets max-parallel to 1 for schedules, and 4 for all other events | |
| max-parallel: ${{ github.event_name == 'schedule' && 1 || 4 }} | |
| steps: | |
| - name: Generate random password | |
| id: password_gen | |
| run: echo "PASSWORD=$(openssl rand -base64 16)" >> $GITHUB_ENV | |
| - name: Start Rancher container | |
| run: | | |
| if [[ "${{ matrix.tag }}" == "v2.10-head" || "${{ matrix.tag }}" == "v2.11-head" ]]; then | |
| IMAGE="stgregistry.suse.com/rancher/rancher:${{ matrix.tag }}" | |
| else | |
| IMAGE="rancher/rancher:${{ matrix.tag }}" | |
| fi | |
| docker run -d -it --name rancher \ | |
| -e "CATTLE_BOOTSTRAP_PASSWORD=${{ env.PASSWORD }}" \ | |
| --restart unless-stopped \ | |
| -p 80:80 -p 443:443 -p 6443:6443 \ | |
| --privileged "$IMAGE" | |
| - name: Wait for Rancher to initialize | |
| run: sleep 3m # Rancher's startup time | |
| - name: Generate Rancher API token | |
| id: get_token | |
| run: | | |
| for i in {1..3}; do | |
| LOGIN_RESPONSE=$(curl --silent -X POST -H 'Content-Type: application/json' -d '{"username":"admin","password":"'${{ env.PASSWORD }}'"}' https://localhost/v3-public/localProviders/local?action=login --insecure) | |
| TOKEN=$(echo $LOGIN_RESPONSE | jq -r .token) | |
| if [ -n "$TOKEN" ]; then | |
| echo "RANCHER_TOKEN=$TOKEN" >> $GITHUB_ENV | |
| break | |
| else | |
| echo "Retrying in 20 seconds..." | |
| sleep 20 | |
| fi | |
| done | |
| - name: Check Rancher node status | |
| run: | | |
| for i in {1..15}; do | |
| NODE_STATUS=$(curl -k --silent -H "Authorization: Bearer ${{ env.RANCHER_TOKEN }}" https://localhost/v3/nodes | jq -r '.data[] | .state' | grep -v "active" || true) | |
| if [ -z "$NODE_STATUS" ]; then | |
| echo "All nodes are active and running!" | |
| break | |
| else | |
| echo "Some nodes are not yet active. Retrying in 20 seconds..." | |
| sleep 20 | |
| fi | |
| done | |
| - name: Rancher permanent token for e2e tests | |
| id: get_permanent_token | |
| run: | | |
| PERMANENT_TOKEN_RESPONSE=$(curl --silent -X POST -H 'Content-Type: application/json' -H "Authorization: Bearer ${{ env.RANCHER_TOKEN }}" -d '{"type":"token","description":"e2e-tests"}' https://localhost/v3/token --insecure) | |
| PERMANENT_TOKEN=$(echo $PERMANENT_TOKEN_RESPONSE | jq -r .token) | |
| if [ "$PERMANENT_TOKEN" == "null" ] || [ -z "$PERMANENT_TOKEN" ]; then | |
| echo "Failed to obtain permanent token. Exiting." | |
| exit 1 | |
| fi | |
| echo "RANCHER_PERMANENT_TOKEN=$PERMANENT_TOKEN" >> $GITHUB_ENV | |
| - name: Setup Rancher Config File in Home Directory | |
| run: | | |
| cat << EOF > ~/cattle-config.yaml | |
| rancher: | |
| host: localhost | |
| adminToken: ${{ env.RANCHER_PERMANENT_TOKEN }} | |
| insecure: True | |
| clusterName: local | |
| cleanup: true | |
| EOF | |
| - name: Export CATTLE_TEST_CONFIG environment variable | |
| run: echo "CATTLE_TEST_CONFIG=$HOME/cattle-config.yaml" >> $GITHUB_ENV | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version-file: './go.mod' | |
| - name: Create artifacts directory | |
| run: mkdir -p ~/artifacts | |
| - name: Run Observability Charts Tests | |
| id: run_observability_tests | |
| run: | | |
| sleep 60 | |
| set -e | |
| TEST_LABEL_FILTER=installation go test -timeout 20m github.com/rancher/observability-e2e/tests/e2e -v -count=1 -ginkgo.v | tee ~/artifacts/test-output-installation-${{ matrix.tag }}.txt | |
| TEST_LABEL_FILTER=E2E go test -timeout 30m github.com/rancher/observability-e2e/tests/e2e -v -count=1 -ginkgo.v | tee ~/artifacts/test-output-e2e-${{ matrix.tag }}.txt | |
| - name: Run Installation Charts Tests For Backup and Restore | |
| id: run_installation_tests_backup_restore | |
| run: | | |
| set -e | |
| mv ./tests/helper/yamls/inputBackupRestoreConfig.yaml.example ./tests/helper/yamls/inputBackupRestoreConfig.yaml | |
| TEST_LABEL_FILTER=installation go test -timeout 20m github.com/rancher/observability-e2e/tests/backuprestore/functional -v -count=1 -ginkgo.v | tee ~/artifacts/test-output-installation-${{ matrix.tag }}.txt | |
| - name: Run Observability Upgrade tests | |
| id: run_observability_upgrade_tests | |
| run: | | |
| sleep 60 | |
| set -e | |
| TEST_LABEL_FILTER=beforeUpgrade go test -timeout 20m github.com/rancher/observability-e2e/tests/e2e -v -count=1 -ginkgo.v | tee ~/artifacts/test-output-upgrade-${{ matrix.tag }}.txt | |
| TEST_LABEL_FILTER=E2E go test -timeout 30m github.com/rancher/observability-e2e/tests/e2e -v -count=1 -ginkgo.v | tee ~/artifacts/test-output-e2e-${{ matrix.tag }}.txt | |
| TEST_LABEL_FILTER=afterUpgrade go test -timeout 20m github.com/rancher/observability-e2e/tests/e2e -v -count=1 -ginkgo.v | tee ~/artifacts/test-output-upgrade-${{ matrix.tag }}.txt | |
| TEST_LABEL_FILTER=E2E go test -timeout 30m github.com/rancher/observability-e2e/tests/e2e -v -count=1 -ginkgo.v | tee ~/artifacts/test-output-e2e-${{ matrix.tag }}.txt | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: test-artifacts-${{ matrix.tag }} | |
| path: ~/artifacts | |
| - name: Cleanup all containers | |
| if: always() | |
| run: | | |
| echo "Cleaning up all containers..." | |
| docker ps -q | xargs -r docker rm -f | |
| - name: Check Test Results and Mark Pipeline | |
| if: always() | |
| run: | | |
| for log_file in ~/artifacts/*; do | |
| if [[ -f "$log_file" ]]; then | |
| if grep -q "FAIL!" "$log_file"; then | |
| echo "RANCHER_VERSION=${{ matrix.tag }} failure encounter in $(basename "$log_file") contains failures!" | |
| grep "FAIL!" "$log_file" | |
| exit 1 | |
| else | |
| echo "RANCHER_VERSION=${{ matrix.tag }} test successfully passed with file details -> $(basename "$log_file")" | |
| fi | |
| fi | |
| done |