Skip to content

Commit b697907

Browse files
authored
[event hubs][test] add workaround to ensure initial partition state (Azure#21850)
This is to work around a service issue when receiving messages from start position of -1. Similar to PR Azure#20982
1 parent 06dfbe1 commit b697907

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

sdk/eventhub/event-hubs/test/internal/eventProcessor.spec.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { delay } from "@azure/core-amqp";
3737
import { isLatestPosition } from "../../src/eventPosition";
3838
import { loggerForTest } from "../public/utils/logHelpers";
3939
import { testWithServiceTypes } from "../public/utils/testWithServiceTypes";
40+
import { v4 } from "uuid";
4041

4142
const should = chai.should();
4243
chai.use(chaiAsPromised);
@@ -699,6 +700,12 @@ testWithServiceTypes((serviceVersion) => {
699700
// ensure we have at least 2 partitions
700701
partitionIds.length.should.gte(2);
701702

703+
// work around initial state issue by filling partitions with at least one message
704+
for (let i = 1; i < 100; i++) {
705+
const filer = { body: "b", messageId: v4() };
706+
await producerClient.sendBatch([filer]);
707+
}
708+
702709
const { subscriptionEventHandler, startPosition } =
703710
await SubscriptionHandlerForTests.startingFromHere(producerClient);
704711

@@ -713,8 +720,6 @@ testWithServiceTypes((serviceVersion) => {
713720
}
714721
);
715722

716-
processor.start();
717-
processor.start();
718723
processor.start();
719724

720725
const expectedMessages = await sendOneMessagePerPartition(partitionIds, producerClient);

0 commit comments

Comments
 (0)