@@ -16,13 +16,15 @@ describe("create cluster of two nodes, and verify that *sticky* subs properly wo
16
16
( { server : server1 , client : client1 } = await createClusterNode ( {
17
17
clusterName : "cluster0" ,
18
18
id : "1" ,
19
- systemAccountPassword : "squeamish" ,
19
+ autoscanInterval : 100 ,
20
+ longAutoscanInterval : 1000 ,
20
21
} ) ) ;
21
22
client1b = server1 . client ( ) ;
22
23
( { server : server2 , client : client2 } = await createClusterNode ( {
23
24
clusterName : "cluster0" ,
24
25
id : "2" ,
25
- systemAccountPassword : "ossifrage" ,
26
+ autoscanInterval : 100 ,
27
+ longAutoscanInterval : 1000 ,
26
28
} ) ) ;
27
29
await server1 . join ( server2 . address ( ) ) ;
28
30
await server2 . join ( server1 . address ( ) ) ;
@@ -60,11 +62,11 @@ describe("create cluster of two nodes, and verify that *sticky* subs properly wo
60
62
61
63
it ( "send messages and note they all go to the same target -- next the hard case across the cluster" , async ( ) => {
62
64
// NOTE: if we do this test without waiting for consistent state, it will definitely
63
- // fail sometimes, since server2 literally doesn't know enough about the servers yet,
65
+ // fail sometimes, since server2 literally doesn't know enough about the servers yet,
64
66
// so has to make a different choice. Services of course must account for the fact that
65
67
// for the first moments of their existence, sticky routing can't work.
66
68
await waitForConsistentState ( [ server1 , server2 ] ) ;
67
-
69
+
68
70
await client2 . waitForInterest ( subject ) ;
69
71
for ( let i = 0 ; i < count ; i ++ ) {
70
72
await client2 . publish ( subject , "hi" ) ;
@@ -73,6 +75,45 @@ describe("create cluster of two nodes, and verify that *sticky* subs properly wo
73
75
expect ( recv1 + recv1b ) . toEqual ( 2 * count ) ;
74
76
expect ( recv1 * recv1b ) . toEqual ( 0 ) ;
75
77
} ) ;
78
+
79
+ let server3 , client3 ;
80
+ it ( "add a third node" , async ( ) => {
81
+ const { client, server } = await createClusterNode ( {
82
+ clusterName : "cluster0" ,
83
+ autoscanInterval : 100 ,
84
+ longAutoscanInterval : 5000 ,
85
+ id : "3" ,
86
+ } ) ;
87
+ server3 = server ;
88
+ client3 = client ;
89
+ await server1 . join ( server . address ( ) ) ;
90
+ } ) ;
91
+
92
+ it ( "waits for consistent state -- this verifies, e.g., that sticky state is equal" , async ( ) => {
93
+ await waitForConsistentState ( [ server1 , server2 , server3 ] ) ;
94
+ } ) ;
95
+
96
+ it ( "client connected to server3 also routes properly" , async ( ) => {
97
+ const total = recv1 + recv1b ;
98
+ await client3 . waitForInterest ( subject ) ;
99
+ for ( let i = 0 ; i < count ; i ++ ) {
100
+ await client3 . publish ( subject , "hi" ) ;
101
+ }
102
+ await wait ( { until : ( ) => recv1 + recv1b >= total + count } ) ;
103
+ expect ( recv1 + recv1b ) . toEqual ( total + count ) ;
104
+ expect ( recv1 * recv1b ) . toEqual ( 0 ) ;
105
+ } ) ;
106
+
107
+ it ( "client1 and client2 still route properly" , async ( ) => {
108
+ const total = recv1 + recv1b ;
109
+ for ( let i = 0 ; i < count ; i ++ ) {
110
+ await client1 . publish ( subject , "hi" ) ;
111
+ await client2 . publish ( subject , "hi" ) ;
112
+ }
113
+ await wait ( { until : ( ) => recv1 + recv1b >= total + 2 * count } ) ;
114
+ expect ( recv1 + recv1b ) . toEqual ( total + 2 * count ) ;
115
+ expect ( recv1 * recv1b ) . toEqual ( 0 ) ;
116
+ } ) ;
76
117
} ) ;
77
118
78
119
afterAll ( after ) ;
0 commit comments