|
| 1 | +name: Test Slurm Cluster |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + workflow_dispatch: # Allow manual trigger |
| 9 | + |
| 10 | +jobs: |
| 11 | + # Build images for all supported versions |
| 12 | + build: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + timeout-minutes: 30 |
| 15 | + strategy: |
| 16 | + matrix: |
| 17 | + slurm_version: ['25.05.3', '24.11.6'] |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Checkout code |
| 21 | + uses: actions/checkout@v4 |
| 22 | + |
| 23 | + - name: Set up Docker Buildx |
| 24 | + uses: docker/setup-buildx-action@v3 |
| 25 | + |
| 26 | + - name: Build Docker image for Slurm ${{ matrix.slurm_version }} |
| 27 | + run: | |
| 28 | + echo "SLURM_VERSION=${{ matrix.slurm_version }}" > .env |
| 29 | + docker compose build |
| 30 | +
|
| 31 | + - name: Save Docker image |
| 32 | + run: | |
| 33 | + docker save slurm-docker-cluster:${{ matrix.slurm_version }} | gzip > slurm-${{ matrix.slurm_version }}.tar.gz |
| 34 | +
|
| 35 | + - name: Upload image artifact |
| 36 | + uses: actions/upload-artifact@v4 |
| 37 | + with: |
| 38 | + name: slurm-image-${{ matrix.slurm_version }} |
| 39 | + path: slurm-${{ matrix.slurm_version }}.tar.gz |
| 40 | + retention-days: 1 |
| 41 | + |
| 42 | + # Test cluster functionality on all versions |
| 43 | + test-cluster: |
| 44 | + needs: build |
| 45 | + runs-on: ubuntu-latest |
| 46 | + timeout-minutes: 30 |
| 47 | + strategy: |
| 48 | + matrix: |
| 49 | + slurm_version: ['25.05.3', '24.11.6'] |
| 50 | + |
| 51 | + steps: |
| 52 | + - name: Checkout code |
| 53 | + uses: actions/checkout@v4 |
| 54 | + |
| 55 | + - name: Download image artifact |
| 56 | + uses: actions/download-artifact@v4 |
| 57 | + with: |
| 58 | + name: slurm-image-${{ matrix.slurm_version }} |
| 59 | + |
| 60 | + - name: Load Docker image |
| 61 | + run: | |
| 62 | + docker load < slurm-${{ matrix.slurm_version }}.tar.gz |
| 63 | + docker images |
| 64 | +
|
| 65 | + - name: Configure version |
| 66 | + run: | |
| 67 | + echo "SLURM_VERSION=${{ matrix.slurm_version }}" > .env |
| 68 | + cat .env |
| 69 | +
|
| 70 | + - name: Start cluster with 2 nodes |
| 71 | + run: | |
| 72 | + docker compose up -d |
| 73 | + echo "Waiting for services to start..." |
| 74 | + sleep 15 |
| 75 | +
|
| 76 | + - name: Wait for MySQL to be healthy |
| 77 | + run: | |
| 78 | + timeout 60 bash -c 'until docker compose ps mysql | grep -q "healthy"; do |
| 79 | + echo "Waiting for MySQL..." |
| 80 | + sleep 2 |
| 81 | + done' |
| 82 | + echo "MySQL is healthy" |
| 83 | +
|
| 84 | + - name: Wait for slurmdbd to be healthy |
| 85 | + run: | |
| 86 | + timeout 60 bash -c 'until docker compose ps slurmdbd | grep -q "healthy"; do |
| 87 | + echo "Waiting for slurmdbd..." |
| 88 | + sleep 2 |
| 89 | + done' |
| 90 | + echo "slurmdbd is healthy" |
| 91 | +
|
| 92 | + - name: Wait for slurmctld to be healthy |
| 93 | + run: | |
| 94 | + timeout 60 bash -c 'until docker compose ps slurmctld | grep -q "healthy"; do |
| 95 | + echo "Waiting for slurmctld..." |
| 96 | + sleep 2 |
| 97 | + done' |
| 98 | + echo "slurmctld is healthy" |
| 99 | +
|
| 100 | + - name: Wait for slurmrestd to be healthy |
| 101 | + run: | |
| 102 | + timeout 60 bash -c 'until docker compose ps slurmrestd | grep -q "healthy"; do |
| 103 | + echo "Waiting for slurmrestd..." |
| 104 | + sleep 2 |
| 105 | + done' |
| 106 | + echo "slurmrestd is healthy" |
| 107 | +
|
| 108 | + - name: Wait for compute nodes to be healthy |
| 109 | + run: | |
| 110 | + timeout 90 bash -c 'until docker compose ps c1 | grep -q "healthy" && docker compose ps c2 | grep -q "healthy"; do |
| 111 | + echo "Waiting for compute nodes..." |
| 112 | + sleep 2 |
| 113 | + done' |
| 114 | + echo "All compute nodes are healthy" |
| 115 | + echo "Waiting for cluster to auto-register with slurmdbd..." |
| 116 | + sleep 10 |
| 117 | +
|
| 118 | + - name: Show cluster status |
| 119 | + run: | |
| 120 | + echo "=== Container Status ===" |
| 121 | + docker compose ps |
| 122 | + echo "" |
| 123 | + echo "=== Slurm Info ===" |
| 124 | + docker exec slurmctld sinfo |
| 125 | + echo "" |
| 126 | + echo "=== Node Details ===" |
| 127 | + docker exec slurmctld scontrol show nodes |
| 128 | +
|
| 129 | + - name: Test REST API |
| 130 | + run: | |
| 131 | + echo "=== Testing REST API via Unix Socket ===" |
| 132 | + # Auto-detect REST API version based on Slurm version |
| 133 | + if [ "${{ matrix.slurm_version }}" == "24.11.6" ]; then |
| 134 | + API_VERSION="v0.0.41" |
| 135 | + else |
| 136 | + API_VERSION="v0.0.42" |
| 137 | + fi |
| 138 | + echo "Using REST API version: $API_VERSION" |
| 139 | +
|
| 140 | + docker exec slurmrestd curl -s --unix-socket /var/run/slurmrestd/slurmrestd.socket \ |
| 141 | + http://localhost/slurm/${API_VERSION}/ping |
| 142 | + echo "" |
| 143 | + echo "=== REST API Jobs Query ===" |
| 144 | + docker exec slurmrestd curl -s --unix-socket /var/run/slurmrestd/slurmrestd.socket \ |
| 145 | + http://localhost/slurm/${API_VERSION}/jobs | head -20 |
| 146 | +
|
| 147 | + - name: Run test suite |
| 148 | + run: chmod +x test_cluster.sh && ./test_cluster.sh |
| 149 | + |
| 150 | + - name: Show logs on failure |
| 151 | + if: failure() |
| 152 | + run: | |
| 153 | + echo "=== Docker Compose Logs ===" |
| 154 | + docker compose logs |
| 155 | + echo "" |
| 156 | + echo "=== Container Status ===" |
| 157 | + docker compose ps |
| 158 | +
|
| 159 | + - name: Cleanup |
| 160 | + if: always() |
| 161 | + run: docker compose down -v |
0 commit comments