Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[event-hubs] add tests for cancellation #15094

Merged
merged 1 commit into from
May 17, 2021
Merged

Conversation

chradek
Copy link
Contributor

@chradek chradek commented Apr 29, 2021

Fixes #4422
Also address #13504 for event hubs by adding tests on the EventHubSender.send method.

The abort signal was plumbed through all the init operations to fix a separate bug as part of #14844 and was released in event-hubs version 5.5.1.

This PR ensures we have cancellation tests for all of our public methods and internal init/send/receive methods.

@chradek
Copy link
Contributor Author

chradek commented Apr 30, 2021

/azp run js - event-hubs - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

await client.initialize({ abortSignal, timeoutInMs: 60000 });
throw new Error(TEST_FAILURE);
} catch (err) {
should.equal(err.name, "AbortError");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not fatal for this PR but it's sometimes nice to compare the message and name together (so if it fails you have the actual exception that got thrown).

Perhaps that's not as easy with the 'should' API as it would be with just assert.deepEqual({
name: err.name,
message: err.message
}, {
name: "AbortError",
message: "The operation was aborted."
})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is definitely less easy using should. Maybe an MQ task will be moving to assert...

const messages = [...errors].map((e) => e.message);
messages.sort();
console.dir(messages);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops!

Copy link
Member

@richardpark-msft richardpark-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any tests for subscribe() specifically. Does it not support abort signals or is there some other logic that covers it?

@chradek
Copy link
Contributor Author

chradek commented May 17, 2021

Subscribe does not support abortSignals. The way to stop it is to call close on either the object returned by the subscribe call, or the EventHubConsumerClient.

@chradek chradek merged commit 4bd3842 into Azure:master May 17, 2021
openapi-sdkautomation bot pushed a commit to AzureSDKAutomation/azure-sdk-for-js that referenced this pull request Jul 7, 2021
Updated examples to use non-global locations and added new flags (Azure#15094)

Co-authored-by: Avi Jerafi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Event Hubs] Update all init() operations to take in cancellation token / aborter
2 participants