Skip to content

Commit

Permalink
Add oci image definition, use it in integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtSilvio committed Nov 22, 2024
1 parent 6e88d14 commit e50c053
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 13 deletions.
33 changes: 32 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,37 @@ oci {
optionalCredentials()
}
}
imageMapping {
mapModule("com.hivemq", "hivemq-enterprise") {
toImage("hivemq/hivemq4")
}
}
imageDefinitions.register("main") {
allPlatforms {
dependencies {
runtime("com.hivemq:hivemq-enterprise:latest") { isChanging = true }
}
config {
ports = setOf("9399")
}
layers {
layer("hivemqExtension") {
contents {
permissions("opt/hivemq/", 0b111_111_000)
permissions("opt/hivemq/extensions/", 0b111_111_000)
into("opt/hivemq/extensions") {
filePermissions = 0b110_100_000 // TODO remove, use default
directoryPermissions = 0b111_101_000 // TODO remove, use default
permissions("*/", 0b111_111_000)
permissions("*/hivemq-extension.xml", 0b110_110_000)
permissions("*/prometheusConfiguration.properties", 0b110_110_000)
from(zipTree(tasks.hivemqExtensionZip.flatMap { it.archiveFile }))
}
}
}
}
}
}
}

@Suppress("UnstableApiUsage")
Expand Down Expand Up @@ -64,7 +95,7 @@ testing {
}
oci.of(this) {
imageDependencies {
runtime("hivemq:hivemq4:latest") { isChanging = true }
runtime(project).tag("latest")
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.testcontainers.hivemq.HiveMQExtension;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.utility.MountableFile;

import java.io.IOException;
import java.util.Map;
Expand All @@ -52,17 +51,16 @@
class PrometheusExtensionIT {

@Container
final @NotNull HiveMQContainer hivemq = new HiveMQContainer(OciImages.getImageName("hivemq/hivemq4")) //
.withExtension(MountableFile.forClasspathResource("hivemq-prometheus-extension"))
.waitForExtension("Prometheus Monitoring Extension")
.withExposedPorts(9399)
.withExtension(HiveMQExtension.builder()
.mainClass(MyMetricsExtension.class)
.name("metrics-extension")
.id("metrics-extension")
.version("1.0.0")
.build())
.waitForExtension("metrics-extension");
final @NotNull HiveMQContainer hivemq =
new HiveMQContainer(OciImages.getImageName("hivemq/extensions/hivemq-prometheus-extension")
.asCompatibleSubstituteFor("hivemq/hivemq4")) //
.withExposedPorts(9399)
.withExtension(HiveMQExtension.builder()
.mainClass(MyMetricsExtension.class)
.name("metrics-extension")
.id("metrics-extension")
.version("1.0.0")
.build());

@Test
@Timeout(value = 5, unit = TimeUnit.MINUTES)
Expand Down

0 comments on commit e50c053

Please sign in to comment.