Skip to content

Commit

Permalink
[Service Bus] Bad merge - Removing an unintentional duplicated test (#…
Browse files Browse the repository at this point in the history
…14000)

Bad merge at #14000
  • Loading branch information
HarshaNalluru authored Feb 26, 2021
1 parent b789438 commit d0d1fca
Showing 1 changed file with 0 additions and 80 deletions.
80 changes: 0 additions & 80 deletions sdk/servicebus/service-bus/test/internal/batchReceiver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1142,86 +1142,6 @@ describe("Batching Receiver", () => {

messages.length.should.equal(1, "Unexpected number of messages received.");
});

describe(withSessionTestClientType + ": Batch Receiver - disconnects", function(): void {
let serviceBusClient: ServiceBusClientForTests;
let sender: ServiceBusSender;
let receiver: ServiceBusSessionReceiver;

async function beforeEachTest(
receiveMode: "peekLock" | "receiveAndDelete" = "peekLock"
): Promise<void> {
serviceBusClient = createServiceBusClientForTests();
const entityNames = await serviceBusClient.test.createTestEntities(
withSessionTestClientType
);
if (receiveMode == "receiveAndDelete") {
receiver = (await serviceBusClient.test.createReceiveAndDeleteReceiver(
entityNames
)) as ServiceBusSessionReceiver;
} else {
receiver = (await serviceBusClient.test.createPeekLockReceiver(
entityNames
)) as ServiceBusSessionReceiver;
}

sender = serviceBusClient.test.addToCleanup(
serviceBusClient.createSender(entityNames.queue ?? entityNames.topic!)
);
}

afterEach(async () => {
if (serviceBusClient) {
await serviceBusClient.test.afterEach();
await serviceBusClient.test.after();
}
});

it.only(`throws "session lock has expired" after a disconnect`, async function(): Promise<
void
> {
// Create the sender and receiver.
await beforeEachTest();

// Send a message so we can be sure when the receiver is open and active.
const message = TestMessage.getSessionSample();
await sender.sendMessages(message);

let settledMessageCount = 0;

const messages1 = await receiver.receiveMessages(1);
for (const message of messages1) {
await receiver.completeMessage(message);
settledMessageCount++;
}

settledMessageCount.should.equal(1, "Unexpected number of settled messages.");

const connectionContext = (receiver as any)["_context"];
const refreshConnection = connectionContext.refreshConnection;
let refreshConnectionCalled = 0;
connectionContext.refreshConnection = function(...args: any) {
refreshConnectionCalled++;
refreshConnection.apply(this, args);
};

// Simulate a disconnect being called with a non-retryable error.
(receiver as ServiceBusSessionReceiverImpl)["_context"].connection["_connection"].idle();

// send a second message to trigger the message handler again.
await sender.sendMessages(TestMessage.getSessionSample());
try {
await receiver.receiveMessages(1);
assert.fail("receiveMessages should have failed");
} catch (error) {
should.equal(
error.message,
`The session lock has expired on the session with id ${message.sessionId}`
);
}
refreshConnectionCalled.should.be.greaterThan(0, "refreshConnection was not called.");
});
});
});

describe(withSessionTestClientType + ": Batch Receiver - disconnects", function(): void {
Expand Down

0 comments on commit d0d1fca

Please sign in to comment.