use a const for cluster test pause period

This commit is contained in:
Jeff Mitchell 2016-11-08 10:30:44 -05:00
parent ba3dc07bb3
commit 6f86e664a8
1 changed files with 17 additions and 13 deletions

View File

@ -16,6 +16,10 @@ import (
log "github.com/mgutz/logxi/v1"
)
var (
clusterTestPausePeriod = 2 * time.Second
)
func TestClusterFetching(t *testing.T) {
c, _, _ := TestCoreUnsealed(t)
@ -135,7 +139,7 @@ func TestCluster_ListenForRequests(t *testing.T) {
}
}
time.Sleep(2 * time.Second)
time.Sleep(clusterTestPausePeriod)
checkListenersFunc(false)
err := cores[0].StepDown(&logical.Request{
@ -149,7 +153,7 @@ func TestCluster_ListenForRequests(t *testing.T) {
// StepDown doesn't wait during actual preSeal so give time for listeners
// to close
time.Sleep(2 * time.Second)
time.Sleep(clusterTestPausePeriod)
checkListenersFunc(true)
// After this period it should be active again
@ -160,7 +164,7 @@ func TestCluster_ListenForRequests(t *testing.T) {
if err != nil {
t.Fatal(err)
}
time.Sleep(2 * time.Second)
time.Sleep(clusterTestPausePeriod)
// After sealing it should be inactive again
checkListenersFunc(true)
}
@ -230,13 +234,13 @@ func testCluster_ForwardRequestsCommon(t *testing.T, rpc bool) {
if err != nil {
t.Fatal(err)
}
time.Sleep(2 * time.Second)
time.Sleep(clusterTestPausePeriod)
_ = cores[2].StepDown(&logical.Request{
Operation: logical.UpdateOperation,
Path: "sys/step-down",
ClientToken: root,
})
time.Sleep(2 * time.Second)
time.Sleep(clusterTestPausePeriod)
TestWaitActive(t, cores[1].Core)
testCluster_ForwardRequests(t, cores[0], "core2")
testCluster_ForwardRequests(t, cores[2], "core2")
@ -250,13 +254,13 @@ func testCluster_ForwardRequestsCommon(t *testing.T, rpc bool) {
if err != nil {
t.Fatal(err)
}
time.Sleep(2 * time.Second)
time.Sleep(clusterTestPausePeriod)
_ = cores[0].StepDown(&logical.Request{
Operation: logical.UpdateOperation,
Path: "sys/step-down",
ClientToken: root,
})
time.Sleep(2 * time.Second)
time.Sleep(clusterTestPausePeriod)
TestWaitActive(t, cores[2].Core)
testCluster_ForwardRequests(t, cores[0], "core3")
testCluster_ForwardRequests(t, cores[1], "core3")
@ -270,13 +274,13 @@ func testCluster_ForwardRequestsCommon(t *testing.T, rpc bool) {
if err != nil {
t.Fatal(err)
}
time.Sleep(2 * time.Second)
time.Sleep(clusterTestPausePeriod)
_ = cores[1].StepDown(&logical.Request{
Operation: logical.UpdateOperation,
Path: "sys/step-down",
ClientToken: root,
})
time.Sleep(2 * time.Second)
time.Sleep(clusterTestPausePeriod)
TestWaitActive(t, cores[0].Core)
testCluster_ForwardRequests(t, cores[1], "core1")
testCluster_ForwardRequests(t, cores[2], "core1")
@ -290,13 +294,13 @@ func testCluster_ForwardRequestsCommon(t *testing.T, rpc bool) {
if err != nil {
t.Fatal(err)
}
time.Sleep(2 * time.Second)
time.Sleep(clusterTestPausePeriod)
_ = cores[2].StepDown(&logical.Request{
Operation: logical.UpdateOperation,
Path: "sys/step-down",
ClientToken: root,
})
time.Sleep(2 * time.Second)
time.Sleep(clusterTestPausePeriod)
TestWaitActive(t, cores[1].Core)
testCluster_ForwardRequests(t, cores[0], "core2")
testCluster_ForwardRequests(t, cores[2], "core2")
@ -310,13 +314,13 @@ func testCluster_ForwardRequestsCommon(t *testing.T, rpc bool) {
if err != nil {
t.Fatal(err)
}
time.Sleep(2 * time.Second)
time.Sleep(clusterTestPausePeriod)
_ = cores[0].StepDown(&logical.Request{
Operation: logical.UpdateOperation,
Path: "sys/step-down",
ClientToken: root,
})
time.Sleep(2 * time.Second)
time.Sleep(clusterTestPausePeriod)
TestWaitActive(t, cores[2].Core)
testCluster_ForwardRequests(t, cores[0], "core3")
testCluster_ForwardRequests(t, cores[1], "core3")