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 9226bc1 commit 825e1be
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 963 deletions.
44 changes: 43 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,44 @@ oci {
optionalCredentials()
}
}
imageMapping {
mapModule("com.hivemq", "hivemq-enterprise") {
toImage("hivemq/hivemq4")
}
}
imageDefinitions {
register("main") {
allPlatforms {
dependencies {
runtime("com.hivemq:hivemq-enterprise:latest") { isChanging = true }
}
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("*/dnsdiscovery.properties", 0b110_110_000)
permissions("*/hivemq-extension.xml", 0b110_110_000)
from(zipTree(tasks.hivemqExtensionZip.flatMap { it.archiveFile }))
}
}
}
}
}
}
register("integrationTest") {
allPlatforms {
dependencies {
runtime(project)
runtime("com.hivemq.extensions:hivemq-prometheus-extension")
}
}
}
}
}

@Suppress("UnstableApiUsage")
Expand Down Expand Up @@ -61,7 +99,11 @@ testing {
}
oci.of(this) {
imageDependencies {
runtime("hivemq:hivemq4:latest") { isChanging = true }
runtime(project) {
capabilities {
requireCapability("$group:$name-integration-test") // TODO requireFeature("integrationTest"), update gradle to 8.11
}
}.tag("latest")
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
rootProject.name = "hivemq-dns-cluster-discovery"

if (file("../hivemq-prometheus-extension").exists()) {
includeBuild("../hivemq-prometheus-extension")
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.api.io.TempDir;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testcontainers.hivemq.HiveMQContainer;
import org.testcontainers.images.builder.Transferable;
import org.testcontainers.utility.MountableFile;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -61,24 +59,21 @@ class DnsDiscoveryExtensionIT {
private @NotNull HiveMQContainer node1;

@BeforeEach
void setUp(final @NotNull @TempDir Path extensionTempPath) throws Exception {
void setUp() throws Exception {
testDnsServer = new TestDnsServer(Set.of(DNS_DISCOVERY_ADDRESS), 4);
testDnsServer.start();

final Path dnsConfigFile = extensionTempPath.resolve("dnsdiscovery.properties");
Files.writeString(dnsConfigFile,
final String config =
"dnsServerAddress=host.docker.internal:" + testDnsServer.localAddress().getPort() + '\n' + //
"discoveryAddress=" + DNS_DISCOVERY_ADDRESS + '\n' + //
"resolutionTimeout=30\n" + //
"reloadInterval=60");
"reloadInterval=60";

node1 = new HiveMQContainer(OciImages.getImageName("hivemq/hivemq4")) //
node1 = new HiveMQContainer(OciImages.getImageName("hivemq/extensions/hivemq-dns-cluster-discovery")
.asCompatibleSubstituteFor("hivemq/hivemq4")) //
.withHiveMQConfig(MountableFile.forClasspathResource("config.xml"))
.withExtension(MountableFile.forClasspathResource("hivemq-dns-cluster-discovery"))
.withFileInExtensionHomeFolder(MountableFile.forHostPath(dnsConfigFile),
"hivemq-dns-cluster-discovery",
"dnsdiscovery.properties")
.withExtension(MountableFile.forClasspathResource("hivemq-prometheus-extension"))
.withCopyToContainer(Transferable.of(config),
"/opt/hivemq/extensions/hivemq-dns-cluster-discovery/dnsdiscovery.properties")
.withExposedPorts(9399)
.withExtraHost("host.docker.internal", "host-gateway");
}
Expand Down
202 changes: 0 additions & 202 deletions src/integrationTest/resources/hivemq-prometheus-extension/LICENSE.txt

This file was deleted.

Loading

0 comments on commit 825e1be

Please sign in to comment.