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 Hub] formatting #10267

Merged
merged 1 commit into from
Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sdk/eventhub/event-hubs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export {
CreateBatchOptions,
GetPartitionIdsOptions,
GetPartitionPropertiesOptions,
GetEventHubPropertiesOptions,
GetEventHubPropertiesOptions
} from "./models/public";
export { EventHubConsumerClient } from "./eventHubConsumerClient";
export { EventHubProducerClient } from "./eventHubProducerClient";
Expand All @@ -27,7 +27,7 @@ export {
ProcessErrorHandler,
ProcessInitializeHandler,
ProcessCloseHandler,
ProcessEventsHandler,
ProcessEventsHandler
} from "./eventHubConsumerClientModels";
export { EventPosition, latestEventPosition, earliestEventPosition } from "./eventPosition";
export { PartitionProperties, EventHubProperties } from "./managementClient";
Expand Down
12 changes: 5 additions & 7 deletions sdk/eventhub/event-hubs/test/receiver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -600,14 +600,12 @@ describe("EventHubConsumerClient", function(): void {
);
let subscription: Subscription | undefined;
const caughtErr = await new Promise<Error | MessagingError>((resolve) => {
subscription = badConsumerClient.subscribe(
{
processEvents: async () => {},
processError: async (err) => {
resolve(err);
}
subscription = badConsumerClient.subscribe({
processEvents: async () => {},
processError: async (err) => {
resolve(err);
}
);
});
});
await subscription!.close();
await badConsumerClient.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { ContainerClient, RestError } from "@azure/storage-blob";
import { PartitionOwnership, Checkpoint, EventHubConsumerClient } from "@azure/event-hubs";
import { Guid } from "guid-typescript";
import { parseIntOrThrow } from "../src/blobCheckpointStore";
import { fail } from 'assert';
import { fail } from "assert";
const env = getEnvVars();

describe("Blob Checkpoint Store", function(): void {
Expand Down Expand Up @@ -53,36 +53,40 @@ describe("Blob Checkpoint Store", function(): void {
});

// these errors happen when we have multiple consumers starting up
// at the same time and load balancing amongst themselves. This is a
// at the same time and load balancing amongst themselves. This is a
// normal thing and shouldn't be reported to the user.
it("claimOwnership ignores errors about etags", async () => {
const checkpointStore = new BlobCheckpointStore(containerClient);

const originalClaimedOwnerships = await checkpointStore.claimOwnership([{
partitionId: "0",
consumerGroup: EventHubConsumerClient.defaultConsumerGroupName,
fullyQualifiedNamespace: "fqdn",
eventHubName: "ehname",
ownerId: "me"
}]);
const originalClaimedOwnerships = await checkpointStore.claimOwnership([
{
partitionId: "0",
consumerGroup: EventHubConsumerClient.defaultConsumerGroupName,
fullyQualifiedNamespace: "fqdn",
eventHubName: "ehname",
ownerId: "me"
}
]);

const originalETag = originalClaimedOwnerships[0] && originalClaimedOwnerships[0].etag;

const newClaimedOwnerships = await checkpointStore.claimOwnership(originalClaimedOwnerships);
newClaimedOwnerships.length.should.equal(1);

newClaimedOwnerships[0]!.etag!.should.not.equal(originalETag);

// we've now invalidated the previous ownership's etag so using the old etag will
// fail.
const shouldNotThrowButNothingWillClaim = await checkpointStore.claimOwnership([{
partitionId: "0",
consumerGroup: EventHubConsumerClient.defaultConsumerGroupName,
fullyQualifiedNamespace: "fqdn",
eventHubName: "ehname",
ownerId: "me",
etag: originalETag
}]);
const shouldNotThrowButNothingWillClaim = await checkpointStore.claimOwnership([
{
partitionId: "0",
consumerGroup: EventHubConsumerClient.defaultConsumerGroupName,
fullyQualifiedNamespace: "fqdn",
eventHubName: "ehname",
ownerId: "me",
etag: originalETag
}
]);

shouldNotThrowButNothingWillClaim.length.should.equal(0);
});
Expand All @@ -94,13 +98,15 @@ describe("Blob Checkpoint Store", function(): void {
await containerClient.delete();

try {
await checkpointStore.claimOwnership([{
partitionId: "0",
consumerGroup: EventHubConsumerClient.defaultConsumerGroupName,
fullyQualifiedNamespace: "fqdn",
eventHubName: "ehname",
ownerId: "me"
}]);
await checkpointStore.claimOwnership([
{
partitionId: "0",
consumerGroup: EventHubConsumerClient.defaultConsumerGroupName,
fullyQualifiedNamespace: "fqdn",
eventHubName: "ehname",
ownerId: "me"
}
]);
fail("Should have thrown an error - this isn't a normal claim collision issue");
} catch (err) {
(err instanceof RestError).should.be.ok;
Expand Down Expand Up @@ -431,7 +437,11 @@ describe("Blob Checkpoint Store", function(): void {
sequenceNumber: 0
});

const checkpoints = await checkpointStore.listCheckpoints(commonData.fullyQualifiedNamespace, commonData.eventHubName, commonData.consumerGroup);
const checkpoints = await checkpointStore.listCheckpoints(
commonData.fullyQualifiedNamespace,
commonData.eventHubName,
commonData.consumerGroup
);

checkpoints.length.should.equal(1);
checkpoints[0].sequenceNumber.should.equal(0);
Expand Down