Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wrong permission setup for HiveMQ container #8399

Merged
merged 6 commits into from
Feb 28, 2024
Merged
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
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
Expand Up @@ -134,9 +134,9 @@ protected void configure() {
setCommand(
"-c",
removeCommand +
"cp -r '/opt/hivemq/temp-extensions/'* /opt/hivemq/extensions/ " +
"; chmod -R 777 /opt/hivemq/extensions " +
"&& /opt/docker-entrypoint.sh /opt/hivemq/bin/run.sh"
"cp -r '/opt/hivemq/temp-extensions/'* /opt/hivemq/extensions/ ; " +
"chmod -R 777 /opt/hivemq/extensions ; " +
"/opt/docker-entrypoint.sh /opt/hivemq/bin/run.sh"
);
}

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,18 @@

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 +42,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,15 @@

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 +32,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,15 @@

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 +42,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,15 @@

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 +43,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
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class DemoExtensionTestsIT {

@Container
final HiveMQContainer hivemqWithClasspathExtension = new HiveMQContainer(
DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3")
DockerImageName.parse("hivemq/hivemq-ce").withTag("2024.3")
)
.waitForExtension(hiveMQEClasspathxtension)
.withExtension(hiveMQEClasspathxtension)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class DemoFilesIT {

// hivemqHome {
final HiveMQContainer hivemqFileInHome = new HiveMQContainer(
DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3")
DockerImageName.parse("hivemq/hivemq-ce").withTag("2024.3")
)
.withFileInHomeFolder(
MountableFile.forHostPath("src/test/resources/additionalFile.txt"),
Expand All @@ -31,7 +31,7 @@ class DemoFilesIT {
// extensionHome {
@Container
final HiveMQContainer hivemqFileInExtensionHome = new HiveMQContainer(
DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3")
DockerImageName.parse("hivemq/hivemq-ce").withTag("2024.3")
)
.withExtension(
HiveMQExtension
Expand All @@ -52,7 +52,7 @@ class DemoFilesIT {

// withLicenses {
@Container
final HiveMQContainer hivemq = new HiveMQContainer(DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3"))
final HiveMQContainer hivemq = new HiveMQContainer(DockerImageName.parse("hivemq/hivemq-ce").withTag("2024.3"))
.withLicense(MountableFile.forHostPath("src/test/resources/myLicense.lic"))
.withLicense(MountableFile.forHostPath("src/test/resources/myExtensionLicense.elic"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DemoHiveMQContainerIT {

// ceVersion {
@Container
final HiveMQContainer hivemqCe = new HiveMQContainer(DockerImageName.parse("hivemq/hivemq-ce").withTag("2021.3"))
final HiveMQContainer hivemqCe = new HiveMQContainer(DockerImageName.parse("hivemq/hivemq-ce").withTag("2024.3"))
.withLogLevel(Level.DEBUG);

// }
Expand All @@ -43,7 +43,7 @@ class DemoHiveMQContainerIT {

// specificVersion {
@Container
final HiveMQContainer hivemqSpecificVersion = new HiveMQContainer(DockerImageName.parse("hivemq/hivemq-ce:2021.3"));
final HiveMQContainer hivemqSpecificVersion = new HiveMQContainer(DockerImageName.parse("hivemq/hivemq-ce:2024.3"));

// }

Expand Down
Loading