5
5
waitForConsistentState ,
6
6
wait ,
7
7
addNodeToDefaultCluster ,
8
+ delay ,
8
9
} from "@cocalc/backend/conat/test/setup" ;
9
10
import { STICKY_QUEUE_GROUP } from "@cocalc/conat/core/client" ;
10
11
@@ -19,7 +20,7 @@ describe("ensure sticky state sync and use is working properly", () => {
19
20
clients = servers . map ( ( x ) => x . client ( ) ) ;
20
21
} ) ;
21
22
22
- const count = 10 ;
23
+ const count = 1 ;
23
24
it ( `create ${ count } distinct sticky subscriptions and send one message to each to creat sticky routing state on servers[0]` , async ( ) => {
24
25
clients . push ( servers [ 0 ] . client ( ) ) ;
25
26
clients . push ( servers [ 1 ] . client ( ) ) ;
@@ -37,8 +38,11 @@ describe("ensure sticky state sync and use is working properly", () => {
37
38
await clients [ 0 ] . subscribe ( `subject.${ i } .*` , {
38
39
queue : STICKY_QUEUE_GROUP ,
39
40
} ) ;
40
- // cause choice to be made and saved on servers[0]
41
- await clients [ 0 ] . publish ( `subject.${ i } .foo` ) ;
41
+ // publishing causes a choice to be made and saved on servers[0]
42
+ await clients [ 0 ] . publish ( `subject.${ i } .foo` , "hello" ) ;
43
+ expect ( servers [ 0 ] . sticky [ `subject.${ i } .*` ] ) . not . toBe ( undefined ) ;
44
+ // but no choice on servers[1]
45
+ expect ( servers [ 1 ] . sticky [ `subject.${ i } .*` ] ) . toBe ( undefined ) ;
42
46
}
43
47
} ) ;
44
48
@@ -49,7 +53,7 @@ describe("ensure sticky state sync and use is working properly", () => {
49
53
expect ( v . length ) . toBe ( count ) ;
50
54
} ) ;
51
55
52
- it . skip ( `sticky on servers[1] should have no entries starting in "subject".` , async ( ) => {
56
+ it ( `sticky on servers[1] should have no entries starting in "subject".` , async ( ) => {
53
57
const v = Object . keys ( servers [ 1 ] . sticky ) . filter ( ( s ) =>
54
58
s . startsWith ( "subject." ) ,
55
59
) ;
@@ -72,7 +76,6 @@ describe("ensure sticky state sync and use is working properly", () => {
72
76
it ( "send message from clients[1] to each subject" , async ( ) => {
73
77
for ( let i = 0 ; i < count ; i ++ ) {
74
78
await clients [ 1 ] . publish ( `subject.${ i } .foo` ) ;
75
- console . log ( servers [ 1 ] . sticky ) ;
76
79
}
77
80
} ) ;
78
81
0 commit comments