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:
parent
241c886bf9
commit
8db03fe0f8
2 changed files with 26 additions and 1 deletions
|
@ -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 {
|
||||
klog.V(2).InfoS("feature not available", "featureName", featureName)
|
||||
if failFast {
|
||||
klog.V(2).InfoS("feature not available", "featureName", featureName)
|
||||
return false, nil, nil
|
||||
}
|
||||
isMatch = false
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue