Skip to content

Commit

Permalink
made timing based tests a bit more lenient
Browse files Browse the repository at this point in the history
They were failing to often in CircleCI.
  • Loading branch information
eikenb committed Feb 4, 2022
1 parent f9dd3bb commit 2bf43d8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions dependency/vault_common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ func TestVaultRenewDuration(t *testing.T) {

nonRenewable := Secret{LeaseDuration: 100}
nonRenewableDur := leaseCheckWait(&nonRenewable).Seconds()
if nonRenewableDur < 85 || nonRenewableDur > 95 {
t.Fatalf("renewable duration is not within 85%% to 95%% of lease duration: %f", nonRenewableDur)
if nonRenewableDur < 80 || nonRenewableDur > 95 {
t.Fatalf("renewable duration is not within 80%% to 95%% of lease duration: %f", nonRenewableDur)
}

var data = map[string]interface{}{
Expand Down Expand Up @@ -60,8 +60,8 @@ func TestVaultRenewDuration(t *testing.T) {

nonRenewableCert := Secret{LeaseDuration: 100, Data: data}
nonRenewableCertDur := leaseCheckWait(&nonRenewableCert).Seconds()
if nonRenewableCertDur < 85 || nonRenewableCertDur > 95 {
t.Fatalf("non renewable certificate duration is not within 85%% to 95%%: %f", nonRenewableCertDur)
if nonRenewableCertDur < 80 || nonRenewableCertDur > 95 {
t.Fatalf("non renewable certificate duration is not within 80%% to 95%%: %f", nonRenewableCertDur)
}

t.Run("secret ID handling", func(t *testing.T) {
Expand All @@ -75,8 +75,8 @@ func TestVaultRenewDuration(t *testing.T) {
nonRenewableSecretID := Secret{LeaseDuration: 100, Data: data}
nonRenewableSecretIDDur := leaseCheckWait(&nonRenewableSecretID).Seconds()

if nonRenewableSecretIDDur < 0.85*(60+1) || nonRenewableSecretIDDur > 0.95*(60+1) {
t.Fatalf("renewable duration is not within 85%% to 95%% of lease duration: %f", nonRenewableSecretIDDur)
if nonRenewableSecretIDDur < 0.80*(60+1) || nonRenewableSecretIDDur > 0.95*(60+1) {
t.Fatalf("renewable duration is not within 80%% to 95%% of lease duration: %f", nonRenewableSecretIDDur)
}
})

Expand All @@ -91,8 +91,8 @@ func TestVaultRenewDuration(t *testing.T) {
nonRenewableSecretID := Secret{LeaseDuration: leaseDuration, Data: data}
nonRenewableSecretIDDur := leaseCheckWait(&nonRenewableSecretID).Seconds()

if nonRenewableSecretIDDur < 0.85*(leaseDuration+1) || nonRenewableSecretIDDur > 0.95*(leaseDuration+1) {
t.Fatalf("renewable duration is not within 85%% to 95%% of lease duration: %f", nonRenewableSecretIDDur)
if nonRenewableSecretIDDur < 0.80*(leaseDuration+1) || nonRenewableSecretIDDur > 0.95*(leaseDuration+1) {
t.Fatalf("renewable duration is not within 80%% to 95%% of lease duration: %f", nonRenewableSecretIDDur)
}
})

Expand All @@ -106,8 +106,8 @@ func TestVaultRenewDuration(t *testing.T) {
nonRenewableSecretID := Secret{LeaseDuration: leaseDuration, Data: data}
nonRenewableSecretIDDur := leaseCheckWait(&nonRenewableSecretID).Seconds()

if nonRenewableSecretIDDur < 0.85*(leaseDuration+1) || nonRenewableSecretIDDur > 0.95*(leaseDuration+1) {
t.Fatalf("renewable duration is not within 85%% to 95%% of lease duration: %f", nonRenewableSecretIDDur)
if nonRenewableSecretIDDur < 0.80*(leaseDuration+1) || nonRenewableSecretIDDur > 0.95*(leaseDuration+1) {
t.Fatalf("renewable duration is not within 80%% to 95%% of lease duration: %f", nonRenewableSecretIDDur)
}
})

Expand Down
2 changes: 1 addition & 1 deletion manager/dedup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestDedup_IsLeader(t *testing.T) {
// Wait until we are leader
select {
case <-dedup.UpdateCh():
case <-time.After(3 * time.Second):
case <-time.After(4 * time.Second):
t.Fatalf("timeout")
}

Expand Down

0 comments on commit 2bf43d8

Please sign in to comment.