This is an automated email from the ASF dual-hosted git repository.
jamesnetherton pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new 8f9a529d83 Speed up the azure-grouped integration tests
8f9a529d83 is described below
commit 8f9a529d83fb1ac07ffee41367b5c7f32660dbdb
Author: James Netherton <[email protected]>
AuthorDate: Wed Sep 2 13:18:15 2026 +0100
Speed up the azure-grouped integration tests
Run the whole module in a single Quarkus application so that Azurite and the
Event Hubs, Service Bus and SQL Server containers start once instead of once
per application.
Co-authored-by: Claude Opus 5 <[email protected]>
---
integration-test-groups/azure/README.adoc | 14 +++++++-----
.../src/main/resources/application.properties | 3 +++
.../eventhubs/it/AzureEventhubsMockedTest.java | 7 ++----
.../datalake/it/AzureStorageDatalakeProducers.java | 12 +++++------
.../datalake/it/AzureStorageDatalakeResource.java | 10 ++++-----
.../src/main/resources/application.properties | 16 ++++----------
.../datalake/it/AzureStorageDatalakeIT.java | 2 ++
.../datalake/it/AzureStorageDatalakeTest.java | 19 +++-------------
...file.java => DatalakeCredentialsAvailable.java} | 25 +++++++---------------
.../support/azure/AzureStorageTestResource.java | 16 ++++++--------
10 files changed, 49 insertions(+), 75 deletions(-)
diff --git a/integration-test-groups/azure/README.adoc
b/integration-test-groups/azure/README.adoc
index bbf42c3053..79a55fed8d 100644
--- a/integration-test-groups/azure/README.adoc
+++ b/integration-test-groups/azure/README.adoc
@@ -1,14 +1,18 @@
== Azure isolated integration tests
-=== Azurite
+=== Test containers
-By default the integration tests are run against the Azurite test container,
-or skipped, if the given service is not supported by Azurite.
+By default the integration tests are run against local containers:
-Unsupported by Azurite:
+* `azure-storage-blob` and `azure-storage-queue` against Azurite
+* `azure-eventhubs` against the Azure Event Hubs emulator, started by
`AzureStorageTestResource` for modules
+ setting `azure.eventhubs.emulator.enabled = true` in their
`application.properties`
+* `azure-servicebus` against the Azure Service Bus emulator and the SQL Server
container it requires
+
+The following have no local emulator and are skipped unless real credentials
are exported:
-* `azure-eventhubs`
* `azure-key-vault`
+* `azure-storage-datalake` (https://github.com/Azure/Azurite/issues/553[not
supported by Azurite])
=== Real Azure API
diff --git
a/integration-test-groups/azure/azure-eventhubs/src/main/resources/application.properties
b/integration-test-groups/azure/azure-eventhubs/src/main/resources/application.properties
index 0439cc3599..31448ed693 100644
---
a/integration-test-groups/azure/azure-eventhubs/src/main/resources/application.properties
+++
b/integration-test-groups/azure/azure-eventhubs/src/main/resources/application.properties
@@ -27,3 +27,6 @@ azurite.storage.account.key =
Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq
azure.storage.account-name =
${AZURE_STORAGE_ACCOUNT_NAME:${azurite.storage.account.name}}
azure.storage.account-key =
${AZURE_STORAGE_ACCOUNT_KEY:${azurite.storage.account.key}}
+
+# Tells AzureStorageTestResource to also start the Azure Event Hubs emulator
container
+azure.eventhubs.emulator.enabled = true
diff --git
a/integration-test-groups/azure/azure-eventhubs/src/test/java/org/apache/camel/quarkus/component/azure/eventhubs/it/AzureEventhubsMockedTest.java
b/integration-test-groups/azure/azure-eventhubs/src/test/java/org/apache/camel/quarkus/component/azure/eventhubs/it/AzureEventhubsMockedTest.java
index 534ed0ecb0..1d661acd23 100644
---
a/integration-test-groups/azure/azure-eventhubs/src/test/java/org/apache/camel/quarkus/component/azure/eventhubs/it/AzureEventhubsMockedTest.java
+++
b/integration-test-groups/azure/azure-eventhubs/src/test/java/org/apache/camel/quarkus/component/azure/eventhubs/it/AzureEventhubsMockedTest.java
@@ -19,8 +19,7 @@ package org.apache.camel.quarkus.component.azure.eventhubs.it;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
-import io.quarkus.test.common.ResourceArg;
-import io.quarkus.test.common.WithTestResource;
+import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
@@ -35,9 +34,7 @@ import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
@QuarkusTest
-@WithTestResource(value = AzureStorageTestResource.class, initArgs = {
- @ResourceArg(name = "eventHubs", value = "true")
-})
+@QuarkusTestResource(AzureStorageTestResource.class)
class AzureEventhubsMockedTest {
@EnabledIf({ MockBackendEnabled.class })
@Test
diff --git
a/integration-test-groups/azure/azure-storage-datalake/src/main/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeProducers.java
b/integration-test-groups/azure/azure-storage-datalake/src/main/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeProducers.java
index bf1a374020..5a9c36ff6c 100644
---
a/integration-test-groups/azure/azure-storage-datalake/src/main/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeProducers.java
+++
b/integration-test-groups/azure/azure-storage-datalake/src/main/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeProducers.java
@@ -34,11 +34,11 @@ import
org.eclipse.microprofile.config.inject.ConfigProperty;
@ApplicationScoped
public class AzureStorageDatalakeProducers {
- @ConfigProperty(name = "azure.storage.account-name")
- Optional<String> azureStorageAccountName;
+ @ConfigProperty(name = "azure.datalake.account-name")
+ Optional<String> azureDatalakeAccountName;
- @ConfigProperty(name = "azure.storage.account-key")
- Optional<String> azureStorageAccountKey;
+ @ConfigProperty(name = "azure.datalake.account-key")
+ Optional<String> azureDatalakeAccountKey;
@ConfigProperty(name = "azure.datalake.service.url")
Optional<String> serviceUrl;
@@ -46,8 +46,8 @@ public class AzureStorageDatalakeProducers {
@jakarta.enterprise.inject.Produces
@Named("azureDatalakeServiceClient")
public DataLakeServiceClient createDatalakeServiceClient() throws
Exception {
- StorageSharedKeyCredential credentials = new
StorageSharedKeyCredential(azureStorageAccountName.get(),
- azureStorageAccountKey.get());
+ StorageSharedKeyCredential credentials = new
StorageSharedKeyCredential(azureDatalakeAccountName.get(),
+ azureDatalakeAccountKey.get());
return new DataLakeServiceClientBuilder()
.endpoint(serviceUrl.get())
.credential(credentials)
diff --git
a/integration-test-groups/azure/azure-storage-datalake/src/main/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeResource.java
b/integration-test-groups/azure/azure-storage-datalake/src/main/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeResource.java
index 001a11f243..1ebe15ac30 100644
---
a/integration-test-groups/azure/azure-storage-datalake/src/main/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeResource.java
+++
b/integration-test-groups/azure/azure-storage-datalake/src/main/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeResource.java
@@ -59,8 +59,8 @@ public class AzureStorageDatalakeResource {
@Inject
CamelContext camelContext;
- @ConfigProperty(name = "azure.storage.account-name")
- Optional<String> azureStorageAccountName;
+ @ConfigProperty(name = "azure.datalake.account-name")
+ Optional<String> azureDatalakeAccountName;
@Path("/filesystem/{filesystem}")
@POST
@@ -149,7 +149,7 @@ public class AzureStorageDatalakeResource {
public String consumer(@PathParam("filesystem") String filesystem,
@PathParam("filename") String filename) throws Exception {
return consumerTemplate.receiveBody(
- "azure-storage-datalake://" + azureStorageAccountName + "/" +
filesystem
+ "azure-storage-datalake://" + azureDatalakeAccountName + "/" +
filesystem
+
"?serviceClient=#azureDatalakeServiceClient&fileName=" + filename,
10000, String.class);
}
@@ -170,7 +170,7 @@ public class AzureStorageDatalakeResource {
}
_headers.put("filesystemName", filesystem);
- _headers.put("accountName", azureStorageAccountName.get());
+ _headers.put("accountName", azureDatalakeAccountName.get());
Exchange exchange = producerTemplate.request(
"direct:" + routeName,
@@ -204,7 +204,7 @@ public class AzureStorageDatalakeResource {
private String componentUri(final String filesystem, final
DataLakeOperationsDefinition operation) {
return
String.format("azure-storage-datalake://%s%s?serviceClient=#azureDatalakeServiceClient&operation=%s",
- azureStorageAccountName,
+ azureDatalakeAccountName,
filesystem == null ? "" : ("/" + filesystem),
operation.name());
}
diff --git
a/integration-test-groups/azure/azure-eventhubs/src/main/resources/application.properties
b/integration-test-groups/azure/azure-storage-datalake/src/main/resources/application.properties
similarity index 59%
copy from
integration-test-groups/azure/azure-eventhubs/src/main/resources/application.properties
copy to
integration-test-groups/azure/azure-storage-datalake/src/main/resources/application.properties
index 0439cc3599..444bd31051 100644
---
a/integration-test-groups/azure/azure-eventhubs/src/main/resources/application.properties
+++
b/integration-test-groups/azure/azure-storage-datalake/src/main/resources/application.properties
@@ -15,15 +15,7 @@
## limitations under the License.
## ---------------------------------------------------------------------------
-# Disable autowiring of EventHubProducerAsyncClient as we want control of
which endpoints the custom client is used in
-camel.component.azure-eventhubs.autowired-enabled = false
-
-# Uncomment to reduce log noise from com.azure internals
-# quarkus.log.category."com.azure".level = OFF
-
-# Support for container testing
-azurite.storage.account.name = devstoreaccount1
-azurite.storage.account.key =
Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
-
-azure.storage.account-name =
${AZURE_STORAGE_ACCOUNT_NAME:${azurite.storage.account.name}}
-azure.storage.account-key =
${AZURE_STORAGE_ACCOUNT_KEY:${azurite.storage.account.key}}
+# Data Lake has its own credentials so that they do not clash with the other
azure-* tests
+# that share this application when built as part of
integration-tests/azure-grouped
+azure.datalake.account-name =
${AZURE_STORAGE_DATALAKE_ACCOUNT_NAME:${AZURE_STORAGE_ACCOUNT_NAME:}}
+azure.datalake.account-key =
${AZURE_STORAGE_DATALAKE_ACCOUNT_KEY:${AZURE_STORAGE_ACCOUNT_KEY:}}
diff --git
a/integration-test-groups/azure/azure-storage-datalake/src/test/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeIT.java
b/integration-test-groups/azure/azure-storage-datalake/src/test/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeIT.java
index 2372735b01..d29c13c444 100644
---
a/integration-test-groups/azure/azure-storage-datalake/src/test/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeIT.java
+++
b/integration-test-groups/azure/azure-storage-datalake/src/test/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeIT.java
@@ -17,8 +17,10 @@
package org.apache.camel.quarkus.component.azure.storage.datalake.it;
import io.quarkus.test.junit.QuarkusIntegrationTest;
+import org.apache.camel.quarkus.test.EnabledIf;
@QuarkusIntegrationTest
+@EnabledIf(DatalakeCredentialsAvailable.class)
class AzureStorageDatalakeIT extends AzureStorageDatalakeTest {
}
diff --git
a/integration-test-groups/azure/azure-storage-datalake/src/test/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeTest.java
b/integration-test-groups/azure/azure-storage-datalake/src/test/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeTest.java
index 445fc84926..49e56ea166 100644
---
a/integration-test-groups/azure/azure-storage-datalake/src/test/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeTest.java
+++
b/integration-test-groups/azure/azure-storage-datalake/src/test/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeTest.java
@@ -29,10 +29,10 @@ import java.util.function.Supplier;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
-import io.quarkus.test.junit.TestProfile;
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import org.apache.camel.component.azure.storage.datalake.DataLakeConstants;
+import org.apache.camel.quarkus.test.EnabledIf;
import org.apache.commons.lang3.RandomStringUtils;
import org.awaitility.Awaitility;
import org.eclipse.microprofile.config.ConfigProvider;
@@ -40,28 +40,15 @@ import org.hamcrest.Matchers;
import org.jboss.logging.Logger;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Assumptions;
-import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-//Disable tests dynamically in beforeEach method, to reflect preferred env
name in case they are used (see README.adoc)
@QuarkusTest
@QuarkusTestResource(AzureStorageDatalakeTestResource.class)
-@TestProfile(AzureStorageDatalakeTestProfile.class)
+@EnabledIf(DatalakeCredentialsAvailable.class)
class AzureStorageDatalakeTest {
private static final Logger LOG =
Logger.getLogger(AzureStorageDatalakeTest.class);
- /**
- * It is not possible to express condition, when test is disabled by using
`EnabledIfEnvironmentVariable`.
- * Condition has to be evaluated dynamicly.
- */
- @BeforeEach
- public void beforeEach() {
- Assumptions.assumeTrue(AzureStorageDatalakeUtil.isRalAccountProvided(),
- "Azure Data Lake credentials were not provided");
-
- }
-
@Test
public void crud() {
final String filesystem = "cqfscrud" +
RandomStringUtils.secure().nextNumeric(16);
@@ -310,7 +297,7 @@ class AzureStorageDatalakeTest {
.then()
.statusCode(200)
.body(Matchers.startsWith(
- "https://" +
ConfigProvider.getConfig().getValue("azure.storage.account-name",
String.class)));
+ "https://" +
ConfigProvider.getConfig().getValue("azure.datalake.account-name",
String.class)));
LOG.info("step - appendToFile");
RestAssured.given()
diff --git
a/integration-test-groups/azure/azure-storage-datalake/src/test/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeTestProfile.java
b/integration-test-groups/azure/azure-storage-datalake/src/test/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/DatalakeCredentialsAvailable.java
similarity index 50%
rename from
integration-test-groups/azure/azure-storage-datalake/src/test/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeTestProfile.java
rename to
integration-test-groups/azure/azure-storage-datalake/src/test/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/DatalakeCredentialsAvailable.java
index 17b98662d3..f9d7eee286 100644
---
a/integration-test-groups/azure/azure-storage-datalake/src/test/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeTestProfile.java
+++
b/integration-test-groups/azure/azure-storage-datalake/src/test/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/DatalakeCredentialsAvailable.java
@@ -14,28 +14,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.camel.quarkus.component.azure.storage.datalake.it;
-import java.util.Collections;
-import java.util.Map;
+package org.apache.camel.quarkus.component.azure.storage.datalake.it;
-import io.quarkus.test.junit.QuarkusTestProfile;
+import java.util.function.BooleanSupplier;
/**
- * Test profile is required, as values azure.storage.account-name and
azure.storage.account-key can be based on
- * different env properties.
+ * Azurite does not emulate Data Lake, so the tests need a real account. The
condition cannot be expressed with
+ * {@code EnabledIfEnvironmentVariable} because either the Data Lake specific
or the generic storage env vars can
+ * supply the credentials (see README.adoc).
*/
-public class AzureStorageDatalakeTestProfile implements QuarkusTestProfile {
+public class DatalakeCredentialsAvailable implements BooleanSupplier {
@Override
- public Map<String, String> getConfigOverrides() {
- String realAzureStorageAccountName =
AzureStorageDatalakeUtil.getRealAccountNameFromEnv();
- String realAzureStorageAccountKey =
AzureStorageDatalakeUtil.getRealAccountKeyFromEnv();
- if (realAzureStorageAccountKey != null && realAzureStorageAccountKey
!= null) {
- return Map.of("azure.storage.account-name",
realAzureStorageAccountName,
- "azure.storage.account-key", realAzureStorageAccountKey);
-
- }
-
- return Collections.emptyMap();
+ public boolean getAsBoolean() {
+ return AzureStorageDatalakeUtil.isRalAccountProvided();
}
}
diff --git
a/integration-tests-support/azure/src/main/java/org/apache/camel/quarkus/test/support/azure/AzureStorageTestResource.java
b/integration-tests-support/azure/src/main/java/org/apache/camel/quarkus/test/support/azure/AzureStorageTestResource.java
index 9f53d6f0f5..3ac9e5674c 100644
---
a/integration-tests-support/azure/src/main/java/org/apache/camel/quarkus/test/support/azure/AzureStorageTestResource.java
+++
b/integration-tests-support/azure/src/main/java/org/apache/camel/quarkus/test/support/azure/AzureStorageTestResource.java
@@ -43,7 +43,10 @@ public class AzureStorageTestResource implements
QuarkusTestResourceLifecycleMan
private static final String EVENTHUBS_EMULATOR_IMAGE =
ConfigProvider.getConfig()
.getValue("eventhubs-emulator.container.image", String.class);
private static final int EVENTHUBS_EMULATOR_PORT = 5672;
- private Map<String, String> initArgs = new LinkedHashMap<>();
+ /**
+ * Set to {@code true} in the {@code application.properties} of test
modules that need the Event Hubs emulator.
+ */
+ private static final String EVENTHUBS_EMULATOR_ENABLED =
"azure.eventhubs.emulator.enabled";
private GenericContainer<?> container;
private GenericContainer<?> eventHubsEmulatorContainer;
private Network network = Network.newNetwork();
@@ -82,11 +85,6 @@ public class AzureStorageTestResource implements
QuarkusTestResourceLifecycleMan
}
}
- @Override
- public void init(Map<String, String> initArgs) {
- this.initArgs = initArgs;
- }
-
@Override
public Map<String, String> start() {
final SmallRyeConfig config =
ConfigProvider.getConfig().unwrap(SmallRyeConfig.class);
@@ -123,9 +121,9 @@ public class AzureStorageTestResource implements
QuarkusTestResourceLifecycleMan
+ azureStorageAccountName);
});
- String eventHubs = initArgs.get("eventHubs");
- if (eventHubs != null && eventHubs.equals("true")) {
- result.put("azure.event.hubs.blob.container.name",
azureBlobContainername);
+ if (config.getOptionalValue(EVENTHUBS_EMULATOR_ENABLED,
Boolean.class).orElse(false)) {
+ // A dedicated container, so that the checkpoint store
does not clash with the blob tests sharing this Azurite instance
+ result.put("azure.event.hubs.blob.container.name",
"camel-quarkus-eventhubs-" + UUID.randomUUID());
eventHubsEmulatorContainer = new GenericContainer<>(
EVENTHUBS_EMULATOR_IMAGE)