diff --git a/.github/workflows/CI.yaml b/.github/workflows/CI.yaml index 6186f91fcf..219dd2c848 100644 --- a/.github/workflows/CI.yaml +++ b/.github/workflows/CI.yaml @@ -9,13 +9,31 @@ on: jobs: build: runs-on: ubuntu-latest + env: + DOCKER_ENTERPRISE_DEV_URL: ${{ secrets.DOCKER_ENTERPRISE_DEV_URL }} + DOCKER_COMMUNITY_DEV_URL: ${{ secrets.DOCKER_COMMUNITY_DEV_URL }} + TEAMCITY_DEV_URL: ${{ secrets.TEAMCITY_DEV_URL }} + TEAMCITY_USER: ${{ secrets.TEAMCITY_USER }} + TEAMCITY_PASSWORD: ${{ secrets.TEAMCITY_PASSWORD }} + ENTERPRISE_TAR: enterprise-docker.tar + COMMUNITY_TAR: community-docker.tar steps: - uses: actions/checkout@v2 + - name: Set up JDK 17 uses: actions/setup-java@v2 with: java-version: '17' distribution: 'adopt' + + - name: Download neo4j dev docker container + run: | + curl -s -L0 -u "${TEAMCITY_USER}:${TEAMCITY_PASSWORD}" -X GET ${DOCKER_ENTERPRISE_DEV_URL} -o ${ENTERPRISE_TAR} & + curl -s -L0 -u "${TEAMCITY_USER}:${TEAMCITY_PASSWORD}" -X GET ${DOCKER_COMMUNITY_DEV_URL} -o ${COMMUNITY_TAR} & + wait + docker load --input ${ENTERPRISE_TAR} + docker load --input ${COMMUNITY_TAR} + - uses: actions/cache@v2 with: path: | @@ -24,19 +42,16 @@ jobs: key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} restore-keys: | ${{ runner.os }}-gradle- - - name: Grant execute permission for gradlew - run: chmod +x gradlew + - name: Build with Gradle - env: - TEAMCITY_DEV_URL: ${{ secrets.TEAMCITY_DEV_URL }} - TEAMCITY_USER: ${{ secrets.TEAMCITY_USER }} - TEAMCITY_PASSWORD: ${{ secrets.TEAMCITY_PASSWORD }} - run: ./gradlew build - - name: Clean neo4j from the cache - if: success() || failure() # run this step even if previous step failed - run: (find ~/.gradle/caches -name "*neo4j*" -exec rm -rf {} \;) || echo "All neo4j files cleaned" - - name: Check procedures included in apoc full - run: git diff --exit-code full/src/main/resources/extended.txt || (echo "extended.txt file does not contain all changes" && exit -1) + run: chmod +x gradlew && ./gradlew build + + - name: Clean neo4j artifacts + if: always() # run this step even if previous step failed + run: | + (find ~/.gradle/caches -name "*neo4j*" -exec rm -rf {} \;) || echo "All neo4j files cleaned" + rm -rf ${ENTERPRISE_TAR} ${COMMUNITY_TAR} + - name: Archive test results uses: actions/upload-artifact@v2 if: always() diff --git a/build.gradle b/build.gradle index c98996997c..20607d868c 100644 --- a/build.gradle +++ b/build.gradle @@ -72,8 +72,8 @@ subprojects { // neo4jDockerImage system property is used in TestContainerUtil systemProperties 'user.language' : 'en' , 'user.country ' : 'US', - 'neo4jDockerImage' : System.getProperty("NEO4JVERSION") ? 'neo4j:' + System.getProperty("NEO4JVERSION") + '-enterprise' : 'neo4j:5.0-enterprise', - 'neo4jCommunityDockerImage': System.getProperty("NEO4JVERSION") ? 'neo4j:' + System.getProperty("NEO4JVERSION") : 'neo4j:5.0' + 'neo4jDockerImage' : System.getProperty("NEO4JVERSION") ? 'neo4j:' + System.getProperty("NEO4JVERSION") + '-enterprise' : 'neo4j:5.0.0-dev-enterprise', + 'neo4jCommunityDockerImage': System.getProperty("NEO4JVERSION") ? 'neo4j:' + System.getProperty("NEO4JVERSION") : 'neo4j:5.0.0-dev' maxHeapSize = "8G" forkEvery = 50 @@ -100,6 +100,9 @@ subprojects { filter { setFailOnNoMatchingTests(false) } + + testLogging.showStandardStreams = true + testLogging.exceptionFormat = 'full' } configurations { diff --git a/core/build.gradle b/core/build.gradle index 606ca312f3..c7571038e3 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -134,6 +134,7 @@ dependencies { configurations.all { exclude group: 'org.slf4j', module: 'slf4j-nop' + exclude group: 'ch.qos.logback', module: 'logback-classic' } } diff --git a/core/src/test/java/apoc/StartupTest.java b/core/src/test/java/apoc/StartupTest.java index bfd4a5b293..0de9cdf3c0 100644 --- a/core/src/test/java/apoc/StartupTest.java +++ b/core/src/test/java/apoc/StartupTest.java @@ -20,7 +20,7 @@ public class StartupTest { public void test() { try { Neo4jContainerExtension neo4jContainer = createEnterpriseDB(!TestUtil.isRunningInCI()) - .withNeo4jConfig("dbms.transaction.timeout", "5s"); + .withNeo4jConfig("dbms.transaction.timeout", "60s"); neo4jContainer.start(); diff --git a/docs/gradle/wrapper/gradle-wrapper.properties b/docs/gradle/wrapper/gradle-wrapper.properties index e54747b5c7..9d2b68c7d7 100644 --- a/docs/gradle/wrapper/gradle-wrapper.properties +++ b/docs/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip \ No newline at end of file +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip \ No newline at end of file diff --git a/extra-dependencies/couchbase/build.gradle b/extra-dependencies/couchbase/build.gradle index 9bd439edea..5356def1b9 100644 --- a/extra-dependencies/couchbase/build.gradle +++ b/extra-dependencies/couchbase/build.gradle @@ -3,8 +3,8 @@ plugins { } java { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } archivesBaseName = 'apoc-couchbase-dependencies' diff --git a/extra-dependencies/couchbase/gradle/wrapper/gradle-wrapper.properties b/extra-dependencies/couchbase/gradle/wrapper/gradle-wrapper.properties index e54747b5c7..9d2b68c7d7 100644 --- a/extra-dependencies/couchbase/gradle/wrapper/gradle-wrapper.properties +++ b/extra-dependencies/couchbase/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip \ No newline at end of file +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip \ No newline at end of file diff --git a/extra-dependencies/email/build.gradle b/extra-dependencies/email/build.gradle index 10c85d367c..de79f45538 100644 --- a/extra-dependencies/email/build.gradle +++ b/extra-dependencies/email/build.gradle @@ -3,8 +3,8 @@ plugins { } java { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } diff --git a/extra-dependencies/email/gradle/wrapper/gradle-wrapper.properties b/extra-dependencies/email/gradle/wrapper/gradle-wrapper.properties index e54747b5c7..9d2b68c7d7 100644 --- a/extra-dependencies/email/gradle/wrapper/gradle-wrapper.properties +++ b/extra-dependencies/email/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip \ No newline at end of file +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip \ No newline at end of file diff --git a/extra-dependencies/mongodb/build.gradle b/extra-dependencies/mongodb/build.gradle index 2737948a54..caccfba592 100644 --- a/extra-dependencies/mongodb/build.gradle +++ b/extra-dependencies/mongodb/build.gradle @@ -3,8 +3,8 @@ plugins { } java { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } archivesBaseName = 'apoc-mongodb-dependencies' diff --git a/extra-dependencies/mongodb/gradle/wrapper/gradle-wrapper.properties b/extra-dependencies/mongodb/gradle/wrapper/gradle-wrapper.properties index e54747b5c7..9d2b68c7d7 100644 --- a/extra-dependencies/mongodb/gradle/wrapper/gradle-wrapper.properties +++ b/extra-dependencies/mongodb/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip \ No newline at end of file +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip \ No newline at end of file diff --git a/extra-dependencies/nlp/build.gradle b/extra-dependencies/nlp/build.gradle index 9b5dd29fa7..5821b1e6c7 100644 --- a/extra-dependencies/nlp/build.gradle +++ b/extra-dependencies/nlp/build.gradle @@ -3,8 +3,8 @@ plugins { } java { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } diff --git a/extra-dependencies/nlp/gradle/wrapper/gradle-wrapper.properties b/extra-dependencies/nlp/gradle/wrapper/gradle-wrapper.properties index e54747b5c7..9d2b68c7d7 100644 --- a/extra-dependencies/nlp/gradle/wrapper/gradle-wrapper.properties +++ b/extra-dependencies/nlp/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip \ No newline at end of file +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip \ No newline at end of file diff --git a/extra-dependencies/redis/build.gradle b/extra-dependencies/redis/build.gradle index 615fed407a..3857c771c8 100644 --- a/extra-dependencies/redis/build.gradle +++ b/extra-dependencies/redis/build.gradle @@ -3,8 +3,8 @@ plugins { } java { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } archivesBaseName = 'apoc-redis-dependencies' diff --git a/extra-dependencies/redis/gradle/wrapper/gradle-wrapper.properties b/extra-dependencies/redis/gradle/wrapper/gradle-wrapper.properties index e54747b5c7..9d2b68c7d7 100644 --- a/extra-dependencies/redis/gradle/wrapper/gradle-wrapper.properties +++ b/extra-dependencies/redis/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip \ No newline at end of file +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip \ No newline at end of file diff --git a/extra-dependencies/xls/build.gradle b/extra-dependencies/xls/build.gradle index ac85f708d9..d1e0c30b1b 100644 --- a/extra-dependencies/xls/build.gradle +++ b/extra-dependencies/xls/build.gradle @@ -3,8 +3,8 @@ plugins { } java { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 } diff --git a/extra-dependencies/xls/gradle/wrapper/gradle-wrapper.properties b/extra-dependencies/xls/gradle/wrapper/gradle-wrapper.properties index e54747b5c7..9d2b68c7d7 100644 --- a/extra-dependencies/xls/gradle/wrapper/gradle-wrapper.properties +++ b/extra-dependencies/xls/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip \ No newline at end of file +distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-bin.zip \ No newline at end of file diff --git a/full/build.gradle b/full/build.gradle index 79415995cb..0f4791920c 100644 --- a/full/build.gradle +++ b/full/build.gradle @@ -6,12 +6,11 @@ plugins { id 'maven-publish' id 'antlr' id "org.sonarqube" - id "org.jetbrains.kotlin.jvm" version "1.5.31" + id "org.jetbrains.kotlin.jvm" version "1.6.0" } archivesBaseName = "apoc" - jar { manifest { attributes 'Implementation-Version': version @@ -20,7 +19,7 @@ jar { } compileKotlin { - kotlinOptions.jvmTarget = "1.8" + kotlinOptions.jvmTarget = "17" } generateGrammarSource { @@ -48,7 +47,7 @@ dependencies { // implementation group: 'commons-codec', name: 'commons-codec', version: '1.14' implementation group: 'com.jayway.jsonpath', name: 'json-path', version: '2.4.0' implementation group: 'org.hdrhistogram', name: 'HdrHistogram', version: '2.1.9' - implementation group: 'org.neo4j.driver', name: 'neo4j-java-driver', version: '4.0.0' + compileOnly group: 'org.neo4j.driver', name: 'neo4j-java-driver-slim', version: '4.4.3' implementation group: 'com.novell.ldap', name: 'jldap', version: '2009-10-07' antlr "org.antlr:antlr4:4.7.2", { @@ -153,10 +152,14 @@ dependencies { configurations.all { exclude group: 'org.slf4j', module: 'slf4j-nop' + exclude group: 'ch.qos.logback', module: 'logback-classic' } } - +java { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 +} // tweaks for CI if (System.env.CI == 'true') { diff --git a/full/src/main/kotlin/apoc/nlp/azure/AzureProcedures.kt b/full/src/main/kotlin/apoc/nlp/azure/AzureProcedures.kt index 1e8a8f6f30..5e3c7625da 100755 --- a/full/src/main/kotlin/apoc/nlp/azure/AzureProcedures.kt +++ b/full/src/main/kotlin/apoc/nlp/azure/AzureProcedures.kt @@ -1,6 +1,7 @@ package apoc.nlp.azure +import apoc.Extended import apoc.nlp.NLPHelperFunctions import apoc.nlp.NLPHelperFunctions.convert import apoc.nlp.NLPHelperFunctions.getNodeProperty @@ -14,6 +15,7 @@ import org.neo4j.logging.Log import org.neo4j.procedure.* import java.util.stream.Stream +@Extended class AzureProcedures { @Context @JvmField diff --git a/full/src/main/resources/extended.txt b/full/src/main/resources/extended.txt index 56451c9321..c6a41e45c2 100644 --- a/full/src/main/resources/extended.txt +++ b/full/src/main/resources/extended.txt @@ -87,6 +87,12 @@ apoc.nlp.aws.keyPhrases.graph apoc.nlp.aws.keyPhrases.stream apoc.nlp.aws.sentiment.graph apoc.nlp.aws.sentiment.stream +apoc.nlp.azure.entities.graph +apoc.nlp.azure.entities.stream +apoc.nlp.azure.keyPhrases.graph +apoc.nlp.azure.keyPhrases.stream +apoc.nlp.azure.sentiment.graph +apoc.nlp.azure.sentiment.stream apoc.nlp.gcp.classify.graph apoc.nlp.gcp.classify.stream apoc.nlp.gcp.entities.graph diff --git a/full/src/test/java/apoc/CoreExtendedTest.java b/full/src/test/java/apoc/CoreExtendedTest.java index 3bd3a0bf59..457cdca177 100644 --- a/full/src/test/java/apoc/CoreExtendedTest.java +++ b/full/src/test/java/apoc/CoreExtendedTest.java @@ -57,7 +57,7 @@ public void checkForCoreAndExtended() { public void matchesSpreadsheet() { try { Neo4jContainerExtension neo4jContainer = createEnterpriseDB(!TestUtil.isRunningInCI()) - .withNeo4jConfig("dbms.transaction.timeout", "5s"); + .withNeo4jConfig("dbms.transaction.timeout", "60s"); neo4jContainer.start(); diff --git a/full/src/test/java/apoc/cypher/CypherEnterpriseTest.java b/full/src/test/java/apoc/cypher/CypherEnterpriseTest.java index 2d9d8add5a..d237d82b8b 100644 --- a/full/src/test/java/apoc/cypher/CypherEnterpriseTest.java +++ b/full/src/test/java/apoc/cypher/CypherEnterpriseTest.java @@ -27,7 +27,7 @@ public static void beforeAll() { TestUtil.ignoreException(() -> { // We build the project, the artifact will be placed into ./build/libs neo4jContainer = createEnterpriseDB(!TestUtil.isRunningInCI()) - .withNeo4jConfig("dbms.transaction.timeout", "5s"); + .withNeo4jConfig("dbms.transaction.timeout", "60s"); neo4jContainer.start(); }, Exception.class); assumeNotNull(neo4jContainer); diff --git a/processor/src/main/java/apoc/processor/ApocProcessor.java b/processor/src/main/java/apoc/processor/ApocProcessor.java index 69b2d3a250..7c5deb9a9b 100644 --- a/processor/src/main/java/apoc/processor/ApocProcessor.java +++ b/processor/src/main/java/apoc/processor/ApocProcessor.java @@ -7,11 +7,12 @@ import javax.annotation.processing.AbstractProcessor; import javax.annotation.processing.ProcessingEnvironment; import javax.annotation.processing.RoundEnvironment; -import javax.lang.model.element.TypeElement; +import javax.annotation.processing.SupportedSourceVersion;import javax.lang.model.SourceVersion;import javax.lang.model.element.TypeElement; import java.util.ArrayList; import java.util.List; import java.util.Set; +@SupportedSourceVersion(SourceVersion.RELEASE_17) public class ApocProcessor extends AbstractProcessor { private List procedureSignatures; diff --git a/test-startup/build.gradle b/test-startup/build.gradle index 47c04d113d..e7947633a3 100644 --- a/test-startup/build.gradle +++ b/test-startup/build.gradle @@ -3,4 +3,9 @@ description = 'APOC :: Test Startup Module' dependencies { testImplementation project(':core') testImplementation project(':test-utils') + + configurations.all { + exclude group: 'org.slf4j', module: 'slf4j-nop' + exclude group: 'ch.qos.logback', module: 'logback-classic' + } } diff --git a/test-startup/src/test/java/StartupTest.java b/test-startup/src/test/java/StartupTest.java index e088ae5dfd..f769d75ccf 100644 --- a/test-startup/src/test/java/StartupTest.java +++ b/test-startup/src/test/java/StartupTest.java @@ -2,7 +2,8 @@ import apoc.util.Neo4jContainerExtension; import apoc.util.TestContainerUtil; import apoc.util.TestUtil; -import org.junit.Test; +import apoc.util.TestContainerUtil.Neo4jVersion;import org.junit.Test; + import org.neo4j.driver.Session; import java.io.File; @@ -10,7 +11,7 @@ import java.util.List; import java.util.stream.Collectors; -import static apoc.util.TestContainerUtil.createEnterpriseDB; +import static apoc.util.TestContainerUtil.createDB; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -31,50 +32,58 @@ public class StartupTest { @Test public void check_basic_deployment() { - try (Neo4jContainerExtension neo4jContainer = createEnterpriseDB(APOC_FULL, !TestUtil.isRunningInCI()) - .withNeo4jConfig("dbms.transaction.timeout", "5s")) { - - neo4jContainer.start(); - assertTrue("Neo4j Instance should be up-and-running", neo4jContainer.isRunning()); - - Session session = neo4jContainer.getSession(); - int procedureCount = session.run("SHOW PROCEDURES YIELD name WHERE name STARTS WITH 'apoc' RETURN count(*) AS count").peek().get("count").asInt(); - int functionCount = session.run("SHOW FUNCTIONS YIELD name WHERE name STARTS WITH 'apoc' RETURN count(*) AS count").peek().get("count").asInt(); - int coreCount = session.run("CALL apoc.help('') YIELD core WHERE core = true RETURN count(*) AS count").peek().get("count").asInt(); - - assertTrue(procedureCount > 0); - assertTrue(functionCount > 0); - assertTrue(coreCount > 0); - } catch (Exception ex) { - // if Testcontainers wasn't able to retrieve the docker image we ignore the test - if (TestContainerUtil.isDockerImageAvailable(ex)) { - ex.printStackTrace(); - fail("Should not have thrown exception when trying to start Neo4j: " + ex); + for (var version: Neo4jVersion.values()) { + try (Neo4jContainerExtension neo4jContainer = createDB(version, APOC_FULL, !TestUtil.isRunningInCI()) + .withNeo4jConfig("dbms.transaction.timeout", "60s")) { + + neo4jContainer.start(); + assertTrue("Neo4j Instance should be up-and-running", neo4jContainer.isRunning()); + + Session session = neo4jContainer.getSession(); + int procedureCount = session.run("SHOW PROCEDURES YIELD name WHERE name STARTS WITH 'apoc' RETURN count(*) AS count").peek().get("count").asInt(); + int functionCount = session.run("SHOW FUNCTIONS YIELD name WHERE name STARTS WITH 'apoc' RETURN count(*) AS count").peek().get("count").asInt(); + int coreCount = session.run("CALL apoc.help('') YIELD core WHERE core = true RETURN count(*) AS count").peek().get("count").asInt(); + + assertTrue(procedureCount > 0); + assertTrue(functionCount > 0); + assertTrue(coreCount > 0); + } catch (Exception ex) { + // if Testcontainers wasn't able to retrieve the docker image we ignore the test + if (TestContainerUtil.isDockerImageAvailable(ex)) { + ex.printStackTrace(); + fail("Should not have thrown exception when trying to start Neo4j: " + ex); + } else if (!TestUtil.isRunningInCI()) { + fail( "The docker image " + TestContainerUtil.neo4jEnterpriseDockerImageVersion + " should be available in the CI"); + } } } } @Test public void compare_with_sources() { - try (Neo4jContainerExtension neo4jContainer = createEnterpriseDB(APOC_FULL, !TestUtil.isRunningInCI())) { - neo4jContainer.start(); + for (var version: Neo4jVersion.values()) { + try (Neo4jContainerExtension neo4jContainer = createDB(version, APOC_FULL, !TestUtil.isRunningInCI())) { + neo4jContainer.start(); - assertTrue("Neo4j Instance should be up-and-running", neo4jContainer.isRunning()); + assertTrue("Neo4j Instance should be up-and-running", neo4jContainer.isRunning()); - try (Session session = neo4jContainer.getSession()) { - final List functionNames = session.run("CALL apoc.help('') YIELD core, type, name WHERE core = true and type = 'function' RETURN name") - .list(record -> record.get("name").asString()); - final List procedureNames = session.run("CALL apoc.help('') YIELD core, type, name WHERE core = true and type = 'procedure' RETURN name") - .list(record -> record.get("name").asString()); + try (Session session = neo4jContainer.getSession()) { + final List functionNames = session.run("CALL apoc.help('') YIELD core, type, name WHERE core = true and type = 'function' RETURN name") + .list(record -> record.get("name").asString()); + final List procedureNames = session.run("CALL apoc.help('') YIELD core, type, name WHERE core = true and type = 'procedure' RETURN name") + .list(record -> record.get("name").asString()); - assertEquals(sorted(ApocSignatures.PROCEDURES), procedureNames); - assertEquals(sorted(ApocSignatures.FUNCTIONS), functionNames); - } - } catch (Exception ex) { - if (TestContainerUtil.isDockerImageAvailable(ex)) { - ex.printStackTrace(); - fail("Should not have thrown exception when trying to start Neo4j: " + ex); + assertEquals(sorted(ApocSignatures.PROCEDURES), procedureNames); + assertEquals(sorted(ApocSignatures.FUNCTIONS), functionNames); + } + } catch (Exception ex) { + if (TestContainerUtil.isDockerImageAvailable(ex)) { + ex.printStackTrace(); + fail("Should not have thrown exception when trying to start Neo4j: " + ex); + } else { + fail( "The docker image " + TestContainerUtil.neo4jEnterpriseDockerImageVersion + " should be available in the CI"); + } } } } diff --git a/test-utils/src/main/java/apoc/util/TestContainerUtil.java b/test-utils/src/main/java/apoc/util/TestContainerUtil.java index b5590492ac..87272c02be 100644 --- a/test-utils/src/main/java/apoc/util/TestContainerUtil.java +++ b/test-utils/src/main/java/apoc/util/TestContainerUtil.java @@ -28,6 +28,14 @@ import static org.junit.Assert.assertTrue; public class TestContainerUtil { + public enum Neo4jVersion { + ENTERPRISE, + COMMUNITY + } + + // read neo4j version from build.gradle + public static final String neo4jEnterpriseDockerImageVersion = System.getProperty("neo4jDockerImage"); + public static final String neo4jCommunityDockerImageVersion = System.getProperty("neo4jCommunityDockerImage"); private TestContainerUtil() {} @@ -37,19 +45,31 @@ public static TestcontainersCausalCluster createEnterpriseCluster(int numOfCoreI return TestcontainersCausalCluster.create(numOfCoreInstances, numberOfReadReplica, Duration.ofMinutes(4), neo4jConfig, envSettings); } + public static Neo4jContainerExtension createDB(Neo4jVersion version, File baseDir, boolean withLogging) { + return switch(version) { + case ENTERPRISE -> createEnterpriseDB(baseDir, withLogging); + case COMMUNITY -> createCommunityDB(baseDir, withLogging); + }; + } + public static Neo4jContainerExtension createEnterpriseDB(boolean withLogging) { return createEnterpriseDB(baseDir, withLogging); } - public static Neo4jContainerExtension createEnterpriseDB(File baseDir, boolean withLogging) { + public static Neo4jContainerExtension createEnterpriseDB(File baseDir, boolean withLogging) { + return createNeo4jContainer(neo4jEnterpriseDockerImageVersion, baseDir, withLogging ); + } + + public static Neo4jContainerExtension createCommunityDB(File baseDir, boolean withLogging) { + return createNeo4jContainer(neo4jCommunityDockerImageVersion, baseDir, withLogging ); + } + + private static Neo4jContainerExtension createNeo4jContainer(String dockerImage, File baseDir, boolean withLogging) { executeGradleTasks(baseDir, "shadowJar"); // We define the container with external volumes File importFolder = new File("import"); importFolder.mkdirs(); - // read neo4j version from build.gradle and use this as default - String neo4jDockerImageVersion = System.getProperty("neo4jDockerImage", "neo4j:5.0-enterprise"); - // use a separate folder for mounting plugins jar - build/libs might contain other jars as well. File pluginsFolder = new File(baseDir, "build/plugins"); pluginsFolder.mkdirs(); @@ -69,8 +89,8 @@ public static Neo4jContainerExtension createEnterpriseDB(File baseDir, boolean w e.printStackTrace(); } - System.out.println("neo4jDockerImageVersion = " + neo4jDockerImageVersion); - Neo4jContainerExtension neo4jContainer = new Neo4jContainerExtension(neo4jDockerImageVersion) + System.out.println("neo4jDockerImageVersion = " + dockerImage); + Neo4jContainerExtension neo4jContainer = new Neo4jContainerExtension(dockerImage) .withPlugins(MountableFile.forHostPath(pluginsFolder.toPath())) .withAdminPassword("apoc") .withEnv("NEO4J_dbms_memory_heap_max__size", "512M")