You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by mc...@apache.org on 2021/04/01 19:21:46 UTC

[cassandra-builds] branch trunk updated: Provide scripts to dockerise test runs

This is an automated email from the ASF dual-hosted git repository.

mck pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra-builds.git


The following commit(s) were added to refs/heads/trunk by this push:
     new ba84d34  Provide scripts to dockerise test runs
ba84d34 is described below

commit ba84d34e8ef38c890a38a1d6d7e73d268c36eb8d
Author: Mick Semb Wever <mc...@apache.org>
AuthorDate: Thu Apr 1 11:35:51 2021 +0200

    Provide scripts to dockerise test runs
    
     patch by Mick Semb Wever; reviewed by Brandon Williams
---
 build-scripts/cassandra-dtest-pytest-docker.sh | 76 ++++++++++++++++++++++++++
 build-scripts/cassandra-test-docker.sh         | 71 ++++++++++++++++++++++++
 docker/jenkins/dtest.sh                        | 15 -----
 docker/jenkins/jenkinscommand.sh               | 47 ----------------
 jenkins-dsl/cassandra_job_dsl_seed.groovy      | 20 +++----
 5 files changed, 154 insertions(+), 75 deletions(-)

diff --git a/build-scripts/cassandra-dtest-pytest-docker.sh b/build-scripts/cassandra-dtest-pytest-docker.sh
new file mode 100644
index 0000000..5a2291c
--- /dev/null
+++ b/build-scripts/cassandra-dtest-pytest-docker.sh
@@ -0,0 +1,76 @@
+#!/bin/bash
+#
+# A wrapper script to cassandra-dtest-pytest.sh
+#  that runs it in docker, collecting results.
+#
+# The docker image used is normally based from those found in docker/testing/
+#
+# Usage: cassandra-dtest-pytest-docker.sh REPO BRANCH DTEST_REPO_URL DTEST_BRANCH BUILDS_REPO_URL BUILDS_BRANCH DOCKER_IMAGE [target] [split_chunk]
+#
+
+if [ "$#" -lt 3 ]; then
+    # inside the docker container, setup env before calling cassandra-dtest-pytest.sh
+    export WORKSPACE=/home/cassandra/cassandra
+    export LANG=en_US.UTF-8
+    export LC_CTYPE=en_US.UTF-8
+    export PYTHONIOENCODING=utf-8
+    export PYTHONUNBUFFERED=true
+    echo "running: git clone --depth 1 --single-branch --branch=$BRANCH https://github.com/$REPO/cassandra.git"
+    git clone --depth 1 --single-branch --branch=$BRANCH https://github.com/$REPO/cassandra.git
+    cd cassandra
+    echo "running: git clone --depth 1 --single-branch --branch=$DTEST_BRANCH $DTEST_REPO"
+    git clone --depth 1 --single-branch --branch=$DTEST_BRANCH $DTEST_REPO
+    echo "cassandra-dtest-pytest.sh (${1} ${2}) cassandra: `git log -1 --pretty=format:'%h %an %ad %s'`" | tee "${1}-$(echo $2 | sed 's/\//-/')-cassandra.head"
+    echo "cassandra-dtest-pytest.sh (${1} ${2}) cassandra-dtest: `git -C cassandra-dtest log -1 --pretty=format:'%h %an %ad %s'`" | tee -a "${1}-$(echo $2 | sed 's/\//-/')-cassandra.head"
+    echo "cassandra-dtest-pytest.sh (${1} ${2}) cassandra-builds: `git -C ../cassandra-builds log -1 --pretty=format:'%h %an %ad %s'`" | tee -a "${1}-$(echo $2 | sed 's/\//-/')-cassandra.head"
+    ../cassandra-builds/build-scripts/cassandra-dtest-pytest.sh "$@"
+    xz test_stdout.txt
+else
+    # start the docker container
+    if [ "$#" -lt 7 ]; then
+       echo "Usage: cassandra-dtest-pytest.sh REPO BRANCH DTEST_REPO_URL DTEST_BRANCH BUILDS_REPO_URL BUILDS_BRANCH DOCKER_IMAGE [target] [split_chunk]"
+       exit 1
+    fi
+    BUILDSREPO=$5
+    BUILDSBRANCH=$6
+    DOCKER_IMAGE=$7
+    TARGET=$8
+    SPLIT_CHUNK=$9
+    cat > env.list <<EOF
+REPO=$1
+BRANCH=$2
+DTEST_REPO=$3
+DTEST_BRANCH=$4
+EOF
+
+    echo "cassandra-dtest-pytest.sh: running: git clone --single-branch --depth 1 --branch $BUILDSBRANCH $BUILDSREPO; sh ./cassandra-builds/build-scripts/cassandra-dtest-pytest.sh $TARGET $SPLIT_CHUNK"
+    ID=$(docker run -m 15g --memory-swap 15g --env-file env.list -dt $DOCKER_IMAGE dumb-init bash -ilc "git clone --single-branch --depth 1 --branch $BUILDSBRANCH $BUILDSREPO; sh ./cassandra-builds/build-scripts/cassandra-dtest-pytest-docker.sh $TARGET $SPLIT_CHUNK")
+
+    # use docker attach instead of docker wait to get output
+    docker attach --no-stdin $ID
+    status="$?"
+
+    if [ "$status" -ne 0 ] ; then
+        echo "$ID failed (${status}), debug…"
+        docker inspect $ID
+        echo "–––"
+        docker logs $ID
+        echo "–––"
+        docker ps -a
+        echo "–––"
+        docker info
+        echo "–––"
+        dmesg
+    else
+        echo "$ID done (${status}), copying files"
+        # dtest.sh meta
+        docker cp "$ID:/home/cassandra/cassandra/${TARGET}-$(echo $SPLIT_CHUNK | sed 's/\//-/')-cassandra.head" .
+        # pytest results
+        docker cp $ID:/home/cassandra/cassandra/cassandra-dtest/nosetests.xml .
+        # pytest logs
+        docker cp $ID:/home/cassandra/cassandra/test_stdout.txt.xz .
+        docker cp $ID:/home/cassandra/cassandra/cassandra-dtest/ccm_logs.tar.xz .
+    fi
+
+    docker rm $ID
+fi
\ No newline at end of file
diff --git a/build-scripts/cassandra-test-docker.sh b/build-scripts/cassandra-test-docker.sh
new file mode 100644
index 0000000..ce14a73
--- /dev/null
+++ b/build-scripts/cassandra-test-docker.sh
@@ -0,0 +1,71 @@
+#!/bin/bash
+#
+# A wrapper script to cassandra-test.sh
+#  that runs it in docker, collecting results.
+#
+# The docker image used is normally based from those found in docker/testing/
+#
+# Usage: cassandra-test-docker.sh REPO BRANCH BUILDS_REPO_URL BUILDS_BRANCH DOCKER_IMAGE [target] [split_chunk]
+#
+
+if [ "$#" -lt 3 ]; then
+    # inside the docker container, setup env before calling cassandra-test.sh
+    export WORKSPACE=/home/cassandra/cassandra
+    export LANG=en_US.UTF-8
+    export LC_CTYPE=en_US.UTF-8
+    export PYTHONIOENCODING=utf-8
+    export PYTHONUNBUFFERED=true
+    echo "running: git clone --depth 1 --single-branch --branch=$BRANCH https://github.com/$REPO/cassandra.git"
+    git clone --depth 1 --single-branch --branch=$BRANCH https://github.com/$REPO/cassandra.git
+    cd cassandra
+    echo "cassandra-test.sh (${1} ${2}) cassandra: `git log -1 --pretty=format:'%h %an %ad %s'`" | tee "${1}-$(echo $2 | sed 's/\//-/')-cassandra.head"
+    echo "cassandra-test.sh (${1} ${2}) cassandra-builds: `git -C ../cassandra-builds log -1 --pretty=format:'%h %an %ad %s'`" | tee -a "${1}-$(echo $2 | sed 's/\//-/')-cassandra.head"
+    bash ../cassandra-builds/build-scripts/cassandra-test.sh "$@"
+    find build/test/logs -type f -name "*.log" | xargs xz -qq
+else
+    # start the docker container
+    if [ "$#" -lt 5 ]; then
+       echo "Usage: cassandra-test-docker.sh REPO BRANCH BUILDS_REPO_URL BUILDS_BRANCH DOCKER_IMAGE [target] [split_chunk]"
+       exit 1
+    fi
+    BUILDSREPO=$3
+    BUILDSBRANCH=$4
+    DOCKER_IMAGE=$5
+    TARGET=$6
+    SPLIT_CHUNK=$7
+    cat > env.list <<EOF
+REPO=$1
+BRANCH=$2
+EOF
+
+    echo "cassandra-test-docker.sh: running: git clone --single-branch --depth 1 --branch $BUILDSBRANCH $BUILDSREPO; sh ./cassandra-builds/build-scripts/cassandra-test-docker.sh $TARGET $SPLIT_CHUNK"
+    ID=$(docker run -m 15g --memory-swap 15g --env-file env.list -dt $DOCKER_IMAGE dumb-init bash -ilc "git clone --single-branch --depth 1 --branch $BUILDSBRANCH $BUILDSREPO; sh ./cassandra-builds/build-scripts/cassandra-test-docker.sh $TARGET $SPLIT_CHUNK")
+
+    # use docker attach instead of docker wait to get output
+    docker attach --no-stdin $ID
+    status="$?"
+
+    if [ "$status" -ne 0 ] ; then
+        echo "$ID failed (${status}), debug…"
+        docker inspect $ID
+        echo "–––"
+        docker logs $ID
+        echo "–––"
+        docker ps -a
+        echo "–––"
+        docker info
+        echo "–––"
+        dmesg
+    else
+        echo "$ID done (${status}), copying files"
+        # test meta
+        docker cp "$ID:/home/cassandra/cassandra/${TARGET}-$(echo $SPLIT_CHUNK | sed 's/\//-/')-cassandra.head" .
+        # test results
+        mkdir -p build/test
+        docker cp $ID:/home/cassandra/cassandra/build/test/output/. build/test/output
+        # test logs
+        docker cp $ID:/home/cassandra/cassandra/build/test/logs/. build/test/logs
+    fi
+
+    docker rm $ID
+fi
diff --git a/docker/jenkins/dtest.sh b/docker/jenkins/dtest.sh
deleted file mode 100644
index 7f15f4a..0000000
--- a/docker/jenkins/dtest.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/bin/sh
-export WORKSPACE=/home/cassandra/cassandra
-export LANG=en_US.UTF-8
-export LC_CTYPE=en_US.UTF-8
-export PYTHONIOENCODING=utf-8
-export PYTHONUNBUFFERED=true
-echo "dtest.sh: running: git clone --depth 1 --single-branch --branch=$BRANCH https://github.com/$REPO/cassandra.git"
-git clone --depth 1 --single-branch --branch=$BRANCH https://github.com/$REPO/cassandra.git
-cd cassandra
-echo git clone --depth 1 --single-branch --branch=$DTEST_BRANCH $DTEST_REPO
-git clone --depth 1 --single-branch --branch=$DTEST_BRANCH $DTEST_REPO
-echo "dtest.sh (${1} ${2}) cassandra: `git log -1 --pretty=format:'%h %an %ad %s'`" | tee "${1}-$(echo $2 | sed 's/\//-/')-cassandra.head"
-echo "dtest.sh (${1} ${2}) cassandra-dtest: `git -C cassandra-dtest log -1 --pretty=format:'%h %an %ad %s'`" | tee -a "${1}-$(echo $2 | sed 's/\//-/')-cassandra.head"
-echo "dtest.sh (${1} ${2}) cassandra-builds: `git -C ../cassandra-builds log -1 --pretty=format:'%h %an %ad %s'`" | tee -a "${1}-$(echo $2 | sed 's/\//-/')-cassandra.head"
-../cassandra-builds/build-scripts/cassandra-dtest-pytest.sh "$@"
diff --git a/docker/jenkins/jenkinscommand.sh b/docker/jenkins/jenkinscommand.sh
deleted file mode 100644
index 88d3d24..0000000
--- a/docker/jenkins/jenkinscommand.sh
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/bin/sh
-if [ "$#" -lt 7 ]; then
-   echo "Usage: jenkinscommand.sh REPO BRANCH DTEST_REPO_URL DTEST_BRANCH BUILDS_REPO_URL BUILDS_BRANCH DOCKER_IMAGE [target]"
-   exit 1
-fi
-BUILDSREPO=$5
-BUILDSBRANCH=$6
-DOCKER_IMAGE=$7
-TARGET=$8
-SPLIT_CHUNK=$9
-cat > env.list <<EOF
-REPO=$1
-BRANCH=$2
-DTEST_REPO=$3
-DTEST_BRANCH=$4
-EOF
-
-echo "jenkinscommand.sh: running: git clone --single-branch --depth 1 --branch $BUILDSBRANCH $BUILDSREPO; sh ./cassandra-builds/docker/jenkins/dtest.sh $TARGET $SPLIT_CHUNK"
-ID=$(docker run -m 15g --memory-swap 15g --env-file env.list -dt $DOCKER_IMAGE dumb-init bash -ilc "git clone --single-branch --depth 1 --branch $BUILDSBRANCH $BUILDSREPO; sh ./cassandra-builds/docker/jenkins/dtest.sh $TARGET $SPLIT_CHUNK")
-
-# use docker attach instead of docker wait to get output
-docker attach --no-stdin $ID
-status="$?"
-
-if [ "$status" -ne 0 ] ; then
-    echo "$ID failed (${status}), debug…"
-    docker inspect $ID
-    echo "–––"
-    docker logs $ID
-    echo "–––"
-    docker ps -a
-    echo "–––"
-    docker info
-    echo "–––"
-    dmesg
-else
-    echo "$ID done (${status}), copying files"
-    # dtest.sh meta
-    docker cp "$ID:/home/cassandra/cassandra/${TARGET}-$(echo $SPLIT_CHUNK | sed 's/\//-/')-cassandra.head" .
-    # pytest results
-    docker cp $ID:/home/cassandra/cassandra/cassandra-dtest/nosetests.xml .
-    # pytest logs
-    docker cp $ID:/home/cassandra/cassandra/test_stdout.txt .
-    docker cp $ID:/home/cassandra/cassandra/cassandra-dtest/ccm_logs.tar.xz .
-fi
-
-docker rm $ID
diff --git a/jenkins-dsl/cassandra_job_dsl_seed.groovy b/jenkins-dsl/cassandra_job_dsl_seed.groovy
index 37558d8..bd1d16d 100644
--- a/jenkins-dsl/cassandra_job_dsl_seed.groovy
+++ b/jenkins-dsl/cassandra_job_dsl_seed.groovy
@@ -57,6 +57,7 @@ def testTargets = ['test', 'test-burn', 'test-cdc', 'test-compression', 'stress-
 if(binding.hasVariable("CASSANDRA_ANT_TEST_TARGETS")) {
     testTargets = "${CASSANDRA_ANT_TEST_TARGETS}".split(",")
 }
+def testDockerImage = 'apache/cassandra-testing-ubuntu2004-java11-w-dependencies'
 
 // Dtest test targets
 def dtestTargets = ['dtest', 'dtest-novnode', 'dtest-offheap', 'dtest-large', 'dtest-large-novnode', 'dtest-upgrade']
@@ -64,9 +65,6 @@ if(binding.hasVariable("CASSANDRA_DTEST_TEST_TARGETS")) {
     dtestTargets = "${CASSANDRA_DTEST_TEST_TARGETS}".split(",")
 }
 def dtestDockerImage = 'apache/cassandra-testing-ubuntu2004-java11'
-if(binding.hasVariable("CASSANDRA_DOCKER_IMAGE")) {
-    dtestDockerImage = "${CASSANDRA_DOCKER_IMAGE}"
-}
 
 // expected longest job runtime
 def maxJobHours = 18
@@ -456,8 +454,7 @@ cassandraBranches.each {
                 }
                 steps {
                     shell("""
-                            ./cassandra-builds/build-scripts/cassandra-test.sh ${targetName} \${split}/${testSplits} ;
-                             find build/test/logs -type f -name "*.log" | xargs xz -qq ;
+                            sh ./cassandra-builds/build-scripts/cassandra-dtest-pytest.sh apache ${branchName} ${buildsRepo} ${buildsBranch} ${testDockerImage} ${targetName} \${split}/${splits} ;
                             ./cassandra-builds/build-scripts/cassandra-test-report.sh ;
                              xz TESTS-TestSuites.xml
                           """)
@@ -552,8 +549,7 @@ cassandraBranches.each {
                                   """)
                         }
                         shell("""
-                            sh ./cassandra-builds/docker/jenkins/jenkinscommand.sh apache ${branchName} https://github.com/apache/cassandra-dtest.git trunk ${buildsRepo} ${buildsBranch} ${dtestDockerImage} ${targetName} \${split}/${splits} ;
-                            xz test_stdout.txt
+                            sh ./cassandra-builds/build-scripts/cassandra-dtest-pytest.sh apache ${branchName} https://github.com/apache/cassandra-dtest.git trunk ${buildsRepo} ${buildsBranch} ${dtestDockerImage} ${targetName} \${split}/${splits} ;
                             """)
                     }
                     publishers {
@@ -580,7 +576,7 @@ cassandraBranches.each {
                             // the pgrep needs to catch any other build/process that is using docker
                             task('.', """
                                 echo "Cleaning project…"; git clean -xdff ;
-                                echo "Pruning docker…" ; if pgrep -af "cassandra-artifacts.sh|jenkinscommand.sh"; then docker system prune --all --force --filter 'until=${maxJobHours}h'; else docker system prune --all --force --volumes ; fi;
+                                echo "Pruning docker…" ; if pgrep -af "cassandra-artifacts.sh|-docker.sh"; then docker system prune --all --force --filter 'until=${maxJobHours}h'; else docker system prune --all --force --volumes ; fi;
                                 echo "Reporting disk usage…"; df -h ;
                                 echo "Cleaning tmp…";
                                 find . -type d -name tmp -delete 2>/dev/null ;
@@ -852,8 +848,7 @@ testTargets.each {
                     echo "Cassandra-devbranch-${targetName}) cassandra: `git log -1 --pretty=format:'%h %an %ad %s'`" > Cassandra-devbranch-${targetName}.head
                   """)
             shell("""
-                    ./cassandra-builds/build-scripts/cassandra-test.sh ${targetName} \${split}/${testSplits} ;
-                    find build/test/logs -type f -name "*.log" | xargs xz -qq ;
+                    sh ./cassandra-builds/build-scripts/cassandra-dtest-pytest.sh ${REPO} ${BRANCH} ${buildsRepo} ${buildsBranch} ${testDockerImage} ${targetName} \${split}/${splits} ;
                     ./cassandra-builds/build-scripts/cassandra-test-report.sh ;
                     xz TESTS-TestSuites.xml
                   """)
@@ -990,8 +985,7 @@ archs.each {
                           """)
                 }
                 shell("""
-                    sh ./cassandra-builds/docker/jenkins/jenkinscommand.sh \$REPO \$BRANCH \$DTEST_REPO \$DTEST_BRANCH ${buildsRepo} ${buildsBranch} \$DOCKER_IMAGE ${targetName} \${split}/${splits} ;
-                    xz test_stdout.txt
+                    sh ./cassandra-builds/build-scripts/cassandra-dtest-pytest.sh \$REPO \$BRANCH \$DTEST_REPO \$DTEST_BRANCH ${buildsRepo} ${buildsBranch} \$DOCKER_IMAGE ${targetName} \${split}/${splits} ;
                       """)
             }
             publishers {
@@ -1014,7 +1008,7 @@ archs.each {
                     // the pgrep needs to catch any other build/process that is using docker
                     task('.', """
                         echo "Cleaning project…" ; git clean -xdff ;
-                        echo "Pruning docker…" ; if pgrep -af "cassandra-artifacts.sh|jenkinscommand.sh"; then docker system prune --all --force --filter "until=${maxJobHours}h"; else docker system prune --all --force --volumes ; fi;
+                        echo "Pruning docker…" ; if pgrep -af "cassandra-artifacts.sh|-docker.sh"; then docker system prune --all --force --filter "until=${maxJobHours}h"; else docker system prune --all --force --volumes ; fi;
                         echo "Reporting disk usage…"; df -h ;
                         echo "Cleaning tmp…";
                         find . -type d -name tmp -delete 2>/dev/null ;

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org