Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run Azure tests grouped on the CI thus saving some time #2477

Merged
merged 3 commits into from
Apr 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/reference/extensions/core.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ What to do if it is not possible to extract CSimple expressions from a route def

|icon:lock[title=Fixed at build time] [[quarkus.camel.main.enabled]]`link:#quarkus.camel.main.enabled[quarkus.camel.main.enabled]`

If `true` all `camel-main` features are enabled; otherwise no `camel-main` features are enabled. See described the xref:user-guide/configuration.adoc#_camel_main[Bootstrap] section of Camel Quarkus documentation for more details.
If `true` all `camel-main` features are enabled; otherwise no `camel-main` features are enabled. See described the xref:user-guide/configuration.adoc#_camel_main[Configuration] section of Camel Quarkus documentation for more details.
| `boolean`
| `true`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class CamelMainConfig {
/**
* If {@code true} all {@code camel-main} features are enabled; otherwise no {@code camel-main} features are
* enabled. See described the
* <a href="https://camel.apache.org/camel-quarkus/latest/user-guide/bootstrap.html#_camel_main">Bootstrap</a>
* <a href="https://camel.apache.org/camel-quarkus/latest/user-guide/configuration.html#_camel_main">Configuration</a>
* section of Camel Quarkus documentation for more details.
*/
@ConfigItem(defaultValue = "true")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-build-parent-it</artifactId>
<artifactId>camel-quarkus-integration-test-groups</artifactId>
<version>1.9.0-SNAPSHOT</version>
<relativePath>../poms/build-parent-it/pom.xml</relativePath>
</parent>

<artifactId>camel-quarkus-integration-tests-aws2</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
== Azure Event Hubs Service integration tests
== Azure isolated integration tests

By default the integration tests run only against the real remote Azure API.
=== Azurite

By default the integration tests are run against the Azurite test container,
or skipped, if the given service is not supported by Azurite.

Unsupported by Azurite:

* `azure-eventhubs`

=== Real Azure API

Prerequisites:

* A https://docs.microsoft.com/en-us/azure/storage/common/storage-account-create?toc=%2Fazure%2Fstorage%2Fblobs%2Ftoc.json&tabs=azure-portal[general-purpose v2 Azure storage account] and
https://docs.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-portal[create a container]
* View the https://docs.microsoft.com/en-us/azure/storage/common/storage-account-keys-manage?tabs=azure-portal#view-account-access-keys[account keys] and set the following environment variables:
* An https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-create[Azure Event Hub]
* An https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-get-connection-string[Event Hubs connection string]

Expand All @@ -26,7 +36,7 @@ Here are the environment variables you need to set:
export AZURE_STORAGE_ACCOUNT_NAME=<your-azure-storage-account-name>
export AZURE_STORAGE_ACCOUNT_KEY=<your-azure-storage-account-key>
# the container has to exist before you run the test
export AZURE_BLOB_CONTAINER_NAME=<your-container-name>
export AZURE_EVENT_HUBS_BLOB_CONTAINER_NAME=<your-container-name>
export AZURE_EVENT_HUBS_CONNECTION_STRING="Endpoint=sb://<your-namespace>.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=<your-key>;EntityPath=<your-hub-name>"
----

Expand All @@ -37,3 +47,6 @@ To clean up, run
$ ./azure-resources.sh delete
----

You may want to `export CAMEL_QUARKUS_START_MOCK_BACKEND=false` to avoid starting the local Azurite container and make sure that you test against the real remote Azure API.


Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-tests</artifactId>
<artifactId>camel-quarkus-integration-tests-azure</artifactId>
<version>1.9.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.net.URI;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

import javax.enterprise.context.ApplicationScoped;
Expand Down Expand Up @@ -51,17 +52,8 @@ public class AzureEventhubsResource {
@Inject
CamelContext context;

@ConfigProperty(name = "azure.storage.account-name")
String azureStorageAccountName;

@ConfigProperty(name = "azure.storage.account-key")
String azureStorageAccountKey;

@ConfigProperty(name = "azure.event.hubs.connection.string")
String connectionString;

@ConfigProperty(name = "azure.blob.container.name")
String azureBlobContainerName;
Optional<String> connectionString;

private volatile String message;
private int counter = 0;
Expand All @@ -73,7 +65,7 @@ public class AzureEventhubsResource {
@Scheduled(every = "1s")
void schedule() {
if (message != null) {
final String endpointUri = "azure-eventhubs:?connectionString=RAW(" + connectionString + ")";
final String endpointUri = "azure-eventhubs:?connectionString=RAW(" + connectionString.get() + ")";
producerTemplate.sendBody(endpointUri, message + (counter++));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.apache.camel.quarkus.component.azure.eventhubs.it;

import java.util.Optional;

import javax.enterprise.context.ApplicationScoped;

import com.azure.core.amqp.AmqpTransportType;
Expand All @@ -32,20 +34,27 @@ public class AzureEventhubsRoutes extends RouteBuilder {
String azureStorageAccountKey;

@ConfigProperty(name = "azure.event.hubs.connection.string")
String connectionString;
Optional<String> connectionString;

@ConfigProperty(name = "azure.event.hubs.blob.container.name")
Optional<String> azureBlobContainerName;

@ConfigProperty(name = "azure.blob.container.name")
String azureBlobContainerName;
@ConfigProperty(name = "camel.quarkus.start.mock.backend", defaultValue = "true")
boolean startMockBackend;

@Override
public void configure() throws Exception {
from("azure-eventhubs:?connectionString=RAW(" + connectionString
+ ")&blobAccountName=RAW(" + azureStorageAccountName
+ ")&blobAccessKey=RAW(" + azureStorageAccountKey
+ ")&blobContainerName=RAW(" + azureBlobContainerName + ")&amqpTransportType="
+ AmqpTransportType.AMQP)
.to("mock:azure-consumed");

if (connectionString.isPresent() && azureBlobContainerName.isPresent()) {
from("azure-eventhubs:?connectionString=RAW(" + connectionString.get()
+ ")&blobAccountName=RAW(" + azureStorageAccountName
+ ")&blobAccessKey=RAW(" + azureStorageAccountKey
+ ")&blobContainerName=RAW(" + azureBlobContainerName.get() + ")&amqpTransportType="
+ AmqpTransportType.AMQP)
.to("mock:azure-consumed");
} else if (!startMockBackend) {
throw new IllegalStateException(
"azure.event.hubs.connection.string and azure.event.hubs.blob.container.name must be set when camel.quarkus.start.mock.backend == false");
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


suffix="$(az ad signed-in-user show --query displayName -o tsv | tr '[:upper:]' '[:lower:]' | tr -cd '[:alnum:]' | cut -c-12)"
suffix="${suffix}1"
suffix="${suffix}4"
export AZURE_STORAGE_ACCOUNT_NAME=cqacc${suffix}
export AZURE_BLOB_CONTAINER_NAME=cq-container-${suffix}

Expand Down Expand Up @@ -54,7 +54,7 @@ function createResources() {

echo 'export AZURE_STORAGE_ACCOUNT_NAME="'${AZURE_STORAGE_ACCOUNT_NAME}'"'
echo 'export AZURE_STORAGE_ACCOUNT_KEY="'${AZURE_STORAGE_ACCOUNT_KEY}'"'
echo 'export AZURE_BLOB_CONTAINER_NAME="'${AZURE_BLOB_CONTAINER_NAME}'"'
echo 'export AZURE_EVENT_HUBS_BLOB_CONTAINER_NAME="'${AZURE_BLOB_CONTAINER_NAME}'"'
echo 'export AZURE_EVENT_HUBS_CONNECTION_STRING="'$AZURE_EVENT_HUBS_CONNECTION_STRING';EntityPath='${EH_NAME}'"'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-tests</artifactId>
<artifactId>camel-quarkus-integration-tests-azure</artifactId>
<version>1.9.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>camel-quarkus-integration-test-azure-storage-blob</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-tests</artifactId>
<artifactId>camel-quarkus-integration-tests-azure</artifactId>
<version>1.9.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>camel-quarkus-integration-test-azure-storage-queue</artifactId>
Expand Down
45 changes: 45 additions & 0 deletions integration-test-groups/azure/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

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.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-test-groups</artifactId>
<version>1.9.0-SNAPSHOT</version>
</parent>

<artifactId>camel-quarkus-integration-tests-azure</artifactId>
<packaging>pom</packaging>

<name>Camel Quarkus :: Azure Integration Tests</name>

<properties>
<quarkus.banner.enabled>false</quarkus.banner.enabled>
</properties>

<modules>
<!-- extensions a..z; do not remove this comment, it is important when sorting via mvn process-resources -Pformat -->
<module>azure-eventhubs</module>
<module>azure-storage-blob</module>
<module>azure-storage-queue</module>
</modules>

</project>
41 changes: 41 additions & 0 deletions integration-test-groups/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

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.

-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-build-parent-it</artifactId>
<version>1.9.0-SNAPSHOT</version>
<relativePath>../poms/build-parent-it/pom.xml</relativePath>
</parent>

<artifactId>camel-quarkus-integration-test-groups</artifactId>
<packaging>pom</packaging>

<name>Camel Quarkus :: Integration Test Groups</name>

<modules>
<!-- test groups a..z; do not remove this comment, it is important when sorting via mvn process-resources -Pformat -->
<module>aws2</module>
<module>azure</module>
</modules>

</project>
8 changes: 4 additions & 4 deletions integration-tests/aws2-grouped/README.adoc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
== AWS 2 grouped integration tests

This module allows executing all tests from `integration-tests-aws2/*` grouped together.
This module allows executing all tests from `integration-test-groups/aws2/*` grouped together.

While grouping brings the benefit of faster native compilation
(compared to the sum of compilation times of all modules under `integration-tests-aws2/*`)
(compared to the sum of compilation times of all modules under `integration-test-groups/aws2/*`)
it is methodologically not as clean as running those tests in isolation.
Hence, this module is intended to be run instead of the tests under `integration-tests-aws2/*`
Hence, this module is intended to be run instead of the tests under `integration-test-groups/aws2/*`
if, in the given situation, the speed matters more than isolation.

=== How the grouping works
Expand All @@ -17,4 +17,4 @@ if, in the given situation, the speed matters more than isolation.

=== Mock backend vs. real service

Please refer to link:../../integration-tests-aws2/README.adoc[integration-tests-aws2/README.adoc] for more details.
Please refer to link:../../integration-test-groups/aws2/README.adoc[integration-test-groups/aws2/README.adoc] for more details.
4 changes: 2 additions & 2 deletions integration-tests/aws2-grouped/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<artifactId>camel-quarkus-integration-test-aws2-grouped</artifactId>
<name>Camel Quarkus :: Integration Tests :: AWS2 Grouped</name>
<description>AWS 2 tests from ../integration-tests-aws2 merged together</description>
<description>AWS 2 tests from ../integration-test-groups/aws2 merged together</description>

<dependencyManagement>
<dependencies>
Expand Down Expand Up @@ -270,7 +270,7 @@
<configuration>
<source>file:///${maven.multiModuleProjectDirectory}/tooling/scripts/group-tests.groovy</source>
<properties>
<group-tests.source.dir>${maven.multiModuleProjectDirectory}/integration-tests-aws2</group-tests.source.dir>
<group-tests.source.dir>${maven.multiModuleProjectDirectory}/integration-test-groups/aws2</group-tests.source.dir>
<group-tests.dest.module.dir>${project.basedir}</group-tests.dest.module.dir>
<group-tests.concat.rel.paths>src/main/resources/application.properties,src/test/resources/META-INF/services/org.apache.camel.quarkus.test.support.aws2.Aws2TestEnvCustomizer</group-tests.concat.rel.paths>
</properties>
Expand Down
20 changes: 20 additions & 0 deletions integration-tests/azure-grouped/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
== Azure grouped integration tests

This module allows executing all tests from `integration-test-groups/azure/*` grouped together.

While grouping brings the benefit of faster native compilation
(compared to the sum of compilation times of all modules under `integration-test-groups/azure/*`)
it is methodologically not as clean as running those tests in isolation.
Hence, this module is intended to be run instead of the tests under `integration-test-groups/azure/*`
if, in the given situation, the speed matters more than isolation.

=== How the grouping works

* The grouped module dynamically pulls all sources from the individual AWS test modules to its
* `target/[test-]classes` directories.
* `application.properties` files and service descriptors are concatenated using a Groovy script.
* The dependencies in the grouped `pom.xml` can be updated via `mvn process-resources -Pformat -N`.

=== Mock backend vs. real service

Please refer to link:../../integration-tests-azure/README.adoc[integration-test-groups/azure/README.adoc] for more details.