Skip to content

Commit

Permalink
Update hivemq-ce in tests to a version that runs as a non-root user
Browse files Browse the repository at this point in the history
Run some tests with an older hivemq-ce version as well
  • Loading branch information
SgtSilvio committed Feb 28, 2024
1 parent 56b7c62 commit 35a9139
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 23 deletions.
3 changes: 1 addition & 2 deletions modules/hivemq/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ dependencies {
shaded("org.jboss.shrinkwrap:shrinkwrap-impl-base:1.2.6")
shaded("net.lingala.zip4j:zip4j:2.11.5")

testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.1")
testImplementation("org.junit.jupiter:junit-jupiter:5.10.1")
testImplementation(project(":junit-jupiter"))
testImplementation("com.hivemq:hivemq-extension-sdk:4.24.0")
testImplementation("com.hivemq:hivemq-mqtt-client:1.3.3")
testImplementation("org.apache.httpcomponents:httpclient:4.5.14")
testImplementation("ch.qos.logback:logback-classic:1.4.14")
testImplementation 'org.assertj:assertj-core:3.25.1'
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.1")
}

test {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package org.testcontainers.hivemq;

import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.slf4j.event.Level;
import org.testcontainers.hivemq.util.TestPublishModifiedUtil;
import org.testcontainers.utility.DockerImageName;
Expand All @@ -11,12 +14,16 @@

class ContainerWithExtensionFromDirectoryIT {

@Test
@ParameterizedTest
@ValueSource(strings = {
"2020.1", // first version that provided a container image
"2024.3" // version that runs the image as a non-root user by default
})
@Timeout(value = 3, unit = TimeUnit.MINUTES)
void test() throws Exception {
void test(final @NotNull String hivemqCeTag) throws Exception {
try (
final HiveMQContainer hivemq = new HiveMQContainer(
DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3")
DockerImageName.parse("hivemq/hivemq-ce").withTag(hivemqCeTag)
)
.withExtension(MountableFile.forClasspathResource("/modifier-extension"))
.waitForExtension("Modifier Extension")
Expand All @@ -33,7 +40,7 @@ void test() throws Exception {
void test_wrongDirectoryName() throws Exception {
try (
final HiveMQContainer hivemq = new HiveMQContainer(
DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3")
DockerImageName.parse("hivemq/hivemq-ce").withTag("2024.3")
)
.withExtension(MountableFile.forClasspathResource("/modifier-extension-wrong-name"))
.waitForExtension("Modifier Extension")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.testcontainers.hivemq;

import org.junit.jupiter.api.Test;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.testcontainers.hivemq.util.MyExtension;
import org.testcontainers.hivemq.util.TestPublishModifiedUtil;
import org.testcontainers.utility.DockerImageName;
Expand All @@ -11,9 +13,13 @@

class ContainerWithExtensionIT {

@Test
@ParameterizedTest
@ValueSource(strings = {
"2020.1", // first version that provided a container image
"2024.3" // version that runs the image as a non-root user by default
})
@Timeout(value = 3, unit = TimeUnit.MINUTES)
void test() throws Exception {
void test(final @NotNull String hivemqCeTag) throws Exception {
final HiveMQExtension hiveMQExtension = HiveMQExtension
.builder()
.id("extension-1")
Expand All @@ -24,7 +30,7 @@ void test() throws Exception {

try (
final HiveMQContainer hivemq = new HiveMQContainer(
DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3")
DockerImageName.parse("hivemq/hivemq-ce").withTag(hivemqCeTag)
)
.withHiveMQConfig(MountableFile.forClasspathResource("/inMemoryConfig.xml"))
.waitForExtension(hiveMQExtension)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void test() throws Exception {

try (
final HiveMQContainer hivemq = new HiveMQContainer(
DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3")
DockerImageName.parse("hivemq/hivemq-ce").withTag("2024.3")
)
.waitForExtension(hiveMQExtension)
.withExtension(hiveMQExtension)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
import com.hivemq.extension.sdk.api.services.Services;
import com.hivemq.extension.sdk.api.services.intializer.ClientInitializer;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.testcontainers.hivemq.util.TestPublishModifiedUtil;
import org.testcontainers.utility.DockerImageName;
import org.testcontainers.utility.MountableFile;
Expand All @@ -22,9 +23,13 @@

class ContainerWithFileInExtensionHomeIT {

@Test
@ParameterizedTest
@ValueSource(strings = {
"2020.1", // first version that provided a container image
"2024.3" // version that runs the image as a non-root user by default
})
@Timeout(value = 3, unit = TimeUnit.MINUTES)
void test() throws Exception {
void test(final @NotNull String hivemqCeTag) throws Exception {
final HiveMQExtension hiveMQExtension = HiveMQExtension
.builder()
.id("extension-1")
Expand All @@ -35,7 +40,7 @@ void test() throws Exception {

try (
final HiveMQContainer hivemq = new HiveMQContainer(
DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3")
DockerImageName.parse("hivemq/hivemq-ce").withTag(hivemqCeTag)
)
.withHiveMQConfig(MountableFile.forClasspathResource("/inMemoryConfig.xml"))
.withExtension(hiveMQExtension)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void test() throws Exception {

try (
final HiveMQContainer hivemq = new HiveMQContainer(
DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3")
DockerImageName.parse("hivemq/hivemq-ce").withTag("2024.3")
)
.withHiveMQConfig(MountableFile.forClasspathResource("/inMemoryConfig.xml"))
.withExtension(hiveMQExtension)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void test() throws Exception {

try (
final HiveMQContainer hivemq = new HiveMQContainer(
DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3")
DockerImageName.parse("hivemq/hivemq-ce").withTag("2024.3")
)
.withHiveMQConfig(MountableFile.forClasspathResource("/inMemoryConfig.xml"))
.withExtension(hiveMQExtension)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void test() throws Exception {

try (
final HiveMQContainer hivemq = new HiveMQContainer(
DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3")
DockerImageName.parse("hivemq/hivemq-ce").withTag("2024.3")
)
.withHiveMQConfig(MountableFile.forClasspathResource("/inMemoryConfig.xml"))
.withExtension(extension)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
import com.hivemq.extension.sdk.api.services.Services;
import com.hivemq.extension.sdk.api.services.intializer.ClientInitializer;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import org.testcontainers.hivemq.util.TestPublishModifiedUtil;
import org.testcontainers.utility.DockerImageName;
import org.testcontainers.utility.MountableFile;
Expand All @@ -23,9 +24,13 @@

class CreateFileInExtensionDirectoryIT {

@Test
@ParameterizedTest
@ValueSource(strings = {
"2020.1", // first version that provided a container image
"2024.3" // version that runs the image as a non-root user by default
})
@Timeout(value = 3, unit = TimeUnit.MINUTES)
void test() throws Exception {
void test(final @NotNull String hivemqCeTag) throws Exception {
final HiveMQExtension hiveMQExtension = HiveMQExtension
.builder()
.id("extension-1")
Expand All @@ -36,7 +41,7 @@ void test() throws Exception {

try (
final HiveMQContainer hivemq = new HiveMQContainer(
DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3")
DockerImageName.parse("hivemq/hivemq-ce").withTag(hivemqCeTag)
)
.withHiveMQConfig(MountableFile.forClasspathResource("/inMemoryConfig.xml"))
.waitForExtension(hiveMQExtension)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
class HiveMQTestContainerCore {

@NotNull
final HiveMQContainer container = new HiveMQContainer(DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3"));
final HiveMQContainer container = new HiveMQContainer(DockerImageName.parse("hivemq/hivemq-ce").withTag("2024.3"));

@TempDir
File tempDir;
Expand Down

0 comments on commit 35a9139

Please sign in to comment.