Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@ public class Neo4jContainer extends GenericContainer<Neo4jContainer> {
*/
private static final DockerImageName DEFAULT_IMAGE_NAME = DockerImageName.parse("neo4j");

/**
* The default tag (version) to use.
*/
private static final String DEFAULT_TAG = "4.4";

private static final String ENTERPRISE_TAG = DEFAULT_TAG + "-enterprise";
private static final String ENTERPRISE_SUFFIX = "-enterprise";

/**
* Default port for the binary Bolt protocol.
Expand Down Expand Up @@ -211,8 +206,7 @@ public Neo4jContainer withEnterpriseEdition() {
String.format("Cannot use enterprise version with alternative image %s.", getDockerImageName())
);
}

setDockerImageName(DEFAULT_IMAGE_NAME.withTag(ENTERPRISE_TAG).asCanonicalNameString());
setDockerImageName(DockerImageName.parse(getDockerImageName() + ENTERPRISE_SUFFIX).asCanonicalNameString());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will break existing users. Why not improve the exception's message?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a technical, formal perspective I would say, that you are right.
But (of course) I would consider this as a bug that came as a left-over when we've removed the default constructor that fell back to the default image name.
I think that nobody would expect working with a neo4j:5.26 image to get ported back to the previous major version (4.4) when enabling enterprise per API.

LicenseAcceptance.assertLicenseAccepted(getDockerImageName());

addEnv("NEO4J_ACCEPT_LICENSE_AGREEMENT", "yes");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
public class Neo4jContainerJUnitIntegrationTest {

@ClassRule
public static Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4");
public static Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:5.26");

@Test
public void shouldStart() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void shouldDisableAuthentication() {
try (
// spotless:off
// withoutAuthentication {
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4")
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:5.26")
.withoutAuthentication()
// }
// spotless:on
Expand Down Expand Up @@ -71,20 +71,11 @@ public void shouldCopyDatabase() {
}
}

@Test
public void shouldFailOnCopyDatabaseForDefaultNeo4j4Image() {
assertThatIllegalArgumentException()
.isThrownBy(() -> {
new Neo4jContainer("neo4j:4.4.1").withDatabase(MountableFile.forClasspathResource("/test-graph.db"));
})
.withMessage("Copying database folder is not supported for Neo4j instances with version 4.0 or higher.");
}

@Test
public void shouldFailOnCopyDatabaseForCustomNeo4j4Image() {
assertThatIllegalArgumentException()
.isThrownBy(() -> {
new Neo4jContainer("neo4j:4.4.1").withDatabase(MountableFile.forClasspathResource("/test-graph.db"));
new Neo4jContainer("neo4j:5.26.10").withDatabase(MountableFile.forClasspathResource("/test-graph.db"));
})
.withMessage("Copying database folder is not supported for Neo4j instances with version 4.0 or higher.");
}
Expand All @@ -102,7 +93,7 @@ public void shouldFailOnCopyDatabaseForCustomNonSemverNeo4j4Image() {
public void shouldCopyPlugins() {
try (
// registerPluginsPath {
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4")
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:5.26")
.withPlugins(MountableFile.forClasspathResource("/custom-plugins"))
// }
) {
Expand All @@ -117,7 +108,7 @@ public void shouldCopyPlugins() {
public void shouldCopyPlugin() {
try (
// registerPluginsJar {
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4")
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:5.26")
.withPlugins(MountableFile.forClasspathResource("/custom-plugins/hello-world.jar"))
// }
) {
Expand All @@ -139,10 +130,10 @@ private static void assertThatCustomPluginWasCopied(Session session) {
public void shouldCheckEnterpriseLicense() {
assumeThat(Neo4jContainerTest.class.getResource(ACCEPTANCE_FILE_LOCATION)).isNull();

String expectedImageName = "neo4j:4.4-enterprise";
String expectedImageName = "neo4j:5.26-enterprise";

assertThatExceptionOfType(IllegalStateException.class)
.isThrownBy(() -> new Neo4jContainer("neo4j:4.4").withEnterpriseEdition())
.isThrownBy(() -> new Neo4jContainer("neo4j:5.26").withEnterpriseEdition())
.withMessageContaining("The image " + expectedImageName + " requires you to accept a license agreement.");
}

Expand All @@ -152,7 +143,7 @@ public void shouldRunEnterprise() {

try (
// enterpriseEdition {
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4")
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:5.26")
.withEnterpriseEdition()
// }
.withAdminPassword("Picard123")
Expand All @@ -172,7 +163,7 @@ public void shouldRunEnterprise() {
@Test
public void shouldAddConfigToEnvironment() {
// neo4jConfiguration {
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4")
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:5.26")
.withNeo4jConfig("dbms.security.procedures.unrestricted", "apoc.*,algo.*")
.withNeo4jConfig("dbms.tx_log.rotation.size", "42M");
// }
Expand All @@ -184,7 +175,7 @@ public void shouldAddConfigToEnvironment() {

@Test
public void shouldRespectEnvironmentAuth() {
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4").withEnv("NEO4J_AUTH", "neo4j/secret");
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:5.26").withEnv("NEO4J_AUTH", "neo4j/secret");

neo4jContainer.configure();

Expand All @@ -194,7 +185,7 @@ public void shouldRespectEnvironmentAuth() {
@Test
public void shouldSetCustomPasswordCorrectly() {
// withAdminPassword {
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4").withAdminPassword("verySecret");
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:5.26").withAdminPassword("verySecret");
// }

neo4jContainer.configure();
Expand All @@ -204,7 +195,7 @@ public void shouldSetCustomPasswordCorrectly() {

@Test
public void containerAdminPasswordOverrulesEnvironmentAuth() {
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4")
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:5.26")
.withEnv("NEO4J_AUTH", "neo4j/secret")
.withAdminPassword("anotherSecret");

Expand All @@ -215,7 +206,7 @@ public void containerAdminPasswordOverrulesEnvironmentAuth() {

@Test
public void containerWithoutAuthenticationOverrulesEnvironmentAuth() {
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4")
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:5.26")
.withEnv("NEO4J_AUTH", "neo4j/secret")
.withoutAuthentication();

Expand All @@ -226,7 +217,7 @@ public void containerWithoutAuthenticationOverrulesEnvironmentAuth() {

@Test
public void shouldRespectAlreadyDefinedPortMappingsBolt() {
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4").withExposedPorts(7687);
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:5.26").withExposedPorts(7687);

neo4jContainer.configure();

Expand All @@ -235,7 +226,7 @@ public void shouldRespectAlreadyDefinedPortMappingsBolt() {

@Test
public void shouldRespectAlreadyDefinedPortMappingsHttp() {
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4").withExposedPorts(7474);
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:5.26").withExposedPorts(7474);

neo4jContainer.configure();

Expand All @@ -244,7 +235,7 @@ public void shouldRespectAlreadyDefinedPortMappingsHttp() {

@Test
public void shouldRespectAlreadyDefinedPortMappingsWithoutHttps() {
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4").withExposedPorts(7687, 7474);
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:5.26").withExposedPorts(7687, 7474);

neo4jContainer.configure();

Expand All @@ -253,7 +244,7 @@ public void shouldRespectAlreadyDefinedPortMappingsWithoutHttps() {

@Test
public void shouldDefaultExportBoltHttpAndHttps() {
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4");
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:5.26");

neo4jContainer.configure();

Expand All @@ -262,7 +253,7 @@ public void shouldDefaultExportBoltHttpAndHttps() {

@Test
public void shouldRespectCustomWaitStrategy() {
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4").waitingFor(new CustomDummyWaitStrategy());
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:5.26").waitingFor(new CustomDummyWaitStrategy());

neo4jContainer.configure();

Expand All @@ -271,7 +262,7 @@ public void shouldRespectCustomWaitStrategy() {

@Test
public void shouldConfigureSinglePluginByName() {
try (Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4").withPlugins("apoc")) {
try (Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:5.26").withPlugins("apoc")) {
// needs to get called explicitly for setup
neo4jContainer.configure();

Expand All @@ -283,7 +274,7 @@ public void shouldConfigureSinglePluginByName() {
public void shouldConfigureMultiplePluginsByName() {
try (
// configureLabsPlugins {
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4") //
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:5.26") //
.withPlugins("apoc", "bloom");
// }
) {
Expand All @@ -299,7 +290,7 @@ public void shouldConfigureMultiplePluginsByName() {
public void shouldCreateRandomUuidBasedPasswords() {
try (
// withRandomPassword {
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4").withRandomPassword();
Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:5.26").withRandomPassword();
// }
) {
// It will throw an exception if it's not UUID parsable.
Expand All @@ -312,8 +303,8 @@ public void shouldCreateRandomUuidBasedPasswords() {

@Test
public void shouldWarnOnPasswordTooShort() {
try (Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:4.4");) {
Logger logger = (Logger) DockerLoggerFactory.getLogger("neo4j:4.4");
try (Neo4jContainer neo4jContainer = new Neo4jContainer("neo4j:5.26");) {
Logger logger = (Logger) DockerLoggerFactory.getLogger("neo4j:5.26");
TestLogAppender testLogAppender = new TestLogAppender();
logger.addAppender(testLogAppender);
testLogAppender.start();
Expand Down
Loading