mirror of
https://github.com/kubernetes-sigs/node-feature-discovery.git
synced 2025-03-31 04:04:51 +00:00
The docker image that used during e2e test composed of repo and tag flags that are passed to the test itself. The problem is that the docker image initialized before the flags are parsed. Hence, it will always contains the default flags value. Moving the variable into a separate function, fixing the issue. Also, moving the global variables to `e2e_test.go` since it commonly used by all tests. Signed-off-by: Talor Itzhak <titzhak@redhat.com>
72 lines
2 KiB
Go
72 lines
2 KiB
Go
/*
|
|
Copyright 2015 The Kubernetes Authors.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package e2e
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"math/rand"
|
|
"os"
|
|
"testing"
|
|
"time"
|
|
|
|
"k8s.io/kubernetes/test/e2e"
|
|
"k8s.io/kubernetes/test/e2e/framework"
|
|
"k8s.io/kubernetes/test/e2e/framework/config"
|
|
"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)
|
|
framework.RegisterCommonFlags(flag.CommandLine)
|
|
framework.RegisterClusterFlags(flag.CommandLine)
|
|
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()
|
|
|
|
framework.AfterReadingAllFlags(&framework.TestContext)
|
|
|
|
// TODO: Deprecating repo-root over time... instead just use gobindata_util.go , see #23987.
|
|
// Right now it is still needed, for example by
|
|
// test/e2e/framework/ingress/ingress_utils.go
|
|
// for providing the optional secret.yaml file and by
|
|
// test/e2e/framework/util.go for cluster/log-dump.
|
|
if framework.TestContext.RepoRoot != "" {
|
|
testfiles.AddFileSource(testfiles.RootFileSource{Root: framework.TestContext.RepoRoot})
|
|
}
|
|
|
|
rand.Seed(time.Now().UnixNano())
|
|
os.Exit(m.Run())
|
|
}
|
|
|
|
func TestE2E(t *testing.T) {
|
|
e2e.RunE2ETests(t)
|
|
}
|