Skip to content

Commit 6fed657

Browse files
spikymonkeyroyclarkson
authored andcommitted
Fix CI log interleaving
* Stop logs from parallel tests interleaving with each other * Cut down on noise and reduce page load times by only logging std streams for tests that fail * @validated AT cloud foundry configuration * Remove unnecessary Gradle tasks from the AT job since they've already been performed as part of `build` * Stop tests and javadoc Gradle tasks being run against docs subproject and causing failures #380
1 parent f2ec97d commit 6fed657

File tree

16 files changed

+91
-47
lines changed

16 files changed

+91
-47
lines changed

build.gradle

Lines changed: 57 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import java.util.concurrent.ConcurrentHashMap
12
/*
23
* Copyright 2002-2020 the original author or authors.
34
*
@@ -51,6 +52,9 @@ if (project.hasProperty("springFrameworkVersion")) {
5152
if (project.hasProperty("reactorVersion")) {
5253
ext['reactor-bom.version'] = ext.reactorVersion
5354
}
55+
if (!project.hasProperty("onlyShowStandardStreamsOnTestFailure")) {
56+
ext.onlyShowStandardStreamsOnTestFailure = false
57+
}
5458

5559
apply plugin: "io.spring.nohttp"
5660

@@ -69,6 +73,59 @@ configure(allprojects) {
6973
if (subproject.description == null || subproject.description.isEmpty()) {
7074
throw new InvalidUserDataException("A project description is required for publishing to maven central")
7175
}
76+
77+
tasks.withType(Test).forEach { Test task ->
78+
task.with {
79+
// enable JUnit 5
80+
useJUnitPlatform()
81+
scanForTestClasses = true
82+
group = "verification"
83+
84+
testLogging {
85+
exceptionFormat = "full"
86+
events = ["passed", "skipped", "failed"]
87+
showStandardStreams = !project.onlyShowStandardStreamsOnTestFailure
88+
}
89+
90+
if (project.onlyShowStandardStreamsOnTestFailure) {
91+
Map<String, StringBuilder> testOutput = new ConcurrentHashMap<>()
92+
93+
onOutput { TestDescriptor descriptor, TestOutputEvent event ->
94+
testOutput.compute(descriptor.displayName, { k, v ->
95+
v == null ? new StringBuilder(event.message) : v.append(event.message)
96+
})
97+
}
98+
99+
afterTest { TestDescriptor descriptor, TestResult result ->
100+
if (result.resultType == TestResult.ResultType.FAILURE && testOutput.containsKey(descriptor.displayName)) {
101+
logger.lifecycle("\n\n${testOutput.get(descriptor.displayName)}")
102+
testOutput.remove(descriptor.displayName)
103+
}
104+
}
105+
}
106+
107+
// print failed tests after the execution
108+
def failedTests = []
109+
afterTest { test, result ->
110+
if (result.resultType == TestResult.ResultType.FAILURE) {
111+
failedTests << test
112+
}
113+
}
114+
115+
// create a summary after the execution
116+
afterSuite { desc, result ->
117+
if (!desc.parent) {
118+
println "\nTest result: ${result.resultType}"
119+
println "Test summary: ${result.testCount} tests, " +
120+
"${result.successfulTestCount} succeeded, " +
121+
"${result.failedTestCount} failed, " +
122+
"${result.skippedTestCount} skipped"
123+
124+
failedTests.each { test -> println "FAILED test: ${test.className} > ${test.name}" }
125+
}
126+
}
127+
}
128+
}
72129
}
73130

74131
apply from: "${rootProject.projectDir}/publish-maven.gradle"
@@ -116,42 +173,6 @@ configure(allprojects - [project(":spring-cloud-app-broker-docs")]) {
116173
ruleSetFiles = files("${project.rootDir}/src/pmd/pmdTestRuleSet.xml")
117174
source = "src/test/java"
118175
}
119-
120-
test {
121-
// enable JUnit 5
122-
useJUnitPlatform()
123-
124-
testLogging {
125-
// display all the events
126-
events 'PASSED', 'FAILED', 'SKIPPED'
127-
// display stdout and stderr
128-
showStandardStreams = true
129-
}
130-
131-
// create a summary after the execution
132-
afterSuite { desc, result ->
133-
if (!desc.parent) {
134-
println "\nTest result: ${result.resultType}"
135-
println "Test summary: ${result.testCount} tests, " +
136-
"${result.successfulTestCount} succeeded, " +
137-
"${result.failedTestCount} failed, " +
138-
"${result.skippedTestCount} skipped"
139-
}
140-
}
141-
142-
// print failed tests after the execution
143-
def failedTests = []
144-
145-
afterTest { test, result ->
146-
if (result.resultType == TestResult.ResultType.FAILURE) {
147-
failedTests << test
148-
}
149-
}
150-
151-
afterSuite {
152-
failedTests.each { test -> println "FAILED test: ${test.className} > ${test.name}" }
153-
}
154-
}
155176
}
156177

157178
subprojects {

ci/scripts/acceptance-tests.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ readonly CLIENT_SECRET="${CLIENT_SECRET:?must be set}"
1111
readonly DEFAULT_ORG="${DEFAULT_ORG:?must be set}"
1212
readonly DEFAULT_SPACE="${DEFAULT_SPACE:?must be set}"
1313
readonly SKIP_SSL_VALIDATION="${SKIP_SSL_VALIDATION:?must be set}"
14-
15-
build() {
16-
./gradlew assemble -x test
17-
}
14+
readonly ONLY_SHOW_STANDARD_STREAMS_ON_TEST_FAILURE="${ONLY_SHOW_STANDARD_STREAMS_ON_TEST_FAILURE:?must be set}"
1815

1916
run_tests() {
2017
export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_API_HOST="${API_HOST}"
@@ -27,12 +24,13 @@ run_tests() {
2724
export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_DEFAULT_SPACE="${DEFAULT_SPACE}"
2825
export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_SKIP_SSL_VALIDATION="${SKIP_SSL_VALIDATION}"
2926
export TESTS_BROKERAPPPATH=build/libs/spring-cloud-app-broker-acceptance-tests.jar
30-
./gradlew clean assemble check -PacceptanceTests -b spring-cloud-app-broker-acceptance-tests/build.gradle
27+
./gradlew -PacceptanceTests \
28+
-PonlyShowStandardStreamsOnTestFailure="${ONLY_SHOW_STANDARD_STREAMS_ON_TEST_FAILURE}" \
29+
:spring-cloud-app-broker-acceptance-tests:test
3130
}
3231

3332
main() {
3433
pushd "git-repo" > /dev/null
35-
build
3634
run_tests
3735
popd > /dev/null
3836
}

ci/scripts/build-project.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
#!/bin/bash
22
set -e
33

4+
readonly ONLY_SHOW_STANDARD_STREAMS_ON_TEST_FAILURE="${ONLY_SHOW_STANDARD_STREAMS_ON_TEST_FAILURE:"true"}"
5+
46
# shellcheck source=scripts/common.sh
57
source "$(dirname "$0")/common.sh"
68
repository=$(pwd)/distribution-repository
79

810
pushd git-repo >/dev/null
9-
./gradlew --no-daemon clean build install -Dmaven.repo.local="${repository}" -Dorg.gradle.jvmargs="-Xmx512m -Xmx2048m"
11+
./gradlew --no-daemon clean build install \
12+
-PonlyShowStandardStreamsOnTestFailure="${ONLY_SHOW_STANDARD_STREAMS_ON_TEST_FAILURE}" \
13+
-Dmaven.repo.local="${repository}" \
14+
-Dorg.gradle.jvmargs="-Xmx512m -Xmx2048m"
1015
popd >/dev/null

ci/tasks/acceptance-tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ params:
2323
DEFAULT_ORG:
2424
DEFAULT_SPACE:
2525
SKIP_SSL_VALIDATION:
26+
ONLY_SHOW_STANDARD_STREAMS_ON_TEST_FAILURE: true

ci/tasks/build-project.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ run:
1313
- -ec
1414
- |
1515
${PWD}/git-repo/ci/scripts/build-project.sh
16+
params:
17+
ONLY_SHOW_STANDARD_STREAMS_ON_TEST_FAILURE: true

spring-cloud-app-broker-acceptance-tests/src/test/java/org/springframework/cloud/appbroker/acceptance/fixtures/cf/CloudFoundryProperties.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,44 @@
1818

1919
import java.net.URI;
2020

21+
import javax.validation.constraints.Min;
22+
import javax.validation.constraints.NotBlank;
23+
2124
import org.cloudfoundry.reactor.ProxyConfiguration;
2225

2326
import org.springframework.boot.context.properties.ConfigurationProperties;
27+
import org.springframework.validation.annotation.Validated;
2428

2529
import static org.springframework.cloud.appbroker.acceptance.fixtures.cf.CloudFoundryProperties.PROPERTY_PREFIX;
2630

2731
@ConfigurationProperties(PROPERTY_PREFIX)
32+
@Validated
2833
public class CloudFoundryProperties {
2934

3035
protected static final String PROPERTY_PREFIX = "spring.cloud.appbroker.acceptancetest.cloudfoundry";
3136

37+
@NotBlank
3238
private String apiHost;
3339

40+
@Min(1)
3441
private Integer apiPort;
3542

43+
@NotBlank
3644
private String defaultOrg;
3745

46+
@NotBlank
3847
private String defaultSpace;
3948

49+
@NotBlank
4050
private String username;
4151

52+
@NotBlank
4253
private String password;
4354

55+
@NotBlank
4456
private String clientId;
4557

58+
@NotBlank
4659
private String clientSecret;
4760

4861
private String identityZoneSubdomain;

spring-cloud-app-broker-docs/build.gradle

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ dependencies {
4949
docs("io.spring.docresources:spring-doc-resources:0.2.1.RELEASE@zip")
5050
}
5151

52+
javadoc {
53+
enabled = false
54+
}
55+
5256
task prepareAsciidocBuild(type: Sync) {
5357
dependsOn configurations.docs
5458
// copy doc resources
@@ -84,7 +88,7 @@ asciidoctorPdf {
8488

8589
asciidoctor {
8690
dependsOn asciidoctorPdf
87-
baseDirFollowsSourceFile()
91+
baseDirFollowsSourceFile()
8892
sourceDir = file("$buildDir/asciidoc")
8993
sources {
9094
include '*.adoc'

spring-cloud-app-broker-docs/src/docs/asciidoc/index.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
:toclevels: 4
77
:sectlinks:
88

9-
:examples-dir: ../../src/test/java/com/example/appbroker/
9+
:examples-dir: ../../src/main/java/com/example/appbroker/
1010
:sapbr: https://cloud.spring.io/spring-cloud-app-broker/
1111
:sapbr-href: {sapbr}[Spring Cloud App Broker]
1212
:sapbr-api: https://docs.spring.io/spring-cloud-app-broker/docs/{project-version}/api/

spring-cloud-app-broker-docs/src/docs/asciidoc/service-bindings.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
:examples-dir: ../../src/test/java/com/example/appbroker/
1+
:examples-dir: ../../src/main/java/com/example/appbroker/
22
[[service-bindings]]
33
== Service Bindings
44

spring-cloud-app-broker-docs/src/docs/asciidoc/service-instances.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
:examples-dir: ../../src/test/java/com/example/appbroker/
1+
:examples-dir: ../../src/main/java/com/example/appbroker/
22
[[service-instances]]
33
== Service Instances
44

0 commit comments

Comments
 (0)