Skip to content

Commit 63f3e1c

Browse files
authored
Backport Jenkinsfile to 2.4 branch (#9329)
Also fix a Scala 2.11 compile error in GroupMetadataManagerTest
1 parent 52ab0ad commit 63f3e1c

File tree

3 files changed

+176
-4
lines changed

3 files changed

+176
-4
lines changed

Jenkinsfile

+164
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
/*
2+
*
3+
* Licensed to the Apache Software Foundation (ASF) under one or more
4+
* contributor license agreements. See the NOTICE file distributed with
5+
* this work for additional information regarding copyright ownership.
6+
* The ASF licenses this file to You under the Apache License, Version 2.0
7+
* (the "License"); you may not use this file except in compliance with
8+
* 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+
def setupGradle() {
21+
// Delete gradle cache to workaround cache corruption bugs, see KAFKA-3167
22+
dir('.gradle') {
23+
deleteDir()
24+
}
25+
sh './gradlew -version'
26+
}
27+
28+
def doValidation() {
29+
sh '''
30+
./gradlew -PscalaVersion=$SCALA_VERSION clean compileJava compileScala compileTestJava compileTestScala \
31+
spotlessScalaCheck checkstyleMain checkstyleTest spotbugsMain rat \
32+
--profile --no-daemon --continue -PxmlSpotBugsReport=true
33+
'''
34+
}
35+
36+
def doTest() {
37+
sh '''
38+
./gradlew -PscalaVersion=$SCALA_VERSION unitTest integrationTest \
39+
--profile --no-daemon --continue -PtestLoggingEvents=started,passed,skipped,failed \
40+
-PignoreFailures=true -PmaxParallelForks=2 -PmaxTestRetries=1 -PmaxTestRetryFailures=5
41+
'''
42+
junit '**/build/test-results/**/TEST-*.xml'
43+
}
44+
45+
def doStreamsArchetype() {
46+
echo 'Verify that Kafka Streams archetype compiles'
47+
48+
sh '''
49+
./gradlew streams:install clients:install connect:json:install connect:api:install \
50+
|| { echo 'Could not install kafka-streams.jar (and dependencies) locally`'; exit 1; }
51+
'''
52+
53+
VERSION = sh(script: 'grep "^version=" gradle.properties | cut -d= -f 2', returnStdout: true).trim()
54+
55+
dir('streams/quickstart') {
56+
sh '''
57+
mvn clean install -Dgpg.skip \
58+
|| { echo 'Could not `mvn install` streams quickstart archetype'; exit 1; }
59+
'''
60+
61+
dir('test-streams-archetype') {
62+
// Note the double quotes for variable interpolation
63+
sh """
64+
echo "Y" | mvn archetype:generate \
65+
-DarchetypeCatalog=local \
66+
-DarchetypeGroupId=org.apache.kafka \
67+
-DarchetypeArtifactId=streams-quickstart-java \
68+
-DarchetypeVersion=${VERSION} \
69+
-DgroupId=streams.examples \
70+
-DartifactId=streams.examples \
71+
-Dversion=0.1 \
72+
-Dpackage=myapps \
73+
|| { echo 'Could not create new project using streams quickstart archetype'; exit 1; }
74+
"""
75+
76+
dir('streams.examples') {
77+
sh '''
78+
mvn compile \
79+
|| { echo 'Could not compile streams quickstart archetype project'; exit 1; }
80+
'''
81+
}
82+
}
83+
}
84+
}
85+
86+
def tryStreamsArchetype() {
87+
try {
88+
doStreamsArchetype()
89+
} catch(err) {
90+
echo 'Failed to build Kafka Streams archetype, marking this build UNSTABLE'
91+
currentBuild.result = 'UNSTABLE'
92+
}
93+
}
94+
95+
96+
pipeline {
97+
agent none
98+
stages {
99+
stage('Build') {
100+
parallel {
101+
stage('JDK 8 and Scala 2.11') {
102+
agent { label 'ubuntu' }
103+
tools {
104+
jdk 'JDK 1.8 (latest)'
105+
maven 'Maven 3.6.3'
106+
}
107+
options {
108+
timeout(time: 8, unit: 'HOURS')
109+
timestamps()
110+
}
111+
environment {
112+
SCALA_VERSION=2.11
113+
}
114+
steps {
115+
setupGradle()
116+
doValidation()
117+
doTest()
118+
tryStreamsArchetype()
119+
}
120+
}
121+
122+
stage('JDK 11 and Scala 2.12') {
123+
agent { label 'ubuntu' }
124+
tools {
125+
jdk 'JDK 11 (latest)'
126+
}
127+
options {
128+
timeout(time: 8, unit: 'HOURS')
129+
timestamps()
130+
}
131+
environment {
132+
SCALA_VERSION=2.12
133+
}
134+
steps {
135+
setupGradle()
136+
doValidation()
137+
doTest()
138+
echo 'Skipping Kafka Streams archetype test for Java 11'
139+
}
140+
}
141+
142+
stage('JDK 11 and Scala 2.13') {
143+
agent { label 'ubuntu' }
144+
tools {
145+
jdk 'JDK 11 (latest)'
146+
}
147+
options {
148+
timeout(time: 8, unit: 'HOURS')
149+
timestamps()
150+
}
151+
environment {
152+
SCALA_VERSION=2.13
153+
}
154+
steps {
155+
setupGradle()
156+
doValidation()
157+
doTest()
158+
echo 'Skipping Kafka Streams archetype test for Java 11'
159+
}
160+
}
161+
}
162+
}
163+
}
164+
}

build.gradle

+4
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ ext {
112112
buildVersionFileName = "kafka-version.properties"
113113

114114
userMaxForks = project.hasProperty('maxParallelForks') ? maxParallelForks.toInteger() : null
115+
userIgnoreFailures = project.hasProperty('ignoreFailures') ? ignoreFailures : false
115116

116117
skipSigning = project.hasProperty('skipSigning') && skipSigning.toBoolean()
117118
shouldSign = !skipSigning && !version.endsWith("SNAPSHOT") && project.gradle.startParameter.taskNames.any { it.contains("upload") }
@@ -300,6 +301,7 @@ subprojects {
300301

301302
test {
302303
maxParallelForks = userMaxForks ?: Runtime.runtime.availableProcessors()
304+
ignoreFailures = userIgnoreFailures
303305

304306
minHeapSize = "256m"
305307
maxHeapSize = "2048m"
@@ -314,6 +316,7 @@ subprojects {
314316

315317
task integrationTest(type: Test, dependsOn: compileJava) {
316318
maxParallelForks = userMaxForks ?: Runtime.runtime.availableProcessors()
319+
ignoreFailures = userIgnoreFailures
317320

318321
minHeapSize = "256m"
319322
maxHeapSize = "2048m"
@@ -337,6 +340,7 @@ subprojects {
337340

338341
task unitTest(type: Test, dependsOn: compileJava) {
339342
maxParallelForks = userMaxForks ?: Runtime.runtime.availableProcessors()
343+
ignoreFailures = userIgnoreFailures
340344

341345
minHeapSize = "256m"
342346
maxHeapSize = "2048m"

core/src/test/scala/unit/kafka/coordinator/group/GroupMetadataManagerTest.scala

+8-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import org.apache.kafka.common.requests.ProduceResponse.PartitionResponse
4545
import org.apache.kafka.common.utils.Utils
4646
import org.apache.kafka.common.KafkaException
4747
import org.easymock.{Capture, EasyMock, IAnswer}
48-
import org.junit.Assert.{assertEquals, assertFalse, assertNull, assertTrue, assertThrows}
48+
import org.junit.Assert.{assertEquals, assertFalse, assertNull, assertTrue}
4949
import org.junit.{Before, Test}
5050
import org.scalatest.Assertions.fail
5151

@@ -912,9 +912,13 @@ class GroupMetadataManagerTest {
912912
// reset the position to the starting position 0 so that it can read the data in correct order
913913
groupMetadataRecordValue.position(0)
914914

915-
val e = assertThrows(classOf[KafkaException],
916-
() => GroupMetadataManager.readGroupMessageValue(groupId, groupMetadataRecordValue, time))
917-
assertEquals(s"Unknown group metadata version ${unsupportedVersion}", e.getMessage)
915+
try {
916+
GroupMetadataManager.readGroupMessageValue(groupId, groupMetadataRecordValue, time)
917+
fail("Expected KafkaException here")
918+
} catch {
919+
case e: KafkaException => assertEquals(s"Unknown group metadata version ${unsupportedVersion}", e.getMessage)
920+
case _ => fail("Expected KafkaException here")
921+
}
918922
}
919923

920924
@Test

0 commit comments

Comments
 (0)