Use ci/build.sh in Jenkinsfile, too

This commit is contained in:
Yoann Rodière 2022-10-11 14:35:57 +02:00 committed by Christian Beikov
parent bf8040638c
commit 89ae1dd0e4
2 changed files with 43 additions and 61 deletions

87
Jenkinsfile vendored
View File

@ -39,11 +39,13 @@ stage('Configure') {
// new BuildEnvironment( dbName: 'db2' ), // new BuildEnvironment( dbName: 'db2' ),
// new BuildEnvironment( dbName: 'mssql' ), // new BuildEnvironment( dbName: 'mssql' ),
// new BuildEnvironment( dbName: 'sybase' ), // new BuildEnvironment( dbName: 'sybase' ),
new BuildEnvironment( dbName: 'hana', node: 'HANA' ), new BuildEnvironment( dbName: 'hana_jenkins', node: 'HANA', dbLockableResource: 'HANA' ),
new BuildEnvironment( dbName: 's390x', node: 's390x' ), new BuildEnvironment( node: 's390x' ),
new BuildEnvironment( dbName: 'tidb', node: 'tidb', notificationRecipients: 'tidb_hibernate@pingcap.com' ), new BuildEnvironment( dbName: 'tidb', node: 'tidb', dbLockableResource: 'TIDB',
additionalOptions: '-DdbHost=localhost:4000',
notificationRecipients: 'tidb_hibernate@pingcap.com' ),
// Disable EDB for now as the image is not available anymore // Disable EDB for now as the image is not available anymore
// new BuildEnvironment( dbName: 'edb' ), // new BuildEnvironment( dbName: 'edb', additionalOptions: '-DdbHost=localhost:5433' ),
new BuildEnvironment( testJdkVersion: '17' ), new BuildEnvironment( testJdkVersion: '17' ),
new BuildEnvironment( testJdkVersion: '18' ), new BuildEnvironment( testJdkVersion: '18' ),
// We want to enable preview features when testing early-access builds of OpenJDK: // We want to enable preview features when testing early-access builds of OpenJDK:
@ -192,38 +194,25 @@ stage('Build') {
} }
} }
stage('Test') { stage('Test') {
switch (buildEnv.dbName) { String cmd = "./ci/build.sh ${buildEnv.additionalOptions ?: ''} ${state[buildEnv.tag]['additionalOptions'] ?: ''}"
case "h2": withEnv(["RDBMS=${buildEnv.dbName}"]) {
case "derby": try {
case "hsqldb": if (buildEnv.dbLockableResource == null) {
runTest("-Pdb=${buildEnv.dbName}${state[buildEnv.tag]['additionalOptions']}") timeout( [time: 120, unit: 'MINUTES'] ) {
break; sh cmd
case "mysql": }
case "mysql8": }
runTest("-Pdb=mysql_ci${state[buildEnv.tag]['additionalOptions']}") else {
break; lock(buildEnv.dbLockableResource) {
case "tidb": timeout( [time: 120, unit: 'MINUTES'] ) {
runTest("-Pdb=tidb -DdbHost=localhost:4000${state[buildEnv.tag]['additionalOptions']}", 'TIDB') sh cmd
break; }
case "postgresql": }
case "postgresql_14": }
runTest("-Pdb=pgsql_ci${state[buildEnv.tag]['additionalOptions']}") }
break; finally {
case "oracle": junit '**/target/test-results/test/*.xml,**/target/test-results/testKitTest/*.xml'
runTest("-Pdb=oracle_ci -PexcludeTests=**.LockTest.testQueryTimeout*${state[buildEnv.tag]['additionalOptions']}") }
break;
case "hana":
runTest("-Pdb=hana_jenkins${state[buildEnv.tag]['additionalOptions']}", 'HANA')
break;
case "edb":
runTest("-Pdb=edb_ci -DdbHost=localhost:5433${state[buildEnv.tag]['additionalOptions']}")
break;
case "s390x":
runTest("-Pdb=h2${state[buildEnv.tag]['additionalOptions']}")
break;
default:
runTest("-Pdb=${buildEnv.dbName}_ci${state[buildEnv.tag]['additionalOptions']}")
break;
} }
} }
} }
@ -252,10 +241,12 @@ class BuildEnvironment {
String testJdkLauncherArgs String testJdkLauncherArgs
String dbName = 'h2' String dbName = 'h2'
String node String node
String dbLockableResource
String additionalOptions
String notificationRecipients String notificationRecipients
String toString() { getTag() } String toString() { getTag() }
String getTag() { "${testJdkVersion ? 'jdk_' + testJdkVersion + '_' : '' }${dbName}" } String getTag() { "${node ? node + "_" : ''}${testJdkVersion ? 'jdk_' + testJdkVersion + '_' : '' }${dbName}" }
} }
void runBuildOnNode(String label, Closure body) { void runBuildOnNode(String label, Closure body) {
@ -281,28 +272,6 @@ void pruneDockerContainers() {
sh 'docker volume prune -f || true' sh 'docker volume prune -f || true'
} }
} }
// Clean by default otherwise the PackagedEntityManager tests fail on a node that previously ran a different DB
void runTest(String goal, String lockableResource = null, boolean clean = true) {
String cmd = "./gradlew" + (clean ? " clean" : "") + " check ${goal} -Plog-test-progress=true --stacktrace";
try {
if (lockableResource == null) {
timeout( [time: 120, unit: 'MINUTES'] ) {
sh cmd
}
}
else {
lock(lockableResource) {
timeout( [time: 120, unit: 'MINUTES'] ) {
sh cmd
}
}
}
}
finally {
junit '**/target/test-results/test/*.xml,**/target/test-results/testKitTest/*.xml'
}
}
void handleNotifications(currentBuild, buildEnv) { void handleNotifications(currentBuild, buildEnv) {
def currentResult = getParallelResult(currentBuild, buildEnv.tag) def currentResult = getParallelResult(currentBuild, buildEnv.tag)

View File

@ -1,8 +1,13 @@
#! /bin/bash #! /bin/bash
goal= goal=
if [ "$RDBMS" == "derby" ]; then if [ "$RDBMS" == "h2" ]; then
# This is the default.
goal=""
elif [ "$RDBMS" == "derby" ]; then
goal="-Pdb=derby" goal="-Pdb=derby"
elif [ "$RDBMS" == "edb" ]; then
goal="-Pdb=edb_ci"
elif [ "$RDBMS" == "hsqldb" ]; then elif [ "$RDBMS" == "hsqldb" ]; then
goal="-Pdb=hsqldb" goal="-Pdb=hsqldb"
elif [ "$RDBMS" == "mysql8" ]; then elif [ "$RDBMS" == "mysql8" ]; then
@ -17,15 +22,23 @@ elif [ "$RDBMS" == "postgresql_14" ]; then
goal="-Pdb=pgsql_ci" goal="-Pdb=pgsql_ci"
elif [ "$RDBMS" == "oracle" ]; then elif [ "$RDBMS" == "oracle" ]; then
# I have no idea why, but these tests don't work on GH Actions # I have no idea why, but these tests don't work on GH Actions
# yrodiere: Apparently those have been disabled on Jenkins as well...
goal="-Pdb=oracle_ci -PexcludeTests=**.LockTest.testQueryTimeout*" goal="-Pdb=oracle_ci -PexcludeTests=**.LockTest.testQueryTimeout*"
elif [ "$RDBMS" == "oracle_ee" ]; then
goal="-Pdb=oracle_jenkins"
elif [ "$RDBMS" == "db2" ]; then elif [ "$RDBMS" == "db2" ]; then
goal="-Pdb=db2_ci" goal="-Pdb=db2_ci"
elif [ "$RDBMS" == "mssql" ]; then elif [ "$RDBMS" == "mssql" ]; then
goal="-Pdb=mssql_ci" goal="-Pdb=mssql_ci"
elif [ "$RDBMS" == "hana" ]; then elif [ "$RDBMS" == "hana" ]; then
goal="-Pdb=hana_ci" goal="-Pdb=hana_ci"
elif [ "$RDBMS" == "hana_jenkins" ]; then
goal="-Pdb=hana_jenkins"
elif [ "$RDBMS" == "sybase" ]; then elif [ "$RDBMS" == "sybase" ]; then
goal="-Pdb=sybase_ci" goal="-Pdb=sybase_ci"
elif [ "$RDBMS" == "tidb" ]; then
goal="-Pdb=tidb"
fi fi
exec ./gradlew check ${goal} -Plog-test-progress=true --stacktrace # Clean by default otherwise the PackagedEntityManager tests fail on a node that previously ran a different DB
exec ./gradlew clean check ${goal} "${@}" -Plog-test-progress=true --stacktrace