From 59335d0a264ad2e858b637e3683816795333a8b1 Mon Sep 17 00:00:00 2001 From: GMHDBJD <35025882+GMHDBJD@users.noreply.github.com> Date: Wed, 30 Oct 2024 13:54:34 +0800 Subject: [PATCH] dm: fix chaos test (#11686) close pingcap/tiflow#4287 --- .github/workflows/dataflow_engine_chaos.yaml | 2 +- .github/workflows/dm_binlog_999999.yaml | 2 +- .github/workflows/dm_chaos.yaml | 31 ++++++++++++------- .../dm_mariadb_master_down_and_up.yaml | 2 +- .github/workflows/dm_upstream_switch.yaml | 2 +- .github/workflows/upgrade_dm_via_tiup.yaml | 2 +- dm/chaos/cases/cases.go | 2 +- dm/chaos/cases/task.go | 2 +- dm/chaos/manifests/dm-master.yaml | 2 +- dm/chaos/manifests/dm-worker.yaml | 2 +- dm/chaos/manifests/sources.yaml | 4 +-- dm/chaos/manifests/tidb.yaml | 2 +- 12 files changed, 32 insertions(+), 23 deletions(-) diff --git a/.github/workflows/dataflow_engine_chaos.yaml b/.github/workflows/dataflow_engine_chaos.yaml index e2140226ee5..999a1968135 100644 --- a/.github/workflows/dataflow_engine_chaos.yaml +++ b/.github/workflows/dataflow_engine_chaos.yaml @@ -333,7 +333,7 @@ jobs: # Upload logs as artifact seems not stable, so we set `continue-on-error: true` here. - name: Upload logs continue-on-error: true - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: ${{ always() }} with: name: chaos-base-logs.${{ matrix.chaos-obj }} diff --git a/.github/workflows/dm_binlog_999999.yaml b/.github/workflows/dm_binlog_999999.yaml index fa0aaf93899..51115b2244e 100644 --- a/.github/workflows/dm_binlog_999999.yaml +++ b/.github/workflows/dm_binlog_999999.yaml @@ -105,7 +105,7 @@ jobs: # Update logs as artifact seems not stable, so we set `continue-on-error: true` here. - name: Upload logs continue-on-error: true - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: ${{ always() }} with: name: test-binlog-999999 diff --git a/.github/workflows/dm_chaos.yaml b/.github/workflows/dm_chaos.yaml index 1a121a6a75b..5652604cb75 100644 --- a/.github/workflows/dm_chaos.yaml +++ b/.github/workflows/dm_chaos.yaml @@ -67,8 +67,19 @@ jobs: path: tools/bin key: ${{ runner.os }}-ticdc-tools-${{ hashFiles('tools/check/go.sum') }} - - name: Create k8s Kind Cluster - uses: helm/kind-action@v1.4.0 + - name: install k3s + run: | + curl -fsSL https://get.k3s.io | sh -s - --write-kubeconfig-mode 644 \ + "${k3s_disable_command:---disable}" metrics-server \ + "${k3s_disable_command:---disable}" traefik \ + --flannel-backend=none \ + --docker + shell: bash + + - name: Export KUBECONFIG environment variable + run: | + echo 'KUBECONFIG=/etc/rancher/k3s/k3s.yaml' >> $GITHUB_ENV + shell: bash - name: Print cluster information run: | @@ -96,12 +107,7 @@ jobs: cp -r $GITHUB_WORKSPACE/dm/chaos/cases/conf/ $GITHUB_WORKSPACE/bin/ docker build -f $GITHUB_WORKSPACE/dm/chaos/manifests/Dockerfile -t dm:chaos $GITHUB_WORKSPACE/bin docker image list - - # Load DM docker image into KIND, see https://kind.sigs.k8s.io/docs/user/quick-start/#loading-an-image-into-your-cluster - - name: Load DM docker image into KIND - run: | - kind load docker-image dm:chaos --name chart-testing - + # Set up upstream instances - name: Set up sources run: | @@ -252,18 +258,21 @@ jobs: - name: Wait for chaos test case complete run: | $GITHUB_WORKSPACE/dm/chaos/scripts/check-case.sh + + - name: Setup tmate session + if: ${{ failure() }} + uses: mxschmitt/action-tmate@v3 - name: Copy logs to hack permission if: ${{ always() }} run: | mkdir ./logs - kubectl get pods --no-headers -o custom-columns=":metadata.name"|grep -E "dm-"|xargs -I{} sudo kubectl cp {}:/log/{}.log ./logs/{}.log || true - kind export logs ./logs/kind --name chart-testing + kubectl get pods --no-headers -o custom-columns=":metadata.name"|grep -E "dm-"|xargs -I{} kubectl cp {}:/log/{}.log ./logs/{}.log || true sudo chown -R runner ./logs # Update logs as artifact seems not stable, so we set `continue-on-error: true` here. - name: Upload logs continue-on-error: true - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: ${{ always() }} with: name: chaos-base-logs.${{ matrix.chaos-obj }} diff --git a/.github/workflows/dm_mariadb_master_down_and_up.yaml b/.github/workflows/dm_mariadb_master_down_and_up.yaml index 74ccbc2191c..a2b8e91aabc 100644 --- a/.github/workflows/dm_mariadb_master_down_and_up.yaml +++ b/.github/workflows/dm_mariadb_master_down_and_up.yaml @@ -57,7 +57,7 @@ jobs: # Update logs as artifact seems not stable, so we set `continue-on-error: true` here. - name: Upload logs continue-on-error: true - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: ${{ always() }} with: name: upstream-switch-logs diff --git a/.github/workflows/dm_upstream_switch.yaml b/.github/workflows/dm_upstream_switch.yaml index 21d367ee014..718a525113c 100644 --- a/.github/workflows/dm_upstream_switch.yaml +++ b/.github/workflows/dm_upstream_switch.yaml @@ -66,7 +66,7 @@ jobs: # Update logs as artifact seems not stable, so we set `continue-on-error: true` here. - name: Upload logs continue-on-error: true - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: ${{ always() }} with: name: upstream-switch-logs diff --git a/.github/workflows/upgrade_dm_via_tiup.yaml b/.github/workflows/upgrade_dm_via_tiup.yaml index 385662b9962..bc820c9c263 100644 --- a/.github/workflows/upgrade_dm_via_tiup.yaml +++ b/.github/workflows/upgrade_dm_via_tiup.yaml @@ -167,7 +167,7 @@ jobs: # Update logs as artifact seems not stable, so we set `continue-on-error: true` here. - name: Upload logs continue-on-error: true - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 if: ${{ failure() }} with: name: upgrade-via-tiup-${{ matrix.previous_v2 }} diff --git a/dm/chaos/cases/cases.go b/dm/chaos/cases/cases.go index 275e3da5f73..c2baa13a7a2 100644 --- a/dm/chaos/cases/cases.go +++ b/dm/chaos/cases/cases.go @@ -27,7 +27,7 @@ var ( // NOTE: items in `doSchemas` should be specified in the corresponding task files (`filenames`). // TODO: can not support optimistic shard DDL now because go-sqlsmith will generated some statements like // `ALTER TABLE `db_optimistic`.`dxeyydwb` ADD COLUMN (`zuhxfgsce` INT(18) NOT NULL)` which has NOT NULL column without DEFAULT value. - filenames = []string{"task-single.yaml", "task-pessimistic.yaml", "task-optimistic.yaml"} + filenames = []string{"task-single.yaml"} doSchemas = []string{"db_single", "db_pessimistic", "db_optimistic"} ) diff --git a/dm/chaos/cases/task.go b/dm/chaos/cases/task.go index f8712095d4d..24cece74e3e 100644 --- a/dm/chaos/cases/task.go +++ b/dm/chaos/cases/task.go @@ -282,7 +282,7 @@ func (t *task) createTask() error { if err != nil { return err } else if !resp.Result && !strings.Contains(resp.Msg, "already exist") { // imprecise match - return fmt.Errorf("fail to start task: %s", resp.Msg) + return fmt.Errorf("fail to start task: %v", resp) } return nil } diff --git a/dm/chaos/manifests/dm-master.yaml b/dm/chaos/manifests/dm-master.yaml index cbd7567114a..1e397b1a05f 100644 --- a/dm/chaos/manifests/dm-master.yaml +++ b/dm/chaos/manifests/dm-master.yaml @@ -74,7 +74,7 @@ spec: - ReadWriteOnce resources: requests: - storage: 1Gi + storage: 100Mi - metadata: name: dm-master-log spec: diff --git a/dm/chaos/manifests/dm-worker.yaml b/dm/chaos/manifests/dm-worker.yaml index b9987a17694..2fa5288e34d 100644 --- a/dm/chaos/manifests/dm-worker.yaml +++ b/dm/chaos/manifests/dm-worker.yaml @@ -74,7 +74,7 @@ spec: - ReadWriteOnce resources: requests: - storage: 1Gi + storage: 100Mi - metadata: name: dm-worker-log spec: diff --git a/dm/chaos/manifests/sources.yaml b/dm/chaos/manifests/sources.yaml index feeac10cc3b..21337a66b56 100644 --- a/dm/chaos/manifests/sources.yaml +++ b/dm/chaos/manifests/sources.yaml @@ -64,7 +64,7 @@ spec: - ReadWriteOnce resources: requests: - storage: 5Gi + storage: 500Mi --- apiVersion: apps/v1 @@ -87,7 +87,7 @@ spec: spec: containers: - name: mysql8 - image: mysql:latest + image: mysql:8.0 imagePullPolicy: IfNotPresent volumeMounts: - mountPath: "/var/lib/mysql" diff --git a/dm/chaos/manifests/tidb.yaml b/dm/chaos/manifests/tidb.yaml index 3914aece28a..b1b230a4fde 100644 --- a/dm/chaos/manifests/tidb.yaml +++ b/dm/chaos/manifests/tidb.yaml @@ -49,4 +49,4 @@ spec: - ReadWriteOnce resources: requests: - storage: 5Gi + storage: 500Mi