Skip to content

Commit ea23eca

Browse files
committed
e2e: verify NRO primary-pool node labels on deploy and cleanup on delete
Add e2e checks to validate that managed nodes receive the numa-operator.openshift.io/primary-pool label after deployment, and that these labels are cleaned up when the NUMAResourcesOperator CR is deleted. Checks are gated to OpenShift platform only. AIA: Human-AI blend, New content, Human-initiated, Reviewed, Claude Opus 4.6 v1.0 Signed-off-by: Talor Itzhak <titzhak@redhat.com>
1 parent 7fdcbbb commit ea23eca

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

test/e2e/install/install_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ import (
3636

3737
machineconfigv1 "github.com/openshift/api/machineconfiguration/v1"
3838

39+
"github.com/k8stopologyawareschedwg/deployer/pkg/deployer/platform"
3940
"github.com/k8stopologyawareschedwg/deployer/pkg/assets/selinux"
4041
"github.com/k8stopologyawareschedwg/deployer/pkg/manifests/rte"
4142
nrtv1alpha2 "github.com/k8stopologyawareschedwg/noderesourcetopology-api/pkg/apis/topology/v1alpha2"
4243

4344
nropv1 "github.com/openshift-kni/numaresources-operator/api/v1"
4445
inthelper "github.com/openshift-kni/numaresources-operator/internal/api/annotations/helper"
46+
nrolabels "github.com/openshift-kni/numaresources-operator/internal/api/labels"
4547
nropmcp "github.com/openshift-kni/numaresources-operator/internal/machineconfigpools"
4648
"github.com/openshift-kni/numaresources-operator/internal/podlogs"
4749
nrowait "github.com/openshift-kni/numaresources-operator/internal/wait"
@@ -151,6 +153,8 @@ var _ = Describe("[Install] continuousIntegration", Serial, func() {
151153
rteContainer, err := findContainerByName(*ds, containerNameRTE)
152154
Expect(err).ToNot(HaveOccurred())
153155
Expect(rteContainer.SecurityContext.SELinuxOptions.Type).To(Equal(selinux.RTEContextType), "container %s is running with wrong selinux context", rteContainer.Name)
156+
157+
expectNROPrimaryPoolLabelsPresent(ds)
154158
})
155159
})
156160
})
@@ -265,10 +269,14 @@ var _ = Describe("[Install] durability", Serial, func() {
265269
return err
266270
}).WithTimeout(5 * time.Minute).WithPolling(10 * time.Second).Should(Succeed())
267271

272+
expectNROPrimaryPoolLabelsPresent(ds)
273+
268274
deleteNROPSync(e2eclient.Client, nroObj)
269275

270276
deploy.WaitForMCPUpdatedAfterNRODeleted(nroObj)
271277

278+
expectNROPrimaryPoolLabelsAbsent()
279+
272280
By("checking there are no leftovers")
273281
// by taking the ns from the ds we're avoiding the need to figure out in advanced
274282
// at which ns we should look for the resources
@@ -326,6 +334,7 @@ var _ = Describe("[Install] durability", Serial, func() {
326334
return ds.Spec.Template.Spec.Containers[0].Image == e2eimages.RTETestImageCI
327335
}).WithTimeout(5 * time.Minute).WithPolling(10 * time.Second).Should(BeTrue())
328336
})
337+
329338
It("should have the desired topology manager configuration under the NRT object", func() {
330339
rteConfigMap := &corev1.ConfigMap{}
331340
Eventually(func() bool {
@@ -415,6 +424,45 @@ func getDaemonSetByOwnerReference(uid types.UID) (*appsv1.DaemonSet, error) {
415424
return nil, fmt.Errorf("failed to get daemonset with owner reference uid: %s", uid)
416425
}
417426

427+
func expectNROPrimaryPoolLabelsPresent(ds *appsv1.DaemonSet) {
428+
GinkgoHelper()
429+
if configuration.Plat != platform.OpenShift {
430+
return
431+
}
432+
433+
By("checking that managed nodes have the NRO primary-pool label")
434+
sel, err := labels.Parse(nrolabels.NodePrimaryPool)
435+
Expect(err).ToNot(HaveOccurred())
436+
nodeList := &corev1.NodeList{}
437+
err = e2eclient.Client.List(context.TODO(), nodeList, &client.ListOptions{LabelSelector: sel})
438+
Expect(err).ToNot(HaveOccurred())
439+
Expect(nodeList.Items).ToNot(BeEmpty(), "expected at least one node with the NRO primary-pool label")
440+
for _, node := range nodeList.Items {
441+
val := node.Labels[nrolabels.NodePrimaryPool]
442+
Expect(val).ToNot(BeEmpty(), "node %s has the NRO label key but empty value", node.Name)
443+
klog.InfoS("node has NRO primary-pool label", "node", node.Name, "pool", val)
444+
}
445+
446+
By("checking that the DaemonSet NodeSelector uses the NRO primary-pool label")
447+
_, hasKey := ds.Spec.Template.Spec.NodeSelector[nrolabels.NodePrimaryPool]
448+
Expect(hasKey).To(BeTrue(), "DaemonSet NodeSelector should contain %s", nrolabels.NodePrimaryPool)
449+
}
450+
451+
func expectNROPrimaryPoolLabelsAbsent() {
452+
GinkgoHelper()
453+
if configuration.Plat != platform.OpenShift {
454+
return
455+
}
456+
457+
By("checking that the NRO primary-pool labels were removed from all nodes")
458+
sel, err := labels.Parse(nrolabels.NodePrimaryPool)
459+
Expect(err).ToNot(HaveOccurred())
460+
nodeList := &corev1.NodeList{}
461+
err = e2eclient.Client.List(context.TODO(), nodeList, &client.ListOptions{LabelSelector: sel})
462+
Expect(err).ToNot(HaveOccurred())
463+
Expect(nodeList.Items).To(BeEmpty(), "expected no nodes with the NRO primary-pool label after deletion, but found %d", len(nodeList.Items))
464+
}
465+
418466
func logRTEPodsLogs(cli client.Client, k8sCli *kubernetes.Clientset, ctx context.Context, nroObj *nropv1.NUMAResourcesOperator, reason string) {
419467
dss, err := objects.GetDaemonSetsByNamespacedName(cli, ctx, nroObj.Status.DaemonSets...)
420468
if err != nil {

0 commit comments

Comments
 (0)