Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions lib/web/autoupdate_common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,10 @@ func TestAutoUpdateAgentShouldUpdate(t *testing.T) {
}))
t.Cleanup(brokenChannelUpstream.Close)

clock := clockwork.NewFakeClock()
cacheClock := clockwork.NewFakeClock()
cmcCache, err := utils.NewFnCache(utils.FnCacheConfig{
TTL: findEndpointCacheTTL,
Clock: clock,
Clock: cacheClock,
Context: ctx,
ReloadOnErr: false,
})
Expand All @@ -179,6 +179,9 @@ func TestAutoUpdateAgentShouldUpdate(t *testing.T) {
cmcCache.Shutdown(ctx)
})

// We don't use the cache clock because we are advancing it to invalidate the cmc cache and
// this would interfere with the test logic
clock := clockwork.NewFakeClock()
activeUpgradeWindow := types.AgentUpgradeWindow{UTCStartHour: uint32(clock.Now().Hour())}
inactiveUpgradeWindow := types.AgentUpgradeWindow{UTCStartHour: uint32(clock.Now().Add(2 * time.Hour).Hour())}
tests := []struct {
Expand Down Expand Up @@ -321,8 +324,8 @@ func TestAutoUpdateAgentShouldUpdate(t *testing.T) {
cmc := types.NewClusterMaintenanceConfig()
cmc.SetAgentUpgradeWindow(tt.upgradeWindow)
require.NoError(t, tt.channel.CheckAndSetDefaults())
// Advance clock to invalidate cache
clock.Advance(2 * findEndpointCacheTTL)
// Advance cache clock to expire cached cmc
cacheClock.Advance(2 * findEndpointCacheTTL)
h := &Handler{
cfg: Config{
AccessPoint: &fakeRolloutAccessPoint{
Expand Down