github.com/pingcap/ticdc@v0.0.0-20220526033649-485a10ef2652/scripts/jenkins_ci/cdc_ghpr_kafka_integration_test.groovy (about)

     1  def script_path = "go/src/github.com/pingcap/ticdc/scripts/jenkins_ci/integration_test_common.groovy"
     2  def common = load script_path
     3  
     4  // HACK! Download jks by injecting RACK_COMMAND
     5  // https://git.io/JJZXX -> https://github.com/pingcap/ticdc/raw/6e62afcfecc4e3965d8818784327d4bf2600d9fa/tests/_certificates/kafka.server.keystore.jks
     6  // https://git.io/JJZXM -> https://github.com/pingcap/ticdc/raw/6e62afcfecc4e3965d8818784327d4bf2600d9fa/tests/_certificates/kafka.server.truststore.jks
     7  def download_jks = 'curl -sfL https://git.io/JJZXX -o /tmp/kafka.server.keystore.jks && curl -sfL https://git.io/JJZXM -o /tmp/kafka.server.truststore.jks'
     8  
     9  
    10  catchError {
    11      def KAFKA_TAG = "2.12-2.4.1"
    12      def KAFKA_VERSION = "2.4.1"
    13      // parse kafka tag
    14      def m1 = ghprbCommentBody =~ /kafka-tag\s*=\s*([^\s\\]+)(\s|\\|$)/
    15      if (m1) {
    16          KAFKA_TAG = "${m1[0][1]}"
    17      }
    18      m1 = null
    19      println "KAFKA_TAG=${KAFKA_TAG}"
    20  
    21      // parse kafka version
    22      def m2 = ghprbCommentBody =~ /kafka-version\s*=\s*([^\s\\]+)(\s|\\|$)/
    23      if (m2) {
    24          KAFKA_VERSION = "${m2[0][1]}"
    25      }
    26      m2 = null
    27      println "KAFKA_VERSION=${KAFKA_VERSION}"
    28  
    29      env.KAFKA_VERSION = "${KAFKA_VERSION}"
    30  
    31      common.prepare_binaries()
    32  
    33      def label = "cdc-kafka-integration-${UUID.randomUUID().toString()}"
    34      podTemplate(label: label, idleMinutes: 0,
    35          containers: [
    36              containerTemplate(name: 'golang',alwaysPullImage: false, image: "${GO_DOCKER_IMAGE}",
    37              resourceRequestCpu: '2000m', resourceRequestMemory: '4Gi',
    38              ttyEnabled: true, command: 'cat'),
    39              containerTemplate(name: 'zookeeper',alwaysPullImage: false, image: 'wurstmeister/zookeeper',
    40              resourceRequestCpu: '2000m', resourceRequestMemory: '4Gi',
    41              ttyEnabled: true),
    42              containerTemplate(
    43                  name: 'kafka',
    44                  image: "wurstmeister/kafka:${KAFKA_TAG}",
    45                  resourceRequestCpu: '2000m', resourceRequestMemory: '4Gi',
    46                  ttyEnabled: true,
    47                  alwaysPullImage: false,
    48                  envVars: [
    49                      envVar(key: 'KAFKA_MESSAGE_MAX_BYTES', value: '1073741824'),
    50                      envVar(key: 'KAFKA_REPLICA_FETCH_MAX_BYTES', value: '1073741824'),
    51                      envVar(key: 'KAFKA_BROKER_ID', value: '1'),
    52                      envVar(key: 'RACK_COMMAND', value: download_jks),
    53                      envVar(key: 'KAFKA_LISTENERS', value: 'SSL://127.0.0.1:9093,PLAINTEXT://127.0.0.1:9092'),
    54                      envVar(key: 'KAFKA_ADVERTISED_LISTENERS', value: 'SSL://127.0.0.1:9093,PLAINTEXT://127.0.0.1:9092'),
    55                      envVar(key: 'KAFKA_SSL_KEYSTORE_LOCATION', value: '/tmp/kafka.server.keystore.jks'),
    56                      envVar(key: 'KAFKA_SSL_KEYSTORE_PASSWORD', value: 'test1234'),
    57                      envVar(key: 'KAFKA_SSL_KEY_PASSWORD', value: 'test1234'),
    58                      envVar(key: 'KAFKA_SSL_TRUSTSTORE_LOCATION', value: '/tmp/kafka.server.truststore.jks'),
    59                      envVar(key: 'KAFKA_SSL_TRUSTSTORE_PASSWORD', value: 'test1234'),
    60                      envVar(key: 'ZK', value: 'zk'),
    61                      envVar(key: 'KAFKA_ZOOKEEPER_CONNECT', value: 'localhost:2181'),
    62                  ]
    63          )],
    64          volumes:[
    65              emptyDirVolume(mountPath: '/tmp', memory: true),
    66              emptyDirVolume(mountPath: '/home/jenkins', memory: true)
    67          ]
    68      ) {
    69          common.tests("kafka", label)
    70      }
    71  
    72      currentBuild.result = "SUCCESS"
    73  }
    74  
    75  stage('Summary') {
    76      def duration = ((System.currentTimeMillis() - currentBuild.startTimeInMillis) / 1000 / 60).setScale(2, BigDecimal.ROUND_HALF_UP)
    77      def slackmsg = "[#${ghprbPullId}: ${ghprbPullTitle}]" + "\n" +
    78      "${ghprbPullLink}" + "\n" +
    79      "${ghprbPullDescription}" + "\n" +
    80      "Integration Kafka Test Result: `${currentBuild.result}`" + "\n" +
    81      "Elapsed Time: `${duration} mins` " + "\n" +
    82      "${env.RUN_DISPLAY_URL}"
    83  
    84      if (currentBuild.result != "SUCCESS") {
    85          slackSend channel: '#jenkins-ci', color: 'danger', teamDomain: 'pingcap', tokenCredentialId: 'slack-pingcap-token', message: "${slackmsg}"
    86      }
    87  }