Skip to content

Commit eb57fd7

Browse files
SiyaoIsHidingmichaelsembwever
authored andcommitted
Build a public CI for Apache Cassandra Java Driver
patch by Siyao (Jane) He; reviewed by Mick Semb Wever for CASSANDRA-19832
1 parent a40e758 commit eb57fd7

File tree

4 files changed

+150
-0
lines changed

4 files changed

+150
-0
lines changed

Jenkinsfile-asf

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!groovy
2+
3+
/*
4+
* Licensed to the Apache Software Foundation (ASF) under one
5+
* or more contributor license agreements. See the NOTICE file
6+
* distributed with this work for additional information
7+
* regarding copyright ownership. The ASF licenses this file
8+
* to you under the Apache License, Version 2.0 (the
9+
* "License"); you may not use this file except in compliance
10+
* with the License. You may obtain a copy of the License at
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*
14+
* Unless required by applicable law or agreed to in writing,
15+
* software distributed under the License is distributed on an
16+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
* KIND, either express or implied. See the License for the
18+
* specific language governing permissions and limitations
19+
* under the License.
20+
*/
21+
22+
pipeline {
23+
agent {
24+
label 'cassandra-small'
25+
}
26+
27+
triggers {
28+
// schedules only run against release branches (i.e. 3.x, 4.x, 4.5.x, etc.)
29+
cron(branchPatternCron().matcher(env.BRANCH_NAME).matches() ? '@weekly' : '')
30+
}
31+
32+
stages {
33+
stage('Matrix') {
34+
matrix {
35+
axes {
36+
axis {
37+
name 'TEST_JAVA_VERSION'
38+
values '[email protected]', '[email protected]', 'openjdk@17'
39+
}
40+
axis {
41+
name 'SERVER_VERSION'
42+
values '3.11.17',
43+
'4.0.13',
44+
'5.0-beta1'
45+
}
46+
}
47+
stages {
48+
stage('Tests') {
49+
agent {
50+
label 'cassandra-medium'
51+
}
52+
steps {
53+
script {
54+
executeTests()
55+
junit testResults: '**/target/surefire-reports/TEST-*.xml', allowEmptyResults: true
56+
junit testResults: '**/target/failsafe-reports/TEST-*.xml', allowEmptyResults: true
57+
}
58+
}
59+
}
60+
}
61+
}
62+
}
63+
}
64+
}
65+
66+
def executeTests() {
67+
def testJavaMajorVersion = (TEST_JAVA_VERSION =~ /@(?:1\.)?(\d+)/)[0][1]
68+
sh """
69+
container_id=\$(docker run -td -e TEST_JAVA_VERSION=${TEST_JAVA_VERSION} -e SERVER_VERSION=${SERVER_VERSION} -e TEST_JAVA_MAJOR_VERSION=${testJavaMajorVersion} -v \$(pwd):/home/docker/cassandra-java-driver apache.jfrog.io/cassan-docker/apache/cassandra-java-driver-testing-ubuntu2204 'sleep 2h')
70+
docker exec --user root \$container_id bash -c \"sudo bash /home/docker/cassandra-java-driver/ci/create-user.sh docker \$(id -u) \$(id -g) /home/docker/cassandra-java-driver\"
71+
docker exec --user docker \$container_id './cassandra-java-driver/ci/run-tests.sh'
72+
( nohup docker stop \$container_id >/dev/null 2>/dev/null & )
73+
"""
74+
}
75+
76+
// branch pattern for cron
77+
// should match 3.x, 4.x, 4.5.x, etc
78+
def branchPatternCron() {
79+
~'((\\d+(\\.[\\dx]+)+))'
80+
}
File renamed without changes.

ci/create-user.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
18+
################################
19+
#
20+
# Prep
21+
#
22+
################################
23+
24+
if [ "$1" == "-h" ]; then
25+
echo "$0 [-h] <username> <uid> <gid>"
26+
echo " this script is used internally by other scripts in the same directory to create a user with the running host user's same uid and gid"
27+
exit 1
28+
fi
29+
30+
# arguments
31+
username=$1
32+
uid=$2
33+
gid=$3
34+
BUILD_HOME=$4
35+
36+
################################
37+
#
38+
# Main
39+
#
40+
################################
41+
42+
# disable git directory ownership checks
43+
su ${username} -c "git config --global safe.directory '*'"
44+
45+
if grep "^ID=" /etc/os-release | grep -q 'debian\|ubuntu' ; then
46+
deluser docker
47+
adduser --quiet --disabled-login --no-create-home --uid $uid --gecos ${username} ${username}
48+
groupmod --non-unique -g $gid $username
49+
gpasswd -a ${username} sudo >/dev/null
50+
else
51+
adduser --no-create-home --uid $uid ${username}
52+
fi
53+
54+
# sudo priviledges
55+
echo "${username} ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/${username}
56+
chmod 0440 /etc/sudoers.d/${username}
57+
58+
# proper permissions
59+
chown -R ${username}:${username} /home/docker
60+
chmod og+wx ${BUILD_HOME}

ci/run-tests.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash -x
2+
3+
. ~/.jabba/jabba.sh
4+
. ~/env.txt
5+
cd $(dirname "$(readlink -f "$0")")/..
6+
printenv | sort
7+
mvn -B -V install -DskipTests -Dmaven.javadoc.skip=true
8+
jabba use ${TEST_JAVA_VERSION}
9+
printenv | sort
10+
mvn -B -V verify -T 1 -Ptest-jdk-${TEST_JAVA_MAJOR_VERSION} -DtestJavaHome=$(jabba which ${TEST_JAVA_VERSION}) -Dccm.version=${SERVER_VERSION} -Dccm.dse=false -Dmaven.test.failure.ignore=true -Dmaven.javadoc.skip=true

0 commit comments

Comments
 (0)