Skip to content

Commit 28132fb

Browse files
committed
test/e2e: stricter validation of node annotations
Now that the hard-to-predict version annotations are gone we can do strict validation of nfd-generated node annotations.
1 parent 6144f3d commit 28132fb

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

test/e2e/node_feature_discovery_test.go

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -708,9 +708,14 @@ core:
708708
expectedLabels["*"][nfdv1alpha1.FeatureLabelNs+"/e2e-template-test-1-instance_1"] = "found"
709709
expectedLabels["*"][nfdv1alpha1.FeatureLabelNs+"/e2e-template-test-1-instance_2"] = "found"
710710
expectedLabels["*"][nfdv1alpha1.FeatureLabelNs+"/dynamic-label"] = "true"
711+
expectedAnnotations := map[string]k8sAnnotations{
712+
"*": {
713+
"nfd.node.kubernetes.io/feature-labels": "dynamic-label,e2e-attribute-test-1,e2e-flag-test-1,e2e-instance-test-1,e2e-matchany-test-1,e2e-template-test-1-instance_1,e2e-template-test-1-instance_2"},
714+
}
711715

712716
By("Verifying node labels from NodeFeatureRules #1 and #2")
713717
eventuallyNonControlPlaneNodes(ctx, f.ClientSet).Should(MatchLabels(expectedLabels, nodes, false))
718+
eventuallyNonControlPlaneNodes(ctx, f.ClientSet).Should(MatchAnnotations(expectedAnnotations, nodes, false))
714719

715720
// Add features from NodeFeatureRule #3
716721
By("Creating NodeFeatureRules #3")
@@ -736,12 +741,10 @@ core:
736741
},
737742
},
738743
}
739-
expectedAnnotations := map[string]k8sAnnotations{
740-
"*": {
741-
"nfd.node.kubernetes.io/taints": "feature.node.kubernetes.io/fake-special-node=exists:PreferNoSchedule,feature.node.kubernetes.io/fake-dedicated-node=true:NoExecute,feature.node.kubernetes.io/performance-optimized-node=true:NoExecute"},
742-
}
744+
expectedAnnotations["*"]["nfd.node.kubernetes.io/taints"] = "feature.node.kubernetes.io/fake-special-node=exists:PreferNoSchedule,feature.node.kubernetes.io/fake-dedicated-node=true:NoExecute,feature.node.kubernetes.io/performance-optimized-node=true:NoExecute"
745+
743746
eventuallyNonControlPlaneNodes(ctx, f.ClientSet).Should(MatchTaints(expectedTaints, nodes, false))
744-
eventuallyNonControlPlaneNodes(ctx, f.ClientSet).Should(MatchAnnotations(expectedAnnotations, nodes, true))
747+
eventuallyNonControlPlaneNodes(ctx, f.ClientSet).Should(MatchAnnotations(expectedAnnotations, nodes, false))
745748

746749
By("Re-applying NodeFeatureRules #3 with updated taints")
747750
Expect(testutils.UpdateNodeFeatureRulesFromFile(ctx, nfdClient, "nodefeaturerule-3-updated.yaml")).NotTo(HaveOccurred())
@@ -761,15 +764,17 @@ core:
761764

762765
By("Verifying updated node taints and annotation from NodeFeatureRules #3")
763766
eventuallyNonControlPlaneNodes(ctx, f.ClientSet).Should(MatchTaints(expectedTaints, nodes, false))
764-
eventuallyNonControlPlaneNodes(ctx, f.ClientSet).Should(MatchAnnotations(expectedAnnotations, nodes, true))
767+
eventuallyNonControlPlaneNodes(ctx, f.ClientSet).Should(MatchAnnotations(expectedAnnotations, nodes, false))
765768

766769
By("Deleting NodeFeatureRule object")
767770
err = nfdClient.NfdV1alpha1().NodeFeatureRules().Delete(ctx, "e2e-test-3", metav1.DeleteOptions{})
768771
Expect(err).NotTo(HaveOccurred())
769772
expectedTaints["*"] = []corev1.Taint{}
773+
delete(expectedAnnotations["*"], "nfd.node.kubernetes.io/taints")
770774
eventuallyNonControlPlaneNodes(ctx, f.ClientSet).Should(MatchTaints(expectedTaints, nodes, false))
775+
eventuallyNonControlPlaneNodes(ctx, f.ClientSet).Should(MatchAnnotations(expectedAnnotations, nodes, false))
771776

772-
expectedAnnotations["*"] = k8sAnnotations{"nfd.node.kubernetes.io/extended-resources": "nons,vendor.feature.node.kubernetes.io/static,vendor.io/dynamic"}
777+
expectedAnnotations["*"]["nfd.node.kubernetes.io/extended-resources"] = "nons,vendor.feature.node.kubernetes.io/static,vendor.io/dynamic"
773778

774779
expectedCapacity := map[string]corev1.ResourceList{
775780
"*": {
@@ -783,7 +788,7 @@ core:
783788
Expect(testutils.CreateNodeFeatureRulesFromFile(ctx, nfdClient, "nodefeaturerule-4.yaml")).NotTo(HaveOccurred())
784789

785790
By("Verifying node annotations from NodeFeatureRules #4")
786-
eventuallyNonControlPlaneNodes(ctx, f.ClientSet).Should(MatchAnnotations(expectedAnnotations, nodes, true))
791+
eventuallyNonControlPlaneNodes(ctx, f.ClientSet).Should(MatchAnnotations(expectedAnnotations, nodes, false))
787792

788793
By("Verfiying node status capacity from NodeFeatureRules #4")
789794
eventuallyNonControlPlaneNodes(ctx, f.ClientSet).Should(MatchCapacity(expectedCapacity, nodes, false))
@@ -794,7 +799,9 @@ core:
794799

795800
By("Verfiying node status capacity from NodeFeatureRules #4")
796801
expectedCapacity = map[string]corev1.ResourceList{"*": {}}
802+
delete(expectedAnnotations["*"], "nfd.node.kubernetes.io/extended-resources")
797803
eventuallyNonControlPlaneNodes(ctx, f.ClientSet).Should(MatchCapacity(expectedCapacity, nodes, false))
804+
eventuallyNonControlPlaneNodes(ctx, f.ClientSet).Should(MatchAnnotations(expectedAnnotations, nodes, false))
798805

799806
By("Deleting nfd-worker daemonset")
800807
err = f.ClientSet.AppsV1().DaemonSets(f.Namespace.Name).Delete(ctx, workerDS.Name, metav1.DeleteOptions{})

0 commit comments

Comments
 (0)