This is an automated email from the ASF dual-hosted git repository.
apupier pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 9c87fadb59c2 CAMEL-27276: camel-azure-cosmosdb - Fix flaky
CosmosDbContainerOperationsIT
9c87fadb59c2 is described below
commit 9c87fadb59c289d69c04f4cfc2c76fb56defb584
Author: Aurélien Pupier <[email protected]>
AuthorDate: Fri Nov 20 09:09:40 2026 +0100
CAMEL-27276: camel-azure-cosmosdb - Fix flaky CosmosDbContainerOperationsIT
testCreateItems and testUpsertItems called blockFirst() on the Flux
returned by createItems()/upsertItems(). These Fluxes write the items
concurrently (flatMap), and blockFirst() returns as soon as the first
response arrives and cancels the subscription, so the write of the
remaining item could be cancelled before completing. The following
read then found 1 item instead of 2:
org.opentest4j.AssertionFailedError: expected: <2> but was: <1>
at
CosmosDbContainerOperationsIT.testCreateItems(CosmosDbContainerOperationsIT.java:163)
Wait for all the responses with collectList().block() instead.
Reproduced locally against the Floci AZ container on a machine loaded
with 44 busy-loop processes on 22 cores, running each test method 20
times:
- before the fix: testCreateItems failed 7/20, testUpsertItems 2/20
- after the fix: both passed 20/20
The main code is not changed: callers that subscribe normally are not
affected by the cancellation. The other blockFirst() usages in the
module are read-only queries expecting a single result and are not
impacted.
Co-authored-by: IBM Bob 2.2.1
Signed-off-by: Aurélien Pupier <[email protected]>
---
.../integration/operations/CosmosDbContainerOperationsIT.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git
a/components/camel-azure/camel-azure-cosmosdb/src/test/java/org/apache/camel/component/azure/cosmosdb/integration/operations/CosmosDbContainerOperationsIT.java
b/components/camel-azure/camel-azure-cosmosdb/src/test/java/org/apache/camel/component/azure/cosmosdb/integration/operations/CosmosDbContainerOperationsIT.java
index 075a4cd62b52..772ae7993614 100644
---
a/components/camel-azure/camel-azure-cosmosdb/src/test/java/org/apache/camel/component/azure/cosmosdb/integration/operations/CosmosDbContainerOperationsIT.java
+++
b/components/camel-azure/camel-azure-cosmosdb/src/test/java/org/apache/camel/component/azure/cosmosdb/integration/operations/CosmosDbContainerOperationsIT.java
@@ -159,7 +159,8 @@ class CosmosDbContainerOperationsIT {
items.add(item2);
// create items
- containerOperations.createItems(items, new PartitionKey("test-1"),
null).blockFirst();
+ // wait for all items, blockFirst() would cancel the creation of the
remaining ones
+ containerOperations.createItems(items, new PartitionKey("test-1"),
null).collectList().block();
assertEquals(2, readAllItems("test-1").count().block());
}
@@ -214,7 +215,8 @@ class CosmosDbContainerOperationsIT {
items.add(item2);
// create items
- containerOperations.upsertItems(items, new PartitionKey("test-1"),
null).blockFirst();
+ // wait for all items, blockFirst() would cancel the upsert of the
remaining ones
+ containerOperations.upsertItems(items, new PartitionKey("test-1"),
null).collectList().block();
assertEquals(2, readAllItems("test-1").count().block());
}