|
| 1 | +name: Cluster End-to-End Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - "main" |
| 7 | + - "release-[0-9]+.[0-9]" |
| 8 | + tags: "**" |
| 9 | + pull_request: |
| 10 | + branches: "**" |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: format('{0}-{1}', ${{ github.ref }}, 'Cluster End-to-End Tests') |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +permissions: read-all |
| 17 | + |
| 18 | +env: |
| 19 | + LAUNCHABLE_ORGANIZATION: "vitess" |
| 20 | + LAUNCHABLE_WORKSPACE: "vitess-app" |
| 21 | + GITHUB_PR_HEAD_SHA: "${{ github.event.pull_request.head.sha }}" |
| 22 | + |
| 23 | +jobs: |
| 24 | + generate-matrix: |
| 25 | + runs-on: ubuntu-24.04 |
| 26 | + outputs: |
| 27 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
| 28 | + steps: |
| 29 | + - name: Check out code |
| 30 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 31 | + with: |
| 32 | + persist-credentials: "false" |
| 33 | + |
| 34 | + - name: Generate shard matrix |
| 35 | + id: set-matrix |
| 36 | + run: | |
| 37 | + # Shards to exclude from this workflow. |
| 38 | + # Modify this list to add or remove shards from the cluster end-to-end tests. |
| 39 | + # These are either: |
| 40 | + # - Run in other dedicated workflows |
| 41 | + # - Not cluster tests (unit tests, examples, etc.) |
| 42 | + # - Special upgrade/downgrade tests |
| 43 | + EXCLUDE_SHARDS='[ |
| 44 | + "", |
| 45 | + "java", |
| 46 | + "docker_cluster", |
| 47 | + "5", |
| 48 | + "28", |
| 49 | + "onlineddl_flow" |
| 50 | + ]' |
| 51 | +
|
| 52 | + # Build matrix |
| 53 | + matrix=$(jq -c -s --argjson exclude "$EXCLUDE_SHARDS" ' |
| 54 | + map(.Tests) | add | to_entries |
| 55 | + | group_by(.value.Shard) |
| 56 | + | map(select(.[0].value.Shard as $s | ($s != null) and ($exclude | index($s) | not))) |
| 57 | + | map({ |
| 58 | + shard: .[0].value.Shard, |
| 59 | + needs: ([.[].value.Needs // []] | add | unique // []), |
| 60 | + buildTag: ([.[].value.BuildTag // null] | map(select(. != null)) | first // "") |
| 61 | + }) |
| 62 | + ' test/config.json test/config_partial_keyspace.json) |
| 63 | +
|
| 64 | + echo "matrix={\"include\":$matrix}" >> $GITHUB_OUTPUT |
| 65 | +
|
| 66 | + test: |
| 67 | + needs: generate-matrix |
| 68 | + if: needs.generate-matrix.outputs.matrix != '' |
| 69 | + timeout-minutes: 60 |
| 70 | + strategy: |
| 71 | + fail-fast: false |
| 72 | + matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix) }} |
| 73 | + |
| 74 | + name: Run endtoend tests on Cluster (${{ matrix.shard }}) |
| 75 | + runs-on: ${{ contains(matrix.needs, 'larger-runner') && 'gh-hosted-runners-16cores-1-24.04' || 'ubuntu-24.04' }} |
| 76 | + |
| 77 | + steps: |
| 78 | + - name: Harden the runner (Audit all outbound calls) |
| 79 | + uses: step-security/harden-runner@e3f713f2d8f53843e71c69a996d56f51aa9adfb9 # v2.14.1 |
| 80 | + with: |
| 81 | + egress-policy: audit |
| 82 | + |
| 83 | + - name: Skip CI |
| 84 | + run: | |
| 85 | + if [[ "${{ contains(github.event.pull_request.labels.*.name, 'Skip CI') }}" == "true" ]]; then |
| 86 | + echo "skipping CI due to the 'Skip CI' label" |
| 87 | + exit 1 |
| 88 | + fi |
| 89 | +
|
| 90 | + - name: Check Memory |
| 91 | + if: contains(matrix.needs, 'memory-check') |
| 92 | + run: | |
| 93 | + totalMem=$(free -g | awk 'NR==2 {print $2}') |
| 94 | + echo "total memory $totalMem GB" |
| 95 | + if [[ "$totalMem" -lt 15 ]]; then |
| 96 | + echo "Less memory than required" |
| 97 | + exit 1 |
| 98 | + fi |
| 99 | +
|
| 100 | + - name: Check out code |
| 101 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 102 | + with: |
| 103 | + persist-credentials: "false" |
| 104 | + |
| 105 | + - name: Check for changes in relevant files |
| 106 | + uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 |
| 107 | + id: changes |
| 108 | + with: |
| 109 | + token: "" |
| 110 | + filters: | |
| 111 | + end_to_end: |
| 112 | + - 'test/config.json' |
| 113 | + - 'test/config_partial_keyspace.json' |
| 114 | + - 'go/**/*.go' |
| 115 | + - 'go/vt/sidecardb/**/*.sql' |
| 116 | + - 'go/test/endtoend/onlineddl/vrepl_suite/**' |
| 117 | + - 'test.go' |
| 118 | + - 'Makefile' |
| 119 | + - 'build.env' |
| 120 | + - 'go.sum' |
| 121 | + - 'go.mod' |
| 122 | + - 'proto/*.proto' |
| 123 | + - 'tools/**' |
| 124 | + - 'config/**' |
| 125 | + - 'bootstrap.sh' |
| 126 | + - '.github/workflows/cluster_endtoend.yml' |
| 127 | +
|
| 128 | + - name: Set up Go |
| 129 | + if: steps.changes.outputs.end_to_end == 'true' |
| 130 | + uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0 |
| 131 | + with: |
| 132 | + go-version-file: go.mod |
| 133 | + |
| 134 | + - name: Set up python |
| 135 | + if: steps.changes.outputs.end_to_end == 'true' |
| 136 | + uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 |
| 137 | + |
| 138 | + - name: Tune the OS |
| 139 | + if: steps.changes.outputs.end_to_end == 'true' |
| 140 | + uses: ./.github/actions/tune-os |
| 141 | + |
| 142 | + - name: Setup MySQL |
| 143 | + if: steps.changes.outputs.end_to_end == 'true' && !contains(matrix.needs, 'xtrabackup') |
| 144 | + uses: ./.github/actions/setup-mysql |
| 145 | + with: |
| 146 | + flavor: mysql-8.0 |
| 147 | + |
| 148 | + - name: Setup Percona Server and XtraBackup |
| 149 | + if: steps.changes.outputs.end_to_end == 'true' && contains(matrix.needs, 'xtrabackup') |
| 150 | + run: | |
| 151 | + sudo apt-get -qq update |
| 152 | + sudo apt-get -qq install -y lsb-release gnupg2 |
| 153 | + wget https://repo.percona.com/apt/percona-release_latest.$(lsb_release -sc)_all.deb |
| 154 | + sudo DEBIAN_FRONTEND="noninteractive" dpkg -i percona-release_latest.$(lsb_release -sc)_all.deb |
| 155 | + sudo percona-release setup pdps8.0 |
| 156 | + sudo apt-get -qq update |
| 157 | + sudo apt-get -qq install -y percona-server-server percona-server-client |
| 158 | + sudo service mysql stop |
| 159 | + sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/ |
| 160 | + sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld |
| 161 | + sudo apt-get -qq install -y percona-xtrabackup-80 lz4 |
| 162 | +
|
| 163 | + - name: Get dependencies |
| 164 | + if: steps.changes.outputs.end_to_end == 'true' |
| 165 | + timeout-minutes: 10 |
| 166 | + run: | |
| 167 | + # Install mysql-shell for non-XtraBackup shards |
| 168 | + if [[ "${{ contains(matrix.needs, 'xtrabackup') }}" != "true" ]]; then |
| 169 | + sudo apt-get -qq install -y mysql-shell |
| 170 | + fi |
| 171 | +
|
| 172 | + sudo apt-get -qq install -y make unzip g++ etcd-client etcd-server curl git wget xz-utils libncurses6 |
| 173 | + sudo service etcd stop |
| 174 | + go mod download |
| 175 | +
|
| 176 | + - name: Install Minio |
| 177 | + if: steps.changes.outputs.end_to_end == 'true' && contains(matrix.needs, 'minio') |
| 178 | + run: | |
| 179 | + wget https://dl.min.io/server/minio/release/linux-amd64/minio |
| 180 | + chmod +x minio |
| 181 | + sudo mv minio /usr/local/bin |
| 182 | +
|
| 183 | + - name: Install Consul and ZooKeeper |
| 184 | + if: steps.changes.outputs.end_to_end == 'true' && contains(matrix.needs, 'consul') |
| 185 | + run: make tools |
| 186 | + |
| 187 | + - name: Setup launchable dependencies |
| 188 | + if: | |
| 189 | + github.event_name == 'pull_request' && |
| 190 | + github.event.pull_request.draft == false && |
| 191 | + steps.changes.outputs.end_to_end == 'true' && |
| 192 | + github.base_ref == 'main' |
| 193 | + run: | |
| 194 | + pip3 install --user launchable~=1.0 > /dev/null |
| 195 | + launchable verify || true |
| 196 | + launchable record build --name "$GITHUB_RUN_ID" --no-commit-collection --source . |
| 197 | +
|
| 198 | + - name: Run cluster endtoend test |
| 199 | + if: steps.changes.outputs.end_to_end == 'true' |
| 200 | + timeout-minutes: 45 |
| 201 | + run: | |
| 202 | + export VTDATAROOT="/tmp/" |
| 203 | + source build.env |
| 204 | + set -exo pipefail |
| 205 | +
|
| 206 | + # Apply resource limits for heavy shards |
| 207 | + if [[ "${{ contains(matrix.needs, 'limit-resources') }}" == "true" ]]; then |
| 208 | + ulimit -n 65536 |
| 209 | + cat <<-EOF>>./config/mycnf/mysql84.cnf |
| 210 | + innodb_buffer_pool_dump_at_shutdown=OFF |
| 211 | + innodb_buffer_pool_in_core_file=OFF |
| 212 | + innodb_buffer_pool_load_at_startup=OFF |
| 213 | + innodb_buffer_pool_size=64M |
| 214 | + innodb_doublewrite=OFF |
| 215 | + innodb_flush_log_at_trx_commit=0 |
| 216 | + innodb_flush_method=O_DIRECT |
| 217 | + innodb_numa_interleave=ON |
| 218 | + innodb_adaptive_hash_index=OFF |
| 219 | + sync_binlog=0 |
| 220 | + sync_relay_log=0 |
| 221 | + performance_schema=OFF |
| 222 | + slow-query-log=OFF |
| 223 | + EOF |
| 224 | + fi |
| 225 | +
|
| 226 | + # Enable binlog compression for vreplication shards |
| 227 | + if [[ "${{ contains(matrix.needs, 'binlog-compression') }}" == "true" ]]; then |
| 228 | + cat <<-EOF>>./config/mycnf/mysql84.cnf |
| 229 | + binlog-transaction-compression=ON |
| 230 | + binlog-row-value-options=PARTIAL_JSON |
| 231 | + EOF |
| 232 | + fi |
| 233 | +
|
| 234 | + # Build test command with optional flags |
| 235 | + EXTRA_FLAGS="" |
| 236 | + if [[ "${{ matrix.buildTag }}" != "" ]]; then |
| 237 | + EXTRA_FLAGS="$EXTRA_FLAGS -build-tag=${{ matrix.buildTag }}" |
| 238 | + fi |
| 239 | + if [[ "${{ matrix.shard }}" == *"partial_keyspace"* ]]; then |
| 240 | + EXTRA_FLAGS="$EXTRA_FLAGS -partial-keyspace=true" |
| 241 | + fi |
| 242 | +
|
| 243 | + go run test.go -docker=false -follow -shard "${{ matrix.shard }}" $EXTRA_FLAGS |
| 244 | +
|
| 245 | + - name: Record test results in launchable |
| 246 | + if: | |
| 247 | + github.event_name == 'pull_request' && |
| 248 | + github.event.pull_request.draft == false && |
| 249 | + steps.changes.outputs.end_to_end == 'true' && |
| 250 | + github.base_ref == 'main' && |
| 251 | + !cancelled() |
| 252 | + run: | |
| 253 | + launchable record tests --build "$GITHUB_RUN_ID" go-test . || true |
| 254 | +
|
| 255 | + - name: Test Summary |
| 256 | + if: steps.changes.outputs.end_to_end == 'true' && failure() |
| 257 | + uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4 |
| 258 | + with: |
| 259 | + paths: "_test/junit/*.xml" |
| 260 | + show: "fail" |
0 commit comments