Skip to content

Commit 6c49283

Browse files
authored
Merge pull request kubernetes#84875 from oomichi/move-test_context
Move RegisterNodeFlags() to e2e_node test
2 parents ded6ee9 + aef8355 commit 6c49283

File tree

3 files changed

+22
-19
lines changed

3 files changed

+22
-19
lines changed

test/e2e/framework/test_context.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -354,24 +354,6 @@ func RegisterClusterFlags(flags *flag.FlagSet) {
354354
flags.DurationVar(&nodeKiller.SimulatedDowntime, "node-killer-simulated-downtime", 10*time.Minute, "A delay between node death and recreation")
355355
}
356356

357-
// RegisterNodeFlags registers flags specific to the node e2e test suite.
358-
func RegisterNodeFlags(flags *flag.FlagSet) {
359-
// Mark the test as node e2e when node flags are api.Registry.
360-
TestContext.NodeE2E = true
361-
flags.StringVar(&TestContext.NodeName, "node-name", "", "Name of the node to run tests on.")
362-
// TODO(random-liu): Move kubelet start logic out of the test.
363-
// TODO(random-liu): Move log fetch logic out of the test.
364-
// There are different ways to start kubelet (systemd, initd, docker, manually started etc.)
365-
// and manage logs (journald, upstart etc.).
366-
// For different situation we need to mount different things into the container, run different commands.
367-
// It is hard and unnecessary to deal with the complexity inside the test suite.
368-
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.")
369-
flags.BoolVar(&TestContext.PrepullImages, "prepull-images", true, "If true, prepull images so image pull failures do not cause test failures.")
370-
flags.StringVar(&TestContext.ImageDescription, "image-description", "", "The description of the image which the test will be running on.")
371-
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.")
372-
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")
373-
}
374-
375357
func createKubeConfig(clientCfg *restclient.Config) *clientcmdapi.Config {
376358
clusterNick := "cluster"
377359
userNick := "user"

test/e2e_node/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ go_test(
214214
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
215215
"//staging/src/k8s.io/apimachinery/pkg/util/yaml:go_default_library",
216216
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
217+
"//staging/src/k8s.io/component-base/cli/flag:go_default_library",
217218
"//test/e2e/framework/config:go_default_library",
218219
"//test/e2e/framework/kubelet:go_default_library",
219220
"//test/e2e/framework/perf:go_default_library",
@@ -230,6 +231,7 @@ go_test(
230231
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
231232
"//staging/src/k8s.io/apimachinery/pkg/util/yaml:go_default_library",
232233
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
234+
"//staging/src/k8s.io/component-base/cli/flag:go_default_library",
233235
"//test/e2e/framework/config:go_default_library",
234236
"//test/e2e/framework/kubelet:go_default_library",
235237
"//test/e2e/framework/perf:go_default_library",

test/e2e_node/e2e_node_suite_test.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3939
utilyaml "k8s.io/apimachinery/pkg/util/yaml"
4040
clientset "k8s.io/client-go/kubernetes"
41+
cliflag "k8s.io/component-base/cli/flag"
4142
commontest "k8s.io/kubernetes/test/e2e/common"
4243
"k8s.io/kubernetes/test/e2e/framework"
4344
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
6263
var systemValidateMode = flag.Bool("system-validate-mode", false, "If true, only run system validation in current process, and not run test.")
6364
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.")
6465

66+
// registerNodeFlags registers flags specific to the node e2e test suite.
67+
func registerNodeFlags(flags *flag.FlagSet) {
68+
// Mark the test as node e2e when node flags are api.Registry.
69+
framework.TestContext.NodeE2E = true
70+
flags.StringVar(&framework.TestContext.NodeName, "node-name", "", "Name of the node to run tests on.")
71+
// TODO(random-liu): Move kubelet start logic out of the test.
72+
// TODO(random-liu): Move log fetch logic out of the test.
73+
// There are different ways to start kubelet (systemd, initd, docker, manually started etc.)
74+
// and manage logs (journald, upstart etc.).
75+
// For different situation we need to mount different things into the container, run different commands.
76+
// It is hard and unnecessary to deal with the complexity inside the test suite.
77+
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.")
78+
flags.BoolVar(&framework.TestContext.PrepullImages, "prepull-images", true, "If true, prepull images so image pull failures do not cause test failures.")
79+
flags.StringVar(&framework.TestContext.ImageDescription, "image-description", "", "The description of the image which the test will be running on.")
80+
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.")
81+
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")
82+
}
83+
6584
func init() {
6685
// Enable bindata file lookup as fallback.
6786
testfiles.AddFileSource(testfiles.BindataFileSource{
@@ -75,7 +94,7 @@ func TestMain(m *testing.M) {
7594
// Copy go flags in TestMain, to ensure go test flags are registered (no longer available in init() as of go1.13)
7695
e2econfig.CopyFlags(e2econfig.Flags, flag.CommandLine)
7796
framework.RegisterCommonFlags(flag.CommandLine)
78-
framework.RegisterNodeFlags(flag.CommandLine)
97+
registerNodeFlags(flag.CommandLine)
7998
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
8099
// Mark the run-services-mode flag as hidden to prevent user from using it.
81100
pflag.CommandLine.MarkHidden("run-services-mode")

0 commit comments

Comments
 (0)