@fluidframework/azure-end-to-end-tests 1.1.0-101037
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +18 -0
- package/LICENSE +21 -0
- package/README.md +8 -0
- package/dist/packageVersion.js +12 -0
- package/dist/packageVersion.js.map +1 -0
- package/dist/test/AzureClientFactory.js +43 -0
- package/dist/test/AzureClientFactory.js.map +1 -0
- package/dist/test/AzureTokenFactory.js +17 -0
- package/dist/test/AzureTokenFactory.js.map +1 -0
- package/dist/test/TestDataObject.js +50 -0
- package/dist/test/TestDataObject.js.map +1 -0
- package/dist/test/audience.spec.js +102 -0
- package/dist/test/audience.spec.js.map +1 -0
- package/dist/test/containerCopy.spec.js +142 -0
- package/dist/test/containerCopy.spec.js.map +1 -0
- package/dist/test/containerCreate.spec.js +112 -0
- package/dist/test/containerCreate.spec.js.map +1 -0
- package/dist/test/ddsTests.spec.js +180 -0
- package/dist/test/ddsTests.spec.js.map +1 -0
- package/dist/test/utils.js +40 -0
- package/dist/test/utils.js.map +1 -0
- package/package.json +97 -0
- package/src/packageVersion.ts +9 -0
- package/src/test/AzureClientFactory.ts +46 -0
- package/src/test/AzureTokenFactory.ts +19 -0
- package/src/test/TestDataObject.ts +68 -0
- package/src/test/audience.spec.ts +138 -0
- package/src/test/containerCopy.spec.ts +184 -0
- package/src/test/containerCreate.spec.ts +152 -0
- package/src/test/ddsTests.spec.ts +246 -0
- package/src/test/tsconfig.json +17 -0
- package/src/test/utils.ts +48 -0
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
module.exports = {
|
|
6
|
+
"extends": [
|
|
7
|
+
require.resolve("@fluidframework/eslint-config-fluid"),
|
|
8
|
+
"prettier",
|
|
9
|
+
],
|
|
10
|
+
"rules": {
|
|
11
|
+
"prefer-arrow-callback": "off",
|
|
12
|
+
"@typescript-eslint/strict-boolean-expressions": "off", // requires strictNullChecks=true in tsconfig
|
|
13
|
+
},
|
|
14
|
+
"parserOptions": {
|
|
15
|
+
"project": [ "./src/test/tsconfig.json" ]
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# @fluidframework/azure-end-to-end-tests
|
|
2
|
+
|
|
3
|
+
Functional end-to-end tests for FRS and Azure Local Service. Here we evaluate various scenarios that involving azure-client, IFluidContainer and a range of distributed data structures (DDSes).
|
|
4
|
+
|
|
5
|
+
To run FRS e2e tests: `test:realsvc:azure`.
|
|
6
|
+
|
|
7
|
+
To run Azure Local Service e2e tests: `test:realsvc`.
|
|
8
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*
|
|
6
|
+
* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.pkgVersion = exports.pkgName = void 0;
|
|
10
|
+
exports.pkgName = "@fluidframework/azure-end-to-end-tests";
|
|
11
|
+
exports.pkgVersion = "1.1.0-101037";
|
|
12
|
+
//# sourceMappingURL=packageVersion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../src/packageVersion.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,OAAO,GAAG,wCAAwC,CAAC;AACnD,QAAA,UAAU,GAAG,cAAc,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n *\n * THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY\n */\n\nexport const pkgName = \"@fluidframework/azure-end-to-end-tests\";\nexport const pkgVersion = \"1.1.0-101037\";\n"]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAzureClient = void 0;
|
|
4
|
+
/*!
|
|
5
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
6
|
+
* Licensed under the MIT License.
|
|
7
|
+
*/
|
|
8
|
+
const uuid_1 = require("uuid");
|
|
9
|
+
const azure_client_1 = require("@fluidframework/azure-client");
|
|
10
|
+
const test_client_utils_1 = require("@fluidframework/test-client-utils");
|
|
11
|
+
const AzureTokenFactory_1 = require("./AzureTokenFactory");
|
|
12
|
+
/**
|
|
13
|
+
* This function will determine if local or remote mode is required (based on FLUID_CLIENT), and return a new
|
|
14
|
+
* {@link AzureClient} instance based on the mode by setting the Connection config accordingly.
|
|
15
|
+
*/
|
|
16
|
+
function createAzureClient(userID, userName) {
|
|
17
|
+
const useAzure = process.env.FLUID_CLIENT === "azure";
|
|
18
|
+
const tenantId = useAzure
|
|
19
|
+
? process.env.azure__fluid__relay__service__tenantId
|
|
20
|
+
: "frs-client-tenant";
|
|
21
|
+
const user = {
|
|
22
|
+
id: userID !== null && userID !== void 0 ? userID : (0, uuid_1.v4)(),
|
|
23
|
+
name: userName !== null && userName !== void 0 ? userName : (0, uuid_1.v4)(),
|
|
24
|
+
};
|
|
25
|
+
// use AzureClient remote mode will run against live Azure Fluid Relay.
|
|
26
|
+
// Default to running Tinylicious for PR validation
|
|
27
|
+
// and local testing so it's not hindered by service availability
|
|
28
|
+
const connectionProps = useAzure
|
|
29
|
+
? {
|
|
30
|
+
tenantId,
|
|
31
|
+
tokenProvider: (0, AzureTokenFactory_1.createAzureTokenProvider)(userID, userName),
|
|
32
|
+
endpoint: "https://alfred.westus2.fluidrelay.azure.com",
|
|
33
|
+
type: "remote",
|
|
34
|
+
}
|
|
35
|
+
: {
|
|
36
|
+
tokenProvider: new test_client_utils_1.InsecureTokenProvider("fooBar", user),
|
|
37
|
+
endpoint: "http://localhost:7071",
|
|
38
|
+
type: "local",
|
|
39
|
+
};
|
|
40
|
+
return new azure_client_1.AzureClient({ connection: connectionProps });
|
|
41
|
+
}
|
|
42
|
+
exports.createAzureClient = createAzureClient;
|
|
43
|
+
//# sourceMappingURL=AzureClientFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AzureClientFactory.js","sourceRoot":"","sources":["../../src/test/AzureClientFactory.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,+BAAkC;AAElC,+DAIsC;AACtC,yEAA0E;AAE1E,2DAA+D;AAE/D;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,MAAe,EAAE,QAAiB;IAChE,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,KAAK,OAAO,CAAC;IACtD,MAAM,QAAQ,GAAG,QAAQ;QACrB,CAAC,CAAE,OAAO,CAAC,GAAG,CAAC,sCAAiD;QAChE,CAAC,CAAC,mBAAmB,CAAC;IAC1B,MAAM,IAAI,GAAG;QACT,EAAE,EAAE,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,IAAA,SAAI,GAAE;QACpB,IAAI,EAAE,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,IAAA,SAAI,GAAE;KAC3B,CAAC;IAEF,uEAAuE;IACvE,mDAAmD;IACnD,iEAAiE;IACjE,MAAM,eAAe,GAA6D,QAAQ;QACtF,CAAC,CAAC;YACI,QAAQ;YACR,aAAa,EAAE,IAAA,4CAAwB,EAAC,MAAM,EAAE,QAAQ,CAAC;YACzD,QAAQ,EAAE,6CAA6C;YACvD,IAAI,EAAE,QAAQ;SACjB;QACH,CAAC,CAAC;YACI,aAAa,EAAE,IAAI,yCAAqB,CAAC,QAAQ,EAAE,IAAI,CAAC;YACxD,QAAQ,EAAE,uBAAuB;YACjC,IAAI,EAAE,OAAO;SAChB,CAAC;IACR,OAAO,IAAI,0BAAW,CAAC,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC,CAAC;AAC5D,CAAC;AA1BD,8CA0BC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { v4 as uuid } from \"uuid\";\n\nimport {\n AzureClient,\n AzureLocalConnectionConfig,\n AzureRemoteConnectionConfig,\n} from \"@fluidframework/azure-client\";\nimport { InsecureTokenProvider } from \"@fluidframework/test-client-utils\";\n\nimport { createAzureTokenProvider } from \"./AzureTokenFactory\";\n\n/**\n * This function will determine if local or remote mode is required (based on FLUID_CLIENT), and return a new\n * {@link AzureClient} instance based on the mode by setting the Connection config accordingly.\n */\nexport function createAzureClient(userID?: string, userName?: string): AzureClient {\n const useAzure = process.env.FLUID_CLIENT === \"azure\";\n const tenantId = useAzure\n ? (process.env.azure__fluid__relay__service__tenantId as string)\n : \"frs-client-tenant\";\n const user = {\n id: userID ?? uuid(),\n name: userName ?? uuid(),\n };\n\n // use AzureClient remote mode will run against live Azure Fluid Relay.\n // Default to running Tinylicious for PR validation\n // and local testing so it's not hindered by service availability\n const connectionProps: AzureRemoteConnectionConfig | AzureLocalConnectionConfig = useAzure\n ? {\n tenantId,\n tokenProvider: createAzureTokenProvider(userID, userName),\n endpoint: \"https://alfred.westus2.fluidrelay.azure.com\",\n type: \"remote\",\n }\n : {\n tokenProvider: new InsecureTokenProvider(\"fooBar\", user),\n endpoint: \"http://localhost:7071\",\n type: \"local\",\n };\n return new AzureClient({ connection: connectionProps });\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.createAzureTokenProvider = void 0;
|
|
8
|
+
const azure_client_1 = require("@fluidframework/azure-client");
|
|
9
|
+
function createAzureTokenProvider(userID, userName) {
|
|
10
|
+
const fnUrl = process.env.azure__fluid__relay__service__function__url;
|
|
11
|
+
return new azure_client_1.AzureFunctionTokenProvider(`${fnUrl}/api/GetFrsToken`, {
|
|
12
|
+
userId: userID !== null && userID !== void 0 ? userID : "foo",
|
|
13
|
+
userName: userName !== null && userName !== void 0 ? userName : "bar",
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
exports.createAzureTokenProvider = createAzureTokenProvider;
|
|
17
|
+
//# sourceMappingURL=AzureTokenFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AzureTokenFactory.js","sourceRoot":"","sources":["../../src/test/AzureTokenFactory.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,+DAEsC;AAEtC,SAAgB,wBAAwB,CACpC,MAAe,EACf,QAAiB;IAEjB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,2CAAqD,CAAC;IAChF,OAAO,IAAI,yCAA0B,CAAC,GAAG,KAAK,kBAAkB,EAAE;QAC9D,MAAM,EAAE,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,KAAK;QACvB,QAAQ,EAAE,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,KAAK;KAC9B,CAAC,CAAC;AACP,CAAC;AATD,4DASC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport {\n AzureFunctionTokenProvider\n} from \"@fluidframework/azure-client\";\n\nexport function createAzureTokenProvider(\n userID?: string,\n userName?: string,\n): AzureFunctionTokenProvider {\n const fnUrl = process.env.azure__fluid__relay__service__function__url as string;\n return new AzureFunctionTokenProvider(`${fnUrl}/api/GetFrsToken`, {\n userId: userID ?? \"foo\",\n userName: userName ?? \"bar\",\n });\n}\n"]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*!
|
|
3
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.CounterTestDataObject = exports.TestDataObject = void 0;
|
|
8
|
+
const aqueduct_1 = require("@fluidframework/aqueduct");
|
|
9
|
+
const counter_1 = require("@fluidframework/counter");
|
|
10
|
+
class TestDataObject extends aqueduct_1.DataObject {
|
|
11
|
+
constructor(props) {
|
|
12
|
+
super(props);
|
|
13
|
+
}
|
|
14
|
+
static get Name() {
|
|
15
|
+
return "@fluid-example/test-data-object";
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.TestDataObject = TestDataObject;
|
|
19
|
+
TestDataObject.factory = new aqueduct_1.DataObjectFactory(TestDataObject.Name, TestDataObject, [], {});
|
|
20
|
+
class CounterTestDataObject extends aqueduct_1.DataObject {
|
|
21
|
+
/**
|
|
22
|
+
* Do setup work here
|
|
23
|
+
*/
|
|
24
|
+
async initializingFirstTime() {
|
|
25
|
+
const counter = counter_1.SharedCounter.create(this.runtime);
|
|
26
|
+
this.root.set("counter-key", counter.handle);
|
|
27
|
+
}
|
|
28
|
+
async hasInitialized() {
|
|
29
|
+
const counterHandle = this.root.get("counter-key");
|
|
30
|
+
this._counter = await (counterHandle === null || counterHandle === void 0 ? void 0 : counterHandle.get());
|
|
31
|
+
}
|
|
32
|
+
static get Name() {
|
|
33
|
+
return "@fluid-example/counter-test-data-object";
|
|
34
|
+
}
|
|
35
|
+
increment() {
|
|
36
|
+
this.counter.increment(1);
|
|
37
|
+
}
|
|
38
|
+
get value() {
|
|
39
|
+
return this.counter.value;
|
|
40
|
+
}
|
|
41
|
+
get counter() {
|
|
42
|
+
if (this._counter === undefined) {
|
|
43
|
+
throw new Error("SharedCounter not initialized");
|
|
44
|
+
}
|
|
45
|
+
return this._counter;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.CounterTestDataObject = CounterTestDataObject;
|
|
49
|
+
CounterTestDataObject.factory = new aqueduct_1.DataObjectFactory(CounterTestDataObject.Name, CounterTestDataObject, [counter_1.SharedCounter.getFactory()], {});
|
|
50
|
+
//# sourceMappingURL=TestDataObject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TestDataObject.js","sourceRoot":"","sources":["../../src/test/Test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DAyCC;AArB0B,6BAAO,GAAG,IAAI,4BAAiB,CAClD,qBAAqB,CAAC,IAAI,EAC1B,qBAAqB,EACrB,CAAC,uBAAa,CAAC,UAAU,EAAE,CAAC,EAC5B,EAAE,CACL,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nimport { DataObject, DataObjectFactory, IDataObjectProps } from \"@fluidframework/aqueduct\";\nimport { SharedCounter } from \"@fluidframework/counter\";\nimport { IFluidHandle } from \"@fluidframework/core-interfaces\";\n\nexport class TestDataObject extends DataObject {\n public static get Name(): string {\n return \"@fluid-example/test-data-object\";\n }\n\n public static readonly factory = new DataObjectFactory(\n TestDataObject.Name,\n TestDataObject,\n [],\n {},\n );\n\n constructor(props: IDataObjectProps) {\n super(props);\n }\n}\n\nexport class CounterTestDataObject extends DataObject {\n private _counter: SharedCounter | undefined;\n\n /**\n * Do setup work here\n */\n protected async initializingFirstTime(): Promise<void> {\n const counter = SharedCounter.create(this.runtime);\n this.root.set(\"counter-key\", counter.handle);\n }\n\n protected async hasInitialized(): Promise<void> {\n const counterHandle = this.root.get<IFluidHandle<SharedCounter>>(\"counter-key\");\n this._counter = await counterHandle?.get();\n }\n\n public static get Name(): string {\n return \"@fluid-example/counter-test-data-object\";\n }\n\n public static readonly factory = new DataObjectFactory(\n CounterTestDataObject.Name,\n CounterTestDataObject,\n [SharedCounter.getFactory()],\n {},\n );\n\n public increment(): void {\n this.counter.increment(1);\n }\n\n public get value(): number {\n return this.counter.value;\n }\n\n private get counter(): SharedCounter {\n if (this._counter === undefined) {\n throw new Error(\"SharedCounter not initialized\");\n }\n return this._counter;\n }\n}\n"]}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/*!
|
|
4
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
5
|
+
* Licensed under the MIT License.
|
|
6
|
+
*/
|
|
7
|
+
const assert_1 = require("assert");
|
|
8
|
+
const container_definitions_1 = require("@fluidframework/container-definitions");
|
|
9
|
+
const map_1 = require("@fluidframework/map");
|
|
10
|
+
const test_utils_1 = require("@fluidframework/test-utils");
|
|
11
|
+
const AzureClientFactory_1 = require("./AzureClientFactory");
|
|
12
|
+
const utils_1 = require("./utils");
|
|
13
|
+
describe("Fluid audience", () => {
|
|
14
|
+
const connectTimeoutMs = 1000;
|
|
15
|
+
let client;
|
|
16
|
+
let schema;
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
client = (0, AzureClientFactory_1.createAzureClient)("test-user-id-1", "test-user-name-1");
|
|
19
|
+
schema = {
|
|
20
|
+
initialObjects: {
|
|
21
|
+
map1: map_1.SharedMap,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* Scenario: Find original member/self
|
|
27
|
+
*
|
|
28
|
+
* Expected behavior: container should have a single member upon creation.
|
|
29
|
+
*/
|
|
30
|
+
it("can find original member", async () => {
|
|
31
|
+
const { container, services } = await client.createContainer(schema);
|
|
32
|
+
const containerId = await container.attach();
|
|
33
|
+
await (0, test_utils_1.timeoutPromise)((resolve) => container.once("connected", () => resolve()), {
|
|
34
|
+
durationMs: connectTimeoutMs,
|
|
35
|
+
errorMsg: "container connect() timeout",
|
|
36
|
+
});
|
|
37
|
+
assert_1.strict.strictEqual(typeof containerId, "string", "Attach did not return a string ID");
|
|
38
|
+
assert_1.strict.strictEqual(container.attachState, container_definitions_1.AttachState.Attached, "Container is not attached after attach is called");
|
|
39
|
+
/* This is a workaround for a known bug, we should have one member (self) upon container connection */
|
|
40
|
+
const myself = await (0, utils_1.waitForMember)(services.audience, "test-user-id-1");
|
|
41
|
+
assert_1.strict.notStrictEqual(myself, undefined, "We should have myself at this point.");
|
|
42
|
+
const members = services.audience.getMembers();
|
|
43
|
+
assert_1.strict.strictEqual(members.size, 1, "We should have only one member at this point.");
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* Scenario: Find partner member
|
|
47
|
+
*
|
|
48
|
+
* Expected behavior: upon resolving container, the partner member should be able
|
|
49
|
+
* to resolve original member.
|
|
50
|
+
*/
|
|
51
|
+
it("can find partner member", async () => {
|
|
52
|
+
const { container, services } = await client.createContainer(schema);
|
|
53
|
+
const containerId = await container.attach();
|
|
54
|
+
await (0, test_utils_1.timeoutPromise)((resolve) => container.once("connected", () => resolve()), {
|
|
55
|
+
durationMs: connectTimeoutMs,
|
|
56
|
+
errorMsg: "container connect() timeout",
|
|
57
|
+
});
|
|
58
|
+
assert_1.strict.strictEqual(typeof containerId, "string", "Attach did not return a string ID");
|
|
59
|
+
assert_1.strict.strictEqual(container.attachState, container_definitions_1.AttachState.Attached, "Container is not attached after attach is called");
|
|
60
|
+
/* This is a workaround for a known bug, we should have one member (self) upon container connection */
|
|
61
|
+
const originalSelf = await (0, utils_1.waitForMember)(services.audience, "test-user-id-1");
|
|
62
|
+
assert_1.strict.notStrictEqual(originalSelf, undefined, "We should have myself at this point.");
|
|
63
|
+
const client2 = (0, AzureClientFactory_1.createAzureClient)("test-user-id-2", "test-user-name-2");
|
|
64
|
+
const { services: servicesGet } = await client2.getContainer(containerId, schema);
|
|
65
|
+
/* This is a workaround for a known bug, we should have one member (self) upon container connection */
|
|
66
|
+
const partner = await (0, utils_1.waitForMember)(servicesGet.audience, "test-user-id-2");
|
|
67
|
+
assert_1.strict.notStrictEqual(partner, undefined, "We should have partner at this point.");
|
|
68
|
+
const members = servicesGet.audience.getMembers();
|
|
69
|
+
assert_1.strict.strictEqual(members.size, 2, "We should have two members at this point.");
|
|
70
|
+
assert_1.strict.notStrictEqual(partner === null || partner === void 0 ? void 0 : partner.userId, originalSelf === null || originalSelf === void 0 ? void 0 : originalSelf.userId, "Self and partner should have different IDs");
|
|
71
|
+
});
|
|
72
|
+
/**
|
|
73
|
+
* Scenario: Partner should be able to observe change in audience
|
|
74
|
+
*
|
|
75
|
+
* Expected behavior: upon 1 partner leaving, other parther should observe
|
|
76
|
+
* memberRemoved event and have correct partner count.
|
|
77
|
+
*/
|
|
78
|
+
it("can observe member leaving", async () => {
|
|
79
|
+
const { container } = await client.createContainer(schema);
|
|
80
|
+
const containerId = await container.attach();
|
|
81
|
+
await (0, test_utils_1.timeoutPromise)((resolve) => container.once("connected", () => resolve()), {
|
|
82
|
+
durationMs: connectTimeoutMs,
|
|
83
|
+
errorMsg: "container connect() timeout",
|
|
84
|
+
});
|
|
85
|
+
const client2 = (0, AzureClientFactory_1.createAzureClient)("test-user-id-2", "test-user-name-2");
|
|
86
|
+
const { services: servicesGet } = await client2.getContainer(containerId, schema);
|
|
87
|
+
/* This is a workaround for a known bug, we should have one member (self) upon container connection */
|
|
88
|
+
const partner = await (0, utils_1.waitForMember)(servicesGet.audience, "test-user-id-2");
|
|
89
|
+
assert_1.strict.notStrictEqual(partner, undefined, "We should have partner at this point.");
|
|
90
|
+
let members = servicesGet.audience.getMembers();
|
|
91
|
+
assert_1.strict.strictEqual(members.size, 2, "We should have two members at this point.");
|
|
92
|
+
container.disconnect();
|
|
93
|
+
await new Promise((resolve) => {
|
|
94
|
+
servicesGet.audience.on("memberRemoved", () => {
|
|
95
|
+
resolve();
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
members = servicesGet.audience.getMembers();
|
|
99
|
+
assert_1.strict.strictEqual(members.size, 1, "We should have one member left at this point.");
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
//# sourceMappingURL=audience.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audience.spec.js","sourceRoot":"","sources":["../../src/test/audience.spec.ts"],"names":[],"mappings":";;AAAA;;;GAGG;AACH,mCAA0C;AAG1C,iFAAoE;AAEpE,6CAAgD;AAChD,2DAA4D;AAE5D,6DAAyD;AACzD,mCAAwC;AAExC,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC5B,MAAM,gBAAgB,GA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AAE,CAAC,EAAE,2CAA2C,CAAC,CAAC;QAEjF,SAAS,CAAC,UAAU,EAAE,CAAC;QAEvB,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;YAChC,WAAW,CAAC,QAAQ,CAAC,EAAE,CAAC,eAAe,EAAE,GAAG,EAAE;gBAC1C,OAAO,EAAE,CAAC;YACd,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,WAAW,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;QAC5C,eAAM,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,EAAE,+CAA+C,CAAC,CAAC;IACzF,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { strict as assert } from \"assert\";\n\nimport { AzureClient } from \"@fluidframework/azure-client\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { ContainerSchema } from \"@fluidframework/fluid-static\";\nimport { SharedMap } from \"@fluidframework/map\";\nimport { timeoutPromise } from \"@fluidframework/test-utils\";\n\nimport { createAzureClient } from \"./AzureClientFactory\";\nimport { waitForMember } from \"./utils\";\n\ndescribe(\"Fluid audience\", () => {\n const connectTimeoutMs = 1000;\n let client: AzureClient;\n let schema: ContainerSchema;\n\n beforeEach(() => {\n client = createAzureClient(\"test-user-id-1\", \"test-user-name-1\");\n schema = {\n initialObjects: {\n map1: SharedMap,\n },\n };\n });\n\n /**\n * Scenario: Find original member/self\n *\n * Expected behavior: container should have a single member upon creation.\n */\n it(\"can find original member\", async () => {\n const { container, services } = await client.createContainer(schema);\n const containerId = await container.attach();\n\n await timeoutPromise((resolve) => container.once(\"connected\", () => resolve()), {\n durationMs: connectTimeoutMs,\n errorMsg: \"container connect() timeout\",\n });\n\n assert.strictEqual(typeof containerId, \"string\", \"Attach did not return a string ID\");\n assert.strictEqual(\n container.attachState,\n AttachState.Attached,\n \"Container is not attached after attach is called\",\n );\n\n /* This is a workaround for a known bug, we should have one member (self) upon container connection */\n const myself = await waitForMember(services.audience, \"test-user-id-1\");\n assert.notStrictEqual(myself, undefined, \"We should have myself at this point.\");\n\n const members = services.audience.getMembers();\n assert.strictEqual(members.size, 1, \"We should have only one member at this point.\");\n });\n\n /**\n * Scenario: Find partner member\n *\n * Expected behavior: upon resolving container, the partner member should be able\n * to resolve original member.\n */\n it(\"can find partner member\", async () => {\n const { container, services } = await client.createContainer(schema);\n const containerId = await container.attach();\n\n await timeoutPromise((resolve) => container.once(\"connected\", () => resolve()), {\n durationMs: connectTimeoutMs,\n errorMsg: \"container connect() timeout\",\n });\n\n assert.strictEqual(typeof containerId, \"string\", \"Attach did not return a string ID\");\n assert.strictEqual(\n container.attachState,\n AttachState.Attached,\n \"Container is not attached after attach is called\",\n );\n\n /* This is a workaround for a known bug, we should have one member (self) upon container connection */\n const originalSelf = await waitForMember(services.audience, \"test-user-id-1\");\n assert.notStrictEqual(originalSelf, undefined, \"We should have myself at this point.\");\n\n const client2 = createAzureClient(\"test-user-id-2\", \"test-user-name-2\");\n const { services: servicesGet } = await client2.getContainer(containerId, schema);\n\n /* This is a workaround for a known bug, we should have one member (self) upon container connection */\n const partner = await waitForMember(servicesGet.audience, \"test-user-id-2\");\n assert.notStrictEqual(partner, undefined, \"We should have partner at this point.\");\n\n const members = servicesGet.audience.getMembers();\n assert.strictEqual(members.size, 2, \"We should have two members at this point.\");\n\n assert.notStrictEqual(\n partner?.userId,\n originalSelf?.userId,\n \"Self and partner should have different IDs\",\n );\n });\n\n /**\n * Scenario: Partner should be able to observe change in audience\n *\n * Expected behavior: upon 1 partner leaving, other parther should observe\n * memberRemoved event and have correct partner count.\n */\n it(\"can observe member leaving\", async () => {\n const { container } = await client.createContainer(schema);\n const containerId = await container.attach();\n\n await timeoutPromise((resolve) => container.once(\"connected\", () => resolve()), {\n durationMs: connectTimeoutMs,\n errorMsg: \"container connect() timeout\",\n });\n\n const client2 = createAzureClient(\"test-user-id-2\", \"test-user-name-2\");\n const { services: servicesGet } = await client2.getContainer(containerId, schema);\n\n /* This is a workaround for a known bug, we should have one member (self) upon container connection */\n const partner = await waitForMember(servicesGet.audience, \"test-user-id-2\");\n assert.notStrictEqual(partner, undefined, \"We should have partner at this point.\");\n\n let members = servicesGet.audience.getMembers();\n assert.strictEqual(members.size, 2, \"We should have two members at this point.\");\n\n container.disconnect();\n\n await new Promise<void>((resolve) => {\n servicesGet.audience.on(\"memberRemoved\", () => {\n resolve();\n });\n });\n\n members = servicesGet.audience.getMembers();\n assert.strictEqual(members.size, 1, \"We should have one member left at this point.\");\n });\n});\n"]}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/*!
|
|
4
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
5
|
+
* Licensed under the MIT License.
|
|
6
|
+
*/
|
|
7
|
+
const assert_1 = require("assert");
|
|
8
|
+
const container_definitions_1 = require("@fluidframework/container-definitions");
|
|
9
|
+
const map_1 = require("@fluidframework/map");
|
|
10
|
+
const test_utils_1 = require("@fluidframework/test-utils");
|
|
11
|
+
const AzureClientFactory_1 = require("./AzureClientFactory");
|
|
12
|
+
const utils_1 = require("./utils");
|
|
13
|
+
describe("Container copy scenarios", () => {
|
|
14
|
+
const connectTimeoutMs = 1000;
|
|
15
|
+
let client;
|
|
16
|
+
let schema;
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
client = (0, AzureClientFactory_1.createAzureClient)();
|
|
19
|
+
schema = {
|
|
20
|
+
initialObjects: {
|
|
21
|
+
map1: map_1.SharedMap,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
beforeEach(async function () {
|
|
26
|
+
if (process.env.FLUID_CLIENT !== "azure") {
|
|
27
|
+
this.skip();
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Scenario: test if Azure Client can provide versions of the container.
|
|
32
|
+
*
|
|
33
|
+
* Expected behavior: an error should not be thrown nor should a rejected promise
|
|
34
|
+
* be returned. Upon creation, we should recieve back 1 version of the container.
|
|
35
|
+
*/
|
|
36
|
+
it("can get versions of current document", async () => {
|
|
37
|
+
const { container } = await client.createContainer(schema);
|
|
38
|
+
const containerId = await container.attach();
|
|
39
|
+
await (0, test_utils_1.timeoutPromise)((resolve) => container.once("connected", () => resolve()), {
|
|
40
|
+
durationMs: connectTimeoutMs,
|
|
41
|
+
errorMsg: "container connect() timeout",
|
|
42
|
+
});
|
|
43
|
+
const resources = client.getContainerVersions(containerId);
|
|
44
|
+
await assert_1.strict.doesNotReject(resources, () => true, "could not get versions of the container");
|
|
45
|
+
const versions = await resources;
|
|
46
|
+
assert_1.strict.strictEqual(versions.length, 1, "Container should have exactly one version.");
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* Scenario: test if Azure Client can handle bad version ID when versions are requested.
|
|
50
|
+
*
|
|
51
|
+
* Expected behavior: Client should throw an error.
|
|
52
|
+
*/
|
|
53
|
+
it("can handle bad versions of current document", async () => {
|
|
54
|
+
const resources = client.getContainerVersions("badid");
|
|
55
|
+
await assert_1.strict.rejects(resources, () => true, "We should not be able to get container versions.");
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* Scenario: test if Azure Client can copy existing container.
|
|
59
|
+
*
|
|
60
|
+
* Expected behavior: an error should not be thrown nor should a rejected promise
|
|
61
|
+
* be returned.
|
|
62
|
+
*/
|
|
63
|
+
it("can copy document successfully", async () => {
|
|
64
|
+
const { container } = await client.createContainer(schema);
|
|
65
|
+
const containerId = await container.attach();
|
|
66
|
+
await (0, test_utils_1.timeoutPromise)((resolve) => container.once("connected", () => resolve()), {
|
|
67
|
+
durationMs: connectTimeoutMs,
|
|
68
|
+
errorMsg: "container connect() timeout",
|
|
69
|
+
});
|
|
70
|
+
const resources = client.copyContainer(containerId, schema);
|
|
71
|
+
await assert_1.strict.doesNotReject(resources, () => true, "container could not be copied");
|
|
72
|
+
const { container: containerCopy } = await resources;
|
|
73
|
+
const newContainerId = await containerCopy.attach();
|
|
74
|
+
await (0, test_utils_1.timeoutPromise)((resolve) => containerCopy.once("connected", () => resolve()), {
|
|
75
|
+
durationMs: connectTimeoutMs,
|
|
76
|
+
errorMsg: "container connect() timeout",
|
|
77
|
+
});
|
|
78
|
+
assert_1.strict.strictEqual(typeof newContainerId, "string", "Attach did not return a string ID");
|
|
79
|
+
assert_1.strict.strictEqual(containerCopy.attachState, container_definitions_1.AttachState.Attached, "Container is not attached after attach is called");
|
|
80
|
+
});
|
|
81
|
+
/**
|
|
82
|
+
* Scenario: test if Azure Client can copy existing container at specific version.
|
|
83
|
+
*
|
|
84
|
+
* Expected behavior: an error should not be thrown nor should a rejected promise
|
|
85
|
+
* be returned.
|
|
86
|
+
*/
|
|
87
|
+
it("can sucesfully copy document from a specific version", async () => {
|
|
88
|
+
const { container } = await client.createContainer(schema);
|
|
89
|
+
const containerId = await container.attach();
|
|
90
|
+
await (0, test_utils_1.timeoutPromise)((resolve) => container.once("connected", () => resolve()), {
|
|
91
|
+
durationMs: connectTimeoutMs,
|
|
92
|
+
errorMsg: "container connect() timeout",
|
|
93
|
+
});
|
|
94
|
+
const versions = await client.getContainerVersions(containerId);
|
|
95
|
+
assert_1.strict.strictEqual(versions.length, 1, "Container should have exactly one version.");
|
|
96
|
+
const resources = client.copyContainer(containerId, schema, versions[0]);
|
|
97
|
+
await assert_1.strict.doesNotReject(resources, () => true, "container could not be copied");
|
|
98
|
+
const { container: containerCopy } = await resources;
|
|
99
|
+
const newContainerId = await containerCopy.attach();
|
|
100
|
+
await (0, test_utils_1.timeoutPromise)((resolve) => containerCopy.once("connected", () => resolve()), {
|
|
101
|
+
durationMs: connectTimeoutMs,
|
|
102
|
+
errorMsg: "container connect() timeout",
|
|
103
|
+
});
|
|
104
|
+
assert_1.strict.strictEqual(typeof newContainerId, "string", "Attach did not return a string ID");
|
|
105
|
+
assert_1.strict.strictEqual(containerCopy.attachState, container_definitions_1.AttachState.Attached, "Container is not attached after attach is called");
|
|
106
|
+
});
|
|
107
|
+
/**
|
|
108
|
+
* Scenario: test if Azure Client properly handles DDS objects when
|
|
109
|
+
* copying existing container.
|
|
110
|
+
*
|
|
111
|
+
* Expected behavior: DDS values should match across original and copied
|
|
112
|
+
* container.
|
|
113
|
+
*/
|
|
114
|
+
it("correctly copies DDS values when copying container", async () => {
|
|
115
|
+
const { container } = await client.createContainer(schema);
|
|
116
|
+
const initialObjectsCreate = container.initialObjects;
|
|
117
|
+
const map1Create = initialObjectsCreate.map1;
|
|
118
|
+
map1Create.set("new-key", "new-value");
|
|
119
|
+
const valueCreate = map1Create.get("new-key");
|
|
120
|
+
const containerId = await container.attach();
|
|
121
|
+
await (0, test_utils_1.timeoutPromise)((resolve) => container.once("connected", () => resolve()), {
|
|
122
|
+
durationMs: connectTimeoutMs,
|
|
123
|
+
errorMsg: "container connect() timeout",
|
|
124
|
+
});
|
|
125
|
+
const resources = client.copyContainer(containerId, schema);
|
|
126
|
+
await assert_1.strict.doesNotReject(resources, () => true, "container could not be copied");
|
|
127
|
+
const { container: containerCopy } = await resources;
|
|
128
|
+
const map1Get = containerCopy.initialObjects.map1;
|
|
129
|
+
const valueGet = await (0, utils_1.mapWait)(map1Get, "new-key");
|
|
130
|
+
assert_1.strict.strictEqual(valueGet, valueCreate, "DDS value was not correctly copied.");
|
|
131
|
+
});
|
|
132
|
+
/**
|
|
133
|
+
* Scenario: test if Azure Client can handle non-existing container when trying to copy
|
|
134
|
+
*
|
|
135
|
+
* Expected behavior: client should throw an error.
|
|
136
|
+
*/
|
|
137
|
+
it("can handle non-existing container", async () => {
|
|
138
|
+
const resources = client.copyContainer("badidoncopy", schema);
|
|
139
|
+
await assert_1.strict.rejects(resources, () => true, "We should not be able to copy container.");
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
//# sourceMapp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CAAC,CAAC;QAC5D,MAAM,eAAM,CAAC,aAAa,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,+BAA+B,CAAC,CAAC;QAEnF,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,MAAM,SAAS,CAAC;QAErD,MAAM,OAAO,GAAG,aAAa,CAAC,cAAc,CAAC,IAAiB,CAAC;QAC/D,MAAM,QAAQ,GAAuB,MAAM,IAAA,eAAO,EAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QACvE,eAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,WAAW,EAAE,qCAAqC,CAAC,CAAC;IACrF,CAAC,CAAC,CAAC;IAEH;;;;OAIG;IACH,EAAE,CAAC,mCAAmC,EAAE,KAAK,IAAI,EAAE;QAC/C,MAAM,SAAS,GAAG,MAAM,CAAC,aAAa,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QAC9D,MAAM,eAAM,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,0CAA0C,CAAC,CAAC;IAC5F,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\nimport { strict as assert } from \"assert\";\nimport { AttachState } from \"@fluidframework/container-definitions\";\nimport { ContainerSchema } from \"@fluidframework/fluid-static\";\nimport { SharedMap } from \"@fluidframework/map\";\nimport { timeoutPromise } from \"@fluidframework/test-utils\";\nimport { AzureClient } from \"@fluidframework/azure-client\";\nimport { createAzureClient } from \"./AzureClientFactory\";\nimport { mapWait } from \"./utils\";\n\ndescribe(\"Container copy scenarios\", () => {\n const connectTimeoutMs = 1000;\n let client: AzureClient;\n let schema: ContainerSchema;\n\n beforeEach(() => {\n client = createAzureClient();\n schema = {\n initialObjects: {\n map1: SharedMap,\n },\n };\n });\n\n beforeEach(async function () {\n if (process.env.FLUID_CLIENT !== \"azure\") {\n this.skip();\n }\n });\n\n /**\n * Scenario: test if Azure Client can provide versions of the container.\n *\n * Expected behavior: an error should not be thrown nor should a rejected promise\n * be returned. Upon creation, we should recieve back 1 version of the container.\n */\n it(\"can get versions of current document\", async () => {\n const { container } = await client.createContainer(schema);\n const containerId = await container.attach();\n\n await timeoutPromise((resolve) => container.once(\"connected\", () => resolve()), {\n durationMs: connectTimeoutMs,\n errorMsg: \"container connect() timeout\",\n });\n const resources = client.getContainerVersions(containerId);\n await assert.doesNotReject(\n resources,\n () => true,\n \"could not get versions of the container\",\n );\n\n const versions = await resources;\n assert.strictEqual(versions.length, 1, \"Container should have exactly one version.\");\n });\n\n /**\n * Scenario: test if Azure Client can handle bad version ID when versions are requested.\n *\n * Expected behavior: Client should throw an error.\n */\n it(\"can handle bad versions of current document\", async () => {\n const resources = client.getContainerVersions(\"badid\");\n await assert.rejects(\n resources,\n () => true,\n \"We should not be able to get container versions.\",\n );\n });\n\n /**\n * Scenario: test if Azure Client can copy existing container.\n *\n * Expected behavior: an error should not be thrown nor should a rejected promise\n * be returned.\n */\n it(\"can copy document successfully\", async () => {\n const { container } = await client.createContainer(schema);\n const containerId = await container.attach();\n\n await timeoutPromise((resolve) => container.once(\"connected\", () => resolve()), {\n durationMs: connectTimeoutMs,\n errorMsg: \"container connect() timeout\",\n });\n const resources = client.copyContainer(containerId, schema);\n await assert.doesNotReject(resources, () => true, \"container could not be copied\");\n\n const { container: containerCopy } = await resources;\n\n const newContainerId = await containerCopy.attach();\n await timeoutPromise((resolve) => containerCopy.once(\"connected\", () => resolve()), {\n durationMs: connectTimeoutMs,\n errorMsg: \"container connect() timeout\",\n });\n\n assert.strictEqual(typeof newContainerId, \"string\", \"Attach did not return a string ID\");\n assert.strictEqual(\n containerCopy.attachState,\n AttachState.Attached,\n \"Container is not attached after attach is called\",\n );\n });\n\n /**\n * Scenario: test if Azure Client can copy existing container at specific version.\n *\n * Expected behavior: an error should not be thrown nor should a rejected promise\n * be returned.\n */\n it(\"can sucesfully copy document from a specific version\", async () => {\n const { container } = await client.createContainer(schema);\n const containerId = await container.attach();\n\n await timeoutPromise((resolve) => container.once(\"connected\", () => resolve()), {\n durationMs: connectTimeoutMs,\n errorMsg: \"container connect() timeout\",\n });\n\n const versions = await client.getContainerVersions(containerId);\n assert.strictEqual(versions.length, 1, \"Container should have exactly one version.\");\n\n const resources = client.copyContainer(containerId, schema, versions[0]);\n await assert.doesNotReject(resources, () => true, \"container could not be copied\");\n\n const { container: containerCopy } = await resources;\n\n const newContainerId = await containerCopy.attach();\n await timeoutPromise((resolve) => containerCopy.once(\"connected\", () => resolve()), {\n durationMs: connectTimeoutMs,\n errorMsg: \"container connect() timeout\",\n });\n\n assert.strictEqual(typeof newContainerId, \"string\", \"Attach did not return a string ID\");\n assert.strictEqual(\n containerCopy.attachState,\n AttachState.Attached,\n \"Container is not attached after attach is called\",\n );\n });\n\n /**\n * Scenario: test if Azure Client properly handles DDS objects when\n * copying existing container.\n *\n * Expected behavior: DDS values should match across original and copied\n * container.\n */\n it(\"correctly copies DDS values when copying container\", async () => {\n const { container } = await client.createContainer(schema);\n\n const initialObjectsCreate = container.initialObjects;\n const map1Create = initialObjectsCreate.map1 as SharedMap;\n map1Create.set(\"new-key\", \"new-value\");\n const valueCreate: string | undefined = map1Create.get(\"new-key\");\n\n const containerId = await container.attach();\n\n await timeoutPromise((resolve) => container.once(\"connected\", () => resolve()), {\n durationMs: connectTimeoutMs,\n errorMsg: \"container connect() timeout\",\n });\n\n const resources = client.copyContainer(containerId, schema);\n await assert.doesNotReject(resources, () => true, \"container could not be copied\");\n\n const { container: containerCopy } = await resources;\n\n const map1Get = containerCopy.initialObjects.map1 as SharedMap;\n const valueGet: string | undefined = await mapWait(map1Get, \"new-key\");\n assert.strictEqual(valueGet, valueCreate, \"DDS value was not correctly copied.\");\n });\n\n /**\n * Scenario: test if Azure Client can handle non-existing container when trying to copy\n *\n * Expected behavior: client should throw an error.\n */\n it(\"can handle non-existing container\", async () => {\n const resources = client.copyContainer(\"badidoncopy\", schema);\n await assert.rejects(resources, () => true, \"We should not be able to copy container.\");\n });\n});\n"]}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/*!
|
|
4
|
+
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
5
|
+
* Licensed under the MIT License.
|
|
6
|
+
*/
|
|
7
|
+
const assert_1 = require("assert");
|
|
8
|
+
const container_definitions_1 = require("@fluidframework/container-definitions");
|
|
9
|
+
const map_1 = require("@fluidframework/map");
|
|
10
|
+
const test_utils_1 = require("@fluidframework/test-utils");
|
|
11
|
+
const AzureClientFactory_1 = require("./AzureClientFactory");
|
|
12
|
+
describe("Container create scenarios", () => {
|
|
13
|
+
const connectTimeoutMs = 1000;
|
|
14
|
+
let client;
|
|
15
|
+
let schema;
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
client = (0, AzureClientFactory_1.createAzureClient)();
|
|
18
|
+
schema = {
|
|
19
|
+
initialObjects: {
|
|
20
|
+
map1: map_1.SharedMap,
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Scenario: test when Azure Client is instantiated correctly, it can create
|
|
26
|
+
* a container successfully.
|
|
27
|
+
*
|
|
28
|
+
* Expected behavior: an error should not be thrown nor should a rejected promise
|
|
29
|
+
* be returned.
|
|
30
|
+
*/
|
|
31
|
+
it("can create new Azure Fluid Relay container successfully", async () => {
|
|
32
|
+
const resourcesP = client.createContainer(schema);
|
|
33
|
+
await assert_1.strict.doesNotReject(resourcesP, () => true, "container cannot be created in Azure Fluid Relay");
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* Scenario: test when an Azure Client container is created,
|
|
37
|
+
* it is initially detached.
|
|
38
|
+
*
|
|
39
|
+
* Expected behavior: an error should not be thrown nor should a rejected promise
|
|
40
|
+
* be returned.
|
|
41
|
+
*/
|
|
42
|
+
it("Created container is detached", async () => {
|
|
43
|
+
const { container } = await client.createContainer(schema);
|
|
44
|
+
assert_1.strict.strictEqual(container.attachState, container_definitions_1.AttachState.Detached, "Container should be detached");
|
|
45
|
+
});
|
|
46
|
+
/**
|
|
47
|
+
* Scenario: Test attaching a container.
|
|
48
|
+
*
|
|
49
|
+
* Expected behavior: an error should not be thrown nor should a rejected promise
|
|
50
|
+
* be returned.
|
|
51
|
+
*/
|
|
52
|
+
it("can attach a container", async () => {
|
|
53
|
+
const { container } = await client.createContainer(schema);
|
|
54
|
+
const containerId = await container.attach();
|
|
55
|
+
await (0, test_utils_1.timeoutPromise)((resolve) => container.once("connected", () => resolve()), {
|
|
56
|
+
durationMs: connectTimeoutMs,
|
|
57
|
+
errorMsg: "container connect() timeout",
|
|
58
|
+
});
|
|
59
|
+
assert_1.strict.strictEqual(typeof containerId, "string", "Attach did not return a string ID");
|
|
60
|
+
assert_1.strict.strictEqual(container.attachState, container_definitions_1.AttachState.Attached, "Container is not attached after attach is called");
|
|
61
|
+
});
|
|
62
|
+
/**
|
|
63
|
+
* Scenario: Test if attaching a container twice fails.
|
|
64
|
+
*
|
|
65
|
+
* Expected behavior: an error should not be thrown nor should a rejected promise
|
|
66
|
+
* be returned.
|
|
67
|
+
*/
|
|
68
|
+
it("cannot attach a container twice", async () => {
|
|
69
|
+
const { container } = await client.createContainer(schema);
|
|
70
|
+
const containerId = await container.attach();
|
|
71
|
+
await (0, test_utils_1.timeoutPromise)((resolve) => container.once("connected", () => resolve()), {
|
|
72
|
+
durationMs: connectTimeoutMs,
|
|
73
|
+
errorMsg: "container connect() timeout",
|
|
74
|
+
});
|
|
75
|
+
assert_1.strict.strictEqual(typeof containerId, "string", "Attach did not return a string ID");
|
|
76
|
+
assert_1.strict.strictEqual(container.attachState, container_definitions_1.AttachState.Attached, "Container is attached after attach is called");
|
|
77
|
+
await assert_1.strict.rejects(container.attach(), () => true, "Container should not attach twice");
|
|
78
|
+
});
|
|
79
|
+
/**
|
|
80
|
+
* Scenario: test if Azure Client can get an existing container.
|
|
81
|
+
*
|
|
82
|
+
* Expected behavior: an error should not be thrown nor should a rejected promise
|
|
83
|
+
* be returned.
|
|
84
|
+
*/
|
|
85
|
+
it("can retrieve existing Azure Fluid Relay container successfully", async () => {
|
|
86
|
+
const { container: newContainer } = await client.createContainer(schema);
|
|
87
|
+
const containerId = await newContainer.attach();
|
|
88
|
+
await (0, test_utils_1.timeoutPromise)((resolve) => newContainer.once("connected", () => resolve()), {
|
|
89
|
+
durationMs: connectTimeoutMs,
|
|
90
|
+
errorMsg: "container connect() timeout",
|
|
91
|
+
});
|
|
92
|
+
const resources = client.getContainer(containerId, schema);
|
|
93
|
+
await assert_1.strict.doesNotReject(resources, () => true, "container cannot be retrieved from Azure Fluid Relay");
|
|
94
|
+
});
|
|
95
|
+
/**
|
|
96
|
+
* Scenario: test if Azure Client can get a non-exiting container.
|
|
97
|
+
*
|
|
98
|
+
* Expected behavior: an error should be thrown when trying to get a non-existent container.
|
|
99
|
+
*/
|
|
100
|
+
it("cannot load improperly created container (cannot load a non-existent container)", async () => {
|
|
101
|
+
const consoleErrorFn = console.error;
|
|
102
|
+
console.error = () => { };
|
|
103
|
+
const containerAndServicesP = client.getContainer("containerConfig", schema);
|
|
104
|
+
const errorFn = (error) => {
|
|
105
|
+
assert_1.strict.notStrictEqual(error.message, undefined, "Azure Client error is undefined");
|
|
106
|
+
return true;
|
|
107
|
+
};
|
|
108
|
+
await assert_1.strict.rejects(containerAndServicesP, errorFn, "Azure Client can load a non-existent container");
|
|
109
|
+
console.error = consoleErrorFn;
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
//# sourceMappingURL=containerCreate.spec.js.map
|