Skip to content

Commit 44d750d

Browse files
committed
Add oci image definition, use it in integration tests
1 parent 1a23338 commit 44d750d

File tree

2 files changed

+37
-21
lines changed

2 files changed

+37
-21
lines changed

build.gradle.kts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,29 @@ oci {
3939
}
4040
}
4141
}
42+
imageMapping {
43+
mapModule("com.hivemq", "hivemq-enterprise") {
44+
toImage("hivemq/hivemq4")
45+
}
46+
}
47+
imageDefinitions.register("main") {
48+
allPlatforms {
49+
dependencies {
50+
runtime("com.hivemq:hivemq-enterprise:latest") { isChanging = true }
51+
}
52+
layers {
53+
layer("hivemqExtension") {
54+
contents {
55+
permissions("opt/hivemq/", 0b111_111_000)
56+
permissions("opt/hivemq/extensions/", 0b111_111_000)
57+
into("opt/hivemq/extensions") {
58+
from(zipTree(tasks.hivemqExtensionZip.flatMap { it.archiveFile }))
59+
}
60+
}
61+
}
62+
}
63+
}
64+
}
4265
}
4366

4467
@Suppress("UnstableApiUsage")
@@ -66,7 +89,7 @@ testing {
6689
}
6790
oci.of(this) {
6891
imageDependencies {
69-
runtime("hivemq:hivemq4:latest") { isChanging = true }
92+
runtime(project).tag("latest")
7093
runtime("azure-storage:azurite:3.33.0").tag("latest")
7194
runtime("shopify:toxiproxy:2.1.0").tag("latest")
7295
}

src/integrationTest/java/com/hivemq/extensions/cluster/discovery/azure/AzureDiscoveryExtensionIT.java

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@
3434
import org.testcontainers.utility.MountableFile;
3535

3636
import java.io.ByteArrayInputStream;
37-
import java.io.IOException;
38-
import java.nio.file.Files;
39-
import java.nio.file.Path;
4037
import java.util.List;
4138
import java.util.concurrent.TimeoutException;
4239
import java.util.stream.Collectors;
@@ -74,7 +71,7 @@ void tearDown() {
7471
}
7572

7673
@Test
77-
void threeNodesFormCluster() throws IOException, TimeoutException {
74+
void threeNodesFormCluster() throws TimeoutException {
7875
final WaitingConsumer consumer1 = new WaitingConsumer();
7976
final WaitingConsumer consumer2 = new WaitingConsumer();
8077
final WaitingConsumer consumer3 = new WaitingConsumer();
@@ -95,7 +92,7 @@ void threeNodesFormCluster() throws IOException, TimeoutException {
9592
}
9693

9794
@Test
98-
void twoNodesInCluster_oneNodeStarted_threeNodesInCluster() throws IOException, TimeoutException {
95+
void twoNodesInCluster_oneNodeStarted_threeNodesInCluster() throws TimeoutException {
9996
final WaitingConsumer consumer1 = new WaitingConsumer();
10097
final WaitingConsumer consumer2 = new WaitingConsumer();
10198
final WaitingConsumer consumer3 = new WaitingConsumer();
@@ -118,7 +115,7 @@ void twoNodesInCluster_oneNodeStarted_threeNodesInCluster() throws IOException,
118115
}
119116

120117
@Test
121-
void twoNodesInCluster_oneNodeCannotReachAzure_nodeFileDeleted() throws IOException, TimeoutException {
118+
void twoNodesInCluster_oneNodeCannotReachAzure_nodeFileDeleted() throws TimeoutException {
122119
final ToxiproxyContainer toxiproxy = new ToxiproxyContainer(OciImages.getImageName("shopify/toxiproxy")) //
123120
.withNetwork(network).withNetworkAliases(TOXIPROXY_NETWORK_ALIAS);
124121
try (toxiproxy) {
@@ -153,7 +150,7 @@ void twoNodesInCluster_oneNodeCannotReachAzure_nodeFileDeleted() throws IOExcept
153150
}
154151

155152
@Test
156-
void threeNodesInCluster_oneNodeStopped_twoNodesInCluster() throws IOException, TimeoutException {
153+
void threeNodesInCluster_oneNodeStopped_twoNodesInCluster() throws TimeoutException {
157154
final WaitingConsumer consumer1 = new WaitingConsumer();
158155
final WaitingConsumer consumer2 = new WaitingConsumer();
159156
final WaitingConsumer consumer3 = new WaitingConsumer();
@@ -187,7 +184,7 @@ void threeNodesInCluster_oneNodeStopped_twoNodesInCluster() throws IOException,
187184
}
188185

189186
@Test
190-
void wrongConnectionString_reloadRightConnectionString_clusterCreated() throws IOException, TimeoutException {
187+
void wrongConnectionString_reloadRightConnectionString_clusterCreated() throws TimeoutException {
191188
final String wrongConnectionString = "DefaultEndpointsProtocol=http;" + //
192189
"AccountName=devstoreaccount1;" +
193190
"AccountKey=XXX8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;" +
@@ -211,7 +208,7 @@ void wrongConnectionString_reloadRightConnectionString_clusterCreated() throws I
211208
}
212209

213210
@Test
214-
void containerNotExisting_nodeStarted_containerCreated() throws IOException {
211+
void containerNotExisting_nodeStarted_containerCreated() {
215212
final BlobContainerClient blobContainerClient = new BlobContainerClientBuilder().connectionString(createHostAzuriteConnectionString())
216213
.containerName(BLOB_CONTAINER_NAME)
217214
.buildClient();
@@ -228,7 +225,7 @@ void containerNotExisting_nodeStarted_containerCreated() throws IOException {
228225
}
229226

230227
@Test
231-
void containerExisting_nodeStarted_containerUsed() throws IOException {
228+
void containerExisting_nodeStarted_containerUsed() {
232229
final BlobContainerClient blobContainerClient = new BlobContainerClientBuilder().connectionString(createHostAzuriteConnectionString())
233230
.containerName(BLOB_CONTAINER_NAME)
234231
.buildClient();
@@ -271,20 +268,16 @@ void containerExisting_nodeStarted_containerUsed() throws IOException {
271268
return createAzuriteConnectionString("127.0.0.1", azureriteContainer.getMappedPort(AZURITE_PORT));
272269
}
273270

274-
private @NotNull HiveMQContainer createHiveMQNode(final @NotNull String connectionString) throws IOException {
275-
276-
final Path configFile = Files.createTempDirectory("az-extension-test").resolve("azDiscovery.properties");
277-
Files.writeString(configFile, createConfig(connectionString));
278-
279-
return new HiveMQContainer(OciImages.getImageName("hivemq/hivemq4")) //
271+
private @NotNull HiveMQContainer createHiveMQNode(final @NotNull String connectionString) {
272+
return new HiveMQContainer(OciImages.getImageName("hivemq/extensions/hivemq-azure-cluster-discovery-extension")
273+
.asCompatibleSubstituteFor("hivemq/hivemq4")) //
280274
.withHiveMQConfig(MountableFile.forClasspathResource("config.xml"))
281-
.withExtension(MountableFile.forClasspathResource("hivemq-azure-cluster-discovery-extension"))
282-
.withFileInExtensionHomeFolder(MountableFile.forHostPath(configFile),
283-
"hivemq-azure-cluster-discovery-extension")
275+
.withCopyToContainer(Transferable.of(createConfig(connectionString)),
276+
"/opt/hivemq/extensions/hivemq-azure-cluster-discovery-extension/azDiscovery.properties")
284277
.withNetwork(network);
285278
}
286279

287-
private @NotNull HiveMQContainer createHiveMQNode() throws IOException {
280+
private @NotNull HiveMQContainer createHiveMQNode() {
288281
return createHiveMQNode(createDockerAzuriteConnectionString());
289282
}
290283
}

0 commit comments

Comments
 (0)