Skip to content

Commit c9eb2c0

Browse files
authored
Merge pull request #11374 from Nordix/healthcheck-fix/adil
🌱 Fixing TestClusterCacheHealthCheck flake
2 parents 3b9a0e5 + 3fc8054 commit c9eb2c0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

controllers/remote/cluster_cache_healthcheck_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package remote
1919
import (
2020
"context"
2121
"fmt"
22+
"math"
2223
"net"
2324
"testing"
2425
"time"
@@ -158,7 +159,8 @@ func TestClusterCacheHealthCheck(t *testing.T) {
158159
ns := setup(t, g)
159160
defer teardown(t, g, ns)
160161
// Create a context with a timeout to cancel the healthcheck after some time
161-
ctx, cancel := context.WithTimeout(ctx, time.Second)
162+
contextTimeout := time.Second
163+
ctx, cancel := context.WithTimeout(ctx, contextTimeout)
162164
defer cancel()
163165
// Delete the cluster accessor and lock the cluster to simulate creation of a new cluster accessor
164166
cct.deleteAccessor(ctx, testClusterKey)
@@ -177,8 +179,9 @@ func TestClusterCacheHealthCheck(t *testing.T) {
177179
path: "/",
178180
})
179181
timeElapsedForHealthCheck := time.Since(startHealthCheck)
182+
timeElapsedForHealthCheckRounded := int(math.Round(timeElapsedForHealthCheck.Seconds()))
180183
// If the duration is shorter than the timeout, we know that the healthcheck wasn't requeued properly.
181-
g.Expect(timeElapsedForHealthCheck).Should(BeNumerically(">=", time.Second))
184+
g.Expect(timeElapsedForHealthCheckRounded).Should(BeNumerically(">=", int(contextTimeout.Seconds())))
182185
// The healthcheck should be aborted by the timout of the context
183186
g.Expect(ctx.Done()).Should(BeClosed())
184187
})

0 commit comments

Comments
 (0)