Skip to content
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
798e4f2
Rename to use sbClient for instances of ServiceBusClient
May 16, 2019
5a27e6d
Refactor out loading of environment variables
May 20, 2019
741e15d
Merge branch 'master' into issue-2859
ramya0820 May 20, 2019
d217886
Merge branch 'master' of https://github.com/Azure/azure-sdk-for-js in…
May 20, 2019
71eb034
Simplify if-else checks
May 20, 2019
360f24a
Merge branch 'issue-2859' of https://github.com/ramya0820/azure-sdk-f…
May 20, 2019
dd56447
Rename utility function to getNamespace
May 20, 2019
96b0b83
Simplify env variable access and error handling
May 20, 2019
3dc2806
Merge branch 'master' into issue-2859
ramya0820 May 20, 2019
1bd14a6
Merge branch 'master' into issue-2859
ramya0820 May 21, 2019
69e3928
Address comments
May 21, 2019
27899e9
Merge branch 'issue-2859' of https://github.com/ramya0820/azure-sdk-f…
May 21, 2019
5f00bdd
Refactor all tests
May 21, 2019
3a1c9e0
Address comments
May 21, 2019
290511b
Merge branch 'master' into issue-2859
ramya0820 May 21, 2019
0d8701d
nom -> npm
May 21, 2019
173d399
Merge fix from issue-2861 and update isNode references
May 21, 2019
b2e36a0
Revert isNode import from amqp-common
May 21, 2019
536d527
Update isNode computation
May 22, 2019
a256dfc
Update isNode check in utils and add header
May 22, 2019
2d465a0
Update reference to version usage in browser mode
May 22, 2019
34ae808
Update version usage references
May 22, 2019
6711f91
Make dependency exclusion test specific
May 22, 2019
09c7cb2
Refactor rollup test config
May 22, 2019
11abcf8
Revert changes that fix version not defined on CI
May 22, 2019
1eb1857
Minor edit to get around linter
May 22, 2019
a234736
Cleanup external module reference
May 22, 2019
ec96ec0
Make ms-rest-nodeauth external for browser
May 22, 2019
789357d
Bypass rush
May 22, 2019
7e49a35
Bypass rush
May 22, 2019
2abfef3
Revert bypassing rush
May 22, 2019
f4adf22
Merge branch 'master' into issue-2859
ramya0820 May 23, 2019
cfe3249
Add missing browser dependencies
May 23, 2019
471919b
Dedupe test:browser script content
May 23, 2019
2906726
Run only a single live test at a time
May 23, 2019
e324063
Merge branch 'master' into issue-2859
ramya0820 May 28, 2019
d3b8846
Use package.json approach
May 29, 2019
bb33fe6
Merge branch 'issue-2859' of https://github.com/ramya0820/azure-sdk-f…
May 29, 2019
6c5c53c
Skip browser tests on CI
May 29, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sdk/servicebus/service-bus/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ module.exports = function(config) {
mocha: {
// change Karma's debug.html to the mocha web reporter
reporter: "html",
timeout: "600000"
timeout: "600000",
grep: " #RunInBrowser"
}
}
});
Expand Down
8 changes: 4 additions & 4 deletions sdk/servicebus/service-bus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,16 +108,16 @@
"build:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1",
"build:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1",
"build:samples": "node .scripts/prepSamples.js && cd samples && tsc -p .",
"build:test:browser": "tsc -p . && cross-env BROWSER_TEST=true rollup -c 2>&1",
"build:test:node": "tsc -p . && rollup -c rollup.test.config.js 2>&1",
"build:test": "tsc -p . && cross-env ONLY_NODE=true rollup -c rollup.test.config.js 2>&1",
"build:test:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c rollup.test.config.js 2>&1",
"build:test:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c rollup.test.config.js 2>&1",
"build:test": "npm run build:test:node && npm run build:test:browser",
"build": "tsc -p . && rollup -c 2>&1 && npm run extract-api",
"check-format": "prettier --list-different --config ../../.prettierrc.json \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
"clean": "rimraf dist dist-esm test-dist typings *.tgz *.log coverage coverage-browser .nyc_output",
"coverage": "nyc --reporter=lcov --exclude-after-remap=false mocha -t 120000 test-dist/index.js --reporter mocha-multi --reporter-options spec=-,mocha-junit-reporter=-",
"extract-api": "tsc -p . && api-extractor run --local",
"format": "prettier --write --config ../../.prettierrc.json \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"",
"integration-test:browser": "echo skipped",
"integration-test:browser": "karma start --single-run",
"integration-test:node": "mocha -t 120000 test-dist/index.js --reporter mocha-multi --reporter-options spec=-,mocha-junit-reporter=-",
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
"lint": "eslint -c ../../.eslintrc.json src test samples --ext .ts",
Expand Down
20 changes: 17 additions & 3 deletions sdk/servicebus/service-bus/rollup.base.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ const pkg = require("./package.json");
const depNames = Object.keys(pkg.dependencies);
const input = "dist-esm/src/index.js";

const version = require("./package.json").version;
const banner = [
"/*!",
` * Azure Service Bus SDK for JavaScript, ${version}`,
" * Copyright (c) Microsoft and contributors. All rights reserved.",
" */"
].join("\n");

const ignoreKnownWarnings = (warning) => {
if (warning.code === "THIS_IS_UNDEFINED") {
// This error happens frequently due to TypeScript emitting `this` at the
Expand Down Expand Up @@ -86,7 +94,7 @@ export function nodeConfig({ test = false, production = false } = {}) {
export function browserConfig({ test = false, production = false } = {}) {
const baseConfig = {
input: input,
external: [],
external: ["@azure/ms-rest-nodeauth"],
output: {
file: "browser/service-bus.js",
format: "umd",
Expand Down Expand Up @@ -149,12 +157,18 @@ export function browserConfig({ test = false, production = false } = {}) {
baseConfig.onwarn = ignoreKnownWarnings;

if (test) {
baseConfig.input = "dist-esm/test/browserified/*.spec.js";
baseConfig.input = "dist-esm/test/*.spec.js";
baseConfig.plugins.unshift(multiEntry({ exports: false }));
baseConfig.output.file = "test-browser/index.js";
} else if (production) {
baseConfig.output.file = "browser/service-bus.min.js";
baseConfig.plugins.push(terser());
baseConfig.plugins.push(
terser({
output: {
preamble: banner
}
})
);
}

return baseConfig;
Expand Down
12 changes: 11 additions & 1 deletion sdk/servicebus/service-bus/rollup.test.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,14 @@

import * as base from "./rollup.base.config";

export default [base.nodeConfig({ test: true }) /*, base.browserConfig({ test: true })*/];
const inputs = [];

if (!process.env.ONLY_BROWSER) {
inputs.push(base.nodeConfig({ test: true }));
}

if (!process.env.ONLY_NODE) {
inputs.push(base.browserConfig({ test: true }));
}

export default inputs;
64 changes: 30 additions & 34 deletions sdk/servicebus/service-bus/test/batchReceiver.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import chai from "chai";
import chaiAsPromised from "chai-as-promised";
import dotenv from "dotenv";
import {
delay,
QueueClient,
Expand All @@ -17,9 +16,14 @@ import {
import { Receiver, SessionReceiver } from "../src/receiver";
import { Sender } from "../src/sender";
import { getAlreadyReceivingErrorMsg } from "../src/util/errors";
import { TestClientType, getSenderReceiverClients, purge, TestMessage } from "./testUtils";
import {
TestClientType,
getSenderReceiverClients,
purge,
TestMessage,
getServiceBusClient
} from "./utils/testUtils";
const should = chai.should();
dotenv.config();
chai.use(chaiAsPromised);

async function testPeekMsgsLength(
Expand All @@ -34,7 +38,7 @@ async function testPeekMsgsLength(
);
}

let ns: ServiceBusClient;
let sbClient: ServiceBusClient;

let errorWasThrown: boolean;

Expand All @@ -50,28 +54,18 @@ async function beforeEachTest(
receiverType: TestClientType,
useSessions?: boolean
): Promise<void> {
// The tests in this file expect the env variables to contain the connection string and
// the names of empty queue/topic/subscription that are to be tested

if (!process.env.SERVICEBUS_CONNECTION_STRING) {
throw new Error(
"Define SERVICEBUS_CONNECTION_STRING in your environment before running integration tests."
);
}

ns = ServiceBusClient.createFromConnectionString(process.env.SERVICEBUS_CONNECTION_STRING);

const clients = await getSenderReceiverClients(ns, senderType, receiverType);
sbClient = getServiceBusClient();
const clients = await getSenderReceiverClients(sbClient, senderType, receiverType);
senderClient = clients.senderClient;
receiverClient = clients.receiverClient;
if (receiverClient instanceof QueueClient) {
deadLetterClient = ns.createQueueClient(
deadLetterClient = sbClient.createQueueClient(
QueueClient.getDeadLetterQueuePath(receiverClient.entityPath)
);
}

if (receiverClient instanceof SubscriptionClient) {
deadLetterClient = ns.createSubscriptionClient(
deadLetterClient = sbClient.createSubscriptionClient(
TopicClient.getDeadLetterTopicPath(senderClient.entityPath, receiverClient.subscriptionName),
receiverClient.subscriptionName
);
Expand Down Expand Up @@ -102,7 +96,7 @@ async function beforeEachTest(
}

async function afterEachTest(): Promise<void> {
await ns.close();
await sbClient.close();
}
describe("Batch Receiver - Settle message", function(): void {
afterEach(async () => {
Expand Down Expand Up @@ -141,7 +135,9 @@ describe("Batch Receiver - Settle message", function(): void {
await testComplete();
});

it("Unpartitioned Queue: complete() removes message", async function(): Promise<void> {
it("Unpartitioned Queue: complete() removes message #RunInBrowser ", async function(): Promise<
void
> {
await beforeEachTest(TestClientType.UnpartitionedQueue, TestClientType.UnpartitionedQueue);
await testComplete();
});
Expand Down Expand Up @@ -176,7 +172,7 @@ describe("Batch Receiver - Settle message", function(): void {
await testComplete(true);
});

it("Unpartitioned Queue with Sessions: complete() removes message", async function(): Promise<
it("Unpartitioned Queue with Sessions: complete() removes message #RunInBrowser", async function(): Promise<
void
> {
await beforeEachTest(
Expand Down Expand Up @@ -234,7 +230,7 @@ describe("Batch Receiver - Settle message", function(): void {
await testAbandon();
});

it("Unpartitioned Queue: abandon() retains message with incremented deliveryCount", async function(): Promise<
it("Unpartitioned Queue: abandon() retains message with incremented deliveryCount #RunInBrowser", async function(): Promise<
void
> {
await beforeEachTest(TestClientType.UnpartitionedQueue, TestClientType.UnpartitionedQueue);
Expand Down Expand Up @@ -273,7 +269,7 @@ describe("Batch Receiver - Settle message", function(): void {
await testAbandon(true);
});

it("Unpartitioned Queue with Sessions: abandon() retains message with incremented deliveryCount", async function(): Promise<
it("Unpartitioned Queue with Sessions: abandon() retains message with incremented deliveryCount #RunInBrowser", async function(): Promise<
void
> {
await beforeEachTest(
Expand Down Expand Up @@ -469,7 +465,7 @@ describe("Batch Receiver - Settle message", function(): void {
await testDefer(true);
});

it("Unpartitioned Queue: defer() moves message to deferred queue", async function(): Promise<
it("Unpartitioned Queue: defer() moves message to deferred queue #RunInBrowser", async function(): Promise<
void
> {
await beforeEachTest(TestClientType.UnpartitionedQueue, TestClientType.UnpartitionedQueue);
Expand All @@ -486,7 +482,7 @@ describe("Batch Receiver - Settle message", function(): void {
await testDefer();
});

it("Unpartitioned Queue with Sessions: defer() moves message to deferred queue", async function(): Promise<
it("Unpartitioned Queue with Sessions: defer() moves message to deferred queue #RunInBrowser", async function(): Promise<
void
> {
await beforeEachTest(
Expand Down Expand Up @@ -554,7 +550,7 @@ describe("Batch Receiver - Settle message", function(): void {
await testDeadletter();
});

it("Unpartitioned Queue: deadLetter() moves message to deadletter queue", async function(): Promise<
it("Unpartitioned Queue: deadLetter() moves message to deadletter queue #RunInBrowser", async function(): Promise<
void
> {
await beforeEachTest(TestClientType.UnpartitionedQueue, TestClientType.UnpartitionedQueue);
Expand Down Expand Up @@ -593,7 +589,7 @@ describe("Batch Receiver - Settle message", function(): void {
await testDeadletter(true);
});

it("Unpartitioned Queue with Sessions: deadLetter() moves message to deadletter queue", async function(): Promise<
it("Unpartitioned Queue with Sessions: deadLetter() moves message to deadletter queue #RunInBrowser", async function(): Promise<
void
> {
await beforeEachTest(
Expand Down Expand Up @@ -898,7 +894,7 @@ describe("Batch Receiver - Multiple Receiver Operations", function(): void {
await testParallelReceiveCalls();
});

it("Unpartitioned Queue: Throws error when ReceiveBatch is called while the previous call is not done", async function(): Promise<
it("Unpartitioned Queue: Throws error when ReceiveBatch is called while the previous call is not done #RunInBrowser", async function(): Promise<
void
> {
await beforeEachTest(TestClientType.UnpartitionedQueue, TestClientType.UnpartitionedQueue);
Expand Down Expand Up @@ -937,7 +933,7 @@ describe("Batch Receiver - Multiple Receiver Operations", function(): void {
await testParallelReceiveCalls(true);
});

it("Unpartitioned Queue with Sessions: Throws error when ReceiveBatch is called while the previous call is not done", async function(): Promise<
it("Unpartitioned Queue with Sessions: Throws error when ReceiveBatch is called while the previous call is not done #RunInBrowser", async function(): Promise<
void
> {
await beforeEachTest(
Expand Down Expand Up @@ -1029,7 +1025,7 @@ describe("Batch Receiver - Multiple Receiver Operations", function(): void {
await testSequentialReceiveBatchCalls();
});

it("Unpartitioned Queue: Multiple sequential receiveMessages calls", async function(): Promise<
it("Unpartitioned Queue: Multiple sequential receiveMessages calls #RunInBrowser", async function(): Promise<
void
> {
await beforeEachTest(TestClientType.UnpartitionedQueue, TestClientType.UnpartitionedQueue);
Expand Down Expand Up @@ -1068,7 +1064,7 @@ describe("Batch Receiver - Multiple Receiver Operations", function(): void {
await testSequentialReceiveBatchCalls(true);
});

it("Unpartitioned Queue with Sessions: Multiple sequential receiveMessages calls", async function(): Promise<
it("Unpartitioned Queue with Sessions: Multiple sequential receiveMessages calls #RunInBrowser", async function(): Promise<
void
> {
await beforeEachTest(
Expand Down Expand Up @@ -1139,7 +1135,7 @@ describe("Batch Receiver - Others", function(): void {
await testNoSettlement();
});

it("Unpartitioned Queue: No settlement of the message is retained with incremented deliveryCount", async function(): Promise<
it("Unpartitioned Queue: No settlement of the message is retained with incremented deliveryCount #RunInBrowser", async function(): Promise<
void
> {
await beforeEachTest(TestClientType.UnpartitionedQueue, TestClientType.UnpartitionedQueue);
Expand Down Expand Up @@ -1190,7 +1186,7 @@ describe("Batch Receiver - Others", function(): void {
await testAskForMore();
});

it("Unpartitioned Queue: Receive n messages but queue only has m messages, where m < n", async function(): Promise<
it("Unpartitioned Queue: Receive n messages but queue only has m messages, where m < n #RunInBrowser", async function(): Promise<
void
> {
await beforeEachTest(TestClientType.UnpartitionedQueue, TestClientType.UnpartitionedQueue);
Expand Down Expand Up @@ -1231,7 +1227,7 @@ describe("Batch Receiver - Others", function(): void {
await testAskForMore(true);
});

it("Unpartitioned Queue with Sessions: Receive n messages but queue only has m messages, where m < n", async function(): Promise<
it("Unpartitioned Queue with Sessions: Receive n messages but queue only has m messages, where m < n #RunInBrowser", async function(): Promise<
void
> {
await beforeEachTest(
Expand Down
Loading