Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Fix ConsolidationState() test failure in state testing (#1957) #2040

Draft
wants to merge 1 commit into
base: release-v1.0.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions pkg/controllers/state/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,17 @@
func (c *Cluster) Reset() {
c.mu.Lock()
defer c.mu.Unlock()
c.clusterState = time.Time{}
c.unsyncedStartTime = time.Time{}

Check failure on line 343 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.25.x)

c.unsyncedStartTime undefined (type *Cluster has no field or method unsyncedStartTime)

Check failure on line 343 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / Analyze Go

c.unsyncedStartTime undefined (type *Cluster has no field or method unsyncedStartTime)

Check failure on line 343 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.26.x)

c.unsyncedStartTime undefined (type *Cluster has no field or method unsyncedStartTime)

Check failure on line 343 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.27.x)

c.unsyncedStartTime undefined (type *Cluster has no field or method unsyncedStartTime)

Check failure on line 343 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.28.x)

c.unsyncedStartTime undefined (type *Cluster has no field or method unsyncedStartTime)

Check failure on line 343 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.29.x)

c.unsyncedStartTime undefined (type *Cluster has no field or method unsyncedStartTime)

Check failure on line 343 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.30.x)

c.unsyncedStartTime undefined (type *Cluster has no field or method unsyncedStartTime)
c.nodes = map[string]*StateNode{}
c.nodeNameToProviderID = map[string]string{}
c.nodeClaimNameToProviderID = map[string]string{}
c.bindings = map[types.NamespacedName]string{}
c.antiAffinityPods = sync.Map{}
c.daemonSetPods = sync.Map{}
c.podAcks = sync.Map{}

Check failure on line 350 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.25.x)

c.podAcks undefined (type *Cluster has no field or method podAcks)

Check failure on line 350 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / Analyze Go

c.podAcks undefined (type *Cluster has no field or method podAcks)

Check failure on line 350 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.26.x)

c.podAcks undefined (type *Cluster has no field or method podAcks)

Check failure on line 350 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.27.x)

c.podAcks undefined (type *Cluster has no field or method podAcks)

Check failure on line 350 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.28.x)

c.podAcks undefined (type *Cluster has no field or method podAcks)

Check failure on line 350 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.29.x)

c.podAcks undefined (type *Cluster has no field or method podAcks)

Check failure on line 350 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.30.x)

c.podAcks undefined (type *Cluster has no field or method podAcks)
c.podsSchedulingAttempted = sync.Map{}

Check failure on line 351 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.25.x)

c.podsSchedulingAttempted undefined (type *Cluster has no field or method podsSchedulingAttempted)

Check failure on line 351 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / Analyze Go

c.podsSchedulingAttempted undefined (type *Cluster has no field or method podsSchedulingAttempted)

Check failure on line 351 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.26.x)

c.podsSchedulingAttempted undefined (type *Cluster has no field or method podsSchedulingAttempted)

Check failure on line 351 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.27.x)

c.podsSchedulingAttempted undefined (type *Cluster has no field or method podsSchedulingAttempted)

Check failure on line 351 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.28.x)

c.podsSchedulingAttempted undefined (type *Cluster has no field or method podsSchedulingAttempted)

Check failure on line 351 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.29.x)

c.podsSchedulingAttempted undefined (type *Cluster has no field or method podsSchedulingAttempted)

Check failure on line 351 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.30.x)

c.podsSchedulingAttempted undefined (type *Cluster has no field or method podsSchedulingAttempted)
c.podsSchedulableTimes = sync.Map{}

Check failure on line 352 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.25.x)

c.podsSchedulableTimes undefined (type *Cluster has no field or method podsSchedulableTimes)

Check failure on line 352 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / Analyze Go

c.podsSchedulableTimes undefined (type *Cluster has no field or method podsSchedulableTimes)

Check failure on line 352 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.26.x)

c.podsSchedulableTimes undefined (type *Cluster has no field or method podsSchedulableTimes)

Check failure on line 352 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.27.x)

c.podsSchedulableTimes undefined (type *Cluster has no field or method podsSchedulableTimes)

Check failure on line 352 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.28.x)

c.podsSchedulableTimes undefined (type *Cluster has no field or method podsSchedulableTimes)

Check failure on line 352 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.29.x)

c.podsSchedulableTimes undefined (type *Cluster has no field or method podsSchedulableTimes)

Check failure on line 352 in pkg/controllers/state/cluster.go

View workflow job for this annotation

GitHub Actions / presubmit (1.30.x)

c.podsSchedulableTimes undefined (type *Cluster has no field or method podsSchedulableTimes)
}

func (c *Cluster) GetDaemonSetPod(daemonset *appsv1.DaemonSet) *corev1.Pod {
Expand Down
11 changes: 10 additions & 1 deletion pkg/controllers/state/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"math/rand"
"net"
"sync"
"testing"
"time"

Expand Down Expand Up @@ -1443,7 +1444,7 @@ var _ = Describe("Consolidated State", func() {
cluster.MarkUnconsolidated()
Expect(cluster.ConsolidationState()).ToNot(Equal(state))
})
It("should update the consolidated value when consolidation timeout (5m) has passed and state hasn't changed", func() {
It("should update the consolidated value when state timeout (5m) has passed and state hasn't changed", func() {
state := cluster.ConsolidationState()

fakeClock.Step(time.Minute)
Expand All @@ -1468,12 +1469,16 @@ var _ = Describe("Consolidated State", func() {
var _ = Describe("Data Races", func() {
It("should ensure that calling Synced() is valid while making updates to Nodes", func() {
cancelCtx, cancel := context.WithCancel(ctx)
var wg sync.WaitGroup
DeferCleanup(func() {
cancel()
wg.Wait()
})

// Keep calling Synced for the entirety of this test
wg.Add(1)
go func() {
defer wg.Done()
for {
_ = cluster.Synced(ctx)
if cancelCtx.Err() != nil {
Expand All @@ -1493,12 +1498,16 @@ var _ = Describe("Data Races", func() {
})
It("should ensure that calling Synced() is valid while making updates to NodeClaims", func() {
cancelCtx, cancel := context.WithCancel(ctx)
var wg sync.WaitGroup
DeferCleanup(func() {
cancel()
wg.Wait()
})

// Keep calling Synced for the entirety of this test
wg.Add(1)
go func() {
defer wg.Done()
for {
_ = cluster.Synced(ctx)
if cancelCtx.Err() != nil {
Expand Down
Loading