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 e5b74f58f0 Add azure-storage-datalake native support e5b74f58f0 is described below commit e5b74f58f0f9faeb9a65fb25a001b832b254429c Author: JiriOndrusek <ondrusek.j...@gmail.com> AuthorDate: Mon Jun 16 12:25:08 2025 +0200 Add azure-storage-datalake native support --- .../examples/components/azure-storage-datalake.yml | 6 +- .../extensions/azure-storage-datalake.adoc | 21 ++++-- .../deployment/AzureStorageDatalakeProcessor.java | 46 ------------ extensions-jvm/pom.xml | 1 - .../azure-storage-datalake/deployment/pom.xml | 0 .../deployment/AzureStorageDatalakeProcessor.java | 85 ++++++++++++++++++++++ .../azure-storage-datalake/pom.xml | 2 +- .../azure-storage-datalake/runtime/pom.xml | 1 + .../runtime/src/main/doc/usage.adoc | 0 .../main/resources/META-INF/quarkus-extension.yaml | 3 +- extensions/pom.xml | 1 + .../azure/azure-storage-datalake/README.adoc | 24 ++++++ .../azure}/azure-storage-datalake/pom.xml | 29 +++++++- .../datalake/it/AzureStorageDatalakeResource.java | 13 ++-- .../datalake/it/AzureStorageDatalakeIT.java | 24 ++++++ .../datalake/it/AzureStorageDatalakeTest.java | 23 ++++-- .../it/AzureStorageDatalakeTestProfile.java | 41 +++++++++++ .../it/AzureStorageDatalakeTestResource.java | 53 ++++++++++++++ .../datalake/it/AzureStorageDatalakeUtil.java | 39 ++++++++++ integration-test-groups/azure/pom.xml | 1 + .../src/main/resources/application.properties | 26 ------- integration-tests-jvm/pom.xml | 1 - .../support/azure/AzureStorageTestResource.java | 4 +- integration-tests/azure-grouped/pom.xml | 17 +++++ 24 files changed, 360 insertions(+), 101 deletions(-) diff --git a/docs/modules/ROOT/examples/components/azure-storage-datalake.yml b/docs/modules/ROOT/examples/components/azure-storage-datalake.yml index 3f3b7e17f6..b90daa4274 100644 --- a/docs/modules/ROOT/examples/components/azure-storage-datalake.yml +++ b/docs/modules/ROOT/examples/components/azure-storage-datalake.yml @@ -2,11 +2,11 @@ # This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page cqArtifactId: camel-quarkus-azure-storage-datalake cqArtifactIdBase: azure-storage-datalake -cqNativeSupported: false -cqStatus: Preview +cqNativeSupported: true +cqStatus: Stable cqDeprecated: false cqJvmSince: 1.8.0 -cqNativeSince: n/a +cqNativeSince: 3.24.0 cqCamelPartName: azure-storage-datalake cqCamelPartTitle: Azure Storage Data Lake Service cqCamelPartDescription: Sends and receives files to/from Azure Data Lake Storage. diff --git a/docs/modules/ROOT/pages/reference/extensions/azure-storage-datalake.adoc b/docs/modules/ROOT/pages/reference/extensions/azure-storage-datalake.adoc index 7d612c28ea..9bcc09d4bd 100644 --- a/docs/modules/ROOT/pages/reference/extensions/azure-storage-datalake.adoc +++ b/docs/modules/ROOT/pages/reference/extensions/azure-storage-datalake.adoc @@ -4,17 +4,17 @@ = Azure storage datalake service :linkattrs: :cq-artifact-id: camel-quarkus-azure-storage-datalake -:cq-native-supported: false -:cq-status: Preview -:cq-status-deprecation: Preview +:cq-native-supported: true +:cq-status: Stable +:cq-status-deprecation: Stable :cq-description: Camel Azure Datalake Gen2 Component :cq-deprecated: false :cq-jvm-since: 1.8.0 -:cq-native-since: n/a +:cq-native-since: 3.24.0 ifeval::[{doc-show-badges} == true] [.badges] -[.badge-key]##JVM since##[.badge-supported]##1.8.0## [.badge-key]##Native##[.badge-unsupported]##unsupported## +[.badge-key]##JVM since##[.badge-supported]##1.8.0## [.badge-key]##Native since##[.badge-supported]##3.24.0## endif::[] Camel Azure Datalake Gen2 Component @@ -29,6 +29,10 @@ Please refer to the above link for usage and configuration details. [id="extensions-azure-storage-datalake-maven-coordinates"] == Maven coordinates +https://{link-quarkus-code-generator}/?extension-search=camel-quarkus-azure-storage-datalake[Create a new project with this extension on {link-quarkus-code-generator}, window="_blank"] + +Or add the coordinates to your existing project: + [source,xml] ---- <dependency> @@ -56,3 +60,10 @@ that they are available via the Quarkus metrics HTTP endpoint. </dependency> ---- + +[id="extensions-azure-storage-datalake-ssl-in-native-mode"] +== SSL in native mode + +This extension auto-enables SSL support in native mode. Hence you do not need to add +`quarkus.ssl.native=true` to your `application.properties` yourself. See also +https://quarkus.io/guides/native-and-ssl[Quarkus SSL guide]. diff --git a/extensions-jvm/azure-storage-datalake/deployment/src/main/java/org/apache/camel/quarkus/component/azure/storage/datalake/deployment/AzureStorageDatalakeProcessor.java b/extensions-jvm/azure-storage-datalake/deployment/src/main/java/org/apache/camel/quarkus/component/azure/storage/datalake/deployment/AzureStorageDatalakeProcessor.java deleted file mode 100644 index dc96415374..0000000000 --- a/extensions-jvm/azure-storage-datalake/deployment/src/main/java/org/apache/camel/quarkus/component/azure/storage/datalake/deployment/AzureStorageDatalakeProcessor.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.quarkus.component.azure.storage.datalake.deployment; - -import io.quarkus.deployment.annotations.BuildStep; -import io.quarkus.deployment.annotations.ExecutionTime; -import io.quarkus.deployment.annotations.Record; -import io.quarkus.deployment.builditem.FeatureBuildItem; -import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild; -import org.apache.camel.quarkus.core.JvmOnlyRecorder; -import org.jboss.logging.Logger; - -class AzureStorageDatalakeProcessor { - - private static final Logger LOG = Logger.getLogger(AzureStorageDatalakeProcessor.class); - private static final String FEATURE = "camel-azure-storage-datalake"; - - @BuildStep - FeatureBuildItem feature() { - return new FeatureBuildItem(FEATURE); - } - - /** - * Remove this once this extension starts supporting the native mode. - */ - @BuildStep(onlyIf = NativeOrNativeSourcesBuild.class) - @Record(value = ExecutionTime.RUNTIME_INIT) - void warnJvmInNative(JvmOnlyRecorder recorder) { - JvmOnlyRecorder.warnJvmInNative(LOG, FEATURE); // warn at build time - recorder.warnJvmInNative(FEATURE); // warn at runtime - } -} diff --git a/extensions-jvm/pom.xml b/extensions-jvm/pom.xml index 2c78edef2a..fc2f8cea19 100644 --- a/extensions-jvm/pom.xml +++ b/extensions-jvm/pom.xml @@ -40,7 +40,6 @@ <module>aws-xray</module> <module>azure-cosmosdb</module> <module>azure-files</module> - <module>azure-storage-datalake</module> <module>barcode</module> <module>bonita</module> <module>chatscript</module> diff --git a/extensions-jvm/azure-storage-datalake/deployment/pom.xml b/extensions/azure-storage-datalake/deployment/pom.xml similarity index 100% rename from extensions-jvm/azure-storage-datalake/deployment/pom.xml rename to extensions/azure-storage-datalake/deployment/pom.xml diff --git a/extensions/azure-storage-datalake/deployment/src/main/java/org/apache/camel/quarkus/component/azure/storage/datalake/deployment/AzureStorageDatalakeProcessor.java b/extensions/azure-storage-datalake/deployment/src/main/java/org/apache/camel/quarkus/component/azure/storage/datalake/deployment/AzureStorageDatalakeProcessor.java new file mode 100644 index 0000000000..1bc96b0117 --- /dev/null +++ b/extensions/azure-storage-datalake/deployment/src/main/java/org/apache/camel/quarkus/component/azure/storage/datalake/deployment/AzureStorageDatalakeProcessor.java @@ -0,0 +1,85 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.quarkus.component.azure.storage.datalake.deployment; + +import java.util.LinkedList; +import java.util.List; +import java.util.stream.Collectors; + +import com.azure.core.annotation.ServiceInterface; +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.CombinedIndexBuildItem; +import io.quarkus.deployment.builditem.ExtensionSslNativeSupportBuildItem; +import io.quarkus.deployment.builditem.FeatureBuildItem; +import io.quarkus.deployment.builditem.IndexDependencyBuildItem; +import io.quarkus.deployment.builditem.nativeimage.NativeImageProxyDefinitionBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; +import org.jboss.jandex.DotName; +import org.jboss.jandex.IndexView; +import org.jboss.logging.Logger; + +class AzureStorageDatalakeProcessor { + + private static final Logger LOG = Logger.getLogger(AzureStorageDatalakeProcessor.class); + private static final String FEATURE = "camel-azure-storage-datalake"; + + private static final DotName SERVICE_INSTANCE_ANNOTATION = DotName.createSimple(ServiceInterface.class.getName()); + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } + + @BuildStep + ExtensionSslNativeSupportBuildItem activateSslNativeSupport() { + return new ExtensionSslNativeSupportBuildItem(FEATURE); + } + + @BuildStep + ReflectiveClassBuildItem registerForReflection(CombinedIndexBuildItem combinedIndex) { + IndexView index = combinedIndex.getIndex(); + + List<String> dtos = new LinkedList<>(index.getKnownClasses().stream() + .map(ci -> ci.name().toString()) + .filter(n -> n.startsWith("com.azure.storage.file.datalake.implementation.models")) + .collect(Collectors.toList())); + + dtos.add("com.azure.storage.file.datalake.implementation.ServicesImpl$ServicesService"); + + return ReflectiveClassBuildItem.builder(dtos.toArray(String[]::new)).methods().fields().build(); + } + + @BuildStep + void registerBeanHandlersForReflection(BuildProducer<NativeImageProxyDefinitionBuildItem> proxiesProducer, + BuildProducer<ReflectiveClassBuildItem> reflectiveProdicer, + CombinedIndexBuildItem combinedIndex) { + IndexView index = combinedIndex.getIndex(); + + index.getAnnotations(SERVICE_INSTANCE_ANNOTATION).stream() + .map(annotationInstance -> annotationInstance.target().asClass().name().toString()) + .forEach(ci -> { + proxiesProducer.produce(new NativeImageProxyDefinitionBuildItem(ci)); + }); + } + + @BuildStep + IndexDependencyBuildItem registerDependencyForIndex() { + return new IndexDependencyBuildItem("com.azure", "azure-storage-file-datalake"); + } + +} diff --git a/extensions-jvm/azure-storage-datalake/pom.xml b/extensions/azure-storage-datalake/pom.xml similarity index 96% rename from extensions-jvm/azure-storage-datalake/pom.xml rename to extensions/azure-storage-datalake/pom.xml index b94cb8451d..beedc62f09 100644 --- a/extensions-jvm/azure-storage-datalake/pom.xml +++ b/extensions/azure-storage-datalake/pom.xml @@ -21,7 +21,7 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-extensions-jvm</artifactId> + <artifactId>camel-quarkus-extensions</artifactId> <version>3.24.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> diff --git a/extensions-jvm/azure-storage-datalake/runtime/pom.xml b/extensions/azure-storage-datalake/runtime/pom.xml similarity index 97% rename from extensions-jvm/azure-storage-datalake/runtime/pom.xml rename to extensions/azure-storage-datalake/runtime/pom.xml index e007de30db..438bd7f9ad 100644 --- a/extensions-jvm/azure-storage-datalake/runtime/pom.xml +++ b/extensions/azure-storage-datalake/runtime/pom.xml @@ -32,6 +32,7 @@ <properties> <camel.quarkus.jvmSince>1.8.0</camel.quarkus.jvmSince> + <camel.quarkus.nativeSince>3.24.0</camel.quarkus.nativeSince> </properties> <dependencies> diff --git a/extensions-jvm/azure-storage-datalake/runtime/src/main/doc/usage.adoc b/extensions/azure-storage-datalake/runtime/src/main/doc/usage.adoc similarity index 100% rename from extensions-jvm/azure-storage-datalake/runtime/src/main/doc/usage.adoc rename to extensions/azure-storage-datalake/runtime/src/main/doc/usage.adoc diff --git a/extensions-jvm/azure-storage-datalake/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/extensions/azure-storage-datalake/runtime/src/main/resources/META-INF/quarkus-extension.yaml similarity index 97% rename from extensions-jvm/azure-storage-datalake/runtime/src/main/resources/META-INF/quarkus-extension.yaml rename to extensions/azure-storage-datalake/runtime/src/main/resources/META-INF/quarkus-extension.yaml index 3667317c63..c32c8e8065 100644 --- a/extensions-jvm/azure-storage-datalake/runtime/src/main/resources/META-INF/quarkus-extension.yaml +++ b/extensions/azure-storage-datalake/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -26,9 +26,8 @@ description: "Camel Azure Datalake Gen2 Component" metadata: icon-url: "https://raw.githubusercontent.com/apache/camel-website/main/antora-ui-camel/src/img/logo-d.svg" sponsor: "Apache Software Foundation" - unlisted: true guide: "https://camel.apache.org/camel-quarkus/latest/reference/extensions/azure-storage-datalake.html" categories: - "integration" status: - - "preview" + - "stable" diff --git a/extensions/pom.xml b/extensions/pom.xml index b7057fafbd..408c225b19 100644 --- a/extensions/pom.xml +++ b/extensions/pom.xml @@ -67,6 +67,7 @@ <module>azure-key-vault</module> <module>azure-servicebus</module> <module>azure-storage-blob</module> + <module>azure-storage-datalake</module> <module>azure-storage-queue</module> <module>base64</module> <module>bean</module> diff --git a/integration-test-groups/azure/azure-storage-datalake/README.adoc b/integration-test-groups/azure/azure-storage-datalake/README.adoc new file mode 100644 index 0000000000..e20e1a785b --- /dev/null +++ b/integration-test-groups/azure/azure-storage-datalake/README.adoc @@ -0,0 +1,24 @@ +There is no test container (nor Azurite), which supportd azure-storage-datalake. + + +=== Real Azure API + +To run the tests against the real Azure API, you need to + +* Export Your credentials (azure account key and account name) + +[source,shell] +---- +export AZURE_STORAGE_ACCOUNT_KEY=<your-account-key> +export AZURE_STORAGE_ACCOUNT_NAME=<your-acount-name> +---- + +In case your need to use separate storage account to run storage tests and to run storage datalake tests: + +Export Your credentials for *datalake* via specific variables + +[source,shell] +---- +export AZURE_STORAGE_DATALAKE_ACCOUNT_KEY=<your-account-key> +export AZURE_STORAGE_DATALAKE_ACCOUNT_NAME=<your-acount-name> +---- \ No newline at end of file diff --git a/integration-tests-jvm/azure-storage-datalake/pom.xml b/integration-test-groups/azure/azure-storage-datalake/pom.xml similarity index 78% rename from integration-tests-jvm/azure-storage-datalake/pom.xml rename to integration-test-groups/azure/azure-storage-datalake/pom.xml index 70a128f6d3..691116ea99 100644 --- a/integration-tests-jvm/azure-storage-datalake/pom.xml +++ b/integration-test-groups/azure/azure-storage-datalake/pom.xml @@ -23,7 +23,7 @@ <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-build-parent-it</artifactId> <version>3.24.0-SNAPSHOT</version> - <relativePath>../../poms/build-parent-it/pom.xml</relativePath> + <relativePath>../../../poms/build-parent-it/pom.xml</relativePath> </parent> <artifactId>camel-quarkus-integration-test-azure-storage-datalake</artifactId> @@ -87,5 +87,32 @@ </dependency> </dependencies> </profile> + <profile> + <id>native</id> + <activation> + <property> + <name>native</name> + </property> + </activation> + <properties> + <quarkus.native.enabled>true</quarkus.native.enabled> + </properties> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-failsafe-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>integration-test</goal> + <goal>verify</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> </profiles> </project> diff --git a/integration-tests-jvm/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 similarity index 96% rename from integration-tests-jvm/azure-storage-datalake/src/main/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeResource.java rename to integration-test-groups/azure/azure-storage-datalake/src/main/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeResource.java index d6701e5c4a..699a1dd25a 100644 --- a/integration-tests-jvm/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 @@ -18,6 +18,7 @@ package org.apache.camel.quarkus.component.azure.storage.datalake.it; import java.net.URI; import java.util.List; +import java.util.Optional; import java.util.stream.Collectors; import com.azure.core.http.policy.HttpLogDetailLevel; @@ -56,21 +57,21 @@ public class AzureStorageDatalakeResource { ConsumerTemplate consumerTemplate; @ConfigProperty(name = "azure.storage.account-name") - String azureStorageAccountName; + Optional<String> azureStorageAccountName; @ConfigProperty(name = "azure.storage.account-key") - String azureStorageAccountKey; + Optional<String> azureStorageAccountKey; @ConfigProperty(name = "azure.datalake.service.url") - String serviceUrl; + Optional<String> serviceUrl; @jakarta.enterprise.inject.Produces @Named("azureDatalakeServiceClient") public DataLakeServiceClient createDatalakeServiceClient() throws Exception { - StorageSharedKeyCredential credentials = new StorageSharedKeyCredential(azureStorageAccountName, - azureStorageAccountKey); + StorageSharedKeyCredential credentials = new StorageSharedKeyCredential(azureStorageAccountName.get(), + azureStorageAccountKey.get()); return new DataLakeServiceClientBuilder() - .endpoint(serviceUrl) + .endpoint(serviceUrl.get()) .credential(credentials) .httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS).setPrettyPrintBody(true)) .buildClient(); 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 new file mode 100644 index 0000000000..2372735b01 --- /dev/null +++ b/integration-test-groups/azure/azure-storage-datalake/src/test/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeIT.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * 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 io.quarkus.test.junit.QuarkusIntegrationTest; + +@QuarkusIntegrationTest +class AzureStorageDatalakeIT extends AzureStorageDatalakeTest { + +} diff --git a/integration-tests-jvm/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 similarity index 85% rename from integration-tests-jvm/azure-storage-datalake/src/test/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeTest.java rename to integration-test-groups/azure/azure-storage-datalake/src/test/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeTest.java index f14d45196a..9bf9b0c66f 100644 --- a/integration-tests-jvm/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 @@ -18,23 +18,33 @@ package org.apache.camel.quarkus.component.azure.storage.datalake.it; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.TestProfile; import io.restassured.RestAssured; -import org.apache.camel.quarkus.test.support.azure.AzureStorageTestResource; import org.apache.commons.lang3.RandomStringUtils; import org.hamcrest.Matchers; import org.jboss.logging.Logger; +import org.junit.jupiter.api.Assumptions; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable; -// Datalake not supported by Azurite https://github.com/Azure/Azurite/issues/553 -@EnabledIfEnvironmentVariable(named = "AZURE_STORAGE_ACCOUNT_NAME", matches = ".+") -@EnabledIfEnvironmentVariable(named = "AZURE_STORAGE_ACCOUNT_KEY", matches = ".+") +//Disable tests dynamically in beforeEach method, to reflect preferred env name in case they are used (see README.adoc) @QuarkusTest -@QuarkusTestResource(AzureStorageTestResource.class) +@QuarkusTestResource(AzureStorageDatalakeTestResource.class) +@TestProfile(AzureStorageDatalakeTestProfile.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 = "cqfs" + RandomStringUtils.randomNumeric(16); @@ -112,5 +122,4 @@ class AzureStorageDatalakeTest { } } - } 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/AzureStorageDatalakeTestProfile.java new file mode 100644 index 0000000000..17b98662d3 --- /dev/null +++ b/integration-test-groups/azure/azure-storage-datalake/src/test/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeTestProfile.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * 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; + +import io.quarkus.test.junit.QuarkusTestProfile; + +/** + * Test profile is required, as values azure.storage.account-name and azure.storage.account-key can be based on + * different env properties. + */ +public class AzureStorageDatalakeTestProfile implements QuarkusTestProfile { + @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(); + } +} diff --git a/integration-test-groups/azure/azure-storage-datalake/src/test/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeTestResource.java b/integration-test-groups/azure/azure-storage-datalake/src/test/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeTestResource.java new file mode 100644 index 0000000000..27a09589b0 --- /dev/null +++ b/integration-test-groups/azure/azure-storage-datalake/src/test/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeTestResource.java @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * 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.Map; + +import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; +import org.apache.camel.quarkus.test.mock.backend.MockBackendUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class AzureStorageDatalakeTestResource implements QuarkusTestResourceLifecycleManager { + private static final Logger LOGGER = LoggerFactory.getLogger(AzureStorageDatalakeTestResource.class); + + @Override + public Map<String, String> start() { + String realAzureStorageAccountName = AzureStorageDatalakeUtil.getRealAccountNameFromEnv(); + String realAzureStorageAccountKey = AzureStorageDatalakeUtil.getRealAccountKeyFromEnv(); + + final boolean realCredentialsProvided = realAzureStorageAccountName != null && realAzureStorageAccountKey != null; + + if (!realCredentialsProvided) { + LOGGER.warn("Set AZURE_STORAGE_ACCOUNT_NAME and AZURE_STORAGE_ACCOUNT_KEY " + + "or AZURE_STORAGE_DATALAKE_ACCOUNT_NAME and AZURE_STORAGE_DATALAKE_ACCOUNT_KEY env vars."); + } else { + MockBackendUtils.logRealBackendUsed(); + } + + return Map.of( + "azure.datalake.service.url", + "https://" + realAzureStorageAccountName + ".dfs.core.windows.net"); + } + + @Override + public void stop() { + //nothing + } +} diff --git a/integration-test-groups/azure/azure-storage-datalake/src/test/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeUtil.java b/integration-test-groups/azure/azure-storage-datalake/src/test/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeUtil.java new file mode 100644 index 0000000000..87b42308a5 --- /dev/null +++ b/integration-test-groups/azure/azure-storage-datalake/src/test/java/org/apache/camel/quarkus/component/azure/storage/datalake/it/AzureStorageDatalakeUtil.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * 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.Optional; + +public class AzureStorageDatalakeUtil { + + public static String getRealAccountNameFromEnv() { + return Optional.ofNullable(System.getenv("AZURE_STORAGE_DATALAKE_ACCOUNT_NAME")) + .orElseGet(() -> System.getenv("AZURE_STORAGE_ACCOUNT_NAME")); + } + + public static String getRealAccountKeyFromEnv() { + return Optional.ofNullable(System.getenv("AZURE_STORAGE_DATALAKE_ACCOUNT_KEY")) + .orElseGet(() -> System.getenv("AZURE_STORAGE_ACCOUNT_KEY")); + } + + public static boolean isRalAccountProvided() { + String realAzureStorageAccountName = AzureStorageDatalakeUtil.getRealAccountNameFromEnv(); + String realAzureStorageAccountKey = AzureStorageDatalakeUtil.getRealAccountKeyFromEnv(); + + return realAzureStorageAccountName != null && realAzureStorageAccountKey != null; + } +} diff --git a/integration-test-groups/azure/pom.xml b/integration-test-groups/azure/pom.xml index 79c933526c..6dbabc81b2 100644 --- a/integration-test-groups/azure/pom.xml +++ b/integration-test-groups/azure/pom.xml @@ -41,6 +41,7 @@ <module>azure-key-vault</module> <module>azure-servicebus</module> <module>azure-storage-blob</module> + <module>azure-storage-datalake</module> <module>azure-storage-queue</module> </modules> diff --git a/integration-tests-jvm/azure-storage-datalake/src/main/resources/application.properties b/integration-tests-jvm/azure-storage-datalake/src/main/resources/application.properties deleted file mode 100644 index b51fdf839b..0000000000 --- a/integration-tests-jvm/azure-storage-datalake/src/main/resources/application.properties +++ /dev/null @@ -1,26 +0,0 @@ -## --------------------------------------------------------------------------- -## Licensed to the Apache Software Foundation (ASF) under one or more -## contributor license agreements. See the NOTICE file distributed with -## this work for additional information regarding copyright ownership. -## The ASF licenses this file to You under the Apache License, Version 2.0 -## (the "License"); you may not use this file except in compliance with -## the License. You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, software -## distributed under the License is distributed on an "AS IS" BASIS, -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -## See the License for the specific language governing permissions and -## limitations under the License. -## --------------------------------------------------------------------------- -# - - -# Azurite test account credentials although Data Lake is not supported -# by Azurite yet https://github.com/Azure/Azurite/issues/553 -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}} diff --git a/integration-tests-jvm/pom.xml b/integration-tests-jvm/pom.xml index 572d389362..7e79f5b987 100644 --- a/integration-tests-jvm/pom.xml +++ b/integration-tests-jvm/pom.xml @@ -38,7 +38,6 @@ <module>aws-xray</module> <module>azure-cosmosdb</module> <module>azure-files</module> - <module>azure-storage-datalake</module> <module>barcode</module> <module>bonita</module> <module>chatscript</module> 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 d8dfb51d57..3ece34b2c5 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 @@ -52,8 +52,8 @@ public class AzureStorageTestResource implements QuarkusTestResourceLifecycleMan public enum AzuriteService { blob(10000), - queue(10001), - datalake(-1, "dfs"); // Datalake not supported by Azurite https://github.com/Azure/Azurite/issues/553 + queue(10001); + // datalake(-1, "dfs"); // Datalake not supported by Azurite https://github.com/Azure/Azurite/issues/553 private final int azuritePort; private final String azureServiceCode; diff --git a/integration-tests/azure-grouped/pom.xml b/integration-tests/azure-grouped/pom.xml index d13ced7f72..ecb4596d0a 100644 --- a/integration-tests/azure-grouped/pom.xml +++ b/integration-tests/azure-grouped/pom.xml @@ -64,6 +64,10 @@ <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-azure-storage-blob</artifactId> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-azure-storage-datalake</artifactId> + </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-azure-storage-queue</artifactId> @@ -228,6 +232,19 @@ </exclusion> </exclusions> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-azure-storage-datalake-deployment</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> + </dependency> <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-azure-storage-queue-deployment</artifactId>