@@ -5,38 +5,18 @@ pnpm test `pwd`/supercluster.test.ts
5
5
6
6
*/
7
7
8
- import {
9
- before ,
10
- after ,
11
- initConatServer ,
12
- once ,
13
- delay ,
14
- wait ,
15
- } from "@cocalc/backend/conat/test/setup" ;
8
+ import { before , after , delay , once , wait } from "@cocalc/backend/conat/test/setup" ;
16
9
import {
17
10
superclusterLink ,
18
11
superclusterStreams ,
19
12
superclusterService ,
20
13
trimSuperclusterStreams ,
21
14
} from "@cocalc/conat/core/supercluster" ;
22
15
import { isEqual } from "lodash" ;
23
- import { STICKY_QUEUE_GROUP } from "@cocalc/conat/core/client " ;
16
+ import { createCluster } from "./util " ;
24
17
25
18
beforeAll ( before ) ;
26
19
27
- let clusterName = 0 ;
28
- async function createCluster ( opts ?) {
29
- clusterName += 1 ;
30
- const server = await initConatServer ( {
31
- clusterName : `${ clusterName } ` ,
32
- id : "0" ,
33
- systemAccountPassword : "foo" ,
34
- ...opts ,
35
- } ) ;
36
- const client = server . client ( ) ;
37
- return { server, client } ;
38
- }
39
-
40
20
describe ( "create a supercluster enabled socketio server and test that the streams update as they should" , ( ) => {
41
21
let server , client ;
42
22
it ( "create a server with supercluster support enabled" , async ( ) => {
@@ -391,65 +371,4 @@ describe("test trimming the interest stream", () => {
391
371
} ) ;
392
372
} ) ;
393
373
394
- describe . only ( "create cluster of two nodes, and verify that *sticky* subs properly work" , ( ) => {
395
- let server1 , server2 , client1 , client1b , client2 ;
396
- it ( "create two distinct servers and link them" , async ( ) => {
397
- ( { server : server1 , client : client1 } = await createCluster ( {
398
- systemAccountPassword : "squeamish" ,
399
- } ) ) ;
400
- client1b = server1 . client ( ) ;
401
- ( { server : server2 , client : client2 } = await createCluster ( {
402
- systemAccountPassword : "ossifrage" ,
403
- } ) ) ;
404
- await server1 . addSuperclusterLink ( {
405
- client : client2 ,
406
- clusterName : server2 . clusterName ,
407
- } ) ;
408
- await server2 . addSuperclusterLink ( {
409
- client : client1 ,
410
- clusterName : server1 . clusterName ,
411
- } ) ;
412
- } ) ;
413
-
414
- let sub1 , sub1b ;
415
- let recv1 = 0 ,
416
- recv1b = 0 ;
417
- const subject = "5077.org" ;
418
- it ( "make two subscriptions with the same sticky queue group" , async ( ) => {
419
- sub1 = await client1 . sub ( subject , { queue : STICKY_QUEUE_GROUP } ) ;
420
- ( async ( ) => {
421
- for await ( const _ of sub1 ) {
422
- recv1 ++ ;
423
- }
424
- } ) ( ) ;
425
- sub1b = await client1b . sub ( subject , { queue : STICKY_QUEUE_GROUP } ) ;
426
- ( async ( ) => {
427
- for await ( const _ of sub1b ) {
428
- recv1b ++ ;
429
- }
430
- } ) ( ) ;
431
- } ) ;
432
-
433
- let count = 50 ;
434
- it ( "send messages and note they all go to the same target -- first the easy sanity check all on the same node" , async ( ) => {
435
- await client1 . waitForInterest ( subject ) ;
436
- for ( let i = 0 ; i < count ; i ++ ) {
437
- await client1 . publish ( subject , "hi" ) ;
438
- }
439
- await wait ( { until : ( ) => recv1 + recv1b >= count } ) ;
440
- expect ( recv1 + recv1b ) . toEqual ( count ) ;
441
- expect ( recv1 * recv1b ) . toEqual ( 0 ) ;
442
- } ) ;
443
-
444
- it ( "send messages and note they all go to the same target -- next the hard case across the cluster" , async ( ) => {
445
- await client2 . waitForInterest ( subject ) ;
446
- for ( let i = 0 ; i < count ; i ++ ) {
447
- await client2 . publish ( subject , "hi" ) ;
448
- }
449
- await wait ( { until : ( ) => recv1 + recv1b >= 2 * count } ) ;
450
- expect ( recv1 + recv1b ) . toEqual ( 2 * count ) ;
451
- expect ( recv1 * recv1b ) . toEqual ( 0 ) ;
452
- } ) ;
453
- } ) ;
454
-
455
374
afterAll ( after ) ;
0 commit comments