1
0
Fork 0
mirror of https://github.com/kubernetes-sigs/node-feature-discovery.git synced 2025-03-14 20:56:42 +00:00

test/e2e: change node-specific config to a list

Change the part of the e2e-test configuration that contains
node-specific expected labels and annotations to a list, instead of a
map. This makes the parsing order deterministic and makes it possible to
e.g. have a default at the end of the list that captures "all the rest".
This commit is contained in:
Markus Lehtonen 2022-06-30 22:49:35 +03:00
parent 9b87c925a6
commit 380936e417
2 changed files with 10 additions and 8 deletions

View file

@ -78,8 +78,8 @@ defaultFeatures:
- "nfd.node.kubernetes.io/worker.version"
- "nfd.node.kubernetes.io/feature-labels"
nodes:
# NOTE: keys here are interpreted as regexps
my-node-regexp-1:
- name: name-of-this-item # name is purely informational
nodeNameRegexp: my-node-regexp-1
expectedLabelValues:
"feature.node.kubernetes.io/cpu-cpuid.ADX": "true"
"feature.node.kubernetes.io/cpu-cpuid.AESNI": "true"

View file

@ -61,16 +61,19 @@ type e2eConfig struct {
DefaultFeatures *struct {
LabelWhitelist lookupMap
AnnotationWhitelist lookupMap
Nodes map[string]nodeConfig
Nodes []nodeConfig
}
}
type nodeConfig struct {
nameRe *regexp.Regexp
Name string
NodeNameRegexp string
ExpectedLabelValues map[string]string
ExpectedLabelKeys lookupMap
ExpectedAnnotationValues map[string]string
ExpectedAnnotationKeys lookupMap
nameRe *regexp.Regexp
}
type lookupMap map[string]struct{}
@ -105,10 +108,9 @@ func readConfig() {
Expect(err).NotTo(HaveOccurred())
// Pre-compile node name matching regexps
for name, nodeConf := range conf.DefaultFeatures.Nodes {
nodeConf.nameRe, err = regexp.Compile(name)
for i, nodeConf := range conf.DefaultFeatures.Nodes {
conf.DefaultFeatures.Nodes[i].nameRe, err = regexp.Compile(nodeConf.NodeNameRegexp)
Expect(err).NotTo(HaveOccurred())
conf.DefaultFeatures.Nodes[name] = nodeConf
}
}
@ -607,7 +609,7 @@ var _ = SIGDescribe("Node Feature Discovery", func() {
var nodeConf *nodeConfig
for _, conf := range fConf.Nodes {
if conf.nameRe.MatchString(node.Name) {
e2elog.Logf("node %q matches rule %q", node.Name, conf.nameRe)
e2elog.Logf("node %q matches rule %q (regexp %q)", node.Name, conf.Name, conf.nameRe)
nodeConf = &conf
break
}