@@ -14,38 +14,38 @@ import { FaultInjectorClient } from "./fault-injector-client";
14
14
import { MovingEndpointType } from "../../../dist/lib/client/enterprise-maintenance-manager" ;
15
15
import { RedisTcpSocketOptions } from "../../client/socket" ;
16
16
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 ) ;
36
34
} ) ;
35
+ } ) ;
37
36
38
- beforeEach ( ( ) => {
39
- log . length = 0 ;
40
- } ) ;
37
+ beforeEach ( ( ) => {
38
+ log . length = 0 ;
39
+ } ) ;
41
40
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
+ } ) ;
48
47
48
+ describe ( "Parameter Configuration" , ( ) => {
49
49
const endpoints : MovingEndpointType [ ] = [
50
50
"auto" ,
51
51
// "internal-ip",
@@ -56,12 +56,12 @@ describe("Parameter Configuration", () => {
56
56
] ;
57
57
58
58
for ( const endpointType of endpoints ) {
59
- it ( `should request \` ${ endpointType } \` movingEndpointType and receive it ` , async ( ) => {
59
+ it ( `clientHandshakeWithEndpointType ' ${ endpointType } ' ` , async ( ) => {
60
60
try {
61
61
client = await createTestClient ( clientConfig , {
62
62
maintMovingEndpointType : endpointType ,
63
63
} ) ;
64
- client . on ( ' error' , ( ) => { } )
64
+ client . on ( " error" , ( ) => { } ) ;
65
65
66
66
//need to copy those because they will be mutated later
67
67
const oldOptions = JSON . parse ( JSON . stringify ( client . options ) ) ;
@@ -138,8 +138,6 @@ describe("Parameter Configuration", () => {
138
138
}
139
139
}
140
140
} catch ( error : any ) {
141
- console . log ( 'endpointType' , endpointType ) ;
142
- console . log ( 'caught error' , error ) ;
143
141
if (
144
142
endpointType === "internal-fqdn" ||
145
143
endpointType === "internal-ip"
@@ -152,4 +150,52 @@ describe("Parameter Configuration", () => {
152
150
} ) ;
153
151
}
154
152
} ) ;
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
+ } ) ;
155
201
} ) ;
0 commit comments