@@ -14,38 +14,38 @@ import { FaultInjectorClient } from "./fault-injector-client";
1414import { MovingEndpointType } from "../../../dist/lib/client/enterprise-maintenance-manager" ;
1515import { RedisTcpSocketOptions } from "../../client/socket" ;
1616
17- describe ( "Parameter Configuration" , ( ) => {
18- describe ( "Handshake with endpoint type" , ( ) => {
19- let clientConfig : RedisConnectionConfig ;
20- let client : ReturnType < typeof createClient < any , any , any , any > > ;
21- let faultInjectorClient : FaultInjectorClient ;
22- let log : DiagnosticsEvent [ ] = [ ] ;
23-
24- before ( ( ) => {
25- const envConfig = getEnvConfig ( ) ;
26- const redisConfig = getDatabaseConfigFromEnv (
27- envConfig . redisEndpointsConfigPath ,
28- ) ;
29-
30- faultInjectorClient = new FaultInjectorClient ( envConfig . faultInjectorUrl ) ;
31- clientConfig = getDatabaseConfig ( redisConfig ) ;
32-
33- diagnostics_channel . subscribe ( "redis.maintenance" , ( event ) => {
34- log . push ( event as DiagnosticsEvent ) ;
35- } ) ;
17+ describe ( "Client Configuration and Handshake" , ( ) => {
18+ let clientConfig : RedisConnectionConfig ;
19+ let client : ReturnType < typeof createClient < any , any , any , any > > ;
20+ let faultInjectorClient : FaultInjectorClient ;
21+ let log : DiagnosticsEvent [ ] = [ ] ;
22+
23+ before ( ( ) => {
24+ const envConfig = getEnvConfig ( ) ;
25+ const redisConfig = getDatabaseConfigFromEnv (
26+ envConfig . redisEndpointsConfigPath ,
27+ ) ;
28+
29+ faultInjectorClient = new FaultInjectorClient ( envConfig . faultInjectorUrl ) ;
30+ clientConfig = getDatabaseConfig ( redisConfig ) ;
31+
32+ diagnostics_channel . subscribe ( "redis.maintenance" , ( event ) => {
33+ log . push ( event as DiagnosticsEvent ) ;
3634 } ) ;
35+ } ) ;
3736
38- beforeEach ( ( ) => {
39- log . length = 0 ;
40- } ) ;
37+ beforeEach ( ( ) => {
38+ log . length = 0 ;
39+ } ) ;
4140
42- afterEach ( async ( ) => {
43- if ( client && client . isOpen ) {
44- await client . flushAll ( ) ;
45- client . destroy ( ) ;
46- }
47- } ) ;
41+ afterEach ( async ( ) => {
42+ if ( client && client . isOpen ) {
43+ await client . flushAll ( ) ;
44+ client . destroy ( ) ;
45+ }
46+ } ) ;
4847
48+ describe ( "Parameter Configuration" , ( ) => {
4949 const endpoints : MovingEndpointType [ ] = [
5050 "auto" ,
5151 // "internal-ip",
@@ -56,12 +56,12 @@ describe("Parameter Configuration", () => {
5656 ] ;
5757
5858 for ( const endpointType of endpoints ) {
59- it ( `should request \` ${ endpointType } \` movingEndpointType and receive it ` , async ( ) => {
59+ it ( `clientHandshakeWithEndpointType ' ${ endpointType } ' ` , async ( ) => {
6060 try {
6161 client = await createTestClient ( clientConfig , {
6262 maintMovingEndpointType : endpointType ,
6363 } ) ;
64- client . on ( ' error' , ( ) => { } )
64+ client . on ( " error" , ( ) => { } ) ;
6565
6666 //need to copy those because they will be mutated later
6767 const oldOptions = JSON . parse ( JSON . stringify ( client . options ) ) ;
@@ -138,8 +138,6 @@ describe("Parameter Configuration", () => {
138138 }
139139 }
140140 } catch ( error : any ) {
141- console . log ( 'endpointType' , endpointType ) ;
142- console . log ( 'caught error' , error ) ;
143141 if (
144142 endpointType === "internal-fqdn" ||
145143 endpointType === "internal-ip"
@@ -152,4 +150,52 @@ describe("Parameter Configuration", () => {
152150 } ) ;
153151 }
154152 } ) ;
153+
154+ describe ( "Feature Enablement" , ( ) => {
155+ it ( "connectionHandshakeIncludesEnablingNotifications" , async ( ) => {
156+ client = await createTestClient ( clientConfig , {
157+ maintPushNotifications : "enabled" ,
158+ } ) ;
159+
160+ const { action_id } = await faultInjectorClient . migrateAndBindAction ( {
161+ bdbId : clientConfig . bdbId ,
162+ clusterIndex : 0 ,
163+ } ) ;
164+
165+ await faultInjectorClient . waitForAction ( action_id ) ;
166+
167+ let movingEvent = false ;
168+ let migratingEvent = false ;
169+ let migratedEvent = false ;
170+ for ( const event of log ) {
171+ if ( event . type === "MOVING" ) movingEvent = true ;
172+ if ( event . type === "MIGRATING" ) migratingEvent = true ;
173+ if ( event . type === "MIGRATED" ) migratedEvent = true ;
174+ }
175+ assert . ok ( movingEvent , "didnt receive MOVING PN" ) ;
176+ assert . ok ( migratingEvent , "didnt receive MIGRATING PN" ) ;
177+ assert . ok ( migratedEvent , "didnt receive MIGRATED PN" ) ;
178+ } ) ;
179+
180+ it ( "disabledDontReceiveNotifications" , async ( ) => {
181+ try {
182+ client = await createTestClient ( clientConfig , {
183+ maintPushNotifications : "disabled" ,
184+ socket : {
185+ reconnectStrategy : false
186+ }
187+ } ) ;
188+ client . on ( 'error' , console . log . bind ( console ) )
189+
190+ const { action_id } = await faultInjectorClient . migrateAndBindAction ( {
191+ bdbId : clientConfig . bdbId ,
192+ clusterIndex : 0 ,
193+ } ) ;
194+
195+ await faultInjectorClient . waitForAction ( action_id ) ;
196+
197+ assert . equal ( log . length , 0 , "received a PN while feature is disabled" ) ;
198+ } catch ( error : any ) { }
199+ } ) ;
200+ } ) ;
155201} ) ;
0 commit comments