faster vaultclient

This commit is contained in:
Alex Dadgar 2017-07-21 19:38:37 -07:00
parent 4dd5d943c7
commit 46c8bec9b0
1 changed files with 8 additions and 4 deletions

View File

@ -12,12 +12,13 @@ import (
)
func TestVaultClient_TokenRenewals(t *testing.T) {
t.Parallel()
v := testutil.NewTestVault(t).Start()
defer v.Stop()
logger := log.New(os.Stderr, "TEST: ", log.Lshortfile|log.LstdFlags)
v.Config.ConnectionRetryIntv = 100 * time.Millisecond
v.Config.TaskTokenTTL = "10s"
v.Config.TaskTokenTTL = "4s"
c, err := NewVaultClient(v.Config, logger, nil)
if err != nil {
t.Fatalf("failed to build vault client: %v", err)
@ -27,7 +28,7 @@ func TestVaultClient_TokenRenewals(t *testing.T) {
defer c.Stop()
// Sleep a little while to ensure that the renewal loop is active
time.Sleep(3 * time.Second)
time.Sleep(time.Duration(testutil.TestMultiplier()) * time.Second)
tcr := &vaultapi.TokenCreateRequest{
Policies: []string{"foo", "bar"},
@ -66,7 +67,9 @@ func TestVaultClient_TokenRenewals(t *testing.T) {
for {
select {
case err := <-errCh:
t.Fatalf("error while renewing the token: %v", err)
if err != nil {
t.Fatalf("error while renewing the token: %v", err)
}
}
}
}(errCh)
@ -76,7 +79,7 @@ func TestVaultClient_TokenRenewals(t *testing.T) {
t.Fatalf("bad: heap length: expected: %d, actual: %d", num, c.heap.Length())
}
time.Sleep(time.Duration(5*testutil.TestMultiplier()) * time.Second)
time.Sleep(time.Duration(testutil.TestMultiplier()) * time.Second)
for i := 0; i < num; i++ {
if err := c.StopRenewToken(tokens[i]); err != nil {
@ -90,6 +93,7 @@ func TestVaultClient_TokenRenewals(t *testing.T) {
}
func TestVaultClient_Heap(t *testing.T) {
t.Parallel()
tr := true
conf := config.DefaultConfig()
conf.VaultConfig.Enabled = &tr