@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,67 +2,66 @@
|
|
|
2
2
|
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
5
|
import { DataObject, DataObjectFactory, IDataObjectProps } from "@fluidframework/aqueduct";
|
|
7
|
-
import { SharedCounter } from "@fluidframework/counter";
|
|
8
6
|
import { IFluidHandle } from "@fluidframework/core-interfaces";
|
|
7
|
+
import { SharedCounter } from "@fluidframework/counter";
|
|
9
8
|
|
|
10
9
|
export class TestDataObject extends DataObject {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
public static get Name(): string {
|
|
11
|
+
return "@fluid-example/test-data-object";
|
|
12
|
+
}
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
public static readonly factory = new DataObjectFactory(
|
|
15
|
+
TestDataObject.Name,
|
|
16
|
+
TestDataObject,
|
|
17
|
+
[],
|
|
18
|
+
{},
|
|
19
|
+
);
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
constructor(props: IDataObjectProps) {
|
|
22
|
+
super(props);
|
|
23
|
+
}
|
|
25
24
|
}
|
|
26
25
|
|
|
27
26
|
export class CounterTestDataObject extends DataObject {
|
|
28
|
-
|
|
27
|
+
private _counter: SharedCounter | undefined;
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Do setup work here
|
|
31
|
+
*/
|
|
32
|
+
protected async initializingFirstTime(): Promise<void> {
|
|
33
|
+
const counter = SharedCounter.create(this.runtime);
|
|
34
|
+
this.root.set("counter-key", counter.handle);
|
|
35
|
+
}
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
protected async hasInitialized(): Promise<void> {
|
|
38
|
+
const counterHandle = this.root.get<IFluidHandle<SharedCounter>>("counter-key");
|
|
39
|
+
this._counter = await counterHandle?.get();
|
|
40
|
+
}
|
|
42
41
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
public static get Name(): string {
|
|
43
|
+
return "@fluid-example/counter-test-data-object";
|
|
44
|
+
}
|
|
46
45
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
public static readonly factory = new DataObjectFactory(
|
|
47
|
+
CounterTestDataObject.Name,
|
|
48
|
+
CounterTestDataObject,
|
|
49
|
+
[SharedCounter.getFactory()],
|
|
50
|
+
{},
|
|
51
|
+
);
|
|
53
52
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
public increment(): void {
|
|
54
|
+
this.counter.increment(1);
|
|
55
|
+
}
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
public get value(): number {
|
|
58
|
+
return this.counter.value;
|
|
59
|
+
}
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
61
|
+
private get counter(): SharedCounter {
|
|
62
|
+
if (this._counter === undefined) {
|
|
63
|
+
throw new Error("SharedCounter not initialized");
|
|
64
|
+
}
|
|
65
|
+
return this._counter;
|
|
66
|
+
}
|
|
68
67
|
}
|
|
@@ -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";
|
|
@@ -14,125 +14,125 @@ import { createAzureClient } from "./AzureClientFactory";
|
|
|
14
14
|
import { waitForMember } from "./utils";
|
|
15
15
|
|
|
16
16
|
describe("Fluid audience", () => {
|
|
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
|
-
|
|
17
|
+
const connectTimeoutMs = 1000;
|
|
18
|
+
let client: AzureClient;
|
|
19
|
+
let schema: ContainerSchema;
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
client = createAzureClient("test-user-id-1", "test-user-name-1");
|
|
23
|
+
schema = {
|
|
24
|
+
initialObjects: {
|
|
25
|
+
map1: SharedMap,
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Scenario: Find original member/self
|
|
32
|
+
*
|
|
33
|
+
* Expected behavior: container should have a single member upon creation.
|
|
34
|
+
*/
|
|
35
|
+
it("can find original member", async () => {
|
|
36
|
+
const { container, services } = await client.createContainer(schema);
|
|
37
|
+
const containerId = await container.attach();
|
|
38
|
+
|
|
39
|
+
await timeoutPromise((resolve) => container.once("connected", () => resolve()), {
|
|
40
|
+
durationMs: connectTimeoutMs,
|
|
41
|
+
errorMsg: "container connect() timeout",
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
assert.strictEqual(typeof containerId, "string", "Attach did not return a string ID");
|
|
45
|
+
assert.strictEqual(
|
|
46
|
+
container.attachState,
|
|
47
|
+
AttachState.Attached,
|
|
48
|
+
"Container is not attached after attach is called",
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
/* This is a workaround for a known bug, we should have one member (self) upon container connection */
|
|
52
|
+
const myself = await waitForMember(services.audience, "test-user-id-1");
|
|
53
|
+
assert.notStrictEqual(myself, undefined, "We should have myself at this point.");
|
|
54
|
+
|
|
55
|
+
const members = services.audience.getMembers();
|
|
56
|
+
assert.strictEqual(members.size, 1, "We should have only one member at this point.");
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Scenario: Find partner member
|
|
61
|
+
*
|
|
62
|
+
* Expected behavior: upon resolving container, the partner member should be able
|
|
63
|
+
* to resolve original member.
|
|
64
|
+
*/
|
|
65
|
+
it("can find partner member", async () => {
|
|
66
|
+
const { container, services } = await client.createContainer(schema);
|
|
67
|
+
const containerId = await container.attach();
|
|
68
|
+
|
|
69
|
+
await timeoutPromise((resolve) => container.once("connected", () => resolve()), {
|
|
70
|
+
durationMs: connectTimeoutMs,
|
|
71
|
+
errorMsg: "container connect() timeout",
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
assert.strictEqual(typeof containerId, "string", "Attach did not return a string ID");
|
|
75
|
+
assert.strictEqual(
|
|
76
|
+
container.attachState,
|
|
77
|
+
AttachState.Attached,
|
|
78
|
+
"Container is not attached after attach is called",
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
/* This is a workaround for a known bug, we should have one member (self) upon container connection */
|
|
82
|
+
const originalSelf = await waitForMember(services.audience, "test-user-id-1");
|
|
83
|
+
assert.notStrictEqual(originalSelf, undefined, "We should have myself at this point.");
|
|
84
|
+
|
|
85
|
+
const client2 = createAzureClient("test-user-id-2", "test-user-name-2");
|
|
86
|
+
const { services: servicesGet } = await client2.getContainer(containerId, schema);
|
|
87
|
+
|
|
88
|
+
/* This is a workaround for a known bug, we should have one member (self) upon container connection */
|
|
89
|
+
const partner = await waitForMember(servicesGet.audience, "test-user-id-2");
|
|
90
|
+
assert.notStrictEqual(partner, undefined, "We should have partner at this point.");
|
|
91
|
+
|
|
92
|
+
const members = servicesGet.audience.getMembers();
|
|
93
|
+
assert.strictEqual(members.size, 2, "We should have two members at this point.");
|
|
94
|
+
|
|
95
|
+
assert.notStrictEqual(
|
|
96
|
+
partner?.userId,
|
|
97
|
+
originalSelf?.userId,
|
|
98
|
+
"Self and partner should have different IDs",
|
|
99
|
+
);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Scenario: Partner should be able to observe change in audience
|
|
104
|
+
*
|
|
105
|
+
* Expected behavior: upon 1 partner leaving, other parther should observe
|
|
106
|
+
* memberRemoved event and have correct partner count.
|
|
107
|
+
*/
|
|
108
|
+
it("can observe member leaving", async () => {
|
|
109
|
+
const { container } = await client.createContainer(schema);
|
|
110
|
+
const containerId = await container.attach();
|
|
111
|
+
|
|
112
|
+
await timeoutPromise((resolve) => container.once("connected", () => resolve()), {
|
|
113
|
+
durationMs: connectTimeoutMs,
|
|
114
|
+
errorMsg: "container connect() timeout",
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
const client2 = createAzureClient("test-user-id-2", "test-user-name-2");
|
|
118
|
+
const { services: servicesGet } = await client2.getContainer(containerId, schema);
|
|
119
|
+
|
|
120
|
+
/* This is a workaround for a known bug, we should have one member (self) upon container connection */
|
|
121
|
+
const partner = await waitForMember(servicesGet.audience, "test-user-id-2");
|
|
122
|
+
assert.notStrictEqual(partner, undefined, "We should have partner at this point.");
|
|
123
|
+
|
|
124
|
+
let members = servicesGet.audience.getMembers();
|
|
125
|
+
assert.strictEqual(members.size, 2, "We should have two members at this point.");
|
|
126
|
+
|
|
127
|
+
container.disconnect();
|
|
128
|
+
|
|
129
|
+
await new Promise<void>((resolve) => {
|
|
130
|
+
servicesGet.audience.on("memberRemoved", () => {
|
|
131
|
+
resolve();
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
members = servicesGet.audience.getMembers();
|
|
136
|
+
assert.strictEqual(members.size, 1, "We should have one member left at this point.");
|
|
137
|
+
});
|
|
138
138
|
});
|