Skip to content

Commit

Permalink
Improve reliability of QuotaExceededError test (Azure#1550)
Browse files Browse the repository at this point in the history
- Partial fix for Azure#1430
  • Loading branch information
mikeharder authored Mar 13, 2019
1 parent a89b3e8 commit f62e61a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/@azure/eventhubs/client/tests/receiver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,13 @@ describe("EventHub Receiver", function (): void {
const partitionId = hubInfo.partitionIds[0];
const rcvHndlrs: ReceiveHandler[] = [];
const rcvrs: any[] = [];

// This test does not require recieving any messages. Just attempting to connect the 6th receiver causes
// onerr2() to be called with QuotaExceededError. So it's fastest to use EventPosition.fromEnd().
// Using EventPosition.fromStart() can cause timeouts or ServiceUnavailableException if the EventHub has
// a large number of messages.
const eventPosition = EventPosition.fromEnd();

debug(">>> Receivers length: ", rcvHndlrs.length);
for (let i = 1; i <= 5; i++) {
const rcvrId = `rcvr-${i}`;
Expand All @@ -492,7 +499,7 @@ describe("EventHub Receiver", function (): void {
debug("@@@@ Error received by receiver %s", rcvrId);
debug(err);
};
const rcvHndlr = client.receive(partitionId, onMsg, onError, { eventPosition: EventPosition.fromStart(), identifier: rcvrId });
const rcvHndlr = client.receive(partitionId, onMsg, onError, { eventPosition: eventPosition, identifier: rcvrId });
rcvHndlrs.push(rcvHndlr);
}
debug(">>> Attached message handlers to each receiver.");
Expand All @@ -517,7 +524,7 @@ describe("EventHub Receiver", function (): void {
done();
});
};
const failedRcvHandler = client.receive(partitionId, onmsg2, onerr2, { eventPosition: EventPosition.fromStart(), identifier: "rcvr-6" });
const failedRcvHandler = client.receive(partitionId, onmsg2, onerr2, { eventPosition: eventPosition, identifier: "rcvr-6" });
rcvHndlrs.push(failedRcvHandler);
}, 5000);
});
Expand Down

0 comments on commit f62e61a

Please sign in to comment.