@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,202 +2,204 @@
|
|
|
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
|
+
|
|
7
|
+
import { AzureClient } from "@fluidframework/azure-client";
|
|
6
8
|
import { AttachState } from "@fluidframework/container-definitions";
|
|
7
9
|
import { ContainerSchema } from "@fluidframework/fluid-static";
|
|
8
10
|
import { SharedMap } from "@fluidframework/map";
|
|
9
11
|
import { timeoutPromise } from "@fluidframework/test-utils";
|
|
10
|
-
|
|
12
|
+
|
|
11
13
|
import { createAzureClient } from "./AzureClientFactory";
|
|
12
14
|
import { mapWait } from "./utils";
|
|
13
15
|
|
|
14
16
|
describe("Container copy scenarios", () => {
|
|
15
|
-
|
|
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
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
17
|
+
const connectTimeoutMs = 1000;
|
|
18
|
+
let client: AzureClient;
|
|
19
|
+
let schema: ContainerSchema;
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
client = createAzureClient();
|
|
23
|
+
schema = {
|
|
24
|
+
initialObjects: {
|
|
25
|
+
map1: SharedMap,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
beforeEach(async function () {
|
|
31
|
+
if (process.env.FLUID_CLIENT !== "azure") {
|
|
32
|
+
this.skip();
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Scenario: test if Azure Client can provide versions of the container.
|
|
38
|
+
*
|
|
39
|
+
* Expected behavior: an error should not be thrown nor should a rejected promise
|
|
40
|
+
* be returned. Upon creation, we should recieve back 1 version of the container.
|
|
41
|
+
*/
|
|
42
|
+
it("can get versions of current document", async () => {
|
|
43
|
+
const { container } = await client.createContainer(schema);
|
|
44
|
+
const containerId = await container.attach();
|
|
45
|
+
|
|
46
|
+
await timeoutPromise((resolve) => container.once("connected", () => resolve()), {
|
|
47
|
+
durationMs: connectTimeoutMs,
|
|
48
|
+
errorMsg: "container connect() timeout",
|
|
49
|
+
});
|
|
50
|
+
const resources = client.getContainerVersions(containerId);
|
|
51
|
+
await assert.doesNotReject(
|
|
52
|
+
resources,
|
|
53
|
+
() => true,
|
|
54
|
+
"could not get versions of the container",
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
const versions = await resources;
|
|
58
|
+
assert.strictEqual(versions.length, 1, "Container should have exactly one version.");
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Scenario: test if Azure Client can handle bad document ID when versions are requested.
|
|
63
|
+
*
|
|
64
|
+
* Expected behavior: Client should throw an error.
|
|
65
|
+
*/
|
|
66
|
+
it("can handle bad document id when requesting versions", async () => {
|
|
67
|
+
const resources = client.getContainerVersions("badid");
|
|
68
|
+
const errorFn = (error: Error): boolean => {
|
|
69
|
+
assert.notStrictEqual(error.message, undefined, "Azure Client error is undefined");
|
|
70
|
+
assert.strictEqual(
|
|
71
|
+
error.message,
|
|
72
|
+
"R11s fetch error: Document is deleted and cannot be accessed.",
|
|
73
|
+
`Unexpected error: ${error.message}`,
|
|
74
|
+
);
|
|
75
|
+
return true;
|
|
76
|
+
};
|
|
77
|
+
await assert.rejects(
|
|
78
|
+
resources,
|
|
79
|
+
errorFn,
|
|
80
|
+
"We should not be able to get container versions.",
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Scenario: test if Azure Client can copy existing container.
|
|
86
|
+
*
|
|
87
|
+
* Expected behavior: an error should not be thrown nor should a rejected promise
|
|
88
|
+
* be returned.
|
|
89
|
+
*/
|
|
90
|
+
it("can copy document successfully", async () => {
|
|
91
|
+
const { container } = await client.createContainer(schema);
|
|
92
|
+
const containerId = await container.attach();
|
|
93
|
+
|
|
94
|
+
await timeoutPromise((resolve) => container.once("connected", () => resolve()), {
|
|
95
|
+
durationMs: connectTimeoutMs,
|
|
96
|
+
errorMsg: "container connect() timeout",
|
|
97
|
+
});
|
|
98
|
+
const resources = client.copyContainer(containerId, schema);
|
|
99
|
+
await assert.doesNotReject(resources, () => true, "container could not be copied");
|
|
100
|
+
|
|
101
|
+
const { container: containerCopy } = await resources;
|
|
102
|
+
|
|
103
|
+
const newContainerId = await containerCopy.attach();
|
|
104
|
+
await timeoutPromise((resolve) => containerCopy.once("connected", () => resolve()), {
|
|
105
|
+
durationMs: connectTimeoutMs,
|
|
106
|
+
errorMsg: "container connect() timeout",
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
assert.strictEqual(typeof newContainerId, "string", "Attach did not return a string ID");
|
|
110
|
+
assert.strictEqual(
|
|
111
|
+
containerCopy.attachState,
|
|
112
|
+
AttachState.Attached,
|
|
113
|
+
"Container is not attached after attach is called",
|
|
114
|
+
);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Scenario: test if Azure Client can copy existing container at specific version.
|
|
119
|
+
*
|
|
120
|
+
* Expected behavior: an error should not be thrown nor should a rejected promise
|
|
121
|
+
* be returned.
|
|
122
|
+
*/
|
|
123
|
+
it.skip("TEST FAILING SO SKIPPED - can sucesfully copy document from a specific version", async () => {
|
|
124
|
+
const { container } = await client.createContainer(schema);
|
|
125
|
+
const containerId = await container.attach();
|
|
126
|
+
|
|
127
|
+
await timeoutPromise((resolve) => container.once("connected", () => resolve()), {
|
|
128
|
+
durationMs: connectTimeoutMs,
|
|
129
|
+
errorMsg: "container connect() timeout",
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
const versions = await client.getContainerVersions(containerId);
|
|
133
|
+
assert.strictEqual(versions.length, 1, "Container should have exactly one version.");
|
|
134
|
+
|
|
135
|
+
const resources = client.copyContainer(containerId, schema, versions[0]);
|
|
136
|
+
await assert.doesNotReject(resources, () => true, "container could not be copied");
|
|
137
|
+
|
|
138
|
+
const { container: containerCopy } = await resources;
|
|
139
|
+
|
|
140
|
+
const newContainerId = await containerCopy.attach();
|
|
141
|
+
await timeoutPromise((resolve) => containerCopy.once("connected", () => resolve()), {
|
|
142
|
+
durationMs: connectTimeoutMs,
|
|
143
|
+
errorMsg: "container connect() timeout",
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
assert.strictEqual(typeof newContainerId, "string", "Attach did not return a string ID");
|
|
147
|
+
assert.strictEqual(
|
|
148
|
+
containerCopy.attachState,
|
|
149
|
+
AttachState.Attached,
|
|
150
|
+
"Container is not attached after attach is called",
|
|
151
|
+
);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Scenario: test if Azure Client properly handles DDS objects when
|
|
156
|
+
* copying existing container.
|
|
157
|
+
*
|
|
158
|
+
* Expected behavior: DDS values should match across original and copied
|
|
159
|
+
* container.
|
|
160
|
+
*/
|
|
161
|
+
it("correctly copies DDS values when copying container", async () => {
|
|
162
|
+
const { container } = await client.createContainer(schema);
|
|
163
|
+
|
|
164
|
+
const initialObjectsCreate = container.initialObjects;
|
|
165
|
+
const map1Create = initialObjectsCreate.map1 as SharedMap;
|
|
166
|
+
map1Create.set("new-key", "new-value");
|
|
167
|
+
const valueCreate: string | undefined = map1Create.get("new-key");
|
|
168
|
+
|
|
169
|
+
const containerId = await container.attach();
|
|
170
|
+
|
|
171
|
+
await timeoutPromise((resolve) => container.once("connected", () => resolve()), {
|
|
172
|
+
durationMs: connectTimeoutMs,
|
|
173
|
+
errorMsg: "container connect() timeout",
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
const resources = client.copyContainer(containerId, schema);
|
|
177
|
+
await assert.doesNotReject(resources, () => true, "container could not be copied");
|
|
178
|
+
|
|
179
|
+
const { container: containerCopy } = await resources;
|
|
180
|
+
|
|
181
|
+
const map1Get = containerCopy.initialObjects.map1 as SharedMap;
|
|
182
|
+
const valueGet: string | undefined = await mapWait(map1Get, "new-key");
|
|
183
|
+
assert.strictEqual(valueGet, valueCreate, "DDS value was not correctly copied.");
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Scenario: test if Azure Client can handle non-existing container when trying to copy
|
|
188
|
+
*
|
|
189
|
+
* Expected behavior: client should throw an error.
|
|
190
|
+
*/
|
|
191
|
+
it("can handle non-existing container", async () => {
|
|
192
|
+
const resources = client.copyContainer("badidoncopy", schema);
|
|
193
|
+
const errorFn = (error: Error): boolean => {
|
|
194
|
+
assert.notStrictEqual(error.message, undefined, "Azure Client error is undefined");
|
|
195
|
+
assert.strictEqual(
|
|
196
|
+
error.message,
|
|
197
|
+
"R11s fetch error: Document is deleted and cannot be accessed.",
|
|
198
|
+
`Unexpected error: ${error.message}`,
|
|
199
|
+
);
|
|
200
|
+
return true;
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
await assert.rejects(resources, errorFn, "We should not be able to copy container.");
|
|
204
|
+
});
|
|
203
205
|
});
|