@@ -27,15 +27,22 @@ var opts = tarantool.Opts{
27
27
func TestGracefulShutdown (t * testing.T ) {
28
28
test_helpers .SkipIfWatchersUnsupported (t )
29
29
30
- inst , err := test_helpers . StartTarantool ( test_helpers.StartOpts {
30
+ instOpts := test_helpers.StartOpts {
31
31
InitScript : "testdata/config.lua" ,
32
32
Listen : server ,
33
33
User : opts .User ,
34
34
Pass : opts .Pass ,
35
35
WaitStart : 100 * time .Millisecond ,
36
36
ConnectRetry : 3 ,
37
37
RetryTimeout : 500 * time .Millisecond ,
38
- })
38
+ }
39
+
40
+ retries := uint (10 )
41
+ timeout := 200 * time .Millisecond
42
+ opts .Reconnect = timeout
43
+ opts .MaxReconnects = retries
44
+
45
+ inst , err := test_helpers .StartTarantool (instOpts )
39
46
require .Nil (t , err )
40
47
41
48
conn := test_helpers .ConnectWithValidation (t , server , opts )
@@ -81,5 +88,42 @@ func TestGracefulShutdown(t *testing.T) {
81
88
82
89
// time.Sleep(2 * time.Second)
83
90
91
+ require .Equal (t , false , conn .ConnectedNow ())
92
+
93
+ err = test_helpers .RestartTarantool (& inst )
94
+ require .Nilf (t , err , "Failed to restart tarantool" )
95
+
96
+ connected := test_helpers .WaitUntilReconnected (conn , retries , timeout )
97
+ require .True (t , connected , "Reconnect success" )
98
+
99
+ fut = conn .Do (req )
100
+ fmt .Printf ("test future is %v\n " , fut )
101
+
102
+ require .Nil (t , inst .Cmd .Process .Signal (syscall .SIGTERM ))
103
+
104
+ retrerr = test_helpers .Retry (func (interface {}) error {
105
+ _ , err = conn .Do (tarantool .NewPingRequest ()).Get ()
106
+ if err == nil {
107
+ return fmt .Errorf ("expected error for requests sent on shutdown" )
108
+ }
109
+
110
+ if err .Error () != "instance shutdown in process" {
111
+ return err
112
+ }
113
+
114
+ return nil
115
+ }, nil , 5 , 100 * time .Millisecond )
116
+ require .Nil (t , retrerr )
117
+
118
+ resp , rerr = fut .Get ()
119
+ require .Nil (t , rerr )
120
+ require .NotNil (t , resp )
121
+ require .Equal (t , resp .Data , []interface {}{"nice sleep" })
122
+
123
+ _ , err = inst .Cmd .Process .Wait ()
124
+ require .Nil (t , err )
125
+
126
+ // time.Sleep(2 * time.Second)
127
+
84
128
require .Equal (t , true , conn .ClosedNow ())
85
129
}
0 commit comments