|
| 1 | +name: obs-hk-stability-test |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + payload_mb: |
| 7 | + description: Payload object size in MB |
| 8 | + type: number |
| 9 | + default: 50 |
| 10 | + readers: |
| 11 | + description: Number of concurrent reader jobs |
| 12 | + type: number |
| 13 | + default: 20 |
| 14 | + downloads_per_reader: |
| 15 | + description: Repeated downloads per reader job |
| 16 | + type: number |
| 17 | + default: 5 |
| 18 | + runner_pool: |
| 19 | + description: JSON array of {tag, region} objects or plain tags, readers spread round-robin |
| 20 | + type: string |
| 21 | + default: '[{"tag": "linux-aarch64-a3-2-cn12-001", "region": "cn12"}, {"tag": "linux-aarch64-a3-test-2", "region": "gy005"}, {"tag": "linux-aarch64-a3-test-4", "region": "gy005"}, {"tag": "linux-amd64-cpu-test-8-hk", "region": "hk"}]' |
| 22 | + delete_payload: |
| 23 | + description: Delete the test object from OBS when finished |
| 24 | + type: boolean |
| 25 | + default: true |
| 26 | + |
| 27 | +concurrency: |
| 28 | + group: obs-hk-stability-test |
| 29 | + cancel-in-progress: false |
| 30 | + |
| 31 | +env: |
| 32 | + OBS_ENDPOINT: https://obs.ap-southeast-1.myhuaweicloud.com |
| 33 | + OBS_BUCKET: ascend-ci-cache-hk |
| 34 | + PIP_INDEX_URL_FALLBACK: http://cache-service.nginx-pypi-cache.svc.cluster.local/pypi/simple |
| 35 | + |
| 36 | +jobs: |
| 37 | + prepare: |
| 38 | + name: upload payload & plan readers |
| 39 | + runs-on: linux-amd64-cpu-test-8-hk |
| 40 | + timeout-minutes: 15 |
| 41 | + env: |
| 42 | + HW_OBS_AK: ${{ secrets.HW_OBS_AK_HK }} |
| 43 | + HW_OBS_SK: ${{ secrets.HW_OBS_SK_HK }} |
| 44 | + outputs: |
| 45 | + object_key: ${{ steps.upload.outputs.object_key }} |
| 46 | + sha256: ${{ steps.upload.outputs.sha256 }} |
| 47 | + upload_mbps: ${{ steps.upload.outputs.upload_mbps }} |
| 48 | + matrix: ${{ steps.upload.outputs.matrix }} |
| 49 | + steps: |
| 50 | + - uses: actions/checkout@v4 |
| 51 | + |
| 52 | + - name: Bootstrap python tooling |
| 53 | + run: | |
| 54 | + set -e |
| 55 | + if ! command -v python3 >/dev/null 2>&1; then |
| 56 | + apt-get update -qq && apt-get install -y -qq python3 python3-pip \ |
| 57 | + || yum install -y -q python3 python3-pip |
| 58 | + fi |
| 59 | + python3 -V |
| 60 | + python3 -m pip --version >/dev/null 2>&1 \ |
| 61 | + || python3 -m ensurepip --upgrade \ |
| 62 | + || { apt-get install -y -qq python3-pip || yum install -y -q python3-pip; } |
| 63 | + python3 -m pip install --quiet esdk-obs-python \ |
| 64 | + || python3 -m pip install --quiet --index-url "$PIP_INDEX_URL_FALLBACK" \ |
| 65 | + --trusted-host cache-service.nginx-pypi-cache.svc.cluster.local esdk-obs-python |
| 66 | +
|
| 67 | + - name: Upload payload and build matrix |
| 68 | + id: upload |
| 69 | + run: | |
| 70 | + python3 .github/workflows/scripts/obs_stability/prepare.py \ |
| 71 | + --endpoint "$OBS_ENDPOINT" \ |
| 72 | + --bucket "$OBS_BUCKET" \ |
| 73 | + --key "obs-stability/${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}/payload-${{ inputs.payload_mb }}mb.bin" \ |
| 74 | + --size-mb "${{ inputs.payload_mb }}" \ |
| 75 | + --readers "${{ inputs.readers }}" \ |
| 76 | + --runner-pool '${{ inputs.runner_pool }}' \ |
| 77 | + --output-file "$GITHUB_OUTPUT" |
| 78 | +
|
| 79 | + read: |
| 80 | + name: read-${{ matrix.reader_id }} (${{ matrix.region }}) |
| 81 | + needs: prepare |
| 82 | + runs-on: ${{ matrix.runner }} |
| 83 | + timeout-minutes: 30 |
| 84 | + strategy: |
| 85 | + fail-fast: false |
| 86 | + matrix: |
| 87 | + include: ${{ fromJSON(needs.prepare.outputs.matrix) }} |
| 88 | + env: |
| 89 | + HW_OBS_AK: ${{ secrets.HW_OBS_AK_HK }} |
| 90 | + HW_OBS_SK: ${{ secrets.HW_OBS_SK_HK }} |
| 91 | + steps: |
| 92 | + - uses: actions/checkout@v4 |
| 93 | + |
| 94 | + - name: Bootstrap python tooling |
| 95 | + run: | |
| 96 | + set -e |
| 97 | + if ! command -v python3 >/dev/null 2>&1; then |
| 98 | + apt-get update -qq && apt-get install -y -qq python3 python3-pip \ |
| 99 | + || yum install -y -q python3 python3-pip |
| 100 | + fi |
| 101 | + python3 -V |
| 102 | + python3 -m pip --version >/dev/null 2>&1 \ |
| 103 | + || python3 -m ensurepip --upgrade \ |
| 104 | + || { apt-get install -y -qq python3-pip || yum install -y -q python3-pip; } |
| 105 | + python3 -m pip install --quiet esdk-obs-python \ |
| 106 | + || python3 -m pip install --quiet --index-url "$PIP_INDEX_URL_FALLBACK" \ |
| 107 | + --trusted-host cache-service.nginx-pypi-cache.svc.cluster.local esdk-obs-python |
| 108 | +
|
| 109 | + - name: Raw curl timing probes |
| 110 | + run: | |
| 111 | + mkdir -p /tmp/obs-test |
| 112 | + BASE="https://${OBS_BUCKET}.${OBS_ENDPOINT#https://}/" |
| 113 | + for i in $(seq 1 5); do |
| 114 | + curl -o /dev/null -s --max-time 30 \ |
| 115 | + -w '%{http_code} %{time_namelookup} %{time_connect} %{time_appconnect} %{time_starttransfer} %{time_total}\n' \ |
| 116 | + "$BASE" >> /tmp/obs-test/curl.txt || echo "000 0 0 0 0 -1" >> /tmp/obs-test/curl.txt |
| 117 | + done |
| 118 | + cat /tmp/obs-test/curl.txt |
| 119 | +
|
| 120 | + - name: Download payload ${{ inputs.downloads_per_reader }}x |
| 121 | + run: | |
| 122 | + python3 .github/workflows/scripts/obs_stability/read.py \ |
| 123 | + --endpoint "$OBS_ENDPOINT" \ |
| 124 | + --bucket "$OBS_BUCKET" \ |
| 125 | + --key "${{ needs.prepare.outputs.object_key }}" \ |
| 126 | + --sha256 "${{ needs.prepare.outputs.sha256 }}" \ |
| 127 | + --downloads "${{ inputs.downloads_per_reader }}" \ |
| 128 | + --region "${{ matrix.region }}" \ |
| 129 | + --runner-id "${{ matrix.reader_id }}" \ |
| 130 | + --runner-tag "${{ matrix.runner }}" \ |
| 131 | + --out /tmp/obs-test/result.json |
| 132 | +
|
| 133 | + - uses: actions/upload-artifact@v4 |
| 134 | + if: always() |
| 135 | + with: |
| 136 | + name: result-${{ matrix.reader_id }} |
| 137 | + path: /tmp/obs-test/ |
| 138 | + |
| 139 | + report: |
| 140 | + name: aggregate report |
| 141 | + needs: [prepare, read] |
| 142 | + if: always() && needs.prepare.result == 'success' |
| 143 | + runs-on: linux-amd64-cpu-test-8-hk |
| 144 | + timeout-minutes: 10 |
| 145 | + steps: |
| 146 | + - uses: actions/checkout@v4 |
| 147 | + |
| 148 | + - uses: actions/download-artifact@v4 |
| 149 | + with: |
| 150 | + pattern: result-* |
| 151 | + path: results |
| 152 | + |
| 153 | + - name: Summary |
| 154 | + run: | |
| 155 | + python3 .github/workflows/scripts/obs_stability/report.py results \ |
| 156 | + "${{ needs.prepare.outputs.object_key }}" \ |
| 157 | + "${{ needs.prepare.outputs.upload_mbps }}" | tee /tmp/obs-report.md |
| 158 | + cat /tmp/obs-report.md >> "$GITHUB_STEP_SUMMARY" |
| 159 | +
|
| 160 | + cleanup: |
| 161 | + name: delete test object |
| 162 | + needs: [prepare, read] |
| 163 | + if: always() && inputs.delete_payload && needs.prepare.result == 'success' |
| 164 | + runs-on: linux-amd64-cpu-test-8-hk |
| 165 | + timeout-minutes: 10 |
| 166 | + env: |
| 167 | + HW_OBS_AK: ${{ secrets.HW_OBS_AK_HK }} |
| 168 | + HW_OBS_SK: ${{ secrets.HW_OBS_SK_HK }} |
| 169 | + steps: |
| 170 | + - name: Delete payload |
| 171 | + run: | |
| 172 | + python3 -m pip install --quiet esdk-obs-python |
| 173 | + python3 - <<'EOF' |
| 174 | + import os |
| 175 | + from obs import ObsClient |
| 176 | + client = ObsClient( |
| 177 | + access_key_id=os.environ["HW_OBS_AK"], |
| 178 | + secret_access_key=os.environ["HW_OBS_SK"], |
| 179 | + server=os.environ["OBS_ENDPOINT"], |
| 180 | + ) |
| 181 | + resp = client.deleteFile(os.environ["OBS_BUCKET"], "${{ needs.prepare.outputs.object_key }}") |
| 182 | + print("delete status:", resp.status) |
| 183 | + client.close() |
| 184 | + EOF |
0 commit comments