@@ -1166,6 +1166,77 @@ func TestConnectionHandlerUpdateError(t *testing.T) {
1166
1166
require .Nilf (t , err , "failed to get ConnectedNow()" )
1167
1167
}
1168
1168
1169
+ type testDeactivatedErrorHandler struct {
1170
+ mut sync.Mutex
1171
+ deactivated []string
1172
+ }
1173
+
1174
+ func (h * testDeactivatedErrorHandler ) Discovered (name string , conn * tarantool.Connection ,
1175
+ role pool.Role ) error {
1176
+ return nil
1177
+ }
1178
+
1179
+ func (h * testDeactivatedErrorHandler ) Deactivated (name string , conn * tarantool.Connection ,
1180
+ role pool.Role ) error {
1181
+ h .mut .Lock ()
1182
+ defer h .mut .Unlock ()
1183
+
1184
+ h .deactivated = append (h .deactivated , name )
1185
+ return nil
1186
+ }
1187
+
1188
+ func TestConnectionHandlerDeactivated_on_remove (t * testing.T ) {
1189
+ poolServers := []string {servers [0 ], servers [1 ]}
1190
+ poolInstances := makeInstances (poolServers , connOpts )
1191
+ roles := []bool {false , false }
1192
+
1193
+ err := test_helpers .SetClusterRO (makeDialers (poolServers ), connOpts , roles )
1194
+ require .Nilf (t , err , "fail to set roles for cluster" )
1195
+
1196
+ h := & testDeactivatedErrorHandler {}
1197
+ poolOpts := pool.Opts {
1198
+ CheckTimeout : 100 * time .Microsecond ,
1199
+ ConnectionHandler : h ,
1200
+ }
1201
+ ctx , cancel := test_helpers .GetPoolConnectContext ()
1202
+ defer cancel ()
1203
+ connPool , err := pool .ConnectWithOpts (ctx , poolInstances , poolOpts )
1204
+ require .Nilf (t , err , "failed to connect" )
1205
+ require .NotNilf (t , connPool , "conn is nil after Connect" )
1206
+ defer connPool .Close ()
1207
+
1208
+ args := test_helpers.CheckStatusesArgs {
1209
+ ConnPool : connPool ,
1210
+ Mode : pool .ANY ,
1211
+ Servers : servers ,
1212
+ ExpectedPoolStatus : true ,
1213
+ ExpectedStatuses : map [string ]bool {
1214
+ servers [0 ]: true ,
1215
+ servers [1 ]: true ,
1216
+ },
1217
+ }
1218
+ err = test_helpers .CheckPoolStatuses (args )
1219
+ require .Nil (t , err )
1220
+
1221
+ for _ , server := range poolServers {
1222
+ connPool .Remove (server )
1223
+ connPool .Remove (server )
1224
+ }
1225
+
1226
+ args = test_helpers.CheckStatusesArgs {
1227
+ ConnPool : connPool ,
1228
+ Mode : pool .ANY ,
1229
+ Servers : servers ,
1230
+ ExpectedPoolStatus : false ,
1231
+ }
1232
+ err = test_helpers .CheckPoolStatuses (args )
1233
+ require .Nil (t , err )
1234
+
1235
+ h .mut .Lock ()
1236
+ defer h .mut .Unlock ()
1237
+ require .ElementsMatch (t , poolServers , h .deactivated )
1238
+ }
1239
+
1169
1240
func TestRequestOnClosed (t * testing.T ) {
1170
1241
server1 := servers [0 ]
1171
1242
server2 := servers [1 ]
0 commit comments