|
| 1 | +# -------------------------------------------------------------------- |
| 2 | +# |
| 3 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 4 | +# contributor license agreements. See the NOTICE file distributed |
| 5 | +# with this work for additional information regarding copyright |
| 6 | +# ownership. The ASF licenses this file to You under the Apache |
| 7 | +# License, Version 2.0 (the "License"); you may not use this file |
| 8 | +# except in compliance with the License. You may obtain a copy of the |
| 9 | +# License at |
| 10 | +# |
| 11 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | +# |
| 13 | +# Unless required by applicable law or agreed to in writing, software |
| 14 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 16 | +# implied. See the License for the specific language governing |
| 17 | +# permissions and limitations under the License. |
| 18 | +# |
| 19 | +# -------------------------------------------------------------------- |
| 20 | + |
| 21 | +name: Sandbox Weekly Validation |
| 22 | + |
| 23 | +on: |
| 24 | + # Run every Monday at 02:00 UTC (weekly validation) |
| 25 | + schedule: |
| 26 | + - cron: '0 2 * * 1' |
| 27 | + |
| 28 | + # Allow manual trigger for testing |
| 29 | + workflow_dispatch: |
| 30 | + |
| 31 | + # Run on changes to sandbox files |
| 32 | + push: |
| 33 | + paths: |
| 34 | + - 'devops/sandbox/**' |
| 35 | + - '.github/workflows/sandbox-validation.yml' |
| 36 | + |
| 37 | + pull_request: |
| 38 | + paths: |
| 39 | + - 'devops/sandbox/**' |
| 40 | + - '.github/workflows/sandbox-validation.yml' |
| 41 | + |
| 42 | +# Prevent concurrent runs on the same ref |
| 43 | +concurrency: |
| 44 | + group: sandbox-validation-${{ github.ref }} |
| 45 | + cancel-in-progress: true |
| 46 | + |
| 47 | +env: |
| 48 | + DOCKER_BUILDKIT: 1 |
| 49 | + COMPOSE_DOCKER_CLI_BUILD: 1 |
| 50 | + |
| 51 | +jobs: |
| 52 | + |
| 53 | + test-single-node-build: |
| 54 | + name: Test Single Node Build |
| 55 | + runs-on: ubuntu-latest |
| 56 | + |
| 57 | + strategy: |
| 58 | + matrix: |
| 59 | + version: ['main', '2.0.0'] |
| 60 | + |
| 61 | + steps: |
| 62 | + - name: Checkout code |
| 63 | + uses: actions/checkout@v4 |
| 64 | + |
| 65 | + - name: Set up Docker Buildx |
| 66 | + uses: docker/setup-buildx-action@v3 |
| 67 | + |
| 68 | + - name: Clean Docker resources |
| 69 | + run: | |
| 70 | + docker system prune -af |
| 71 | + docker volume prune -f |
| 72 | +
|
| 73 | + - name: Test single node deployment |
| 74 | + run: | |
| 75 | + cd devops/sandbox |
| 76 | + ./run.sh -c ${{ matrix.version }} |
| 77 | +
|
| 78 | + echo "Waiting for Apache Cloudberry deployment to complete..." |
| 79 | + timeout 120 bash -c 'until docker logs cbdb-cdw 2>&1 | grep -q "DEPLOYMENT SUCCESSFUL"; do sleep 10; echo "Still waiting for deployment..."; done' |
| 80 | + echo "Deployment completed successfully!" |
| 81 | +
|
| 82 | + # Test basic database operations |
| 83 | + echo "Testing database version..." |
| 84 | + docker exec -u gpadmin cbdb-cdw bash -l -c "psql -c 'SELECT version()'" |
| 85 | +
|
| 86 | + echo "Verifying segment configuration..." |
| 87 | + docker exec -u gpadmin cbdb-cdw bash -l -c "psql -c 'SELECT * FROM gp_segment_configuration'" |
| 88 | +
|
| 89 | + echo "Checking available extensions..." |
| 90 | + docker exec -u gpadmin cbdb-cdw bash -l -c "psql -c 'SELECT * FROM pg_available_extensions'" |
| 91 | +
|
| 92 | + echo "✅ Single node test (${{ matrix.version }}) completed successfully" |
| 93 | + timeout-minutes: 30 |
| 94 | + |
| 95 | + - name: Check container logs on failure |
| 96 | + if: failure() |
| 97 | + run: | |
| 98 | + echo "=== Container Status ===" |
| 99 | + docker ps -a || true |
| 100 | + echo "=== Container Logs (last 100 lines) ===" |
| 101 | + docker logs --tail 100 cbdb-cdw || true |
| 102 | + echo "=== Container Resource Usage ===" |
| 103 | + docker stats --no-stream cbdb-cdw || true |
| 104 | +
|
| 105 | + - name: Cleanup |
| 106 | + if: always() |
| 107 | + run: | |
| 108 | + docker rm -f cbdb-cdw || true |
| 109 | + docker system prune -af || true |
| 110 | +
|
| 111 | + test-multi-node-build: |
| 112 | + name: Test Multi Node Build |
| 113 | + runs-on: ubuntu-latest |
| 114 | + |
| 115 | + strategy: |
| 116 | + matrix: |
| 117 | + version: ['main', '2.0.0'] |
| 118 | + |
| 119 | + steps: |
| 120 | + - name: Checkout code |
| 121 | + uses: actions/checkout@v4 |
| 122 | + |
| 123 | + - name: Set up Docker Buildx |
| 124 | + uses: docker/setup-buildx-action@v3 |
| 125 | + |
| 126 | + - name: Clean Docker resources |
| 127 | + run: | |
| 128 | + docker system prune -af |
| 129 | + docker volume prune -f |
| 130 | +
|
| 131 | + - name: Test multi-node deployment |
| 132 | + run: | |
| 133 | + cd devops/sandbox |
| 134 | + ./run.sh -c ${{ matrix.version }} -m |
| 135 | +
|
| 136 | + echo "Waiting for Apache Cloudberry multi-node deployment to complete..." |
| 137 | + timeout 120 bash -c 'until docker logs cbdb-cdw 2>&1 | grep -q "DEPLOYMENT SUCCESSFUL"; do sleep 15; echo "Still waiting for multi-node deployment..."; done' |
| 138 | + echo "Multi-node deployment completed successfully!" |
| 139 | + timeout-minutes: 30 |
| 140 | + |
| 141 | + - name: Test SSH connectivity between nodes |
| 142 | + run: | |
| 143 | + echo "Testing SSH connectivity from coordinator to all nodes..." |
| 144 | + docker exec -u gpadmin cbdb-cdw bash -l -c "ssh -o StrictHostKeyChecking=no sdw1 'hostname'" |
| 145 | + docker exec -u gpadmin cbdb-cdw bash -l -c "ssh -o StrictHostKeyChecking=no sdw2 'hostname'" |
| 146 | + docker exec -u gpadmin cbdb-cdw bash -l -c "ssh -o StrictHostKeyChecking=no scdw 'hostname'" |
| 147 | + echo "✅ SSH connectivity test passed" |
| 148 | +
|
| 149 | + - name: Test database operations |
| 150 | + run: | |
| 151 | + echo "Testing database version..." |
| 152 | + docker exec -u gpadmin cbdb-cdw bash -l -c "psql -c 'SELECT version()'" |
| 153 | +
|
| 154 | + echo "Verifying segment configuration..." |
| 155 | + docker exec -u gpadmin cbdb-cdw bash -l -c "psql -c 'SELECT * FROM gp_segment_configuration'" |
| 156 | +
|
| 157 | + echo "Checking available extensions..." |
| 158 | + docker exec -u gpadmin cbdb-cdw bash -l -c "psql -c 'SELECT * FROM pg_available_extensions'" |
| 159 | +
|
| 160 | + echo "✅ Multi-node test (${{ matrix.version }}) completed successfully" |
| 161 | + |
| 162 | + - name: Check all container logs on failure |
| 163 | + if: failure() |
| 164 | + run: | |
| 165 | + echo "=== All Container Status ===" |
| 166 | + docker ps -a || true |
| 167 | + echo "=== Coordinator Logs (last 100 lines) ===" |
| 168 | + docker logs --tail 100 cbdb-cdw || true |
| 169 | + echo "=== Standby Coordinator Logs (last 50 lines) ===" |
| 170 | + docker logs --tail 50 cbdb-scdw || true |
| 171 | + echo "=== Segment 1 Logs (last 50 lines) ===" |
| 172 | + docker logs --tail 50 cbdb-sdw1 || true |
| 173 | + echo "=== Segment 2 Logs (last 50 lines) ===" |
| 174 | + docker logs --tail 50 cbdb-sdw2 || true |
| 175 | + echo "=== Network Status ===" |
| 176 | + docker network ls || true |
| 177 | +
|
| 178 | + - name: Cleanup |
| 179 | + if: always() |
| 180 | + run: | |
| 181 | + cd devops/sandbox |
| 182 | + docker compose -f docker-compose-rockylinux9.yml down -v || true |
| 183 | + docker system prune -af || true |
| 184 | +
|
| 185 | + notify-results: |
| 186 | + name: Notify Results |
| 187 | + runs-on: ubuntu-latest |
| 188 | + needs: [test-single-node-build, test-multi-node-build] |
| 189 | + if: always() |
| 190 | + |
| 191 | + steps: |
| 192 | + - name: Generate Summary Report |
| 193 | + run: | |
| 194 | + # Determine status icons |
| 195 | + single_node_icon="❌" |
| 196 | + multi_node_icon="❌" |
| 197 | + overall_status="❌ FAILED" |
| 198 | +
|
| 199 | + if [[ "${{ needs.test-single-node-build.result }}" == "success" ]]; then |
| 200 | + single_node_icon="✅" |
| 201 | + fi |
| 202 | +
|
| 203 | + if [[ "${{ needs.test-multi-node-build.result }}" == "success" ]]; then |
| 204 | + multi_node_icon="✅" |
| 205 | + fi |
| 206 | +
|
| 207 | + if [[ "${{ needs.test-single-node-build.result }}" == "success" ]] && \ |
| 208 | + [[ "${{ needs.test-multi-node-build.result }}" == "success" ]]; then |
| 209 | + overall_status="✅ PASSED" |
| 210 | + fi |
| 211 | +
|
| 212 | + # Generate GitHub Actions Summary |
| 213 | + cat >> $GITHUB_STEP_SUMMARY << EOF |
| 214 | + # 🧪 Apache Cloudberry Sandbox Validation Report |
| 215 | +
|
| 216 | + **Overall Status:** $overall_status |
| 217 | +
|
| 218 | + | Test Type | Status | Versions Tested | |
| 219 | + |-----------|--------|-----------------| |
| 220 | + | Single Node | $single_node_icon ${{ needs.test-single-node-build.result }} | main, 2.0.0 | |
| 221 | + | Multi Node | $multi_node_icon ${{ needs.test-multi-node-build.result }} | main, 2.0.0 | |
| 222 | +
|
| 223 | + **Generated on:** $(date -u '+%Y-%m-%d %H:%M:%S UTC') |
| 224 | + EOF |
| 225 | +
|
| 226 | + # Also output to console for logs |
| 227 | + echo "Validation Results:" |
| 228 | + echo "- Single node test: ${{ needs.test-single-node-build.result }}" |
| 229 | + echo "- Multi node test: ${{ needs.test-multi-node-build.result }}" |
| 230 | + echo "- Overall status: $overall_status" |
| 231 | +
|
| 232 | + # Set exit code based on results (fail if any job is not successful) |
| 233 | + if [[ "${{ needs.test-single-node-build.result }}" != "success" ]] || \ |
| 234 | + [[ "${{ needs.test-multi-node-build.result }}" != "success" ]]; then |
| 235 | + exit 1 |
| 236 | + fi |
0 commit comments