From 723e4badf41e5513a43575f6a1678c4f7aaeb2a6 Mon Sep 17 00:00:00 2001 From: Jonathan Cardenas Date: Thu, 23 Dec 2021 00:03:07 -0600 Subject: [PATCH 1/3] Upgrade prettier version --- common/config/rush/pnpm-lock.yaml | 21 ++++++++++--------- sdk/eventhub/event-hubs/package.json | 2 +- .../event-processor-host/package.json | 2 +- .../package.json | 2 +- .../package.json | 2 +- sdk/eventhub/mock-hub/package.json | 2 +- .../event-hubs-track-1/package.json | 2 +- .../perf-tests/event-hubs/package.json | 2 +- 8 files changed, 18 insertions(+), 17 deletions(-) diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 36d8343e64e7..c97cb5b05e5e 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -1408,6 +1408,7 @@ packages: /@opentelemetry/node/0.22.0_@opentelemetry+api@1.0.3: resolution: {integrity: sha512-+HhGbDruQ7cwejVOIYyxRa28uosnG8W95NiQZ6qE8PXXPsDSyGeftAPbtYpGit0H2f5hrVcMlwmWHeAo9xkSLA==} engines: {node: '>=8.0.0'} + deprecated: Package renamed to @opentelemetry/sdk-trace-node peerDependencies: '@opentelemetry/api': ^1.0.0 dependencies: @@ -10691,7 +10692,7 @@ packages: dev: false file:projects/event-hubs.tgz: - resolution: {integrity: sha512-QKo+ksa6MGdQm2cw3Rh1iZkW4yCs5227Y7uhLtIpODfLotbCM0Vjo4ecwZickPdmkFLepUzB6woCuJbb7eU9ZQ==, tarball: file:projects/event-hubs.tgz} + resolution: {integrity: sha512-NXA2+FZUn6CRh48QSGarB26hjUX5XXy9Z0PTowwGPr8Mlxk1audkfULILZjHIa0VlUaaXMa1S9p2aR7J/tSd2g==, tarball: file:projects/event-hubs.tgz} name: '@rush-temp/event-hubs' version: 0.0.0 dependencies: @@ -10743,7 +10744,7 @@ packages: mocha-junit-reporter: 2.0.2_mocha@7.2.0 moment: 2.29.1 nyc: 15.1.0 - prettier: 1.19.1 + prettier: 2.5.1 process: 0.11.10 puppeteer: 10.4.0 rhea-promise: 2.1.0 @@ -10829,7 +10830,7 @@ packages: dev: false file:projects/eventhubs-checkpointstore-blob.tgz: - resolution: {integrity: sha512-yukKMardh/Y+wmzXQ9Vs9SE8f29QNHZqoRrw2DoyXrSuIQxxTUVls5N4q6MKV+CYsAeiSwJyC2F7MsYIBOgr+w==, tarball: file:projects/eventhubs-checkpointstore-blob.tgz} + resolution: {integrity: sha512-W13AwI/nScWIjjYL5DakdTiesm+gJc2tFivKmMsI4NcwbIvTXHBODROS1J7mq0jYcLX460RaYhp/uyZUPxb0KQ==, tarball: file:projects/eventhubs-checkpointstore-blob.tgz} name: '@rush-temp/eventhubs-checkpointstore-blob' version: 0.0.0 dependencies: @@ -10867,7 +10868,7 @@ packages: mocha: 7.2.0 mocha-junit-reporter: 2.0.2_mocha@7.2.0 nyc: 15.1.0 - prettier: 1.19.1 + prettier: 2.5.1 rimraf: 3.0.2 rollup: 1.32.1 ts-node: 10.4.0_276ff2ad8f60608417677a4691c0f835 @@ -10883,7 +10884,7 @@ packages: dev: false file:projects/eventhubs-checkpointstore-table.tgz: - resolution: {integrity: sha512-zWlHbjrXxodAevHGy9Jf1UAVGlG/3tlPCZz1aGBDk8G/JPO96k1pHWbt7WCWR+LdfHJKBxM7YvIp6zggKW0Oog==, tarball: file:projects/eventhubs-checkpointstore-table.tgz} + resolution: {integrity: sha512-UlfM48pxr7Yk+oSi9wDG9uhg4gulxHf/QpwXCCzNKdzEYUU1vIPr+6/c5yMAeIKYLra0TtmHQVb1tPMKxTgmhw==, tarball: file:projects/eventhubs-checkpointstore-table.tgz} name: '@rush-temp/eventhubs-checkpointstore-table' version: 0.0.0 dependencies: @@ -10920,7 +10921,7 @@ packages: mocha: 7.2.0 mocha-junit-reporter: 2.0.2_mocha@7.2.0 nyc: 15.1.0 - prettier: 1.19.1 + prettier: 2.5.1 rimraf: 3.0.2 rollup: 1.32.1 ts-node: 10.4.0_276ff2ad8f60608417677a4691c0f835 @@ -11495,14 +11496,14 @@ packages: dev: false file:projects/mock-hub.tgz: - resolution: {integrity: sha512-K6rFTLoACIBX5It6x5v3r668Kpt7jjkgCeukzTyZ13cvPrjqJ4M7L9y0oU2ECIigGm59cbHx4sWOX/rHAhELhw==, tarball: file:projects/mock-hub.tgz} + resolution: {integrity: sha512-LlpgK1cB6WNMiX6Zq+iQ8+uYzOOSzwdW7BGwRSy7y+vNJD1Dfiqj3DTPAWJ8l82oGD7h6tQJoC7Q884CKbGwWw==, tarball: file:projects/mock-hub.tgz} name: '@rush-temp/mock-hub' version: 0.0.0 dependencies: '@types/node': 12.20.37 dotenv: 8.6.0 eslint: 7.32.0 - prettier: 1.19.1 + prettier: 2.5.1 rhea: 2.0.6 rimraf: 3.0.2 tslib: 2.3.1 @@ -11741,7 +11742,7 @@ packages: dev: false file:projects/perf-event-hubs.tgz: - resolution: {integrity: sha512-6AxLA3ozcov9w1YdM3FYvCUXRlN+ZstuasCq0lWD9evFsqIs1Yfjqv+W/SaqjgY1k6EuYXzM1JtUhBC0f8EVyw==, tarball: file:projects/perf-event-hubs.tgz} + resolution: {integrity: sha512-0Shj+f5HUSjnyL56js5KhwURz4fwSgQu9vAxnC5DawSdWpExDLiGSLG+pVm7YuDQ432ondadTZDYgdkVqlFE5A==, tarball: file:projects/perf-event-hubs.tgz} name: '@rush-temp/perf-event-hubs' version: 0.0.0 dependencies: @@ -11751,7 +11752,7 @@ packages: dotenv: 8.6.0 eslint: 7.32.0 moment: 2.29.1 - prettier: 1.19.1 + prettier: 2.5.1 rimraf: 3.0.2 ts-node: 10.4.0_276ff2ad8f60608417677a4691c0f835 tslib: 2.3.1 diff --git a/sdk/eventhub/event-hubs/package.json b/sdk/eventhub/event-hubs/package.json index 41361c53ec55..94f1295219fa 100644 --- a/sdk/eventhub/event-hubs/package.json +++ b/sdk/eventhub/event-hubs/package.json @@ -171,7 +171,7 @@ "mocha-junit-reporter": "^2.0.0", "moment": "^2.24.0", "nyc": "^15.0.0", - "prettier": "^1.16.4", + "prettier": "^2.5.1", "puppeteer": "^10.2.0", "rimraf": "^3.0.0", "rollup": "^1.16.3", diff --git a/sdk/eventhub/event-processor-host/package.json b/sdk/eventhub/event-processor-host/package.json index f3edbbbca45b..3ff55493f742 100644 --- a/sdk/eventhub/event-processor-host/package.json +++ b/sdk/eventhub/event-processor-host/package.json @@ -106,7 +106,7 @@ "mocha": "^7.1.1", "mocha-junit-reporter": "^2.0.0", "nyc": "^15.0.0", - "prettier": "^1.16.4", + "prettier": "^2.5.1", "rimraf": "^3.0.0", "rollup": "^1.16.3", "ts-node": "^10.0.0", diff --git a/sdk/eventhub/eventhubs-checkpointstore-blob/package.json b/sdk/eventhub/eventhubs-checkpointstore-blob/package.json index 93355bdddbf9..2a5b33cba682 100644 --- a/sdk/eventhub/eventhubs-checkpointstore-blob/package.json +++ b/sdk/eventhub/eventhubs-checkpointstore-blob/package.json @@ -99,7 +99,7 @@ "mocha": "^7.1.1", "mocha-junit-reporter": "^2.0.0", "nyc": "^15.0.0", - "prettier": "^1.16.4", + "prettier": "^2.5.1", "rimraf": "^3.0.0", "rollup": "^1.16.3", "ts-node": "^10.0.0", diff --git a/sdk/eventhub/eventhubs-checkpointstore-table/package.json b/sdk/eventhub/eventhubs-checkpointstore-table/package.json index f8ba80ad6aa8..a7aa74f55df2 100644 --- a/sdk/eventhub/eventhubs-checkpointstore-table/package.json +++ b/sdk/eventhub/eventhubs-checkpointstore-table/package.json @@ -98,7 +98,7 @@ "mocha": "^7.1.1", "mocha-junit-reporter": "^2.0.0", "nyc": "^15.0.0", - "prettier": "^1.16.4", + "prettier": "^2.5.1", "rimraf": "^3.0.0", "rollup": "^1.16.3", "ts-node": "^10.0.0", diff --git a/sdk/eventhub/mock-hub/package.json b/sdk/eventhub/mock-hub/package.json index b3d247ddcff5..7bca719e4a05 100644 --- a/sdk/eventhub/mock-hub/package.json +++ b/sdk/eventhub/mock-hub/package.json @@ -55,7 +55,7 @@ "@types/node": "^12.0.0", "dotenv": "^8.2.0", "eslint": "^7.15.0", - "prettier": "^1.16.4", + "prettier": "^2.5.1", "rimraf": "^3.0.0", "typescript": "~4.2.0" }, diff --git a/sdk/eventhub/perf-tests/event-hubs-track-1/package.json b/sdk/eventhub/perf-tests/event-hubs-track-1/package.json index 50561ac3605e..9cefd1ad9c0f 100644 --- a/sdk/eventhub/perf-tests/event-hubs-track-1/package.json +++ b/sdk/eventhub/perf-tests/event-hubs-track-1/package.json @@ -20,7 +20,7 @@ "ts-node": "^8.3.0", "tslib": "^2.0.0", "typescript": "4.1.2", - "prettier": "^1.16.4" + "prettier": "^2.5.1" }, "private": true, "scripts": { diff --git a/sdk/eventhub/perf-tests/event-hubs/package.json b/sdk/eventhub/perf-tests/event-hubs/package.json index 5a68da58d1bc..13366b3aaf44 100644 --- a/sdk/eventhub/perf-tests/event-hubs/package.json +++ b/sdk/eventhub/perf-tests/event-hubs/package.json @@ -19,7 +19,7 @@ "@types/uuid": "^8.0.0", "@types/node": "^12.0.0", "eslint": "^7.15.0", - "prettier": "^1.16.4", + "prettier": "^2.5.1", "rimraf": "^3.0.0", "tslib": "^2.2.0", "ts-node": "^10.0.0", From d6fc45b33d08d6c8d3a5544a4b2d2fd1ba26d9b5 Mon Sep 17 00:00:00 2001 From: Jonathan Cardenas Date: Thu, 23 Dec 2021 00:17:58 -0600 Subject: [PATCH 2/3] Format files --- sdk/eventhub/event-hubs/karma.conf.js | 22 +- sdk/eventhub/event-hubs/rollup.test.config.js | 16 +- .../samples-dev/iothubConnectionString.ts | 6 +- .../iothubConnectionStringWebsockets.ts | 8 +- .../event-hubs/samples-dev/receiveEvents.ts | 2 +- .../event-hubs/samples-dev/websockets.ts | 4 +- .../src/batchingPartitionChannel.ts | 12 +- .../event-hubs/src/connectionContext.ts | 16 +- .../event-hubs/src/dataTransformer.ts | 4 +- .../src/diagnostics/instrumentEventData.ts | 6 +- .../event-hubs/src/diagnostics/tracing.ts | 18 +- sdk/eventhub/event-hubs/src/eventData.ts | 10 +- sdk/eventhub/event-hubs/src/eventDataBatch.ts | 2 +- .../src/eventHubBufferedProducerClient.ts | 6 +- .../event-hubs/src/eventHubConsumerClient.ts | 31 +- .../event-hubs/src/eventHubProducerClient.ts | 18 +- .../event-hubs/src/eventHubReceiver.ts | 30 +- sdk/eventhub/event-hubs/src/eventHubSender.ts | 26 +- sdk/eventhub/event-hubs/src/eventPosition.ts | 6 +- sdk/eventhub/event-hubs/src/eventProcessor.ts | 8 +- .../src/eventhubConnectionConfig.ts | 2 +- .../event-hubs/src/impl/partitionAssigner.ts | 2 +- .../event-hubs/src/inMemoryCheckpointStore.ts | 2 +- sdk/eventhub/event-hubs/src/index.ts | 8 +- sdk/eventhub/event-hubs/src/linkEntity.ts | 10 +- .../loadBalancingStrategy.ts | 10 +- .../event-hubs/src/managementClient.ts | 40 +-- sdk/eventhub/event-hubs/src/models/public.ts | 2 +- .../event-hubs/src/partitionProcessor.ts | 4 +- sdk/eventhub/event-hubs/src/partitionPump.ts | 12 +- .../src/util/connectionStringUtils.ts | 2 +- sdk/eventhub/event-hubs/src/util/constants.ts | 2 +- .../event-hubs/src/util/getPromiseParts.ts | 2 +- .../event-hubs/src/util/typeGuards.ts | 2 +- .../test/connectionStringUtils.spec.ts | 6 +- .../test/impl/parseEndpoint.spec.ts | 8 +- .../event-hubs/test/internal/amqp.spec.ts | 16 +- .../event-hubs/test/internal/auth.spec.ts | 12 +- .../test/internal/cancellation.spec.ts | 14 +- .../event-hubs/test/internal/client.spec.ts | 174 ++++----- .../event-hubs/test/internal/config.spec.ts | 8 +- .../test/internal/dataTransformer.spec.ts | 24 +- .../internal/diagnostics/messageSpan.spec.ts | 4 +- .../eventHubConsumerClientUnitTests.spec.ts | 64 ++-- .../test/internal/eventPosition.spec.ts | 40 +-- .../test/internal/eventProcessor.spec.ts | 290 +++++++-------- .../test/internal/eventdata.spec.ts | 82 ++--- .../internal/loadBalancingStrategy.spec.ts | 56 +-- .../event-hubs/test/internal/misc.spec.ts | 108 +++--- .../test/internal/node/disconnect.spec.ts | 32 +- .../test/internal/node/packageInfo.spec.ts | 2 +- .../test/internal/partitionPump.spec.ts | 27 +- .../test/internal/receiveBatch.spec.ts | 22 +- .../event-hubs/test/internal/sender.spec.ts | 334 +++++++++--------- .../test/public/amqpAnnotatedMessage.spec.ts | 52 +-- .../event-hubs/test/public/auth.spec.ts | 48 ++- .../test/public/cancellation.spec.ts | 8 +- .../event-hubs/test/public/eventData.spec.ts | 16 +- .../eventHubBufferedProducerClient.spec.ts | 22 +- .../public/eventHubConsumerClient.spec.ts | 215 +++++------ .../event-hubs/test/public/hubruntime.spec.ts | 56 +-- .../test/public/node/client.spec.ts | 16 +- .../test/public/node/disconnects.spec.ts | 20 +- .../event-hubs/test/public/receiver.spec.ts | 86 ++--- .../test/public/utils/logHelpers.ts | 2 +- .../test/public/utils/mockService.ts | 4 +- .../public/utils/receivedMessagesTester.ts | 4 +- .../utils/subscriptionHandlerForTests.ts | 14 +- .../utils/testInMemoryCheckpointStore.ts | 2 +- .../event-hubs/test/public/utils/testUtils.ts | 10 +- .../test/public/utils/testWithServiceTypes.ts | 39 +- .../karma.conf.js | 20 +- .../samples-dev/createCustomPipeline.ts | 6 +- .../receiveEventsUsingCheckpointStore.ts | 2 +- .../receiveEventsWithApiSpecificStorage.ts | 2 +- .../src/blobCheckpointStore.ts | 26 +- .../test/blob-checkpointstore.spec.ts | 120 +++---- .../test/snippets.spec.ts | 2 +- .../test/utils/testUtils.ts | 4 +- .../karma.conf.js | 20 +- .../src/tableCheckpointStore.ts | 20 +- .../test/tables-checkpointstore.spec.ts | 72 ++-- .../test/utils/testUtils.ts | 4 +- .../mock-hub/src/messages/cbs/cbsAccepted.ts | 4 +- .../src/messages/event-hubs/partitionInfo.ts | 12 +- .../src/messages/event-hubs/runtimeInfo.ts | 6 +- .../src/sender/streamingPartitionSender.ts | 2 +- .../mock-hub/src/server/mockServer.ts | 33 +- .../mock-hub/src/services/eventHubs.ts | 50 +-- .../mock-hub/src/storage/messageStore.ts | 6 +- .../src/utils/convertBufferToMessage.ts | 4 +- .../mock-hub/src/utils/eventPosition.ts | 6 +- .../event-hubs/test/receive.spec.ts | 4 +- .../perf-tests/event-hubs/test/send.spec.ts | 8 +- 94 files changed, 1281 insertions(+), 1440 deletions(-) diff --git a/sdk/eventhub/event-hubs/karma.conf.js b/sdk/eventhub/event-hubs/karma.conf.js index 187c45ebc353..44e76d059169 100644 --- a/sdk/eventhub/event-hubs/karma.conf.js +++ b/sdk/eventhub/event-hubs/karma.conf.js @@ -2,7 +2,7 @@ process.env.CHROME_BIN = require("puppeteer").executablePath(); require("dotenv").config(); -module.exports = function(config) { +module.exports = function (config) { config.set({ // base path that will be used to resolve all patterns (eg. files, exclude) basePath: "./", @@ -21,13 +21,13 @@ module.exports = function(config) { "karma-env-preprocessor", "karma-coverage", "karma-sourcemap-loader", - "karma-junit-reporter" + "karma-junit-reporter", ], // list of files / patterns to load in the browser files: [ "dist-test/index.browser.js", - { pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: true } + { pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: true }, ], // list of files / patterns to exclude @@ -36,7 +36,7 @@ module.exports = function(config) { // preprocess matching files before serving them to the browser // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: { - "**/*.js": ["env"] + "**/*.js": ["env"], // IMPORTANT: COMMENT following line if you want to debug in your browsers!! // Preprocess source file to calculate code coverage, however this will make source file unreadable // "dist-test/index.browser.js": ["coverage"] @@ -49,7 +49,7 @@ module.exports = function(config) { "EVENTHUB_CONNECTION_STRING", "EVENTHUB_NAME", "IOTHUB_EH_COMPATIBLE_CONNECTION_STRING", - "TEST_TARGET" + "TEST_TARGET", ], // test results reporter to use @@ -64,8 +64,8 @@ module.exports = function(config) { { type: "json", subdir: ".", file: "coverage.json" }, { type: "lcovonly", subdir: ".", file: "lcov.info" }, { type: "html", subdir: "html" }, - { type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" } - ] + { type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" }, + ], }, junitReporter: { @@ -75,7 +75,7 @@ module.exports = function(config) { useBrowserName: false, // add browser name to report and classes names nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element - properties: {} // key value pair of properties to add to the section of the report + properties: {}, // key value pair of properties to add to the section of the report }, // web server port @@ -112,8 +112,8 @@ module.exports = function(config) { mocha: { // change Karma's debug.html to the mocha web reporter reporter: "html", - timeout: "600000" - } - } + timeout: "600000", + }, + }, }); }; diff --git a/sdk/eventhub/event-hubs/rollup.test.config.js b/sdk/eventhub/event-hubs/rollup.test.config.js index 0b1cb6ebd4d4..3a6b4c8bbae5 100644 --- a/sdk/eventhub/event-hubs/rollup.test.config.js +++ b/sdk/eventhub/event-hubs/rollup.test.config.js @@ -28,32 +28,32 @@ function makeBrowserTestConfigPatch() { // browser only. Rollup's dead code elimination will remove // any code guarded by if (isNode) { ... } "if (isNode)": "if (false)", - "if (!isNode)": "if (true)" + "if (!isNode)": "if (true)", }), // fs, net, and tls are used by rhea and need to be shimmed // dotenv doesn't work in the browser, so replace it with a no-op function shim({ - dotenv: `export function config() { }` + dotenv: `export function config() { }`, }), nodeResolve({ mainFields: ["module", "browser"], - preferBuiltins: false + preferBuiltins: false, }), cjs({ namedExports: { - chai: ["should", "assert"] - } + chai: ["should", "assert"], + }, }), // rhea and rhea-promise use the Buffer global which requires // injection to shim properly inject({ modules: { Buffer: ["buffer", "Buffer"], - process: "process" + process: "process", }, - exclude: ["./**/package.json"] + exclude: ["./**/package.json"], }), - json() + json(), ]; return config; diff --git a/sdk/eventhub/event-hubs/samples-dev/iothubConnectionString.ts b/sdk/eventhub/event-hubs/samples-dev/iothubConnectionString.ts index c444d2caecac..bc1198f84b19 100644 --- a/sdk/eventhub/event-hubs/samples-dev/iothubConnectionString.ts +++ b/sdk/eventhub/event-hubs/samples-dev/iothubConnectionString.ts @@ -95,13 +95,13 @@ async function convertIotHubToEventHubsConnectionString(connectionString: string username: `${SharedAccessKeyName}@sas.root.${iotHubName}`, port: 5671, reconnect: false, - password: token + password: token, }); await connection.open(); // Create the receiver that will trigger a redirect error. const receiver = await connection.createReceiver({ - source: { address: `amqps://${HostName}/messages/events/$management` } + source: { address: `amqps://${HostName}/messages/events/$management` }, }); return new Promise((resolve, reject) => { @@ -147,7 +147,7 @@ export async function main() { }, processError: async (err, context) => { console.log(`Error on partition "${context.partitionId}" : ${err}`); - } + }, }, { startPosition: earliestEventPosition } ); diff --git a/sdk/eventhub/event-hubs/samples-dev/iothubConnectionStringWebsockets.ts b/sdk/eventhub/event-hubs/samples-dev/iothubConnectionStringWebsockets.ts index 2af2dd8ac011..c1eaf90ca225 100644 --- a/sdk/eventhub/event-hubs/samples-dev/iothubConnectionStringWebsockets.ts +++ b/sdk/eventhub/event-hubs/samples-dev/iothubConnectionStringWebsockets.ts @@ -100,14 +100,14 @@ async function convertIotHubToEventHubsConnectionString(connectionString: string webSocketOptions: { webSocket: WebSocket, protocol: ["AMQPWSB10"], - url: `wss://${HostName}:${443}/$servicebus/websocket` - } + url: `wss://${HostName}:${443}/$servicebus/websocket`, + }, }); await connection.open(); // Create the receiver that will trigger a redirect error. const receiver = await connection.createReceiver({ - source: { address: `amqps://${HostName}/messages/events/$management` } + source: { address: `amqps://${HostName}/messages/events/$management` }, }); return new Promise((resolve, reject) => { @@ -153,7 +153,7 @@ export async function main() { }, processError: async (err, context) => { console.log(`Error on partition "${context.partitionId}" : ${err}`); - } + }, }, { startPosition: earliestEventPosition } ); diff --git a/sdk/eventhub/event-hubs/samples-dev/receiveEvents.ts b/sdk/eventhub/event-hubs/samples-dev/receiveEvents.ts index db5f8743d4ad..ff1c6b6bc986 100644 --- a/sdk/eventhub/event-hubs/samples-dev/receiveEvents.ts +++ b/sdk/eventhub/event-hubs/samples-dev/receiveEvents.ts @@ -40,7 +40,7 @@ export async function main() { }, processError: async (err, context) => { console.log(`Error on partition "${context.partitionId}": ${err}`); - } + }, }, { startPosition: earliestEventPosition } ); diff --git a/sdk/eventhub/event-hubs/samples-dev/websockets.ts b/sdk/eventhub/event-hubs/samples-dev/websockets.ts index 1e69950146f9..0a4c8b231b57 100644 --- a/sdk/eventhub/event-hubs/samples-dev/websockets.ts +++ b/sdk/eventhub/event-hubs/samples-dev/websockets.ts @@ -38,8 +38,8 @@ export async function main(): Promise { const client = new EventHubConsumerClient(consumerGroup, connectionString, eventHubName, { webSocketOptions: { webSocket: WebSocket, - webSocketConstructorOptions: { agent: proxyAgent } - } + webSocketConstructorOptions: { agent: proxyAgent }, + }, }); /* Refer to other samples, and place your code here to send/receive events diff --git a/sdk/eventhub/event-hubs/src/batchingPartitionChannel.ts b/sdk/eventhub/event-hubs/src/batchingPartitionChannel.ts index ff6a18ed5cc5..cc30f5bc2631 100644 --- a/sdk/eventhub/event-hubs/src/batchingPartitionChannel.ts +++ b/sdk/eventhub/event-hubs/src/batchingPartitionChannel.ts @@ -7,7 +7,7 @@ import { EventDataBatch, EventHubBufferedProducerClientOptions, EventHubProducerClient, - OperationOptions + OperationOptions, } from "./index"; import { isDefined, isObjectWithProperties } from "./util/typeGuards"; import { AbortSignalLike } from "@azure/abort-controller"; @@ -47,7 +47,7 @@ export class BatchingPartitionChannel { private _flushState: | { isFlushing: false } | { isFlushing: true; currentPromise: Promise; resolve: () => void } = { - isFlushing: false + isFlushing: false, }; private _isRunning: boolean = false; private _lastBatchCreationTime: number = 0; @@ -67,7 +67,7 @@ export class BatchingPartitionChannel { onSendEventsErrorHandler, onSendEventsSuccessHandler, partitionId, - producer + producer, }: BatchingPartitionChannelProps) { this._loopAbortSignal = loopAbortSignal; this._maxBufferSize = maxBufferSize; @@ -242,7 +242,7 @@ export class BatchingPartitionChannel { this._lastBatchCreationTime = Date.now(); this._batchedEvents = []; const batch = await this._producer.createBatch({ - partitionId: this._partitionId + partitionId: this._partitionId, }); this._incrementReadiness(); return batch; @@ -276,7 +276,7 @@ export class BatchingPartitionChannel { this._updateFlushState(); this._onSendEventsSuccessHandler?.({ events: this._batchedEvents, - partitionId: this._partitionId + partitionId: this._partitionId, }).catch((e) => { logger.error( `The following error occured in the onSendEventsSuccessHandler: ${JSON.stringify( @@ -298,7 +298,7 @@ export class BatchingPartitionChannel { this._onSendEventsErrorHandler({ error: err, events: event ? [event] : this._batchedEvents, - partitionId: this._partitionId + partitionId: this._partitionId, }).catch((e) => { logger.error( `The following error occured in the onSendEventsErrorHandler: ${JSON.stringify( diff --git a/sdk/eventhub/event-hubs/src/connectionContext.ts b/sdk/eventhub/event-hubs/src/connectionContext.ts index efc750f444b6..7be44b21792f 100644 --- a/sdk/eventhub/event-hubs/src/connectionContext.ts +++ b/sdk/eventhub/event-hubs/src/connectionContext.ts @@ -11,11 +11,11 @@ import { Constants, CreateConnectionContextBaseParameters, SasTokenProvider, - createSasTokenProvider + createSasTokenProvider, } from "@azure/core-amqp"; import { EventHubConnectionStringProperties, - parseEventHubConnectionString + parseEventHubConnectionString, } from "./util/connectionStringUtils"; import { ManagementClient, ManagementClientOptions } from "./managementClient"; import { @@ -23,7 +23,7 @@ import { SASCredential, TokenCredential, isNamedKeyCredential, - isSASCredential + isSASCredential, } from "@azure/core-auth"; import { logErrorStackTrace, logger } from "./log"; import { EventHubClientOptions } from "./models/public"; @@ -179,8 +179,8 @@ export namespace ConnectionContext { connectionProperties: { product: "MSJSClient", userAgent: getUserAgent(options), - version: packageJsonInfo.version - } + version: packageJsonInfo.version, + }, }; // Let us create the base context and then add EventHub specific ConnectionContext properties. const connectionContext = ConnectionContextBase.create(parameters) as ConnectionContext; @@ -190,7 +190,7 @@ export namespace ConnectionContext { connectionContext.receivers = {}; const mOptions: ManagementClientOptions = { address: options.managementSessionAddress, - audience: options.managementSessionAudience + audience: options.managementSessionAudience, }; connectionContext.managementSession = new ManagementClient(connectionContext, mOptions); @@ -268,7 +268,7 @@ export namespace ConnectionContext { logErrorStackTrace(err); throw err; } - } + }, }); // Define listeners to be added to the connection object for @@ -316,7 +316,7 @@ export namespace ConnectionContext { }> = { wasConnectionCloseCalled: connectionContext.wasConnectionCloseCalled, numSenders: Object.keys(connectionContext.senders).length, - numReceivers: Object.keys(connectionContext.receivers).length + numReceivers: Object.keys(connectionContext.receivers).length, }; logger.verbose( "[%s] Closing all open senders and receivers in the state: %O", diff --git a/sdk/eventhub/event-hubs/src/dataTransformer.ts b/sdk/eventhub/event-hubs/src/dataTransformer.ts index cc479e8834b6..172963cf44fc 100644 --- a/sdk/eventhub/event-hubs/src/dataTransformer.ts +++ b/sdk/eventhub/event-hubs/src/dataTransformer.ts @@ -88,7 +88,7 @@ export const defaultDataTransformer = { case dataSectionTypeCode: return { body: skipParsingBodyAsJson ? body.content : tryToJsonDecode(body.content), - bodyType: "data" + bodyType: "data", }; case sequenceSectionTypeCode: return { body: body.content, bodyType: "sequence" }; @@ -109,7 +109,7 @@ export const defaultDataTransformer = { ); throw err; } - } + }, }; /** diff --git a/sdk/eventhub/event-hubs/src/diagnostics/instrumentEventData.ts b/sdk/eventhub/event-hubs/src/diagnostics/instrumentEventData.ts index 040c4906e543..308685bcf518 100644 --- a/sdk/eventhub/event-hubs/src/diagnostics/instrumentEventData.ts +++ b/sdk/eventhub/event-hubs/src/diagnostics/instrumentEventData.ts @@ -5,7 +5,7 @@ import { EventData, isAmqpAnnotatedMessage } from "../eventData"; import { extractSpanContextFromTraceParentHeader, getTraceParentHeader, - isSpanContextValid + isSpanContextValid, } from "@azure/core-tracing"; import { AmqpAnnotatedMessage } from "@azure/core-amqp"; import { OperationOptions } from "../util/operationOptions"; @@ -46,7 +46,7 @@ export function instrumentEventData( if (!messageSpan.isRecording()) { return { event: eventData, - spanContext: undefined + spanContext: undefined, }; } @@ -65,7 +65,7 @@ export function instrumentEventData( return { event: eventData, - spanContext: messageSpan.spanContext() + spanContext: messageSpan.spanContext(), }; } finally { messageSpan.end(); diff --git a/sdk/eventhub/event-hubs/src/diagnostics/tracing.ts b/sdk/eventhub/event-hubs/src/diagnostics/tracing.ts index 1f4755fd5e33..0e87bf4140c0 100644 --- a/sdk/eventhub/event-hubs/src/diagnostics/tracing.ts +++ b/sdk/eventhub/event-hubs/src/diagnostics/tracing.ts @@ -9,7 +9,7 @@ import { context, createSpanFunction, setSpan, - setSpanContext + setSpanContext, } from "@azure/core-tracing"; import { EventHubConnectionConfig } from "../eventhubConnectionConfig"; import { OperationOptions } from "../util/operationOptions"; @@ -17,7 +17,7 @@ import { TryAddOptions } from "../eventDataBatch"; const _createSpan = createSpanFunction({ namespace: "Microsoft.EventHub", - packagePrefix: "Azure.EventHubs" + packagePrefix: "Azure.EventHubs", }); /** @@ -37,9 +37,9 @@ export function createEventHubSpan( spanOptions: { // By passing spanOptions if they exist at runtime, we're backwards compatible with @azure/core-tracing@preview.13 and earlier. ...(operationOptions?.tracingOptions as any)?.spanOptions, - ...additionalSpanOptions - } - } + ...additionalSpanOptions, + }, + }, }); span.setAttribute("message_bus.destination", connectionConfig.entityPath); @@ -47,7 +47,7 @@ export function createEventHubSpan( return { span, - updatedOptions + updatedOptions, }; } @@ -59,7 +59,7 @@ export function createMessageSpan( eventHubConfig: Pick ): ReturnType { return createEventHubSpan("message", operationOptions, eventHubConfig, { - kind: SpanKind.PRODUCER + kind: SpanKind.PRODUCER, }); } @@ -119,8 +119,8 @@ export function convertTryAddOptionsForCompatibility(tryAddOptions: TryAddOption tracingOptions: { tracingContext: isSpan(legacyParentSpanOrSpanContext) ? setSpan(context.active(), legacyParentSpanOrSpanContext) - : setSpanContext(context.active(), legacyParentSpanOrSpanContext) - } + : setSpanContext(context.active(), legacyParentSpanOrSpanContext), + }, }; return convertedOptions; diff --git a/sdk/eventhub/event-hubs/src/eventData.ts b/sdk/eventhub/event-hubs/src/eventData.ts index 2031335ae00e..e45c3e0d5b19 100644 --- a/sdk/eventhub/event-hubs/src/eventData.ts +++ b/sdk/eventhub/event-hubs/src/eventData.ts @@ -150,7 +150,7 @@ const messagePropertiesMap = { creation_time: "creationTime", group_id: "groupId", group_sequence: "groupSequence", - reply_to_group_id: "replyToGroupId" + reply_to_group_id: "replyToGroupId", } as const; /** @@ -171,7 +171,7 @@ export function fromRheaMessage( body, getRawAmqpMessage() { return rawMessage; - } + }, }; if (msg.message_annotations) { @@ -253,7 +253,7 @@ export function toRheaMessage( if (isAmqpAnnotatedMessage(data)) { rheaMessage = { ...AmqpAnnotatedMessage.toRheaMessage(data), - body: defaultDataTransformer.encode(data.body, data.bodyType ?? "data") + body: defaultDataTransformer.encode(data.body, data.bodyType ?? "data"), }; } else { let bodyType: BodyTypes = "data"; @@ -266,7 +266,7 @@ export function toRheaMessage( } rheaMessage = { - body: defaultDataTransformer.encode(data.body, bodyType) + body: defaultDataTransformer.encode(data.body, bodyType), }; // As per the AMQP 1.0 spec If the message-annotations or delivery-annotations section is omitted, // it is equivalent to a message-annotations section containing anempty map of annotations. @@ -457,7 +457,7 @@ function convertDatesToNumbers(thing: T): T { [0, 'foo', new Date(), { nested: new Date()}] */ if (Array.isArray(thing)) { - return (thing.map(convertDatesToNumbers) as unknown) as T; + return thing.map(convertDatesToNumbers) as unknown as T; } /* diff --git a/sdk/eventhub/event-hubs/src/eventDataBatch.ts b/sdk/eventhub/event-hubs/src/eventDataBatch.ts index a9517cf3da66..37a80c9c2d83 100644 --- a/sdk/eventhub/event-hubs/src/eventDataBatch.ts +++ b/sdk/eventhub/event-hubs/src/eventDataBatch.ts @@ -254,7 +254,7 @@ export class EventDataBatchImpl implements EventDataBatch { */ private _generateBatch(encodedEvents: Buffer[], annotations?: MessageAnnotations): Buffer { const batchEnvelope: RheaMessage = { - body: message.data_sections(encodedEvents) + body: message.data_sections(encodedEvents), }; if (annotations) { batchEnvelope.message_annotations = annotations; diff --git a/sdk/eventhub/event-hubs/src/eventHubBufferedProducerClient.ts b/sdk/eventhub/event-hubs/src/eventHubBufferedProducerClient.ts index a58d652ca31a..edeadbd913f1 100644 --- a/sdk/eventhub/event-hubs/src/eventHubBufferedProducerClient.ts +++ b/sdk/eventhub/event-hubs/src/eventHubBufferedProducerClient.ts @@ -7,7 +7,7 @@ import { GetEventHubPropertiesOptions, GetPartitionIdsOptions, GetPartitionPropertiesOptions, - SendBatchOptions + SendBatchOptions, } from "./models/public"; import { EventHubProperties, PartitionProperties } from "./managementClient"; import { NamedKeyCredential, SASCredential, TokenCredential } from "@azure/core-auth"; @@ -332,7 +332,7 @@ export class EventHubBufferedProducerClient { const partitionId = this._partitionAssigner.assignPartition({ partitionId: options.partitionId, - partitionKey: options.partitionKey + partitionKey: options.partitionKey, }); const partitionChannel = this._getPartitionChannel(partitionId); @@ -436,7 +436,7 @@ export class EventHubBufferedProducerClient { onSendEventsErrorHandler: this._clientOptions.onSendEventsErrorHandler, onSendEventsSuccessHandler: this._clientOptions.onSendEventsSuccessHandler, partitionId, - producer: this._producer + producer: this._producer, }); this._partitionChannels.set(partitionId, partitionChannel); return partitionChannel; diff --git a/sdk/eventhub/event-hubs/src/eventHubConsumerClient.ts b/sdk/eventhub/event-hubs/src/eventHubConsumerClient.ts index fb702688e931..3a50b7cc5b31 100644 --- a/sdk/eventhub/event-hubs/src/eventHubConsumerClient.ts +++ b/sdk/eventhub/event-hubs/src/eventHubConsumerClient.ts @@ -8,14 +8,14 @@ import { GetEventHubPropertiesOptions, GetPartitionIdsOptions, GetPartitionPropertiesOptions, - LoadBalancingOptions + LoadBalancingOptions, } from "./models/public"; import { EventHubProperties, PartitionProperties } from "./managementClient"; import { NamedKeyCredential, SASCredential, TokenCredential } from "@azure/core-auth"; import { SubscribeOptions, Subscription, - SubscriptionEventHandlers + SubscriptionEventHandlers, } from "./eventHubConsumerClientModels"; import { BalancedLoadBalancingStrategy } from "./loadBalancerStrategies/balancedStrategy"; import { Constants } from "@azure/core-amqp"; @@ -29,14 +29,13 @@ import { logger } from "./log"; import { v4 as uuid } from "uuid"; import { validateEventPositions } from "./eventPosition"; -const defaultConsumerClientOptions: Required> = { +const defaultConsumerClientOptions: Required< + Pick +> = { // to support our current "process single event only" workflow we'll also purposefully // only request a single event at a time. maxBatchSize: 1, - maxWaitTimeInSeconds: 60 + maxWaitTimeInSeconds: 60, }; /** @@ -334,7 +333,7 @@ export class EventHubConsumerClient { updateIntervalInMs: 10000, partitionOwnershipExpirationIntervalInMs: 60000, // options supplied by user - ...this._clientOptions?.loadBalancingOptions + ...this._clientOptions?.loadBalancingOptions, }; } @@ -368,7 +367,7 @@ export class EventHubConsumerClient { return this._context .managementSession!.getEventHubProperties({ ...options, - retryOptions: this._clientOptions.retryOptions + retryOptions: this._clientOptions.retryOptions, }) .then((eventHubProperties) => { return eventHubProperties.partitionIds; @@ -389,7 +388,7 @@ export class EventHubConsumerClient { ): Promise { return this._context.managementSession!.getPartitionProperties(partitionId, { ...options, - retryOptions: this._clientOptions.retryOptions + retryOptions: this._clientOptions.retryOptions, }); } @@ -403,7 +402,7 @@ export class EventHubConsumerClient { getEventHubProperties(options: GetEventHubPropertiesOptions = {}): Promise { return this._context.managementSession!.getEventHubProperties({ ...options, - retryOptions: this._clientOptions.retryOptions + retryOptions: this._clientOptions.retryOptions, }); } @@ -514,7 +513,7 @@ export class EventHubConsumerClient { this._partitionGate.remove(targetedPartitionId); this._subscriptions.delete(subscription); return eventProcessor.stop(); - } + }, }; this._subscriptions.add(subscription); return subscription; @@ -530,8 +529,8 @@ export class EventHubConsumerClient { return new UnbalancedLoadBalancingStrategy(); } - const partitionOwnershipExpirationIntervalInMs = this._loadBalancingOptions - .partitionOwnershipExpirationIntervalInMs; + const partitionOwnershipExpirationIntervalInMs = + this._loadBalancingOptions.partitionOwnershipExpirationIntervalInMs; if (this._loadBalancingOptions?.strategy === "greedy") { return new GreedyLoadBalancingStrategy(partitionOwnershipExpirationIntervalInMs); } @@ -569,7 +568,7 @@ export class EventHubConsumerClient { ownerId: this._id, retryOptions: this._clientOptions.retryOptions, loadBalancingStrategy, - loopIntervalInMs: this._loadBalancingOptions.updateIntervalInMs + loopIntervalInMs: this._loadBalancingOptions.updateIntervalInMs, } ); @@ -606,7 +605,7 @@ export class EventHubConsumerClient { ownerLevel: getOwnerLevel(subscribeOptions, this._userChoseCheckpointStore), retryOptions: this._clientOptions.retryOptions, loadBalancingStrategy: new UnbalancedLoadBalancingStrategy(), - loopIntervalInMs: this._loadBalancingOptions.updateIntervalInMs ?? 10000 + loopIntervalInMs: this._loadBalancingOptions.updateIntervalInMs ?? 10000, } ); diff --git a/sdk/eventhub/event-hubs/src/eventHubProducerClient.ts b/sdk/eventhub/event-hubs/src/eventHubProducerClient.ts index 881d384a354c..6d2b68a00101 100644 --- a/sdk/eventhub/event-hubs/src/eventHubProducerClient.ts +++ b/sdk/eventhub/event-hubs/src/eventHubProducerClient.ts @@ -8,7 +8,7 @@ import { GetEventHubPropertiesOptions, GetPartitionIdsOptions, GetPartitionPropertiesOptions, - SendBatchOptions + SendBatchOptions, } from "./models/public"; import { EventDataBatch, EventDataBatchImpl, isEventDataBatch } from "./eventDataBatch"; import { EventHubProperties, PartitionProperties } from "./managementClient"; @@ -195,7 +195,7 @@ export class EventHubProducerClient { let maxMessageSize = await sender.getMaxMessageSize({ retryOptions: this._clientOptions.retryOptions, - abortSignal: options.abortSignal + abortSignal: options.abortSignal, }); if (options.maxSizeInBytes) { @@ -348,14 +348,14 @@ export class EventHubProducerClient { ...options, partitionId, partitionKey, - retryOptions: this._clientOptions.retryOptions + retryOptions: this._clientOptions.retryOptions, }); sendSpan.setStatus({ code: SpanStatusCode.OK }); return result; } catch (error) { sendSpan.setStatus({ code: SpanStatusCode.ERROR, - message: error.message + message: error.message, }); throw error; } finally { @@ -388,7 +388,7 @@ export class EventHubProducerClient { getEventHubProperties(options: GetEventHubPropertiesOptions = {}): Promise { return this._context.managementSession!.getEventHubProperties({ ...options, - retryOptions: this._clientOptions.retryOptions + retryOptions: this._clientOptions.retryOptions, }); } @@ -404,7 +404,7 @@ export class EventHubProducerClient { return this._context .managementSession!.getEventHubProperties({ ...options, - retryOptions: this._clientOptions.retryOptions + retryOptions: this._clientOptions.retryOptions, }) .then((eventHubProperties) => { return eventHubProperties.partitionIds; @@ -425,7 +425,7 @@ export class EventHubProducerClient { ): Promise { return this._context.managementSession!.getPartitionProperties(partitionId, { ...options, - retryOptions: this._clientOptions.retryOptions + retryOptions: this._clientOptions.retryOptions, }); } @@ -435,13 +435,13 @@ export class EventHubProducerClient { ): Span { const links: Link[] = spanContextsToLink.map((context) => { return { - context + context, }; }); const { span } = createEventHubSpan("send", operationOptions, this._context.config, { kind: SpanKind.CLIENT, - links + links, }); return span; diff --git a/sdk/eventhub/event-hubs/src/eventHubReceiver.ts b/sdk/eventhub/event-hubs/src/eventHubReceiver.ts index 14d6d86a253e..b921c113ccfd 100644 --- a/sdk/eventhub/event-hubs/src/eventHubReceiver.ts +++ b/sdk/eventhub/event-hubs/src/eventHubReceiver.ts @@ -10,14 +10,14 @@ import { StandardAbortMessage, delay, retry, - translate + translate, } from "@azure/core-amqp"; import { EventContext, OnAmqpEvent, Receiver, ReceiverOptions as RheaReceiverOptions, - types + types, } from "rhea-promise"; import { EventDataInternal, ReceivedEventData, fromRheaMessage } from "./eventData"; import { EventPosition, getEventPositionFilter } from "./eventPosition"; @@ -202,7 +202,7 @@ export class EventHubReceiver extends LinkEntity { ) { super(context, { partitionId: partitionId, - name: context.config.getReceiverAddress(partitionId, consumerGroup) + name: context.config.getReceiverAddress(partitionId, consumerGroup), }); this.consumerGroup = consumerGroup; this.address = context.config.getReceiverAddress(partitionId, this.consumerGroup); @@ -232,7 +232,7 @@ export class EventHubReceiver extends LinkEntity { systemProperties: data.systemProperties, getRawAmqpMessage() { return rawMessage; - } + }, }; if (data.correlationId != null) { receivedEventData.correlationId = data.correlationId; @@ -459,7 +459,7 @@ export class EventHubReceiver extends LinkEntity { try { await this.initialize({ abortSignal, - timeoutInMs: getRetryAttemptTimeoutInMs(this.options.retryOptions) + timeoutInMs: getRetryAttemptTimeoutInMs(this.options.retryOptions), }); } catch (err) { if (this._onError === onError) { @@ -547,7 +547,7 @@ export class EventHubReceiver extends LinkEntity { */ async initialize({ abortSignal, - timeoutInMs + timeoutInMs, }: { abortSignal: AbortSignalLike | undefined; timeoutInMs: number; @@ -565,7 +565,7 @@ export class EventHubReceiver extends LinkEntity { onError: (context: EventContext) => this._onAmqpError(context), onMessage: (context: EventContext) => this._onAmqpMessage(context), onSessionClose: (context: EventContext) => this._onAmqpSessionClose(context), - onSessionError: (context: EventContext) => this._onAmqpSessionError(context) + onSessionError: (context: EventContext) => this._onAmqpSessionError(context), }; if (this.checkpoint > -1) { receiverOptions.eventPosition = { sequenceNumber: this.checkpoint }; @@ -623,19 +623,19 @@ export class EventHubReceiver extends LinkEntity { name: this.name, autoaccept: true, source: { - address: this.address + address: this.address, }, credit_window: 0, onMessage: options.onMessage, onError: options.onError, onClose: options.onClose, onSessionError: options.onSessionError, - onSessionClose: options.onSessionClose + onSessionClose: options.onSessionClose, }; if (typeof this.ownerLevel === "number") { rcvrOptions.properties = { - [Constants.attachEpoch]: types.wrap_long(this.ownerLevel) + [Constants.attachEpoch]: types.wrap_long(this.ownerLevel), }; } @@ -649,7 +649,7 @@ export class EventHubReceiver extends LinkEntity { const filterClause = getEventPositionFilter(eventPosition); if (filterClause) { (rcvrOptions.source as any).filter = { - "apache.org:selector-filter:string": types.wrap_described(filterClause, 0x468c00000004) + "apache.org:selector-filter:string": types.wrap_described(filterClause, 0x468c00000004), }; } } @@ -806,21 +806,21 @@ export class EventHubReceiver extends LinkEntity { operation: retrieveEvents, operationType: RetryOperationType.receiveMessage, abortSignal: abortSignal, - retryOptions: retryOptions + retryOptions: retryOptions, }, { connectionId: { enumerable: true, get: () => { return this._context.connectionId; - } + }, }, connectionHost: { enumerable: true, get: () => { return this._context.config.host; - } - } + }, + }, } ); return retry(config); diff --git a/sdk/eventhub/event-hubs/src/eventHubSender.ts b/sdk/eventhub/event-hubs/src/eventHubSender.ts index 0e35016899f0..67dab584865c 100644 --- a/sdk/eventhub/event-hubs/src/eventHubSender.ts +++ b/sdk/eventhub/event-hubs/src/eventHubSender.ts @@ -8,7 +8,7 @@ import { EventContext, OnAmqpEvent, Message as RheaMessage, - message + message, } from "rhea-promise"; import { ErrorNameConditionMapper, @@ -18,7 +18,7 @@ import { defaultCancellableLock, delay, retry, - translate + translate, } from "@azure/core-amqp"; import { EventData, toRheaMessage } from "./eventData"; import { EventDataBatch, isEventDataBatch } from "./eventDataBatch"; @@ -78,7 +78,7 @@ export class EventHubSender extends LinkEntity { constructor(context: ConnectionContext, partitionId?: string) { super(context, { name: context.config.getSenderAddress(partitionId), - partitionId: partitionId + partitionId: partitionId, }); this.address = context.config.getSenderAddress(partitionId); this.audience = context.config.getSenderAudience(partitionId); @@ -258,7 +258,7 @@ export class EventHubSender extends LinkEntity { } // Encode every amqp message and then convert every encoded message to amqp data section const batchMessage: RheaMessage = { - body: message.data_sections(messages.map(message.encode)) + body: message.data_sections(messages.map(message.encode)), }; // Set message_annotations of the first message as @@ -302,12 +302,12 @@ export class EventHubSender extends LinkEntity { const srOptions: AwaitableSenderOptions = { name: this.name, target: { - address: this.address + address: this.address, }, onError: this._onAmqpError, onClose: this._onAmqpClose, onSessionError: this._onSessionError, - onSessionClose: this._onSessionClose + onSessionClose: this._onSessionClose, }; logger.verbose("Creating sender with options: %O", srOptions); return srOptions; @@ -372,7 +372,7 @@ export class EventHubSender extends LinkEntity { logger.warning(msg); const amqpError: AmqpError = { condition: ErrorNameConditionMapper.SenderBusyError, - description: msg + description: msg, }; throw translate(amqpError); } @@ -390,7 +390,7 @@ export class EventHubSender extends LinkEntity { logger.warning(desc); const e: AmqpError = { condition: ErrorNameConditionMapper.ServiceUnavailableError, - description: desc + description: desc, }; throw translate(e); } @@ -399,7 +399,7 @@ export class EventHubSender extends LinkEntity { const delivery = await sender.send(rheaMessage, { format: 0x80013700, timeoutInSeconds: (timeoutInMs - timeTakenByInit - waitTimeForSendable) / 1000, - abortSignal + abortSignal, }); logger.info( "[%s] Sender '%s', sent message with delivery id: %d", @@ -417,7 +417,7 @@ export class EventHubSender extends LinkEntity { connectionId: this._context.connectionId, operationType: RetryOperationType.sendMessage, abortSignal: abortSignal, - retryOptions: retryOptions + retryOptions: retryOptions, }; try { @@ -459,7 +459,7 @@ export class EventHubSender extends LinkEntity { return this._init({ ...senderOptions, abortSignal: options.abortSignal, - timeoutInMs: taskTimeoutInMs + timeoutInMs: taskTimeoutInMs, }); }, { abortSignal: options.abortSignal, timeoutInMs: timeoutInMs } @@ -471,7 +471,7 @@ export class EventHubSender extends LinkEntity { connectionId: this._context.connectionId, operationType: RetryOperationType.senderLink, abortSignal: options.abortSignal, - retryOptions: retryOptions + retryOptions: retryOptions, }; try { @@ -506,7 +506,7 @@ export class EventHubSender extends LinkEntity { await this._negotiateClaim({ setTokenRenewal: false, abortSignal: options.abortSignal, - timeoutInMs: options.timeoutInMs + timeoutInMs: options.timeoutInMs, }); logger.verbose( diff --git a/sdk/eventhub/event-hubs/src/eventPosition.ts b/sdk/eventhub/event-hubs/src/eventPosition.ts index e666d3986cb9..c514b31296c3 100644 --- a/sdk/eventhub/event-hubs/src/eventPosition.ts +++ b/sdk/eventhub/event-hubs/src/eventPosition.ts @@ -70,7 +70,7 @@ export function getEventPositionFilter(eventPosition: EventPosition): string { if (!result) { throw translate({ condition: ErrorNameConditionMapper.ArgumentError, - description: "No starting position was set in the EventPosition." + description: "No starting position was set in the EventPosition.", }); } return result; @@ -93,7 +93,7 @@ export function isLatestPosition(eventPosition: EventPosition): boolean { * first event in the partition which has not expired due to the retention policy. */ export const earliestEventPosition: EventPosition = { - offset: -1 + offset: -1, }; /** @@ -103,7 +103,7 @@ export const earliestEventPosition: EventPosition = { * @returns EventPosition */ export const latestEventPosition: EventPosition = { - offset: "@latest" + offset: "@latest", }; /** diff --git a/sdk/eventhub/event-hubs/src/eventProcessor.ts b/sdk/eventhub/event-hubs/src/eventProcessor.ts index 2c2d0b97c49a..06166d3f57f8 100644 --- a/sdk/eventhub/event-hubs/src/eventProcessor.ts +++ b/sdk/eventhub/event-hubs/src/eventProcessor.ts @@ -269,7 +269,7 @@ export class EventProcessor { fullyQualifiedNamespace: this._fullyQualifiedNamespace, consumerGroup: this._consumerGroup, eventHubName: this._eventHubName, - etag: previousPartitionOwnership ? previousPartitionOwnership.etag : undefined + etag: previousPartitionOwnership ? previousPartitionOwnership.etag : undefined, }; return partitionOwnership; @@ -341,7 +341,7 @@ export class EventProcessor { eventHubName: this._eventHubName, consumerGroup: this._consumerGroup, partitionId: partitionId, - eventProcessorId: this.id + eventProcessorId: this.id, } ); @@ -434,7 +434,7 @@ export class EventProcessor { const iterationStartTimeInMs = Date.now(); try { const { partitionIds } = await this._context.managementSession!.getEventHubProperties({ - abortSignal: abortSignal + abortSignal: abortSignal, }); await this._performLoadBalancing(loadBalancingStrategy, partitionIds, abortSignal); } catch (err) { @@ -540,7 +540,7 @@ export class EventProcessor { partitionId: "", updateCheckpoint: async () => { /* no-op */ - } + }, }); } catch (errorFromUser) { logger.verbose( diff --git a/sdk/eventhub/event-hubs/src/eventhubConnectionConfig.ts b/sdk/eventhub/event-hubs/src/eventhubConnectionConfig.ts index f5da83f2b7c1..4f08ad620247 100644 --- a/sdk/eventhub/event-hubs/src/eventhubConnectionConfig.ts +++ b/sdk/eventhub/event-hubs/src/eventhubConnectionConfig.ts @@ -167,5 +167,5 @@ export const EventHubConnectionConfig = { */ validate(config: EventHubConnectionConfig): void { return ConnectionConfig.validate(config, { isEntityPathRequired: true }); - } + }, }; diff --git a/sdk/eventhub/event-hubs/src/impl/partitionAssigner.ts b/sdk/eventhub/event-hubs/src/impl/partitionAssigner.ts index c78f1b033500..c5603993dfe1 100644 --- a/sdk/eventhub/event-hubs/src/impl/partitionAssigner.ts +++ b/sdk/eventhub/event-hubs/src/impl/partitionAssigner.ts @@ -33,7 +33,7 @@ export class PartitionAssigner { */ assignPartition({ partitionId, - partitionKey + partitionKey, }: { partitionId?: string; partitionKey?: string; diff --git a/sdk/eventhub/event-hubs/src/inMemoryCheckpointStore.ts b/sdk/eventhub/event-hubs/src/inMemoryCheckpointStore.ts index b930bd424b16..983611713a6b 100644 --- a/sdk/eventhub/event-hubs/src/inMemoryCheckpointStore.ts +++ b/sdk/eventhub/event-hubs/src/inMemoryCheckpointStore.ts @@ -65,7 +65,7 @@ export class InMemoryCheckpointStore implements CheckpointStore { const newOwnership = { ...ownership, etag: generate_uuid(), - lastModifiedTimeInMs: date.getTime() + lastModifiedTimeInMs: date.getTime(), }; this._partitionOwnershipMap.set(newOwnership.partitionId, newOwnership); diff --git a/sdk/eventhub/event-hubs/src/index.ts b/sdk/eventhub/event-hubs/src/index.ts index 28e465b0091b..92ca9e5fb5d3 100644 --- a/sdk/eventhub/event-hubs/src/index.ts +++ b/sdk/eventhub/event-hubs/src/index.ts @@ -15,7 +15,7 @@ export { CreateBatchOptions, GetPartitionIdsOptions, GetPartitionPropertiesOptions, - GetEventHubPropertiesOptions + GetEventHubPropertiesOptions, } from "./models/public"; export { EventHubConsumerClient } from "./eventHubConsumerClient"; export { EventHubProducerClient } from "./eventHubProducerClient"; @@ -26,7 +26,7 @@ export { EnqueueEventOptions, BufferedFlushOptions, OnSendEventsErrorContext, - OnSendEventsSuccessContext + OnSendEventsSuccessContext, } from "./eventHubBufferedProducerClient"; export { SubscribeOptions, @@ -36,7 +36,7 @@ export { ProcessErrorHandler, ProcessInitializeHandler, ProcessCloseHandler, - ProcessEventsHandler + ProcessEventsHandler, } from "./eventHubConsumerClientModels"; export { EventPosition, latestEventPosition, earliestEventPosition } from "./eventPosition"; export { PartitionProperties, EventHubProperties } from "./managementClient"; @@ -49,5 +49,5 @@ export { TokenCredential } from "@azure/core-auth"; export { logger } from "./log"; export { parseEventHubConnectionString, - EventHubConnectionStringProperties + EventHubConnectionStringProperties, } from "./util/connectionStringUtils"; diff --git a/sdk/eventhub/event-hubs/src/linkEntity.ts b/sdk/eventhub/event-hubs/src/linkEntity.ts index c40eeb5bdbe4..7f6790fd9652 100644 --- a/sdk/eventhub/event-hubs/src/linkEntity.ts +++ b/sdk/eventhub/event-hubs/src/linkEntity.ts @@ -114,7 +114,7 @@ export class LinkEntity { protected async _negotiateClaim({ abortSignal, setTokenRenewal, - timeoutInMs + timeoutInMs, }: { setTokenRenewal: boolean | undefined; abortSignal: AbortSignalLike | undefined; @@ -140,12 +140,12 @@ export class LinkEntity { () => { return this._context.cbsSession.init({ abortSignal, - timeoutInMs: timeoutInMs - (Date.now() - startTime) + timeoutInMs: timeoutInMs - (Date.now() - startTime), }); }, { abortSignal, - timeoutInMs + timeoutInMs, } ); } @@ -194,7 +194,7 @@ export class LinkEntity { }, { abortSignal, - timeoutInMs: timeoutInMs - (Date.now() - startTime) + timeoutInMs: timeoutInMs - (Date.now() - startTime), } ); logger.verbose( @@ -227,7 +227,7 @@ export class LinkEntity { await this._negotiateClaim({ setTokenRenewal: true, abortSignal: undefined, - timeoutInMs: getRetryAttemptTimeoutInMs(undefined) + timeoutInMs: getRetryAttemptTimeoutInMs(undefined), }); } catch (err) { logger.verbose( diff --git a/sdk/eventhub/event-hubs/src/loadBalancerStrategies/loadBalancingStrategy.ts b/sdk/eventhub/event-hubs/src/loadBalancerStrategies/loadBalancingStrategy.ts index 871ffa978b9e..e9eebef7ef8b 100644 --- a/sdk/eventhub/event-hubs/src/loadBalancerStrategies/loadBalancingStrategy.ts +++ b/sdk/eventhub/event-hubs/src/loadBalancerStrategies/loadBalancingStrategy.ts @@ -105,7 +105,7 @@ function calculateBalancedLoadCounts( return { minPartitionsPerOwner, - requiredNumberOfOwnersWithExtraPartition + requiredNumberOfOwnersWithExtraPartition, }; } @@ -134,7 +134,7 @@ function getEventProcessorCounts( const counts: EventProcessorCounts = { haveRequiredPartitions: 0, haveAdditionalPartition: 0, - haveTooManyPartitions: 0 + haveTooManyPartitions: 0, }; for (const ownershipList of ownerToOwnershipMap.values()) { @@ -324,10 +324,8 @@ export function listAvailablePartitions( logger.info(`[${ownerId}] Number of active event processors: ${ownerToOwnershipMap.size}.`); - const { - minPartitionsPerOwner, - requiredNumberOfOwnersWithExtraPartition - } = calculateBalancedLoadCounts(ownerToOwnershipMap, partitionIds); + const { minPartitionsPerOwner, requiredNumberOfOwnersWithExtraPartition } = + calculateBalancedLoadCounts(ownerToOwnershipMap, partitionIds); logger.verbose( `[${ownerId}] Expected minimum number of partitions per event processor: ${minPartitionsPerOwner},` + diff --git a/sdk/eventhub/event-hubs/src/managementClient.ts b/sdk/eventhub/event-hubs/src/managementClient.ts index c26e31a053b6..3712f4f534e5 100644 --- a/sdk/eventhub/event-hubs/src/managementClient.ts +++ b/sdk/eventhub/event-hubs/src/managementClient.ts @@ -11,7 +11,7 @@ import { defaultCancellableLock, isSasTokenProvider, retry, - translate + translate, } from "@azure/core-amqp"; import { EventContext, @@ -20,7 +20,7 @@ import { ReceiverOptions, SenderEvents, SenderOptions, - generate_uuid + generate_uuid, } from "rhea-promise"; import { logErrorStackTrace, logger } from "./log"; import { throwErrorIfConnectionClosed, throwTypeErrorIfParameterMissing } from "./util/error"; @@ -125,7 +125,7 @@ export class ManagementClient extends LinkEntity { super(context, { address: options && options.address ? options.address : Constants.management, audience: - options && options.audience ? options.audience : context.config.getManagementAudience() + options && options.audience ? options.audience : context.config.getManagementAudience(), }); this._context = context; this.entityPath = context.config.entityPath as string; @@ -175,18 +175,18 @@ export class ManagementClient extends LinkEntity { operation: Constants.readOperation, name: this.entityPath as string, type: `${Constants.vendorString}:${Constants.eventHub}`, - security_token: securityToken?.token - } + security_token: securityToken?.token, + }, }; const info: any = await this._makeManagementRequest(request, { ...options, - requestName: "getHubRuntimeInformation" + requestName: "getHubRuntimeInformation", }); const runtimeInfo: EventHubProperties = { name: info.name, createdOn: new Date(info.created_at), - partitionIds: info.partition_ids + partitionIds: info.partition_ids, }; logger.verbose("[%s] The hub runtime info is: %O", this._context.connectionId, runtimeInfo); @@ -195,7 +195,7 @@ export class ManagementClient extends LinkEntity { } catch (error) { clientSpan.setStatus({ code: SpanStatusCode.ERROR, - message: error.message + message: error.message, }); logger.warning( `An error occurred while getting the hub runtime information: ${error?.name}: ${error?.message}` @@ -241,13 +241,13 @@ export class ManagementClient extends LinkEntity { name: this.entityPath as string, type: `${Constants.vendorString}:${Constants.partition}`, partition: `${partitionId}`, - security_token: securityToken?.token - } + security_token: securityToken?.token, + }, }; const info: any = await this._makeManagementRequest(request, { ...options, - requestName: "getPartitionInformation" + requestName: "getPartitionInformation", }); const partitionInfo: PartitionProperties = { @@ -257,7 +257,7 @@ export class ManagementClient extends LinkEntity { lastEnqueuedOnUtc: new Date(info.last_enqueued_time_utc), lastEnqueuedSequenceNumber: info.last_enqueued_sequence_number, partitionId: info.partition, - isEmpty: info.is_partition_empty + isEmpty: info.is_partition_empty, }; logger.verbose("[%s] The partition info is: %O.", this._context.connectionId, partitionInfo); @@ -267,7 +267,7 @@ export class ManagementClient extends LinkEntity { } catch (error) { clientSpan.setStatus({ code: SpanStatusCode.ERROR, - message: error.message + message: error.message, }); logger.warning( `An error occurred while getting the partition information: ${error?.name}: ${error?.message}` @@ -304,7 +304,7 @@ export class ManagementClient extends LinkEntity { private async _init({ abortSignal, - timeoutInMs + timeoutInMs, }: { abortSignal: AbortSignalLike | undefined; timeoutInMs: number; @@ -327,10 +327,10 @@ export class ManagementClient extends LinkEntity { id, ehError ); - } + }, }; const sropt: SenderOptions = { - target: { address: this.address } + target: { address: this.address }, }; logger.verbose( "[%s] Creating sender/receiver links on a session for $management endpoint with " + @@ -437,7 +437,7 @@ export class ManagementClient extends LinkEntity { const sendRequestOptions: SendRequestOptions = { abortSignal: options.abortSignal, requestName: options.requestName, - timeoutInMs: remainingOperationTimeoutInMs + timeoutInMs: remainingOperationTimeoutInMs, }; count++; @@ -457,15 +457,15 @@ export class ManagementClient extends LinkEntity { operation: sendOperationPromise, operationType: RetryOperationType.management, abortSignal: abortSignal, - retryOptions: retryOptions + retryOptions: retryOptions, }, { connectionId: { enumerable: true, get: () => { return this._context.connectionId; - } - } + }, + }, } ); return (await retry(config)).body; diff --git a/sdk/eventhub/event-hubs/src/models/public.ts b/sdk/eventhub/event-hubs/src/models/public.ts index cd35dff74390..c1047b3a1f66 100644 --- a/sdk/eventhub/event-hubs/src/models/public.ts +++ b/sdk/eventhub/event-hubs/src/models/public.ts @@ -83,7 +83,7 @@ export enum CloseReason { /** * The EventProcessor was shutdown. */ - Shutdown = "Shutdown" + Shutdown = "Shutdown", } /** diff --git a/sdk/eventhub/event-hubs/src/partitionProcessor.ts b/sdk/eventhub/event-hubs/src/partitionProcessor.ts index 4f88cf2e5043..c074a3fc7c4f 100644 --- a/sdk/eventhub/event-hubs/src/partitionProcessor.ts +++ b/sdk/eventhub/event-hubs/src/partitionProcessor.ts @@ -4,7 +4,7 @@ import { BasicPartitionProperties, PartitionContext, - SubscriptionEventHandlers + SubscriptionEventHandlers, } from "./eventHubConsumerClientModels"; import { CheckpointStore } from "./eventProcessor"; import { CloseReason } from "./models/public"; @@ -192,7 +192,7 @@ export class PartitionProcessor implements PartitionContext { consumerGroup: this._context.consumerGroup, partitionId: this._context.partitionId, sequenceNumber: eventData.sequenceNumber, - offset: eventData.offset + offset: eventData.offset, }; await this._checkpointStore!.updateCheckpoint(checkpoint); diff --git a/sdk/eventhub/event-hubs/src/partitionPump.ts b/sdk/eventhub/event-hubs/src/partitionPump.ts index 5177f1675957..fe44c0992280 100644 --- a/sdk/eventhub/event-hubs/src/partitionPump.ts +++ b/sdk/eventhub/event-hubs/src/partitionPump.ts @@ -77,7 +77,7 @@ export class PartitionPump { lastSeenSequenceNumber >= 0 ? { sequenceNumber: lastSeenSequenceNumber, - isInclusive: false + isInclusive: false, } : this._startPosition; @@ -91,7 +91,7 @@ export class PartitionPump { ownerLevel: this._processorOptions.ownerLevel, trackLastEnqueuedEventProperties: this._processorOptions.trackLastEnqueuedEventProperties, retryOptions: this._processorOptions.retryOptions, - skipParsingBodyAsJson: this._processorOptions.skipParsingBodyAsJson + skipParsingBodyAsJson: this._processorOptions.skipParsingBodyAsJson, } ); @@ -225,14 +225,14 @@ export function createProcessingSpan( links.push({ context: spanContext, attributes: { - enqueuedTime: receivedEvent.enqueuedTimeUtc.getTime() - } + enqueuedTime: receivedEvent.enqueuedTimeUtc.getTime(), + }, }); } const { span } = createEventHubSpan("process", options, eventHubProperties, { kind: SpanKind.CONSUMER, - links + links, }); return span; @@ -248,7 +248,7 @@ export async function trace(fn: () => Promise, span: Span): Promise } catch (err) { span.setStatus({ code: SpanStatusCode.ERROR, - message: err.message + message: err.message, }); throw err; } finally { diff --git a/sdk/eventhub/event-hubs/src/util/connectionStringUtils.ts b/sdk/eventhub/event-hubs/src/util/connectionStringUtils.ts index 5b030e3b4100..0edb82e6627a 100644 --- a/sdk/eventhub/event-hubs/src/util/connectionStringUtils.ts +++ b/sdk/eventhub/event-hubs/src/util/connectionStringUtils.ts @@ -69,7 +69,7 @@ export function parseEventHubConnectionString( const output: EventHubConnectionStringProperties = { fullyQualifiedNamespace: (parsedResult.Endpoint.match(".*://([^/]*)") || [])[1], - endpoint: parsedResult.Endpoint + endpoint: parsedResult.Endpoint, }; if (parsedResult.EntityPath) { diff --git a/sdk/eventhub/event-hubs/src/util/constants.ts b/sdk/eventhub/event-hubs/src/util/constants.ts index fbc1dd786221..3e70cf81ae91 100644 --- a/sdk/eventhub/event-hubs/src/util/constants.ts +++ b/sdk/eventhub/event-hubs/src/util/constants.ts @@ -6,5 +6,5 @@ */ export const packageJsonInfo = { name: "@azure/event-hubs", - version: "5.7.0-beta.2" + version: "5.7.0-beta.2", }; diff --git a/sdk/eventhub/event-hubs/src/util/getPromiseParts.ts b/sdk/eventhub/event-hubs/src/util/getPromiseParts.ts index 202ca3f3128e..8a7db136d9ab 100644 --- a/sdk/eventhub/event-hubs/src/util/getPromiseParts.ts +++ b/sdk/eventhub/event-hubs/src/util/getPromiseParts.ts @@ -19,6 +19,6 @@ export function getPromiseParts(): { return { promise, resolve: resolver!, - reject: rejector! + reject: rejector!, }; } diff --git a/sdk/eventhub/event-hubs/src/util/typeGuards.ts b/sdk/eventhub/event-hubs/src/util/typeGuards.ts index f6d1ab13f622..c896cdbd7fb6 100644 --- a/sdk/eventhub/event-hubs/src/util/typeGuards.ts +++ b/sdk/eventhub/event-hubs/src/util/typeGuards.ts @@ -7,7 +7,7 @@ import { TokenCredential, isNamedKeyCredential, isSASCredential, - isTokenCredential + isTokenCredential, } from "@azure/core-auth"; /** diff --git a/sdk/eventhub/event-hubs/test/connectionStringUtils.spec.ts b/sdk/eventhub/event-hubs/test/connectionStringUtils.spec.ts index b27a70a9eaa2..c48246d041c3 100644 --- a/sdk/eventhub/event-hubs/test/connectionStringUtils.spec.ts +++ b/sdk/eventhub/event-hubs/test/connectionStringUtils.spec.ts @@ -3,7 +3,7 @@ import { EventHubConnectionStringProperties, - parseEventHubConnectionString + parseEventHubConnectionString, } from "../src/util/connectionStringUtils"; import chai from "chai"; @@ -24,7 +24,7 @@ describe("parseEventHubConnectionString", () => { endpoint: endpoint, eventHubName: eventHubName, sharedAccessKeyName: sharedAccessKeyName, - sharedAccessKey: sharedAccessKey + sharedAccessKey: sharedAccessKey, }; const connectionString = `Endpoint=${endpoint};EntityPath=${eventHubName};SharedAccessKeyName=${sharedAccessKeyName};SharedAccessKey=${sharedAccessKey}`; @@ -36,7 +36,7 @@ describe("parseEventHubConnectionString", () => { const expected: EventHubConnectionStringProperties = { fullyQualifiedNamespace: namespace, endpoint: endpoint, - sharedAccessSignature: sharedAccessSignature + sharedAccessSignature: sharedAccessSignature, }; const connectionString = `Endpoint=${endpoint};SharedAccessSignature=${sharedAccessSignature}`; diff --git a/sdk/eventhub/event-hubs/test/impl/parseEndpoint.spec.ts b/sdk/eventhub/event-hubs/test/impl/parseEndpoint.spec.ts index f516939fea02..8fe3011730b1 100644 --- a/sdk/eventhub/event-hubs/test/impl/parseEndpoint.spec.ts +++ b/sdk/eventhub/event-hubs/test/impl/parseEndpoint.spec.ts @@ -17,25 +17,25 @@ describe("parseEndpoint", () => { parseEndpoint("sb://test.servicebus.windows.net:5671").should.eql({ host: "test.servicebus.windows.net:5671", hostname: "test.servicebus.windows.net", - port: "5671" + port: "5671", } as ReturnType); parseEndpoint("https://127.0.0.1:5671").should.eql({ host: "127.0.0.1:5671", hostname: "127.0.0.1", - port: "5671" + port: "5671", } as ReturnType); parseEndpoint("amqps://127.0.0.1:5671/path/?query=foo").should.eql({ host: "127.0.0.1:5671", hostname: "127.0.0.1", - port: "5671" + port: "5671", } as ReturnType); parseEndpoint("wss://127.0.0.1/path/?query=foo").should.eql({ host: "127.0.0.1", hostname: "127.0.0.1", - port: undefined + port: undefined, } as ReturnType); }); }); diff --git a/sdk/eventhub/event-hubs/test/internal/amqp.spec.ts b/sdk/eventhub/event-hubs/test/internal/amqp.spec.ts index abc0a85cb72c..4a74fa4bf47b 100644 --- a/sdk/eventhub/event-hubs/test/internal/amqp.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/amqp.spec.ts @@ -18,9 +18,9 @@ testWithServiceTypes(() => { fromRheaMessage( { message_annotations: { - [Constants.enqueuedTime]: Date.now() + [Constants.enqueuedTime]: Date.now(), }, - body: undefined + body: undefined, }, false ) @@ -32,9 +32,9 @@ testWithServiceTypes(() => { fromRheaMessage( { message_annotations: { - [Constants.enqueuedTime]: Date.now() + [Constants.enqueuedTime]: Date.now(), }, - body: undefined + body: undefined, }, false ).getRawAmqpMessage() @@ -44,26 +44,26 @@ testWithServiceTypes(() => { assert.isTrue( isAmqpAnnotatedMessage({ body: "hello world", - bodyType: "sequence" + bodyType: "sequence", }) ); assert.isTrue( isAmqpAnnotatedMessage({ body: "hello world", - bodyType: "value" + bodyType: "value", }) ); assert.isTrue( isAmqpAnnotatedMessage({ body: "hello world", - bodyType: "data" + bodyType: "data", }) ); assert.isTrue( isAmqpAnnotatedMessage({ body: "hello world", - bodyType: undefined // the property _must_ exist, but undefined is fine. We'll default to 'data' + bodyType: undefined, // the property _must_ exist, but undefined is fine. We'll default to 'data' }) ); }); diff --git a/sdk/eventhub/event-hubs/test/internal/auth.spec.ts b/sdk/eventhub/event-hubs/test/internal/auth.spec.ts index 54940ce843ba..4ac1c7c21c7f 100644 --- a/sdk/eventhub/event-hubs/test/internal/auth.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/auth.spec.ts @@ -7,7 +7,7 @@ import { EventHubConnectionStringProperties, EventHubConsumerClient, EventHubProducerClient, - parseEventHubConnectionString + parseEventHubConnectionString, } from "../../src"; import chai from "chai"; import { createMockServer } from "../public/utils/mockService"; @@ -31,16 +31,12 @@ testWithServiceTypes((serviceVersion) => { } describe("Authentication via", () => { - const { - endpoint, - fullyQualifiedNamespace, - sharedAccessKey, - sharedAccessKeyName - } = parseEventHubConnectionString(env[EnvVarKeys.EVENTHUB_CONNECTION_STRING]); + const { endpoint, fullyQualifiedNamespace, sharedAccessKey, sharedAccessKeyName } = + parseEventHubConnectionString(env[EnvVarKeys.EVENTHUB_CONNECTION_STRING]); const service = { connectionString: env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], path: env[EnvVarKeys.EVENTHUB_NAME], - endpoint: endpoint.replace(/\/+$/, "") + endpoint: endpoint.replace(/\/+$/, ""), }; before(() => { diff --git a/sdk/eventhub/event-hubs/test/internal/cancellation.spec.ts b/sdk/eventhub/event-hubs/test/internal/cancellation.spec.ts index ab92e177b558..56c0e5b5f549 100644 --- a/sdk/eventhub/event-hubs/test/internal/cancellation.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/cancellation.spec.ts @@ -31,7 +31,7 @@ testWithServiceTypes((serviceVersion) => { describe("Cancellation via AbortSignal", () => { const service = { connectionString: env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], - path: env[EnvVarKeys.EVENTHUB_NAME] + path: env[EnvVarKeys.EVENTHUB_NAME], }; before("validate environment", () => { should.exist( @@ -45,11 +45,11 @@ testWithServiceTypes((serviceVersion) => { }); let context: ReturnType; - beforeEach("create connection context", function() { + beforeEach("create connection context", function () { context = createConnectionContext(service.connectionString, service.path); }); - afterEach("close connection context", function() { + afterEach("close connection context", function () { return context.close(); }); @@ -62,7 +62,7 @@ testWithServiceTypes((serviceVersion) => { const controller = new AbortController(); controller.abort(); return controller.signal; - } + }, }, { type: "aborted after timeout", @@ -72,8 +72,8 @@ testWithServiceTypes((serviceVersion) => { controller.abort(); }, 0); return controller.signal; - } - } + }, + }, ]; describe("EventHubReceiver", () => { @@ -84,7 +84,7 @@ testWithServiceTypes((serviceVersion) => { "$default", // consumer group "0", // partition id { - enqueuedOn: Date.now() + enqueuedOn: Date.now(), } ); }); diff --git a/sdk/eventhub/event-hubs/test/internal/client.spec.ts b/sdk/eventhub/event-hubs/test/internal/client.spec.ts index cbcaf893f9e6..7c08dfbde8e1 100644 --- a/sdk/eventhub/event-hubs/test/internal/client.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/client.spec.ts @@ -6,7 +6,7 @@ import { EventHubConsumerClient, EventHubProducerClient, Subscription, - TokenCredential + TokenCredential, } from "../../src"; import { ConnectionContext } from "../../src/connectionContext"; import { MessagingError } from "@azure/core-amqp"; @@ -47,10 +47,10 @@ testWithServiceTypes((serviceVersion) => { }); } - describe("Create EventHubConsumerClient", function(): void { - it("throws when no EntityPath in connection string", function(): void { + describe("Create EventHubConsumerClient", function (): void { + it("throws when no EntityPath in connection string", function (): void { const connectionString = "Endpoint=sb://abc"; - const test = function(): EventHubConsumerClient { + const test = function (): EventHubConsumerClient { return new EventHubConsumerClient("dummy", connectionString); }; test.should.throw( @@ -60,11 +60,11 @@ testWithServiceTypes((serviceVersion) => { ); }); - it("throws when EntityPath in connection string doesn't match with event hub name parameter", function(): void { + it("throws when EntityPath in connection string doesn't match with event hub name parameter", function (): void { const connectionString = "Endpoint=sb://a;SharedAccessKeyName=b;SharedAccessKey=c=;EntityPath=my-event-hub-name"; const eventHubName = "event-hub-name"; - const test = function(): EventHubConsumerClient { + const test = function (): EventHubConsumerClient { return new EventHubConsumerClient("dummy", connectionString, eventHubName); }; test.should.throw( @@ -74,7 +74,7 @@ testWithServiceTypes((serviceVersion) => { ); }); - it("sets eventHubName, fullyQualifiedNamespace properties when created from a connection string", function(): void { + it("sets eventHubName, fullyQualifiedNamespace properties when created from a connection string", function (): void { const client = new EventHubConsumerClient( "dummy", "Endpoint=sb://test.servicebus.windows.net;SharedAccessKeyName=b;SharedAccessKey=c;EntityPath=my-event-hub-name" @@ -84,7 +84,7 @@ testWithServiceTypes((serviceVersion) => { should.equal(client.fullyQualifiedNamespace, "test.servicebus.windows.net"); }); - it("sets eventHubName, fullyQualifiedNamespace properties when created from a connection string and event hub name", function(): void { + it("sets eventHubName, fullyQualifiedNamespace properties when created from a connection string and event hub name", function (): void { const client = new EventHubConsumerClient( "dummy", "Endpoint=sb://test.servicebus.windows.net;SharedAccessKeyName=b;SharedAccessKey=c", @@ -95,14 +95,14 @@ testWithServiceTypes((serviceVersion) => { should.equal(client.fullyQualifiedNamespace, "test.servicebus.windows.net"); }); - it("sets eventHubName, fullyQualifiedNamespace properties when created from a token credential", function(): void { + it("sets eventHubName, fullyQualifiedNamespace properties when created from a token credential", function (): void { const dummyCredential: TokenCredential = { getToken: async () => { return { token: "boo", - expiresOnTimestamp: 12324 + expiresOnTimestamp: 12324, }; - } + }, }; const client = new EventHubConsumerClient( "dummy", @@ -132,9 +132,9 @@ testWithServiceTypes((serviceVersion) => { getToken: async () => { return { token: "boo", - expiresOnTimestamp: 12324 + expiresOnTimestamp: 12324, }; - } + }, }; const client = new EventHubConsumerClient( "dummy", @@ -150,10 +150,10 @@ testWithServiceTypes((serviceVersion) => { }); }); - describe("Create EventHubProducerClient", function(): void { - it("throws when no EntityPath in connection string ", function(): void { + describe("Create EventHubProducerClient", function (): void { + it("throws when no EntityPath in connection string ", function (): void { const connectionString = "Endpoint=sb://abc"; - const test = function(): EventHubProducerClient { + const test = function (): EventHubProducerClient { return new EventHubProducerClient(connectionString); }; test.should.throw( @@ -163,11 +163,11 @@ testWithServiceTypes((serviceVersion) => { ); }); - it("throws when EntityPath in connection string doesn't match with event hub name parameter", function(): void { + it("throws when EntityPath in connection string doesn't match with event hub name parameter", function (): void { const connectionString = "Endpoint=sb://a;SharedAccessKeyName=b;SharedAccessKey=c=;EntityPath=my-event-hub-name"; const eventHubName = "event-hub-name"; - const test = function(): EventHubProducerClient { + const test = function (): EventHubProducerClient { return new EventHubProducerClient(connectionString, eventHubName); }; test.should.throw( @@ -177,7 +177,7 @@ testWithServiceTypes((serviceVersion) => { ); }); - it("sets eventHubName, fullyQualifiedNamespace properties when created from a connection string", function(): void { + it("sets eventHubName, fullyQualifiedNamespace properties when created from a connection string", function (): void { const client = new EventHubProducerClient( "Endpoint=sb://test.servicebus.windows.net;SharedAccessKeyName=b;SharedAccessKey=c;EntityPath=my-event-hub-name" ); @@ -186,7 +186,7 @@ testWithServiceTypes((serviceVersion) => { should.equal(client.fullyQualifiedNamespace, "test.servicebus.windows.net"); }); - it("sets eventHubName, fullyQualifiedNamespace properties when created from a connection string and event hub name", function(): void { + it("sets eventHubName, fullyQualifiedNamespace properties when created from a connection string and event hub name", function (): void { const client = new EventHubProducerClient( "Endpoint=sb://test.servicebus.windows.net;SharedAccessKeyName=b;SharedAccessKey=c", "my-event-hub-name" @@ -196,14 +196,14 @@ testWithServiceTypes((serviceVersion) => { should.equal(client.fullyQualifiedNamespace, "test.servicebus.windows.net"); }); - it("sets eventHubName, fullyQualifiedNamespace properties when created from a token credential", function(): void { + it("sets eventHubName, fullyQualifiedNamespace properties when created from a token credential", function (): void { const dummyCredential: TokenCredential = { getToken: async () => { return { token: "boo", - expiresOnTimestamp: 12324 + expiresOnTimestamp: 12324, }; - } + }, }; const client = new EventHubProducerClient( "test.servicebus.windows.net", @@ -231,9 +231,9 @@ testWithServiceTypes((serviceVersion) => { getToken: async () => { return { token: "boo", - expiresOnTimestamp: 12324 + expiresOnTimestamp: 12324, }; - } + }, }; const client = new EventHubProducerClient( "test.servicebus.windows.net", @@ -248,7 +248,7 @@ testWithServiceTypes((serviceVersion) => { }); }); - describe("EventHubConsumerClient with non existent namespace", function(): void { + describe("EventHubConsumerClient with non existent namespace", function (): void { let client: EventHubConsumerClient; beforeEach(() => { client = new EventHubConsumerClient( @@ -261,9 +261,7 @@ testWithServiceTypes((serviceVersion) => { return client.close(); }); - it("should throw ServiceCommunicationError for getEventHubProperties", async function(): Promise< - void - > { + it("should throw ServiceCommunicationError for getEventHubProperties", async function (): Promise { try { await client.getEventHubProperties(); throw new Error(testFailureMessage); @@ -273,9 +271,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should throw ServiceCommunicationError for getPartitionProperties", async function(): Promise< - void - > { + it("should throw ServiceCommunicationError for getPartitionProperties", async function (): Promise { try { await client.getPartitionProperties("0"); throw new Error(testFailureMessage); @@ -285,9 +281,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should throw ServiceCommunicationError for getPartitionIds", async function(): Promise< - void - > { + it("should throw ServiceCommunicationError for getPartitionIds", async function (): Promise { try { await client.getPartitionIds(); throw new Error(testFailureMessage); @@ -297,7 +291,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should throw ServiceCommunicationError while subscribe()", async function(): Promise { + it("should throw ServiceCommunicationError while subscribe()", async function (): Promise { let subscription: Subscription | undefined; const caughtErr = await new Promise((resolve) => { subscription = client.subscribe({ @@ -306,7 +300,7 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err) => { resolve(err); - } + }, }); }); if (subscription) { @@ -318,7 +312,7 @@ testWithServiceTypes((serviceVersion) => { }); }); - describe("EventHubProducerClient with non existent namespace", function(): void { + describe("EventHubProducerClient with non existent namespace", function (): void { let client: EventHubProducerClient; beforeEach(() => { client = new EventHubProducerClient( @@ -330,9 +324,7 @@ testWithServiceTypes((serviceVersion) => { return client.close(); }); - it("should throw ServiceCommunicationError for getEventHubProperties", async function(): Promise< - void - > { + it("should throw ServiceCommunicationError for getEventHubProperties", async function (): Promise { try { await client.getEventHubProperties(); throw new Error(testFailureMessage); @@ -342,9 +334,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should throw ServiceCommunicationError for getPartitionProperties", async function(): Promise< - void - > { + it("should throw ServiceCommunicationError for getPartitionProperties", async function (): Promise { try { await client.getPartitionProperties("0"); throw new Error(testFailureMessage); @@ -354,9 +344,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should throw ServiceCommunicationError for getPartitionIds", async function(): Promise< - void - > { + it("should throw ServiceCommunicationError for getPartitionIds", async function (): Promise { try { await client.getPartitionIds(); throw new Error(testFailureMessage); @@ -366,7 +354,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should throw ServiceCommunicationError while sending", async function(): Promise { + it("should throw ServiceCommunicationError while sending", async function (): Promise { try { await client.sendBatch([{ body: "Hello World" }]); throw new Error(testFailureMessage); @@ -376,9 +364,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should throw ServiceCommunicationError while creating a batch", async function(): Promise< - void - > { + it("should throw ServiceCommunicationError while creating a batch", async function (): Promise { try { await client.createBatch(); throw new Error(testFailureMessage); @@ -389,7 +375,7 @@ testWithServiceTypes((serviceVersion) => { }); }); - describe("EventHubConsumerClient with non existent event hub", function(): void { + describe("EventHubConsumerClient with non existent event hub", function (): void { let client: EventHubConsumerClient; const expectedErrCode = "MessagingEntityNotFoundError"; @@ -410,9 +396,7 @@ testWithServiceTypes((serviceVersion) => { return client.close(); }); - it("should throw MessagingEntityNotFoundError for getEventHubProperties", async function(): Promise< - void - > { + it("should throw MessagingEntityNotFoundError for getEventHubProperties", async function (): Promise { try { await client.getEventHubProperties(); throw new Error(testFailureMessage); @@ -422,9 +406,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should throw MessagingEntityNotFoundError for getPartitionProperties", async function(): Promise< - void - > { + it("should throw MessagingEntityNotFoundError for getPartitionProperties", async function (): Promise { try { await client.getPartitionProperties("0"); throw new Error(testFailureMessage); @@ -434,9 +416,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should throw MessagingEntityNotFoundError for getPartitionIds", async function(): Promise< - void - > { + it("should throw MessagingEntityNotFoundError for getPartitionIds", async function (): Promise { try { await client.getPartitionIds(); throw new Error(testFailureMessage); @@ -446,9 +426,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should throw MessagingEntityNotFoundError while subscribe()", async function(): Promise< - void - > { + it("should throw MessagingEntityNotFoundError while subscribe()", async function (): Promise { let subscription: Subscription | undefined; const caughtErr = await new Promise((resolve) => { subscription = client.subscribe({ @@ -457,7 +435,7 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err) => { resolve(err); - } + }, }); }); if (subscription) { @@ -469,7 +447,7 @@ testWithServiceTypes((serviceVersion) => { }); }); - describe("EventHubProducerClient with non existent event hub", function(): void { + describe("EventHubProducerClient with non existent event hub", function (): void { let client: EventHubProducerClient; const expectedErrCode = "MessagingEntityNotFoundError"; @@ -485,9 +463,7 @@ testWithServiceTypes((serviceVersion) => { return client.close(); }); - it("should throw MessagingEntityNotFoundError for getEventHubProperties", async function(): Promise< - void - > { + it("should throw MessagingEntityNotFoundError for getEventHubProperties", async function (): Promise { try { await client.getEventHubProperties(); throw new Error(testFailureMessage); @@ -497,9 +473,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should throw MessagingEntityNotFoundError for getPartitionProperties", async function(): Promise< - void - > { + it("should throw MessagingEntityNotFoundError for getPartitionProperties", async function (): Promise { try { await client.getPartitionProperties("0"); throw new Error(testFailureMessage); @@ -509,9 +483,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should throw MessagingEntityNotFoundError for getPartitionIds", async function(): Promise< - void - > { + it("should throw MessagingEntityNotFoundError for getPartitionIds", async function (): Promise { try { await client.getPartitionIds(); throw new Error(testFailureMessage); @@ -521,7 +493,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should throw MessagingEntityNotFoundError while sending", async function(): Promise { + it("should throw MessagingEntityNotFoundError while sending", async function (): Promise { try { await client.sendBatch([{ body: "Hello World" }]); throw new Error(testFailureMessage); @@ -531,9 +503,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should throw MessagingEntityNotFoundError while creating a batch", async function(): Promise< - void - > { + it("should throw MessagingEntityNotFoundError while creating a batch", async function (): Promise { try { await client.createBatch(); throw new Error(testFailureMessage); @@ -544,7 +514,7 @@ testWithServiceTypes((serviceVersion) => { }); }); - describe("EventHubConsumerClient User Agent String", function(): void { + describe("EventHubConsumerClient User Agent String", function (): void { beforeEach(() => { should.exist( env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], @@ -557,7 +527,7 @@ testWithServiceTypes((serviceVersion) => { ); }); - it("should correctly populate the default user agent", async function(): Promise { + it("should correctly populate the default user agent", async function (): Promise { const consumerClient = new EventHubConsumerClient( "$Default", env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], @@ -567,7 +537,7 @@ testWithServiceTypes((serviceVersion) => { await consumerClient.close(); }); - it("should correctly populate the custom user agent", async function(): Promise { + it("should correctly populate the custom user agent", async function (): Promise { const customUserAgent = "boo"; const consumerClient = new EventHubConsumerClient( "$Default", @@ -580,7 +550,7 @@ testWithServiceTypes((serviceVersion) => { }); }); - describe("EventHubProducerClient User Agent String", function(): void { + describe("EventHubProducerClient User Agent String", function (): void { beforeEach(() => { should.exist( env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], @@ -593,7 +563,7 @@ testWithServiceTypes((serviceVersion) => { ); }); - it("should correctly populate the default user agent", async function(): Promise { + it("should correctly populate the default user agent", async function (): Promise { const producerClient = new EventHubProducerClient( env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], env[EnvVarKeys.EVENTHUB_NAME] @@ -602,7 +572,7 @@ testWithServiceTypes((serviceVersion) => { await producerClient.close(); }); - it("should correctly populate the custom user agent", async function(): Promise { + it("should correctly populate the custom user agent", async function (): Promise { const customUserAgent = "boo"; const producerClient = new EventHubProducerClient( env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], @@ -633,7 +603,7 @@ testWithServiceTypes((serviceVersion) => { } } - describe("EventHubConsumerClient after close()", function(): void { + describe("EventHubConsumerClient after close()", function (): void { let client: EventHubConsumerClient; const expectedErrorMsg = "The underlying AMQP connection is closed."; @@ -659,9 +629,7 @@ testWithServiceTypes((serviceVersion) => { await client.close(); } - it("should throw connection closed error for getEventHubProperties", async function(): Promise< - void - > { + it("should throw connection closed error for getEventHubProperties", async function (): Promise { await beforeEachTest(); try { await client.getEventHubProperties(); @@ -672,9 +640,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should throw connection closed error for getPartitionProperties", async function(): Promise< - void - > { + it("should throw connection closed error for getPartitionProperties", async function (): Promise { await beforeEachTest(); try { await client.getPartitionProperties("0"); @@ -685,7 +651,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should throw connection closed error for getPartitionIds", async function(): Promise { + it("should throw connection closed error for getPartitionIds", async function (): Promise { await beforeEachTest(); try { await client.getPartitionIds(); @@ -696,7 +662,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should throw connection closed error while subscribe()", async function(): Promise { + it("should throw connection closed error while subscribe()", async function (): Promise { await beforeEachTest(); let subscription: Subscription | undefined; const caughtErr = await new Promise((resolve) => { @@ -706,7 +672,7 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err) => { resolve(err); - } + }, }); }); if (subscription) { @@ -717,7 +683,7 @@ testWithServiceTypes((serviceVersion) => { }); }); - describe("EventHubProducerClient after close()", function(): void { + describe("EventHubProducerClient after close()", function (): void { let client: EventHubProducerClient; const expectedErrorMsg = "The underlying AMQP connection is closed."; @@ -742,9 +708,7 @@ testWithServiceTypes((serviceVersion) => { await client.close(); } - it("should throw connection closed error for getEventHubProperties", async function(): Promise< - void - > { + it("should throw connection closed error for getEventHubProperties", async function (): Promise { await beforeEachTest(); try { await client.getEventHubProperties(); @@ -755,9 +719,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should throw connection closed error for getPartitionProperties", async function(): Promise< - void - > { + it("should throw connection closed error for getPartitionProperties", async function (): Promise { await beforeEachTest(); try { await client.getPartitionProperties("0"); @@ -768,7 +730,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should throw connection closed error for getPartitionIds", async function(): Promise { + it("should throw connection closed error for getPartitionIds", async function (): Promise { await beforeEachTest(); try { await client.getPartitionIds(); @@ -779,7 +741,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should throw connection closed error while sending", async function(): Promise { + it("should throw connection closed error while sending", async function (): Promise { await beforeEachTest(); try { await client.sendBatch([{ body: "Hello World" }]); @@ -790,9 +752,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should throw connection closed error while creating a batch", async function(): Promise< - void - > { + it("should throw connection closed error while creating a batch", async function (): Promise { await beforeEachTest(); try { await client.createBatch(); diff --git a/sdk/eventhub/event-hubs/test/internal/config.spec.ts b/sdk/eventhub/event-hubs/test/internal/config.spec.ts index 9c11a461d486..0777ec621c24 100644 --- a/sdk/eventhub/event-hubs/test/internal/config.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/config.spec.ts @@ -7,9 +7,9 @@ import { testWithServiceTypes } from "../public/utils/testWithServiceTypes"; const should = chai.should(); testWithServiceTypes(() => { - describe("ConnectionConfig", function() { - describe("EventHub", function() { - it("should fail if connection config does not contain path and the connectionstring also does not contain EntityPath", function(done) { + describe("ConnectionConfig", function () { + describe("EventHub", function () { + it("should fail if connection config does not contain path and the connectionstring also does not contain EntityPath", function (done) { const connectionString = "Endpoint=sb://hostname.servicebus.windows.net/;SharedAccessKeyName=sakName;SharedAccessKey=sak"; try { @@ -21,7 +21,7 @@ testWithServiceTypes(() => { done(); }); - it("should correctly populate config properties from an EventHubs connection string and the helper methods should work as expected", function(done) { + it("should correctly populate config properties from an EventHubs connection string and the helper methods should work as expected", function (done) { const config = EventHubConnectionConfig.create( "Endpoint=sb://hostname.servicebus.windows.net/;SharedAccessKeyName=sakName;SharedAccessKey=sak;EntityPath=ep" ); diff --git a/sdk/eventhub/event-hubs/test/internal/dataTransformer.spec.ts b/sdk/eventhub/event-hubs/test/internal/dataTransformer.spec.ts index 74155528aa07..00081bbf8f79 100644 --- a/sdk/eventhub/event-hubs/test/internal/dataTransformer.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/dataTransformer.spec.ts @@ -10,7 +10,7 @@ import { testWithServiceTypes } from "../public/utils/testWithServiceTypes"; const should = chai.should(); testWithServiceTypes(() => { - describe("DataTransformer", function() { + describe("DataTransformer", function () { const objectBody: any = { id: "123-456-789", weight: 10, @@ -19,19 +19,19 @@ testWithServiceTypes(() => { { id: "098-789-564", weight: 20, - isBlue: false - } - ] + isBlue: false, + }, + ], }; const arrayBody = [ { id: "098-789-564", weight: 20, - isBlue: false + isBlue: false, }, 10, 20, - "some string" + "some string", ]; const stringBody: string = "some string"; const booleanBody: boolean = true; @@ -430,7 +430,7 @@ testWithServiceTypes(() => { it("should correctly decode a buffer message body and that body is a JSON string", (done) => { const jsonBody = { - foo: "bar" + foo: "bar", }; const jsonStringBufferBody = Buffer.from(JSON.stringify(jsonBody), "utf8"); const { body: decoded, bodyType: decodedType } = transformer.decode( @@ -444,7 +444,7 @@ testWithServiceTypes(() => { it("should correctly decode a buffer message body and that body is a JSON string, setting skipParsingBodyAsJson to true", (done) => { const jsonBody = { - foo: "bar" + foo: "bar", }; const jsonStringBufferBody = Buffer.from(JSON.stringify(jsonBody), "utf8"); const { body: decoded, bodyType: decodedType } = transformer.decode( @@ -458,12 +458,12 @@ testWithServiceTypes(() => { it("should correctly decode a buffer message body and that body is a JSON string for a rhea AMQP section", (done) => { const jsonBody = { - foo: "bar" + foo: "bar", }; const jsonStringBufferBody = Buffer.from(JSON.stringify(jsonBody), "utf8"); const rheaAmqpSection = { typecode: dataSectionTypeCode, - content: jsonStringBufferBody + content: jsonStringBufferBody, }; const { body: decoded, bodyType: decodedType } = transformer.decode(rheaAmqpSection, false); should.equal(decodedType, "data"); @@ -473,12 +473,12 @@ testWithServiceTypes(() => { it("should correctly decode a buffer message body and that body is a JSON string for a rhea AMQP section, setting skipParsingBodyAsJson to true", (done) => { const jsonBody = { - foo: "bar" + foo: "bar", }; const jsonStringBufferBody = Buffer.from(JSON.stringify(jsonBody), "utf8"); const rheaAmqpSection = { typecode: dataSectionTypeCode, - content: jsonStringBufferBody + content: jsonStringBufferBody, }; const { body: decoded, bodyType: decodedType } = transformer.decode(rheaAmqpSection, true); should.equal(decodedType, "data"); 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 b53f1ddfa700..1d859a6ed0da 100644 --- a/sdk/eventhub/event-hubs/test/internal/diagnostics/messageSpan.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/diagnostics/messageSpan.spec.ts @@ -24,7 +24,7 @@ testWithServiceTypes(() => { {}, { entityPath: "entity path", - host: "host" + host: "host", } ); @@ -36,7 +36,7 @@ testWithServiceTypes(() => { assert.deepStrictEqual((span as any).attributes, { "az.namespace": "Microsoft.EventHub", "message_bus.destination": "entity path", - "peer.address": "host" + "peer.address": "host", }); span.end(); diff --git a/sdk/eventhub/event-hubs/test/internal/eventHubConsumerClientUnitTests.spec.ts b/sdk/eventhub/event-hubs/test/internal/eventHubConsumerClientUnitTests.spec.ts index 50f422a53495..0d9b4f528b1d 100644 --- a/sdk/eventhub/event-hubs/test/internal/eventHubConsumerClientUnitTests.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/eventHubConsumerClientUnitTests.spec.ts @@ -33,7 +33,7 @@ testWithServiceTypes((serviceVersion) => { describe("EventHubConsumerClient", () => { const service = { connectionString: env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], - path: env[EnvVarKeys.EVENTHUB_NAME]! + path: env[EnvVarKeys.EVENTHUB_NAME]!, }; before(() => { @@ -55,7 +55,7 @@ testWithServiceTypes((serviceVersion) => { }, processClose: async () => { /* no-op */ - } + }, }).should.not.equal(true); isCheckpointStore("hello").should.not.equal(true); @@ -107,13 +107,12 @@ testWithServiceTypes((serviceVersion) => { }, processError: async () => { /* no-op */ - } + }, }; (client as any)["_createEventProcessor"] = fakeEventProcessorConstructor; - (clientWithCheckpointStore as any)[ - "_createEventProcessor" - ] = fakeEventProcessorConstructor; + (clientWithCheckpointStore as any)["_createEventProcessor"] = + fakeEventProcessorConstructor; }); it("conflicting subscribes", () => { @@ -194,8 +193,8 @@ testWithServiceTypes((serviceVersion) => { loadBalancingOptions: { strategy: "greedy", // ignored partitionOwnershipExpirationIntervalInMs: 100, // ignored - updateIntervalInMs: 20 - } + updateIntervalInMs: 20, + }, } ); (client as any)["_createEventProcessor"] = fakeEventProcessorConstructor; @@ -255,13 +254,12 @@ testWithServiceTypes((serviceVersion) => { loadBalancingOptions: { strategy: "greedy", // ignored partitionOwnershipExpirationIntervalInMs: 100, // ignored - updateIntervalInMs: 20 - } + updateIntervalInMs: 20, + }, } ); - (clientWithCheckpointStore as any)[ - "_createEventProcessor" - ] = fakeEventProcessorConstructor; + (clientWithCheckpointStore as any)["_createEventProcessor"] = + fakeEventProcessorConstructor; clientWithCheckpointStore.subscribe("0", subscriptionHandlers); }); @@ -304,8 +302,8 @@ testWithServiceTypes((serviceVersion) => { loadBalancingOptions: { strategy: "greedy", // ignored partitionOwnershipExpirationIntervalInMs: 100, // ignored - updateIntervalInMs: 20 - } + updateIntervalInMs: 20, + }, } ); (client as any)["_createEventProcessor"] = fakeEventProcessorConstructor; @@ -360,13 +358,12 @@ testWithServiceTypes((serviceVersion) => { loadBalancingOptions: { strategy: "greedy", partitionOwnershipExpirationIntervalInMs: 100, - updateIntervalInMs: 20 - } + updateIntervalInMs: 20, + }, } ); - (clientWithCheckpointStore as any)[ - "_createEventProcessor" - ] = fakeEventProcessorConstructor; + (clientWithCheckpointStore as any)["_createEventProcessor"] = + fakeEventProcessorConstructor; clientWithCheckpointStore.subscribe(subscriptionHandlers); }); @@ -396,13 +393,12 @@ testWithServiceTypes((serviceVersion) => { loadBalancingOptions: { strategy: "balanced", partitionOwnershipExpirationIntervalInMs: 100, - updateIntervalInMs: 20 - } + updateIntervalInMs: 20, + }, } ); - (clientWithCheckpointStore as any)[ - "_createEventProcessor" - ] = fakeEventProcessorConstructor; + (clientWithCheckpointStore as any)["_createEventProcessor"] = + fakeEventProcessorConstructor; clientWithCheckpointStore.subscribe(subscriptionHandlers); }); @@ -432,13 +428,12 @@ testWithServiceTypes((serviceVersion) => { loadBalancingOptions: { // default 'strategy' is 'balanced' partitionOwnershipExpirationIntervalInMs: 100, - updateIntervalInMs: 20 - } + updateIntervalInMs: 20, + }, } ); - (clientWithCheckpointStore as any)[ - "_createEventProcessor" - ] = fakeEventProcessorConstructor; + (clientWithCheckpointStore as any)["_createEventProcessor"] = + fakeEventProcessorConstructor; clientWithCheckpointStore.subscribe(subscriptionHandlers); }); @@ -466,14 +461,13 @@ testWithServiceTypes((serviceVersion) => { new InMemoryCheckpointStore(), { loadBalancingOptions: { - strategy: "greedy" + strategy: "greedy", // defaults are used for the rest of the parameters. - } + }, } ); - (clientWithCheckpointStore as any)[ - "_createEventProcessor" - ] = fakeEventProcessorConstructor; + (clientWithCheckpointStore as any)["_createEventProcessor"] = + fakeEventProcessorConstructor; clientWithCheckpointStore.subscribe(subscriptionHandlers); }); diff --git a/sdk/eventhub/event-hubs/test/internal/eventPosition.spec.ts b/sdk/eventhub/event-hubs/test/internal/eventPosition.spec.ts index 655aaf1d9431..16b3e789a9ac 100644 --- a/sdk/eventhub/event-hubs/test/internal/eventPosition.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/eventPosition.spec.ts @@ -9,30 +9,30 @@ import { testWithServiceTypes } from "../public/utils/testWithServiceTypes"; chai.should(); testWithServiceTypes(() => { - describe("EventPosition", function(): void { - describe("happy", function(): void { - it("should create from an offset with inclusive false", function(done: Mocha.Done): void { + describe("EventPosition", function (): void { + describe("happy", function (): void { + it("should create from an offset with inclusive false", function (done: Mocha.Done): void { const result = "amqp.annotation.x-opt-offset > '1234'"; const pos = { offset: 1234 }; result.should.equal(getEventPositionFilter(pos)); done(); }); - it("should create from a sequence with inclusive false", function(done: Mocha.Done): void { + it("should create from a sequence with inclusive false", function (done: Mocha.Done): void { const result = "amqp.annotation.x-opt-sequence-number > '0'"; const pos = { sequenceNumber: 0 }; result.should.equal(getEventPositionFilter(pos)); done(); }); - it("should create from a sequence with inclusive true", function(done: Mocha.Done): void { + it("should create from a sequence with inclusive true", function (done: Mocha.Done): void { const result = "amqp.annotation.x-opt-sequence-number >= '0'"; const pos = { sequenceNumber: 0, isInclusive: true }; result.should.equal(getEventPositionFilter(pos)); done(); }); - it("should create from enqueuedTime with Date as Date", function(done: Mocha.Done): void { + it("should create from enqueuedTime with Date as Date", function (done: Mocha.Done): void { const result = "amqp.annotation.x-opt-enqueued-time > '1537406052971'"; const d = new Date("2018-09-20T01:14:12.971Z"); const pos = { enqueuedOn: d }; @@ -40,7 +40,7 @@ testWithServiceTypes(() => { done(); }); - it("should create from enqueuedTime with Date as number", function(done: Mocha.Done): void { + it("should create from enqueuedTime with Date as number", function (done: Mocha.Done): void { const result = "amqp.annotation.x-opt-enqueued-time > '1537406052971'"; const d = new Date("2018-09-20T01:14:12.971Z").getTime(); const pos = { enqueuedOn: d }; @@ -55,14 +55,14 @@ testWithServiceTypes(() => { // done(); // }); - it("should create from an offset from start", function(done: Mocha.Done): void { + it("should create from an offset from start", function (done: Mocha.Done): void { const result = "amqp.annotation.x-opt-offset > '-1'"; const pos = earliestEventPosition; result.should.equal(getEventPositionFilter(pos)); done(); }); - it("should create from an offset from end", function(done: Mocha.Done): void { + it("should create from an offset from end", function (done: Mocha.Done): void { const result = "amqp.annotation.x-opt-offset > '@latest'"; const pos = latestEventPosition; result.should.equal(getEventPositionFilter(pos)); @@ -70,9 +70,9 @@ testWithServiceTypes(() => { }); }); - describe("sad", function(): void { + describe("sad", function (): void { it("throws error when empty object is passed for event position", () => { - const test = function(): void { + const test = function (): void { validateEventPositions({}); }; test.should.throw( @@ -81,7 +81,7 @@ testWithServiceTypes(() => { ); }); it("throws error when event position is passed with both offset and sequence number set", () => { - const test = function(): void { + const test = function (): void { validateEventPositions({ offset: 123, sequenceNumber: 456 }); }; test.should.throw( @@ -90,7 +90,7 @@ testWithServiceTypes(() => { ); }); it("throws error when event position is passed with both offset and enqueuedOn set", () => { - const test = function(): void { + const test = function (): void { validateEventPositions({ offset: 123, enqueuedOn: 456 }); }; test.should.throw( @@ -99,7 +99,7 @@ testWithServiceTypes(() => { ); }); it("throws error when event position is passed with both sequence number and enqueuedOn set", () => { - const test = function(): void { + const test = function (): void { validateEventPositions({ sequenceNumber: 123, enqueuedOn: 456 }); }; test.should.throw( @@ -108,7 +108,7 @@ testWithServiceTypes(() => { ); }); it("throws error when empty object is passed in event position map", () => { - const test = function(): void { + const test = function (): void { validateEventPositions({ "1": {}, "2": { offset: 123 } }); }; test.should.throw( @@ -117,10 +117,10 @@ testWithServiceTypes(() => { ); }); it("throws error when event position map is passed with both offset and sequence number set", () => { - const test = function(): void { + const test = function (): void { validateEventPositions({ "1": { offset: 123, sequenceNumber: 456 }, - "2": { offset: 123 } + "2": { offset: 123 }, }); }; test.should.throw( @@ -129,7 +129,7 @@ testWithServiceTypes(() => { ); }); it("throws error when event position map is passed with both offset and enqueuedOn set", () => { - const test = function(): void { + const test = function (): void { validateEventPositions({ "1": { offset: 123, enqueuedOn: 456 }, "2": { offset: 123 } }); }; test.should.throw( @@ -138,10 +138,10 @@ testWithServiceTypes(() => { ); }); it("throws error when event position map is passed with both sequence number and enqueuedOn set", () => { - const test = function(): void { + const test = function (): void { validateEventPositions({ "1": { sequenceNumber: 123, enqueuedOn: 456 }, - "2": { offset: 123 } + "2": { offset: 123 }, }); }; test.should.throw( diff --git a/sdk/eventhub/event-hubs/test/internal/eventProcessor.spec.ts b/sdk/eventhub/event-hubs/test/internal/eventProcessor.spec.ts index b0864877962a..cb8832a2a4ea 100644 --- a/sdk/eventhub/event-hubs/test/internal/eventProcessor.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/eventProcessor.spec.ts @@ -12,14 +12,14 @@ import { ReceivedEventData, SubscriptionEventHandlers, earliestEventPosition, - latestEventPosition + latestEventPosition, } from "../../src"; import { Dictionary, generate_uuid } from "rhea-promise"; import { EnvVarKeys, getEnvVars, loopUntil } from "../public/utils/testUtils"; import { EventProcessor, FullEventProcessorOptions } from "../../src/eventProcessor"; import { SubscriptionHandlerForTests, - sendOneMessagePerPartition + sendOneMessagePerPartition, } from "../public/utils/subscriptionHandlerForTests"; import { AbortController } from "@azure/abort-controller"; import { BalancedLoadBalancingStrategy } from "../../src/loadBalancerStrategies/balancedStrategy"; @@ -56,23 +56,23 @@ testWithServiceTypes((serviceVersion) => { }); } - describe("Event Processor", function(): void { + describe("Event Processor", function (): void { const defaultOptions: FullEventProcessorOptions = { maxBatchSize: 1, maxWaitTimeInSeconds: 1, ownerLevel: 0, loopIntervalInMs: 10000, - loadBalancingStrategy: new UnbalancedLoadBalancingStrategy() + loadBalancingStrategy: new UnbalancedLoadBalancingStrategy(), }; const service = { connectionString: env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], - path: env[EnvVarKeys.EVENTHUB_NAME] + path: env[EnvVarKeys.EVENTHUB_NAME], }; let producerClient: EventHubProducerClient; let consumerClient: EventHubConsumerClient; - before("validate environment", async function(): Promise { + before("validate environment", async function (): Promise { should.exist( env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], "define EVENTHUB_CONNECTION_STRING in your environment before running integration tests." @@ -83,7 +83,7 @@ testWithServiceTypes((serviceVersion) => { ); }); - beforeEach("create the client", function() { + beforeEach("create the client", function () { producerClient = new EventHubProducerClient(service.connectionString, service.path); consumerClient = new EventHubConsumerClient( EventHubConsumerClient.defaultConsumerGroupName, @@ -92,7 +92,7 @@ testWithServiceTypes((serviceVersion) => { ); }); - afterEach("close the connection", async function(): Promise { + afterEach("close the connection", async function (): Promise { await producerClient.close(); await consumerClient.close(); }); @@ -112,7 +112,7 @@ testWithServiceTypes((serviceVersion) => { }, processError: async () => { /* no-op */ - } + }, }, checkpointStore, { @@ -120,7 +120,7 @@ testWithServiceTypes((serviceVersion) => { maxBatchSize: 1, maxWaitTimeInSeconds: 1, loadBalancingStrategy: defaultOptions.loadBalancingStrategy, - loopIntervalInMs: defaultOptions.loopIntervalInMs + loopIntervalInMs: defaultOptions.loopIntervalInMs, } ); } @@ -142,7 +142,7 @@ testWithServiceTypes((serviceVersion) => { eventHubName: "not-used-for-this-test", offset: cp.offset, sequenceNumber: cp.sequenceNumber, - partitionId: cp.partitionId + partitionId: cp.partitionId, }; }); }, @@ -151,7 +151,7 @@ testWithServiceTypes((serviceVersion) => { }, updateCheckpoint: async () => { /* no-op */ - } + }, }; } @@ -160,7 +160,7 @@ testWithServiceTypes((serviceVersion) => { return Promise.resolve({ name: "boo", createdOn: new Date(), - partitionIds: ["0", "1"] + partitionIds: ["0", "1"], }); }; }); @@ -177,8 +177,8 @@ testWithServiceTypes((serviceVersion) => { { offset: 1009, sequenceNumber: 1010, - partitionId: "0" - } + partitionId: "0", + }, ]); const processor = createEventProcessor( @@ -200,8 +200,8 @@ testWithServiceTypes((serviceVersion) => { { offset: 0, sequenceNumber: 0, - partitionId: "0" - } + partitionId: "0", + }, ]); const processor = createEventProcessor(checkpointStore); @@ -263,7 +263,7 @@ testWithServiceTypes((serviceVersion) => { if (userCallback) { userCallback(); } - } + }, }, new InMemoryCheckpointStore(), defaultOptions @@ -313,7 +313,7 @@ testWithServiceTypes((serviceVersion) => { }, async listCheckpoints(): Promise { return []; - } + }, }; const pumpManager = { @@ -333,7 +333,7 @@ testWithServiceTypes((serviceVersion) => { receivingFromPartitions() { return []; - } + }, }; const eventProcessor = new EventProcessor( @@ -345,12 +345,12 @@ testWithServiceTypes((serviceVersion) => { }, processError: async () => { /* no-op */ - } + }, }, checkpointStore, { ...defaultOptions, - pumpManager: pumpManager + pumpManager: pumpManager, } ); @@ -360,7 +360,7 @@ testWithServiceTypes((serviceVersion) => { eventHubName: "ehname", fullyQualifiedNamespace: "fqdn", ownerId: "owner", - partitionId: "0" + partitionId: "0", }, new AbortController().signal ); @@ -377,7 +377,7 @@ testWithServiceTypes((serviceVersion) => { const commonFields = { fullyQualifiedNamespace: "irrelevant namespace", eventHubName: "irrelevant eventhub name", - consumerGroup: "irrelevant consumer group" + consumerGroup: "irrelevant consumer group", }; const handlers = new FakeSubscriptionEventHandlers(); @@ -387,7 +387,7 @@ testWithServiceTypes((serviceVersion) => { // abandoned claim { ...commonFields, partitionId: "1001", ownerId: "", etag: "abandoned etag" }, // normally owned claim - { ...commonFields, partitionId: "1002", ownerId: "owned partition", etag: "owned etag" } + { ...commonFields, partitionId: "1002", ownerId: "owned partition", etag: "owned etag" }, // 1003 - completely unowned ]); @@ -399,14 +399,14 @@ testWithServiceTypes((serviceVersion) => { managementSession: { getEventHubProperties: async () => { return { - partitionIds + partitionIds, }; - } + }, }, config: { entityPath: commonFields.eventHubName, - host: commonFields.fullyQualifiedNamespace - } + host: commonFields.fullyQualifiedNamespace, + }, }; const ep = new EventProcessor( @@ -427,9 +427,9 @@ testWithServiceTypes((serviceVersion) => { }, isReceivingFromPartition() { return false; - } + }, }, - loadBalancingStrategy: new BalancedLoadBalancingStrategy(60000) + loadBalancingStrategy: new BalancedLoadBalancingStrategy(60000), } ); @@ -467,7 +467,7 @@ testWithServiceTypes((serviceVersion) => { partitionId: "1001", ownerId: ep.id, etag: currentOwnerships[0].etag, - lastModifiedTimeInMs: currentOwnerships[0].lastModifiedTimeInMs + lastModifiedTimeInMs: currentOwnerships[0].lastModifiedTimeInMs, }, // 1002 is not going to be claimed since it's already owned so it should be untouched originalClaimedPartitions[1], @@ -476,8 +476,8 @@ testWithServiceTypes((serviceVersion) => { partitionId: "1003", ownerId: ep.id, etag: currentOwnerships[2].etag, - lastModifiedTimeInMs: currentOwnerships[2].lastModifiedTimeInMs - } + lastModifiedTimeInMs: currentOwnerships[2].lastModifiedTimeInMs, + }, ]); // now let's "unclaim" everything by stopping our event processor @@ -491,7 +491,7 @@ testWithServiceTypes((serviceVersion) => { partitionId: "1001", ownerId: ep.id, etag: currentOwnerships[0].etag, - lastModifiedTimeInMs: currentOwnerships[0].lastModifiedTimeInMs + lastModifiedTimeInMs: currentOwnerships[0].lastModifiedTimeInMs, }, // 1002 is not going to be claimed since it's already owned so it should be untouched originalClaimedPartitions[1], @@ -500,8 +500,8 @@ testWithServiceTypes((serviceVersion) => { partitionId: "1003", ownerId: ep.id, etag: currentOwnerships[2].etag, - lastModifiedTimeInMs: currentOwnerships[2].lastModifiedTimeInMs - } + lastModifiedTimeInMs: currentOwnerships[2].lastModifiedTimeInMs, + }, ]); const ownershipsAfterStop = await checkpointStore.listOwnership( @@ -517,7 +517,7 @@ testWithServiceTypes((serviceVersion) => { partitionId: "1001", ownerId: "", etag: ownershipsAfterStop[0].etag, - lastModifiedTimeInMs: ownershipsAfterStop[0].lastModifiedTimeInMs + lastModifiedTimeInMs: ownershipsAfterStop[0].lastModifiedTimeInMs, }, // 1002 is not going to be claimed since it's already owned so it should be untouched originalClaimedPartitions[1], @@ -526,8 +526,8 @@ testWithServiceTypes((serviceVersion) => { partitionId: "1003", ownerId: "", etag: ownershipsAfterStop[2].etag, - lastModifiedTimeInMs: ownershipsAfterStop[2].lastModifiedTimeInMs - } + lastModifiedTimeInMs: ownershipsAfterStop[2].lastModifiedTimeInMs, + }, ]); }); }); @@ -544,7 +544,7 @@ testWithServiceTypes((serviceVersion) => { updateCheckpoint: async () => { /* no-op */ }, - listCheckpoints: async () => [] + listCheckpoints: async () => [], }; const eventProcessor = new EventProcessor( @@ -556,11 +556,11 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err, _) => { errors.push(err); - } + }, }, faultyCheckpointStore, { - ...defaultOptions + ...defaultOptions, } ); @@ -573,7 +573,7 @@ testWithServiceTypes((serviceVersion) => { name: "waiting for checkpoint store errors to show up", timeBetweenRunsMs: 1000, maxTimes: 30, - until: async () => errors.length !== 0 + until: async () => errors.length !== 0, }); errors.length.should.equal(partitionIds.length); @@ -622,12 +622,12 @@ testWithServiceTypes((serviceVersion) => { processError: async (err, _) => { errors.add(err); throw new Error("These are logged but ignored"); - } + }, }, new InMemoryCheckpointStore(), { ...defaultOptions, - startPosition: earliestEventPosition + startPosition: earliestEventPosition, } ); @@ -641,7 +641,7 @@ testWithServiceTypes((serviceVersion) => { maxTimes: 30, until: async () => { return errors.size >= partitionIds.length * 3; - } + }, }); const messages = [...errors].map((e) => e.message); messages.sort(); @@ -651,7 +651,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should expose an id", async function(): Promise { + it("should expose an id", async function (): Promise { const processor = new EventProcessor( EventHubConsumerClient.defaultConsumerGroupName, consumerClient["_context"], @@ -661,12 +661,12 @@ testWithServiceTypes((serviceVersion) => { }, processError: async () => { /* no-op */ - } + }, }, new InMemoryCheckpointStore(), { ...defaultOptions, - startPosition: latestEventPosition + startPosition: latestEventPosition, } ); @@ -674,7 +674,7 @@ testWithServiceTypes((serviceVersion) => { id.length.should.be.gt(1); }); - it("id can be forced to be a specific value", async function(): Promise { + it("id can be forced to be a specific value", async function (): Promise { const processor = new EventProcessor( EventHubConsumerClient.defaultConsumerGroupName, consumerClient["_context"], @@ -684,7 +684,7 @@ testWithServiceTypes((serviceVersion) => { }, processError: async () => { /* no-op */ - } + }, }, new InMemoryCheckpointStore(), { ...defaultOptions, ownerId: "hello", startPosition: latestEventPosition } @@ -693,16 +693,14 @@ testWithServiceTypes((serviceVersion) => { processor.id.should.equal("hello"); }); - it("should treat consecutive start invocations as idempotent", async function(): Promise { + it("should treat consecutive start invocations as idempotent", async function (): Promise { const partitionIds = await producerClient.getPartitionIds(); // ensure we have at least 2 partitions partitionIds.length.should.gte(2); - const { - subscriptionEventHandler, - startPosition - } = await SubscriptionHandlerForTests.startingFromHere(producerClient); + const { subscriptionEventHandler, startPosition } = + await SubscriptionHandlerForTests.startingFromHere(producerClient); const processor = new EventProcessor( EventHubConsumerClient.defaultConsumerGroupName, @@ -711,7 +709,7 @@ testWithServiceTypes((serviceVersion) => { new InMemoryCheckpointStore(), { ...defaultOptions, - startPosition: startPosition + startPosition: startPosition, } ); @@ -731,7 +729,7 @@ testWithServiceTypes((serviceVersion) => { subscriptionEventHandler.allShutdown(partitionIds).should.equal(true); }); - it("should not throw if stop is called without start", async function(): Promise { + it("should not throw if stop is called without start", async function (): Promise { let didPartitionProcessorStart = false; const processor = new EventProcessor( @@ -746,12 +744,12 @@ testWithServiceTypes((serviceVersion) => { }, processError: async () => { /* no-op */ - } + }, }, new InMemoryCheckpointStore(), { ...defaultOptions, - startPosition: latestEventPosition + startPosition: latestEventPosition, } ); @@ -761,16 +759,14 @@ testWithServiceTypes((serviceVersion) => { didPartitionProcessorStart.should.equal(false); }); - it("should support start after stopping", async function(): Promise { + it("should support start after stopping", async function (): Promise { const partitionIds = await producerClient.getPartitionIds(); // ensure we have at least 2 partitions partitionIds.length.should.gte(2); - const { - subscriptionEventHandler, - startPosition - } = await SubscriptionHandlerForTests.startingFromHere(producerClient); + const { subscriptionEventHandler, startPosition } = + await SubscriptionHandlerForTests.startingFromHere(producerClient); const processor = new EventProcessor( EventHubConsumerClient.defaultConsumerGroupName, @@ -779,7 +775,7 @@ testWithServiceTypes((serviceVersion) => { new InMemoryCheckpointStore(), { ...defaultOptions, - startPosition: startPosition + startPosition: startPosition, } ); @@ -814,15 +810,11 @@ testWithServiceTypes((serviceVersion) => { subscriptionEventHandler.allShutdown(partitionIds).should.equal(true); }); - describe("Partition processor", function(): void { - it("should support processing events across multiple partitions", async function(): Promise< - void - > { + describe("Partition processor", function (): void { + it("should support processing events across multiple partitions", async function (): Promise { const partitionIds = await producerClient.getPartitionIds(); - const { - subscriptionEventHandler, - startPosition - } = await SubscriptionHandlerForTests.startingFromHere(producerClient); + const { subscriptionEventHandler, startPosition } = + await SubscriptionHandlerForTests.startingFromHere(producerClient); const processor = new EventProcessor( EventHubConsumerClient.defaultConsumerGroupName, @@ -831,7 +823,7 @@ testWithServiceTypes((serviceVersion) => { new InMemoryCheckpointStore(), { ...defaultOptions, - startPosition: startPosition + startPosition: startPosition, } ); @@ -850,28 +842,26 @@ testWithServiceTypes((serviceVersion) => { }); }); - describe("InMemory Partition Manager", function(): void { - it("should claim ownership, get a list of ownership and update checkpoint", async function(): Promise< - void - > { + describe("InMemory Partition Manager", function (): void { + it("should claim ownership, get a list of ownership and update checkpoint", async function (): Promise { const inMemoryCheckpointStore = new InMemoryCheckpointStore(); const partitionOwnership1: PartitionOwnership = { fullyQualifiedNamespace: "myNamespace.servicebus.windows.net", eventHubName: "myEventHub", consumerGroup: EventHubConsumerClient.defaultConsumerGroupName, ownerId: generate_uuid(), - partitionId: "0" + partitionId: "0", }; const partitionOwnership2: PartitionOwnership = { fullyQualifiedNamespace: "myNamespace.servicebus.windows.net", eventHubName: "myEventHub", consumerGroup: EventHubConsumerClient.defaultConsumerGroupName, ownerId: generate_uuid(), - partitionId: "1" + partitionId: "1", }; const partitionOwnership = await inMemoryCheckpointStore.claimOwnership([ partitionOwnership1, - partitionOwnership2 + partitionOwnership2, ]); partitionOwnership.length.should.equals(2); const ownershiplist = await inMemoryCheckpointStore.listOwnership( @@ -887,7 +877,7 @@ testWithServiceTypes((serviceVersion) => { consumerGroup: EventHubConsumerClient.defaultConsumerGroupName, partitionId: "0", sequenceNumber: 10, - offset: 50 + offset: 50, }; await inMemoryCheckpointStore.updateCheckpoint(checkpoint); @@ -906,7 +896,7 @@ testWithServiceTypes((serviceVersion) => { ); }); - it("should receive events from the checkpoint", async function(): Promise { + it("should receive events from the checkpoint", async function (): Promise { const partitionIds = await producerClient.getPartitionIds(); // ensure we have at least 2 partitions @@ -958,7 +948,7 @@ testWithServiceTypes((serviceVersion) => { inMemoryCheckpointStore, { ...defaultOptions, - startPosition: earliestEventPosition + startPosition: earliestEventPosition, } ); @@ -1066,17 +1056,17 @@ testWithServiceTypes((serviceVersion) => { const basicProperties = { consumerGroup: "initial consumer group", eventHubName: "initial event hub name", - fullyQualifiedNamespace: "initial fully qualified namespace" + fullyQualifiedNamespace: "initial fully qualified namespace", }; const originalPartitionOwnership = { ...basicProperties, ownerId: "initial owner ID", - partitionId: "1001" + partitionId: "1001", }; const copyOfPartitionOwnership = { - ...originalPartitionOwnership + ...originalPartitionOwnership, }; assertUnique(originalPartitionOwnership); @@ -1104,11 +1094,11 @@ testWithServiceTypes((serviceVersion) => { ...basicProperties, sequenceNumber: 1, partitionId: "1", - offset: 101 + offset: 101, }; const copyOfOriginalCheckpoint = { - ...originalCheckpoint + ...originalCheckpoint, }; await checkpointStore.updateCheckpoint(originalCheckpoint); @@ -1127,8 +1117,8 @@ testWithServiceTypes((serviceVersion) => { }); }); - describe("Load balancing", function(): void { - beforeEach("validate partitions", async function(): Promise { + describe("Load balancing", function (): void { + beforeEach("validate partitions", async function (): Promise { const partitionIds = await producerClient.getPartitionIds(); // ensure we have at least 3 partitions partitionIds.length.should.gte( @@ -1137,9 +1127,7 @@ testWithServiceTypes((serviceVersion) => { ); }); - it("should 'steal' partitions until all the processors have reached a steady-state (BalancedLoadBalancingStrategy)", async function(): Promise< - void - > { + it("should 'steal' partitions until all the processors have reached a steady-state (BalancedLoadBalancingStrategy)", async function (): Promise { loggerForTest("starting up the stealing test"); const processorByName: Dictionary = {}; @@ -1187,19 +1175,19 @@ testWithServiceTypes((serviceVersion) => { const expectedMessagePrefix = "EventProcessor test - multiple partitions - "; for (const partitionId of partitionIds) { await producerClient.sendBatch([{ body: expectedMessagePrefix + partitionId }], { - partitionId + partitionId, }); } const processor1LoadBalancingInterval = { - loopIntervalInMs: 1000 + loopIntervalInMs: 1000, }; // working around a potential deadlock - this allows `processor-2` to more // aggressively pursue getting its required partitions and avoid being in // lockstep with `processor-1` const processor2LoadBalancingInterval = { - loopIntervalInMs: processor1LoadBalancingInterval.loopIntervalInMs / 2 + loopIntervalInMs: processor1LoadBalancingInterval.loopIntervalInMs / 2, }; processorByName[`processor-1`] = new EventProcessor( @@ -1211,7 +1199,7 @@ testWithServiceTypes((serviceVersion) => { ...defaultOptions, startPosition: earliestEventPosition, ...processor1LoadBalancingInterval, - loadBalancingStrategy: new BalancedLoadBalancingStrategy(60000) + loadBalancingStrategy: new BalancedLoadBalancingStrategy(60000), } ); @@ -1222,7 +1210,7 @@ testWithServiceTypes((serviceVersion) => { maxTimes: 60, timeBetweenRunsMs: 1000, until: async () => partitionOwnershipArr.size === partitionIds.length, - errorMessageFn: () => `${partitionOwnershipArr.size}/${partitionIds.length}` + errorMessageFn: () => `${partitionOwnershipArr.size}/${partitionIds.length}`, }); processorByName[`processor-2`] = new EventProcessor( @@ -1234,7 +1222,7 @@ testWithServiceTypes((serviceVersion) => { ...defaultOptions, startPosition: earliestEventPosition, ...processor2LoadBalancingInterval, - loadBalancingStrategy: new BalancedLoadBalancingStrategy(60000) + loadBalancingStrategy: new BalancedLoadBalancingStrategy(60000), } ); @@ -1261,16 +1249,16 @@ testWithServiceTypes((serviceVersion) => { ); // map of ownerId as a key and partitionIds as a value - const partitionOwnershipMap: Map = ownershipListToMap( - partitionOwnership - ); + const partitionOwnershipMap: Map = + ownershipListToMap(partitionOwnership); // if stealing has occurred we just want to make sure that _all_ // the stealing has completed. const isBalanced = (friendlyName: string): boolean => { const n = Math.floor(partitionIds.length / 2); - const numPartitions = partitionOwnershipMap.get(processorByName[friendlyName].id)! - .length; + const numPartitions = partitionOwnershipMap.get( + processorByName[friendlyName].id + )!.length; return numPartitions === n || numPartitions === n + 1; }; @@ -1279,7 +1267,7 @@ testWithServiceTypes((serviceVersion) => { } return true; - } + }, }); for (const processor in processorByName) { @@ -1299,9 +1287,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should 'steal' partitions until all the processors have reached a steady-state (GreedyLoadBalancingStrategy)", async function(): Promise< - void - > { + it("should 'steal' partitions until all the processors have reached a steady-state (GreedyLoadBalancingStrategy)", async function (): Promise { loggerForTest("starting up the stealing test"); const processorByName: Dictionary = {}; @@ -1349,19 +1335,19 @@ testWithServiceTypes((serviceVersion) => { const expectedMessagePrefix = "EventProcessor test - multiple partitions - "; for (const partitionId of partitionIds) { await producerClient.sendBatch([{ body: expectedMessagePrefix + partitionId }], { - partitionId + partitionId, }); } const processor1LoadBalancingInterval = { - loopIntervalInMs: 1000 + loopIntervalInMs: 1000, }; // working around a potential deadlock - this allows `processor-2` to more // aggressively pursue getting its required partitions and avoid being in // lockstep with `processor-1` const processor2LoadBalancingInterval = { - loopIntervalInMs: processor1LoadBalancingInterval.loopIntervalInMs / 2 + loopIntervalInMs: processor1LoadBalancingInterval.loopIntervalInMs / 2, }; processorByName[`processor-1`] = new EventProcessor( @@ -1373,7 +1359,7 @@ testWithServiceTypes((serviceVersion) => { ...defaultOptions, startPosition: earliestEventPosition, ...processor1LoadBalancingInterval, - loadBalancingStrategy: new GreedyLoadBalancingStrategy(60000) + loadBalancingStrategy: new GreedyLoadBalancingStrategy(60000), } ); @@ -1384,7 +1370,7 @@ testWithServiceTypes((serviceVersion) => { maxTimes: 60, timeBetweenRunsMs: 1000, until: async () => partitionOwnershipArr.size === partitionIds.length, - errorMessageFn: () => `${partitionOwnershipArr.size}/${partitionIds.length}` + errorMessageFn: () => `${partitionOwnershipArr.size}/${partitionIds.length}`, }); processorByName[`processor-2`] = new EventProcessor( @@ -1396,7 +1382,7 @@ testWithServiceTypes((serviceVersion) => { ...defaultOptions, startPosition: earliestEventPosition, ...processor2LoadBalancingInterval, - loadBalancingStrategy: new GreedyLoadBalancingStrategy(60000) + loadBalancingStrategy: new GreedyLoadBalancingStrategy(60000), } ); @@ -1423,16 +1409,16 @@ testWithServiceTypes((serviceVersion) => { ); // map of ownerId as a key and partitionIds as a value - const partitionOwnershipMap: Map = ownershipListToMap( - partitionOwnership - ); + const partitionOwnershipMap: Map = + ownershipListToMap(partitionOwnership); // if stealing has occurred we just want to make sure that _all_ // the stealing has completed. const isBalanced = (friendlyName: string): boolean => { const n = Math.floor(partitionIds.length / 2); - const numPartitions = partitionOwnershipMap.get(processorByName[friendlyName].id)! - .length; + const numPartitions = partitionOwnershipMap.get( + processorByName[friendlyName].id + )!.length; return numPartitions === n || numPartitions === n + 1; }; @@ -1441,7 +1427,7 @@ testWithServiceTypes((serviceVersion) => { } return true; - } + }, }); for (const processor in processorByName) { @@ -1461,9 +1447,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should ensure that all the processors reach a steady-state where all partitions are being processed (BalancedLoadBalancingStrategy)", async function(): Promise< - void - > { + it("should ensure that all the processors reach a steady-state where all partitions are being processed (BalancedLoadBalancingStrategy)", async function (): Promise { const processorByName: Dictionary = {}; const partitionIds = await producerClient.getPartitionIds(); const checkpointStore = new InMemoryCheckpointStore(); @@ -1487,7 +1471,7 @@ testWithServiceTypes((serviceVersion) => { const expectedMessagePrefix = "EventProcessor test - multiple partitions - "; for (const partitionId of partitionIds) { await producerClient.sendBatch([{ body: expectedMessagePrefix + partitionId }], { - partitionId + partitionId, }); } @@ -1501,7 +1485,7 @@ testWithServiceTypes((serviceVersion) => { { ...defaultOptions, startPosition: earliestEventPosition, - loadBalancingStrategy: new BalancedLoadBalancingStrategy(60000) + loadBalancingStrategy: new BalancedLoadBalancingStrategy(60000), } ); processorByName[processorName].start(); @@ -1512,7 +1496,7 @@ testWithServiceTypes((serviceVersion) => { name: "partitionownership", timeBetweenRunsMs: 5000, maxTimes: 10, - until: async () => partitionOwnershipArr.size === partitionIds.length + until: async () => partitionOwnershipArr.size === partitionIds.length, }); // map of ownerId as a key and partitionIds as a value @@ -1549,9 +1533,7 @@ testWithServiceTypes((serviceVersion) => { .length.should.oneOf([n, n + 1]); }); - it("should ensure that all the processors reach a steady-state where all partitions are being processed (GreedyLoadBalancingStrategy)", async function(): Promise< - void - > { + it("should ensure that all the processors reach a steady-state where all partitions are being processed (GreedyLoadBalancingStrategy)", async function (): Promise { const processorByName: Dictionary = {}; const partitionIds = await producerClient.getPartitionIds(); const checkpointStore = new InMemoryCheckpointStore(); @@ -1574,7 +1556,7 @@ testWithServiceTypes((serviceVersion) => { const expectedMessagePrefix = "EventProcessor test - multiple partitions - "; for (const partitionId of partitionIds) { await producerClient.sendBatch([{ body: expectedMessagePrefix + partitionId }], { - partitionId + partitionId, }); } @@ -1588,7 +1570,7 @@ testWithServiceTypes((serviceVersion) => { { ...defaultOptions, startPosition: earliestEventPosition, - loadBalancingStrategy: new GreedyLoadBalancingStrategy(60000) + loadBalancingStrategy: new GreedyLoadBalancingStrategy(60000), } ); processorByName[processorName].start(); @@ -1599,7 +1581,7 @@ testWithServiceTypes((serviceVersion) => { name: "partitionownership", timeBetweenRunsMs: 5000, maxTimes: 10, - until: async () => partitionOwnershipArr.size === partitionIds.length + until: async () => partitionOwnershipArr.size === partitionIds.length, }); // map of ownerId as a key and partitionIds as a value @@ -1635,9 +1617,7 @@ testWithServiceTypes((serviceVersion) => { .length.should.oneOf([n, n + 1]); }); - it("should ensure that all the processors maintain a steady-state when all partitions are being processed (BalancedLoadBalancingStrategy)", async function(): Promise< - void - > { + it("should ensure that all the processors maintain a steady-state when all partitions are being processed (BalancedLoadBalancingStrategy)", async function (): Promise { const partitionIds = await producerClient.getPartitionIds(); const checkpointStore = new InMemoryCheckpointStore(); const claimedPartitionsMap = {} as { [eventProcessorId: string]: Set }; @@ -1685,7 +1665,7 @@ testWithServiceTypes((serviceVersion) => { ); thrashAfterSettling = true; } - } + }, }; const eventProcessorOptions: FullEventProcessorOptions = { @@ -1696,7 +1676,7 @@ testWithServiceTypes((serviceVersion) => { ownerLevel: 0, // For this test we don't want to actually checkpoint, just test ownership. startPosition: latestEventPosition, - loadBalancingStrategy: new BalancedLoadBalancingStrategy(60000) + loadBalancingStrategy: new BalancedLoadBalancingStrategy(60000), }; const processor1 = new EventProcessor( @@ -1737,7 +1717,7 @@ testWithServiceTypes((serviceVersion) => { lastLoopError = { reason: "Not all event processors have shown up", eventProcessorIds, - partitionOwnershipHistory + partitionOwnershipHistory, }; return false; } @@ -1751,7 +1731,7 @@ testWithServiceTypes((serviceVersion) => { reason: "Delta between partitions is greater than 1", a: Array.from(aProcessorPartitions), b: Array.from(bProcessorPartitions), - partitionOwnershipHistory + partitionOwnershipHistory, }; return false; } @@ -1766,12 +1746,12 @@ testWithServiceTypes((serviceVersion) => { partitionIds, a: Array.from(aProcessorPartitions), b: Array.from(bProcessorPartitions), - partitionOwnershipHistory + partitionOwnershipHistory, }; } return innerAllPartitionsClaimed; - } + }, }); } catch (err) { // close processors @@ -1788,7 +1768,7 @@ testWithServiceTypes((serviceVersion) => { name: "partitionThrash", maxTimes: 4, timeBetweenRunsMs: 1000, - until: async () => thrashAfterSettling + until: async () => thrashAfterSettling, }); } catch (err) { // swallow error, check trashAfterSettling for the condition in finally @@ -1802,9 +1782,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should ensure that all the processors maintain a steady-state when all partitions are being processed (GreedyLoadBalancingStrategy)", async function(): Promise< - void - > { + it("should ensure that all the processors maintain a steady-state when all partitions are being processed (GreedyLoadBalancingStrategy)", async function (): Promise { const partitionIds = await producerClient.getPartitionIds(); const checkpointStore = new InMemoryCheckpointStore(); const claimedPartitionsMap = {} as { [eventProcessorId: string]: Set }; @@ -1852,7 +1830,7 @@ testWithServiceTypes((serviceVersion) => { ); thrashAfterSettling = true; } - } + }, }; const eventProcessorOptions: FullEventProcessorOptions = { @@ -1863,7 +1841,7 @@ testWithServiceTypes((serviceVersion) => { ownerLevel: 0, // For this test we don't want to actually checkpoint, just test ownership. startPosition: latestEventPosition, - loadBalancingStrategy: new GreedyLoadBalancingStrategy(60000) + loadBalancingStrategy: new GreedyLoadBalancingStrategy(60000), }; const processor1 = new EventProcessor( @@ -1904,7 +1882,7 @@ testWithServiceTypes((serviceVersion) => { lastLoopError = { reason: "Not all event processors have shown up", eventProcessorIds, - partitionOwnershipHistory + partitionOwnershipHistory, }; return false; } @@ -1918,7 +1896,7 @@ testWithServiceTypes((serviceVersion) => { reason: "Delta between partitions is greater than 1", a: Array.from(aProcessorPartitions), b: Array.from(bProcessorPartitions), - partitionOwnershipHistory + partitionOwnershipHistory, }; return false; } @@ -1933,12 +1911,12 @@ testWithServiceTypes((serviceVersion) => { partitionIds, a: Array.from(aProcessorPartitions), b: Array.from(bProcessorPartitions), - partitionOwnershipHistory + partitionOwnershipHistory, }; } return innerAllPartitionsClaimed; - } + }, }); } catch (err) { // close processors @@ -1955,7 +1933,7 @@ testWithServiceTypes((serviceVersion) => { name: "partitionThrash", maxTimes: 4, timeBetweenRunsMs: 1000, - until: async () => thrashAfterSettling + until: async () => thrashAfterSettling, }); } catch (err) { // swallow error, check trashAfterSettling for the condition in finally @@ -2009,7 +1987,7 @@ testWithServiceTypes((serviceVersion) => { onabort: () => { /* no-op */ }, - dispatchEvent: () => true + dispatchEvent: () => true, }; return abortSignal; diff --git a/sdk/eventhub/event-hubs/test/internal/eventdata.spec.ts b/sdk/eventhub/event-hubs/test/internal/eventdata.spec.ts index 68b4cbab61b1..984b3ea082b8 100644 --- a/sdk/eventhub/event-hubs/test/internal/eventdata.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/eventdata.spec.ts @@ -6,7 +6,7 @@ import chai, { assert, should } from "chai"; import { dataSectionTypeCode, sequenceSectionTypeCode, - valueSectionTypeCode + valueSectionTypeCode, } from "../../src/dataTransformer"; import { AmqpAnnotatedMessage } from "@azure/core-amqp"; import { Message } from "rhea-promise"; @@ -18,36 +18,36 @@ const testAnnotations = { "x-opt-enqueued-time": Date.now(), "x-opt-offset": "42", "x-opt-sequence-number": 0, - "x-opt-partition-key": "key" + "x-opt-partition-key": "key", }; const testBody = '{ "foo": "bar" }'; const applicationProperties = { - propKey: "propValue" + propKey: "propValue", }; const testMessage: Message = { body: testBody, message_annotations: testAnnotations, - application_properties: applicationProperties + application_properties: applicationProperties, }; const properties = { - foo: "bar" + foo: "bar", }; const testSourceEventData: EventData = { body: testBody, - properties: properties + properties: properties, }; const messageFromED = toRheaMessage(testSourceEventData); testWithServiceTypes(() => { - describe("EventData", function(): void { - describe("fromRheaMessage", function(): void { - it("populates body with the message body", function(): void { + describe("EventData", function (): void { + describe("fromRheaMessage", function (): void { + it("populates body with the message body", function (): void { const testEventData = fromRheaMessage(testMessage, false); testEventData.body.should.equal(testBody); }); @@ -56,7 +56,7 @@ testWithServiceTypes(() => { const testEventData = fromRheaMessage( { ...testMessage, - ...{ content_type: "application/json", correlation_id: "cid", message_id: 1 } + ...{ content_type: "application/json", correlation_id: "cid", message_id: 1 }, }, false ); @@ -69,33 +69,33 @@ testWithServiceTypes(() => { should().equal(testEventData.correlationId, "cid", "Unexpected correlationId found."); }); - describe("properties", function(): void { - it("enqueuedTimeUtc gets the enqueued time from system properties", function(): void { + describe("properties", function (): void { + it("enqueuedTimeUtc gets the enqueued time from system properties", function (): void { const testEventData = fromRheaMessage(testMessage, false); testEventData .enqueuedTimeUtc!.getTime() .should.equal(testAnnotations["x-opt-enqueued-time"]); }); - it("offset gets the offset from system properties", function(): void { + it("offset gets the offset from system properties", function (): void { const testEventData = fromRheaMessage(testMessage, false); testEventData.offset!.should.equal(testAnnotations["x-opt-offset"]); }); - it("sequenceNumber gets the sequence number from system properties", function(): void { + it("sequenceNumber gets the sequence number from system properties", function (): void { const testEventData = fromRheaMessage(testMessage, false); testEventData.sequenceNumber!.should.equal(testAnnotations["x-opt-sequence-number"]); }); - it("partitionKey gets the sequence number from system properties", function(): void { + it("partitionKey gets the sequence number from system properties", function (): void { const testEventData = fromRheaMessage(testMessage, false); testEventData.partitionKey!.should.equal(testAnnotations["x-opt-partition-key"]); }); - it("returns systemProperties for unknown message annotations", function(): void { + it("returns systemProperties for unknown message annotations", function (): void { const extraAnnotations = { "x-iot-foo-prop": "just-a-foo", - "x-iot-bar-prop": "bar-above-the-rest" + "x-iot-bar-prop": "bar-above-the-rest", }; const testEventData = fromRheaMessage( { @@ -103,8 +103,8 @@ testWithServiceTypes(() => { application_properties: applicationProperties, message_annotations: { ...testAnnotations, - ...extraAnnotations - } + ...extraAnnotations, + }, }, false ); @@ -122,7 +122,7 @@ testWithServiceTypes(() => { ); }); - it("returns systemProperties for special known properties", function(): void { + it("returns systemProperties for special known properties", function (): void { const testEventData = fromRheaMessage( { body: testBody, @@ -140,7 +140,7 @@ testWithServiceTypes(() => { absolute_expiry_time: new Date(0), creation_time: new Date(0), group_id: "groupId", - group_sequence: 1 + group_sequence: 1, }, false ); @@ -171,7 +171,7 @@ testWithServiceTypes(() => { const timestamp = new Date(); const extraAnnotations = { "x-date": timestamp, - "x-number": timestamp.getTime() + "x-number": timestamp.getTime(), }; const testEventData = fromRheaMessage( { @@ -180,13 +180,13 @@ testWithServiceTypes(() => { topLevelDate: timestamp, child: { nestedDate: timestamp, - children: [timestamp, { deepDate: timestamp }] - } + children: [timestamp, { deepDate: timestamp }], + }, }, message_annotations: { ...testAnnotations, - ...extraAnnotations - } + ...extraAnnotations, + }, }, false ); @@ -202,13 +202,13 @@ testWithServiceTypes(() => { topLevelDate: timestamp.getTime(), child: { nestedDate: timestamp.getTime(), - children: [timestamp.getTime(), { deepDate: timestamp.getTime() }] - } + children: [timestamp.getTime(), { deepDate: timestamp.getTime() }], + }, }); }); }); - describe("toAmqpMessage", function(): void { - it("populates body with the message body encoded", function(): void { + describe("toAmqpMessage", function (): void { + it("populates body with the message body encoded", function (): void { const expectedTestBodyContents = Buffer.from(JSON.stringify(testBody)); should().equal( expectedTestBodyContents.equals(messageFromED.body.content), @@ -225,21 +225,21 @@ testWithServiceTypes(() => { it("populates top-level fields", () => { const message = toRheaMessage({ ...testSourceEventData, - ...{ contentType: "application/json", correlationId: "cid", messageId: 1 } + ...{ contentType: "application/json", correlationId: "cid", messageId: 1 }, }); should().equal(message.message_id, 1, "Unexpected message_id found."); should().equal(message.content_type, "application/json", "Unexpected content_type found."); should().equal(message.correlation_id, "cid", "Unexpected correlation_id found."); }); - it("populates application_properties of the message", function(): void { + it("populates application_properties of the message", function (): void { messageFromED.application_properties!.should.equal(properties); }); it("AmqpAnnotatedMessage (explicit type)", () => { const amqpAnnotatedMessage: AmqpAnnotatedMessage = { body: "hello", - bodyType: "value" + bodyType: "value", }; const rheaMessage = toRheaMessage(amqpAnnotatedMessage); @@ -250,7 +250,7 @@ testWithServiceTypes(() => { it("AmqpAnnotatedMessage (implicit type)", () => { const amqpAnnotatedMessage: AmqpAnnotatedMessage = { body: "hello", - bodyType: undefined + bodyType: undefined, }; const rheaMessage = toRheaMessage(amqpAnnotatedMessage); @@ -260,7 +260,7 @@ testWithServiceTypes(() => { it("EventData", () => { const event: EventData = { - body: "hello" + body: "hello", }; const rheaMessage = toRheaMessage(event); @@ -278,9 +278,9 @@ testWithServiceTypes(() => { getRawAmqpMessage() { return { body: this.body, - bodyType: "sequence" + bodyType: "sequence", }; - } + }, }; const rheaMessage = toRheaMessage(event); @@ -298,9 +298,9 @@ testWithServiceTypes(() => { getRawAmqpMessage() { return { body: this.body, - bodyType: "data" + bodyType: "data", }; - } + }, }; const rheaMessage = toRheaMessage(event); @@ -318,9 +318,9 @@ testWithServiceTypes(() => { getRawAmqpMessage() { return { body: this.body, - bodyType: "value" + bodyType: "value", }; - } + }, }; const rheaMessage = toRheaMessage(event); diff --git a/sdk/eventhub/event-hubs/test/internal/loadBalancingStrategy.spec.ts b/sdk/eventhub/event-hubs/test/internal/loadBalancingStrategy.spec.ts index cad5fc72ccc9..9c9024f8c9c0 100644 --- a/sdk/eventhub/event-hubs/test/internal/loadBalancingStrategy.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/loadBalancingStrategy.spec.ts @@ -25,7 +25,7 @@ testWithServiceTypes(() => { ownerId: partitionToOwner[partitionId], partitionId: partitionId, etag: "etag", - lastModifiedTimeInMs: Date.now() + lastModifiedTimeInMs: Date.now(), }); } @@ -51,7 +51,7 @@ testWithServiceTypes(() => { // we already own this so we won't // try to reclaim it. ownerId: "ownerId", - partitionId: "" + partitionId: "", }); m.set("2", { @@ -61,7 +61,7 @@ testWithServiceTypes(() => { // owned by someone else - we'll steal this // partition ownerId: "someOtherOwnerId", - partitionId: "" + partitionId: "", }); const lb = new UnbalancedLoadBalancingStrategy(); @@ -83,7 +83,7 @@ testWithServiceTypes(() => { createOwnershipMap({ "1": "b", "2": "a", - "3": "a" + "3": "a", }), allPartitions ); @@ -99,7 +99,7 @@ testWithServiceTypes(() => { "a", createOwnershipMap({ "1": "b", - "2": "a" + "2": "a", }), allPartitions ); @@ -120,7 +120,7 @@ testWithServiceTypes(() => { createOwnershipMap({ "1": "b", "2": "a", - "3": "a" + "3": "a", }), allPartitions ); @@ -136,7 +136,7 @@ testWithServiceTypes(() => { "0": "b", "1": "b", "2": "a", - "3": "a" + "3": "a", }), allPartitions ); @@ -158,7 +158,7 @@ testWithServiceTypes(() => { createOwnershipMap({ "0": "a", "1": "a", - "2": "a" + "2": "a", }), ["0", "1", "2"] ); @@ -176,7 +176,7 @@ testWithServiceTypes(() => { "0": "a", "1": "a", "2": "a", - "3": "a" + "3": "a", }), ["0", "1", "2", "3"] ); @@ -222,7 +222,7 @@ testWithServiceTypes(() => { "7": "c", "8": "c", - "9": "d" + "9": "d", }); const requestedPartitions = lbs.getPartitionsToCliam("c", initialOwnershipMap, partitions); @@ -243,7 +243,7 @@ testWithServiceTypes(() => { createOwnershipMap({ "0": "a", "1": "b", - "2": "a" + "2": "a", }), ["0", "1", "2"] ); @@ -264,7 +264,7 @@ testWithServiceTypes(() => { "a", createOwnershipMap({ "1": "b", - "3": "a" + "3": "a", }), allPartitions ); @@ -278,7 +278,7 @@ testWithServiceTypes(() => { createOwnershipMap({ "1": "b", "2": "a", - "3": "a" + "3": "a", }), allPartitions ); @@ -292,7 +292,7 @@ testWithServiceTypes(() => { "0": "b", "1": "a", "2": "b", - "3": "a" + "3": "a", }), allPartitions ); @@ -306,7 +306,7 @@ testWithServiceTypes(() => { const allPartitions = ["0", "1"]; const ownershipMap = createOwnershipMap({ "0": "b", - "1": "a" + "1": "a", }); // At this point, 'a' has its fair share of partitions, and none should be returned. @@ -335,7 +335,7 @@ testWithServiceTypes(() => { createOwnershipMap({ "1": "b", "2": "a", - "3": "a" + "3": "a", }), allPartitions ); @@ -351,7 +351,7 @@ testWithServiceTypes(() => { "a", createOwnershipMap({ "1": "b", - "2": "a" + "2": "a", }), allPartitions ); @@ -372,7 +372,7 @@ testWithServiceTypes(() => { createOwnershipMap({ "1": "b", "2": "a", - "3": "a" + "3": "a", }), allPartitions ); @@ -388,7 +388,7 @@ testWithServiceTypes(() => { "0": "b", "1": "b", "2": "a", - "3": "a" + "3": "a", }), allPartitions ); @@ -410,7 +410,7 @@ testWithServiceTypes(() => { createOwnershipMap({ "0": "a", "1": "a", - "2": "a" + "2": "a", }), ["0", "1", "2"] ); @@ -428,7 +428,7 @@ testWithServiceTypes(() => { "0": "a", "1": "a", "2": "a", - "3": "a" + "3": "a", }), ["0", "1", "2", "3"] ); @@ -455,7 +455,7 @@ testWithServiceTypes(() => { "4": "b", "5": "b", "6": "b", - "7": "b" + "7": "b", }), allPartitions ); @@ -502,7 +502,7 @@ testWithServiceTypes(() => { "7": "c", "8": "c", - "9": "d" + "9": "d", }); const requestedPartitions = lbs.getPartitionsToCliam("c", initialOwnershipMap, partitions); @@ -523,7 +523,7 @@ testWithServiceTypes(() => { createOwnershipMap({ "0": "a", "1": "b", - "2": "a" + "2": "a", }), ["0", "1", "2"] ); @@ -544,7 +544,7 @@ testWithServiceTypes(() => { "a", createOwnershipMap({ "1": "b", - "3": "a" + "3": "a", }), allPartitions ); @@ -558,7 +558,7 @@ testWithServiceTypes(() => { createOwnershipMap({ "1": "b", "2": "a", - "3": "a" + "3": "a", }), allPartitions ); @@ -572,7 +572,7 @@ testWithServiceTypes(() => { "0": "b", "1": "a", "2": "b", - "3": "a" + "3": "a", }), allPartitions ); @@ -586,7 +586,7 @@ testWithServiceTypes(() => { const allPartitions = ["0", "1", "2", "3"]; const ownershipMap = createOwnershipMap({ "0": "b", - "1": "a" + "1": "a", }); // At this point, "a" should only grab 1 partition since both "a" and "b" should end up with 2 partitions each. diff --git a/sdk/eventhub/event-hubs/test/internal/misc.spec.ts b/sdk/eventhub/event-hubs/test/internal/misc.spec.ts index 3d6dfcc55385..8fd955161266 100644 --- a/sdk/eventhub/event-hubs/test/internal/misc.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/misc.spec.ts @@ -8,11 +8,11 @@ import { EventHubProducerClient, EventHubProperties, ReceivedEventData, - Subscription + Subscription, } from "../../src"; import { TRACEPARENT_PROPERTY, - extractSpanContextFromEventData + extractSpanContextFromEventData, } from "../../src/diagnostics/instrumentEventData"; import { SubscriptionHandlerForTests } from "../public/utils/subscriptionHandlerForTests"; import { TraceFlags } from "@azure/core-tracing"; @@ -41,10 +41,10 @@ testWithServiceTypes((serviceVersion) => { }); } - describe("Misc tests", function(): void { + describe("Misc tests", function (): void { const service = { connectionString: env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], - path: env[EnvVarKeys.EVENTHUB_NAME] + path: env[EnvVarKeys.EVENTHUB_NAME], }; let consumerClient: EventHubConsumerClient; let producerClient: EventHubProducerClient; @@ -52,7 +52,7 @@ testWithServiceTypes((serviceVersion) => { let partitionId: string; let lastEnqueuedOffset: number; - before("validate environment", async function(): Promise { + before("validate environment", async function (): Promise { should.exist( env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], "define EVENTHUB_CONNECTION_STRING in your environment before running integration tests." @@ -83,9 +83,7 @@ testWithServiceTypes((serviceVersion) => { await consumerClient.close(); }); - it("should be able to send and receive a large message correctly", async function(): Promise< - void - > { + it("should be able to send and receive a large message correctly", async function (): Promise { const bodysize = 220 * 1024; const msgString = "A".repeat(220 * 1024); const msgBody = Buffer.from(msgString); @@ -110,19 +108,17 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err) => { reject(err); - } + }, }, { - startPosition: { offset: lastEnqueuedOffset } + startPosition: { offset: lastEnqueuedOffset }, } ); }); await subscription!.close(); }); - it("should be able to send and receive a JSON object as a message correctly", async function(): Promise< - void - > { + it("should be able to send and receive a JSON object as a message correctly", async function (): Promise { const msgBody = { id: "123-456-789", weight: 10, @@ -131,9 +127,9 @@ testWithServiceTypes((serviceVersion) => { { id: "098-789-564", weight: 20, - isBlue: false - } - ] + isBlue: false, + }, + ], }; const obj: EventData = { body: msgBody }; debug(`Partition ${partitionId} has last message with offset ${lastEnqueuedOffset}.`); @@ -156,28 +152,26 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err) => { reject(err); - } + }, }, { - startPosition: { offset: lastEnqueuedOffset } + startPosition: { offset: lastEnqueuedOffset }, } ); }); await subscription!.close(); }); - it("should be able to send and receive an array as a message correctly", async function(): Promise< - void - > { + it("should be able to send and receive an array as a message correctly", async function (): Promise { const msgBody = [ { id: "098-789-564", weight: 20, - isBlue: false + isBlue: false, }, 10, 20, - "some string" + "some string", ]; const obj: EventData = { body: msgBody, properties: { message_id: uuid() } }; debug(`Partition ${partitionId} has last message with offset ${lastEnqueuedOffset}.`); @@ -200,17 +194,17 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err) => { reject(err); - } + }, }, { - startPosition: { offset: lastEnqueuedOffset } + startPosition: { offset: lastEnqueuedOffset }, } ); }); await subscription!.close(); }); - it("should be able to send a boolean as a message correctly", async function(): Promise { + it("should be able to send a boolean as a message correctly", async function (): Promise { const msgBody = true; const obj: EventData = { body: msgBody }; debug(`Partition ${partitionId} has last message with offset ${lastEnqueuedOffset}.`); @@ -233,19 +227,17 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err) => { reject(err); - } + }, }, { - startPosition: { offset: lastEnqueuedOffset } + startPosition: { offset: lastEnqueuedOffset }, } ); }); await subscription!.close(); }); - it("should be able to send and receive batched messages correctly ", async function(): Promise< - void - > { + it("should be able to send and receive batched messages correctly ", async function (): Promise { debug(`Partition ${partitionId} has last message with offset ${lastEnqueuedOffset}.`); const messageCount = 5; const d: EventData[] = []; @@ -272,10 +264,10 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err) => { reject(err); - } + }, }, { - startPosition: { offset: lastEnqueuedOffset } + startPosition: { offset: lastEnqueuedOffset }, } ); }); @@ -286,9 +278,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should be able to send and receive batched messages as JSON objects correctly ", async function(): Promise< - void - > { + it("should be able to send and receive batched messages as JSON objects correctly ", async function (): Promise { debug(`Partition ${partitionId} has last message with offset ${lastEnqueuedOffset}.`); const messageCount = 5; const d: EventData[] = []; @@ -303,13 +293,13 @@ testWithServiceTypes((serviceVersion) => { { id: "098-789-564", weight: 20, - isBlue: false - } - ] + isBlue: false, + }, + ], }, properties: { - message_id: uuid() - } + message_id: uuid(), + }, }; d.push(obj); } @@ -332,10 +322,10 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err) => { reject(err); - } + }, }, { - startPosition: { offset: lastEnqueuedOffset } + startPosition: { offset: lastEnqueuedOffset }, } ); }); @@ -347,13 +337,9 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should consistently send messages with partitionkey to a partitionId", async function(): Promise< - void - > { - const { - subscriptionEventHandler, - startPosition - } = await SubscriptionHandlerForTests.startingFromHere(consumerClient); + it("should consistently send messages with partitionkey to a partitionId", async function (): Promise { + const { subscriptionEventHandler, startPosition } = + await SubscriptionHandlerForTests.startingFromHere(consumerClient); const msgToSendCount = 50; debug("Sending %d messages.", msgToSendCount); @@ -368,7 +354,7 @@ testWithServiceTypes((serviceVersion) => { const partitionKey = getRandomInt(10); senderPromises.push( producerClient.sendBatch([{ body: "Hello EventHub " + i }], { - partitionKey: partitionKey.toString() + partitionKey: partitionKey.toString(), }) ); } @@ -382,7 +368,7 @@ testWithServiceTypes((serviceVersion) => { try { subscription = consumerClient.subscribe(subscriptionEventHandler, { - startPosition + startPosition, }); const receivedEvents = await subscriptionEventHandler.waitForFullEvents( hubInfo.partitionIds, @@ -412,8 +398,8 @@ testWithServiceTypes((serviceVersion) => { }); }).timeout(60000); - describe("extractSpanContextFromEventData", function() { - it("should extract a SpanContext from a properly instrumented EventData", function() { + describe("extractSpanContextFromEventData", function () { + it("should extract a SpanContext from a properly instrumented EventData", function () { const traceId = "11111111111111111111111111111111"; const spanId = "2222222222222222"; const flags = "00"; @@ -424,11 +410,11 @@ testWithServiceTypes((serviceVersion) => { sequenceNumber: 0, partitionKey: null, properties: { - [TRACEPARENT_PROPERTY]: `00-${traceId}-${spanId}-${flags}` + [TRACEPARENT_PROPERTY]: `00-${traceId}-${spanId}-${flags}`, }, getRawAmqpMessage() { return {} as any; - } + }, }; const spanContext = extractSpanContextFromEventData(eventData); @@ -443,7 +429,7 @@ testWithServiceTypes((serviceVersion) => { ); }); - it("should return undefined when EventData is not properly instrumented", function() { + it("should return undefined when EventData is not properly instrumented", function () { const traceId = "11111111111111111111111111111111"; const spanId = "2222222222222222"; const flags = "00"; @@ -454,11 +440,11 @@ testWithServiceTypes((serviceVersion) => { sequenceNumber: 0, partitionKey: null, properties: { - [TRACEPARENT_PROPERTY]: `99-${traceId}-${spanId}-${flags}` + [TRACEPARENT_PROPERTY]: `99-${traceId}-${spanId}-${flags}`, }, getRawAmqpMessage() { return {} as any; - } + }, }; const spanContext = extractSpanContextFromEventData(eventData); @@ -469,7 +455,7 @@ testWithServiceTypes((serviceVersion) => { ); }); - it("should return undefined when EventData is not instrumented", function() { + it("should return undefined when EventData is not instrumented", function () { const eventData: ReceivedEventData = { body: "This is a test.", enqueuedTimeUtc: new Date(), @@ -478,7 +464,7 @@ testWithServiceTypes((serviceVersion) => { partitionKey: null, getRawAmqpMessage() { return {} as any; - } + }, }; const spanContext = extractSpanContextFromEventData(eventData); 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 21a4ecc449de..4911e0fe25a5 100644 --- a/sdk/eventhub/event-hubs/test/internal/node/disconnect.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/node/disconnect.spec.ts @@ -30,13 +30,13 @@ testWithServiceTypes((serviceVersion) => { }); } - describe("disconnected", function() { + describe("disconnected", function () { let partitionIds: string[] = []; const service = { connectionString: env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], - path: env[EnvVarKeys.EVENTHUB_NAME] + path: env[EnvVarKeys.EVENTHUB_NAME], }; - before("validate environment", function(): void { + before("validate environment", function (): void { should.exist( env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], "define EVENTHUB_CONNECTION_STRING in your environment before running integration tests." @@ -47,7 +47,7 @@ testWithServiceTypes((serviceVersion) => { ); }); - before("get partition ids", async function() { + before("get partition ids", async function () { const client = new EventHubConsumerClient( EventHubConsumerClient.defaultConsumerGroupName, service.connectionString, @@ -57,7 +57,7 @@ testWithServiceTypes((serviceVersion) => { return client.close(); }); - describe("EventHubSender", function() { + describe("EventHubSender", function () { /** * Test added for issue https://github.com/Azure/azure-sdk-for-js/issues/15002 * Prior to fixing this issue, a TypeError would be thrown when this test was ran. @@ -92,8 +92,8 @@ testWithServiceTypes((serviceVersion) => { }); }); - describe("ConnectionContext", function() { - describe("onDisconnected", function() { + describe("ConnectionContext", function () { + describe("onDisconnected", function () { it("does not fail when entities are closed concurrently", async () => { const context = createConnectionContext(service.connectionString, service.path); @@ -122,16 +122,16 @@ testWithServiceTypes((serviceVersion) => { // Initialize receiver links await receiver1.initialize({ abortSignal: undefined, - timeoutInMs: 60000 + timeoutInMs: 60000, }); await receiver2.initialize({ abortSignal: undefined, - timeoutInMs: 60000 + timeoutInMs: 60000, }); // We are going to override sender1's close method so that it also invokes receiver2's close method. const sender1Close = sender1.close.bind(sender1); - sender1.close = async function() { + sender1.close = async function () { sender2.close().catch(() => { /* no-op */ }); @@ -140,7 +140,7 @@ testWithServiceTypes((serviceVersion) => { // We are going to override receiver1's close method so that it also invokes receiver2's close method. const receiver1Close = receiver1.close.bind(receiver1); - receiver1.close = async function() { + receiver1.close = async function () { receiver2.close().catch(() => { /* no-op */ }); @@ -153,7 +153,7 @@ testWithServiceTypes((serviceVersion) => { }); }); - describe("close", function() { + describe("close", function () { it("does not fail when entities are closed concurrently", async () => { const context = createConnectionContext(service.connectionString, service.path); @@ -182,16 +182,16 @@ testWithServiceTypes((serviceVersion) => { // Initialize receiver links await receiver1.initialize({ abortSignal: undefined, - timeoutInMs: 60000 + timeoutInMs: 60000, }); await receiver2.initialize({ abortSignal: undefined, - timeoutInMs: 60000 + timeoutInMs: 60000, }); // We are going to override sender1's close method so that it also invokes receiver2's close method. const sender1Close = sender1.close.bind(sender1); - sender1.close = async function() { + sender1.close = async function () { sender2.close().catch(() => { /* no-op */ }); @@ -200,7 +200,7 @@ testWithServiceTypes((serviceVersion) => { // We are going to override receiver1's close method so that it also invokes receiver2's close method. const originalClose = receiver1.close.bind(receiver1); - receiver1.close = async function() { + receiver1.close = async function () { receiver2.close().catch(() => { /* no-op */ }); 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 2a337d8fc52f..ab741cf39685 100644 --- a/sdk/eventhub/event-hubs/test/internal/node/packageInfo.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/node/packageInfo.spec.ts @@ -13,7 +13,7 @@ const should = chai.should(); // following test is in place to ensure the values in package.json and in this file are consistent testWithServiceTypes(() => { - describe("Ensure package name and version are consistent in SDK and package.json", function(): void { + describe("Ensure package name and version are consistent in SDK and package.json", function (): void { it("Ensure constants.ts file is consistent with package.json", () => { const packageJsonFilePath = path.join(__dirname, "..", "..", "..", "..", "package.json"); const rawFileContents = fs.readFileSync(packageJsonFilePath, { encoding: "utf-8" }); diff --git a/sdk/eventhub/event-hubs/test/internal/partitionPump.spec.ts b/sdk/eventhub/event-hubs/test/internal/partitionPump.spec.ts index 0698bdbdf769..413d198094c5 100644 --- a/sdk/eventhub/event-hubs/test/internal/partitionPump.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/partitionPump.spec.ts @@ -7,7 +7,7 @@ import { SpanOptions, SpanStatusCode, context, - setSpanContext + setSpanContext, } from "@azure/core-tracing"; import { TestSpan, TestTracer } from "@azure/test-utils"; import { createProcessingSpan, trace } from "../../src/partitionPump"; @@ -24,7 +24,7 @@ testWithServiceTypes(() => { describe("telemetry", () => { const eventHubProperties = { host: "thehost", - entityPath: "theeventhubname" + entityPath: "theeventhubname", }; class TestTracer2 extends TestTracer { @@ -49,8 +49,8 @@ testWithServiceTypes(() => { await createProcessingSpan([], eventHubProperties, { tracingOptions: { - tracingContext: fakeParentSpanContext - } + tracingContext: fakeParentSpanContext, + }, }); should.equal(tracer.spanName, "Azure.EventHubs.process"); @@ -59,13 +59,14 @@ testWithServiceTypes(() => { tracer.spanOptions!.kind!.should.equal(SpanKind.CONSUMER); tracer.context!.should.equal(fakeParentSpanContext); - const attributes = tracer.getActiveSpans().find((s) => s.name === "Azure.EventHubs.process") - ?.attributes; + const attributes = tracer + .getActiveSpans() + .find((s) => s.name === "Azure.EventHubs.process")?.attributes; attributes!.should.deep.equal({ "az.namespace": "Microsoft.EventHub", "message_bus.destination": eventHubProperties.entityPath, - "peer.address": eventHubProperties.host + "peer.address": eventHubProperties.host, }); resetTracer(); @@ -80,7 +81,7 @@ testWithServiceTypes(() => { sequenceNumber: 0, getRawAmqpMessage() { return {} as any; - } + }, }; const { tracer, resetTracer } = setTracerForTest(new TestTracer2()); @@ -93,8 +94,8 @@ testWithServiceTypes(() => { { ...requiredEventProperties }, { tracingOptions: { - tracingContext: setSpanContext(context.active(), firstEvent.spanContext()) - } + tracingContext: setSpanContext(context.active(), firstEvent.spanContext()), + }, }, "entityPath", "host" @@ -104,12 +105,12 @@ testWithServiceTypes(() => { { ...requiredEventProperties }, { tracingOptions: { - tracingContext: setSpanContext(context.active(), thirdEvent.spanContext()) - } + tracingContext: setSpanContext(context.active(), thirdEvent.spanContext()), + }, }, "entityPath", "host" - ).event as ReceivedEventData + ).event as ReceivedEventData, ]; await createProcessingSpan(receivedEvents, eventHubProperties, {}); diff --git a/sdk/eventhub/event-hubs/test/internal/receiveBatch.spec.ts b/sdk/eventhub/event-hubs/test/internal/receiveBatch.spec.ts index 8b7c74437200..702e7586d16a 100644 --- a/sdk/eventhub/event-hubs/test/internal/receiveBatch.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/receiveBatch.spec.ts @@ -7,7 +7,7 @@ import { EventHubConsumerClient, EventHubProducerClient, EventPosition, - MessagingError + MessagingError, } from "../../src"; import { EventHubReceiver } from "../../src/eventHubReceiver"; import chai from "chai"; @@ -33,15 +33,15 @@ testWithServiceTypes((serviceVersion) => { }); } - describe("EventHubConsumerClient", function(): void { + describe("EventHubConsumerClient", function (): void { const service = { connectionString: env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], - path: env[EnvVarKeys.EVENTHUB_NAME] + path: env[EnvVarKeys.EVENTHUB_NAME], }; let producerClient: EventHubProducerClient; let consumerClient: EventHubConsumerClient; let partitionIds: string[]; - before("validate environment", async function(): Promise { + before("validate environment", async function (): Promise { should.exist( env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], "define EVENTHUB_CONNECTION_STRING in your environment before running integration tests." @@ -67,7 +67,7 @@ testWithServiceTypes((serviceVersion) => { await consumerClient.close(); }); - describe("EventHubConsumer receiveBatch", function(): void { + describe("EventHubConsumer receiveBatch", function (): void { it("should not lose messages on error", async () => { const partitionId = partitionIds[0]; const { lastEnqueuedSequenceNumber } = await producerClient.getPartitionProperties( @@ -77,7 +77,7 @@ testWithServiceTypes((serviceVersion) => { // Ensure the receiver only looks at new messages. const startPosition: EventPosition = { sequenceNumber: lastEnqueuedSequenceNumber, - isInclusive: false + isInclusive: false, }; // Send a message we expect to receive. @@ -92,8 +92,8 @@ testWithServiceTypes((serviceVersion) => { startPosition, { retryOptions: { - maxRetries: 0 - } + maxRetries: 0, + }, } ); @@ -132,7 +132,7 @@ testWithServiceTypes((serviceVersion) => { // Ensure the receiver only looks at new messages. const startPosition: EventPosition = { sequenceNumber: lastEnqueuedSequenceNumber, - isInclusive: false + isInclusive: false, }; // Send a message we expect to receive. @@ -147,8 +147,8 @@ testWithServiceTypes((serviceVersion) => { startPosition, { retryOptions: { - maxRetries: 1 - } + maxRetries: 1, + }, } ); diff --git a/sdk/eventhub/event-hubs/test/internal/sender.spec.ts b/sdk/eventhub/event-hubs/test/internal/sender.spec.ts index d70046450f5c..2df75bcb862b 100644 --- a/sdk/eventhub/event-hubs/test/internal/sender.spec.ts +++ b/sdk/eventhub/event-hubs/test/internal/sender.spec.ts @@ -5,7 +5,7 @@ import { EnvVarKeys, getEnvVars, getStartingPositionsForTests, - setTracerForTest + setTracerForTest, } from "../public/utils/testUtils"; import { EventData, @@ -15,7 +15,7 @@ import { OperationOptions, ReceivedEventData, SendBatchOptions, - TryAddOptions + TryAddOptions, } from "../../src"; import { SpanGraph, TestSpan } from "@azure/test-utils"; import { context, setSpan } from "@azure/core-tracing"; @@ -45,16 +45,16 @@ testWithServiceTypes((serviceVersion) => { }); } - describe("EventHub Sender", function(): void { + describe("EventHub Sender", function (): void { const service = { connectionString: env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], - path: env[EnvVarKeys.EVENTHUB_NAME] + path: env[EnvVarKeys.EVENTHUB_NAME], }; let producerClient: EventHubProducerClient; let consumerClient: EventHubConsumerClient; let startPosition: { [partitionId: string]: EventPosition }; - before("validate environment", function(): void { + before("validate environment", function (): void { should.exist( env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], "define EVENTHUB_CONNECTION_STRING in your environment before running integration tests." @@ -82,8 +82,8 @@ testWithServiceTypes((serviceVersion) => { await consumerClient.close(); }); - describe("Create batch", function(): void { - describe("tryAdd", function() { + describe("Create batch", function (): void { + describe("tryAdd", function () { it("doesn't grow if invalid events are added", async () => { const batch = await producerClient.createBatch({ maxSizeInBytes: 20 }); const event = { body: Buffer.alloc(30).toString() }; @@ -103,7 +103,7 @@ testWithServiceTypes((serviceVersion) => { it("partitionId is set as expected", async () => { const batch = await producerClient.createBatch({ - partitionId: "0" + partitionId: "0", }); should.equal(batch.partitionId, "0"); }); @@ -111,14 +111,14 @@ testWithServiceTypes((serviceVersion) => { it("partitionId is set as expected when it is 0 i.e. falsy", async () => { const batch = await producerClient.createBatch({ // @ts-expect-error Testing the value 0 is not ignored. - partitionId: 0 + partitionId: 0, }); should.equal(batch.partitionId, "0"); }); it("partitionKey is set as expected", async () => { const batch = await producerClient.createBatch({ - partitionKey: "boo" + partitionKey: "boo", }); should.equal(batch.partitionKey, "boo"); }); @@ -126,7 +126,7 @@ testWithServiceTypes((serviceVersion) => { it("partitionKey is set as expected when it is 0 i.e. falsy", async () => { const batch = await producerClient.createBatch({ // @ts-expect-error Testing the value 0 is not ignored. - partitionKey: 0 + partitionKey: 0, }); should.equal(batch.partitionKey, "0"); }); @@ -136,11 +136,11 @@ testWithServiceTypes((serviceVersion) => { should.equal(batch.maxSizeInBytes, 30); }); - it("should be sent successfully", async function(): Promise { + it("should be sent successfully", async function (): Promise { const list = ["Albert", `${Buffer.from("Mike".repeat(1300000))}`, "Marie"]; const batch = await producerClient.createBatch({ - partitionId: "0" + partitionId: "0", }); batch.partitionId!.should.equal("0"); @@ -156,7 +156,7 @@ testWithServiceTypes((serviceVersion) => { ); const subscriber = consumerClient.subscribe("0", subscriptionEventHandler, { - startPosition + startPosition, }); await producerClient.sendBatch(batch); @@ -176,14 +176,12 @@ testWithServiceTypes((serviceVersion) => { ); }); - it("should be sent successfully when partitionId is 0 i.e. falsy", async function(): Promise< - void - > { + it("should be sent successfully when partitionId is 0 i.e. falsy", async function (): Promise { const list = ["Albert", "Marie"]; const batch = await producerClient.createBatch({ // @ts-expect-error Testing the value 0 is not ignored. - partitionId: 0 + partitionId: 0, }); batch.partitionId!.should.equal("0"); @@ -198,7 +196,7 @@ testWithServiceTypes((serviceVersion) => { ); const subscriber = consumerClient.subscribe("0", subscriptionEventHandler, { - startPosition + startPosition, }); await producerClient.sendBatch(batch); @@ -216,14 +214,12 @@ testWithServiceTypes((serviceVersion) => { ); }); - it("should be sent successfully when partitionKey is 0 i.e. falsy", async function(): Promise< - void - > { + it("should be sent successfully when partitionKey is 0 i.e. falsy", async function (): Promise { const list = ["Albert", "Marie"]; const batch = await producerClient.createBatch({ // @ts-expect-error Testing the value 0 is not ignored. - partitionKey: 0 + partitionKey: 0, }); batch.partitionKey!.should.equal("0"); @@ -238,7 +234,7 @@ testWithServiceTypes((serviceVersion) => { ); const subscriber = consumerClient.subscribe(subscriptionEventHandler, { - startPosition + startPosition, }); await producerClient.sendBatch(batch); @@ -256,16 +252,16 @@ testWithServiceTypes((serviceVersion) => { ); }); - it("should be sent successfully with properties", async function(): Promise { + it("should be sent successfully with properties", async function (): Promise { const properties = { test: "super" }; const list = [ { body: "Albert-With-Properties", properties }, { body: "Mike-With-Properties", properties }, - { body: "Marie-With-Properties", properties } + { body: "Marie-With-Properties", properties }, ]; const batch = await producerClient.createBatch({ - partitionId: "0" + partitionId: "0", }); batch.maxSizeInBytes.should.be.gt(0); @@ -294,13 +290,13 @@ testWithServiceTypes((serviceVersion) => { if (receivedEvents.length >= 3) { waitUntilEventsReceivedResolver(); } - } + }, }, { startPosition: { - sequenceNumber + sequenceNumber, }, - maxBatchSize: 3 + maxBatchSize: 3, } ); @@ -316,14 +312,14 @@ testWithServiceTypes((serviceVersion) => { receivedEvents.map((event) => { return { body: event.body, - properties: event.properties + properties: event.properties, }; }), "Received messages should be equal to our sent messages" ); }); - it("can be manually traced", async function(): Promise { + it("can be manually traced", async function (): Promise { const { tracer, resetTracer } = setTracerForTest(); const rootSpan = tracer.startSpan("root"); @@ -331,7 +327,7 @@ testWithServiceTypes((serviceVersion) => { const list = [{ name: "Albert" }, { name: "Marie" }]; const eventDataBatch = await producerClient.createBatch({ - partitionId: "0" + partitionId: "0", }); for (let i = 0; i < 2; i++) { @@ -339,8 +335,8 @@ testWithServiceTypes((serviceVersion) => { { body: `${list[i].name}` }, { tracingOptions: { - tracingContext: setSpan(context.active(), rootSpan) - } + tracingContext: setSpan(context.active(), rootSpan), + }, } ); } @@ -358,15 +354,15 @@ testWithServiceTypes((serviceVersion) => { children: [ { name: "Azure.EventHubs.message", - children: [] + children: [], }, { name: "Azure.EventHubs.message", - children: [] - } - ] - } - ] + children: [], + }, + ], + }, + ], }; tracer.getSpanGraph(rootSpan.spanContext().traceId).should.eql(expectedGraph); @@ -395,28 +391,28 @@ testWithServiceTypes((serviceVersion) => { rootSpan: TestSpan ): Pick { return { - parentSpan: rootSpan.spanContext() + parentSpan: rootSpan.spanContext(), }; } function legacyOptionsUsingSpan(rootSpan: TestSpan): Pick { return { - parentSpan: rootSpan + parentSpan: rootSpan, }; } function modernOptions(rootSpan: TestSpan): OperationOptions { return { tracingOptions: { - tracingContext: setSpan(context.active(), rootSpan) - } + tracingContext: setSpan(context.active(), rootSpan), + }, }; } [legacyOptionsUsingSpan, legacyOptionsUsingSpanContext, modernOptions].forEach( (optionsFn) => { describe(`tracing (${optionsFn.name})`, () => { - it("will not instrument already instrumented events", async function(): Promise { + it("will not instrument already instrumented events", async function (): Promise { const { tracer, resetTracer } = setTracerForTest(); const rootSpan = tracer.startSpan("test"); @@ -426,13 +422,13 @@ testWithServiceTypes((serviceVersion) => { { name: "Marie", properties: { - [TRACEPARENT_PROPERTY]: "foo" - } - } + [TRACEPARENT_PROPERTY]: "foo", + }, + }, ]; const eventDataBatch = await producerClient.createBatch({ - partitionId: "0" + partitionId: "0", }); for (let i = 0; i < 2; i++) { @@ -455,11 +451,11 @@ testWithServiceTypes((serviceVersion) => { children: [ { name: "Azure.EventHubs.message", - children: [] - } - ] - } - ] + children: [], + }, + ], + }, + ], }; tracer.getSpanGraph(rootSpan.spanContext().traceId).should.eql(expectedGraph); @@ -469,7 +465,7 @@ testWithServiceTypes((serviceVersion) => { resetTracer(); }); - it("will support tracing batch and send", async function(): Promise { + it("will support tracing batch and send", async function (): Promise { const { tracer, resetTracer } = setTracerForTest(); const rootSpan = tracer.startSpan("root"); @@ -477,15 +473,15 @@ testWithServiceTypes((serviceVersion) => { const list = [{ name: "Albert" }, { name: "Marie" }]; const eventDataBatch = await producerClient.createBatch({ - partitionId: "0" + partitionId: "0", }); for (let i = 0; i < 2; i++) { eventDataBatch.tryAdd({ body: `${list[i].name}` }, optionsFn(rootSpan)); } await producerClient.sendBatch(eventDataBatch, { tracingOptions: { - tracingContext: setSpan(context.active(), rootSpan) - } + tracingContext: setSpan(context.active(), rootSpan), + }, }); rootSpan.end(); @@ -500,19 +496,19 @@ testWithServiceTypes((serviceVersion) => { children: [ { name: "Azure.EventHubs.message", - children: [] + children: [], }, { name: "Azure.EventHubs.message", - children: [] + children: [], }, { name: "Azure.EventHubs.send", - children: [] - } - ] - } - ] + children: [], + }, + ], + }, + ], }; tracer.getSpanGraph(rootSpan.spanContext().traceId).should.eql(expectedGraph); @@ -525,7 +521,7 @@ testWithServiceTypes((serviceVersion) => { } ); - it("with partition key should be sent successfully.", async function(): Promise { + it("with partition key should be sent successfully.", async function (): Promise { const eventDataBatch = await producerClient.createBatch({ partitionKey: "1" }); for (let i = 0; i < 5; i++) { eventDataBatch.tryAdd({ body: `Hello World ${i}` }); @@ -533,10 +529,10 @@ testWithServiceTypes((serviceVersion) => { await producerClient.sendBatch(eventDataBatch); }); - it("with max message size should be sent successfully.", async function(): Promise { + it("with max message size should be sent successfully.", async function (): Promise { const eventDataBatch = await producerClient.createBatch({ maxSizeInBytes: 5000, - partitionId: "0" + partitionId: "0", }); const message = { body: `${Buffer.from("Z".repeat(4096))}` }; for (let i = 1; i <= 3; i++) { @@ -551,8 +547,8 @@ testWithServiceTypes((serviceVersion) => { }); }); - describe("Multiple sendBatch calls", function(): void { - it("should be sent successfully in parallel", async function(): Promise { + describe("Multiple sendBatch calls", function (): void { + it("should be sent successfully in parallel", async function (): Promise { const { subscriptionEventHandler } = await SubscriptionHandlerForTests.startingFromHere( consumerClient ); @@ -564,7 +560,7 @@ testWithServiceTypes((serviceVersion) => { await Promise.all(promises); const subscription = await consumerClient.subscribe(subscriptionEventHandler, { - startPosition + startPosition, }); try { @@ -583,16 +579,14 @@ testWithServiceTypes((serviceVersion) => { "Hello World 1", "Hello World 2", "Hello World 3", - "Hello World 4" + "Hello World 4", ]); } finally { subscription.close(); } }); - it("should be sent successfully in parallel, even when exceeding max event listener count of 1000", async function(): Promise< - void - > { + it("should be sent successfully in parallel, even when exceeding max event listener count of 1000", async function (): Promise { const senderCount = 1200; try { const promises = []; @@ -606,9 +600,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should be sent successfully in parallel by multiple clients", async function(): Promise< - void - > { + it("should be sent successfully in parallel by multiple clients", async function (): Promise { const senderCount = 3; try { const promises = []; @@ -635,11 +627,9 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should fail when a message greater than 1 MB is sent and succeed when a normal message is sent after that on the same link.", async function(): Promise< - void - > { + it("should fail when a message greater than 1 MB is sent and succeed when a normal message is sent after that on the same link.", async function (): Promise { const data: EventData = { - body: Buffer.from("Z".repeat(1300000)) + body: Buffer.from("Z".repeat(1300000)), }; try { debug("Sending a message of 300KB..."); @@ -657,7 +647,7 @@ testWithServiceTypes((serviceVersion) => { debug("Sent the message successfully on the same link.."); }); - it("can be manually traced", async function(): Promise { + it("can be manually traced", async function (): Promise { const { tracer, resetTracer } = setTracerForTest(); const rootSpan = tracer.startSpan("root"); @@ -669,8 +659,8 @@ testWithServiceTypes((serviceVersion) => { await producerClient.sendBatch(events, { partitionId: "0", tracingOptions: { - tracingContext: setSpan(context.active(), rootSpan) - } + tracingContext: setSpan(context.active(), rootSpan), + }, }); rootSpan.end(); @@ -685,31 +675,31 @@ testWithServiceTypes((serviceVersion) => { children: [ { name: "Azure.EventHubs.message", - children: [] + children: [], }, { name: "Azure.EventHubs.message", - children: [] + children: [], }, { name: "Azure.EventHubs.message", - children: [] + children: [], }, { name: "Azure.EventHubs.message", - children: [] + children: [], }, { name: "Azure.EventHubs.message", - children: [] + children: [], }, { name: "Azure.EventHubs.send", - children: [] - } - ] - } - ] + children: [], + }, + ], + }, + ], }; tracer.getSpanGraph(rootSpan.spanContext().traceId).should.eql(expectedGraph); @@ -718,7 +708,7 @@ testWithServiceTypes((serviceVersion) => { resetTracer(); }); - it("skips already instrumented events when manually traced", async function(): Promise { + it("skips already instrumented events when manually traced", async function (): Promise { const { tracer, resetTracer } = setTracerForTest(); const rootSpan = tracer.startSpan("root"); @@ -731,8 +721,8 @@ testWithServiceTypes((serviceVersion) => { await producerClient.sendBatch(events, { partitionId: "0", tracingOptions: { - tracingContext: setSpan(context.active(), rootSpan) - } + tracingContext: setSpan(context.active(), rootSpan), + }, }); rootSpan.end(); @@ -747,27 +737,27 @@ testWithServiceTypes((serviceVersion) => { children: [ { name: "Azure.EventHubs.message", - children: [] + children: [], }, { name: "Azure.EventHubs.message", - children: [] + children: [], }, { name: "Azure.EventHubs.message", - children: [] + children: [], }, { name: "Azure.EventHubs.message", - children: [] + children: [], }, { name: "Azure.EventHubs.send", - children: [] - } - ] - } - ] + children: [], + }, + ], + }, + ], }; tracer.getSpanGraph(rootSpan.spanContext().traceId).should.eql(expectedGraph); @@ -777,7 +767,7 @@ testWithServiceTypes((serviceVersion) => { }); }); - describe("Array of events", function() { + describe("Array of events", function () { it("should be sent successfully", async () => { const data: EventData[] = [{ body: "Hello World 1" }, { body: "Hello World 2" }]; const receivedEvents: ReceivedEventData[] = []; @@ -792,11 +782,11 @@ testWithServiceTypes((serviceVersion) => { async processEvents(events) { receivedEvents.push(...events); receivingResolver(); - } + }, }, { startPosition, - maxBatchSize: data.length + maxBatchSize: data.length, } ); @@ -822,11 +812,11 @@ testWithServiceTypes((serviceVersion) => { async processEvents(events) { receivedEvents.push(...events); receivingResolver(); - } + }, }, { startPosition, - maxBatchSize: data.length + maxBatchSize: data.length, } ); @@ -857,11 +847,11 @@ testWithServiceTypes((serviceVersion) => { async processEvents(events) { receivedEvents.push(...events); receivingResolver(); - } + }, }, { startPosition, - maxBatchSize: data.length + maxBatchSize: data.length, } ); @@ -877,7 +867,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("can be manually traced", async function(): Promise { + it("can be manually traced", async function (): Promise { const { tracer, resetTracer } = setTracerForTest(); const rootSpan = tracer.startSpan("root"); @@ -888,8 +878,8 @@ testWithServiceTypes((serviceVersion) => { } await producerClient.sendBatch(events, { tracingOptions: { - tracingContext: setSpan(context.active(), rootSpan) - } + tracingContext: setSpan(context.active(), rootSpan), + }, }); rootSpan.end(); @@ -904,31 +894,31 @@ testWithServiceTypes((serviceVersion) => { children: [ { name: "Azure.EventHubs.message", - children: [] + children: [], }, { name: "Azure.EventHubs.message", - children: [] + children: [], }, { name: "Azure.EventHubs.message", - children: [] + children: [], }, { name: "Azure.EventHubs.message", - children: [] + children: [], }, { name: "Azure.EventHubs.message", - children: [] + children: [], }, { name: "Azure.EventHubs.send", - children: [] - } - ] - } - ] + children: [], + }, + ], + }, + ], }; tracer.getSpanGraph(rootSpan.spanContext().traceId).should.eql(expectedGraph); @@ -941,12 +931,12 @@ testWithServiceTypes((serviceVersion) => { knownSendSpans[0].attributes.should.deep.equal({ "az.namespace": "Microsoft.EventHub", "message_bus.destination": producerClient.eventHubName, - "peer.address": producerClient.fullyQualifiedNamespace + "peer.address": producerClient.fullyQualifiedNamespace, }); resetTracer(); }); - it("skips already instrumented events when manually traced", async function(): Promise { + it("skips already instrumented events when manually traced", async function (): Promise { const { tracer, resetTracer } = setTracerForTest(); const rootSpan = tracer.startSpan("root"); @@ -958,8 +948,8 @@ testWithServiceTypes((serviceVersion) => { events[0].properties = { [TRACEPARENT_PROPERTY]: "foo" }; await producerClient.sendBatch(events, { tracingOptions: { - tracingContext: setSpan(context.active(), rootSpan) - } + tracingContext: setSpan(context.active(), rootSpan), + }, }); rootSpan.end(); @@ -974,27 +964,27 @@ testWithServiceTypes((serviceVersion) => { children: [ { name: "Azure.EventHubs.message", - children: [] + children: [], }, { name: "Azure.EventHubs.message", - children: [] + children: [], }, { name: "Azure.EventHubs.message", - children: [] + children: [], }, { name: "Azure.EventHubs.message", - children: [] + children: [], }, { name: "Azure.EventHubs.send", - children: [] - } - ] - } - ] + children: [], + }, + ], + }, + ], }; tracer.getSpanGraph(rootSpan.spanContext().traceId).should.eql(expectedGraph); @@ -1002,14 +992,12 @@ testWithServiceTypes((serviceVersion) => { resetTracer(); }); - it("should throw when partitionId and partitionKey are provided", async function(): Promise< - void - > { + it("should throw when partitionId and partitionKey are provided", async function (): Promise { try { const data: EventData[] = [ { - body: "Sender paritition id and partition key" - } + body: "Sender paritition id and partition key", + }, ]; await producerClient.sendBatch(data, { partitionKey: "1", partitionId: "0" }); throw new Error("Test Failure"); @@ -1021,8 +1009,8 @@ testWithServiceTypes((serviceVersion) => { }); }); - describe("Validation", function() { - describe("createBatch", function() { + describe("Validation", function () { + describe("createBatch", function () { it("throws an error if partitionId and partitionKey are set", async () => { try { await producerClient.createBatch({ partitionId: "0", partitionKey: "boo" }); @@ -1039,7 +1027,7 @@ testWithServiceTypes((serviceVersion) => { await producerClient.createBatch({ // @ts-expect-error Testing the value 0 is not ignored. partitionId: 0, - partitionKey: "boo" + partitionKey: "boo", }); throw new Error("Test failure"); } catch (error) { @@ -1054,7 +1042,7 @@ testWithServiceTypes((serviceVersion) => { await producerClient.createBatch({ partitionId: "1", // @ts-expect-error Testing the value 0 is not ignored. - partitionKey: 0 + partitionKey: 0, }); throw new Error("Test failure"); } catch (error) { @@ -1064,9 +1052,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("should throw when maxMessageSize is greater than maximum message size on the AMQP sender link", async function(): Promise< - void - > { + it("should throw when maxMessageSize is greater than maximum message size on the AMQP sender link", async function (): Promise { try { await producerClient.createBatch({ maxSizeInBytes: 2046528 }); throw new Error("Test Failure"); @@ -1077,24 +1063,24 @@ testWithServiceTypes((serviceVersion) => { } }); }); - describe("sendBatch with EventDataBatch", function() { + describe("sendBatch with EventDataBatch", function () { it("works if partitionKeys match", async () => { const misconfiguredOptions: SendBatchOptions = { - partitionKey: "foo" + partitionKey: "foo", }; const batch = await producerClient.createBatch({ partitionKey: "foo" }); await producerClient.sendBatch(batch, misconfiguredOptions); }); it("works if partitionIds match", async () => { const misconfiguredOptions: SendBatchOptions = { - partitionId: "0" + partitionId: "0", }; const batch = await producerClient.createBatch({ partitionId: "0" }); await producerClient.sendBatch(batch, misconfiguredOptions); }); it("throws an error if partitionKeys don't match", async () => { const badOptions: SendBatchOptions = { - partitionKey: "bar" + partitionKey: "bar", }; const batch = await producerClient.createBatch({ partitionKey: "foo" }); try { @@ -1108,7 +1094,7 @@ testWithServiceTypes((serviceVersion) => { }); it("throws an error if partitionKeys don't match (undefined)", async () => { const badOptions: SendBatchOptions = { - partitionKey: "bar" + partitionKey: "bar", }; const batch = await producerClient.createBatch(); try { @@ -1122,7 +1108,7 @@ testWithServiceTypes((serviceVersion) => { }); it("throws an error if partitionIds don't match", async () => { const badOptions: SendBatchOptions = { - partitionId: "0" + partitionId: "0", }; const batch = await producerClient.createBatch({ partitionId: "1" }); try { @@ -1136,7 +1122,7 @@ testWithServiceTypes((serviceVersion) => { }); it("throws an error if partitionIds don't match (undefined)", async () => { const badOptions: SendBatchOptions = { - partitionId: "0" + partitionId: "0", }; const batch = await producerClient.createBatch(); try { @@ -1150,7 +1136,7 @@ testWithServiceTypes((serviceVersion) => { }); it("throws an error if partitionId and partitionKey are set (create, send)", async () => { const badOptions: SendBatchOptions = { - partitionKey: "foo" + partitionKey: "foo", }; const batch = await producerClient.createBatch({ partitionId: "0" }); try { @@ -1162,7 +1148,7 @@ testWithServiceTypes((serviceVersion) => { }); it("throws an error if partitionId and partitionKey are set (send, create)", async () => { const badOptions: SendBatchOptions = { - partitionId: "0" + partitionId: "0", }; const batch = await producerClient.createBatch({ partitionKey: "foo" }); try { @@ -1175,7 +1161,7 @@ testWithServiceTypes((serviceVersion) => { it("throws an error if partitionId and partitionKey are set (send, send)", async () => { const badOptions: SendBatchOptions = { partitionKey: "foo", - partitionId: "0" + partitionId: "0", }; const batch = await producerClient.createBatch(); try { @@ -1187,11 +1173,11 @@ testWithServiceTypes((serviceVersion) => { }); }); - describe("sendBatch with EventDataBatch with events array", function() { + describe("sendBatch with EventDataBatch with events array", function () { it("throws an error if partitionId and partitionKey are set", async () => { const badOptions: SendBatchOptions = { partitionKey: "foo", - partitionId: "0" + partitionId: "0", }; const batch = [{ body: "Hello 1" }, { body: "Hello 2" }]; try { @@ -1207,7 +1193,7 @@ testWithServiceTypes((serviceVersion) => { const badOptions: SendBatchOptions = { partitionKey: "foo", // @ts-expect-error Testing the value 0 is not ignored. - partitionId: 0 + partitionId: 0, }; const batch = [{ body: "Hello 1" }, { body: "Hello 2" }]; try { @@ -1223,7 +1209,7 @@ testWithServiceTypes((serviceVersion) => { const badOptions: SendBatchOptions = { // @ts-expect-error Testing the value 0 is not ignored. partitionKey: 0, - partitionId: "0" + partitionId: "0", }; const batch = [{ body: "Hello 1" }, { body: "Hello 2" }]; try { @@ -1238,10 +1224,10 @@ testWithServiceTypes((serviceVersion) => { }); }); - describe("Negative scenarios", function(): void { - it("a message greater than 1 MB should fail.", async function(): Promise { + describe("Negative scenarios", function (): void { + it("a message greater than 1 MB should fail.", async function (): Promise { const data: EventData = { - body: Buffer.from("Z".repeat(1300000)) + body: Buffer.from("Z".repeat(1300000)), }; try { await producerClient.sendBatch([data]); @@ -1256,15 +1242,15 @@ testWithServiceTypes((serviceVersion) => { } }); - describe("on invalid partition ids like", function(): void { + describe("on invalid partition ids like", function (): void { // tslint:disable-next-line: no-null-keyword const invalidIds = ["XYZ", "-1", "1000", "-"]; - invalidIds.forEach(function(id: string | null): void { - it(`"${id}" should throw an error`, async function(): Promise { + invalidIds.forEach(function (id: string | null): void { + it(`"${id}" should throw an error`, async function (): Promise { try { debug("Created sender and will be sending a message to partition id ...", id); await producerClient.sendBatch([{ body: "Hello world!" }], { - partitionId: id as any + partitionId: id as any, }); debug("sent the message."); throw new Error("Test failure"); diff --git a/sdk/eventhub/event-hubs/test/public/amqpAnnotatedMessage.spec.ts b/sdk/eventhub/event-hubs/test/public/amqpAnnotatedMessage.spec.ts index 39a6c568dc12..26215c76170a 100644 --- a/sdk/eventhub/event-hubs/test/public/amqpAnnotatedMessage.spec.ts +++ b/sdk/eventhub/event-hubs/test/public/amqpAnnotatedMessage.spec.ts @@ -7,7 +7,7 @@ import { EventHubProducerClient, EventPosition, ReceivedEventData, - Subscription + Subscription, } from "../../src"; import { AmqpAnnotatedMessage } from "@azure/core-amqp"; import { BodyTypes } from "../../src/dataTransformer"; @@ -37,15 +37,15 @@ testWithServiceTypes((serviceVersion) => { return service?.stop(); }); } - describe("AmqpAnnotatedMessage", function(): void { + describe("AmqpAnnotatedMessage", function (): void { let producerClient: EventHubProducerClient; let consumerClient: EventHubConsumerClient; const service = { connectionString: env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], - path: env[EnvVarKeys.EVENTHUB_NAME] + path: env[EnvVarKeys.EVENTHUB_NAME], }; - before("validate environment", function(): void { + before("validate environment", function (): void { should.exist( env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], "define EVENTHUB_CONNECTION_STRING in your environment before running integration tests." @@ -65,7 +65,7 @@ testWithServiceTypes((serviceVersion) => { ); }); - afterEach("close the connection", async function(): Promise { + afterEach("close the connection", async function (): Promise { await producerClient.close(); await consumerClient.close(); }); @@ -80,17 +80,17 @@ testWithServiceTypes((serviceVersion) => { propOne: 1, propTwo: "two", propThree: true, - propFour: Date() + propFour: Date(), }, footer: { - propFooter: "foot" + propFooter: "foot", }, messageAnnotations: { propMsgAnnotate: "annotation" }, properties: { contentEncoding: "application/json; charset=utf-8", correlationId: randomTag, - messageId: v4() - } + messageId: v4(), + }, } as AmqpAnnotatedMessage; } @@ -115,10 +115,10 @@ testWithServiceTypes((serviceVersion) => { resolve(events[0]); return subscription.close(); } - } + }, }, { - startPosition: startingPositions + startPosition: startingPositions, } ); }); @@ -187,8 +187,8 @@ testWithServiceTypes((serviceVersion) => { [ { body: valueType, - bodyType: "value" - } + bodyType: "value", + }, ], { useBatch } ); @@ -211,7 +211,7 @@ testWithServiceTypes((serviceVersion) => { it(`sequences (useBatch: ${useBatch})`, async () => { const sequenceTypes = [ [[1], [2], [3]], - [1, 2, 3] + [1, 2, 3], ]; for (const sequenceType of sequenceTypes) { @@ -220,8 +220,8 @@ testWithServiceTypes((serviceVersion) => { [ { body: sequenceType, - bodyType: "sequence" - } + bodyType: "sequence", + }, ], { useBatch } ); @@ -252,8 +252,8 @@ testWithServiceTypes((serviceVersion) => { [ { body: dataType, - bodyType: "data" - } + bodyType: "data", + }, ], { useBatch } ); @@ -273,11 +273,13 @@ testWithServiceTypes((serviceVersion) => { } }); - ([ - ["sequence", [1, 2, 3]], - ["value", "hello"], - ["data", "hello"] - ] as [BodyTypes, any][]).forEach(([expectedBodyType, expectedBody]) => { + ( + [ + ["sequence", [1, 2, 3]], + ["value", "hello"], + ["data", "hello"], + ] as [BodyTypes, any][] + ).forEach(([expectedBodyType, expectedBody]) => { it(`receive ${expectedBodyType} EventData and resend (useBatch: ${useBatch})`, async () => { let startingPositions = await getStartingPositionsForTests(consumerClient); // if we receive an event that was encoded to a non-data section @@ -287,8 +289,8 @@ testWithServiceTypes((serviceVersion) => { [ { body: expectedBody, - bodyType: expectedBodyType - } + bodyType: expectedBodyType, + }, ], { useBatch } ); diff --git a/sdk/eventhub/event-hubs/test/public/auth.spec.ts b/sdk/eventhub/event-hubs/test/public/auth.spec.ts index c303ace71200..35722c453b4d 100644 --- a/sdk/eventhub/event-hubs/test/public/auth.spec.ts +++ b/sdk/eventhub/event-hubs/test/public/auth.spec.ts @@ -6,7 +6,7 @@ import { EnvVarKeys, getEnvVars } from "./utils/testUtils"; import { EventHubConsumerClient, EventHubProducerClient, - parseEventHubConnectionString + parseEventHubConnectionString, } from "../../src/index"; import { SinonFakeTimers, useFakeTimers } from "sinon"; import chai from "chai"; @@ -33,16 +33,12 @@ testWithServiceTypes((serviceVersion, onVersions) => { } onVersions(["live"]).describe("Authentication via", () => { - const { - endpoint, - fullyQualifiedNamespace, - sharedAccessKey, - sharedAccessKeyName - } = parseEventHubConnectionString(env[EnvVarKeys.EVENTHUB_CONNECTION_STRING]); + const { endpoint, fullyQualifiedNamespace, sharedAccessKey, sharedAccessKeyName } = + parseEventHubConnectionString(env[EnvVarKeys.EVENTHUB_CONNECTION_STRING]); const service = { connectionString: env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], path: env[EnvVarKeys.EVENTHUB_NAME], - endpoint: endpoint.replace(/\/+$/, "") + endpoint: endpoint.replace(/\/+$/, ""), }; before(() => { @@ -60,7 +56,7 @@ testWithServiceTypes((serviceVersion, onVersions) => { beforeEach("setup new space-time continuum", () => { clock = useFakeTimers({ now: new Date(), - shouldAdvanceTime: true + shouldAdvanceTime: true, }); }); @@ -116,8 +112,8 @@ testWithServiceTypes((serviceVersion, onVersions) => { namedKeyCredential, { retryOptions: { - maxRetries: 0 - } + maxRetries: 0, + }, } ); @@ -157,7 +153,7 @@ testWithServiceTypes((serviceVersion, onVersions) => { reject(new Error("Step 4 failed. Expected to see a list of events.")); } resolve(); - } + }, ]; consumerClient.subscribe( @@ -170,10 +166,10 @@ testWithServiceTypes((serviceVersion, onVersions) => { async processEvents(events) { const step = steps.shift(); if (step) step(events); - } + }, }, { - maxWaitTimeInSeconds: 5 + maxWaitTimeInSeconds: 5, } ); }); @@ -193,8 +189,8 @@ testWithServiceTypes((serviceVersion, onVersions) => { namedKeyCredential, { retryOptions: { - maxRetries: 0 - } + maxRetries: 0, + }, } ); @@ -230,7 +226,7 @@ testWithServiceTypes((serviceVersion, onVersions) => { function getSas(): string { return createSasTokenProvider({ sharedAccessKeyName: sharedAccessKeyName!, - sharedAccessKey: sharedAccessKey! + sharedAccessKey: sharedAccessKey!, }).getToken(`${service.endpoint}/${service.path}`).token; } @@ -245,8 +241,8 @@ testWithServiceTypes((serviceVersion, onVersions) => { sasCredential, { retryOptions: { - maxRetries: 0 - } + maxRetries: 0, + }, } ); @@ -282,8 +278,8 @@ testWithServiceTypes((serviceVersion, onVersions) => { sasCredential, { retryOptions: { - maxRetries: 0 - } + maxRetries: 0, + }, } ); @@ -325,7 +321,7 @@ testWithServiceTypes((serviceVersion, onVersions) => { reject(new Error("Step 4 failed. Expected to see a list of events.")); } resolve(); - } + }, ]; consumerClient.subscribe( @@ -338,10 +334,10 @@ testWithServiceTypes((serviceVersion, onVersions) => { async processEvents(events) { const step = steps.shift(); if (step) step(events); - } + }, }, { - maxWaitTimeInSeconds: 5 + maxWaitTimeInSeconds: 5, } ); }); @@ -358,8 +354,8 @@ testWithServiceTypes((serviceVersion, onVersions) => { sasCredential, { retryOptions: { - maxRetries: 0 - } + maxRetries: 0, + }, } ); diff --git a/sdk/eventhub/event-hubs/test/public/cancellation.spec.ts b/sdk/eventhub/event-hubs/test/public/cancellation.spec.ts index 832f333ae2f6..c4da02346944 100644 --- a/sdk/eventhub/event-hubs/test/public/cancellation.spec.ts +++ b/sdk/eventhub/event-hubs/test/public/cancellation.spec.ts @@ -29,7 +29,7 @@ testWithServiceTypes((serviceVersion) => { describe("Cancellation via AbortSignal", () => { const service = { connectionString: env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], - path: env[EnvVarKeys.EVENTHUB_NAME] + path: env[EnvVarKeys.EVENTHUB_NAME], }; before("validate environment", () => { should.exist( @@ -51,7 +51,7 @@ testWithServiceTypes((serviceVersion) => { const controller = new AbortController(); controller.abort(); return controller.signal; - } + }, }, { type: "aborted after timeout", @@ -61,8 +61,8 @@ testWithServiceTypes((serviceVersion) => { controller.abort(); }, 0); return controller.signal; - } - } + }, + }, ]; describe("EventHubConsumerClient", () => { diff --git a/sdk/eventhub/event-hubs/test/public/eventData.spec.ts b/sdk/eventhub/event-hubs/test/public/eventData.spec.ts index 76763518054a..3a1918d65d9d 100644 --- a/sdk/eventhub/event-hubs/test/public/eventData.spec.ts +++ b/sdk/eventhub/event-hubs/test/public/eventData.spec.ts @@ -8,7 +8,7 @@ import { EventHubProducerClient, EventPosition, ReceivedEventData, - Subscription + Subscription, } from "../../src"; import chai from "chai"; import chaiAsPromised from "chai-as-promised"; @@ -35,15 +35,15 @@ testWithServiceTypes((serviceVersion) => { }); } - describe("EventData", function(): void { + describe("EventData", function (): void { let producerClient: EventHubProducerClient; let consumerClient: EventHubConsumerClient; const service = { connectionString: env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], - path: env[EnvVarKeys.EVENTHUB_NAME] + path: env[EnvVarKeys.EVENTHUB_NAME], }; - before("validate environment", function(): void { + before("validate environment", function (): void { should.exist( env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], "define EVENTHUB_CONNECTION_STRING in your environment before running integration tests." @@ -63,7 +63,7 @@ testWithServiceTypes((serviceVersion) => { ); }); - afterEach("close the connection", async function(): Promise { + afterEach("close the connection", async function (): Promise { await producerClient.close(); await consumerClient.close(); }); @@ -75,7 +75,7 @@ testWithServiceTypes((serviceVersion) => { body: `message body ${randomTag}`, contentEncoding: "application/json; charset=utf-8", correlationId: randomTag, - messageId: v4() + messageId: v4(), } as EventData; } @@ -100,10 +100,10 @@ testWithServiceTypes((serviceVersion) => { resolve(events[0]); return subscription.close(); } - } + }, }, { - startPosition: startingPositions + startPosition: startingPositions, } ); }); diff --git a/sdk/eventhub/event-hubs/test/public/eventHubBufferedProducerClient.spec.ts b/sdk/eventhub/event-hubs/test/public/eventHubBufferedProducerClient.spec.ts index 99f4e2e2a400..970a20ad016e 100644 --- a/sdk/eventhub/event-hubs/test/public/eventHubBufferedProducerClient.spec.ts +++ b/sdk/eventhub/event-hubs/test/public/eventHubBufferedProducerClient.spec.ts @@ -6,7 +6,7 @@ import { EventData, EventHubBufferedProducerClient, OnSendEventsErrorContext, - OnSendEventsSuccessContext + OnSendEventsSuccessContext, } from "../../src/index"; import { AmqpAnnotatedMessage } from "@azure/core-amqp"; import chai from "chai"; @@ -78,7 +78,7 @@ testWithServiceTypes((serviceVersion) => { async onSendEventsSuccessHandler(context) { results.push({ type: "success", context }); }, - maxWaitTimeInMs: 1000 + maxWaitTimeInMs: 1000, }); for (let i = 0; i < expectedEventCount; i++) { @@ -109,12 +109,12 @@ testWithServiceTypes((serviceVersion) => { async onSendEventsSuccessHandler(context) { results.push({ type: "success", context }); }, - maxWaitTimeInMs: 1000 + maxWaitTimeInMs: 1000, }); for (let i = 0; i < expectedEventCount; i++) { const bufferedEventCount = await client.enqueueEvent(testEvents[i], { - partitionKey: "foo" + partitionKey: "foo", }); assert.equal(bufferedEventCount, i + 1, "Unexpected number of events buffered."); } @@ -133,7 +133,7 @@ testWithServiceTypes((serviceVersion) => { const testEvents: EventData[] = []; for (let i = 0; i < expectedEventCount; i++) { testEvents.push({ - body: `Test event ${i}` + body: `Test event ${i}`, }); } @@ -144,16 +144,16 @@ testWithServiceTypes((serviceVersion) => { async onSendEventsSuccessHandler(context) { results.push({ type: "success", context }); }, - maxEventBufferLengthPerPartition: 2 + maxEventBufferLengthPerPartition: 2, }); for (const testEvent of testEvents) { await client.enqueueEvent(testEvent, { - partitionKey: "foo" + partitionKey: "foo", }); results.push({ type: "enqueue", - event: testEvent + event: testEvent, }); } @@ -174,7 +174,7 @@ testWithServiceTypes((serviceVersion) => { "enqueue", "success", "enqueue", - "success" + "success", ]); assert.deepEqual( resultEnqueued, @@ -194,7 +194,7 @@ testWithServiceTypes((serviceVersion) => { async onSendEventsSuccessHandler(context) { results.push({ type: "success", context }); }, - maxEventBufferLengthPerPartition: 2 + maxEventBufferLengthPerPartition: 2, }); /** @@ -227,7 +227,7 @@ testWithServiceTypes((serviceVersion) => { await client.enqueueEvent({ body: 1 }, { partitionId: "0" }); await Promise.all([ client.flush().then(() => results.push({ type: "flush" })), - client.enqueueEvent({ body: 2 }, { partitionId: "0" }) + client.enqueueEvent({ body: 2 }, { partitionId: "0" }), ]); await client.flush(); results.push({ type: "flush" }); diff --git a/sdk/eventhub/event-hubs/test/public/eventHubConsumerClient.spec.ts b/sdk/eventhub/event-hubs/test/public/eventHubConsumerClient.spec.ts index c5721982293b..06c6aa87b73b 100644 --- a/sdk/eventhub/event-hubs/test/public/eventHubConsumerClient.spec.ts +++ b/sdk/eventhub/event-hubs/test/public/eventHubConsumerClient.spec.ts @@ -12,7 +12,7 @@ import { SubscriptionEventHandlers, earliestEventPosition, latestEventPosition, - logger + logger, } from "../../src"; import { EnvVarKeys, getEnvVars, getStartingPositionsForTests, loopUntil } from "./utils/testUtils"; import { LogTester } from "./utils/logHelpers"; @@ -43,7 +43,7 @@ testWithServiceTypes((serviceVersion) => { describe("EventHubConsumerClient", () => { const service = { connectionString: env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], - path: env[EnvVarKeys.EVENTHUB_NAME] + path: env[EnvVarKeys.EVENTHUB_NAME], }; let producerClient: EventHubProducerClient; @@ -96,8 +96,8 @@ testWithServiceTypes((serviceVersion) => { clients = []; }); - describe("#close()", function(): void { - it("stops any actively running subscriptions", async function(): Promise { + describe("#close()", function (): void { + it("stops any actively running subscriptions", async function (): Promise { const client = new EventHubConsumerClient( EventHubConsumerClient.defaultConsumerGroupName, service.connectionString, @@ -113,7 +113,7 @@ testWithServiceTypes((serviceVersion) => { }, async processEvents() { /* no-op for test */ - } + }, }) ); } @@ -137,7 +137,7 @@ testWithServiceTypes((serviceVersion) => { ); }); - it("gracefully stops running subscriptions", async function(): Promise { + it("gracefully stops running subscriptions", async function (): Promise { const client = new EventHubConsumerClient( EventHubConsumerClient.defaultConsumerGroupName, service.connectionString, @@ -171,10 +171,10 @@ testWithServiceTypes((serviceVersion) => { }, async processClose(reason) { waitForCloseResolver(reason); - } + }, }, { - startPosition: startingPositions + startPosition: startingPositions, } ); @@ -211,8 +211,8 @@ testWithServiceTypes((serviceVersion) => { }); }); - describe("Reinitialize partition processing after error", function(): void { - it("when subscribed to single partition", async function(): Promise { + describe("Reinitialize partition processing after error", function (): void { + it("when subscribed to single partition", async function (): Promise { const partitionId = "0"; const consumerClient1 = new EventHubConsumerClient( EventHubConsumerClient.defaultConsumerGroupName, @@ -234,13 +234,13 @@ testWithServiceTypes((serviceVersion) => { async processEvents() { // stop this subscription since it already should have forced the 1st subscription to have an error. await subscription2!.close(); - } + }, }; // keep track of the handlers called on subscription 1 const handlerCalls = { initialize: 0, - close: 0 + close: 0, }; const subscription1 = consumerClient1.subscribe( @@ -255,7 +255,7 @@ testWithServiceTypes((serviceVersion) => { subscription2 = consumerClient2.subscribe(partitionId, subscriptionHandlers2, { ownerLevel: 1, maxBatchSize: 1, - maxWaitTimeInSeconds: 1 + maxWaitTimeInSeconds: 1, }); } else { // stop this subscription, we know close was called so we've restarted @@ -267,11 +267,11 @@ testWithServiceTypes((serviceVersion) => { }, async processInitialize() { handlerCalls.initialize++; - } + }, }, { maxBatchSize: 1, - maxWaitTimeInSeconds: 1 + maxWaitTimeInSeconds: 1, } ); @@ -281,7 +281,7 @@ testWithServiceTypes((serviceVersion) => { timeBetweenRunsMs: 5000, async until() { return !subscription1.isRunning && !subscription2!.isRunning; - } + }, }); // Initialize may be called multiple times while the 2nd subscription is running. @@ -291,7 +291,7 @@ testWithServiceTypes((serviceVersion) => { handlerCalls.close.should.be.greaterThan(1); }); - it("when subscribed to multiple partitions", async function(): Promise { + it("when subscribed to multiple partitions", async function (): Promise { const consumerClient1 = new EventHubConsumerClient( EventHubConsumerClient.defaultConsumerGroupName, service.connectionString, @@ -334,12 +334,12 @@ testWithServiceTypes((serviceVersion) => { }, async processInitialize(context) { partitionHandlerCalls[context.partitionId].initialize++; - } + }, }; const subscription1 = consumerClient1.subscribe(subscriptionHandlers1, { maxBatchSize: 1, - maxWaitTimeInSeconds: 1 + maxWaitTimeInSeconds: 1, }); await loopUntil({ @@ -353,7 +353,7 @@ testWithServiceTypes((serviceVersion) => { return partitionHandlerCalls[id].processEvents; }).length === partitionIds.length ); - } + }, }); const partitionsReadFromSub2 = new Set(); @@ -363,20 +363,19 @@ testWithServiceTypes((serviceVersion) => { }, async processEvents(_, context) { partitionsReadFromSub2.add(context.partitionId); - } + }, }; // start 2nd subscription with an ownerLevel so it triggers the close handlers on the 1st subscription. const subscription2 = consumerClient2.subscribe(subscriptionHandlers2, { maxBatchSize: 1, maxWaitTimeInSeconds: 1, - ownerLevel: 1 + ownerLevel: 1, }); await loopUntil({ maxTimes: 10, - name: - "Wait for subscription2 to read from all partitions and subscription1 to invoke close handlers", + name: "Wait for subscription2 to read from all partitions and subscription1 to invoke close handlers", timeBetweenRunsMs: 1000, async until() { const sub1CloseHandlersCalled = Boolean( @@ -385,7 +384,7 @@ testWithServiceTypes((serviceVersion) => { }).length === partitionIds.length ); return partitionsReadFromSub2.size === partitionIds.length && sub1CloseHandlersCalled; - } + }, }); // close subscription2 so subscription1 can recover. @@ -402,7 +401,7 @@ testWithServiceTypes((serviceVersion) => { return partitionHandlerCalls[id].processEvents; }).length === partitionIds.length ); - } + }, }); await subscription1.close(); @@ -420,17 +419,17 @@ testWithServiceTypes((serviceVersion) => { }); }); - it("Receive from specific partitions, no coordination", async function(): Promise { + it("Receive from specific partitions, no coordination", async function (): Promise { const logTester = new LogTester( [ "EventHubConsumerClient subscribing to specific partition (0), no checkpoint store.", "Single partition target: 0", - "No partitions owned, skipping abandoning." + "No partitions owned, skipping abandoning.", ], [ logger.verbose as debug.Debugger, logger.verbose as debug.Debugger, - logger.verbose as debug.Debugger + logger.verbose as debug.Debugger, ] ); @@ -455,13 +454,13 @@ testWithServiceTypes((serviceVersion) => { logTester.assert(); }); - it("Receive from all partitions, no coordination", async function(): Promise { + it("Receive from all partitions, no coordination", async function (): Promise { const logTester = new LogTester( ["EventHubConsumerClient subscribing to all partitions, no checkpoint store."], [ logger.verbose as debug.Debugger, logger.verbose as debug.Debugger, - logger.verbose as debug.Debugger + logger.verbose as debug.Debugger, ] ); @@ -484,9 +483,7 @@ testWithServiceTypes((serviceVersion) => { logTester.assert(); }); - it("Receive from all partitions, no coordination but through multiple subscribe() calls", async function(): Promise< - void - > { + it("Receive from all partitions, no coordination but through multiple subscribe() calls", async function (): Promise { const logTester = new LogTester( [ ...partitionIds.map( @@ -494,12 +491,12 @@ testWithServiceTypes((serviceVersion) => { `EventHubConsumerClient subscribing to specific partition (${partitionId}), no checkpoint store.`, `Abandoning owned partitions` ), - ...partitionIds.map((partitionId) => `Single partition target: ${partitionId}`) + ...partitionIds.map((partitionId) => `Single partition target: ${partitionId}`), ], [ logger.verbose as debug.Debugger, logger.verbose as debug.Debugger, - logger.verbose as debug.Debugger + logger.verbose as debug.Debugger, ] ); @@ -524,21 +521,19 @@ testWithServiceTypes((serviceVersion) => { logTester.assert(); }); - it("Receive from all partitions, coordinating with the same partition manager and using the default LoadBalancingStrategy", async function(): Promise< - void - > { + it("Receive from all partitions, coordinating with the same partition manager and using the default LoadBalancingStrategy", async function (): Promise { // fast forward our partition manager so it starts reading from the latest offset // instead of the beginning of time. const logTester = new LogTester( [ "EventHubConsumerClient subscribing to all partitions, using a checkpoint store.", /Starting event processor with ID /, - "Abandoning owned partitions" + "Abandoning owned partitions", ], [ logger.verbose as debug.Debugger, logger.verbose as debug.Debugger, - logger.verbose as debug.Debugger + logger.verbose as debug.Debugger, ] ); @@ -583,21 +578,19 @@ testWithServiceTypes((serviceVersion) => { logTester.assert(); }); - it("Receive from all partitions, coordinating with the same partition manager and using the GreedyLoadBalancingStrategy", async function(): Promise< - void - > { + it("Receive from all partitions, coordinating with the same partition manager and using the GreedyLoadBalancingStrategy", async function (): Promise { // fast forward our partition manager so it starts reading from the latest offset // instead of the beginning of time. const logTester = new LogTester( [ "EventHubConsumerClient subscribing to all partitions, using a checkpoint store.", /Starting event processor with ID /, - "Abandoning owned partitions" + "Abandoning owned partitions", ], [ logger.verbose as debug.Debugger, logger.verbose as debug.Debugger, - logger.verbose as debug.Debugger + logger.verbose as debug.Debugger, ] ); @@ -611,8 +604,8 @@ testWithServiceTypes((serviceVersion) => { // specifying your own checkpoint store activates the "production ready" code path that { loadBalancingOptions: { - strategy: "greedy" - } + strategy: "greedy", + }, } ) ); @@ -632,8 +625,8 @@ testWithServiceTypes((serviceVersion) => { checkpointStore, { loadBalancingOptions: { - strategy: "greedy" - } + strategy: "greedy", + }, } ) ); @@ -650,9 +643,7 @@ testWithServiceTypes((serviceVersion) => { logTester.assert(); }); - it("Stops receiving events if close is immediately called, single partition.", async function(): Promise< - void - > { + it("Stops receiving events if close is immediately called, single partition.", async function (): Promise { const partitionId = "0"; const client = new EventHubConsumerClient( EventHubConsumerClient.defaultConsumerGroupName, @@ -677,7 +668,7 @@ testWithServiceTypes((serviceVersion) => { }, async processInitialize() { initializeCalled++; - } + }, }); await subscription.close(); @@ -688,7 +679,7 @@ testWithServiceTypes((serviceVersion) => { timeBetweenRunsMs: 100, async until() { return !subscription.isRunning; - } + }, }); // If `processInitialize` is called, then `processClose` should be called as well. @@ -699,9 +690,7 @@ testWithServiceTypes((serviceVersion) => { ); }); - it("Stops receiving events if close is immediately called, multiple partitions.", async function(): Promise< - void - > { + it("Stops receiving events if close is immediately called, multiple partitions.", async function (): Promise { const client = new EventHubConsumerClient( EventHubConsumerClient.defaultConsumerGroupName, service.connectionString, @@ -725,7 +714,7 @@ testWithServiceTypes((serviceVersion) => { }, async processInitialize() { initializeCalled++; - } + }, }); await subscription.close(); @@ -736,7 +725,7 @@ testWithServiceTypes((serviceVersion) => { timeBetweenRunsMs: 100, async until() { return !subscription.isRunning; - } + }, }); // If `processInitialize` is called, then `processClose` should be called as well. @@ -747,10 +736,8 @@ testWithServiceTypes((serviceVersion) => { ); }); - describe("processError", function(): void { - it("supports awaiting subscription.close on non partition-specific errors", async function(): Promise< - void - > { + describe("processError", function (): void { + it("supports awaiting subscription.close on non partition-specific errors", async function (): Promise { // Use an invalid Event Hub name to trigger a non partition-specific error. const client = new EventHubConsumerClient( EventHubConsumerClient.defaultConsumerGroupName, @@ -769,7 +756,7 @@ testWithServiceTypes((serviceVersion) => { await subscription.close(); resolve(err); } - } + }, }); }); @@ -778,9 +765,7 @@ testWithServiceTypes((serviceVersion) => { await client.close(); }); - it("supports awaiting subscription.close on partition-specific errors", async function(): Promise< - void - > { + it("supports awaiting subscription.close on partition-specific errors", async function (): Promise { // Use an invalid Event Hub name to trigger a non partition-specific error. const client = new EventHubConsumerClient( EventHubConsumerClient.defaultConsumerGroupName, @@ -800,7 +785,7 @@ testWithServiceTypes((serviceVersion) => { await subscription.close(); resolve(err); } - } + }, }); }); @@ -811,8 +796,8 @@ testWithServiceTypes((serviceVersion) => { }); }); - describe("subscribe() with partitionId 0 as number", function(): void { - it("should not throw an error", async function(): Promise { + describe("subscribe() with partitionId 0 as number", function (): void { + it("should not throw an error", async function (): Promise { let subscription: Subscription | undefined; await new Promise((resolve, reject) => { subscription = consumerClient.subscribe( @@ -824,11 +809,11 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err) => { reject(err); - } + }, }, { startPosition: latestEventPosition, - maxWaitTimeInSeconds: 0 // Set timeout of 0 to resolve the promise ASAP + maxWaitTimeInSeconds: 0, // Set timeout of 0 to resolve the promise ASAP } ); }); @@ -836,7 +821,7 @@ testWithServiceTypes((serviceVersion) => { }); }); - describe("subscribe() with EventPosition specified as", function(): void { + describe("subscribe() with EventPosition specified as", function (): void { let partitionId: string; let eventSentBeforeSubscribe: EventData; let eventsSentAfterSubscribe: EventData[]; @@ -845,7 +830,7 @@ testWithServiceTypes((serviceVersion) => { partitionId = partitionIds[0]; eventSentBeforeSubscribe = { - body: "Hello awesome world " + Math.random() + body: "Hello awesome world " + Math.random(), }; await producerClient.sendBatch([eventSentBeforeSubscribe], { partitionId }); @@ -854,13 +839,13 @@ testWithServiceTypes((serviceVersion) => { eventsSentAfterSubscribe.push({ body: "Hello awesome world " + Math.random(), properties: { - stamp: Math.random() - } + stamp: Math.random(), + }, }); } }); - it("'from end of stream' should receive messages correctly", async function(): Promise { + it("'from end of stream' should receive messages correctly", async function (): Promise { let subscription: Subscription | undefined; let processEventsCalled = false; const eventsReceived: ReceivedEventData[] = []; @@ -883,11 +868,11 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err) => { reject(err); - } + }, }, { startPosition: latestEventPosition, - maxWaitTimeInSeconds: 30 + maxWaitTimeInSeconds: 30, } ); }); @@ -910,9 +895,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("'after a particular sequence number' should receive messages correctly", async function(): Promise< - void - > { + it("'after a particular sequence number' should receive messages correctly", async function (): Promise { const partitionInfo = await consumerClient.getPartitionProperties(partitionId); let subscription: Subscription | undefined; let processEventsCalled = false; @@ -936,11 +919,11 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err) => { reject(err); - } + }, }, { startPosition: { sequenceNumber: partitionInfo.lastEnqueuedSequenceNumber }, - maxWaitTimeInSeconds: 30 + maxWaitTimeInSeconds: 30, } ); }); @@ -963,9 +946,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("'after a particular sequence number' with isInclusive should receive messages correctly", async function(): Promise< - void - > { + it("'after a particular sequence number' with isInclusive should receive messages correctly", async function (): Promise { const partitionInfo = await consumerClient.getPartitionProperties(partitionId); let subscription: Subscription | undefined; let processEventsCalled = false; @@ -1000,14 +981,14 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err) => { reject(err); - } + }, }, { startPosition: { sequenceNumber: partitionInfo.lastEnqueuedSequenceNumber, - isInclusive: true + isInclusive: true, }, - maxWaitTimeInSeconds: 30 + maxWaitTimeInSeconds: 30, } ); }); @@ -1027,9 +1008,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("'after a particular offset' should receive messages correctly", async function(): Promise< - void - > { + it("'after a particular offset' should receive messages correctly", async function (): Promise { const partitionInfo = await consumerClient.getPartitionProperties(partitionId); let subscription: Subscription | undefined; let processEventsCalled = false; @@ -1053,11 +1032,11 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err) => { reject(err); - } + }, }, { startPosition: { offset: partitionInfo.lastEnqueuedOffset }, - maxWaitTimeInSeconds: 30 + maxWaitTimeInSeconds: 30, } ); }); @@ -1080,9 +1059,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("'after a particular offset' with isInclusive should receive messages correctly", async function(): Promise< - void - > { + it("'after a particular offset' with isInclusive should receive messages correctly", async function (): Promise { const partitionInfo = await consumerClient.getPartitionProperties(partitionId); let subscription: Subscription | undefined; let processEventsCalled = false; @@ -1107,7 +1084,7 @@ testWithServiceTypes((serviceVersion) => { ); await producerClient.sendBatch(eventsSentAfterSubscribe, { - partitionId + partitionId, }); return; } @@ -1119,14 +1096,14 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err) => { reject(err); - } + }, }, { startPosition: { offset: partitionInfo.lastEnqueuedOffset, - isInclusive: true + isInclusive: true, }, - maxWaitTimeInSeconds: 30 + maxWaitTimeInSeconds: 30, } ); }); @@ -1146,9 +1123,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("'after a particular enqueued time' should receive messages correctly", async function(): Promise< - void - > { + it("'after a particular enqueued time' should receive messages correctly", async function (): Promise { const partitionInfo = await consumerClient.getPartitionProperties(partitionId); let subscription: Subscription | undefined; let processEventsCalled = false; @@ -1163,7 +1138,7 @@ testWithServiceTypes((serviceVersion) => { processEventsCalled = true; should.equal(data.length, 0, "Received events when none were sent yet."); await producerClient.sendBatch(eventsSentAfterSubscribe, { - partitionId + partitionId, }); return; } @@ -1175,11 +1150,11 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err) => { reject(err); - } + }, }, { startPosition: { enqueuedOn: partitionInfo.lastEnqueuedOnUtc }, - maxWaitTimeInSeconds: 30 + maxWaitTimeInSeconds: 30, } ); }); @@ -1203,8 +1178,8 @@ testWithServiceTypes((serviceVersion) => { }); }); - describe("subscribe() with trackLastEnqueuedEventProperties", function(): void { - it("should have lastEnqueuedEventProperties populated", async function(): Promise { + describe("subscribe() with trackLastEnqueuedEventProperties", function (): void { + it("should have lastEnqueuedEventProperties populated", async function (): Promise { const partitionId = partitionIds[0]; const eventData = { body: "Hello awesome world " + Math.random() }; @@ -1237,12 +1212,12 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err) => { reject(err); - } + }, }, { startPosition: earliestEventPosition, maxBatchSize: 1, - trackLastEnqueuedEventProperties: true + trackLastEnqueuedEventProperties: true, } ); }); @@ -1250,10 +1225,8 @@ testWithServiceTypes((serviceVersion) => { }); }); - describe("Negative scenarios", function(): void { - it("should throw MessagingEntityNotFoundError for non existing consumer group", async function(): Promise< - void - > { + describe("Negative scenarios", function (): void { + it("should throw MessagingEntityNotFoundError for non existing consumer group", async function (): Promise { const badConsumerClient = new EventHubConsumerClient( "boo", service.connectionString, @@ -1267,7 +1240,7 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err) => { resolve(err); - } + }, }); }); await subscription!.close(); @@ -1277,9 +1250,7 @@ testWithServiceTypes((serviceVersion) => { should.equal((caughtErr as MessagingError).code, "MessagingEntityNotFoundError"); }); - it(`should throw an invalid EventHub address error for invalid partition`, async function(): Promise< - void - > { + it(`should throw an invalid EventHub address error for invalid partition`, async function (): Promise { let subscription: Subscription | undefined; const caughtErr = await new Promise((resolve) => { subscription = consumerClient.subscribe("boo", { @@ -1288,7 +1259,7 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err) => { resolve(err); - } + }, }); }); await subscription!.close(); diff --git a/sdk/eventhub/event-hubs/test/public/hubruntime.spec.ts b/sdk/eventhub/event-hubs/test/public/hubruntime.spec.ts index 13a324bb3906..a80145d9b27b 100644 --- a/sdk/eventhub/event-hubs/test/public/hubruntime.spec.ts +++ b/sdk/eventhub/event-hubs/test/public/hubruntime.spec.ts @@ -6,7 +6,7 @@ import { EventHubBufferedProducerClient, EventHubConsumerClient, EventHubProducerClient, - MessagingError + MessagingError, } from "../../src"; import { context, setSpan } from "@azure/core-tracing"; import { SpanGraph } from "@azure/test-utils"; @@ -39,19 +39,19 @@ testWithServiceTypes((serviceVersion) => { }); } - describe("RuntimeInformation", function(): void { + describe("RuntimeInformation", function (): void { const clientTypes = [ "EventHubBufferedProducerClient", "EventHubConsumerClient", - "EventHubProducerClient" + "EventHubProducerClient", ] as const; const clientMap = new Map(); const service = { connectionString: env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], - path: env[EnvVarKeys.EVENTHUB_NAME] + path: env[EnvVarKeys.EVENTHUB_NAME], }; - before("validate environment", function(): void { + before("validate environment", function (): void { should.exist( env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], "define EVENTHUB_CONNECTION_STRING in your environment before running integration tests." @@ -82,7 +82,7 @@ testWithServiceTypes((serviceVersion) => { ); }); - afterEach("close the connection", async function(): Promise { + afterEach("close the connection", async function (): Promise { for (const client of clientMap.values()) { await client?.close(); } @@ -111,8 +111,8 @@ testWithServiceTypes((serviceVersion) => { const rootSpan = tracer.startSpan("root"); const ids = await client.getPartitionIds({ tracingOptions: { - tracingContext: setSpan(context.active(), rootSpan) - } + tracingContext: setSpan(context.active(), rootSpan), + }, }); ids.should.have.members(arrayOfIncreasingNumbersFromZero(ids.length)); rootSpan.end(); @@ -128,11 +128,11 @@ testWithServiceTypes((serviceVersion) => { children: [ { name: "Azure.EventHubs.getEventHubProperties", - children: [] - } - ] - } - ] + children: [], + }, + ], + }, + ], }; tracer.getSpanGraph(rootSpan.spanContext().traceId).should.eql(expectedGraph); @@ -153,15 +153,15 @@ testWithServiceTypes((serviceVersion) => { hubRuntimeInfo.createdOn.should.be.instanceof(Date); }); - it("can be manually traced", async function(): Promise { + it("can be manually traced", async function (): Promise { const client = clientMap.get(clientType)!; const { tracer, resetTracer } = setTracerForTest(); const rootSpan = tracer.startSpan("root"); const hubRuntimeInfo = await client.getEventHubProperties({ tracingOptions: { - tracingContext: setSpan(context.active(), rootSpan) - } + tracingContext: setSpan(context.active(), rootSpan), + }, }); hubRuntimeInfo.partitionIds.should.have.members( arrayOfIncreasingNumbersFromZero(hubRuntimeInfo.partitionIds.length) @@ -179,11 +179,11 @@ testWithServiceTypes((serviceVersion) => { children: [ { name: "Azure.EventHubs.getEventHubProperties", - children: [] - } - ] - } - ] + children: [], + }, + ], + }, + ], }; tracer.getSpanGraph(rootSpan.spanContext().traceId).should.eql(expectedGraph); @@ -244,8 +244,8 @@ testWithServiceTypes((serviceVersion) => { const rootSpan = tracer.startSpan("root"); const partitionRuntimeInfo = await client.getPartitionProperties("0", { tracingOptions: { - tracingContext: setSpan(context.active(), rootSpan) - } + tracingContext: setSpan(context.active(), rootSpan), + }, }); partitionRuntimeInfo.partitionId.should.equal("0"); partitionRuntimeInfo.eventHubName.should.equal(service.path); @@ -265,11 +265,11 @@ testWithServiceTypes((serviceVersion) => { children: [ { name: "Azure.EventHubs.getPartitionProperties", - children: [] - } - ] - } - ] + children: [], + }, + ], + }, + ], }; tracer.getSpanGraph(rootSpan.spanContext().traceId).should.eql(expectedGraph); 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 4f1c59f8e84d..52dd68fd1309 100644 --- a/sdk/eventhub/event-hubs/test/public/node/client.spec.ts +++ b/sdk/eventhub/event-hubs/test/public/node/client.spec.ts @@ -29,10 +29,10 @@ testWithServiceTypes((serviceVersion) => { }); } - describe("Create clients using Azure Identity", function(): void { + describe("Create clients using Azure Identity", function (): void { let endpoint: string; let credential: TokenCredential; - before("validate environment", function() { + before("validate environment", function () { should.exist( env[EnvVarKeys.AZURE_CLIENT_ID], "define AZURE_CLIENT_ID in your environment before running integration tests." @@ -56,16 +56,14 @@ testWithServiceTypes((serviceVersion) => { credential = { getToken(_args) { return Promise.resolve({ token: "token", expiresOnTimestamp: Date.now() + 360000 }); - } + }, }; } else { credential = new EnvironmentCredential(); } }); - it("creates an EventHubProducerClient from an Azure.Identity credential", async function(): Promise< - void - > { + it("creates an EventHubProducerClient from an Azure.Identity credential", async function (): Promise { const client = new EventHubProducerClient(endpoint, env.EVENTHUB_NAME, credential); should.equal(client.fullyQualifiedNamespace, endpoint); @@ -76,9 +74,7 @@ testWithServiceTypes((serviceVersion) => { await client.close(); }); - it("creates an EventHubConsumerClient from an Azure.Identity credential", async function(): Promise< - void - > { + it("creates an EventHubConsumerClient from an Azure.Identity credential", async function (): Promise { const client = new EventHubConsumerClient( EventHubConsumerClient.defaultConsumerGroupName, endpoint, @@ -127,7 +123,7 @@ testWithServiceTypes((serviceVersion) => { spans[0].attributes.should.deep.equal({ "az.namespace": "Microsoft.EventHub", "message_bus.destination": client.eventHubName, - "peer.address": client.fullyQualifiedNamespace + "peer.address": client.fullyQualifiedNamespace, }); }); }); 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 d6eb64141a3c..8fb84f0c9d77 100644 --- a/sdk/eventhub/event-hubs/test/public/node/disconnects.spec.ts +++ b/sdk/eventhub/event-hubs/test/public/node/disconnects.spec.ts @@ -25,12 +25,12 @@ testWithServiceTypes((serviceVersion, onVersions) => { }); } - describe("disconnected", function() { + describe("disconnected", function () { const service = { connectionString: env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], - path: env[EnvVarKeys.EVENTHUB_NAME] + path: env[EnvVarKeys.EVENTHUB_NAME], }; - before("validate environment", function(): void { + before("validate environment", function (): void { should.exist( env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], "define EVENTHUB_CONNECTION_STRING in your environment before running integration tests." @@ -41,7 +41,7 @@ testWithServiceTypes((serviceVersion, onVersions) => { ); }); - describe("EventHubConsumerClient", function() { + describe("EventHubConsumerClient", function () { it("runtimeInfo work after disconnect", async () => { const client = new EventHubConsumerClient( EventHubConsumerClient.defaultConsumerGroupName, @@ -153,13 +153,13 @@ testWithServiceTypes((serviceVersion, onVersions) => { }, processError: async (err) => { reject(err); - } + }, }, { startPosition: { - sequenceNumber: partitionProperties.lastEnqueuedSequenceNumber + sequenceNumber: partitionProperties.lastEnqueuedSequenceNumber, }, - maxWaitTimeInSeconds + maxWaitTimeInSeconds, } ); }); @@ -169,7 +169,7 @@ testWithServiceTypes((serviceVersion, onVersions) => { }); }); - describe("EventHubProducerClient", function() { + describe("EventHubProducerClient", function () { it("runtimeInfo work after disconnect", async () => { const client = new EventHubProducerClient(service.connectionString, service.path); const clientConnectionContext = client["_context"]; @@ -210,8 +210,8 @@ testWithServiceTypes((serviceVersion, onVersions) => { onVersions(["live"]).it("should not throw an uncaught exception", async () => { const client = new EventHubProducerClient(service.connectionString, service.path, { retryOptions: { - timeoutInMs: 0 - } + timeoutInMs: 0, + }, }); const clientConnectionContext = client["_context"]; diff --git a/sdk/eventhub/event-hubs/test/public/receiver.spec.ts b/sdk/eventhub/event-hubs/test/public/receiver.spec.ts index 0a93a7d632d7..f89ae9dea645 100644 --- a/sdk/eventhub/event-hubs/test/public/receiver.spec.ts +++ b/sdk/eventhub/event-hubs/test/public/receiver.spec.ts @@ -9,7 +9,7 @@ import { ReceivedEventData, Subscription, earliestEventPosition, - latestEventPosition + latestEventPosition, } from "../../src"; import chai from "chai"; import chaiAsPromised from "chai-as-promised"; @@ -34,15 +34,15 @@ testWithServiceTypes((serviceVersion) => { return service?.stop(); }); } - describe("EventHubConsumerClient", function(): void { + describe("EventHubConsumerClient", function (): void { const service = { connectionString: env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], - path: env[EnvVarKeys.EVENTHUB_NAME] + path: env[EnvVarKeys.EVENTHUB_NAME], }; let producerClient: EventHubProducerClient; let consumerClient: EventHubConsumerClient; let partitionIds: string[]; - before("validate environment", async function(): Promise { + before("validate environment", async function (): Promise { should.exist( env[EnvVarKeys.EVENTHUB_CONNECTION_STRING], "define EVENTHUB_CONNECTION_STRING in your environment before running integration tests." @@ -68,8 +68,8 @@ testWithServiceTypes((serviceVersion) => { await consumerClient.close(); }); - describe("subscribe() with partitionId 0 as number", function(): void { - it("should not throw an error", async function(): Promise { + describe("subscribe() with partitionId 0 as number", function (): void { + it("should not throw an error", async function (): Promise { let subscription: Subscription | undefined; await new Promise((resolve, reject) => { subscription = consumerClient.subscribe( @@ -81,11 +81,11 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err) => { reject(err); - } + }, }, { startPosition: latestEventPosition, - maxWaitTimeInSeconds: 0 // Set timeout of 0 to resolve the promise ASAP + maxWaitTimeInSeconds: 0, // Set timeout of 0 to resolve the promise ASAP } ); }); @@ -93,7 +93,7 @@ testWithServiceTypes((serviceVersion) => { }); }); - describe("subscribe() with EventPosition specified as", function(): void { + describe("subscribe() with EventPosition specified as", function (): void { let partitionId: string; let eventSentBeforeSubscribe: EventData; let eventsSentAfterSubscribe: EventData[]; @@ -102,7 +102,7 @@ testWithServiceTypes((serviceVersion) => { partitionId = partitionIds[0]; eventSentBeforeSubscribe = { - body: "Hello awesome world " + Math.random() + body: "Hello awesome world " + Math.random(), }; await producerClient.sendBatch([eventSentBeforeSubscribe], { partitionId }); @@ -111,13 +111,13 @@ testWithServiceTypes((serviceVersion) => { eventsSentAfterSubscribe.push({ body: "Hello awesome world " + Math.random(), properties: { - stamp: Math.random() - } + stamp: Math.random(), + }, }); } }); - it("'from end of stream' should receive messages correctly", async function(): Promise { + it("'from end of stream' should receive messages correctly", async function (): Promise { let subscription: Subscription | undefined; let processEventsCalled = false; const eventsReceived: ReceivedEventData[] = []; @@ -140,11 +140,11 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err) => { reject(err); - } + }, }, { startPosition: latestEventPosition, - maxWaitTimeInSeconds: 30 + maxWaitTimeInSeconds: 30, } ); }); @@ -167,9 +167,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("'after a particular sequence number' should receive messages correctly", async function(): Promise< - void - > { + it("'after a particular sequence number' should receive messages correctly", async function (): Promise { const partitionInfo = await consumerClient.getPartitionProperties(partitionId); let subscription: Subscription | undefined; let processEventsCalled = false; @@ -193,11 +191,11 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err) => { reject(err); - } + }, }, { startPosition: { sequenceNumber: partitionInfo.lastEnqueuedSequenceNumber }, - maxWaitTimeInSeconds: 30 + maxWaitTimeInSeconds: 30, } ); }); @@ -220,9 +218,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("'after a particular sequence number' with isInclusive should receive messages correctly", async function(): Promise< - void - > { + it("'after a particular sequence number' with isInclusive should receive messages correctly", async function (): Promise { const partitionInfo = await consumerClient.getPartitionProperties(partitionId); let subscription: Subscription | undefined; let processEventsCalled = false; @@ -257,14 +253,14 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err) => { reject(err); - } + }, }, { startPosition: { sequenceNumber: partitionInfo.lastEnqueuedSequenceNumber, - isInclusive: true + isInclusive: true, }, - maxWaitTimeInSeconds: 30 + maxWaitTimeInSeconds: 30, } ); }); @@ -284,9 +280,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("'after a particular offset' should receive messages correctly", async function(): Promise< - void - > { + it("'after a particular offset' should receive messages correctly", async function (): Promise { const partitionInfo = await consumerClient.getPartitionProperties(partitionId); let subscription: Subscription | undefined; let processEventsCalled = false; @@ -310,11 +304,11 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err) => { reject(err); - } + }, }, { startPosition: { offset: partitionInfo.lastEnqueuedOffset }, - maxWaitTimeInSeconds: 30 + maxWaitTimeInSeconds: 30, } ); }); @@ -337,9 +331,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("'after a particular offset' with isInclusive should receive messages correctly", async function(): Promise< - void - > { + it("'after a particular offset' with isInclusive should receive messages correctly", async function (): Promise { const partitionInfo = await consumerClient.getPartitionProperties(partitionId); let subscription: Subscription | undefined; let processEventsCalled = false; @@ -364,7 +356,7 @@ testWithServiceTypes((serviceVersion) => { ); await producerClient.sendBatch(eventsSentAfterSubscribe, { - partitionId + partitionId, }); return; } @@ -376,14 +368,14 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err) => { reject(err); - } + }, }, { startPosition: { offset: partitionInfo.lastEnqueuedOffset, - isInclusive: true + isInclusive: true, }, - maxWaitTimeInSeconds: 30 + maxWaitTimeInSeconds: 30, } ); }); @@ -403,9 +395,7 @@ testWithServiceTypes((serviceVersion) => { } }); - it("'after a particular enqueued time' should receive messages correctly", async function(): Promise< - void - > { + it("'after a particular enqueued time' should receive messages correctly", async function (): Promise { const partitionInfo = await consumerClient.getPartitionProperties(partitionId); let subscription: Subscription | undefined; let processEventsCalled = false; @@ -420,7 +410,7 @@ testWithServiceTypes((serviceVersion) => { processEventsCalled = true; should.equal(data.length, 0, "Received events when none were sent yet."); await producerClient.sendBatch(eventsSentAfterSubscribe, { - partitionId + partitionId, }); return; } @@ -432,11 +422,11 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err) => { reject(err); - } + }, }, { startPosition: { enqueuedOn: partitionInfo.lastEnqueuedOnUtc }, - maxWaitTimeInSeconds: 30 + maxWaitTimeInSeconds: 30, } ); }); @@ -460,8 +450,8 @@ testWithServiceTypes((serviceVersion) => { }); }); - describe("subscribe() with trackLastEnqueuedEventProperties", function(): void { - it("should have lastEnqueuedEventProperties populated", async function(): Promise { + describe("subscribe() with trackLastEnqueuedEventProperties", function (): void { + it("should have lastEnqueuedEventProperties populated", async function (): Promise { const partitionId = partitionIds[0]; const eventData = { body: "Hello awesome world " + Math.random() }; @@ -494,12 +484,12 @@ testWithServiceTypes((serviceVersion) => { }, processError: async (err) => { reject(err); - } + }, }, { startPosition: earliestEventPosition, maxBatchSize: 1, - trackLastEnqueuedEventProperties: true + trackLastEnqueuedEventProperties: true, } ); }); diff --git a/sdk/eventhub/event-hubs/test/public/utils/logHelpers.ts b/sdk/eventhub/event-hubs/test/public/utils/logHelpers.ts index b83c64767e93..544c8dc799a7 100644 --- a/sdk/eventhub/event-hubs/test/public/utils/logHelpers.ts +++ b/sdk/eventhub/event-hubs/test/public/utils/logHelpers.ts @@ -63,7 +63,7 @@ export class LogTester { this._attachedLoggers.push({ logger, wasEnabled: logger.enabled, - previousLogFunction: logger.log + previousLogFunction: logger.log, }); // install our check instead diff --git a/sdk/eventhub/event-hubs/test/public/utils/mockService.ts b/sdk/eventhub/event-hubs/test/public/utils/mockService.ts index a83c67d02b90..5827eaa61bb3 100644 --- a/sdk/eventhub/event-hubs/test/public/utils/mockService.ts +++ b/sdk/eventhub/event-hubs/test/public/utils/mockService.ts @@ -15,8 +15,8 @@ export function createMockServer(options: MockServerOptions = {}): MockEventHub port: 5671, tlsOptions: { cert: readFileSync(resolvePath(process.cwd(), "certs", "my-server.crt.pem")), - key: readFileSync(resolvePath(process.cwd(), "certs", "my-server.key.pem")) + key: readFileSync(resolvePath(process.cwd(), "certs", "my-server.key.pem")), }, - ...options + ...options, }); } diff --git a/sdk/eventhub/event-hubs/test/public/utils/receivedMessagesTester.ts b/sdk/eventhub/event-hubs/test/public/utils/receivedMessagesTester.ts index 2b9a83b8ca11..9278b0768e1a 100644 --- a/sdk/eventhub/event-hubs/test/public/utils/receivedMessagesTester.ts +++ b/sdk/eventhub/event-hubs/test/public/utils/receivedMessagesTester.ts @@ -86,7 +86,7 @@ export class ReceivedMessagesTester implements Required { return { event, - partitionId: context.partitionId + partitionId: context.partitionId, }; }) ); @@ -97,7 +97,7 @@ export class SubscriptionHandlerForTests implements Required { return this.data.size === partitionIds.length; - } + }, }); } @@ -144,7 +144,7 @@ export class SubscriptionHandlerForTests implements Required { return { body: eventAndPartitionId.event.body, - partitionId: eventAndPartitionId.partitionId + partitionId: eventAndPartitionId.partitionId, }; }); } @@ -188,7 +188,7 @@ export async function sendOneMessagePerPartition( await producerClient.sendBatch([{ body }], { partitionId }); sentMessages.push({ body, - partitionId + partitionId, }); } diff --git a/sdk/eventhub/event-hubs/test/public/utils/testInMemoryCheckpointStore.ts b/sdk/eventhub/event-hubs/test/public/utils/testInMemoryCheckpointStore.ts index f8330c6a4ad9..2de88a0ca4b0 100644 --- a/sdk/eventhub/event-hubs/test/public/utils/testInMemoryCheckpointStore.ts +++ b/sdk/eventhub/event-hubs/test/public/utils/testInMemoryCheckpointStore.ts @@ -63,7 +63,7 @@ export class TestInMemoryCheckpointStore implements CheckpointStore { const newOwnership = { ...ownership, etag: generate_uuid(), - lastModifiedTimeInMs: date.getTime() + lastModifiedTimeInMs: date.getTime(), }; this._partitionOwnershipMap.set(newOwnership.partitionId, newOwnership); diff --git a/sdk/eventhub/event-hubs/test/public/utils/testUtils.ts b/sdk/eventhub/event-hubs/test/public/utils/testUtils.ts index 343d57eba6df..2c300b4bcfac 100644 --- a/sdk/eventhub/event-hubs/test/public/utils/testUtils.ts +++ b/sdk/eventhub/event-hubs/test/public/utils/testUtils.ts @@ -20,7 +20,7 @@ export enum EnvVarKeys { AZURE_TENANT_ID = "AZURE_TENANT_ID", AZURE_CLIENT_ID = "AZURE_CLIENT_ID", AZURE_CLIENT_SECRET = "AZURE_CLIENT_SECRET", - TEST_TARGET = "TEST_TARGET" + TEST_TARGET = "TEST_TARGET", } export function getEnvVarValue(name: string): string | undefined { @@ -50,7 +50,7 @@ export function getEnvVars(): Omit<{ [key in EnvVarKeys]: any }, EnvVarKeys.TEST [EnvVarKeys.EVENTHUB_NAME]: "mock-hub", [EnvVarKeys.AZURE_TENANT_ID]: "AzureTenantId", [EnvVarKeys.AZURE_CLIENT_ID]: "AzureClientId", - [EnvVarKeys.AZURE_CLIENT_SECRET]: "AzureClientSecret" + [EnvVarKeys.AZURE_CLIENT_SECRET]: "AzureClientSecret", }); } @@ -59,7 +59,7 @@ export function getEnvVars(): Omit<{ [key in EnvVarKeys]: any }, EnvVarKeys.TEST [EnvVarKeys.EVENTHUB_NAME]: getEnvVarValue(EnvVarKeys.EVENTHUB_NAME), [EnvVarKeys.AZURE_TENANT_ID]: getEnvVarValue(EnvVarKeys.AZURE_TENANT_ID), [EnvVarKeys.AZURE_CLIENT_ID]: getEnvVarValue(EnvVarKeys.AZURE_CLIENT_ID), - [EnvVarKeys.AZURE_CLIENT_SECRET]: getEnvVarValue(EnvVarKeys.AZURE_CLIENT_SECRET) + [EnvVarKeys.AZURE_CLIENT_SECRET]: getEnvVarValue(EnvVarKeys.AZURE_CLIENT_SECRET), }; } @@ -98,7 +98,7 @@ export async function getStartingPositionsForTests( for (const partitionId of eventHubProperties.partitionIds) { startingPositions[partitionId] = { - sequenceNumber: (await client.getPartitionProperties(partitionId)).lastEnqueuedSequenceNumber + sequenceNumber: (await client.getPartitionProperties(partitionId)).lastEnqueuedSequenceNumber, }; } @@ -113,6 +113,6 @@ export function setTracerForTest( return { tracer, - resetTracer + resetTracer, }; } diff --git a/sdk/eventhub/event-hubs/test/public/utils/testWithServiceTypes.ts b/sdk/eventhub/event-hubs/test/public/utils/testWithServiceTypes.ts index 881ff942e96e..58711ccb42a2 100644 --- a/sdk/eventhub/event-hubs/test/public/utils/testWithServiceTypes.ts +++ b/sdk/eventhub/event-hubs/test/public/utils/testWithServiceTypes.ts @@ -15,29 +15,30 @@ export function testWithServiceTypes( ): void { // Wrap within an empty `describe` so that nested functions get the mocha // context object for the current suite being ran. - describe("", function() { + describe("", function () { // this.file comes from the current mocha suite context. // eslint-disable-next-line @typescript-eslint/no-invalid-this - describe(this.file ?? "", function() { - versionsToTest(serviceVersions, { versionForRecording: testTarget }, function( - serviceVersion, - ...rest - ) { - if (serviceVersion !== testTarget) { - // The min-max tests don't currently allow us to set the environment variables - // we use to disable running all targets when TEST_MODE is live. - // This ensures we only run the tests against the target version we want. - return; - } + describe(this.file ?? "", function () { + versionsToTest( + serviceVersions, + { versionForRecording: testTarget }, + function (serviceVersion, ...rest) { + if (serviceVersion !== testTarget) { + // The min-max tests don't currently allow us to set the environment variables + // we use to disable running all targets when TEST_MODE is live. + // This ensures we only run the tests against the target version we want. + return; + } - if (serviceVersion === "mock" && !isNode) { - // We don't currently support running tests aginst the mock service in browsers. - // This can be revisted once the mock service supports websockets. - return; - } + if (serviceVersion === "mock" && !isNode) { + // We don't currently support running tests aginst the mock service in browsers. + // This can be revisted once the mock service supports websockets. + return; + } - handler(serviceVersion as SupportedTargets, ...rest); - }); + handler(serviceVersion as SupportedTargets, ...rest); + } + ); }); }); } diff --git a/sdk/eventhub/eventhubs-checkpointstore-blob/karma.conf.js b/sdk/eventhub/eventhubs-checkpointstore-blob/karma.conf.js index a74fa98ceb9a..a3cef496a003 100644 --- a/sdk/eventhub/eventhubs-checkpointstore-blob/karma.conf.js +++ b/sdk/eventhub/eventhubs-checkpointstore-blob/karma.conf.js @@ -1,7 +1,7 @@ // https://github.com/karma-runner/karma-chrome-launcher process.env.CHROME_BIN = require("puppeteer").executablePath(); -module.exports = function(config) { +module.exports = function (config) { config.set({ // base path that will be used to resolve all patterns (eg. files, exclude) basePath: "./", @@ -20,13 +20,13 @@ module.exports = function(config) { "karma-env-preprocessor", "karma-coverage", "karma-sourcemap-loader", - "karma-junit-reporter" + "karma-junit-reporter", ], // list of files / patterns to load in the browser files: [ "dist-test/index.browser.js", - { pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: true } + { pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: true }, ], // list of files / patterns to exclude @@ -38,7 +38,7 @@ module.exports = function(config) { "**/*.js": ["sourcemap", "env"], // IMPORTANT: COMMENT following line if you want to debug in your browsers!! // Preprocess source file to calculate code coverage, however this will make source file unreadable - "dist-test/index.browser.js": ["coverage"] + "dist-test/index.browser.js": ["coverage"], }, // inject following environment values into browser testing with window.__env__ @@ -58,8 +58,8 @@ module.exports = function(config) { { type: "json", subdir: ".", file: "coverage.json" }, { type: "lcovonly", subdir: ".", file: "lcov.info" }, { type: "html", subdir: "html" }, - { type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" } - ] + { type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" }, + ], }, junitReporter: { @@ -69,7 +69,7 @@ module.exports = function(config) { useBrowserName: false, // add browser name to report and classes names nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element - properties: {} // key value pair of properties to add to the section of the report + properties: {}, // key value pair of properties to add to the section of the report }, // web server port @@ -106,8 +106,8 @@ module.exports = function(config) { mocha: { // change Karma's debug.html to the mocha web reporter reporter: "html", - timeout: "600000" - } - } + timeout: "600000", + }, + }, }); }; diff --git a/sdk/eventhub/eventhubs-checkpointstore-blob/samples-dev/createCustomPipeline.ts b/sdk/eventhub/eventhubs-checkpointstore-blob/samples-dev/createCustomPipeline.ts index 821719bcaf34..0e96218be427 100644 --- a/sdk/eventhub/eventhubs-checkpointstore-blob/samples-dev/createCustomPipeline.ts +++ b/sdk/eventhub/eventhubs-checkpointstore-blob/samples-dev/createCustomPipeline.ts @@ -17,7 +17,7 @@ import { Pipeline, RequestPolicyFactory, StorageSharedKeyCredential, - newPipeline + newPipeline, } from "@azure/storage-blob"; // In this example, we assume you are running Event Hubs on Azure Stack Hub @@ -41,9 +41,9 @@ export function createCustomPipeline(credentials: StorageSharedKeyCredential): P httpRequest.headers.set("x-ms-version", API_VERSION); const response = await nextPolicy.sendRequest(httpRequest); return response; - } + }, }; - } + }, }; const pipelineFactoriesCount = storagePipeline.factories.length; // Set the storage version policy as the second to last so that the HTTP header diff --git a/sdk/eventhub/eventhubs-checkpointstore-blob/samples-dev/receiveEventsUsingCheckpointStore.ts b/sdk/eventhub/eventhubs-checkpointstore-blob/samples-dev/receiveEventsUsingCheckpointStore.ts index eaffd0cc4312..b42de685db70 100644 --- a/sdk/eventhub/eventhubs-checkpointstore-blob/samples-dev/receiveEventsUsingCheckpointStore.ts +++ b/sdk/eventhub/eventhubs-checkpointstore-blob/samples-dev/receiveEventsUsingCheckpointStore.ts @@ -79,7 +79,7 @@ export async function main() { }, processError: async (err, context) => { console.log(`Error on partition "${context.partitionId}": ${err}`); - } + }, }); // after 30 seconds, stop processing diff --git a/sdk/eventhub/eventhubs-checkpointstore-blob/samples-dev/receiveEventsWithApiSpecificStorage.ts b/sdk/eventhub/eventhubs-checkpointstore-blob/samples-dev/receiveEventsWithApiSpecificStorage.ts index 3ba9f3f2b615..9cbd89a10eb9 100644 --- a/sdk/eventhub/eventhubs-checkpointstore-blob/samples-dev/receiveEventsWithApiSpecificStorage.ts +++ b/sdk/eventhub/eventhubs-checkpointstore-blob/samples-dev/receiveEventsWithApiSpecificStorage.ts @@ -76,7 +76,7 @@ export async function main() { }, processError: async (err, context) => { console.log(`Error on partition "${context.partitionId}": ${err}`); - } + }, }); // after 30 seconds, stop processing diff --git a/sdk/eventhub/eventhubs-checkpointstore-blob/src/blobCheckpointStore.ts b/sdk/eventhub/eventhubs-checkpointstore-blob/src/blobCheckpointStore.ts index 0fd1a6d434b8..f7e07df13850 100644 --- a/sdk/eventhub/eventhubs-checkpointstore-blob/src/blobCheckpointStore.ts +++ b/sdk/eventhub/eventhubs-checkpointstore-blob/src/blobCheckpointStore.ts @@ -5,7 +5,7 @@ import { CheckpointStore, PartitionOwnership, Checkpoint, - OperationOptions + OperationOptions, } from "@azure/event-hubs"; import { ContainerClient, Metadata, RestError, BlobSetMetadataResponse } from "@azure/storage-blob"; import { logger, logErrorStackTrace } from "./log"; @@ -47,7 +47,7 @@ export class BlobCheckpointStore implements CheckpointStore { type: "ownership", fullyQualifiedNamespace, eventHubName, - consumerGroup: consumerGroup + consumerGroup: consumerGroup, }); try { @@ -55,7 +55,7 @@ export class BlobCheckpointStore implements CheckpointStore { abortSignal, includeMetadata: true, prefix: blobPrefix, - tracingOptions + tracingOptions, }); for await (const blob of blobs) { @@ -76,7 +76,7 @@ export class BlobCheckpointStore implements CheckpointStore { partitionId: blobName, lastModifiedTimeInMs: blob.properties.lastModified && blob.properties.lastModified.getTime(), - etag: blob.properties.etag + etag: blob.properties.etag, }; partitionOwnershipArray.push(partitionOwnership); } @@ -112,7 +112,7 @@ export class BlobCheckpointStore implements CheckpointStore { const updatedBlobResponse = await this._setBlobMetadata( blobName, { - ownerid: ownership.ownerId + ownerid: ownership.ownerId, }, ownership.etag, options @@ -175,14 +175,14 @@ export class BlobCheckpointStore implements CheckpointStore { type: "checkpoint", fullyQualifiedNamespace, eventHubName, - consumerGroup + consumerGroup, }); const blobs = this._containerClient.listBlobsFlat({ abortSignal, includeMetadata: true, prefix: blobPrefix, - tracingOptions + tracingOptions, }); const checkpoints: Checkpoint[] = []; @@ -206,7 +206,7 @@ export class BlobCheckpointStore implements CheckpointStore { fullyQualifiedNamespace, partitionId: blobName, offset, - sequenceNumber + sequenceNumber, }); } @@ -236,7 +236,7 @@ export class BlobCheckpointStore implements CheckpointStore { blobName, { sequencenumber: checkpoint.sequenceNumber.toString(), - offset: checkpoint.offset.toString() + offset: checkpoint.offset.toString(), }, undefined, options @@ -299,9 +299,9 @@ export class BlobCheckpointStore implements CheckpointStore { return blockBlobClient.setMetadata(metadata as Metadata, { abortSignal, conditions: { - ifMatch: etag + ifMatch: etag, }, - tracingOptions + tracingOptions, }); } else { try { @@ -310,7 +310,7 @@ export class BlobCheckpointStore implements CheckpointStore { // https://github.com/Azure/azure-sdk-for-js/issues/10132 return await blockBlobClient.setMetadata(metadata as Metadata, { abortSignal, - tracingOptions + tracingOptions, }); } catch (err) { // Check if the error is `BlobNotFound` and fallback to `upload` if it is. @@ -326,7 +326,7 @@ export class BlobCheckpointStore implements CheckpointStore { return blockBlobClient.upload("", 0, { abortSignal, metadata: metadata as Metadata, - tracingOptions + tracingOptions, }); } } diff --git a/sdk/eventhub/eventhubs-checkpointstore-blob/test/blob-checkpointstore.spec.ts b/sdk/eventhub/eventhubs-checkpointstore-blob/test/blob-checkpointstore.spec.ts index 8edc35d19874..be3c04e51244 100644 --- a/sdk/eventhub/eventhubs-checkpointstore-blob/test/blob-checkpointstore.spec.ts +++ b/sdk/eventhub/eventhubs-checkpointstore-blob/test/blob-checkpointstore.spec.ts @@ -19,13 +19,13 @@ import { fail } from "assert"; import { AbortController } from "@azure/abort-controller"; const env = getEnvVars(); -describe("Blob Checkpoint Store", function(): void { +describe("Blob Checkpoint Store", function (): void { const TEST_FAILURE = "Test failure"; const service = { - storageConnectionString: env[EnvVarKeys.STORAGE_CONNECTION_STRING] + storageConnectionString: env[EnvVarKeys.STORAGE_CONNECTION_STRING], }; let containerClient: ContainerClient; - before("validate environment", async function(): Promise { + before("validate environment", async function (): Promise { should.exist( env[EnvVarKeys.STORAGE_CONNECTION_STRING], "define STORAGE_CONNECTION_STRING in your environment before running integration tests." @@ -44,8 +44,8 @@ describe("Blob Checkpoint Store", function(): void { await containerClient.delete(); }); - describe("listOwnership", function() { - it("supports cancellation via abortSignal", async function() { + describe("listOwnership", function () { + it("supports cancellation via abortSignal", async function () { const checkpointStore = new BlobCheckpointStore(containerClient); // Create an abort controller and abort it after blocking code is ran. @@ -59,7 +59,7 @@ describe("Blob Checkpoint Store", function(): void { "testEventHub", "testConsumerGroup", { - abortSignal: signal + abortSignal: signal, } ); throw new Error(TEST_FAILURE); @@ -69,7 +69,7 @@ describe("Blob Checkpoint Store", function(): void { } }); - it("supports cancellation via abortSignal (pre-cancelled)", async function() { + it("supports cancellation via abortSignal (pre-cancelled)", async function () { const checkpointStore = new BlobCheckpointStore(containerClient); // Create an abort controller and immediately abort it. @@ -83,7 +83,7 @@ describe("Blob Checkpoint Store", function(): void { "testEventHub", "testConsumerGroup", { - abortSignal: signal + abortSignal: signal, } ); throw new Error(TEST_FAILURE); @@ -94,7 +94,7 @@ describe("Blob Checkpoint Store", function(): void { }); }); - it("listOwnership should return an empty array", async function(): Promise { + it("listOwnership should return an empty array", async function (): Promise { const checkpointStore = new BlobCheckpointStore(containerClient); const listOwnership = await checkpointStore.listOwnership( "testNamespace.servicebus.windows.net", @@ -104,8 +104,8 @@ describe("Blob Checkpoint Store", function(): void { should.equal(listOwnership.length, 0); }); - describe("claimOwnership", function() { - it("supports cancellation via abortSignal", async function() { + describe("claimOwnership", function () { + it("supports cancellation via abortSignal", async function () { const checkpointStore = new BlobCheckpointStore(containerClient); // Create an abort controller and abort it after blocking code is ran. @@ -121,11 +121,11 @@ describe("Blob Checkpoint Store", function(): void { consumerGroup: EventHubConsumerClient.defaultConsumerGroupName, fullyQualifiedNamespace: "fqdn", eventHubName: "ehname", - ownerId: "me" - } + ownerId: "me", + }, ], { - abortSignal: signal + abortSignal: signal, } ); throw new Error(TEST_FAILURE); @@ -135,7 +135,7 @@ describe("Blob Checkpoint Store", function(): void { } }); - it("supports cancellation via abortSignal (pre-cancelled)", async function() { + it("supports cancellation via abortSignal (pre-cancelled)", async function () { const checkpointStore = new BlobCheckpointStore(containerClient); // Create an abort controller and immediately abort it. @@ -151,11 +151,11 @@ describe("Blob Checkpoint Store", function(): void { consumerGroup: EventHubConsumerClient.defaultConsumerGroupName, fullyQualifiedNamespace: "fqdn", eventHubName: "ehname", - ownerId: "me" - } + ownerId: "me", + }, ], { - abortSignal: signal + abortSignal: signal, } ); throw new Error(TEST_FAILURE); @@ -178,8 +178,8 @@ describe("Blob Checkpoint Store", function(): void { consumerGroup: EventHubConsumerClient.defaultConsumerGroupName, fullyQualifiedNamespace: "fqdn", eventHubName: "ehname", - ownerId: "me" - } + ownerId: "me", + }, ]); const originalETag = originalClaimedOwnerships[0] && originalClaimedOwnerships[0].etag; @@ -198,8 +198,8 @@ describe("Blob Checkpoint Store", function(): void { fullyQualifiedNamespace: "fqdn", eventHubName: "ehname", ownerId: "me", - etag: originalETag - } + etag: originalETag, + }, ]); shouldNotThrowButNothingWillClaim.length.should.equal(0); @@ -218,8 +218,8 @@ describe("Blob Checkpoint Store", function(): void { consumerGroup: EventHubConsumerClient.defaultConsumerGroupName, fullyQualifiedNamespace: "fqdn", eventHubName: "ehname", - ownerId: "me" - } + ownerId: "me", + }, ]); fail("Should have thrown an error - this isn't a normal claim collision issue"); } catch (err) { @@ -229,9 +229,7 @@ describe("Blob Checkpoint Store", function(): void { } }); - it("claimOwnership call should succeed, if it has been called for the first time", async function(): Promise< - void - > { + it("claimOwnership call should succeed, if it has been called for the first time", async function (): Promise { const checkpointStore = new BlobCheckpointStore(containerClient); const listOwnership = await checkpointStore.listOwnership( "testNamespace.servicebus.windows.net", @@ -245,7 +243,7 @@ describe("Blob Checkpoint Store", function(): void { partitionId: "0", fullyQualifiedNamespace: "testNamespace.servicebus.windows.net", consumerGroup: "testConsumerGroup", - eventHubName: "testEventHub" + eventHubName: "testEventHub", }; const partitionOwnershipArray = await checkpointStore.claimOwnership([partitionOwnership]); @@ -287,9 +285,7 @@ describe("Blob Checkpoint Store", function(): void { ); }); - it("After multiple claimOwnership calls for a single partition, listOwnership should return an array with a single PartitionOwnership for that partition.", async function(): Promise< - void - > { + it("After multiple claimOwnership calls for a single partition, listOwnership should return an array with a single PartitionOwnership for that partition.", async function (): Promise { const checkpointStore = new BlobCheckpointStore(containerClient); const listOwnership = await checkpointStore.listOwnership( "testNamespace.servicebus.windows.net", @@ -303,7 +299,7 @@ describe("Blob Checkpoint Store", function(): void { partitionId: "0", consumerGroup: "testConsumerGroup", fullyQualifiedNamespace: "testNamespace.servicebus.windows.net", - eventHubName: "testEventHub" + eventHubName: "testEventHub", }; await checkpointStore.claimOwnership([partitionOwnership]); @@ -345,9 +341,7 @@ describe("Blob Checkpoint Store", function(): void { ); }); - it("After multiple claimOwnership calls for multiple partition, listOwnership should return an array with a single PartitionOwnership for each partition.", async function(): Promise< - void - > { + it("After multiple claimOwnership calls for multiple partition, listOwnership should return an array with a single PartitionOwnership for each partition.", async function (): Promise { const checkpointStore = new BlobCheckpointStore(containerClient); const listOwnership = await checkpointStore.listOwnership( "testNamespace.servicebus.windows.net", @@ -364,7 +358,7 @@ describe("Blob Checkpoint Store", function(): void { partitionId: `${index}`, fullyQualifiedNamespace: "testNamespace.servicebus.windows.net", consumerGroup: "testConsumerGroup", - eventHubName: "testEventHub" + eventHubName: "testEventHub", }; partitionOwnershipArray.push(partitionOwnership); } @@ -422,8 +416,8 @@ describe("Blob Checkpoint Store", function(): void { should.exist(ownershipList[2].etag, "etag should exist."); }); - describe("listCheckpoints", function() { - it("supports cancellation via abortSignal", async function() { + describe("listCheckpoints", function () { + it("supports cancellation via abortSignal", async function () { const checkpointStore = new BlobCheckpointStore(containerClient); // Create an abort controller and abort it after blocking code is ran. @@ -437,7 +431,7 @@ describe("Blob Checkpoint Store", function(): void { "testEventHub", "testConsumerGroup", { - abortSignal: signal + abortSignal: signal, } ); throw new Error(TEST_FAILURE); @@ -447,7 +441,7 @@ describe("Blob Checkpoint Store", function(): void { } }); - it("supports cancellation via abortSignal (pre-cancelled)", async function() { + it("supports cancellation via abortSignal (pre-cancelled)", async function () { const checkpointStore = new BlobCheckpointStore(containerClient); // Create an abort controller and immediately abort it. @@ -461,7 +455,7 @@ describe("Blob Checkpoint Store", function(): void { "testEventHub", "testConsumerGroup", { - abortSignal: signal + abortSignal: signal, } ); throw new Error(TEST_FAILURE); @@ -479,7 +473,7 @@ describe("Blob Checkpoint Store", function(): void { const eventHubProperties = { fullyQualifiedNamespace: "testNamespace.servicebus.windows.net", eventHubName: "testEventHub", - consumerGroup: "testConsumerGroup" + consumerGroup: "testConsumerGroup", }; for (let i = 0; i < 3; ++i) { @@ -487,7 +481,7 @@ describe("Blob Checkpoint Store", function(): void { ...eventHubProperties, partitionId: i.toString(), sequenceNumber: 100 + i, - offset: 1023 + i + offset: 1023 + i, }; await checkpointStore.updateCheckpoint(checkpoint); @@ -545,7 +539,7 @@ describe("Blob Checkpoint Store", function(): void { const eventHubProperties = { fullyQualifiedNamespace: "testNamespace.servicebus.windows.net", eventHubName: "testEventHub", - consumerGroup: "testConsumerGroup" + consumerGroup: "testConsumerGroup", }; // Ensure that there aren't any checkpoints. @@ -564,7 +558,7 @@ describe("Blob Checkpoint Store", function(): void { fullyQualifiedNamespace: eventHubProperties.fullyQualifiedNamespace, offset: 0, partitionId: "0", - sequenceNumber: 1 + sequenceNumber: 1, }; await checkpointStore.updateCheckpoint(checkpoint); @@ -584,7 +578,7 @@ describe("Blob Checkpoint Store", function(): void { const eventHubProperties = { fullyQualifiedNamespace: "testNamespace.servicebus.windows.net", eventHubName: "testEventHub", - consumerGroup: "testConsumerGroup" + consumerGroup: "testConsumerGroup", }; // now let's induce a bad failure (removing the container) @@ -597,7 +591,7 @@ describe("Blob Checkpoint Store", function(): void { fullyQualifiedNamespace: eventHubProperties.fullyQualifiedNamespace, offset: 0, partitionId: "0", - sequenceNumber: 1 + sequenceNumber: 1, }; try { @@ -608,7 +602,7 @@ describe("Blob Checkpoint Store", function(): void { } }); - it("supports cancellation via abortSignal", async function() { + it("supports cancellation via abortSignal", async function () { const checkpointStore = new BlobCheckpointStore(containerClient); // Create an abort controller and abort it after blocking code is ran. @@ -623,7 +617,7 @@ describe("Blob Checkpoint Store", function(): void { fullyQualifiedNamespace: "testConsumerGroup", offset: 0, partitionId: "0", - sequenceNumber: 1 + sequenceNumber: 1, }; try { @@ -635,7 +629,7 @@ describe("Blob Checkpoint Store", function(): void { } }); - it("supports cancellation via abortSignal (pre-cancelled)", async function() { + it("supports cancellation via abortSignal (pre-cancelled)", async function () { const checkpointStore = new BlobCheckpointStore(containerClient); // Create an abort controller and immediately abort it. @@ -650,7 +644,7 @@ describe("Blob Checkpoint Store", function(): void { fullyQualifiedNamespace: "testConsumerGroup", offset: 0, partitionId: "0", - sequenceNumber: 1 + sequenceNumber: 1, }; try { @@ -663,9 +657,7 @@ describe("Blob Checkpoint Store", function(): void { }); }); - it("Claiming ownership with an empty owner id should be fine (ie, unclaiming)", async function(): Promise< - void - > { + it("Claiming ownership with an empty owner id should be fine (ie, unclaiming)", async function (): Promise { const checkpointStore = new BlobCheckpointStore(containerClient); const listOwnership = await checkpointStore.listOwnership( "testNamespace.servicebus.windows.net", @@ -679,7 +671,7 @@ describe("Blob Checkpoint Store", function(): void { partitionId: "0", fullyQualifiedNamespace: "testNamespace.servicebus.windows.net", consumerGroup: "testConsumerGroup", - eventHubName: "testEventHub" + eventHubName: "testEventHub", }; const partitionOwnershipArray = await checkpointStore.claimOwnership([partitionOwnership]); @@ -707,14 +699,14 @@ describe("Blob Checkpoint Store", function(): void { consumerGroup: "test", eventHubName: "test", fullyQualifiedNamespace: "test", - ownerId: "test" + ownerId: "test", }; await checkpointStore.claimOwnership([ { ...commonData, - partitionId: "100" - } + partitionId: "100", + }, ]); // muck with the metadata in an incompatible way @@ -740,14 +732,14 @@ describe("Blob Checkpoint Store", function(): void { consumerGroup: "test", eventHubName: "test", fullyQualifiedNamespace: "test", - ownerId: "test" + ownerId: "test", }; await checkpointStore.updateCheckpoint({ ...commonData, partitionId: "100", sequenceNumber: 0, - offset: 0 + offset: 0, }); // muck with the metadata in an incompatible way @@ -774,13 +766,13 @@ describe("Blob Checkpoint Store", function(): void { eventHubName: "test", fullyQualifiedNamespace: "test", ownerId: "test", - partitionId: "0" + partitionId: "0", }; await checkpointStore.updateCheckpoint({ ...commonData, offset: 0, - sequenceNumber: 0 + sequenceNumber: 0, }); const checkpoints = await checkpointStore.listCheckpoints( @@ -802,7 +794,7 @@ describe("Blob Checkpoint Store", function(): void { type: "ownership", fullyQualifiedNamespace: "nAmESpAce", eventHubName: "eVentHubNamE", - consumerGroup: "cOnsuMerGrouPNaMe" + consumerGroup: "cOnsuMerGrouPNaMe", // partition ID is optional }) ); @@ -814,7 +806,7 @@ describe("Blob Checkpoint Store", function(): void { fullyQualifiedNamespace: "nAmESpAce", eventHubName: "eVentHubNamE", consumerGroup: "cOnsuMerGrouPNaMe", - partitionId: "0" + partitionId: "0", }) ); }); diff --git a/sdk/eventhub/eventhubs-checkpointstore-blob/test/snippets.spec.ts b/sdk/eventhub/eventhubs-checkpointstore-blob/test/snippets.spec.ts index 6a8203c7a7d0..ba84c97272ac 100644 --- a/sdk/eventhub/eventhubs-checkpointstore-blob/test/snippets.spec.ts +++ b/sdk/eventhub/eventhubs-checkpointstore-blob/test/snippets.spec.ts @@ -73,7 +73,7 @@ describe.skip("Snippets", () => { // handle any errors that occur during the course of // this subscription console.log(`Errors in subscription to partition ${context.partitionId}: ${err}`); - } + }, }); // Wait for a few seconds to receive events before closing diff --git a/sdk/eventhub/eventhubs-checkpointstore-blob/test/utils/testUtils.ts b/sdk/eventhub/eventhubs-checkpointstore-blob/test/utils/testUtils.ts index 82c58389846c..ff125c9a8fbe 100644 --- a/sdk/eventhub/eventhubs-checkpointstore-blob/test/utils/testUtils.ts +++ b/sdk/eventhub/eventhubs-checkpointstore-blob/test/utils/testUtils.ts @@ -10,7 +10,7 @@ export const isNode = !!process && !!process.version && !!process.versions && !!process.versions.node; export enum EnvVarKeys { - STORAGE_CONNECTION_STRING = "STORAGE_CONNECTION_STRING" + STORAGE_CONNECTION_STRING = "STORAGE_CONNECTION_STRING", } function getEnvVarValue(name: string): string | undefined { @@ -23,6 +23,6 @@ function getEnvVarValue(name: string): string | undefined { export function getEnvVars(): { [key in EnvVarKeys]: any } { return { - [EnvVarKeys.STORAGE_CONNECTION_STRING]: getEnvVarValue(EnvVarKeys.STORAGE_CONNECTION_STRING) + [EnvVarKeys.STORAGE_CONNECTION_STRING]: getEnvVarValue(EnvVarKeys.STORAGE_CONNECTION_STRING), }; } diff --git a/sdk/eventhub/eventhubs-checkpointstore-table/karma.conf.js b/sdk/eventhub/eventhubs-checkpointstore-table/karma.conf.js index bee744285631..70847d336eaf 100644 --- a/sdk/eventhub/eventhubs-checkpointstore-table/karma.conf.js +++ b/sdk/eventhub/eventhubs-checkpointstore-table/karma.conf.js @@ -1,7 +1,7 @@ // https://github.com/karma-runner/karma-chrome-launcher process.env.CHROME_BIN = require("puppeteer").executablePath(); -module.exports = function(config) { +module.exports = function (config) { config.set({ // base path that will be used to resolve all patterns (eg. files, exclude) basePath: "./", @@ -20,7 +20,7 @@ module.exports = function(config) { "karma-env-preprocessor", "karma-coverage", "karma-sourcemap-loader", - "karma-junit-reporter" + "karma-junit-reporter", ], // list of files / patterns to load in the browser @@ -29,7 +29,7 @@ module.exports = function(config) { // Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys // "https://cdn.polyfill.io/v2/polyfill.js?features=Symbol,Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys|always", "dist-test/index.browser.js", - { pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: true } + { pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: true }, ], // list of files / patterns to exclude @@ -41,7 +41,7 @@ module.exports = function(config) { "**/*.js": ["sourcemap", "env"], // IMPORTANT: COMMENT following line if you want to debug in your browsers!! // Preprocess source file to calculate code coverage, however this will make source file unreadable - "dist-test/index.browser.js": ["coverage"] + "dist-test/index.browser.js": ["coverage"], }, // inject following environment values into browser testing with window.__env__ @@ -61,8 +61,8 @@ module.exports = function(config) { { type: "json", subdir: ".", file: "coverage.json" }, { type: "lcovonly", subdir: ".", file: "lcov.info" }, { type: "html", subdir: "html" }, - { type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" } - ] + { type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" }, + ], }, junitReporter: { @@ -72,7 +72,7 @@ module.exports = function(config) { useBrowserName: false, // add browser name to report and classes names nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element - properties: {} // key value pair of properties to add to the section of the report + properties: {}, // key value pair of properties to add to the section of the report }, // web server port @@ -109,8 +109,8 @@ module.exports = function(config) { mocha: { // change Karma's debug.html to the mocha web reporter reporter: "html", - timeout: "600000" - } - } + timeout: "600000", + }, + }, }); }; diff --git a/sdk/eventhub/eventhubs-checkpointstore-table/src/tableCheckpointStore.ts b/sdk/eventhub/eventhubs-checkpointstore-table/src/tableCheckpointStore.ts index df267e58b80d..aec36b2bae86 100644 --- a/sdk/eventhub/eventhubs-checkpointstore-table/src/tableCheckpointStore.ts +++ b/sdk/eventhub/eventhubs-checkpointstore-table/src/tableCheckpointStore.ts @@ -85,7 +85,7 @@ export class TableCheckpointStore implements CheckpointStore { const partitionKey = `${fullyQualifiedNamespace} ${eventHubName} ${consumerGroup} Ownership`; const partitionOwnershipArray: PartitionOwnership[] = []; const entitiesIter = this._tableClient.listEntities({ - queryOptions: { filter: odata`PartitionKey eq ${partitionKey}` } + queryOptions: { filter: odata`PartitionKey eq ${partitionKey}` }, }); try { for await (const entity of entitiesIter) { @@ -102,7 +102,7 @@ export class TableCheckpointStore implements CheckpointStore { ownerId: entity.ownerid, partitionId: entity.rowKey, lastModifiedTimeInMs: new Date(entity.timestamp).getTime(), - etag: entity.etag + etag: entity.etag, }; partitionOwnershipArray.push(partitionOwnership); } @@ -135,7 +135,7 @@ export class TableCheckpointStore implements CheckpointStore { const ownershipEntity: PartitionOwnershipEntity = { partitionKey: partitionKey, rowKey: ownership.partitionId, - ownerid: ownership.ownerId + ownerid: ownership.ownerId, }; // When we have an etag, we know the entity existed. @@ -143,7 +143,7 @@ export class TableCheckpointStore implements CheckpointStore { try { if (ownership.etag) { const updatedMetadata = await this._tableClient.updateEntity(ownershipEntity, "Replace", { - etag: ownership.etag + etag: ownership.etag, }); const entityRetrieved = await this._tableClient.getEntity( ownershipEntity.partitionKey, @@ -165,9 +165,9 @@ export class TableCheckpointStore implements CheckpointStore { const newOwnershipMetadata = await this._tableClient.createEntity(ownershipEntity, { requestOptions: { customHeaders: { - Prefer: "return-content" - } - } + Prefer: "return-content", + }, + }, }); if (!_hasTimestamp(newOwnershipMetadata)) { @@ -221,7 +221,7 @@ export class TableCheckpointStore implements CheckpointStore { const partitionKey = `${fullyQualifiedNamespace} ${eventHubName} ${consumerGroup} Checkpoint`; const checkpoints: Checkpoint[] = []; const entitiesIter = this._tableClient.listEntities({ - queryOptions: { filter: odata`PartitionKey eq ${partitionKey}` } + queryOptions: { filter: odata`PartitionKey eq ${partitionKey}` }, }); for await (const entity of entitiesIter) { checkpoints.push({ @@ -230,7 +230,7 @@ export class TableCheckpointStore implements CheckpointStore { fullyQualifiedNamespace, partitionId: entity.rowKey, offset: parseInt(entity.offset, 10), - sequenceNumber: parseInt(entity.sequencenumber, 10) + sequenceNumber: parseInt(entity.sequencenumber, 10), }); } return checkpoints; @@ -251,7 +251,7 @@ export class TableCheckpointStore implements CheckpointStore { partitionKey: partitionKey, rowKey: checkpoint.partitionId, sequencenumber: checkpoint.sequenceNumber.toString(), - offset: checkpoint.offset.toString() + offset: checkpoint.offset.toString(), }; try { await this._tableClient.upsertEntity(checkpointEntity); diff --git a/sdk/eventhub/eventhubs-checkpointstore-table/test/tables-checkpointstore.spec.ts b/sdk/eventhub/eventhubs-checkpointstore-table/test/tables-checkpointstore.spec.ts index 594ce2aae2b0..a8b596ad0d21 100644 --- a/sdk/eventhub/eventhubs-checkpointstore-table/test/tables-checkpointstore.spec.ts +++ b/sdk/eventhub/eventhubs-checkpointstore-table/test/tables-checkpointstore.spec.ts @@ -23,7 +23,7 @@ describe("TableCheckpointStore", () => { const service = { storageAccountName: env[EnvVarKeys.STORAGE_ACCOUNT_NAME], - storageAccountKey: env[EnvVarKeys.STORAGE_ACCOUNT_KEY] + storageAccountKey: env[EnvVarKeys.STORAGE_ACCOUNT_KEY], }; const credential = new AzureNamedKeyCredential( @@ -35,7 +35,7 @@ const serviceClient = new TableServiceClient( credential ); -describe("TableCheckpointStore", function(): void { +describe("TableCheckpointStore", function (): void { let client: TableClient; let tableName: string; beforeEach("creating table", async () => { @@ -51,9 +51,9 @@ describe("TableCheckpointStore", function(): void { await serviceClient.deleteTable(tableName); }); - describe("Runs tests on table with no entities", function() { - describe("listOwnership", function() { - it("listOwnership should return an empty array", async function(): Promise { + describe("Runs tests on table with no entities", function () { + describe("listOwnership", function () { + it("listOwnership should return an empty array", async function (): Promise { const checkpointStore = new TableCheckpointStore(client); const listOwnership = await checkpointStore.listOwnership( "test.servicebus.windows.net", @@ -64,8 +64,8 @@ describe("TableCheckpointStore", function(): void { }); }); - describe("listCheckpoints", function() { - it("listCheckpoint should return an empty array", async function(): Promise { + describe("listCheckpoints", function () { + it("listCheckpoint should return an empty array", async function (): Promise { const checkpointStore = new TableCheckpointStore(client); const checkpoints = await checkpointStore.listCheckpoints( "test.servicebus.windows.net", @@ -75,13 +75,13 @@ describe("TableCheckpointStore", function(): void { should.equal(checkpoints.length, 0); }); }); - describe("updateCheckpoint", function() { + describe("updateCheckpoint", function () { it("creates a checkpoint where one doesn't already exist", async () => { const checkpointStore = new TableCheckpointStore(client); const eventHubProperties = { fullyQualifiedNamespace: "pink.servicebus.windows.net", eventHubName: "pinkHub", - consumerGroup: "testConsumerGroup" + consumerGroup: "testConsumerGroup", }; // Ensure that there aren't any checkpoints. let checkpoints = await checkpointStore.listCheckpoints( @@ -97,7 +97,7 @@ describe("TableCheckpointStore", function(): void { fullyQualifiedNamespace: eventHubProperties.fullyQualifiedNamespace, offset: 0, partitionId: "0", - sequenceNumber: 1 + sequenceNumber: 1, }; await checkpointStore.updateCheckpoint(checkpoint); @@ -116,7 +116,7 @@ describe("TableCheckpointStore", function(): void { const eventHubProperties = { fullyQualifiedNamespace: "testNamespace.servicebus.windows.net", eventHubName: "testEventHub", - consumerGroup: "testConsumerGroup" + consumerGroup: "testConsumerGroup", }; // now let's induce a bad failure (removing the table) @@ -129,7 +129,7 @@ describe("TableCheckpointStore", function(): void { fullyQualifiedNamespace: eventHubProperties.fullyQualifiedNamespace, offset: 0, partitionId: "0", - sequenceNumber: 1 + sequenceNumber: 1, }; try { @@ -141,10 +141,8 @@ describe("TableCheckpointStore", function(): void { }); }); - describe("claimOwnership", function() { - it("claimOwnership call should succeed, if it has been called for the first time", async function(): Promise< - void - > { + describe("claimOwnership", function () { + it("claimOwnership call should succeed, if it has been called for the first time", async function (): Promise { const checkpointStore = new TableCheckpointStore(client); const listOwnership = await checkpointStore.listOwnership( "testNamespace.servicebus.windows.net", @@ -158,7 +156,7 @@ describe("TableCheckpointStore", function(): void { partitionId: "0", fullyQualifiedNamespace: "testNamespace.servicebus.windows.net", consumerGroup: "testConsumerGroup", - eventHubName: "testEventHub" + eventHubName: "testEventHub", }; const partitionOwnershipArray = await checkpointStore.claimOwnership([partitionOwnership]); should.equal(partitionOwnershipArray.length, 1); @@ -206,7 +204,7 @@ describe("TableCheckpointStore", function(): void { }); }); - describe("Runs tests on a populated table", function() { + describe("Runs tests on a populated table", function () { const namespace = "blue.servicebus.windows.net"; const eventHubName = "blueHub"; const consumerGroup = "$default"; @@ -216,7 +214,7 @@ describe("TableCheckpointStore", function(): void { partitionKey: `${namespace} ${eventHubName} ${consumerGroup} Checkpoint`, rowKey: "0", sequencenumber: "100", - offset: "1023" + offset: "1023", }; await client.createEntity(checkpoint_entity); @@ -224,13 +222,13 @@ describe("TableCheckpointStore", function(): void { const ownership_entity: PartitionOwnershipEntity = { partitionKey: `${namespace} ${eventHubName} ${consumerGroup} Ownership`, rowKey: "0", - ownerid: "Id0" + ownerid: "Id0", }; await client.createEntity(ownership_entity); }); - describe("listOwnership", function() { - it("listOwnership should print an array of ownerships", async function() { + describe("listOwnership", function () { + it("listOwnership should print an array of ownerships", async function () { const checkpointStore = new TableCheckpointStore(client); const listOwnership = await checkpointStore.listOwnership( "blue.servicebus.windows.net", @@ -240,8 +238,8 @@ describe("TableCheckpointStore", function(): void { should.equal(listOwnership.length, 1); }); - describe("listCheckpoints", function() { - it("listCheckpoints should print out an array of checkpoints", async function() { + describe("listCheckpoints", function () { + it("listCheckpoints should print out an array of checkpoints", async function () { const checkpointStore = new TableCheckpointStore(client); const listCheckpoint = await checkpointStore.listCheckpoints( "blue.servicebus.windows.net", @@ -252,7 +250,7 @@ describe("TableCheckpointStore", function(): void { }); }); - describe("claimOwnership", function() { + describe("claimOwnership", function () { // these errors happen when we have multiple consumers starting up // at the same time and load balancing amongst themselves. This is a // normal thing and shouldn't be reported to the user. @@ -266,7 +264,7 @@ describe("TableCheckpointStore", function(): void { ); const originalClaimedOwnerships = await checkpointStore.claimOwnership([ - listOwnership[0] + listOwnership[0], ]); const originalETag = originalClaimedOwnerships[0].etag; @@ -288,16 +286,14 @@ describe("TableCheckpointStore", function(): void { fullyQualifiedNamespace: "blue.servicebus.windows.net", eventHubName: "blueHub", ownerId: "Id0", - etag: originalETag - } + etag: originalETag, + }, ]); shouldNotThrowButNothingWillClaim.length.should.equal(0); }); - it("After multiple claimOwnership calls for a single partition, listOwnership should return an array with a single PartitionOwnership for that partition.", async function(): Promise< - void - > { + it("After multiple claimOwnership calls for a single partition, listOwnership should return an array with a single PartitionOwnership for that partition.", async function (): Promise { const checkpointStore = new TableCheckpointStore(client); const listOwnership = await checkpointStore.listOwnership( "testNamespace.servicebus.windows.net", @@ -313,7 +309,7 @@ describe("TableCheckpointStore", function(): void { partitionId: `${index}`, fullyQualifiedNamespace: "testNamespace.servicebus.windows.net", consumerGroup: "testConsumerGroup", - eventHubName: "testEventHub" + eventHubName: "testEventHub", }; partitionOwnershipArray.push(partitionOwnership); } @@ -362,9 +358,7 @@ describe("TableCheckpointStore", function(): void { ); }); - it("After multiple claimOwnership calls for multiple partition, listOwnership should return an array with a single PartitionOwnership for each partition.", async function(): Promise< - void - > { + it("After multiple claimOwnership calls for multiple partition, listOwnership should return an array with a single PartitionOwnership for each partition.", async function (): Promise { const checkpointStore = new TableCheckpointStore(client); const listOwnership = await checkpointStore.listOwnership( "testNamespace.servicebus.windows.net", @@ -381,7 +375,7 @@ describe("TableCheckpointStore", function(): void { partitionId: `${index}`, fullyQualifiedNamespace: "testNamespace.servicebus.windows.net", consumerGroup: "testConsumerGroup", - eventHubName: "testEventHub" + eventHubName: "testEventHub", }; partitionOwnershipArray.push(partitionOwnership); } @@ -449,13 +443,13 @@ describe("TableCheckpointStore", function(): void { }); }); - describe("updateCheckpoint", function() { + describe("updateCheckpoint", function () { it("updates checkpoints successfully", async () => { const checkpointStore = new TableCheckpointStore(client); const eventHubProperties = { fullyQualifiedNamespace: "testNamespace.servicebus.windows.net", eventHubName: "testEventHub", - consumerGroup: "testConsumerGroup" + consumerGroup: "testConsumerGroup", }; let i = 0; while (i < 3) { @@ -463,7 +457,7 @@ describe("TableCheckpointStore", function(): void { ...eventHubProperties, partitionId: i.toString(), sequenceNumber: 100 + i, - offset: 1023 + i + offset: 1023 + i, }; await checkpointStore.updateCheckpoint(checkpoint); i++; diff --git a/sdk/eventhub/eventhubs-checkpointstore-table/test/utils/testUtils.ts b/sdk/eventhub/eventhubs-checkpointstore-table/test/utils/testUtils.ts index b9d38c776496..52d475114551 100644 --- a/sdk/eventhub/eventhubs-checkpointstore-table/test/utils/testUtils.ts +++ b/sdk/eventhub/eventhubs-checkpointstore-table/test/utils/testUtils.ts @@ -11,7 +11,7 @@ export const isNode = export enum EnvVarKeys { STORAGE_ACCOUNT_NAME = "STORAGE_ACCOUNT_NAME", - STORAGE_ACCOUNT_KEY = "STORAGE_ACCOUNT_KEY" + STORAGE_ACCOUNT_KEY = "STORAGE_ACCOUNT_KEY", } function getEnvVarValue(name: string): string | undefined { @@ -25,6 +25,6 @@ function getEnvVarValue(name: string): string | undefined { export function getEnvVars(): { [key in EnvVarKeys]: any } { return { [EnvVarKeys.STORAGE_ACCOUNT_KEY]: getEnvVarValue(EnvVarKeys.STORAGE_ACCOUNT_KEY), - [EnvVarKeys.STORAGE_ACCOUNT_NAME]: getEnvVarValue(EnvVarKeys.STORAGE_ACCOUNT_NAME) + [EnvVarKeys.STORAGE_ACCOUNT_NAME]: getEnvVarValue(EnvVarKeys.STORAGE_ACCOUNT_NAME), }; } diff --git a/sdk/eventhub/mock-hub/src/messages/cbs/cbsAccepted.ts b/sdk/eventhub/mock-hub/src/messages/cbs/cbsAccepted.ts index ad35579111a5..f3f9a8cef095 100644 --- a/sdk/eventhub/mock-hub/src/messages/cbs/cbsAccepted.ts +++ b/sdk/eventhub/mock-hub/src/messages/cbs/cbsAccepted.ts @@ -13,8 +13,8 @@ export function createCbsAccepted(options: CreateCbsAcceptedOptions = {}): Messa body: undefined, application_properties: { "status-code": types.wrap_int(202), - "status-description": "Accepted" - } + "status-description": "Accepted", + }, }; if (options.toLinkName) { diff --git a/sdk/eventhub/mock-hub/src/messages/event-hubs/partitionInfo.ts b/sdk/eventhub/mock-hub/src/messages/event-hubs/partitionInfo.ts index 386626a8041c..884a00bfad7e 100644 --- a/sdk/eventhub/mock-hub/src/messages/event-hubs/partitionInfo.ts +++ b/sdk/eventhub/mock-hub/src/messages/event-hubs/partitionInfo.ts @@ -66,7 +66,7 @@ export function generatePartitionInfoResponse({ lastEnqueuedOffset, lastEnqueuedTimeUtc, isPartitionEmpty, - partitionId + partitionId, }: GeneratePartitionInfoResponseOptions): Message { return { to: targetLinkName, @@ -80,8 +80,8 @@ export function generatePartitionInfoResponse({ last_enqueued_offset: lastEnqueuedOffset, last_enqueued_time_utc: lastEnqueuedTimeUtc, is_partition_empty: isPartitionEmpty, - partition: partitionId - } + partition: partitionId, + }, }; } @@ -92,7 +92,7 @@ export interface GenerateBadPartitionInfoResponseOptions { export function generateBadPartitionInfoResponse({ correlationId, - targetLinkName + targetLinkName, }: GenerateBadPartitionInfoResponseOptions): Message { return { to: targetLinkName, @@ -102,8 +102,8 @@ export function generateBadPartitionInfoResponse({ "status-code": 400, "error-condition": "com.microsoft:argument-out-of-range", "status-description": - "The specified partition is invalid for an EventHub partition sender or receiver." + "The specified partition is invalid for an EventHub partition sender or receiver.", }, - body: undefined + body: undefined, }; } diff --git a/sdk/eventhub/mock-hub/src/messages/event-hubs/runtimeInfo.ts b/sdk/eventhub/mock-hub/src/messages/event-hubs/runtimeInfo.ts index 12c01afd83ef..c837fd349590 100644 --- a/sdk/eventhub/mock-hub/src/messages/event-hubs/runtimeInfo.ts +++ b/sdk/eventhub/mock-hub/src/messages/event-hubs/runtimeInfo.ts @@ -53,7 +53,7 @@ export function generateHubRuntimeInfoResponse({ partitions, targetLinkName, createdOn, - eventHubName + eventHubName, }: GenerateHubRuntimeInfoResponseOptions): Message { return { to: targetLinkName, @@ -64,7 +64,7 @@ export function generateHubRuntimeInfoResponse({ type: "com.microsoft:eventhub", created_at: createdOn, partition_count: partitions.length, - partition_ids: types.wrap_array(partitions, 0xa1, undefined) - } + partition_ids: types.wrap_array(partitions, 0xa1, undefined), + }, }; } diff --git a/sdk/eventhub/mock-hub/src/sender/streamingPartitionSender.ts b/sdk/eventhub/mock-hub/src/sender/streamingPartitionSender.ts index 58e7aa1fc513..c594faa11927 100644 --- a/sdk/eventhub/mock-hub/src/sender/streamingPartitionSender.ts +++ b/sdk/eventhub/mock-hub/src/sender/streamingPartitionSender.ts @@ -100,7 +100,7 @@ export class StreamingPartitionSender { } const outgoingMessage: Message = { - ...value.message + ...value.message, }; if (Object.keys(messageAnnotations).length) { outgoingMessage.message_annotations = messageAnnotations; diff --git a/sdk/eventhub/mock-hub/src/server/mockServer.ts b/sdk/eventhub/mock-hub/src/server/mockServer.ts index 0fed2b768841..9d9aeedbedf4 100644 --- a/sdk/eventhub/mock-hub/src/server/mockServer.ts +++ b/sdk/eventhub/mock-hub/src/server/mockServer.ts @@ -12,7 +12,7 @@ import { ReceiverEvents, Sender, SenderEvents, - create_container + create_container, } from "rhea"; import { EventEmitter } from "events"; import { ListenOptions } from "net"; @@ -158,15 +158,15 @@ export class MockServer extends EventEmitter { receiver_options: { max_message_size: options.maxMessageSize ?? ONE_MB, autosettle: true, - autoaccept: false + autoaccept: false, }, sender_options: { max_message_size: options.maxMessageSize ?? ONE_MB, - autosettle: true + autosettle: true, }, transport: "tls", rejectUnauthorized: true, - ...options.tlsOptions + ...options.tlsOptions, }; this._setupDefaultListeners(); @@ -274,9 +274,8 @@ export class MockServer extends EventEmitter { private _setupDefaultListeners(): void { this._container.sasl_server_mechanisms.enable_anonymous(); this._container.sasl.server_add_external(this._container.sasl_server_mechanisms); - this._container.sasl_server_mechanisms["MSSBCBS"] = this._container.sasl_server_mechanisms[ - "EXTERNAL" - ]; + this._container.sasl_server_mechanisms["MSSBCBS"] = + this._container.sasl_server_mechanisms["EXTERNAL"]; this._container.on(ConnectionEvents.connectionError, () => { /* do nothing */ }); @@ -284,23 +283,23 @@ export class MockServer extends EventEmitter { /* do nothing */ }); this._container.on(ConnectionEvents.connectionOpen, (context: EventContext) => { - context.connection.on("error", function(this: typeof context.connection, err: Error) { + context.connection.on("error", function (this: typeof context.connection, err: Error) { console.log(`Error occurred on connection:`, err?.message); }); this.emit("connectionOpen", { - context + context, }); }); this._container.on(ConnectionEvents.connectionClose, (context: EventContext) => { this.emit("connectionClose", { context, - error: context.error as ConnectionError + error: context.error as ConnectionError, }); }); this._container.on(ConnectionEvents.disconnected, (context: EventContext) => { this.emit("connectionClose", { context, - error: context.error as Error + error: context.error as Error, }); }); this._container.on(SenderEvents.senderOpen, (context: EventContext) => { @@ -309,7 +308,7 @@ export class MockServer extends EventEmitter { this.emit("senderOpen", { context, entityPath, - sender: context.sender + sender: context.sender, }); } }); @@ -319,7 +318,7 @@ export class MockServer extends EventEmitter { this.emit("receiverOpen", { context, entityPath, - receiver: context.receiver + receiver: context.receiver, }); } }); @@ -330,7 +329,7 @@ export class MockServer extends EventEmitter { this.emit("senderClose", { context, entityPath, - sender: context.sender + sender: context.sender, }); } }); @@ -340,11 +339,11 @@ export class MockServer extends EventEmitter { this.emit("receiverClose", { context, entityPath, - receiver: context.receiver + receiver: context.receiver, }); } }); - this._container.on("error", function(err) { + this._container.on("error", function (err) { console.log("Unexpected error encountered:", err); }); } @@ -379,7 +378,7 @@ export class MockServer extends EventEmitter { sendMessage: (message: Message) => { this._sendMessage(context, message, message.to); }, - context + context, }); }; diff --git a/sdk/eventhub/mock-hub/src/services/eventHubs.ts b/sdk/eventhub/mock-hub/src/services/eventHubs.ts index ed81475eb834..eae6d20bbfaf 100644 --- a/sdk/eventhub/mock-hub/src/services/eventHubs.ts +++ b/sdk/eventhub/mock-hub/src/services/eventHubs.ts @@ -8,7 +8,7 @@ import { Message, ReceiverEvents, Sender, - SenderEvents + SenderEvents, } from "rhea"; import { ConnectionCloseEvent, @@ -17,16 +17,16 @@ import { OnMessagesEvent, ReceiverOpenEvent, SenderCloseEvent, - SenderOpenEvent + SenderOpenEvent, } from "../server/mockServer"; import { generateBadPartitionInfoResponse, generatePartitionInfoResponse, - isPartitionInfo + isPartitionInfo, } from "../messages/event-hubs/partitionInfo"; import { generateHubRuntimeInfoResponse, - isHubRuntimeInfo + isHubRuntimeInfo, } from "../messages/event-hubs/runtimeInfo"; import { MessageStore } from "../storage/messageStore"; import { StreamingPartitionSender } from "../sender/streamingPartitionSender"; @@ -185,7 +185,7 @@ export class MockEventHub implements IMockEventHub { const forceCloseConnection = (): void => { connection.close({ condition: "amqp:connection:forced", - description: `The connection was inactive for more than the allowed ${this._connectionInactivityTimeoutInMs} milliseconds and is closed by the service.` + description: `The connection was inactive for more than the allowed ${this._connectionInactivityTimeoutInMs} milliseconds and is closed by the service.`, }); }; @@ -228,7 +228,7 @@ export class MockEventHub implements IMockEventHub { return event.receiver.close({ condition: "com.microsoft:argument-out-of-range", description: - "The specified partition is invalid for an EventHub partition sender or receiver." + "The specified partition is invalid for an EventHub partition sender or receiver.", }); } } @@ -306,7 +306,7 @@ export class MockEventHub implements IMockEventHub { // Probably should close the sender at this point. event.sender.close({ condition: "amqp:internal-error", - description: err?.message ?? "" + description: err?.message ?? "", }); } } @@ -425,14 +425,14 @@ export class MockEventHub implements IMockEventHub { application_properties: { "status-code": 404, "status-description": `The messaging entity '${message.application_properties?.name}' could not be found.`, - "error-condition": "amqp:not-found" + "error-condition": "amqp:not-found", }, - body: undefined + body: undefined, }; } else { outgoingMessage = createCbsAccepted({ correlationId: message.message_id as string, - toLinkName: message.reply_to + toLinkName: message.reply_to, }); } event.context.delivery?.accept(); @@ -449,7 +449,7 @@ export class MockEventHub implements IMockEventHub { partitions: this.partitionIds, targetLinkName: message.reply_to, createdOn: this._createdOn, - eventHubName: this._name + eventHubName: this._name, }); event.context.delivery?.accept(); event.sendMessage(outgoingMessage); @@ -465,7 +465,7 @@ export class MockEventHub implements IMockEventHub { if (!this.partitionIds.includes(partitionId)) { outgoingMessage = generateBadPartitionInfoResponse({ correlationId: message.message_id?.toString(), - targetLinkName: message.reply_to + targetLinkName: message.reply_to, }); } else { const partitionInfo = this._messageStore.getPartitionInfo(partitionId); @@ -473,7 +473,7 @@ export class MockEventHub implements IMockEventHub { ...partitionInfo, correlationId: message.message_id?.toString(), targetLinkName: message.reply_to, - eventHubName: this._name + eventHubName: this._name, }); } event.context.delivery?.accept(); @@ -500,8 +500,9 @@ export class MockEventHub implements IMockEventHub { condition: "amqp:link:message-size-exceeded", description: `The received message (delivery-id:${ delivery.id - }, size:${deliverySize} bytes) exceeds the limit (${maxMessageSize ?? - 1024 * 1024} bytes) currently allowed on the link.` + }, size:${deliverySize} bytes) exceeds the limit (${ + maxMessageSize ?? 1024 * 1024 + } bytes) currently allowed on the link.`, }); return; } @@ -601,7 +602,7 @@ export class MockEventHub implements IMockEventHub { condition: "amqp:link:stolen", description: `At least one receiver for the endpoint is created with epoch of '${maxOwnerLevel}', and so non-epoch receiver is not allowed. ` + - `Either reconnect with a higher epoch, or make sure all epoch receivers are closed or disconnected.` + `Either reconnect with a higher epoch, or make sure all epoch receivers are closed or disconnected.`, }); return false; } @@ -615,9 +616,10 @@ export class MockEventHub implements IMockEventHub { partitionSender.close({ condition: "amqp:link:stolen", description: - `New receiver 'nil' with higher epoch of '${ownerLevel}' is created hence current receiver 'nil' with epoch '${senderOwnerLevel ?? - ""}' is getting disconnected. ` + - `If you are recreating the receiver, make sure a higher epoch is used.` + `New receiver 'nil' with higher epoch of '${ownerLevel}' is created hence current receiver 'nil' with epoch '${ + senderOwnerLevel ?? "" + }' is getting disconnected. ` + + `If you are recreating the receiver, make sure a higher epoch is used.`, }); } return true; @@ -629,7 +631,7 @@ export class MockEventHub implements IMockEventHub { description: `Receiver 'nil' with a higher epoch '${maxOwnerLevel}' already exists. ` + `Receiver 'nil' with epoch ${ownerLevel} cannot be created. ` + - `Make sure you are creating receiver with increasing epoch value to ensure connectivity, or ensure all old epoch receivers are closed or disconnected.` + `Make sure you are creating receiver with increasing epoch value to ensure connectivity, or ensure all old epoch receivers are closed or disconnected.`, }); return false; } @@ -694,7 +696,7 @@ export class MockEventHub implements IMockEventHub { sender.close({ condition: "com.microsoft:argument-out-of-range", description: - "The specified partition is invalid for an EventHub partition sender or receiver." + "The specified partition is invalid for an EventHub partition sender or receiver.", }); return false; } @@ -702,7 +704,7 @@ export class MockEventHub implements IMockEventHub { const host = (context.connection.hostname ?? "").split(".")[0]; sender.close({ condition: "amqp-not-found", - description: `The messaging entity '${host}:eventhub:${eventHubName}~0|${consumerGroup}' could not be found.` + description: `The messaging entity '${host}:eventhub:${eventHubName}~0|${consumerGroup}' could not be found.`, }); return false; } @@ -738,7 +740,7 @@ export class MockEventHub implements IMockEventHub { const [eventHubName, , partitionId] = parts; return { eventHubName, - partitionId + partitionId, }; } @@ -754,7 +756,7 @@ export class MockEventHub implements IMockEventHub { return { eventHubName, consumerGroup, - partitionId + partitionId, }; } diff --git a/sdk/eventhub/mock-hub/src/storage/messageStore.ts b/sdk/eventhub/mock-hub/src/storage/messageStore.ts index 2c9751ca90b8..68c2cdebac16 100644 --- a/sdk/eventhub/mock-hub/src/storage/messageStore.ts +++ b/sdk/eventhub/mock-hub/src/storage/messageStore.ts @@ -119,7 +119,7 @@ export class MessageStore { lastEnqueuedTimeUtc: new Date(0), lastEnqueuedSequenceNumber: -1, partitionId, - isPartitionEmpty: isEmpty + isPartitionEmpty: isEmpty, }; } @@ -131,7 +131,7 @@ export class MessageStore { lastEnqueuedTimeUtc: lastMessage.enqueuedTime, lastEnqueuedSequenceNumber: lastMessage.sequenceNumber, partitionId, - isPartitionEmpty: isEmpty + isPartitionEmpty: isEmpty, }; } @@ -149,7 +149,7 @@ export class MessageStore { enqueuedTime: new Date(), sequenceNumber: partitionStore.length + 1, offset: partitionStore.length, - message + message, }; if (partitionKey) { record.partitionKey = partitionKey; diff --git a/sdk/eventhub/mock-hub/src/utils/convertBufferToMessage.ts b/sdk/eventhub/mock-hub/src/utils/convertBufferToMessage.ts index df74fd1ad38a..e7674e73db82 100644 --- a/sdk/eventhub/mock-hub/src/utils/convertBufferToMessage.ts +++ b/sdk/eventhub/mock-hub/src/utils/convertBufferToMessage.ts @@ -9,7 +9,7 @@ import { Message, message as rheaMessage } from "rhea"; export function convertBufferToMessages(buf: Buffer): Message[] { const amqpMessage = rheaMessage.decode(buf); if (!amqpMessage.body?.content) { - return [(amqpMessage as unknown) as Message]; + return [amqpMessage as unknown as Message]; } if (Array.isArray(amqpMessage.body.content)) { @@ -18,5 +18,5 @@ export function convertBufferToMessages(buf: Buffer): Message[] { }); } - return [(rheaMessage.decode(amqpMessage.body.content) as unknown) as Message]; + return [rheaMessage.decode(amqpMessage.body.content) as unknown as Message]; } diff --git a/sdk/eventhub/mock-hub/src/utils/eventPosition.ts b/sdk/eventhub/mock-hub/src/utils/eventPosition.ts index e53753358dc9..6b2a4dbccd2f 100644 --- a/sdk/eventhub/mock-hub/src/utils/eventPosition.ts +++ b/sdk/eventhub/mock-hub/src/utils/eventPosition.ts @@ -42,19 +42,19 @@ export function getEventPosition(filter: string): EventPosition { return { type: "offset", operator, - value: normalizedValue === "@latest" ? normalizedValue : parseInt(normalizedValue, 10) + value: normalizedValue === "@latest" ? normalizedValue : parseInt(normalizedValue, 10), }; } else if (fullType === "amqp.annotation.x-opt-sequence-number") { return { type: "sequenceNumber", operator, - value: parseInt(normalizedValue, 10) + value: parseInt(normalizedValue, 10), }; } else if (fullType === "amqp.annotation.x-opt-enqueued-time") { return { type: "enqueuedTime", operator, - value: parseInt(normalizedValue, 10) + value: parseInt(normalizedValue, 10), }; } diff --git a/sdk/eventhub/perf-tests/event-hubs/test/receive.spec.ts b/sdk/eventhub/perf-tests/event-hubs/test/receive.spec.ts index 4c49238e0499..08d2e449b40e 100644 --- a/sdk/eventhub/perf-tests/event-hubs/test/receive.spec.ts +++ b/sdk/eventhub/perf-tests/event-hubs/test/receive.spec.ts @@ -19,7 +19,7 @@ import { earliestEventPosition, EventData, PartitionContext, - EventHubProducerClient + EventHubProducerClient, } from "@azure/event-hubs"; import { getEnvVar } from "@azure/test-utils-perf"; import moment from "moment"; @@ -98,7 +98,7 @@ async function RunTest(maxBatchSize: number, messages: number): Promise { consumerClient.subscribe( { processEvents, - processError + processError, }, { maxBatchSize, startPosition: earliestEventPosition } ); diff --git a/sdk/eventhub/perf-tests/event-hubs/test/send.spec.ts b/sdk/eventhub/perf-tests/event-hubs/test/send.spec.ts index 41009a6d7b4c..c2b092f8306f 100644 --- a/sdk/eventhub/perf-tests/event-hubs/test/send.spec.ts +++ b/sdk/eventhub/perf-tests/event-hubs/test/send.spec.ts @@ -26,22 +26,22 @@ export class SendTest extends PerfTest { description: "Size in bytes", shortName: "sz", longName: "size", - defaultValue: 1024 + defaultValue: 1024, }, numberOfEvents: { required: true, description: "Number of events per send", shortName: "num", longName: "numberOfEvents", - defaultValue: 10 - } + defaultValue: 10, + }, }; constructor() { super(); this.producer = producer; const event = { - body: Buffer.alloc(this.parsedOptions.eventBodySize.value!) + body: Buffer.alloc(this.parsedOptions.eventBodySize.value!), }; this.eventBatch = new Array(this.parsedOptions.numberOfEvents.value!).fill(event); } From 721de13ece6947c4a400917d3c58f78f567c648d Mon Sep 17 00:00:00 2001 From: Jonathan Cardenas Date: Thu, 23 Dec 2021 01:01:29 -0600 Subject: [PATCH 3/3] Removing path `"test/**/*.ts"` from format command --- sdk/eventhub/mock-hub/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/eventhub/mock-hub/package.json b/sdk/eventhub/mock-hub/package.json index 7bca719e4a05..7e8be057e13d 100644 --- a/sdk/eventhub/mock-hub/package.json +++ b/sdk/eventhub/mock-hub/package.json @@ -17,11 +17,11 @@ "build": "npm run clean && tsc -p .", "build:samples": "dev-tool samples prep && cd dist-samples && tsc -p .", "build:test": "echo skipped", - "check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"", + "check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\"", "clean": "rimraf dist types *.tgz *.log", "execute:samples": "npm run build:samples && dev-tool samples run dist-samples/javascript dist-samples/typescript/dist/dist-samples/typescript/src/", "extract-api": "tsc -p . && api-extractor run --local", - "format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"", + "format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"*.{js,json}\"", "integration-test:browser": "echo skipped", "integration-test:node": "echo skipped", "integration-test": "npm run integration-test:node && npm run integration-test:browser",