diff --git a/sdk/eventhub/event-hubs/src/batchingPartitionChannel.ts b/sdk/eventhub/event-hubs/src/batchingPartitionChannel.ts index 60b002d1a8ac..ff6a18ed5cc5 100644 --- a/sdk/eventhub/event-hubs/src/batchingPartitionChannel.ts +++ b/sdk/eventhub/event-hubs/src/batchingPartitionChannel.ts @@ -9,9 +9,9 @@ import { EventHubProducerClient, OperationOptions } from "./index"; -import { AwaitableQueue } from "./impl/awaitableQueue"; import { isDefined, isObjectWithProperties } from "./util/typeGuards"; import { AbortSignalLike } from "@azure/abort-controller"; +import { AwaitableQueue } from "./impl/awaitableQueue"; import { getPromiseParts } from "./util/getPromiseParts"; import { logger } from "./log"; diff --git a/sdk/eventhub/event-hubs/src/connectionContext.ts b/sdk/eventhub/event-hubs/src/connectionContext.ts index e03a67b686bc..efc750f444b6 100644 --- a/sdk/eventhub/event-hubs/src/connectionContext.ts +++ b/sdk/eventhub/event-hubs/src/connectionContext.ts @@ -4,35 +4,35 @@ /* eslint-disable @typescript-eslint/no-namespace */ /* eslint-disable no-inner-declarations */ -import { logger, logErrorStackTrace } from "./log"; -import { getRuntimeInfo } from "./util/runtimeInfo"; -import { packageJsonInfo } from "./util/constants"; -import { - EventHubConnectionStringProperties, - parseEventHubConnectionString -} from "./util/connectionStringUtils"; -import { EventHubReceiver } from "./eventHubReceiver"; -import { EventHubSender } from "./eventHubSender"; +import { Connection, ConnectionEvents, Dictionary, EventContext, OnAmqpEvent } from "rhea-promise"; import { + ConnectionConfig, ConnectionContextBase, Constants, CreateConnectionContextBaseParameters, - ConnectionConfig, SasTokenProvider, createSasTokenProvider } from "@azure/core-amqp"; import { - TokenCredential, + EventHubConnectionStringProperties, + parseEventHubConnectionString +} from "./util/connectionStringUtils"; +import { ManagementClient, ManagementClientOptions } from "./managementClient"; +import { NamedKeyCredential, SASCredential, + TokenCredential, isNamedKeyCredential, isSASCredential } from "@azure/core-auth"; -import { ManagementClient, ManagementClientOptions } from "./managementClient"; +import { logErrorStackTrace, logger } from "./log"; import { EventHubClientOptions } from "./models/public"; -import { Connection, ConnectionEvents, Dictionary, EventContext, OnAmqpEvent } from "rhea-promise"; import { EventHubConnectionConfig } from "./eventhubConnectionConfig"; +import { EventHubReceiver } from "./eventHubReceiver"; +import { EventHubSender } from "./eventHubSender"; +import { getRuntimeInfo } from "./util/runtimeInfo"; import { isCredential } from "./util/typeGuards"; +import { packageJsonInfo } from "./util/constants"; /** * @internal diff --git a/sdk/eventhub/event-hubs/src/dataTransformer.ts b/sdk/eventhub/event-hubs/src/dataTransformer.ts index ab4d1e912b78..cc479e8834b6 100644 --- a/sdk/eventhub/event-hubs/src/dataTransformer.ts +++ b/sdk/eventhub/event-hubs/src/dataTransformer.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { message } from "rhea-promise"; -import isBuffer from "is-buffer"; -import { Buffer } from "buffer"; import { logErrorStackTrace, logger } from "./log"; +import { Buffer } from "buffer"; +import isBuffer from "is-buffer"; +import { message } from "rhea-promise"; /** * The allowed AMQP message body types. diff --git a/sdk/eventhub/event-hubs/src/diagnostics/instrumentEventData.ts b/sdk/eventhub/event-hubs/src/diagnostics/instrumentEventData.ts index dd3facc8e052..a3e9aa48cb26 100644 --- a/sdk/eventhub/event-hubs/src/diagnostics/instrumentEventData.ts +++ b/sdk/eventhub/event-hubs/src/diagnostics/instrumentEventData.ts @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +import { EventData, isAmqpAnnotatedMessage } from "../eventData"; import { extractSpanContextFromTraceParentHeader, getTraceParentHeader, isSpanContextValid } from "@azure/core-tracing"; -import { SpanContext } from "@azure/core-tracing"; import { AmqpAnnotatedMessage } from "@azure/core-amqp"; -import { EventData, isAmqpAnnotatedMessage } from "../eventData"; import { OperationOptions } from "../util/operationOptions"; +import { SpanContext } from "@azure/core-tracing"; import { createMessageSpan } from "./tracing"; /** diff --git a/sdk/eventhub/event-hubs/src/diagnostics/tracing.ts b/sdk/eventhub/event-hubs/src/diagnostics/tracing.ts index fce82fff3d49..1f4755fd5e33 100644 --- a/sdk/eventhub/event-hubs/src/diagnostics/tracing.ts +++ b/sdk/eventhub/event-hubs/src/diagnostics/tracing.ts @@ -2,18 +2,18 @@ // Licensed under the MIT license. import { - createSpanFunction, + Span, SpanContext, + SpanKind, SpanOptions, + context, + createSpanFunction, setSpan, - setSpanContext, - Span, - SpanKind, - context + setSpanContext } from "@azure/core-tracing"; -import { TryAddOptions } from "../eventDataBatch"; import { EventHubConnectionConfig } from "../eventhubConnectionConfig"; import { OperationOptions } from "../util/operationOptions"; +import { TryAddOptions } from "../eventDataBatch"; const _createSpan = createSpanFunction({ namespace: "Microsoft.EventHub", @@ -86,8 +86,8 @@ export function convertTryAddOptionsForCompatibility(tryAddOptions: TryAddOption } function takeSomeOptionsFromSomewhere(someOptionsPassedIntoTheirFunction) { - - batch.tryAddMessage(message, { + + batch.tryAddMessage(message, { // "runtime" blend of options from some other part of their app ...someOptionsPassedIntoTheirFunction, // parentSpan comes along for the ride... @@ -102,9 +102,9 @@ export function convertTryAddOptionsForCompatibility(tryAddOptions: TryAddOption And now they've accidentally been opted into the legacy code path even though they think they're using the modern code path. - + This does kick the can down the road a bit - at some point we will be putting them in this - situation where things looked okay but their spans are becoming unparented but we can + situation where things looked okay but their spans are becoming unparented but we can try to announce this (and other changes related to tracing) in our next big rev. */ diff --git a/sdk/eventhub/event-hubs/src/eventData.ts b/sdk/eventhub/event-hubs/src/eventData.ts index d32a5affc5ef..fa7ed8420b30 100644 --- a/sdk/eventhub/event-hubs/src/eventData.ts +++ b/sdk/eventhub/event-hubs/src/eventData.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { DeliveryAnnotations, Message as RheaMessage, MessageAnnotations } from "rhea-promise"; import { AmqpAnnotatedMessage, Constants } from "@azure/core-amqp"; -import { isDefined, isObjectWithProperties, objectHasProperty } from "./util/typeGuards"; import { BodyTypes, defaultDataTransformer } from "./dataTransformer"; +import { DeliveryAnnotations, MessageAnnotations, Message as RheaMessage } from "rhea-promise"; +import { isDefined, isObjectWithProperties, objectHasProperty } from "./util/typeGuards"; /** * Describes the delivery annotations. diff --git a/sdk/eventhub/event-hubs/src/eventDataBatch.ts b/sdk/eventhub/event-hubs/src/eventDataBatch.ts index ba2f55af15e6..a9517cf3da66 100644 --- a/sdk/eventhub/event-hubs/src/eventDataBatch.ts +++ b/sdk/eventhub/event-hubs/src/eventDataBatch.ts @@ -2,15 +2,15 @@ // Licensed under the MIT license. import { EventData, toRheaMessage } from "./eventData"; -import { ConnectionContext } from "./connectionContext"; -import { MessageAnnotations, message, Message as RheaMessage } from "rhea-promise"; -import { throwTypeErrorIfParameterMissing } from "./util/error"; -import { AmqpAnnotatedMessage } from "@azure/core-amqp"; +import { MessageAnnotations, Message as RheaMessage, message } from "rhea-promise"; import { Span, SpanContext } from "@azure/core-tracing"; -import { instrumentEventData } from "./diagnostics/instrumentEventData"; -import { convertTryAddOptionsForCompatibility } from "./diagnostics/tracing"; import { isDefined, isObjectWithProperties } from "./util/typeGuards"; +import { AmqpAnnotatedMessage } from "@azure/core-amqp"; +import { ConnectionContext } from "./connectionContext"; import { OperationTracingOptions } from "@azure/core-tracing"; +import { convertTryAddOptionsForCompatibility } from "./diagnostics/tracing"; +import { instrumentEventData } from "./diagnostics/instrumentEventData"; +import { throwTypeErrorIfParameterMissing } from "./util/error"; /** * The amount of bytes to reserve as overhead for a small message. diff --git a/sdk/eventhub/event-hubs/src/eventHubBufferedProducerClient.ts b/sdk/eventhub/event-hubs/src/eventHubBufferedProducerClient.ts index 44b38e3ce06b..a58d652ca31a 100644 --- a/sdk/eventhub/event-hubs/src/eventHubBufferedProducerClient.ts +++ b/sdk/eventhub/event-hubs/src/eventHubBufferedProducerClient.ts @@ -1,13 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { AbortController } from "@azure/abort-controller"; -import { AmqpAnnotatedMessage } from "@azure/core-amqp"; -import { NamedKeyCredential, SASCredential, TokenCredential } from "@azure/core-auth"; -import { BatchingPartitionChannel } from "./batchingPartitionChannel"; -import { PartitionAssigner } from "./impl/partitionAssigner"; import { EventData, EventHubProducerClient, OperationOptions } from "./index"; -import { EventHubProperties, PartitionProperties } from "./managementClient"; import { EventHubClientOptions, GetEventHubPropertiesOptions, @@ -15,7 +9,13 @@ import { GetPartitionPropertiesOptions, SendBatchOptions } from "./models/public"; +import { EventHubProperties, PartitionProperties } from "./managementClient"; +import { NamedKeyCredential, SASCredential, TokenCredential } from "@azure/core-auth"; import { isCredential, isDefined } from "./util/typeGuards"; +import { AbortController } from "@azure/abort-controller"; +import { AmqpAnnotatedMessage } from "@azure/core-amqp"; +import { BatchingPartitionChannel } from "./batchingPartitionChannel"; +import { PartitionAssigner } from "./impl/partitionAssigner"; /** * Contains the events that were successfully sent to the Event Hub, diff --git a/sdk/eventhub/event-hubs/src/eventHubConsumerClient.ts b/sdk/eventhub/event-hubs/src/eventHubConsumerClient.ts index 427ff5633e2f..fb702688e931 100644 --- a/sdk/eventhub/event-hubs/src/eventHubConsumerClient.ts +++ b/sdk/eventhub/event-hubs/src/eventHubConsumerClient.ts @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +import { CheckpointStore, EventProcessor, FullEventProcessorOptions } from "./eventProcessor"; import { ConnectionContext, createConnectionContext } from "./connectionContext"; import { EventHubConsumerClientOptions, @@ -9,26 +10,24 @@ import { GetPartitionPropertiesOptions, LoadBalancingOptions } from "./models/public"; -import { InMemoryCheckpointStore } from "./inMemoryCheckpointStore"; -import { CheckpointStore, EventProcessor, FullEventProcessorOptions } from "./eventProcessor"; -import { Constants } from "@azure/core-amqp"; -import { logger } from "./log"; - +import { EventHubProperties, PartitionProperties } from "./managementClient"; +import { NamedKeyCredential, SASCredential, TokenCredential } from "@azure/core-auth"; import { SubscribeOptions, Subscription, SubscriptionEventHandlers } from "./eventHubConsumerClientModels"; -import { TokenCredential, NamedKeyCredential, SASCredential } from "@azure/core-auth"; -import { EventHubProperties, PartitionProperties } from "./managementClient"; -import { PartitionGate } from "./impl/partitionGate"; -import { v4 as uuid } from "uuid"; -import { validateEventPositions } from "./eventPosition"; +import { BalancedLoadBalancingStrategy } from "./loadBalancerStrategies/balancedStrategy"; +import { Constants } from "@azure/core-amqp"; +import { GreedyLoadBalancingStrategy } from "./loadBalancerStrategies/greedyStrategy"; +import { InMemoryCheckpointStore } from "./inMemoryCheckpointStore"; import { LoadBalancingStrategy } from "./loadBalancerStrategies/loadBalancingStrategy"; +import { PartitionGate } from "./impl/partitionGate"; import { UnbalancedLoadBalancingStrategy } from "./loadBalancerStrategies/unbalancedStrategy"; -import { GreedyLoadBalancingStrategy } from "./loadBalancerStrategies/greedyStrategy"; -import { BalancedLoadBalancingStrategy } from "./loadBalancerStrategies/balancedStrategy"; import { isCredential } from "./util/typeGuards"; +import { logger } from "./log"; +import { v4 as uuid } from "uuid"; +import { validateEventPositions } from "./eventPosition"; const defaultConsumerClientOptions: Required { diff --git a/sdk/eventhub/event-hubs/test/internal/amqp.spec.ts b/sdk/eventhub/event-hubs/test/internal/amqp.spec.ts index a13f72c81e89..abc0a85cb72c 100644 --- a/sdk/eventhub/event-hubs/test/internal/amqp.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/amqp.spec.ts @@ -1,10 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import chai from "chai"; -import { Constants } from "@azure/core-amqp"; import { fromRheaMessage, isAmqpAnnotatedMessage } from "../../src/eventData"; +import { Constants } from "@azure/core-amqp"; +import chai from "chai"; import { testWithServiceTypes } from "../public/utils/testWithServiceTypes"; + const assert = chai.assert; testWithServiceTypes(() => { diff --git a/sdk/eventhub/event-hubs/test/internal/auth.spec.ts b/sdk/eventhub/event-hubs/test/internal/auth.spec.ts index 115bee565f05..54940ce843ba 100644 --- a/sdk/eventhub/event-hubs/test/internal/auth.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/auth.spec.ts @@ -1,18 +1,18 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +import { AzureNamedKeyCredential, AzureSASCredential } from "@azure/core-auth"; +import { EnvVarKeys, getEnvVars } from "../public/utils/testUtils"; import { EventHubConnectionStringProperties, EventHubConsumerClient, EventHubProducerClient, parseEventHubConnectionString } from "../../src"; -import { EnvVarKeys, getEnvVars } from "../public/utils/testUtils"; import chai from "chai"; -import { AzureNamedKeyCredential, AzureSASCredential } from "@azure/core-auth"; +import { createMockServer } from "../public/utils/mockService"; import { createSasTokenProvider } from "@azure/core-amqp"; import { testWithServiceTypes } from "../public/utils/testWithServiceTypes"; -import { createMockServer } from "../public/utils/mockService"; const should = chai.should(); diff --git a/sdk/eventhub/event-hubs/test/internal/cancellation.spec.ts b/sdk/eventhub/event-hubs/test/internal/cancellation.spec.ts index c4a9c87f7145..ab92e177b558 100644 --- a/sdk/eventhub/event-hubs/test/internal/cancellation.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/cancellation.spec.ts @@ -1,19 +1,19 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +import { EnvVarKeys, getEnvVars } from "../public/utils/testUtils"; import { AbortController } from "@azure/abort-controller"; +import { EventHubReceiver } from "../../src/eventHubReceiver"; +import { EventHubSender } from "../../src/eventHubSender"; import chai from "chai"; -const should = chai.should(); import chaiAsPromised from "chai-as-promised"; import { createConnectionContext } from "../../src/connectionContext"; -import { EventHubReceiver } from "../../src/eventHubReceiver"; -import { EventHubSender } from "../../src/eventHubSender"; import { createMockServer } from "../public/utils/mockService"; -chai.use(chaiAsPromised); - -import { EnvVarKeys, getEnvVars } from "../public/utils/testUtils"; import { testWithServiceTypes } from "../public/utils/testWithServiceTypes"; +const should = chai.should(); +chai.use(chaiAsPromised); + testWithServiceTypes((serviceVersion) => { const env = getEnvVars(); if (serviceVersion === "mock") { diff --git a/sdk/eventhub/event-hubs/test/internal/client.spec.ts b/sdk/eventhub/event-hubs/test/internal/client.spec.ts index e8383b49e41a..cbcaf893f9e6 100644 --- a/sdk/eventhub/event-hubs/test/internal/client.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/client.spec.ts @@ -1,27 +1,28 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import chai from "chai"; -const should = chai.should(); -import chaiAsPromised from "chai-as-promised"; -chai.use(chaiAsPromised); -import chaiString from "chai-string"; -chai.use(chaiString); -import debugModule from "debug"; -const debug = debugModule("azure:event-hubs:client-spec"); +import { EnvVarKeys, getEnvVars, isNode } from "../public/utils/testUtils"; import { - TokenCredential, - EventHubProducerClient, EventHubConsumerClient, - Subscription + EventHubProducerClient, + Subscription, + TokenCredential } from "../../src"; -import { packageJsonInfo } from "../../src/util/constants"; -import { EnvVarKeys, getEnvVars, isNode } from "../public/utils/testUtils"; -import { MessagingError } from "@azure/core-amqp"; import { ConnectionContext } from "../../src/connectionContext"; +import { MessagingError } from "@azure/core-amqp"; +import chai from "chai"; +import chaiAsPromised from "chai-as-promised"; +import chaiString from "chai-string"; +import { createMockServer } from "../public/utils/mockService"; +import debugModule from "debug"; import { getRuntimeInfo } from "../../src/util/runtimeInfo"; +import { packageJsonInfo } from "../../src/util/constants"; import { testWithServiceTypes } from "../public/utils/testWithServiceTypes"; -import { createMockServer } from "../public/utils/mockService"; + +const should = chai.should(); +chai.use(chaiAsPromised); +chai.use(chaiString); +const debug = debugModule("azure:event-hubs:client-spec"); const testFailureMessage = "Test failure"; function validateConnectionError(err: E): void { diff --git a/sdk/eventhub/event-hubs/test/internal/dataTransformer.spec.ts b/sdk/eventhub/event-hubs/test/internal/dataTransformer.spec.ts index 413d130896fe..9beaf31a546d 100644 --- a/sdk/eventhub/event-hubs/test/internal/dataTransformer.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/dataTransformer.spec.ts @@ -1,14 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { Buffer } from "buffer"; -import * as chai from "chai"; -const should = chai.should(); import * as assert from "assert"; -import isBuffer from "is-buffer"; +import * as chai from "chai"; import { dataSectionTypeCode, defaultDataTransformer } from "../../src/dataTransformer"; +import { Buffer } from "buffer"; +import isBuffer from "is-buffer"; import { testWithServiceTypes } from "../public/utils/testWithServiceTypes"; +const should = chai.should(); + testWithServiceTypes(() => { describe("DataTransformer", function() { const objectBody: any = { diff --git a/sdk/eventhub/event-hubs/test/internal/diagnostics/messageSpan.spec.ts b/sdk/eventhub/event-hubs/test/internal/diagnostics/messageSpan.spec.ts index 53ce21e00f5d..b53f1ddfa700 100644 --- a/sdk/eventhub/event-hubs/test/internal/diagnostics/messageSpan.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/diagnostics/messageSpan.spec.ts @@ -1,9 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +import { resetTracer, setTracer } from "@azure/test-utils"; import chai from "chai"; import { createMessageSpan } from "../../../src/diagnostics/tracing"; -import { setTracer, resetTracer } from "@azure/test-utils"; import { testWithServiceTypes } from "../../public/utils/testWithServiceTypes"; const should = chai.should(); diff --git a/sdk/eventhub/event-hubs/test/internal/eventHubConsumerClientUnitTests.spec.ts b/sdk/eventhub/event-hubs/test/internal/eventHubConsumerClientUnitTests.spec.ts index 8f5a2b61a8e1..50f422a53495 100644 --- a/sdk/eventhub/event-hubs/test/internal/eventHubConsumerClientUnitTests.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/eventHubConsumerClientUnitTests.spec.ts @@ -1,17 +1,18 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. + import { CheckpointStore, SubscriptionEventHandlers } from "../../src"; +import { EnvVarKeys, getEnvVars } from "../public/utils/testUtils"; import { EventHubConsumerClient, isCheckpointStore } from "../../src/eventHubConsumerClient"; -import { InMemoryCheckpointStore } from "../../src/inMemoryCheckpointStore"; import { EventProcessor, FullEventProcessorOptions } from "../../src/eventProcessor"; import { SinonStubbedInstance, createStubInstance } from "sinon"; -import { ConnectionContext } from "../../src/connectionContext"; import { BalancedLoadBalancingStrategy } from "../../src/loadBalancerStrategies/balancedStrategy"; +import { ConnectionContext } from "../../src/connectionContext"; import { GreedyLoadBalancingStrategy } from "../../src/loadBalancerStrategies/greedyStrategy"; +import { InMemoryCheckpointStore } from "../../src/inMemoryCheckpointStore"; import chai from "chai"; -import { EnvVarKeys, getEnvVars } from "../public/utils/testUtils"; -import { testWithServiceTypes } from "../public/utils/testWithServiceTypes"; import { createMockServer } from "../public/utils/mockService"; +import { testWithServiceTypes } from "../public/utils/testWithServiceTypes"; const should = chai.should(); diff --git a/sdk/eventhub/event-hubs/test/internal/eventPosition.spec.ts b/sdk/eventhub/event-hubs/test/internal/eventPosition.spec.ts index f55d36b2a033..655aaf1d9431 100644 --- a/sdk/eventhub/event-hubs/test/internal/eventPosition.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/eventPosition.spec.ts @@ -1,13 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import chai from "chai"; -chai.should(); - import { earliestEventPosition, latestEventPosition } from "../../src"; import { getEventPositionFilter, validateEventPositions } from "../../src/eventPosition"; +import chai from "chai"; import { testWithServiceTypes } from "../public/utils/testWithServiceTypes"; +chai.should(); + testWithServiceTypes(() => { describe("EventPosition", function(): void { describe("happy", function(): void { diff --git a/sdk/eventhub/event-hubs/test/internal/eventProcessor.spec.ts b/sdk/eventhub/event-hubs/test/internal/eventProcessor.spec.ts index 9cface634c82..b0864877962a 100644 --- a/sdk/eventhub/event-hubs/test/internal/eventProcessor.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/eventProcessor.spec.ts @@ -1,45 +1,46 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import chai from "chai"; -const should = chai.should(); -import chaiAsPromised from "chai-as-promised"; -chai.use(chaiAsPromised); -import debugModule from "debug"; -const debug = debugModule("azure:event-hubs:partitionPump"); +import { AbortError, AbortSignal } from "@azure/abort-controller"; import { CheckpointStore, CloseReason, EventData, + EventHubConsumerClient, + EventHubProducerClient, PartitionOwnership, ReceivedEventData, SubscriptionEventHandlers, earliestEventPosition, - latestEventPosition, - EventHubConsumerClient, - EventHubProducerClient + latestEventPosition } from "../../src"; -import { EnvVarKeys, getEnvVars, loopUntil } from "../public/utils/testUtils"; import { Dictionary, generate_uuid } from "rhea-promise"; +import { EnvVarKeys, getEnvVars, loopUntil } from "../public/utils/testUtils"; import { EventProcessor, FullEventProcessorOptions } from "../../src/eventProcessor"; -import { Checkpoint } from "../../src/partitionProcessor"; -import { delay } from "@azure/core-amqp"; -import { PartitionContext } from "../../src/eventHubConsumerClientModels"; -import { InMemoryCheckpointStore } from "../../src/inMemoryCheckpointStore"; -import { loggerForTest } from "../public/utils/logHelpers"; import { SubscriptionHandlerForTests, sendOneMessagePerPartition } from "../public/utils/subscriptionHandlerForTests"; -import { AbortError, AbortSignal } from "@azure/abort-controller"; -import { FakeSubscriptionEventHandlers } from "../public/utils/fakeSubscriptionEventHandlers"; -import { isLatestPosition } from "../../src/eventPosition"; import { AbortController } from "@azure/abort-controller"; -import { UnbalancedLoadBalancingStrategy } from "../../src/loadBalancerStrategies/unbalancedStrategy"; import { BalancedLoadBalancingStrategy } from "../../src/loadBalancerStrategies/balancedStrategy"; +import { Checkpoint } from "../../src/partitionProcessor"; +import { FakeSubscriptionEventHandlers } from "../public/utils/fakeSubscriptionEventHandlers"; import { GreedyLoadBalancingStrategy } from "../../src/loadBalancerStrategies/greedyStrategy"; -import { testWithServiceTypes } from "../public/utils/testWithServiceTypes"; +import { InMemoryCheckpointStore } from "../../src/inMemoryCheckpointStore"; +import { PartitionContext } from "../../src/eventHubConsumerClientModels"; +import { UnbalancedLoadBalancingStrategy } from "../../src/loadBalancerStrategies/unbalancedStrategy"; +import chai from "chai"; +import chaiAsPromised from "chai-as-promised"; import { createMockServer } from "../public/utils/mockService"; +import debugModule from "debug"; +import { delay } from "@azure/core-amqp"; +import { isLatestPosition } from "../../src/eventPosition"; +import { loggerForTest } from "../public/utils/logHelpers"; +import { testWithServiceTypes } from "../public/utils/testWithServiceTypes"; + +const should = chai.should(); +chai.use(chaiAsPromised); +const debug = debugModule("azure:event-hubs:partitionPump"); testWithServiceTypes((serviceVersion) => { const env = getEnvVars(); diff --git a/sdk/eventhub/event-hubs/test/internal/eventdata.spec.ts b/sdk/eventhub/event-hubs/test/internal/eventdata.spec.ts index 03ed246e928f..68b4cbab61b1 100644 --- a/sdk/eventhub/event-hubs/test/internal/eventdata.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/eventdata.spec.ts @@ -1,19 +1,19 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +import { EventData, ReceivedEventData, fromRheaMessage, toRheaMessage } from "../../src/eventData"; import chai, { assert, should } from "chai"; -chai.should(); - -import { EventData, fromRheaMessage, ReceivedEventData, toRheaMessage } from "../../src/eventData"; -import { Message } from "rhea-promise"; import { dataSectionTypeCode, sequenceSectionTypeCode, valueSectionTypeCode } from "../../src/dataTransformer"; import { AmqpAnnotatedMessage } from "@azure/core-amqp"; +import { Message } from "rhea-promise"; import { testWithServiceTypes } from "../public/utils/testWithServiceTypes"; +chai.should(); + const testAnnotations = { "x-opt-enqueued-time": Date.now(), "x-opt-offset": "42", diff --git a/sdk/eventhub/event-hubs/test/internal/impl/awaitableQueue.spec.ts b/sdk/eventhub/event-hubs/test/internal/impl/awaitableQueue.spec.ts index 60bcffa4b9a1..4353b69098c8 100644 --- a/sdk/eventhub/event-hubs/test/internal/impl/awaitableQueue.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/impl/awaitableQueue.spec.ts @@ -1,9 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +import { AwaitableQueue } from "../../../src/impl/awaitableQueue"; import chai from "chai"; import { testWithServiceTypes } from "../../public/utils/testWithServiceTypes"; -import { AwaitableQueue } from "../../../src/impl/awaitableQueue"; + const should = chai.should(); testWithServiceTypes(() => { diff --git a/sdk/eventhub/event-hubs/test/internal/loadBalancingStrategy.spec.ts b/sdk/eventhub/event-hubs/test/internal/loadBalancingStrategy.spec.ts index 205081f7c060..cad5fc72ccc9 100644 --- a/sdk/eventhub/event-hubs/test/internal/loadBalancingStrategy.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/loadBalancingStrategy.spec.ts @@ -1,12 +1,13 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import chai from "chai"; -import { PartitionOwnership } from "../../src"; import { BalancedLoadBalancingStrategy } from "../../src/loadBalancerStrategies/balancedStrategy"; import { GreedyLoadBalancingStrategy } from "../../src/loadBalancerStrategies/greedyStrategy"; +import { PartitionOwnership } from "../../src"; import { UnbalancedLoadBalancingStrategy } from "../../src/loadBalancerStrategies/unbalancedStrategy"; +import chai from "chai"; import { testWithServiceTypes } from "../public/utils/testWithServiceTypes"; + const should = chai.should(); testWithServiceTypes(() => { diff --git a/sdk/eventhub/event-hubs/test/internal/misc.spec.ts b/sdk/eventhub/event-hubs/test/internal/misc.spec.ts index ca6d5617dace..83d2961e0ade 100644 --- a/sdk/eventhub/event-hubs/test/internal/misc.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/misc.spec.ts @@ -1,14 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { v4 as uuid } from "uuid"; -import chai from "chai"; -import assert from "assert"; -const should = chai.should(); -import chaiAsPromised from "chai-as-promised"; -chai.use(chaiAsPromised); -import debugModule from "debug"; -const debug = debugModule("azure:event-hubs:misc-spec"); +import { EnvVarKeys, getEnvVars } from "../public/utils/testUtils"; import { EventData, EventHubConsumerClient, @@ -17,15 +10,23 @@ import { ReceivedEventData, Subscription } from "../../src"; -import { EnvVarKeys, getEnvVars } from "../public/utils/testUtils"; import { TRACEPARENT_PROPERTY, extractSpanContextFromEventData } from "../../src/diagnostics/instrumentEventData"; -import { TraceFlags } from "@azure/core-tracing"; import { SubscriptionHandlerForTests } from "../public/utils/subscriptionHandlerForTests"; -import { testWithServiceTypes } from "../public/utils/testWithServiceTypes"; +import { TraceFlags } from "@azure/core-tracing"; +import assert from "assert"; +import chai from "chai"; +import chaiAsPromised from "chai-as-promised"; import { createMockServer } from "../public/utils/mockService"; +import debugModule from "debug"; +import { testWithServiceTypes } from "../public/utils/testWithServiceTypes"; +import { v4 as uuid } from "uuid"; + +const should = chai.should(); +chai.use(chaiAsPromised); +const debug = debugModule("azure:event-hubs:misc-spec"); testWithServiceTypes((serviceVersion) => { const env = getEnvVars(); diff --git a/sdk/eventhub/event-hubs/test/internal/node/disconnect.spec.ts b/sdk/eventhub/event-hubs/test/internal/node/disconnect.spec.ts index 78d3ff99f37a..21a4ecc449de 100644 --- a/sdk/eventhub/event-hubs/test/internal/node/disconnect.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/node/disconnect.spec.ts @@ -1,20 +1,21 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import chai from "chai"; -const should = chai.should(); -import chaiAsPromised from "chai-as-promised"; -chai.use(chaiAsPromised); import { EnvVarKeys, getEnvVars } from "../../public/utils/testUtils"; +import { EventHubConsumerClient, latestEventPosition } from "../../../src"; +import { EventHubReceiver } from "../../../src/eventHubReceiver"; import { EventHubSender } from "../../../src/eventHubSender"; -import { createConnectionContext } from "../../../src/connectionContext"; -import { stub } from "sinon"; import { MessagingError } from "@azure/core-amqp"; -import { EventHubReceiver } from "../../../src/eventHubReceiver"; -import { EventHubConsumerClient, latestEventPosition } from "../../../src"; +import chai from "chai"; +import chaiAsPromised from "chai-as-promised"; +import { createConnectionContext } from "../../../src/connectionContext"; import { createMockServer } from "../../public/utils/mockService"; +import { stub } from "sinon"; import { testWithServiceTypes } from "../../public/utils/testWithServiceTypes"; +const should = chai.should(); +chai.use(chaiAsPromised); + testWithServiceTypes((serviceVersion) => { const env = getEnvVars(); if (serviceVersion === "mock") { diff --git a/sdk/eventhub/event-hubs/test/internal/node/packageInfo.spec.ts b/sdk/eventhub/event-hubs/test/internal/node/packageInfo.spec.ts index c26cf4938c71..2a337d8fc52f 100644 --- a/sdk/eventhub/event-hubs/test/internal/node/packageInfo.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/node/packageInfo.spec.ts @@ -2,12 +2,13 @@ // Licensed under the MIT license. import chai from "chai"; -const should = chai.should(); import fs from "fs"; -import path from "path"; import { packageJsonInfo } from "../../../src/util/constants"; +import path from "path"; import { testWithServiceTypes } from "../../public/utils/testWithServiceTypes"; +const should = chai.should(); + // Since we currently hardcode package name and version in `constants.ts` file, // following test is in place to ensure the values in package.json and in this file are consistent diff --git a/sdk/eventhub/event-hubs/test/internal/partitionPump.spec.ts b/sdk/eventhub/event-hubs/test/internal/partitionPump.spec.ts index 19cca3013964..0698bdbdf769 100644 --- a/sdk/eventhub/event-hubs/test/internal/partitionPump.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/partitionPump.spec.ts @@ -1,18 +1,18 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { createProcessingSpan, trace } from "../../src/partitionPump"; import { - SpanStatusCode, + Context, SpanKind, SpanOptions, - Context, - setSpanContext, - context + SpanStatusCode, + context, + setSpanContext } from "@azure/core-tracing"; import { TestSpan, TestTracer } from "@azure/test-utils"; -import chai from "chai"; +import { createProcessingSpan, trace } from "../../src/partitionPump"; import { ReceivedEventData } from "../../src/eventData"; +import chai from "chai"; import { instrumentEventData } from "../../src/diagnostics/instrumentEventData"; import { setTracerForTest } from "../public/utils/testUtils"; import { testWithServiceTypes } from "../public/utils/testWithServiceTypes"; diff --git a/sdk/eventhub/event-hubs/test/internal/receiveBatch.spec.ts b/sdk/eventhub/event-hubs/test/internal/receiveBatch.spec.ts index 4e104229a31c..8b7c74437200 100644 --- a/sdk/eventhub/event-hubs/test/internal/receiveBatch.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/receiveBatch.spec.ts @@ -1,23 +1,23 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import chai from "chai"; -const should = chai.should(); -import chaiAsPromised from "chai-as-promised"; -chai.use(chaiAsPromised); - +import { EnvVarKeys, getEnvVars } from "../public/utils/testUtils"; import { EventData, - MessagingError, EventHubConsumerClient, EventHubProducerClient, - EventPosition + EventPosition, + MessagingError } from "../../src"; -import { EnvVarKeys, getEnvVars } from "../public/utils/testUtils"; import { EventHubReceiver } from "../../src/eventHubReceiver"; -import { translate } from "@azure/core-amqp"; -import { testWithServiceTypes } from "../public/utils/testWithServiceTypes"; +import chai from "chai"; +import chaiAsPromised from "chai-as-promised"; import { createMockServer } from "../public/utils/mockService"; +import { testWithServiceTypes } from "../public/utils/testWithServiceTypes"; +import { translate } from "@azure/core-amqp"; + +const should = chai.should(); +chai.use(chaiAsPromised); testWithServiceTypes((serviceVersion) => { const env = getEnvVars(); diff --git a/sdk/eventhub/event-hubs/test/internal/sender.spec.ts b/sdk/eventhub/event-hubs/test/internal/sender.spec.ts index 8fd70aad66cf..d70046450f5c 100644 --- a/sdk/eventhub/event-hubs/test/internal/sender.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/sender.spec.ts @@ -1,12 +1,12 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import chai from "chai"; -const should = chai.should(); -import chaiAsPromised from "chai-as-promised"; -chai.use(chaiAsPromised); -import debugModule from "debug"; -const debug = debugModule("azure:event-hubs:sender-spec"); +import { + EnvVarKeys, + getEnvVars, + getStartingPositionsForTests, + setTracerForTest +} from "../public/utils/testUtils"; import { EventData, EventHubConsumerClient, @@ -17,18 +17,19 @@ import { SendBatchOptions, TryAddOptions } from "../../src"; -import { - EnvVarKeys, - getEnvVars, - getStartingPositionsForTests, - setTracerForTest -} from "../public/utils/testUtils"; import { SpanGraph, TestSpan } from "@azure/test-utils"; -import { TRACEPARENT_PROPERTY } from "../../src/diagnostics/instrumentEventData"; +import { context, setSpan } from "@azure/core-tracing"; import { SubscriptionHandlerForTests } from "../public/utils/subscriptionHandlerForTests"; -import { setSpan, context } from "@azure/core-tracing"; -import { testWithServiceTypes } from "../public/utils/testWithServiceTypes"; +import { TRACEPARENT_PROPERTY } from "../../src/diagnostics/instrumentEventData"; +import chai from "chai"; +import chaiAsPromised from "chai-as-promised"; import { createMockServer } from "../public/utils/mockService"; +import debugModule from "debug"; +import { testWithServiceTypes } from "../public/utils/testWithServiceTypes"; + +const should = chai.should(); +chai.use(chaiAsPromised); +const debug = debugModule("azure:event-hubs:sender-spec"); testWithServiceTypes((serviceVersion) => { const env = getEnvVars(); diff --git a/sdk/eventhub/event-hubs/test/public/amqpAnnotatedMessage.spec.ts b/sdk/eventhub/event-hubs/test/public/amqpAnnotatedMessage.spec.ts index 79e4aac5b5fe..39a6c568dc12 100644 --- a/sdk/eventhub/event-hubs/test/public/amqpAnnotatedMessage.spec.ts +++ b/sdk/eventhub/event-hubs/test/public/amqpAnnotatedMessage.spec.ts @@ -1,12 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import chai from "chai"; -import chaiAsPromised from "chai-as-promised"; -import chaiExclude from "chai-exclude"; -import { Buffer } from "buffer"; -import { AmqpAnnotatedMessage } from "@azure/core-amqp"; -import { v4 } from "uuid"; import { EnvVarKeys, getEnvVars, getStartingPositionsForTests } from "./utils/testUtils"; import { EventHubConsumerClient, @@ -15,9 +9,15 @@ import { ReceivedEventData, Subscription } from "../../src"; +import { AmqpAnnotatedMessage } from "@azure/core-amqp"; import { BodyTypes } from "../../src/dataTransformer"; -import { testWithServiceTypes } from "./utils/testWithServiceTypes"; +import { Buffer } from "buffer"; +import chai from "chai"; +import chaiAsPromised from "chai-as-promised"; +import chaiExclude from "chai-exclude"; import { createMockServer } from "./utils/mockService"; +import { testWithServiceTypes } from "./utils/testWithServiceTypes"; +import { v4 } from "uuid"; const should = chai.should(); chai.use(chaiAsPromised); diff --git a/sdk/eventhub/event-hubs/test/public/auth.spec.ts b/sdk/eventhub/event-hubs/test/public/auth.spec.ts index 3b9ae3168c26..c303ace71200 100644 --- a/sdk/eventhub/event-hubs/test/public/auth.spec.ts +++ b/sdk/eventhub/event-hubs/test/public/auth.spec.ts @@ -1,18 +1,18 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +import { AzureNamedKeyCredential, AzureSASCredential } from "@azure/core-auth"; +import { EnvVarKeys, getEnvVars } from "./utils/testUtils"; import { EventHubConsumerClient, EventHubProducerClient, parseEventHubConnectionString } from "../../src/index"; -import { EnvVarKeys, getEnvVars } from "./utils/testUtils"; +import { SinonFakeTimers, useFakeTimers } from "sinon"; import chai from "chai"; -import { AzureNamedKeyCredential, AzureSASCredential } from "@azure/core-auth"; +import { createMockServer } from "./utils/mockService"; import { createSasTokenProvider } from "@azure/core-amqp"; -import { SinonFakeTimers, useFakeTimers } from "sinon"; import { testWithServiceTypes } from "./utils/testWithServiceTypes"; -import { createMockServer } from "./utils/mockService"; const should = chai.should(); diff --git a/sdk/eventhub/event-hubs/test/public/cancellation.spec.ts b/sdk/eventhub/event-hubs/test/public/cancellation.spec.ts index 00d2169d6849..832f333ae2f6 100644 --- a/sdk/eventhub/event-hubs/test/public/cancellation.spec.ts +++ b/sdk/eventhub/event-hubs/test/public/cancellation.spec.ts @@ -1,17 +1,17 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +import { EnvVarKeys, getEnvVars } from "./utils/testUtils"; +import { EventHubConsumerClient, EventHubProducerClient } from "../../src"; import { AbortController } from "@azure/abort-controller"; import chai from "chai"; -const should = chai.should(); import chaiAsPromised from "chai-as-promised"; -import { EventHubConsumerClient, EventHubProducerClient } from "../../src"; import { createMockServer } from "./utils/mockService"; -chai.use(chaiAsPromised); - -import { EnvVarKeys, getEnvVars } from "./utils/testUtils"; import { testWithServiceTypes } from "./utils/testWithServiceTypes"; +const should = chai.should(); +chai.use(chaiAsPromised); + testWithServiceTypes((serviceVersion) => { const env = getEnvVars(); if (serviceVersion === "mock") { diff --git a/sdk/eventhub/event-hubs/test/public/eventData.spec.ts b/sdk/eventhub/event-hubs/test/public/eventData.spec.ts index 5b00ebf02e7d..76763518054a 100644 --- a/sdk/eventhub/event-hubs/test/public/eventData.spec.ts +++ b/sdk/eventhub/event-hubs/test/public/eventData.spec.ts @@ -1,10 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import chai from "chai"; -import chaiAsPromised from "chai-as-promised"; -import chaiExclude from "chai-exclude"; -import { v4 } from "uuid"; import { EnvVarKeys, getEnvVars, getStartingPositionsForTests } from "./utils/testUtils"; import { EventData, @@ -14,8 +10,12 @@ import { ReceivedEventData, Subscription } from "../../src"; -import { testWithServiceTypes } from "./utils/testWithServiceTypes"; +import chai from "chai"; +import chaiAsPromised from "chai-as-promised"; +import chaiExclude from "chai-exclude"; import { createMockServer } from "./utils/mockService"; +import { testWithServiceTypes } from "./utils/testWithServiceTypes"; +import { v4 } from "uuid"; const should = chai.should(); chai.use(chaiAsPromised); diff --git a/sdk/eventhub/event-hubs/test/public/eventHubBufferedProducerClient.spec.ts b/sdk/eventhub/event-hubs/test/public/eventHubBufferedProducerClient.spec.ts index c99e4ff06ed1..99f4e2e2a400 100644 --- a/sdk/eventhub/event-hubs/test/public/eventHubBufferedProducerClient.spec.ts +++ b/sdk/eventhub/event-hubs/test/public/eventHubBufferedProducerClient.spec.ts @@ -1,17 +1,17 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import chai from "chai"; import { EnvVarKeys, getEnvVars } from "./utils/testUtils"; -import { testWithServiceTypes } from "./utils/testWithServiceTypes"; -import { createMockServer } from "./utils/mockService"; import { - EventHubBufferedProducerClient, EventData, + EventHubBufferedProducerClient, OnSendEventsErrorContext, OnSendEventsSuccessContext } from "../../src/index"; import { AmqpAnnotatedMessage } from "@azure/core-amqp"; +import chai from "chai"; +import { createMockServer } from "./utils/mockService"; +import { testWithServiceTypes } from "./utils/testWithServiceTypes"; const assert = chai.assert; diff --git a/sdk/eventhub/event-hubs/test/public/eventHubConsumerClient.spec.ts b/sdk/eventhub/event-hubs/test/public/eventHubConsumerClient.spec.ts index d037f84e70e6..c5721982293b 100644 --- a/sdk/eventhub/event-hubs/test/public/eventHubConsumerClient.spec.ts +++ b/sdk/eventhub/event-hubs/test/public/eventHubConsumerClient.spec.ts @@ -2,28 +2,28 @@ // Licensed under the MIT license. import { - EventHubProducerClient, - Subscription, - SubscriptionEventHandlers, - latestEventPosition, - logger, CloseReason, - EventHubConsumerClient, EventData, + EventHubConsumerClient, + EventHubProducerClient, MessagingError, ReceivedEventData, - earliestEventPosition + Subscription, + SubscriptionEventHandlers, + earliestEventPosition, + latestEventPosition, + logger } from "../../src"; -import debugModule from "debug"; -const debug = debugModule("azure:event-hubs:receiver-spec"); -import { EnvVarKeys, loopUntil, getStartingPositionsForTests, getEnvVars } from "./utils/testUtils"; -import chai from "chai"; -import { ReceivedMessagesTester } from "./utils/receivedMessagesTester"; +import { EnvVarKeys, getEnvVars, getStartingPositionsForTests, loopUntil } from "./utils/testUtils"; import { LogTester } from "./utils/logHelpers"; +import { ReceivedMessagesTester } from "./utils/receivedMessagesTester"; import { TestInMemoryCheckpointStore } from "./utils/testInMemoryCheckpointStore"; -import { testWithServiceTypes } from "./utils/testWithServiceTypes"; +import chai from "chai"; import { createMockServer } from "./utils/mockService"; +import debugModule from "debug"; +import { testWithServiceTypes } from "./utils/testWithServiceTypes"; +const debug = debugModule("azure:event-hubs:receiver-spec"); const should = chai.should(); testWithServiceTypes((serviceVersion) => { diff --git a/sdk/eventhub/event-hubs/test/public/hubruntime.spec.ts b/sdk/eventhub/event-hubs/test/public/hubruntime.spec.ts index 5cc0db28a135..13a324bb3906 100644 --- a/sdk/eventhub/event-hubs/test/public/hubruntime.spec.ts +++ b/sdk/eventhub/event-hubs/test/public/hubruntime.spec.ts @@ -1,24 +1,24 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import chai from "chai"; -const should = chai.should(); -import chaiAsPromised from "chai-as-promised"; -chai.use(chaiAsPromised); -import debugModule from "debug"; -const debug = debugModule("azure:event-hubs:hubruntime-spec"); import { EnvVarKeys, getEnvVars, setTracerForTest } from "./utils/testUtils"; -import { setSpan, context } from "@azure/core-tracing"; - -import { SpanGraph } from "@azure/test-utils"; import { EventHubBufferedProducerClient, - EventHubProducerClient, EventHubConsumerClient, + EventHubProducerClient, MessagingError } from "../../src"; -import { testWithServiceTypes } from "./utils/testWithServiceTypes"; +import { context, setSpan } from "@azure/core-tracing"; +import { SpanGraph } from "@azure/test-utils"; +import chai from "chai"; +import chaiAsPromised from "chai-as-promised"; import { createMockServer } from "./utils/mockService"; +import debugModule from "debug"; +import { testWithServiceTypes } from "./utils/testWithServiceTypes"; + +const should = chai.should(); +chai.use(chaiAsPromised); +const debug = debugModule("azure:event-hubs:hubruntime-spec"); type ClientCommonMethods = Pick< EventHubProducerClient, diff --git a/sdk/eventhub/event-hubs/test/public/node/client.spec.ts b/sdk/eventhub/event-hubs/test/public/node/client.spec.ts index 3414a5e9255a..4f1c59f8e84d 100644 --- a/sdk/eventhub/event-hubs/test/public/node/client.spec.ts +++ b/sdk/eventhub/event-hubs/test/public/node/client.spec.ts @@ -1,18 +1,19 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +import { EnvVarKeys, getEnvVars } from "../utils/testUtils"; +import { EnvironmentCredential, TokenCredential } from "@azure/identity"; +import { EventHubConsumerClient, EventHubProducerClient } from "../../../src"; +import { TestTracer, resetTracer, setTracer } from "@azure/test-utils"; import chai from "chai"; -const should = chai.should(); import chaiAsPromised from "chai-as-promised"; -chai.use(chaiAsPromised); import chaiString from "chai-string"; -chai.use(chaiString); -import { EnvVarKeys, getEnvVars } from "../utils/testUtils"; -import { EnvironmentCredential, TokenCredential } from "@azure/identity"; -import { EventHubProducerClient, EventHubConsumerClient } from "../../../src"; -import { TestTracer, setTracer, resetTracer } from "@azure/test-utils"; -import { testWithServiceTypes } from "../utils/testWithServiceTypes"; import { createMockServer } from "../utils/mockService"; +import { testWithServiceTypes } from "../utils/testWithServiceTypes"; + +const should = chai.should(); +chai.use(chaiAsPromised); +chai.use(chaiString); testWithServiceTypes((serviceVersion) => { const env = getEnvVars(); diff --git a/sdk/eventhub/event-hubs/test/public/node/disconnects.spec.ts b/sdk/eventhub/event-hubs/test/public/node/disconnects.spec.ts index a8f84c303575..d6eb64141a3c 100644 --- a/sdk/eventhub/event-hubs/test/public/node/disconnects.spec.ts +++ b/sdk/eventhub/event-hubs/test/public/node/disconnects.spec.ts @@ -1,14 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import chai from "chai"; -const should = chai.should(); -import chaiAsPromised from "chai-as-promised"; -chai.use(chaiAsPromised); import { EnvVarKeys, getEnvVars } from "../utils/testUtils"; import { EventHubConsumerClient, EventHubProducerClient, Subscription } from "../../../src"; -import { testWithServiceTypes } from "../utils/testWithServiceTypes"; +import chai from "chai"; +import chaiAsPromised from "chai-as-promised"; import { createMockServer } from "../utils/mockService"; +import { testWithServiceTypes } from "../utils/testWithServiceTypes"; + +const should = chai.should(); +chai.use(chaiAsPromised); testWithServiceTypes((serviceVersion, onVersions) => { const env = getEnvVars(); diff --git a/sdk/eventhub/event-hubs/test/public/receiver.spec.ts b/sdk/eventhub/event-hubs/test/public/receiver.spec.ts index 179ff7b233f1..0a93a7d632d7 100644 --- a/sdk/eventhub/event-hubs/test/public/receiver.spec.ts +++ b/sdk/eventhub/event-hubs/test/public/receiver.spec.ts @@ -1,25 +1,26 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import chai from "chai"; -const should = chai.should(); -import chaiAsPromised from "chai-as-promised"; -chai.use(chaiAsPromised); -import debugModule from "debug"; -const debug = debugModule("azure:event-hubs:receiver-spec"); +import { EnvVarKeys, getEnvVars } from "./utils/testUtils"; import { EventData, - ReceivedEventData, - latestEventPosition, - earliestEventPosition, EventHubConsumerClient, EventHubProducerClient, - Subscription + ReceivedEventData, + Subscription, + earliestEventPosition, + latestEventPosition } from "../../src"; +import chai from "chai"; +import chaiAsPromised from "chai-as-promised"; import { createMockServer } from "./utils/mockService"; -import { EnvVarKeys, getEnvVars } from "./utils/testUtils"; +import debugModule from "debug"; import { testWithServiceTypes } from "./utils/testWithServiceTypes"; +const should = chai.should(); +chai.use(chaiAsPromised); +const debug = debugModule("azure:event-hubs:receiver-spec"); + testWithServiceTypes((serviceVersion) => { const env = getEnvVars(); if (serviceVersion === "mock") { diff --git a/sdk/eventhub/event-hubs/test/public/utils/mockService.ts b/sdk/eventhub/event-hubs/test/public/utils/mockService.ts index 3ec15d12a0a8..a83c67d02b90 100644 --- a/sdk/eventhub/event-hubs/test/public/utils/mockService.ts +++ b/sdk/eventhub/event-hubs/test/public/utils/mockService.ts @@ -1,10 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { readFileSync } from "fs"; -import { resolve as resolvePath } from "path"; import { MockEventHub, MockServerOptions } from "@azure/mock-hub"; import { getEnvVars } from "./testUtils"; +import { readFileSync } from "fs"; +import { resolve as resolvePath } from "path"; export function createMockServer(options: MockServerOptions = {}): MockEventHub { const { EVENTHUB_NAME } = getEnvVars(); diff --git a/sdk/eventhub/event-hubs/test/public/utils/subscriptionHandlerForTests.ts b/sdk/eventhub/event-hubs/test/public/utils/subscriptionHandlerForTests.ts index 2952c936889d..bdbfe1d1bd6d 100644 --- a/sdk/eventhub/event-hubs/test/public/utils/subscriptionHandlerForTests.ts +++ b/sdk/eventhub/event-hubs/test/public/utils/subscriptionHandlerForTests.ts @@ -1,19 +1,20 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { delay } from "@azure/core-amqp"; -import chai from "chai"; import { CloseReason, EventHubConsumerClient, EventHubProducerClient, EventPosition, - ReceivedEventData, PartitionContext, + ReceivedEventData, SubscriptionEventHandlers } from "../../../src"; +import chai from "chai"; +import { delay } from "@azure/core-amqp"; import { loggerForTest } from "./logHelpers"; import { loopUntil } from "./testUtils"; + const should = chai.should(); export interface HandlerAndPositions { diff --git a/sdk/eventhub/event-hubs/test/public/utils/testInMemoryCheckpointStore.ts b/sdk/eventhub/event-hubs/test/public/utils/testInMemoryCheckpointStore.ts index 5fb233e6c9b0..f8330c6a4ad9 100644 --- a/sdk/eventhub/event-hubs/test/public/utils/testInMemoryCheckpointStore.ts +++ b/sdk/eventhub/event-hubs/test/public/utils/testInMemoryCheckpointStore.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { CheckpointStore, PartitionOwnership, Checkpoint } from "../../../src"; +import { Checkpoint, CheckpointStore, PartitionOwnership } from "../../../src"; import { generate_uuid } from "rhea-promise"; /** diff --git a/sdk/eventhub/event-hubs/test/public/utils/testUtils.ts b/sdk/eventhub/event-hubs/test/public/utils/testUtils.ts index 55d8f6a47bfd..343d57eba6df 100644 --- a/sdk/eventhub/event-hubs/test/public/utils/testUtils.ts +++ b/sdk/eventhub/event-hubs/test/public/utils/testUtils.ts @@ -2,10 +2,10 @@ // Licensed under the MIT license. import * as dotenv from "dotenv"; -import { loggerForTest } from "./logHelpers"; -import { delay } from "@azure/core-amqp"; import { EventHubConsumerClient, EventHubProducerClient, EventPosition } from "../../../src"; -import { TestTracer, setTracer, resetTracer } from "@azure/test-utils"; +import { TestTracer, resetTracer, setTracer } from "@azure/test-utils"; +import { delay } from "@azure/core-amqp"; +import { loggerForTest } from "./logHelpers"; dotenv.config(); diff --git a/sdk/eventhub/event-hubs/test/public/utils/testWithServiceTypes.ts b/sdk/eventhub/event-hubs/test/public/utils/testWithServiceTypes.ts index f143b7ba3693..881ff942e96e 100644 --- a/sdk/eventhub/event-hubs/test/public/utils/testWithServiceTypes.ts +++ b/sdk/eventhub/event-hubs/test/public/utils/testWithServiceTypes.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { isNode, TestFunctionWrapper, versionsToTest } from "@azure/test-utils"; +import { TestFunctionWrapper, isNode, versionsToTest } from "@azure/test-utils"; import { getEnvVarValue } from "./testUtils"; export type SupportedTargets = "mock" | "live";