Skip to content

Commit 5f3f3db

Browse files
committed
e2e: serial: ensure MCPs and nodes are healthy
At the setup of the test, check that MCPs and nodes are healthy enough for the test to run by verifying that the MCPs are all `Updated` and non of the nodes is `unschedulable`. We don't want to fail on any error so keep any unexpected results at warning level. Signed-off-by: Shereen Haj <[email protected]>
1 parent eee9ff4 commit 5f3f3db

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

test/internal/fixture/fixture.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ import (
3636
"sigs.k8s.io/controller-runtime/pkg/client"
3737
"sigs.k8s.io/yaml"
3838

39+
machineconfigv1 "github.com/openshift/api/machineconfiguration/v1"
40+
3941
"github.com/k8stopologyawareschedwg/deployer/pkg/deployer"
4042
nrtv1alpha2 "github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/apis/topology/v1alpha2"
4143

@@ -102,6 +104,7 @@ func SetupWithOptions(name string, nrtList nrtv1alpha2.NodeResourceTopologyList,
102104
randomizeName := (options & OptionRandomizeName) == OptionRandomizeName
103105
avoidCooldown := (options & OptionAvoidCooldown) == OptionAvoidCooldown
104106
staticClusterData := (options & OptionStaticClusterData) == OptionStaticClusterData
107+
105108
ginkgo.By("set up the test namespace")
106109
ns, err := setupNamespace(e2eclient.Client, name, randomizeName)
107110
if err != nil {
@@ -133,6 +136,44 @@ func SetupWithOptions(name string, nrtList nrtv1alpha2.NodeResourceTopologyList,
133136
}
134137
klog.Infof("set up the fixture reference NRT List: %s", intnrt.ListToString(nrtList.Items, " fixture initial"))
135138

139+
ginkgo.By("warn about not updated MCPs")
140+
var mcps machineconfigv1.MachineConfigPoolList
141+
err = wait.PollUntilContextTimeout(ctx, 10*time.Second, 30*time.Second, true, func(ctx context.Context) (bool, error) {
142+
err := e2eclient.Client.List(ctx, &mcps)
143+
return err == nil, nil
144+
})
145+
if err != nil {
146+
klog.Errorf("failed to pull MCP items: %v", err)
147+
} else {
148+
for _, mcp := range mcps.Items {
149+
conditions := mcp.Status.Conditions
150+
klog.InfoS("MCP status", "name", mcp.Name, "conditions", conditions)
151+
for _, condition := range conditions {
152+
if condition.Type == machineconfigv1.MachineConfigPoolUpdated {
153+
if condition.Status != corev1.ConditionTrue {
154+
klog.Warningf("MCP %q is not updated", mcp.Name)
155+
break
156+
}
157+
}
158+
}
159+
}
160+
}
161+
ginkgo.By("warn about unschedulable nodes")
162+
var nodes corev1.NodeList
163+
err = wait.PollUntilContextTimeout(ctx, 10*time.Second, 30*time.Second, true, func(ctx context.Context) (bool, error) {
164+
err := e2eclient.Client.List(ctx, &nodes)
165+
return err == nil, nil
166+
})
167+
if err != nil {
168+
klog.Errorf("failed to pull cluster nodes: %v", err)
169+
} else {
170+
for _, node := range nodes.Items {
171+
if node.Spec.Unschedulable {
172+
klog.Warningf("Node %q is unschedulable", node.Name)
173+
}
174+
}
175+
}
176+
136177
return &Fixture{
137178
Client: e2eclient.Client,
138179
K8sClient: e2eclient.K8sClient,

0 commit comments

Comments
 (0)