1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2025-03-06 16:57:10 +00:00

Add unit tests for invalid feature in the compatibility spec

Signed-off-by: Marcin Franczyk <marcin0franczyk@gmail.com>
This commit is contained in:
Marcin Franczyk 2025-01-09 10:16:34 +01:00
parent 241c886bf9
commit 8db03fe0f8
No known key found for this signature in database
GPG key ID: F9AC05762F39A284
2 changed files with 26 additions and 1 deletions

View file

@ -268,10 +268,11 @@ func evaluateFeatureMatcher(m *nfdv1alpha1.FeatureMatcher, features *nfdv1alpha1
fA, okA := features.Attributes[featureName]
fI, okI := features.Instances[featureName]
if !okF && !okA && !okI {
if failFast {
klog.V(2).InfoS("feature not available", "featureName", featureName)
if failFast {
return false, nil, nil
}
isMatch = false
continue
}

View file

@ -114,6 +114,17 @@ func TestNodeValidator(t *testing.T) {
},
},
},
{
Name: "fake_5",
MatchFeatures: v1alpha1.FeatureMatcher{
{
Feature: "unknown.unknown",
MatchExpressions: &v1alpha1.MatchExpressionSet{
"name": &v1alpha1.MatchExpression{Op: v1alpha1.MatchIn, Value: v1alpha1.MatchValue{"instance_1"}},
},
},
},
},
},
},
},
@ -219,6 +230,19 @@ func TestNodeValidator(t *testing.T) {
},
},
},
{
Name: "fake_5",
IsMatch: false,
MatchedExpressions: []MatchedExpression{
{
Feature: "unknown.unknown",
Name: "name",
Expression: &v1alpha1.MatchExpression{Op: v1alpha1.MatchIn, Value: v1alpha1.MatchValue{"instance_1"}},
MatcherType: MatchExpressionType,
IsMatch: false,
},
},
},
},
},
}