Skip to content

Commit a1c073b

Browse files
phlogistonjohnmergify[bot]
authored andcommitted
integration tests: check for node availability in scheduling tests
The tests for the node selector and affinity scheduling require at least two nodes. Previously, the tests would simply fail if there weren't enough nodes to run the test. This patch adds a check such that the test is skipped if there aren't enough nodes - unless the SMBOP_TEST_MIN_NODE_COUNT was specified. This variable acts as a double check on the expected environment. If the number of available nodes is less than that given by the env var the test is required to fail. Signed-off-by: John Mulligan <[email protected]>
1 parent 023562d commit a1c073b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

tests/integration/scheduling_test.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,17 @@ func (s *CommonSelectorSuite) labelANode(ctx context.Context) {
6161
LabelSelector: "kubernetes.io/os=linux,kubernetes.io/arch=amd64,!node-role.kubernetes.io/control-plane",
6262
})
6363
s.Require().NoError(err)
64-
s.Require().Greater(len(nodesList.Items), 0)
64+
nodesAvail := len(nodesList.Items)
65+
// did we find enough nodes for the test?
66+
if nodesAvail < 2 {
67+
// were we told we should have enough? Fail if we should have had enough
68+
if nodesAvail < testMinNodeCount {
69+
s.T().Fatalf(
70+
"fewer available nodes than expected. matched %d, expected at least %d",
71+
nodesAvail, testMinNodeCount)
72+
}
73+
s.T().Skip("test requires at least 2 nodes")
74+
}
6575
idx := rand.Intn(len(nodesList.Items))
6676
targetNode := nodesList.Items[idx]
6777
targetNode.Labels["mytestid"] = s.testID

0 commit comments

Comments
 (0)