Skip to content

Commit

Permalink
Merge pull request #1028 from k8stopologyawareschedwg/docker_image_init
Browse files Browse the repository at this point in the history
e2e: init docker image
  • Loading branch information
k8s-ci-robot authored Jan 11, 2023
2 parents 677783e + 97ca4de commit 497e6c7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
11 changes: 11 additions & 0 deletions test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package e2e

import (
"flag"
"fmt"
"math/rand"
"os"
"testing"
Expand All @@ -29,6 +30,11 @@ import (
"k8s.io/kubernetes/test/e2e/framework/testfiles"
)

var (
dockerRepo = flag.String("nfd.repo", "gcr.io/k8s-staging-nfd/node-feature-discovery", "Docker repository to fetch image from")
dockerTag = flag.String("nfd.tag", "master", "Docker tag to use")
)

// handleFlags sets up all flags and parses the command line.
func handleFlags() {
config.CopyFlags(config.Flags, flag.CommandLine)
Expand All @@ -37,6 +43,11 @@ func handleFlags() {
flag.Parse()
}

// must be called after flags are parsed
func dockerImage() string {
return fmt.Sprintf("%s:%s", *dockerRepo, *dockerTag)
}

func TestMain(m *testing.M) {
// Register test flags, then parse flags.
handleFlags()
Expand Down
16 changes: 6 additions & 10 deletions test/e2e/node_feature_discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package e2e

import (
"context"
"flag"
"fmt"
"path/filepath"
"strings"
Expand Down Expand Up @@ -49,9 +48,6 @@ import (
)

var (
dockerRepo = flag.String("nfd.repo", "gcr.io/k8s-staging-nfd/node-feature-discovery", "Docker repository to fetch image from")
dockerTag = flag.String("nfd.tag", "master", "Docker tag to use")
dockerImage = fmt.Sprintf("%s:%s", *dockerRepo, *dockerTag)
testTolerations = []corev1.Toleration{
{
Key: "nfd.node.kubernetes.io/fake-special-node",
Expand Down Expand Up @@ -216,7 +212,7 @@ var _ = SIGDescribe("Node Feature Discovery", func() {
// Launch nfd-master
By("Creating nfd master pod and nfd-master service")
podSpecOpts := createPodSpecOpts(
testpod.SpecWithContainerImage(dockerImage),
testpod.SpecWithContainerImage(dockerImage()),
testpod.SpecWithTolerations(testTolerations),
testpod.SpecWithContainerExtraArgs("-enable-taints"),
)
Expand Down Expand Up @@ -265,7 +261,7 @@ var _ = SIGDescribe("Node Feature Discovery", func() {
By("Creating a nfd worker pod")
podSpecOpts := createPodSpecOpts(
testpod.SpecWithRestartPolicy(corev1.RestartPolicyNever),
testpod.SpecWithContainerImage(dockerImage),
testpod.SpecWithContainerImage(dockerImage()),
testpod.SpecWithContainerExtraArgs("-oneshot", "-label-sources=fake"),
testpod.SpecWithTolerations(testTolerations),
)
Expand Down Expand Up @@ -318,7 +314,7 @@ var _ = SIGDescribe("Node Feature Discovery", func() {

By("Creating nfd-worker daemonset")
podSpecOpts := createPodSpecOpts(
testpod.SpecWithContainerImage(dockerImage),
testpod.SpecWithContainerImage(dockerImage()),
testpod.SpecWithTolerations(testTolerations),
)
workerDS := testds.NFDWorker(podSpecOpts...)
Expand Down Expand Up @@ -448,7 +444,7 @@ var _ = SIGDescribe("Node Feature Discovery", func() {

By("Creating nfd-worker daemonset with configmap mounted")
podSpecOpts := createPodSpecOpts(
testpod.SpecWithContainerImage(dockerImage),
testpod.SpecWithContainerImage(dockerImage()),
testpod.SpecWithConfigMap(cm1.Name, filepath.Join(custom.Directory, "cm1")),
testpod.SpecWithConfigMap(cm2.Name, filepath.Join(custom.Directory, "cm2")),
testpod.SpecWithTolerations(testTolerations),
Expand Down Expand Up @@ -533,7 +529,7 @@ var _ = SIGDescribe("Node Feature Discovery", func() {

By("Creating nfd-worker daemonset")
podSpecOpts := createPodSpecOpts(
testpod.SpecWithContainerImage(dockerImage),
testpod.SpecWithContainerImage(dockerImage()),
testpod.SpecWithContainerExtraArgs("-label-sources=fake"),
)
workerDS := testds.NFDWorker(podSpecOpts...)
Expand Down Expand Up @@ -599,7 +595,7 @@ core:

By("Creating nfd-worker daemonset")
podSpecOpts := createPodSpecOpts(
testpod.SpecWithContainerImage(dockerImage),
testpod.SpecWithContainerImage(dockerImage()),
testpod.SpecWithConfigMap(cm.Name, "/etc/kubernetes/node-feature-discovery"),
testpod.SpecWithTolerations(testTolerations),
)
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/topology_updater_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ var _ = SIGDescribe("Node Feature Discovery topology updater", func() {
kcfg := cfg.GetKubeletConfig()
By(fmt.Sprintf("Using config (%#v)", kcfg))

podSpecOpts := []testpod.SpecOption{testpod.SpecWithContainerImage(dockerImage)}
podSpecOpts := []testpod.SpecOption{testpod.SpecWithContainerImage(dockerImage())}
topologyUpdaterDaemonSet = testds.NFDTopologyUpdater(kcfg, podSpecOpts...)
})

Expand Down Expand Up @@ -281,7 +281,7 @@ excludeList:
By(fmt.Sprintf("Using config (%#v)", kcfg))

podSpecOpts := []testpod.SpecOption{
testpod.SpecWithContainerImage(dockerImage),
testpod.SpecWithContainerImage(dockerImage()),
testpod.SpecWithConfigMap(cm.Name, "/etc/kubernetes/node-feature-discovery"),
}
topologyUpdaterDaemonSet = testds.NFDTopologyUpdater(kcfg, podSpecOpts...)
Expand Down

0 comments on commit 497e6c7

Please sign in to comment.