@@ -78,7 +78,7 @@ func testGracefulShutdown(t *testing.T, conn *Connection, inst *test_helpers.Tar
78
78
79
79
// SIGTERM the server.
80
80
shutdownStart := time .Now ()
81
- require .Nil (t , inst .Cmd . Process . Signal (syscall .SIGTERM ))
81
+ require .Nil (t , inst .Signal (syscall .SIGTERM ))
82
82
83
83
// Check that we can't send new requests after shutdown starts.
84
84
// Retry helps to wait a bit until server starts to shutdown
@@ -108,14 +108,11 @@ func testGracefulShutdown(t *testing.T, conn *Connection, inst *test_helpers.Tar
108
108
// Wait until server go down.
109
109
// Server will go down only when it process all requests from our connection
110
110
// (or on timeout).
111
- _ , err = inst . Cmd . Process .Wait ()
111
+ err = inst .Wait ()
112
112
require .Nil (t , err )
113
113
shutdownFinish := time .Now ()
114
114
shutdownTime := shutdownFinish .Sub (shutdownStart )
115
115
116
- // Help test helpers to properly clean up.
117
- inst .Cmd .Process = nil
118
-
119
116
// Check that it wasn't a timeout.
120
117
require .Lessf (t ,
121
118
shutdownTime ,
@@ -129,18 +126,16 @@ func testGracefulShutdown(t *testing.T, conn *Connection, inst *test_helpers.Tar
129
126
func TestGracefulShutdown (t * testing.T ) {
130
127
test_helpers .SkipIfWatchersUnsupported (t )
131
128
132
- var inst test_helpers.TarantoolInstance
133
129
var conn * Connection
134
- var err error
135
130
136
- inst , err = test_helpers .StartTarantool (shtdnSrvOpts )
131
+ inst , err : = test_helpers .StartTarantool (shtdnSrvOpts )
137
132
require .Nil (t , err )
138
133
defer test_helpers .StopTarantoolWithCleanup (inst )
139
134
140
135
conn = test_helpers .ConnectWithValidation (t , shtdnDialer , shtdnClntOpts )
141
136
defer conn .Close ()
142
137
143
- testGracefulShutdown (t , conn , & inst )
138
+ testGracefulShutdown (t , conn , inst )
144
139
}
145
140
146
141
func TestCloseGraceful (t * testing.T ) {
@@ -190,26 +185,23 @@ func TestCloseGraceful(t *testing.T) {
190
185
func TestGracefulShutdownWithReconnect (t * testing.T ) {
191
186
test_helpers .SkipIfWatchersUnsupported (t )
192
187
193
- var inst test_helpers.TarantoolInstance
194
- var err error
195
-
196
- inst , err = test_helpers .StartTarantool (shtdnSrvOpts )
188
+ inst , err := test_helpers .StartTarantool (shtdnSrvOpts )
197
189
require .Nil (t , err )
198
190
defer test_helpers .StopTarantoolWithCleanup (inst )
199
191
200
192
conn := test_helpers .ConnectWithValidation (t , shtdnDialer , shtdnClntOpts )
201
193
defer conn .Close ()
202
194
203
- testGracefulShutdown (t , conn , & inst )
195
+ testGracefulShutdown (t , conn , inst )
204
196
205
- err = test_helpers .RestartTarantool (& inst )
197
+ err = test_helpers .RestartTarantool (inst )
206
198
require .Nilf (t , err , "Failed to restart tarantool" )
207
199
208
200
connected := test_helpers .WaitUntilReconnected (conn , shtdnClntOpts .MaxReconnects ,
209
201
shtdnClntOpts .Reconnect )
210
202
require .Truef (t , connected , "Reconnect success" )
211
203
212
- testGracefulShutdown (t , conn , & inst )
204
+ testGracefulShutdown (t , conn , inst )
213
205
}
214
206
215
207
func TestNoGracefulShutdown (t * testing.T ) {
@@ -219,14 +211,12 @@ func TestNoGracefulShutdown(t *testing.T) {
219
211
noShtdDialer .RequiredProtocolInfo = ProtocolInfo {}
220
212
test_helpers .SkipIfWatchersSupported (t )
221
213
222
- var inst test_helpers.TarantoolInstance
223
214
var conn * Connection
224
- var err error
225
215
226
216
testSrvOpts := shtdnSrvOpts
227
217
testSrvOpts .Dialer = noShtdDialer
228
218
229
- inst , err = test_helpers .StartTarantool (testSrvOpts )
219
+ inst , err : = test_helpers .StartTarantool (testSrvOpts )
230
220
require .Nil (t , err )
231
221
defer test_helpers .StopTarantoolWithCleanup (inst )
232
222
@@ -249,21 +239,18 @@ func TestNoGracefulShutdown(t *testing.T) {
249
239
250
240
// SIGTERM the server.
251
241
shutdownStart := time .Now ()
252
- require .Nil (t , inst .Cmd . Process . Signal (syscall .SIGTERM ))
242
+ require .Nil (t , inst .Signal (syscall .SIGTERM ))
253
243
254
244
// Check that request was interrupted.
255
245
_ , err = fut .Get ()
256
246
require .NotNilf (t , err , "sleep request error" )
257
247
258
248
// Wait until server go down.
259
- _ , err = inst . Cmd . Process .Wait ()
249
+ err = inst .Wait ()
260
250
require .Nil (t , err )
261
251
shutdownFinish := time .Now ()
262
252
shutdownTime := shutdownFinish .Sub (shutdownStart )
263
253
264
- // Help test helpers to properly clean up.
265
- inst .Cmd .Process = nil
266
-
267
254
// Check that server finished without waiting for eval to finish.
268
255
require .Lessf (t ,
269
256
shutdownTime ,
@@ -274,11 +261,9 @@ func TestNoGracefulShutdown(t *testing.T) {
274
261
func TestGracefulShutdownRespectsClose (t * testing.T ) {
275
262
test_helpers .SkipIfWatchersUnsupported (t )
276
263
277
- var inst test_helpers.TarantoolInstance
278
264
var conn * Connection
279
- var err error
280
265
281
- inst , err = test_helpers .StartTarantool (shtdnSrvOpts )
266
+ inst , err : = test_helpers .StartTarantool (shtdnSrvOpts )
282
267
require .Nil (t , err )
283
268
defer test_helpers .StopTarantoolWithCleanup (inst )
284
269
@@ -314,7 +299,7 @@ func TestGracefulShutdownRespectsClose(t *testing.T) {
314
299
315
300
// SIGTERM the server.
316
301
shutdownStart := time .Now ()
317
- require .Nil (t , inst .Cmd . Process . Signal (syscall .SIGTERM ))
302
+ require .Nil (t , inst .Signal (syscall .SIGTERM ))
318
303
319
304
// Close the connection.
320
305
conn .Close ()
@@ -327,14 +312,11 @@ func TestGracefulShutdownRespectsClose(t *testing.T) {
327
312
require .NotNilf (t , err , "sleep request error" )
328
313
329
314
// Wait until server go down.
330
- _ , err = inst . Cmd . Process .Wait ()
315
+ err = inst .Wait ()
331
316
require .Nil (t , err )
332
317
shutdownFinish := time .Now ()
333
318
shutdownTime := shutdownFinish .Sub (shutdownStart )
334
319
335
- // Help test helpers to properly clean up.
336
- inst .Cmd .Process = nil
337
-
338
320
// Check that server finished without waiting for eval to finish.
339
321
require .Lessf (t ,
340
322
shutdownTime ,
@@ -354,11 +336,9 @@ func TestGracefulShutdownRespectsClose(t *testing.T) {
354
336
func TestGracefulShutdownNotRacesWithRequestReconnect (t * testing.T ) {
355
337
test_helpers .SkipIfWatchersUnsupported (t )
356
338
357
- var inst test_helpers.TarantoolInstance
358
339
var conn * Connection
359
- var err error
360
340
361
- inst , err = test_helpers .StartTarantool (shtdnSrvOpts )
341
+ inst , err : = test_helpers .StartTarantool (shtdnSrvOpts )
362
342
require .Nil (t , err )
363
343
defer test_helpers .StopTarantoolWithCleanup (inst )
364
344
@@ -397,16 +377,13 @@ func TestGracefulShutdownNotRacesWithRequestReconnect(t *testing.T) {
397
377
fut := conn .Do (req )
398
378
399
379
// SIGTERM the server.
400
- require .Nil (t , inst .Cmd . Process . Signal (syscall .SIGTERM ))
380
+ require .Nil (t , inst .Signal (syscall .SIGTERM ))
401
381
402
382
// Wait until server go down.
403
383
// Server is expected to go down on timeout.
404
- _ , err = inst . Cmd . Process .Wait ()
384
+ err = inst .Wait ()
405
385
require .Nil (t , err )
406
386
407
- // Help test helpers to properly clean up.
408
- inst .Cmd .Process = nil
409
-
410
387
// Check that request failed by server disconnect, not a client timeout.
411
388
_ , err = fut .Get ()
412
389
require .NotNil (t , err )
@@ -425,11 +402,9 @@ func TestGracefulShutdownNotRacesWithRequestReconnect(t *testing.T) {
425
402
func TestGracefulShutdownCloseConcurrent (t * testing.T ) {
426
403
test_helpers .SkipIfWatchersUnsupported (t )
427
404
428
- var inst test_helpers.TarantoolInstance
429
- var err error
430
405
var srvShtdnStart , srvShtdnFinish time.Time
431
406
432
- inst , err = test_helpers .StartTarantool (shtdnSrvOpts )
407
+ inst , err : = test_helpers .StartTarantool (shtdnSrvOpts )
433
408
require .Nil (t , err )
434
409
defer test_helpers .StopTarantoolWithCleanup (inst )
435
410
@@ -487,22 +462,19 @@ func TestGracefulShutdownCloseConcurrent(t *testing.T) {
487
462
go func (inst * test_helpers.TarantoolInstance ) {
488
463
srvToStop .Wait ()
489
464
srvShtdnStart = time .Now ()
490
- cerr := inst .Cmd . Process . Signal (syscall .SIGTERM )
465
+ cerr := inst .Signal (syscall .SIGTERM )
491
466
if cerr != nil {
492
467
sret = cerr
493
468
}
494
469
srvStop .Done ()
495
- }(& inst )
470
+ }(inst )
496
471
497
472
srvStop .Wait ()
498
473
require .Nil (t , sret , "No errors on server SIGTERM" )
499
474
500
- _ , err = inst . Cmd . Process .Wait ()
475
+ err = inst .Wait ()
501
476
require .Nil (t , err )
502
477
503
- // Help test helpers to properly clean up.
504
- inst .Cmd .Process = nil
505
-
506
478
srvShtdnFinish = time .Now ()
507
479
srvShtdnTime := srvShtdnFinish .Sub (srvShtdnStart )
508
480
@@ -515,11 +487,9 @@ func TestGracefulShutdownCloseConcurrent(t *testing.T) {
515
487
func TestGracefulShutdownConcurrent (t * testing.T ) {
516
488
test_helpers .SkipIfWatchersUnsupported (t )
517
489
518
- var inst test_helpers.TarantoolInstance
519
- var err error
520
490
var srvShtdnStart , srvShtdnFinish time.Time
521
491
522
- inst , err = test_helpers .StartTarantool (shtdnSrvOpts )
492
+ inst , err : = test_helpers .StartTarantool (shtdnSrvOpts )
523
493
require .Nil (t , err )
524
494
defer test_helpers .StopTarantoolWithCleanup (inst )
525
495
@@ -577,25 +547,22 @@ func TestGracefulShutdownConcurrent(t *testing.T) {
577
547
go func (inst * test_helpers.TarantoolInstance ) {
578
548
srvToStop .Wait ()
579
549
srvShtdnStart = time .Now ()
580
- cerr := inst .Cmd . Process . Signal (syscall .SIGTERM )
550
+ cerr := inst .Signal (syscall .SIGTERM )
581
551
if cerr != nil {
582
552
sret = cerr
583
553
}
584
554
srvStop .Done ()
585
- }(& inst )
555
+ }(inst )
586
556
587
557
srvStop .Wait ()
588
558
require .Nil (t , sret , "No errors on server SIGTERM" )
589
559
590
560
caseWg .Wait ()
591
561
require .Nil (t , ret , "No errors on concurrent wait" )
592
562
593
- _ , err = inst . Cmd . Process .Wait ()
563
+ err = inst .Wait ()
594
564
require .Nil (t , err )
595
565
596
- // Help test helpers to properly clean up.
597
- inst .Cmd .Process = nil
598
-
599
566
srvShtdnFinish = time .Now ()
600
567
srvShtdnTime := srvShtdnFinish .Sub (srvShtdnStart )
601
568
0 commit comments