mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2025-03-15 04:57:56 +00:00
test/e2e: interpret node names in config as regexps
Interpret node names in the e2e test config as regexps instead of plain strings. This makes it a lot easier to maintain a config file where multiple nodes share configuration.
This commit is contained in:
parent
a08fb66fa7
commit
87c412c48e
2 changed files with 20 additions and 4 deletions
|
@ -60,7 +60,8 @@ defaultFeatures:
|
||||||
- "nfd.node.kubernetes.io/worker.version"
|
- "nfd.node.kubernetes.io/worker.version"
|
||||||
- "nfd.node.kubernetes.io/feature-labels"
|
- "nfd.node.kubernetes.io/feature-labels"
|
||||||
nodes:
|
nodes:
|
||||||
my-node-1:
|
# NOTE: keys here are interpreted as regexps
|
||||||
|
my-node-regexp-1:
|
||||||
expectedLabelValues:
|
expectedLabelValues:
|
||||||
"feature.node.kubernetes.io/cpu-cpuid.ADX": "true"
|
"feature.node.kubernetes.io/cpu-cpuid.ADX": "true"
|
||||||
"feature.node.kubernetes.io/cpu-cpuid.AESNI": "true"
|
"feature.node.kubernetes.io/cpu-cpuid.AESNI": "true"
|
||||||
|
|
|
@ -20,6 +20,7 @@ import (
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
@ -57,6 +58,7 @@ type e2eConfig struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type nodeConfig struct {
|
type nodeConfig struct {
|
||||||
|
nameRe *regexp.Regexp
|
||||||
ExpectedLabelValues map[string]string
|
ExpectedLabelValues map[string]string
|
||||||
ExpectedLabelKeys lookupMap
|
ExpectedLabelKeys lookupMap
|
||||||
ExpectedAnnotationValues map[string]string
|
ExpectedAnnotationValues map[string]string
|
||||||
|
@ -93,6 +95,13 @@ func readConfig() {
|
||||||
ginkgo.By("Parsing end-to-end test configuration data")
|
ginkgo.By("Parsing end-to-end test configuration data")
|
||||||
err = yaml.Unmarshal(data, &conf)
|
err = yaml.Unmarshal(data, &conf)
|
||||||
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
||||||
|
|
||||||
|
// Pre-compile node name matching regexps
|
||||||
|
for name, nodeConf := range conf.DefaultFeatures.Nodes {
|
||||||
|
nodeConf.nameRe, err = regexp.Compile(name)
|
||||||
|
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
||||||
|
conf.DefaultFeatures.Nodes[name] = nodeConf
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create required RBAC configuration
|
// Create required RBAC configuration
|
||||||
|
@ -519,11 +528,17 @@ var _ = framework.KubeDescribe("Node Feature Discovery", func() {
|
||||||
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
||||||
|
|
||||||
for _, node := range nodeList.Items {
|
for _, node := range nodeList.Items {
|
||||||
if _, ok := fConf.Nodes[node.Name]; !ok {
|
var nodeConf *nodeConfig
|
||||||
e2elog.Logf("node %q missing from e2e-config, skipping...", node.Name)
|
for _, conf := range fConf.Nodes {
|
||||||
|
if conf.nameRe.MatchString(node.Name) {
|
||||||
|
e2elog.Logf("node %q matches rule %q", node.Name, conf.nameRe)
|
||||||
|
nodeConf = &conf
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if nodeConf == nil {
|
||||||
|
e2elog.Logf("node %q has no matching rule in e2e-config, skipping...", node.Name)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
nodeConf := fConf.Nodes[node.Name]
|
|
||||||
|
|
||||||
// Check labels
|
// Check labels
|
||||||
e2elog.Logf("verifying labels of node %q...", node.Name)
|
e2elog.Logf("verifying labels of node %q...", node.Name)
|
||||||
|
|
Loading…
Add table
Reference in a new issue