@fluidframework/azure-end-to-end-tests 1.2.0-111554 → 1.2.0
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 +9 -13
- package/README.md +58 -0
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/test/AzureClientFactory.js +1 -1
- package/dist/test/AzureClientFactory.js.map +1 -1
- package/dist/test/AzureTokenFactory.js.map +1 -1
- package/dist/test/TestDataObject.js +2 -2
- package/dist/test/TestDataObject.js.map +1 -1
- package/dist/test/audience.spec.js +14 -14
- package/dist/test/audience.spec.js.map +1 -1
- package/dist/test/containerCopy.spec.js +19 -19
- package/dist/test/containerCopy.spec.js.map +1 -1
- package/dist/test/containerCreate.spec.js +13 -12
- package/dist/test/containerCreate.spec.js.map +1 -1
- package/dist/test/ddsTests.spec.js +19 -19
- package/dist/test/ddsTests.spec.js.map +1 -1
- package/dist/test/utils.js.map +1 -1
- package/package.json +99 -92
- package/src/packageVersion.ts +1 -1
- package/src/test/AzureClientFactory.ts +28 -28
- package/src/test/AzureTokenFactory.ts +16 -16
- package/src/test/TestDataObject.ts +46 -47
- package/src/test/audience.spec.ts +122 -122
- package/src/test/containerCopy.spec.ts +192 -190
- package/src/test/containerCreate.spec.ts +131 -131
- package/src/test/ddsTests.spec.ts +236 -234
- package/src/test/tsconfig.json +9 -15
- package/src/test/utils.ts +32 -32
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
import { strict as assert } from "assert";
|
|
5
|
+
import { strict as assert } from "node:assert";
|
|
6
6
|
|
|
7
7
|
import { AzureClient } from "@fluidframework/azure-client";
|
|
8
8
|
import { AttachState } from "@fluidframework/container-definitions";
|
|
@@ -13,134 +13,134 @@ import { timeoutPromise } from "@fluidframework/test-utils";
|
|
|
13
13
|
import { createAzureClient } from "./AzureClientFactory";
|
|
14
14
|
|
|
15
15
|
describe("Container create scenarios", () => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
16
|
+
const connectTimeoutMs = 1000;
|
|
17
|
+
let client: AzureClient;
|
|
18
|
+
let schema: ContainerSchema;
|
|
19
|
+
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
client = createAzureClient();
|
|
22
|
+
schema = {
|
|
23
|
+
initialObjects: {
|
|
24
|
+
map1: SharedMap,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Scenario: test when an Azure Client container is created,
|
|
31
|
+
* it is initially detached.
|
|
32
|
+
*
|
|
33
|
+
* Expected behavior: an error should not be thrown nor should a rejected promise
|
|
34
|
+
* be returned.
|
|
35
|
+
*/
|
|
36
|
+
it("Created container is detached", async () => {
|
|
37
|
+
const { container } = await client.createContainer(schema);
|
|
38
|
+
assert.strictEqual(
|
|
39
|
+
container.attachState,
|
|
40
|
+
AttachState.Detached,
|
|
41
|
+
"Container should be detached",
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
// Make sure we can attach.
|
|
45
|
+
const containerId = await container.attach();
|
|
46
|
+
assert.strictEqual(typeof containerId, "string", "Attach did not return a string ID");
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Scenario: Test attaching a container.
|
|
51
|
+
*
|
|
52
|
+
* Expected behavior: an error should not be thrown nor should a rejected promise
|
|
53
|
+
* be returned.
|
|
54
|
+
*/
|
|
55
|
+
it("can attach a container", async () => {
|
|
56
|
+
const { container } = await client.createContainer(schema);
|
|
57
|
+
const containerId = await container.attach();
|
|
58
|
+
|
|
59
|
+
await timeoutPromise((resolve) => container.once("connected", () => resolve()), {
|
|
60
|
+
durationMs: connectTimeoutMs,
|
|
61
|
+
errorMsg: "container connect() timeout",
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
assert.strictEqual(typeof containerId, "string", "Attach did not return a string ID");
|
|
65
|
+
assert.strictEqual(
|
|
66
|
+
container.attachState,
|
|
67
|
+
AttachState.Attached,
|
|
68
|
+
"Container is not attached after attach is called",
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Scenario: Test if attaching a container twice fails.
|
|
74
|
+
*
|
|
75
|
+
* Expected behavior: an error should not be thrown nor should a rejected promise
|
|
76
|
+
* be returned.
|
|
77
|
+
*/
|
|
78
|
+
it("cannot attach a container twice", async () => {
|
|
79
|
+
const { container } = await client.createContainer(schema);
|
|
80
|
+
const containerId = await container.attach();
|
|
81
|
+
|
|
82
|
+
await timeoutPromise((resolve) => container.once("connected", () => resolve()), {
|
|
83
|
+
durationMs: connectTimeoutMs,
|
|
84
|
+
errorMsg: "container connect() timeout",
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
assert.strictEqual(typeof containerId, "string", "Attach did not return a string ID");
|
|
88
|
+
assert.strictEqual(
|
|
89
|
+
container.attachState,
|
|
90
|
+
AttachState.Attached,
|
|
91
|
+
"Container is attached after attach is called",
|
|
92
|
+
);
|
|
93
|
+
await assert.rejects(container.attach(), () => true, "Container should not attach twice");
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Scenario: test if Azure Client can get an existing container.
|
|
98
|
+
*
|
|
99
|
+
* Expected behavior: an error should not be thrown nor should a rejected promise
|
|
100
|
+
* be returned.
|
|
101
|
+
*/
|
|
102
|
+
it("can retrieve existing Azure Fluid Relay container successfully", async () => {
|
|
103
|
+
const { container: newContainer } = await client.createContainer(schema);
|
|
104
|
+
const containerId = await newContainer.attach();
|
|
105
|
+
|
|
106
|
+
await timeoutPromise((resolve) => newContainer.once("connected", () => resolve()), {
|
|
107
|
+
durationMs: connectTimeoutMs,
|
|
108
|
+
errorMsg: "container connect() timeout",
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const resources = client.getContainer(containerId, schema);
|
|
112
|
+
await assert.doesNotReject(
|
|
113
|
+
resources,
|
|
114
|
+
() => true,
|
|
115
|
+
"container cannot be retrieved from Azure Fluid Relay",
|
|
116
|
+
);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Scenario: test if Azure Client can get a non-exiting container.
|
|
121
|
+
*
|
|
122
|
+
* Expected behavior: an error should be thrown when trying to get a non-existent container.
|
|
123
|
+
*/
|
|
124
|
+
it("cannot load improperly created container (cannot load a non-existent container)", async () => {
|
|
125
|
+
const consoleErrorFn = console.error;
|
|
126
|
+
console.error = (): void => {};
|
|
127
|
+
const containerAndServicesP = client.getContainer("containerConfig", schema);
|
|
128
|
+
|
|
129
|
+
const errorFn = (error: Error): boolean => {
|
|
130
|
+
assert.notStrictEqual(error.message, undefined, "Azure Client error is undefined");
|
|
131
|
+
assert.strict(
|
|
132
|
+
error.message.startsWith("R11s fetch error"),
|
|
133
|
+
`Unexpected error: ${error.message}`,
|
|
134
|
+
);
|
|
135
|
+
return true;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
await assert.rejects(
|
|
139
|
+
containerAndServicesP,
|
|
140
|
+
errorFn,
|
|
141
|
+
"Azure Client can load a non-existent container",
|
|
142
|
+
);
|
|
143
|
+
// eslint-disable-next-line require-atomic-updates
|
|
144
|
+
console.error = consoleErrorFn;
|
|
145
|
+
});
|
|
146
146
|
});
|