diff --git a/ci/runClusterTests.sh b/ci/runClusterTests.sh deleted file mode 100755 index ac067aebc..000000000 --- a/ci/runClusterTests.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env bash - -# This script is used to run SDN6's integration test against a Neo4j cluster via `runClusterTests.java`. The idea behind it is: -# 1. Build a local deployment of SDN 6 including a test jar containing all tests -# 2. Extract the version, direct dependencies and the repo path from the Maven build descriptor and replace the placeholders -# in the template. -# 3. Execute the Java script file via JBang. -# -# The result code of this script will be 0 in a successful run, a non-zero value otherwise. The Java program will try -# upto 100 times to get a completely successful test run, retrying on error cases that might happen in a cluster. -# -# Run this script with a pair of environmental values to point it to a cluster: -# SDN_NEO4J_URL=neo4j+s://your.neo4j.cluster.io SDN_NEO4J_PASSWORD=yourPassword ./ci/runClusterTests.sh - -set -euo pipefail - -CI_BASEDIR=$(dirname "$0") -BASEDIR=$(realpath $CI_BASEDIR/..) -CLUSTER_TEST_DIR=$BASEDIR/target/cluster-tests - -( - cd $BASEDIR - SDN_VERSION=$(./mvnw --no-transfer-progress help:evaluate -Dexpression=project.version -q -DforceStdout) - - mkdir -p $CLUSTER_TEST_DIR - - # Create the distribution and deploy it into the target folder itself - ./mvnw --no-transfer-progress -Pgenerate-test-jar -DskipTests clean deploy -DaltDeploymentRepository=snapshot-repo::default::file:///$CLUSTER_TEST_DIR/snapshot-repo - - # Massage the directory name into something sed is happy with - SNAPSHOT_REPO=$(printf '%s\n' "$CLUSTER_TEST_DIR/snapshot-repo" | sed -e 's/[\/&]/\\&/g') - - # Create a plain list of dependencies - ./mvnw --no-transfer-progress dependency:list -DexcludeTransitive | sed -n -e 's/^\[INFO\] //p' > $CLUSTER_TEST_DIR/dependencies.txt - - # Update repository path, version and dependencies in template - sed -e s/\$SDN_VERSION/$SDN_VERSION/ -e s/\$SNAPSHOT_REPO/$SNAPSHOT_REPO/ $CI_BASEDIR/runClusterTests.template.java |\ - awk -F: -v deps=$CLUSTER_TEST_DIR/dependencies.txt -v target=$CLUSTER_TEST_DIR/runClusterTests.java ' - /\/\/\$ADDITIONAL_DEPENDENCIES/ { - while((getline < deps) > 0) { - print "//DEPS " $1 ":" $2 ":" $4 > target - } - next - } - {print > target}' - - # clean up - rm $CLUSTER_TEST_DIR/dependencies.txt - - # Prepare run - chmod +x $CLUSTER_TEST_DIR/runClusterTests.java && cp src/test/resources/logback-silent.xml $CLUSTER_TEST_DIR/logback.xml -) - -jbang $CLUSTER_TEST_DIR/runClusterTests.java diff --git a/ci/runClusterTests.template.java b/ci/runClusterTests.template.java deleted file mode 100755 index 2a5d12b48..000000000 --- a/ci/runClusterTests.template.java +++ /dev/null @@ -1,123 +0,0 @@ -///usr/bin/env jbang "$0" "$@" ; exit $? -//JAVA 11+ -//REPOS mavencentral,spring-libs-snapshot=https://repo.spring.io/libs-snapshot,snapshot-repo=file://$SNAPSHOT_REPO - -// This is a template to create a Java script runnable via JBang https://github.com/jbangdev/jbang and Java 11 to run. -// It takes most of the integration tests and runs them against Neo4j. It will react on exceptions happening due to cluster -// changes and retry them accordingly. While you can point it against a non-cluster deployment, it wouldn't make much sense, -// as this scenario is already covered based on the standard testing. -// The file is named `template.java` as it has some placeholders that needs to be replaced by the orchestrating `runClusterTests.sh`. - -//FILES logback.xml - -//DEPS org.junit.platform:junit-platform-launcher:1.7.1 -//DEPS org.springframework.data:spring-data-neo4j:$SDN_VERSION -//DEPS org.springframework.data:spring-data-neo4j:$SDN_VERSION:tests@test-jar -//$ADDITIONAL_DEPENDENCIES - -import static java.util.stream.Collectors.partitioningBy; -import static java.util.stream.Collectors.toList; -import static org.junit.platform.engine.discovery.ClassNameFilter.includeClassNamePatterns; -import static org.junit.platform.engine.discovery.DiscoverySelectors.selectPackage; -import static org.junit.platform.launcher.TagFilter.excludeTags; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.StandardCopyOption; -import java.util.List; - -import org.junit.platform.engine.DiscoverySelector; -import org.junit.platform.engine.discovery.DiscoverySelectors; -import org.junit.platform.launcher.TestExecutionListener; -import org.junit.platform.launcher.TestIdentifier; -import org.junit.platform.launcher.core.LauncherConfig; -import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder; -import org.junit.platform.launcher.core.LauncherFactory; -import org.junit.platform.launcher.listeners.SummaryGeneratingListener; -import org.neo4j.driver.internal.retry.ExponentialBackoffRetryLogic; -import org.slf4j.LoggerFactory; -import org.springframework.data.neo4j.core.support.RetryExceptionPredicate; - -public class runClusterTests { - - public static void main(String... args) throws IOException { - - var logConfig = Files.createTempFile("logback", ".xml"); - try (var s = runClusterTests.class.getResourceAsStream("logback.xml")) { - Files.copy(s, logConfig, StandardCopyOption.REPLACE_EXISTING); - } - System.setProperty("logback.configurationFile", logConfig.toAbsolutePath().normalize().toString()); - - var log = LoggerFactory.getLogger(runClusterTests.class); - - var listener = new SummaryGeneratingListener(); - var launcher = LauncherFactory - .create(LauncherConfig.builder() - .addTestExecutionListeners(new TestExecutionListener() { - @Override public void executionStarted(TestIdentifier testIdentifier) { - if (testIdentifier.isContainer() && testIdentifier.getParentId().isPresent()) { - log.debug(testIdentifier.getUniqueId()); - } - } - }) - .addTestExecutionListeners(listener).build()); - - var canRetry = new RetryExceptionPredicate().or(ExponentialBackoffRetryLogic::isRetryable); - - var selectors = List.of(selectPackage("org.springframework.data.neo4j.integration")); - var maxRetries = 100; - var counter = 0; - - while (!selectors.isEmpty() && ++counter <= maxRetries) { - log.info("Attempt {}/{}", counter, maxRetries); - var request = LauncherDiscoveryRequestBuilder.request() - .selectors(selectors) - .filters( - includeClassNamePatterns(".*IT.*"), - excludeTags("incompatible-with-clusters") - ) - .build(); - - launcher.execute(request); - - var failures = listener.getSummary().getFailures(); - - if (failures.isEmpty()) { - log.info("Finished succesfully after {} attempts.", counter); - System.exit(0); - } - - var failuresByState = failures.stream().collect(partitioningBy(failure -> { - var ex = new Throwable[] { failure.getException() }; - if (ex[0] instanceof AssertionError) { - ex = ((AssertionError) ex[0]).getSuppressed(); - } - for (var candidate : ex) { - do { - if (canRetry.test(candidate)) { - return true; - } - candidate = candidate.getCause(); - } while (candidate != null); - } - return false; - })); - - if (!failuresByState.get(false).isEmpty()) { - log.error("The following tests failed in non retryable ways:"); - failuresByState.get(false).forEach(failure -> { - log.error(failure.getTestIdentifier().getUniqueId()); - failure.getException().printStackTrace(); - }); - System.exit(1); - } - - selectors = failuresByState.get(true).stream() - .peek(failure -> log.info("{} will be retried", failure.getTestIdentifier().getUniqueId())) - .map(failure -> DiscoverySelectors.selectUniqueId(failure.getTestIdentifier().getUniqueId())) - .collect(toList()); - } - log.error("Several tests failed despite a number of retries."); - System.exit(1); - } -} diff --git a/src/test/resources/logback-silent.xml b/src/test/resources/logback-silent.xml deleted file mode 100644 index 18918384e..000000000 --- a/src/test/resources/logback-silent.xml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - [%t] %d %5p %40.40c:%4L - %m%n - - - - - - - - - - - - - - -