diff --git a/test/e2e/framework/test_context.go b/test/e2e/framework/test_context.go index 77f5e6ffa24..bb113c18209 100644 --- a/test/e2e/framework/test_context.go +++ b/test/e2e/framework/test_context.go @@ -354,24 +354,6 @@ func RegisterClusterFlags(flags *flag.FlagSet) { flags.DurationVar(&nodeKiller.SimulatedDowntime, "node-killer-simulated-downtime", 10*time.Minute, "A delay between node death and recreation") } -// RegisterNodeFlags registers flags specific to the node e2e test suite. -func RegisterNodeFlags(flags *flag.FlagSet) { - // Mark the test as node e2e when node flags are api.Registry. - TestContext.NodeE2E = true - flags.StringVar(&TestContext.NodeName, "node-name", "", "Name of the node to run tests on.") - // TODO(random-liu): Move kubelet start logic out of the test. - // TODO(random-liu): Move log fetch logic out of the test. - // There are different ways to start kubelet (systemd, initd, docker, manually started etc.) - // and manage logs (journald, upstart etc.). - // For different situation we need to mount different things into the container, run different commands. - // It is hard and unnecessary to deal with the complexity inside the test suite. - flags.BoolVar(&TestContext.NodeConformance, "conformance", false, "If true, the test suite will not start kubelet, and fetch system log (kernel, docker, kubelet log etc.) to the report directory.") - flags.BoolVar(&TestContext.PrepullImages, "prepull-images", true, "If true, prepull images so image pull failures do not cause test failures.") - flags.StringVar(&TestContext.ImageDescription, "image-description", "", "The description of the image which the test will be running on.") - flags.StringVar(&TestContext.SystemSpecName, "system-spec-name", "", "The name of the system spec (e.g., gke) that's used in the node e2e test. The system specs are in test/e2e_node/system/specs/. This is used by the test framework to determine which tests to run for validating the system requirements.") - flags.Var(cliflag.NewMapStringString(&TestContext.ExtraEnvs), "extra-envs", "The extra environment variables needed for node e2e tests. Format: a list of key=value pairs, e.g., env1=val1,env2=val2") -} - func createKubeConfig(clientCfg *restclient.Config) *clientcmdapi.Config { clusterNick := "cluster" userNick := "user" diff --git a/test/e2e_node/BUILD b/test/e2e_node/BUILD index 2d71a32415e..8a3647533ea 100644 --- a/test/e2e_node/BUILD +++ b/test/e2e_node/BUILD @@ -214,6 +214,7 @@ go_test( "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/yaml:go_default_library", "//staging/src/k8s.io/client-go/tools/cache:go_default_library", + "//staging/src/k8s.io/component-base/cli/flag:go_default_library", "//test/e2e/framework/config:go_default_library", "//test/e2e/framework/kubelet:go_default_library", "//test/e2e/framework/perf:go_default_library", @@ -230,6 +231,7 @@ go_test( "//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/util/yaml:go_default_library", "//staging/src/k8s.io/client-go/tools/cache:go_default_library", + "//staging/src/k8s.io/component-base/cli/flag:go_default_library", "//test/e2e/framework/config:go_default_library", "//test/e2e/framework/kubelet:go_default_library", "//test/e2e/framework/perf:go_default_library", diff --git a/test/e2e_node/e2e_node_suite_test.go b/test/e2e_node/e2e_node_suite_test.go index b36caaa2bba..a47a2634632 100644 --- a/test/e2e_node/e2e_node_suite_test.go +++ b/test/e2e_node/e2e_node_suite_test.go @@ -38,6 +38,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" utilyaml "k8s.io/apimachinery/pkg/util/yaml" clientset "k8s.io/client-go/kubernetes" + cliflag "k8s.io/component-base/cli/flag" commontest "k8s.io/kubernetes/test/e2e/common" "k8s.io/kubernetes/test/e2e/framework" e2econfig "k8s.io/kubernetes/test/e2e/framework/config" @@ -62,6 +63,24 @@ var runKubeletMode = flag.Bool("run-kubelet-mode", false, "If true, only start k var systemValidateMode = flag.Bool("system-validate-mode", false, "If true, only run system validation in current process, and not run test.") var systemSpecFile = flag.String("system-spec-file", "", "The name of the system spec file that will be used for node conformance test. If it's unspecified or empty, the default system spec (system.DefaultSysSpec) will be used.") +// registerNodeFlags registers flags specific to the node e2e test suite. +func registerNodeFlags(flags *flag.FlagSet) { + // Mark the test as node e2e when node flags are api.Registry. + framework.TestContext.NodeE2E = true + flags.StringVar(&framework.TestContext.NodeName, "node-name", "", "Name of the node to run tests on.") + // TODO(random-liu): Move kubelet start logic out of the test. + // TODO(random-liu): Move log fetch logic out of the test. + // There are different ways to start kubelet (systemd, initd, docker, manually started etc.) + // and manage logs (journald, upstart etc.). + // For different situation we need to mount different things into the container, run different commands. + // It is hard and unnecessary to deal with the complexity inside the test suite. + flags.BoolVar(&framework.TestContext.NodeConformance, "conformance", false, "If true, the test suite will not start kubelet, and fetch system log (kernel, docker, kubelet log etc.) to the report directory.") + flags.BoolVar(&framework.TestContext.PrepullImages, "prepull-images", true, "If true, prepull images so image pull failures do not cause test failures.") + flags.StringVar(&framework.TestContext.ImageDescription, "image-description", "", "The description of the image which the test will be running on.") + flags.StringVar(&framework.TestContext.SystemSpecName, "system-spec-name", "", "The name of the system spec (e.g., gke) that's used in the node e2e test. The system specs are in test/e2e_node/system/specs/. This is used by the test framework to determine which tests to run for validating the system requirements.") + flags.Var(cliflag.NewMapStringString(&framework.TestContext.ExtraEnvs), "extra-envs", "The extra environment variables needed for node e2e tests. Format: a list of key=value pairs, e.g., env1=val1,env2=val2") +} + func init() { // Enable bindata file lookup as fallback. testfiles.AddFileSource(testfiles.BindataFileSource{ @@ -75,7 +94,7 @@ func TestMain(m *testing.M) { // Copy go flags in TestMain, to ensure go test flags are registered (no longer available in init() as of go1.13) e2econfig.CopyFlags(e2econfig.Flags, flag.CommandLine) framework.RegisterCommonFlags(flag.CommandLine) - framework.RegisterNodeFlags(flag.CommandLine) + registerNodeFlags(flag.CommandLine) pflag.CommandLine.AddGoFlagSet(flag.CommandLine) // Mark the run-services-mode flag as hidden to prevent user from using it. pflag.CommandLine.MarkHidden("run-services-mode")