From b2f18244ee491b8a92b8a0d74f0d6ef8bd264038 Mon Sep 17 00:00:00 2001 From: Ehco1996 Date: Fri, 30 Jul 2021 08:44:28 +0800 Subject: [PATCH 1/3] split dm others test --- .../pipelines/ci/dm/dm_ghpr_new_test.groovy | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/jenkins/pipelines/ci/dm/dm_ghpr_new_test.groovy b/jenkins/pipelines/ci/dm/dm_ghpr_new_test.groovy index 14314c6e5..f95a5e64a 100644 --- a/jenkins/pipelines/ci/dm/dm_ghpr_new_test.groovy +++ b/jenkins/pipelines/ci/dm/dm_ghpr_new_test.groovy @@ -44,7 +44,7 @@ def boolean isBranchMatched(List branches, String targetBranch) { return false } -def isNeedGo1160 = isBranchMatched(['master', "release-2.0"], ghprbTargetBranch) +def isNeedGo1160 = isBranchMatched(['master', 'release-2.0'], ghprbTargetBranch) if (isNeedGo1160) { println 'This build use go1.16' GO_BUILD_SLAVE = GO1160_BUILD_SLAVE @@ -110,6 +110,8 @@ def build_dm_bin() { unstash 'dm' ws = pwd() dir('go/src/github.com/pingcap/dm') { + println "debug command:\nkubectl -n jenkins-tidb exec -ti ${env.NODE_NAME} bash" + // build it test bin sh 'make dm_integration_test_build' @@ -130,8 +132,6 @@ def build_dm_bin() { // use a new version of gh-ost to overwrite the one in container("golang") (1.0.47 --> 1.1.0) sh 'curl -L https://github.com/github/gh-ost/releases/download/v1.1.0/gh-ost-binary-linux-20200828140552.tar.gz | tar xz' sh 'mv gh-ost bin/' - - println "debug command:\nkubectl -n jenkins-tidb exec -ti ${env.NODE_NAME} bash" } dir("${ws}") { stash includes: 'go/src/github.com/pingcap/dm/**', name: 'dm-with-bin', useDefaultExcludes: false @@ -319,6 +319,7 @@ def run_make_coverage() { unstash 'integration-cov-sharding2' unstash 'integration-cov-ha' unstash 'integration-cov-others' + unstash 'integration-cov-others_2' } catch (Exception e) { println e } @@ -686,7 +687,15 @@ pipeline { } } - // END Integration Test + + stage('IT-others-2') { + steps { + script { + run_single_it_test('others_2') + } + } + } + // END Integration Test } } @@ -705,4 +714,4 @@ pipeline { } } } -} \ No newline at end of file +} From 13ba037ebfc2e00ac849c9723dd88c6a256e1d58 Mon Sep 17 00:00:00 2001 From: ehco1996 Date: Sun, 1 Aug 2021 09:45:25 +0800 Subject: [PATCH 2/3] add run_tls_source_it_test --- .../pipelines/ci/dm/dm_ghpr_new_test.groovy | 111 +++++++++++++++++- 1 file changed, 107 insertions(+), 4 deletions(-) diff --git a/jenkins/pipelines/ci/dm/dm_ghpr_new_test.groovy b/jenkins/pipelines/ci/dm/dm_ghpr_new_test.groovy index f95a5e64a..54a6d89cd 100644 --- a/jenkins/pipelines/ci/dm/dm_ghpr_new_test.groovy +++ b/jenkins/pipelines/ci/dm/dm_ghpr_new_test.groovy @@ -17,7 +17,7 @@ if ("${ghprbTargetBranch}" == 'release-1.0') { MYSQL_ARGS = '--ssl=OFF --log-bin --binlog-format=ROW --enforce-gtid-consistency=ON --gtid-mode=ON --server-id=1 --default-authentication-plugin=mysql_native_password' }else { - MYSQL_ARGS = '--log-bin --binlog-format=ROW --enforce-gtid-consistency=ON --gtid-mode=ON --server-id=1 --default-authentication-plugin=mysql_native_password' + MYSQL_ARGS = '--ssl=ON --log-bin --binlog-format=ROW --enforce-gtid-consistency=ON --gtid-mode=ON --server-id=1 --default-authentication-plugin=mysql_native_password' } MYSQL_HOST = '127.0.0.1' @@ -193,6 +193,110 @@ def run_single_unit_test(String case_name) { } } + +def run_tls_source_it_test(String case_name) { + def label = 'dm-integration-test' + podTemplate(label: label, + nodeSelector: 'role_type=slave', + namespace: 'jenkins-tidb', + containers: [ + containerTemplate( + name: 'golang', alwaysPullImage: false, + image: "${POD_GO_DOCKER_IMAGE}", ttyEnabled: true, + resourceRequestCpu: '2000m', resourceRequestMemory: '4Gi', + command: 'cat'), + containerTemplate( + name: 'mysql1', alwaysPullImage: false, + image: 'hub.pingcap.net/jenkins/mysql:5.7',ttyEnabled: true, + resourceRequestCpu: '1000m', resourceRequestMemory: '1Gi', + envVars: [ + envVar(key: 'MYSQL_ROOT_PASSWORD', value: "${MYSQL_PSWD}"), + ], + args: "${MYSQL_ARGS}"), + // mysql 5.7 2 + containerTemplate( + name: 'mysql2', alwaysPullImage: false, + image: 'hub.pingcap.net/jenkins/mysql:5.7',ttyEnabled: true, + resourceRequestCpu: '1000m', resourceRequestMemory: '1Gi', + envVars: [ + envVar(key: 'MYSQL_ROOT_PASSWORD', value: "${MYSQL_PSWD}"), + envVar(key: 'MYSQL_TCP_PORT', value: "${MYSQL2_PORT}") + ], + args: "${MYSQL_ARGS}") + ] + ) { + node(label) { + println "${NODE_NAME}" + println "debug command: \nkubectl -n jenkins-tidb exec -ti ${env.NODE_NAME} -c golang bash" + // stash ssl certs to jenkins, i don't know why if filename == client-key.pem , the stash will fail + // so just hack the filename + container('mysql1') { + def ws = pwd() + deleteDir() + sh "set +e && for i in {1..90}; do mysqladmin ping -h127.0.0.1 -P 3306 -p123456 -uroot --silent; if [ \$? -eq 0 ]; then set -e; break; else if [ \$i -eq 90 ]; then set -e; exit 2; fi; sleep 2; fi; done" + sh "cp -r /var/lib/mysql/*.pem ." + sh "ls" + sh "pwd" + sh "cat client-key.pem > client.key.pem" + sh "cat client.key.pem" + stash includes: 'ca.pem,client-cert.pem,client.key.pem', name: "mysql-certs", useDefaultExcludes: false + } + + container('golang') { + def ws = pwd() + deleteDir() + unstash(name: 'mysql-certs') + sh "ls" + sh "mv client.key.pem client-key.pem" + sh "sudo mkdir -p /var/lib/mysql" + sh "sudo chmod 777 /var/lib/mysql" + sh "cp *.pem /var/lib/mysql/" + sh "ls /var/lib/mysql" + + unstash 'dm-with-bin' + dir('go/src/github.com/pingcap/dm') { + try { + sh""" + # use a new version of gh-ost to overwrite the one in container("golang") (1.0.47 --> 1.1.0) + export PATH=bin:$PATH + rm -rf /tmp/dm_test + mkdir -p /tmp/dm_test + export MYSQL_HOST1=${MYSQL_HOST} + export MYSQL_PORT1=${MYSQL_PORT} + export MYSQL_HOST2=${MYSQL_HOST} + export MYSQL_PORT2=${MYSQL2_PORT} + # wait for mysql container ready. + set +e && for i in {1..90}; do mysqladmin ping -h127.0.0.1 -P 3306 -p123456 -uroot --silent; if [ \$? -eq 0 ]; then set -e; break; else if [ \$i -eq 90 ]; then set -e; exit 2; fi; sleep 2; fi; done + set +e && for i in {1..90}; do mysqladmin ping -h127.0.0.1 -P 3307 -p123456 -uroot --silent; if [ \$? -eq 0 ]; then set -e; break; else if [ \$i -eq 90 ]; then set -e; exit 2; fi; sleep 2; fi; done + # run test + export GOPATH=\$GOPATH:${ws}/go + make integration_test CASE="${case_name}" + # upload coverage + rm -rf cov_dir + mkdir -p cov_dir + ls /tmp/dm_test + cp /tmp/dm_test/cov*out cov_dir + """ + }catch (Exception e) { + sh """ + echo "${case_name} test faild print all log..." + for log in `ls /tmp/dm_test/*/*/log/*.log`; do + echo "____________________________________" + echo "\$log" + cat "\$log" + echo "____________________________________" + done + """ + throw e + } + } + stash includes: 'go/src/github.com/pingcap/dm/cov_dir/**', name: "integration-cov-${case_name}" + } + } + } +} + + def run_single_it_test(String case_name) { def label = 'dm-integration-test' podTemplate(label: label, @@ -212,10 +316,9 @@ def run_single_it_test(String case_name) { envVar(key: 'MYSQL_ROOT_PASSWORD', value: "${MYSQL_PSWD}"), ], args: "${MYSQL_ARGS}"), - // mysql 8.0 containerTemplate( name: 'mysql2', alwaysPullImage: false, - image: 'hub.pingcap.net/zhangxuecheng/mysql:8.0.21',ttyEnabled: true, + image: 'hub.pingcap.net/jenkins/mysql:5.7',ttyEnabled: true, resourceRequestCpu: '1000m', resourceRequestMemory: '1Gi', envVars: [ envVar(key: 'MYSQL_ROOT_PASSWORD', value: "${MYSQL_PSWD}"), @@ -658,7 +761,7 @@ pipeline { stage('IT-tls') { steps { script { - run_single_it_test('tls') + run_tls_source_it_test('tls') } } } From e8cd8eb2eac11eef6db8527a99ef0d515cfd74e7 Mon Sep 17 00:00:00 2001 From: Ehco1996 Date: Mon, 2 Aug 2021 08:47:59 +0800 Subject: [PATCH 3/3] revert to mysql8 --- jenkins/pipelines/ci/dm/dm_ghpr_new_test.groovy | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jenkins/pipelines/ci/dm/dm_ghpr_new_test.groovy b/jenkins/pipelines/ci/dm/dm_ghpr_new_test.groovy index 54a6d89cd..cc80d3865 100644 --- a/jenkins/pipelines/ci/dm/dm_ghpr_new_test.groovy +++ b/jenkins/pipelines/ci/dm/dm_ghpr_new_test.groovy @@ -213,10 +213,10 @@ def run_tls_source_it_test(String case_name) { envVar(key: 'MYSQL_ROOT_PASSWORD', value: "${MYSQL_PSWD}"), ], args: "${MYSQL_ARGS}"), - // mysql 5.7 2 + // mysql 8 containerTemplate( name: 'mysql2', alwaysPullImage: false, - image: 'hub.pingcap.net/jenkins/mysql:5.7',ttyEnabled: true, + image: 'hub.pingcap.net/zhangxuecheng/mysql:8.0.21',ttyEnabled: true, resourceRequestCpu: '1000m', resourceRequestMemory: '1Gi', envVars: [ envVar(key: 'MYSQL_ROOT_PASSWORD', value: "${MYSQL_PSWD}"), @@ -316,9 +316,10 @@ def run_single_it_test(String case_name) { envVar(key: 'MYSQL_ROOT_PASSWORD', value: "${MYSQL_PSWD}"), ], args: "${MYSQL_ARGS}"), + // mysql 8.0.21 containerTemplate( name: 'mysql2', alwaysPullImage: false, - image: 'hub.pingcap.net/jenkins/mysql:5.7',ttyEnabled: true, + image: 'hub.pingcap.net/zhangxuecheng/mysql:8.0.21',ttyEnabled: true, resourceRequestCpu: '1000m', resourceRequestMemory: '1Gi', envVars: [ envVar(key: 'MYSQL_ROOT_PASSWORD', value: "${MYSQL_PSWD}"),