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
This commit is contained in:
Gareth Clay
2020-06-09 17:16:23 +01:00
committed by Roy Clarkson
parent f2ec97d977
commit 6fed6572cb
16 changed files with 91 additions and 47 deletions

View File

@@ -1,3 +1,4 @@
import java.util.concurrent.ConcurrentHashMap
/*
* Copyright 2002-2020 the original author or authors.
*
@@ -51,6 +52,9 @@ if (project.hasProperty("springFrameworkVersion")) {
if (project.hasProperty("reactorVersion")) {
ext['reactor-bom.version'] = ext.reactorVersion
}
if (!project.hasProperty("onlyShowStandardStreamsOnTestFailure")) {
ext.onlyShowStandardStreamsOnTestFailure = false
}
apply plugin: "io.spring.nohttp"
@@ -69,6 +73,59 @@ configure(allprojects) {
if (subproject.description == null || subproject.description.isEmpty()) {
throw new InvalidUserDataException("A project description is required for publishing to maven central")
}
tasks.withType(Test).forEach { Test task ->
task.with {
// enable JUnit 5
useJUnitPlatform()
scanForTestClasses = true
group = "verification"
testLogging {
exceptionFormat = "full"
events = ["passed", "skipped", "failed"]
showStandardStreams = !project.onlyShowStandardStreamsOnTestFailure
}
if (project.onlyShowStandardStreamsOnTestFailure) {
Map<String, StringBuilder> testOutput = new ConcurrentHashMap<>()
onOutput { TestDescriptor descriptor, TestOutputEvent event ->
testOutput.compute(descriptor.displayName, { k, v ->
v == null ? new StringBuilder(event.message) : v.append(event.message)
})
}
afterTest { TestDescriptor descriptor, TestResult result ->
if (result.resultType == TestResult.ResultType.FAILURE && testOutput.containsKey(descriptor.displayName)) {
logger.lifecycle("\n\n${testOutput.get(descriptor.displayName)}")
testOutput.remove(descriptor.displayName)
}
}
}
// print failed tests after the execution
def failedTests = []
afterTest { test, result ->
if (result.resultType == TestResult.ResultType.FAILURE) {
failedTests << test
}
}
// create a summary after the execution
afterSuite { desc, result ->
if (!desc.parent) {
println "\nTest result: ${result.resultType}"
println "Test summary: ${result.testCount} tests, " +
"${result.successfulTestCount} succeeded, " +
"${result.failedTestCount} failed, " +
"${result.skippedTestCount} skipped"
failedTests.each { test -> println "FAILED test: ${test.className} > ${test.name}" }
}
}
}
}
}
apply from: "${rootProject.projectDir}/publish-maven.gradle"
@@ -116,42 +173,6 @@ configure(allprojects - [project(":spring-cloud-app-broker-docs")]) {
ruleSetFiles = files("${project.rootDir}/src/pmd/pmdTestRuleSet.xml")
source = "src/test/java"
}
test {
// enable JUnit 5
useJUnitPlatform()
testLogging {
// display all the events
events 'PASSED', 'FAILED', 'SKIPPED'
// display stdout and stderr
showStandardStreams = true
}
// create a summary after the execution
afterSuite { desc, result ->
if (!desc.parent) {
println "\nTest result: ${result.resultType}"
println "Test summary: ${result.testCount} tests, " +
"${result.successfulTestCount} succeeded, " +
"${result.failedTestCount} failed, " +
"${result.skippedTestCount} skipped"
}
}
// print failed tests after the execution
def failedTests = []
afterTest { test, result ->
if (result.resultType == TestResult.ResultType.FAILURE) {
failedTests << test
}
}
afterSuite {
failedTests.each { test -> println "FAILED test: ${test.className} > ${test.name}" }
}
}
}
subprojects {

View File

@@ -11,10 +11,7 @@ readonly CLIENT_SECRET="${CLIENT_SECRET:?must be set}"
readonly DEFAULT_ORG="${DEFAULT_ORG:?must be set}"
readonly DEFAULT_SPACE="${DEFAULT_SPACE:?must be set}"
readonly SKIP_SSL_VALIDATION="${SKIP_SSL_VALIDATION:?must be set}"
build() {
./gradlew assemble -x test
}
readonly ONLY_SHOW_STANDARD_STREAMS_ON_TEST_FAILURE="${ONLY_SHOW_STANDARD_STREAMS_ON_TEST_FAILURE:?must be set}"
run_tests() {
export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_API_HOST="${API_HOST}"
@@ -27,12 +24,13 @@ run_tests() {
export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_DEFAULT_SPACE="${DEFAULT_SPACE}"
export SPRING_CLOUD_APPBROKER_ACCEPTANCETEST_CLOUDFOUNDRY_SKIP_SSL_VALIDATION="${SKIP_SSL_VALIDATION}"
export TESTS_BROKERAPPPATH=build/libs/spring-cloud-app-broker-acceptance-tests.jar
./gradlew clean assemble check -PacceptanceTests -b spring-cloud-app-broker-acceptance-tests/build.gradle
./gradlew -PacceptanceTests \
-PonlyShowStandardStreamsOnTestFailure="${ONLY_SHOW_STANDARD_STREAMS_ON_TEST_FAILURE}" \
:spring-cloud-app-broker-acceptance-tests:test
}
main() {
pushd "git-repo" > /dev/null
build
run_tests
popd > /dev/null
}

View File

@@ -1,10 +1,15 @@
#!/bin/bash
set -e
readonly ONLY_SHOW_STANDARD_STREAMS_ON_TEST_FAILURE="${ONLY_SHOW_STANDARD_STREAMS_ON_TEST_FAILURE:"true"}"
# shellcheck source=scripts/common.sh
source "$(dirname "$0")/common.sh"
repository=$(pwd)/distribution-repository
pushd git-repo >/dev/null
./gradlew --no-daemon clean build install -Dmaven.repo.local="${repository}" -Dorg.gradle.jvmargs="-Xmx512m -Xmx2048m"
./gradlew --no-daemon clean build install \
-PonlyShowStandardStreamsOnTestFailure="${ONLY_SHOW_STANDARD_STREAMS_ON_TEST_FAILURE}" \
-Dmaven.repo.local="${repository}" \
-Dorg.gradle.jvmargs="-Xmx512m -Xmx2048m"
popd >/dev/null

View File

@@ -23,3 +23,4 @@ params:
DEFAULT_ORG:
DEFAULT_SPACE:
SKIP_SSL_VALIDATION:
ONLY_SHOW_STANDARD_STREAMS_ON_TEST_FAILURE: true

View File

@@ -13,3 +13,5 @@ run:
- -ec
- |
${PWD}/git-repo/ci/scripts/build-project.sh
params:
ONLY_SHOW_STANDARD_STREAMS_ON_TEST_FAILURE: true

View File

@@ -18,31 +18,44 @@ package org.springframework.cloud.appbroker.acceptance.fixtures.cf;
import java.net.URI;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import org.cloudfoundry.reactor.ProxyConfiguration;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;
import static org.springframework.cloud.appbroker.acceptance.fixtures.cf.CloudFoundryProperties.PROPERTY_PREFIX;
@ConfigurationProperties(PROPERTY_PREFIX)
@Validated
public class CloudFoundryProperties {
protected static final String PROPERTY_PREFIX = "spring.cloud.appbroker.acceptancetest.cloudfoundry";
@NotBlank
private String apiHost;
@Min(1)
private Integer apiPort;
@NotBlank
private String defaultOrg;
@NotBlank
private String defaultSpace;
@NotBlank
private String username;
@NotBlank
private String password;
@NotBlank
private String clientId;
@NotBlank
private String clientSecret;
private String identityZoneSubdomain;

View File

@@ -49,6 +49,10 @@ dependencies {
docs("io.spring.docresources:spring-doc-resources:0.2.1.RELEASE@zip")
}
javadoc {
enabled = false
}
task prepareAsciidocBuild(type: Sync) {
dependsOn configurations.docs
// copy doc resources
@@ -84,7 +88,7 @@ asciidoctorPdf {
asciidoctor {
dependsOn asciidoctorPdf
baseDirFollowsSourceFile()
baseDirFollowsSourceFile()
sourceDir = file("$buildDir/asciidoc")
sources {
include '*.adoc'

View File

@@ -6,7 +6,7 @@
:toclevels: 4
:sectlinks:
:examples-dir: ../../src/test/java/com/example/appbroker/
:examples-dir: ../../src/main/java/com/example/appbroker/
:sapbr: https://cloud.spring.io/spring-cloud-app-broker/
:sapbr-href: {sapbr}[Spring Cloud App Broker]
:sapbr-api: https://docs.spring.io/spring-cloud-app-broker/docs/{project-version}/api/

View File

@@ -1,4 +1,4 @@
:examples-dir: ../../src/test/java/com/example/appbroker/
:examples-dir: ../../src/main/java/com/example/appbroker/
[[service-bindings]]
== Service Bindings

View File

@@ -1,4 +1,4 @@
:examples-dir: ../../src/test/java/com/example/appbroker/
:examples-dir: ../../src/main/java/com/example/appbroker/
[[service-instances]]
== Service Instances