Skip to content

Commit

Permalink
Merge pull request #317 from majguo/main
Browse files Browse the repository at this point in the history
Prepare for the next release
  • Loading branch information
majguo authored Dec 26, 2024
2 parents ff93915 + 4cbd90b commit f0aef91
Show file tree
Hide file tree
Showing 23 changed files with 237 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .github/create-azure-resources.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -Euo pipefail
set -Eeuo pipefail

# The following environment variables need to be configured before running the script
# - RESOURCE_GROUP_NAME
Expand Down
34 changes: 19 additions & 15 deletions .github/run-integration-test.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -Euo pipefail
set -Eeuo pipefail

# The following environment variables need to be configured before running the script
# - RESOURCE_GROUP_NAME
Expand Down Expand Up @@ -36,11 +36,11 @@ AZURE_STORAGE_BLOB_CONNECTION_STRING=$(az storage account show-connection-string
--name "${STORAGE_ACCOUNT_NAME}" \
--query connectionString -o tsv)
# Run integration test with existing native executables against Azure services
mvn -f azure-storage-blob/pom.xml -B test-compile failsafe:integration-test -Dnative -Dazure.test=true -Dquarkus.azure.storage.blob.endpoint=${AZURE_STORAGE_BLOB_ENDPOINT}
mvn -f azure-storage-blob/pom.xml -B test-compile failsafe:integration-test -Dnative -Dazure.test=true -Dquarkus.azure.storage.blob.connection-string=${AZURE_STORAGE_BLOB_CONNECTION_STRING}
mvn -f azure-storage-blob/pom.xml test-compile failsafe:integration-test -Dnative -Dazure.test=true -Dquarkus.azure.storage.blob.endpoint=${AZURE_STORAGE_BLOB_ENDPOINT}
mvn -f azure-storage-blob/pom.xml test-compile failsafe:integration-test -Dnative -Dazure.test=true -Dquarkus.azure.storage.blob.connection-string=${AZURE_STORAGE_BLOB_CONNECTION_STRING}
# Run both unit test and integration test in JVM mode against Azure services
mvn -f azure-storage-blob/pom.xml -B verify -Dazure.test=true -Dquarkus.azure.storage.blob.endpoint=${AZURE_STORAGE_BLOB_ENDPOINT}
mvn -f azure-storage-blob/pom.xml -B verify -Dazure.test=true -Dquarkus.azure.storage.blob.connection-string=${AZURE_STORAGE_BLOB_CONNECTION_STRING}
mvn -f azure-storage-blob/pom.xml verify -Dazure.test=true -Dquarkus.azure.storage.blob.endpoint=${AZURE_STORAGE_BLOB_ENDPOINT}
mvn -f azure-storage-blob/pom.xml verify -Dazure.test=true -Dquarkus.azure.storage.blob.connection-string=${AZURE_STORAGE_BLOB_CONNECTION_STRING}

# Azure App Configuration Extension
export QUARKUS_AZURE_APP_CONFIGURATION_ENDPOINT=$(az appconfig show \
Expand All @@ -53,16 +53,16 @@ credential=$(az appconfig credential list \
| jq 'map(select(.readOnly == true)) | .[0]')
export QUARKUS_AZURE_APP_CONFIGURATION_ID=$(echo "${credential}" | jq -r '.id')
export QUARKUS_AZURE_APP_CONFIGURATION_SECRET=$(echo "${credential}" | jq -r '.value')
mvn -f azure-app-configuration/pom.xml -B test-compile failsafe:integration-test -Dnative -Dazure.test=true
mvn -f azure-app-configuration/pom.xml -B verify -Dazure.test=true
mvn -f azure-app-configuration/pom.xml test-compile failsafe:integration-test -Dnative -Dazure.test=true
mvn -f azure-app-configuration/pom.xml verify -Dazure.test=true

# Azure Key Vault Extension
export QUARKUS_AZURE_KEYVAULT_SECRET_ENDPOINT=$(az keyvault show --name "${KEY_VAULT_NAME}" \
--resource-group "${RESOURCE_GROUP_NAME}" \
--query properties.vaultUri\
--output tsv)
mvn -f azure-keyvault/pom.xml -B test-compile failsafe:integration-test -Dnative -Dazure.test=true
mvn -f azure-keyvault/pom.xml -B verify -Dazure.test=true
mvn -f azure-keyvault/pom.xml test-compile failsafe:integration-test -Dnative -Dazure.test=true
mvn -f azure-keyvault/pom.xml verify -Dazure.test=true

# Azure Cosmos Extension
# Authenticate to Azure Cosmos DB with Microsoft Entra ID and key
Expand Down Expand Up @@ -94,10 +94,10 @@ AZURE_COSMOS_KEY=$(az cosmosdb keys list \
-n ${COSMOSDB_ACCOUNT_NAME} \
-g ${RESOURCE_GROUP_NAME} \
--query primaryMasterKey -o tsv)
mvn -f azure-cosmos/pom.xml -B test-compile failsafe:integration-test -Dnative -Dazure.test=true
mvn -f azure-cosmos/pom.xml -B test-compile failsafe:integration-test -Dnative -Dazure.test=true -Dquarkus.azure.cosmos.key=${AZURE_COSMOS_KEY}
mvn -f azure-cosmos/pom.xml -B verify -Dazure.test=true
mvn -f azure-cosmos/pom.xml -B verify -Dazure.test=true -Dquarkus.azure.cosmos.key=${AZURE_COSMOS_KEY}
mvn -f azure-cosmos/pom.xml test-compile failsafe:integration-test -Dnative -Dazure.test=true
mvn -f azure-cosmos/pom.xml test-compile failsafe:integration-test -Dnative -Dazure.test=true -Dquarkus.azure.cosmos.key=${AZURE_COSMOS_KEY}
mvn -f azure-cosmos/pom.xml verify -Dazure.test=true
mvn -f azure-cosmos/pom.xml verify -Dazure.test=true -Dquarkus.azure.cosmos.key=${AZURE_COSMOS_KEY}

# Azure Event Hubs Extension
# Retrieve the event hub resource ID
Expand All @@ -114,5 +114,9 @@ az role assignment create \
--scope $EVENTHUBS_EVENTHUB_RESOURCE_ID
export QUARKUS_AZURE_EVENTHUBS_NAMESPACE=${EVENTHUBS_NAMESPACE}
export QUARKUS_AZURE_EVENTHUBS_EVENTHUB_NAME=${EVENTHUBS_EVENTHUB_NAME}
mvn -f azure-eventhubs/pom.xml -B test-compile failsafe:integration-test -Dnative -Dazure.test=true
mvn -f azure-eventhubs/pom.xml -B verify -Dazure.test=true
mvn -f azure-eventhubs/pom.xml test-compile failsafe:integration-test -Dnative -Dazure.test=true
mvn -f azure-eventhubs/pom.xml verify -Dazure.test=true

# Test azure-services-disabled
mvn -f azure-services-disabled/pom.xml test-compile failsafe:integration-test -Dnative -Dazure.test=true
mvn -f azure-services-disabled/pom.xml verify -Dazure.test=true
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Integration Test
name: Build

on:
push:
Expand Down
1 change: 1 addition & 0 deletions docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
* xref:quarkus-azure-app-configuration.adoc[Quarkus Azure App Configuration Extension]
* xref:quarkus-azure-cosmos.adoc[Quarkus Azure Cosmos DB Extension]
* xref:quarkus-azure-eventhubs.adoc[Quarkus Azure Event Hubs Extension]
* xref:quarkus-azure-key-vault.adoc[Quarkus Azure Key Vault Extension]
* xref:quarkus-azure-storage-blob.adoc[Quarkus Azure Blob Storage Extension]
4 changes: 2 additions & 2 deletions docs/modules/ROOT/pages/includes/quarkus-azure-eventhubs.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Environment variable: `+++QUARKUS_AZURE_EVENTHUBS_NAMESPACE+++`
endif::add-copy-button-to-env-var[]
--
|string
|required icon:exclamation-circle[title=Configuration property is required]
|

a| [[quarkus-azure-eventhubs_quarkus-azure-eventhubs-domain-name]] [.property-path]##link:#quarkus-azure-eventhubs_quarkus-azure-eventhubs-domain-name[`quarkus.azure.eventhubs.domain-name`]##

Expand Down Expand Up @@ -73,7 +73,7 @@ Environment variable: `+++QUARKUS_AZURE_EVENTHUBS_EVENTHUB_NAME+++`
endif::add-copy-button-to-env-var[]
--
|string
|required icon:exclamation-circle[title=Configuration property is required]
|

|===

Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Environment variable: `+++QUARKUS_AZURE_EVENTHUBS_NAMESPACE+++`
endif::add-copy-button-to-env-var[]
--
|string
|required icon:exclamation-circle[title=Configuration property is required]
|

a| [[quarkus-azure-eventhubs_quarkus-azure-eventhubs-domain-name]] [.property-path]##link:#quarkus-azure-eventhubs_quarkus-azure-eventhubs-domain-name[`quarkus.azure.eventhubs.domain-name`]##

Expand Down Expand Up @@ -73,7 +73,7 @@ Environment variable: `+++QUARKUS_AZURE_EVENTHUBS_EVENTHUB_NAME+++`
endif::add-copy-button-to-env-var[]
--
|string
|required icon:exclamation-circle[title=Configuration property is required]
|

|===

6 changes: 3 additions & 3 deletions docs/modules/ROOT/pages/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ include::quarkus-azure-app-configuration.adoc[leveloffset=+1, opts=optional]

include::quarkus-azure-cosmos.adoc[leveloffset=+1, opts=optional]

include::quarkus-azure-key-vault.adoc[leveloffset=+1, opts=optional]
include::quarkus-azure-eventhubs.adoc[leveloffset=+1, opts=optional]

include::quarkus-azure-storage-blob.adoc[leveloffset=+1, opts=optional]
include::quarkus-azure-key-vault.adoc[leveloffset=+1, opts=optional]

include::quarkus-azure-eventhubs.adoc[leveloffset=+1, opts=optional]
include::quarkus-azure-storage-blob.adoc[leveloffset=+1, opts=optional]
12 changes: 12 additions & 0 deletions docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkiverse.azureservices</groupId>
<artifactId>quarkus-azure-eventhubs-deployment</artifactId>
<version>${project.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkiverse.azureservices</groupId>
<artifactId>quarkus-azure-keyvault-deployment</artifactId>
Expand Down
4 changes: 0 additions & 4 deletions extensions/azure-eventhubs/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
<description>Interacts with Azure Event Hubs through the Azure SDK for Java</description>

<dependencies>
<dependency>
<groupId>io.quarkiverse.azureservices</groupId>
<artifactId>quarkus-azure-eventhubs</artifactId>
</dependency>
<dependency>
<groupId>io.quarkiverse.azureservices</groupId>
<artifactId>quarkus-azure-http-client-vertx-deployment</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
import jakarta.enterprise.inject.Produces;
import jakarta.inject.Inject;

import com.azure.core.util.ClientOptions;
import com.azure.identity.DefaultAzureCredentialBuilder;
import com.azure.messaging.eventhubs.EventHubClientBuilder;
import com.azure.messaging.eventhubs.EventHubConsumerAsyncClient;
import com.azure.messaging.eventhubs.EventHubConsumerClient;
import com.azure.messaging.eventhubs.EventHubProducerAsyncClient;
import com.azure.messaging.eventhubs.EventHubProducerClient;

import io.quarkiverse.azure.core.util.AzureQuarkusIdentifier;

public class EventhubsClientProducer {

@Inject
Expand Down Expand Up @@ -68,12 +71,15 @@ private EventHubClientBuilder getBuilder() {
return null;
}

EventHubClientBuilder builder = new EventHubClientBuilder()
.credential(eventhubsConfig.namespace()
assert eventhubsConfig.namespace().isPresent() : "The namespace of Azure Event Hubs must be set";
assert eventhubsConfig.domainName().isPresent() : "The domain name of Azure Event Hubs must be set";
assert eventhubsConfig.eventhubName().isPresent() : "The event hub name of Azure Event Hubs must be set";
return new EventHubClientBuilder()
.clientOptions(new ClientOptions().setApplicationId(AzureQuarkusIdentifier.AZURE_QUARKUS_EVENTHUBS))
.credential(eventhubsConfig.namespace().get()
+ "."
+ eventhubsConfig.domainName(),
eventhubsConfig.eventhubName(),
+ eventhubsConfig.domainName().get(),
eventhubsConfig.eventhubName().get(),
new DefaultAzureCredentialBuilder().build());
return builder;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.quarkiverse.azure.eventhubs.runtime;

import java.util.Optional;

import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.smallrye.config.ConfigMapping;
Expand All @@ -18,16 +20,16 @@ public interface EventhubsConfig {
/**
* The namespace of the event hub. Required if quarkus.azure.eventhubs.enabled is set to true
*/
String namespace();
Optional<String> namespace();

/**
* The domain name of the event hub. Required if quarkus.azure.eventhubs.enabled is set to true
*/
@WithDefault("servicebus.windows.net")
String domainName();
Optional<String> domainName();

/**
* The name of the event hub. Required if quarkus.azure.eventhubs.enabled is set to true
*/
String eventhubName();
Optional<String> eventhubName();
}
36 changes: 36 additions & 0 deletions integration-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,42 @@ az cosmosdb sql container create \
-p "/id"
```

### Creating Azure Event Hubs resources

Run the following commands to create an Azure eventhub namespace and an eventhub within the namespace, and export the environment variables to be used in the sample application.

```
EVENTHUBS_NAMESPACE=<unique-eventhub-namespace-name>
EVENTHUBS_EVENTHUB_NAME=<unique-eventhub-name>
# Azure Event Hubs Extension
az eventhubs namespace create \
--name ${EVENTHUBS_NAMESPACE} \
--resource-group ${RESOURCE_GROUP_NAME}
az eventhubs eventhub create \
--name ${EVENTHUBS_EVENTHUB_NAME} \
--namespace-name ${EVENTHUBS_NAMESPACE} \
--resource-group ${RESOURCE_GROUP_NAME} \
--partition-count 2
export QUARKUS_AZURE_EVENTHUBS_NAMESPACE=${EVENTHUBS_NAMESPACE}
export QUARKUS_AZURE_EVENTHUBS_EVENTHUB_NAME=${EVENTHUBS_EVENTHUB_NAME}
```

Assign the `Azure Event Hubs Data Owner` role to the signed-in user as a Microsoft Entra identity, so that the sample application can do data plane operations.

```
EVENTHUBS_EVENTHUB_RESOURCE_ID=$(az eventhubs eventhub show \
--resource-group $RESOURCE_GROUP_NAME \
--namespace-name $EVENTHUBS_NAMESPACE \
--name $EVENTHUBS_EVENTHUB_NAME \
--query 'id' \
--output tsv)
az role assignment create \
--role "Azure Event Hubs Data Owner" \
--assignee $(az ad signed-in-user show --query 'id' --output tsv) \
--scope $EVENTHUBS_EVENTHUB_RESOURCE_ID
```

### Running the test

Finally, build the native executable and launch the test with:
Expand Down
6 changes: 0 additions & 6 deletions integration-tests/azure-cosmos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,6 @@ curl http://localhost:8080/quarkus-azure-cosmos/demodb/democontainer -X GET
# Delete the item from Azure Cosmos DB database demodb and container democontainer.
curl http://localhost:8080/quarkus-azure-cosmos/demodb/democontainer/1 -X DELETE
# Read the deleted item from Azure Cosmos DB database demodb and container democontainer. You should see HTTP status code 500 in the response.
curl http://localhost:8080/quarkus-azure-cosmos/demodb/democontainer/1 -X DELETE -w "%{http_code}" -s -o /dev/null
# List items again from Azure Cosmos DB database demodb and container democontainer. You should see [] in the response.
curl http://localhost:8080/quarkus-azure-cosmos/demodb/democontainer -X GET
Expand All @@ -223,9 +220,6 @@ curl http://localhost:8080/quarkus-azure-cosmos-async/demodb/democontainer -X GE
# Delete the item from Azure Cosmos DB database demodb and container democontainer using the async API.
curl http://localhost:8080/quarkus-azure-cosmos-async/demodb/democontainer/1 -X DELETE
# Read the deleted item from Azure Cosmos DB database demodb and container democontainer using the async API. You should see HTTP status code 500 in the response.
curl http://localhost:8080/quarkus-azure-cosmos-async/demodb/democontainer/1 -X DELETE -w "%{http_code}" -s -o /dev/null
# List items again from Azure Cosmos DB database demodb and container democontainer using the async API. You should see [] in the response.
curl http://localhost:8080/quarkus-azure-cosmos-async/demodb/democontainer -X GET
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public Uni<Response> createItem(
@Context UriInfo uriInfo) {

Mono<CosmosItemResponse<Item>> response = getContainer(database, container, true)
.upsertItem(body);
.flatMap(cosmosAsyncContainer -> cosmosAsyncContainer.upsertItem(body));
return Uni.createFrom().completionStage(response.toFuture())
.map(it -> Response.created(uriInfo.getAbsolutePathBuilder().path(body.getId()).build()).build());
}
Expand All @@ -46,7 +46,7 @@ public Uni<Response> getItem(
@PathParam("container") String container,
@PathParam("itemId") String itemId) {
Mono<CosmosItemResponse<Item>> item = getContainer(database, container, false)
.readItem(itemId, new PartitionKey(itemId), Item.class);
.flatMap(cosmosAsyncContainer -> cosmosAsyncContainer.readItem(itemId, new PartitionKey(itemId), Item.class));
return Uni.createFrom().completionStage(item.toFuture())
.map(it -> Response.ok().entity(it.getItem()).build());

Expand All @@ -59,8 +59,8 @@ public Uni<Response> deleteItem(
@PathParam("container") String container,
@PathParam("itemId") String itemId) {
Mono<CosmosItemResponse<Object>> response = getContainer(database, container, false)
.deleteItem(itemId, new PartitionKey(itemId),
new CosmosItemRequestOptions());
.flatMap(cosmosAsyncContainer -> cosmosAsyncContainer.deleteItem(itemId, new PartitionKey(itemId),
new CosmosItemRequestOptions()));
return Uni.createFrom().completionStage(response.toFuture())
.map(it -> Response.noContent().build());
}
Expand All @@ -72,19 +72,21 @@ public Multi<Item> getItems(
@PathParam("database") String database,
@PathParam("container") String container) {
Flux<Item> items = getContainer(database, container, false)
.queryItems("SELECT * FROM Item", new CosmosQueryRequestOptions(), Item.class)
.byPage(10)
.map(FeedResponse::getResults)
.flatMapIterable(it -> it);
.map(cosmosAsyncContainer -> cosmosAsyncContainer
.queryItems("SELECT * FROM Item", new CosmosQueryRequestOptions(), Item.class)
.byPage(10)
.map(FeedResponse::getResults)
.flatMapIterable(it -> it))
.flatMapMany(flux -> flux);

return Multi.createFrom().emitter(emitter -> {
items.subscribe(emitter::emit, emitter::fail, emitter::complete);
});
}

private CosmosAsyncContainer getContainer(String database, String container, boolean createIfNotExists) {
private Mono<CosmosAsyncContainer> getContainer(String database, String container, boolean createIfNotExists) {
if (!createIfNotExists) {
return cosmosAsyncClient.getDatabase(database).getContainer(container);
return Mono.just(cosmosAsyncClient.getDatabase(database).getContainer(container));
}

return cosmosAsyncClient.createDatabaseIfNotExists(database)
Expand All @@ -94,7 +96,6 @@ private CosmosAsyncContainer getContainer(String database, String container, boo
.flatMap(databaseAsync -> databaseAsync.createContainerIfNotExists(container, Item.PARTITION_KEY))
.map(CosmosContainerResponse::getProperties)
.map(CosmosContainerProperties::getId)
.map(id -> cosmosAsyncClient.getDatabase(database).getContainer(container))
.block();
.map(id -> cosmosAsyncClient.getDatabase(database).getContainer(container));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@ void azureCosmosAsync() {
.then()
.statusCode(204);

given()
.when()
.get("/quarkus-azure-cosmos-async/" + database + "/" + container + "/1")
.then()
.statusCode(500);

given()
.when()
.get("/quarkus-azure-cosmos-async/" + database + "/" + container)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,6 @@ void azureCosmos() {
.then()
.statusCode(204);

given()
.when()
.get("/quarkus-azure-cosmos/" + database + "/" + container + "/1")
.then()
.statusCode(500);

given()
.when()
.get("/quarkus-azure-cosmos/" + database + "/" + container)
Expand Down
Loading

0 comments on commit f0aef91

Please sign in to comment.