1
- /*
2
1
import {
3
2
before ,
4
3
after ,
5
4
defaultCluster as servers ,
6
5
waitForConsistentState ,
7
- wait,
8
6
addNodeToDefaultCluster ,
9
7
} from "@cocalc/backend/conat/test/setup" ;
10
8
import { STICKY_QUEUE_GROUP } from "@cocalc/conat/core/client" ;
@@ -47,9 +45,6 @@ describe("ensure sticky state sync and use is working properly", () => {
47
45
) ;
48
46
// publishing causes a choice to be made and saved on servers[0]
49
47
await clients [ 0 ] . publish ( `subject.${ i } .foo` , "hello" ) ;
50
- expect(servers[0].sticky[`subject.${i}.*`]).not.toBe(undefined);
51
- // but no choice on servers[1]
52
- expect(servers[1].sticky[`subject.${i}.*`]).toBe(undefined);
53
48
}
54
49
} ) ;
55
50
@@ -66,51 +61,12 @@ describe("ensure sticky state sync and use is working properly", () => {
66
61
chosen = await Promise . race ( [ p0 ( ) , p1 ( ) ] ) ;
67
62
} ) ;
68
63
69
- it(`sticky on servers[0] should have ${count} entries starting in "subject".`, async () => {
70
- const v = Object.keys(servers[0].sticky).filter((s) =>
71
- s.startsWith("subject."),
72
- );
73
- expect(v.length).toBe(count);
74
- });
75
-
76
- it(`sticky on servers[1] should have no entries starting in "subject".`, async () => {
77
- const v = Object.keys(servers[1].sticky).filter((s) =>
78
- s.startsWith("subject."),
79
- );
80
- expect(v.length).toBe(0);
81
- });
82
-
83
- it(`servers[1]'s link to servers[0] should *eventually* have ${count} entries starting in "subject."`, async () => {
84
- // @ts -ignore
85
- const link = servers[1].clusterLinksByAddress[servers[0].address()];
86
- let v;
87
- await wait({
88
- until: () => {
89
- v = Object.keys(link.sticky).filter((s) => s.startsWith("subject."));
90
- return v.length == count;
91
- },
92
- });
93
- expect(v.length).toBe(count);
94
- });
95
-
96
64
it ( "send message from clients[1] to each subject" , async ( ) => {
97
65
for ( let i = 0 ; i < count ; i ++ ) {
98
66
await clients [ 1 ] . publish ( `subject.${ i } .foo` ) ;
99
67
}
100
68
} ) ;
101
69
102
- // Sometimes this fails under very heavy load.
103
- // It's not a good test, because it probably hits some timeouts sometimes, and
104
- // it is testing internal structure/optimizations, not behavior.
105
- // Note also that minimizing sticky state computation is just an optimization so even if this test were failing
106
- // due to a bug, it might just mean things are slightly slower.
107
- // it(`sticky on servers[1] should STILL have no entries starting in "subject", since no choices had to be made`, async () => {
108
- // const v = Object.keys(servers[1].sticky).filter((s) =>
109
- // s.startsWith("subject."),
110
- // );
111
- // expect(v.length).toBe(0);
112
- // });
113
-
114
70
async function deliveryTest ( ) {
115
71
const sub = chosen == 0 ? subs0 [ 0 ] : subs1 [ 0 ] ;
116
72
@@ -155,17 +111,6 @@ describe("ensure sticky state sync and use is working properly", () => {
155
111
await waitForConsistentState ( servers ) ;
156
112
} ) ;
157
113
158
- it("double check the links have the sticky state", () => {
159
- for (const server of servers.slice(1)) {
160
- // @ts -ignore
161
- const link = server.clusterLinksByAddress[servers[0].address()];
162
- const v = Object.keys(link.sticky).filter((s) =>
163
- s.startsWith("subject."),
164
- );
165
- expect(v.length).toBe(count);
166
- }
167
- });
168
-
169
114
it (
170
115
"in bigger, cluster, publish from every node to subject.0.foo" ,
171
116
deliveryTest ,
@@ -181,15 +126,6 @@ describe("ensure sticky state sync and use is working properly", () => {
181
126
}
182
127
sub . close ( ) ;
183
128
} ) ;
184
-
185
- it("unjoining servers[0] from servers[1] should transfer the sticky state to servers[1]", async () => {
186
- await servers[1].unjoin({ address: servers[0].address() });
187
- const v = Object.keys(servers[1].sticky).filter((s) =>
188
- s.startsWith("subject."),
189
- );
190
- expect(v.length).toBe(count);
191
- });
192
129
} ) ;
193
130
194
131
afterAll ( after ) ;
195
- */
0 commit comments