mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-18 04:54:54 +00:00
Merge pull request #131710 from saza-ku/fix-test-node-affinity-scoring
test: wait for nodes to be in scheduler's cache
This commit is contained in:
@@ -308,6 +308,9 @@ func TestNodeAffinityScoring(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Cannot create labeled node: %v", err)
|
||||
}
|
||||
if err = testutils.WaitForNodesInCache(testCtx.Ctx, testCtx.Scheduler, 5); err != nil {
|
||||
t.Fatalf("failed to wait for nodes in cache: %v", err)
|
||||
}
|
||||
|
||||
// Create a pod with node affinity.
|
||||
podName := "pod-with-node-affinity"
|
||||
@@ -744,6 +747,9 @@ func TestPodAffinityScoring(t *testing.T) {
|
||||
t.Fatalf("failed to create node: %v", err)
|
||||
}
|
||||
}
|
||||
if err := testutils.WaitForNodesInCache(testCtx.Ctx, testCtx.Scheduler, len(tt.nodes)); err != nil {
|
||||
t.Fatalf("failed to wait for nodes in cache: %v", err)
|
||||
}
|
||||
|
||||
for _, p := range tt.existingPods {
|
||||
if _, err := runPausePod(testCtx.ClientSet, initPausePod(p)); err != nil {
|
||||
@@ -838,6 +844,9 @@ func TestTaintTolerationScoring(t *testing.T) {
|
||||
t.Fatalf("Failed to create node: %v", err)
|
||||
}
|
||||
}
|
||||
if err := testutils.WaitForNodesInCache(testCtx.Ctx, testCtx.Scheduler, len(tt.nodes)); err != nil {
|
||||
t.Fatalf("Failed to wait for nodes in cache: %v", err)
|
||||
}
|
||||
pod, err := runPausePod(testCtx.ClientSet, initPausePod(&testutils.PausePodConfig{
|
||||
Name: fmt.Sprintf("test-pod-%v", i),
|
||||
Namespace: testCtx.NS.Name,
|
||||
@@ -1102,6 +1111,9 @@ func TestPodTopologySpreadScoring(t *testing.T) {
|
||||
t.Fatalf("Cannot create node: %v", err)
|
||||
}
|
||||
}
|
||||
if err := testutils.WaitForNodesInCache(testCtx.Ctx, testCtx.Scheduler, len(tt.nodes)); err != nil {
|
||||
t.Fatalf("Failed to wait for nodes in cache: %v", err)
|
||||
}
|
||||
|
||||
// set namespace to pods
|
||||
for i := range tt.existingPods {
|
||||
@@ -1149,9 +1161,10 @@ func TestDefaultPodTopologySpreadScoring(t *testing.T) {
|
||||
testCtx := initTestSchedulerForScoringTests(t, podtopologyspread.Name, podtopologyspread.Name)
|
||||
cs := testCtx.ClientSet
|
||||
ns := testCtx.NS.Name
|
||||
nodeNum := 300
|
||||
|
||||
zoneForNode := make(map[string]string)
|
||||
for i := 0; i < 300; i++ {
|
||||
for i := 0; i < nodeNum; i++ {
|
||||
nodeName := fmt.Sprintf("node-%d", i)
|
||||
zone := fmt.Sprintf("zone-%d", i%3)
|
||||
zoneForNode[nodeName] = zone
|
||||
@@ -1160,6 +1173,9 @@ func TestDefaultPodTopologySpreadScoring(t *testing.T) {
|
||||
t.Fatalf("Cannot create node: %v", err)
|
||||
}
|
||||
}
|
||||
if err := testutils.WaitForNodesInCache(testCtx.Ctx, testCtx.Scheduler, nodeNum); err != nil {
|
||||
t.Fatalf("Failed to wait for nodes in cache: %v", err)
|
||||
}
|
||||
|
||||
serviceName := "test-service"
|
||||
svc := &v1.Service{
|
||||
|
||||
Reference in New Issue
Block a user