Allow configuring graceful stop in testutil (#10566)
* Allow configuring graceful stop in testutil Signed-off-by: Sergey Matyukevich <s.matyukevich@gmail.com> * add a changelog Co-authored-by: Dhia Ayachi <dhia@hashicorp.com>
This commit is contained in:
parent
a7b5a5d1b4
commit
19a744191f
|
@ -0,0 +1,3 @@
|
||||||
|
```release-note:enhancement
|
||||||
|
Allow configuring graceful stop in testutil.
|
||||||
|
```
|
|
@ -101,7 +101,9 @@ type TestServerConfig struct {
|
||||||
EnableScriptChecks bool `json:"enable_script_checks,omitempty"`
|
EnableScriptChecks bool `json:"enable_script_checks,omitempty"`
|
||||||
Connect map[string]interface{} `json:"connect,omitempty"`
|
Connect map[string]interface{} `json:"connect,omitempty"`
|
||||||
EnableDebug bool `json:"enable_debug,omitempty"`
|
EnableDebug bool `json:"enable_debug,omitempty"`
|
||||||
|
SkipLeaveOnInt bool `json:"skip_leave_on_interrupt"`
|
||||||
ReadyTimeout time.Duration `json:"-"`
|
ReadyTimeout time.Duration `json:"-"`
|
||||||
|
StopTimeout time.Duration `json:"-"`
|
||||||
Stdout io.Writer `json:"-"`
|
Stdout io.Writer `json:"-"`
|
||||||
Stderr io.Writer `json:"-"`
|
Stderr io.Writer `json:"-"`
|
||||||
Args []string `json:"-"`
|
Args []string `json:"-"`
|
||||||
|
@ -163,7 +165,9 @@ func defaultServerConfig(t TestingTB) *TestServerConfig {
|
||||||
SerfWan: ports[4],
|
SerfWan: ports[4],
|
||||||
Server: ports[5],
|
Server: ports[5],
|
||||||
},
|
},
|
||||||
ReadyTimeout: 10 * time.Second,
|
ReadyTimeout: 10 * time.Second,
|
||||||
|
StopTimeout: 10 * time.Second,
|
||||||
|
SkipLeaveOnInt: true,
|
||||||
Connect: map[string]interface{}{
|
Connect: map[string]interface{}{
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"ca_config": map[string]interface{}{
|
"ca_config": map[string]interface{}{
|
||||||
|
@ -340,7 +344,7 @@ func (s *TestServer) Stop() error {
|
||||||
select {
|
select {
|
||||||
case err := <-waitDone:
|
case err := <-waitDone:
|
||||||
return err
|
return err
|
||||||
case <-time.After(10 * time.Second):
|
case <-time.After(s.Config.StopTimeout):
|
||||||
s.cmd.Process.Signal(syscall.SIGABRT)
|
s.cmd.Process.Signal(syscall.SIGABRT)
|
||||||
<-waitDone
|
<-waitDone
|
||||||
return fmt.Errorf("timeout waiting for server to stop gracefully")
|
return fmt.Errorf("timeout waiting for server to stop gracefully")
|
||||||
|
|
Loading…
Reference in New Issue