Skip to content

Commit 881779d

Browse files
committed
Improve AzureDiscoveryExtensionIT
1 parent d9640c0 commit 881779d

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

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

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.testcontainers.utility.MountableFile;
3232

3333
import java.io.ByteArrayInputStream;
34-
import java.util.concurrent.TimeoutException;
3534
import java.util.stream.Collectors;
3635

3736
import static java.util.concurrent.TimeUnit.SECONDS;
@@ -51,7 +50,18 @@ class AzureDiscoveryExtensionIT {
5150
new GenericContainer<>(OciImages.getImageName("azure-storage/azurite")) //
5251
.withExposedPorts(AZURITE_PORT) //
5352
.withNetwork(network) //
54-
.withNetworkAliases(AZURITE_NETWORK_ALIAS);
53+
.withNetworkAliases(AZURITE_NETWORK_ALIAS) //
54+
.withLogConsumer(outputFrame -> System.out.printf("[AZURITE] %s", outputFrame.getUtf8String())) //
55+
.withCommand("azurite",
56+
// listen on all network interfaces within the container
57+
"--blobHost",
58+
"0.0.0.0",
59+
"--queueHost",
60+
"0.0.0.0",
61+
"--tableHost",
62+
"0.0.0.0",
63+
// prevent test failure when azure-storage-blob is updated before azurite supports its new API version
64+
"--skipApiVersionCheck");
5565

5666
@BeforeEach
5767
void setUp() {
@@ -65,7 +75,7 @@ void tearDown() {
6575
}
6676

6777
@Test
68-
void threeNodesFormCluster() throws TimeoutException {
78+
void threeNodesFormCluster() throws Exception {
6979
final var consumer1 = new WaitingConsumer();
7080
final var consumer2 = new WaitingConsumer();
7181
final var consumer3 = new WaitingConsumer();
@@ -86,7 +96,7 @@ void threeNodesFormCluster() throws TimeoutException {
8696
}
8797

8898
@Test
89-
void twoNodesInCluster_oneNodeStarted_threeNodesInCluster() throws TimeoutException {
99+
void twoNodesInCluster_oneNodeStarted_threeNodesInCluster() throws Exception {
90100
final var consumer1 = new WaitingConsumer();
91101
final var consumer2 = new WaitingConsumer();
92102
final var consumer3 = new WaitingConsumer();
@@ -106,7 +116,7 @@ void twoNodesInCluster_oneNodeStarted_threeNodesInCluster() throws TimeoutExcept
106116
}
107117

108118
@Test
109-
void twoNodesInCluster_oneNodeCannotReachAzure_nodeFileDeleted() throws TimeoutException {
119+
void twoNodesInCluster_oneNodeCannotReachAzure_nodeFileDeleted() throws Exception {
110120
final var toxiproxy = new ToxiproxyContainer(OciImages.getImageName("shopify/toxiproxy")) //
111121
.withNetwork(network).withNetworkAliases(TOXIPROXY_NETWORK_ALIAS);
112122
try (toxiproxy) {
@@ -142,7 +152,7 @@ void twoNodesInCluster_oneNodeCannotReachAzure_nodeFileDeleted() throws TimeoutE
142152
}
143153

144154
@Test
145-
void threeNodesInCluster_oneNodeStopped_twoNodesInCluster() throws TimeoutException {
155+
void threeNodesInCluster_oneNodeStopped_twoNodesInCluster() throws Exception {
146156
final var consumer1 = new WaitingConsumer();
147157
final var consumer2 = new WaitingConsumer();
148158
final var consumer3 = new WaitingConsumer();
@@ -174,15 +184,11 @@ void threeNodesInCluster_oneNodeStopped_twoNodesInCluster() throws TimeoutExcept
174184

175185
@Test
176186
@SuppressWarnings("HttpUrlsUsage")
177-
void wrongConnectionString_reloadRightConnectionString_clusterCreated() throws TimeoutException {
178-
final var wrongConnectionString = "DefaultEndpointsProtocol=http;" +
187+
void wrongConnectionString_reloadRightConnectionString_clusterCreated() throws Exception {
188+
final var wrongConnectionString = String.format("DefaultEndpointsProtocol=http;" +
179189
"AccountName=devstoreaccount1;" +
180190
"AccountKey=XXX8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;" +
181-
"BlobEndpoint=http://" +
182-
AZURITE_NETWORK_ALIAS +
183-
":" +
184-
AZURITE_PORT +
185-
"/devstoreaccount1";
191+
"BlobEndpoint=http://%s:%d/devstoreaccount1", AZURITE_NETWORK_ALIAS, AZURITE_PORT);
186192

187193
final var consumer = new WaitingConsumer();
188194

@@ -235,33 +241,24 @@ void containerExisting_nodeStarted_containerUsed() {
235241
}
236242
}
237243

238-
@SuppressWarnings("HttpUrlsUsage")
239-
private @NotNull String createAzuriteConnectionString(final @NotNull String host, final int port) {
240-
return "DefaultEndpointsProtocol=http;" +
241-
//
242-
"AccountName=devstoreaccount1;" +
243-
"AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;" +
244-
"BlobEndpoint=http://" +
245-
host +
246-
":" +
247-
port +
248-
"/devstoreaccount1";
244+
private @NotNull String createHostAzuriteConnectionString() {
245+
return createAzuriteConnectionString("127.0.0.1", azuriteContainer.getMappedPort(AZURITE_PORT));
249246
}
250247

251248
private @NotNull String createDockerAzuriteConnectionString() {
252249
return createAzuriteConnectionString(AZURITE_NETWORK_ALIAS, AZURITE_PORT);
253250
}
254251

255-
private @NotNull String createConfig(final @NotNull String connectionString) {
256-
return "connection-string=" + connectionString + '\n' + //
257-
"container-name=" + BLOB_CONTAINER_NAME + '\n' + //
258-
"file-prefix=hivemq-node-\n" + //
259-
"file-expiration=15\n" + //
260-
"update-interval=5";
252+
@SuppressWarnings("HttpUrlsUsage")
253+
private @NotNull String createAzuriteConnectionString(final @NotNull String host, final int port) {
254+
return String.format("DefaultEndpointsProtocol=http;" +
255+
"AccountName=devstoreaccount1;" +
256+
"AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;" +
257+
"BlobEndpoint=http://%s:%s/devstoreaccount1", host, port);
261258
}
262259

263-
private @NotNull String createHostAzuriteConnectionString() {
264-
return createAzuriteConnectionString("127.0.0.1", azuriteContainer.getMappedPort(AZURITE_PORT));
260+
private @NotNull HiveMQContainer createHiveMQNode() {
261+
return createHiveMQNode(createDockerAzuriteConnectionString());
265262
}
266263

267264
private @NotNull HiveMQContainer createHiveMQNode(final @NotNull String connectionString) {
@@ -273,7 +270,10 @@ void containerExisting_nodeStarted_containerUsed() {
273270
.withNetwork(network);
274271
}
275272

276-
private @NotNull HiveMQContainer createHiveMQNode() {
277-
return createHiveMQNode(createDockerAzuriteConnectionString());
273+
private @NotNull String createConfig(final @NotNull String connectionString) {
274+
return String.format(
275+
"connection-string=%s\ncontainer-name=%s\nfile-prefix=hivemq-node-\nfile-expiration=15\nupdate-interval=5",
276+
connectionString,
277+
BLOB_CONTAINER_NAME);
278278
}
279279
}

0 commit comments

Comments
 (0)