From 13a50e3b97ed70753a07a6b4654448ef096d2a76 Mon Sep 17 00:00:00 2001 From: Random-Liu Date: Wed, 10 Aug 2016 12:51:55 -0700 Subject: [PATCH] Add containerize flag to avoid starting kubelet and collecting logs. --- test/e2e/framework/test_context.go | 9 +++++++ test/e2e_node/services/services.go | 40 ++++++++++++++++-------------- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/test/e2e/framework/test_context.go b/test/e2e/framework/test_context.go index 1d67e3c81d5..e726a78dcfb 100644 --- a/test/e2e/framework/test_context.go +++ b/test/e2e/framework/test_context.go @@ -102,6 +102,8 @@ type TestContextType struct { type NodeTestContextType struct { // Name of the node to run tests on (node e2e suite only). NodeName string + // NodeConformance indicates whether the test is running in node conformance mode. + NodeConformance bool // DisableKubenet disables kubenet when starting kubelet. DisableKubenet bool // Whether to enable the QoS Cgroup Hierarchy or not @@ -209,6 +211,13 @@ func RegisterClusterFlags() { // Register flags specific to the node e2e test suite. func RegisterNodeFlags() { flag.StringVar(&TestContext.NodeName, "node-name", "", "Name of the node to run tests on (node e2e suite only).") + // 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, rkt, 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. + flag.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.") // TODO(random-liu): Remove kubelet related flags when we move the kubelet start logic out of the test. // TODO(random-liu): Find someway to get kubelet configuration, and automatic config and filter test based on the configuration. flag.BoolVar(&TestContext.DisableKubenet, "disable-kubenet", false, "If true, start kubelet without kubenet. (default false)") diff --git a/test/e2e_node/services/services.go b/test/e2e_node/services/services.go index b6f4ba6c2c4..4570c372e9b 100644 --- a/test/e2e_node/services/services.go +++ b/test/e2e_node/services/services.go @@ -78,16 +78,18 @@ func NewE2EServices(monitorParent bool) *E2EServices { // standard kubelet launcher) func (e *E2EServices) Start() error { var err error - // Start kubelet - // Create the manifest path for kubelet. - // TODO(random-liu): Remove related logic when we move kubelet starting logic out of the test. - framework.TestContext.ManifestPath, err = ioutil.TempDir("", "node-e2e-pod") - if err != nil { - return fmt.Errorf("failed to create static pod manifest directory: %v", err) - } - e.kubelet, err = e.startKubelet() - if err != nil { - return fmt.Errorf("failed to start kubelet: %v", err) + if !framework.TestContext.NodeConformance { + // Start kubelet + // Create the manifest path for kubelet. + // TODO(random-liu): Remove related logic when we move kubelet starting logic out of the test. + framework.TestContext.ManifestPath, err = ioutil.TempDir("", "node-e2e-pod") + if err != nil { + return fmt.Errorf("failed to create static pod manifest directory: %v", err) + } + e.kubelet, err = e.startKubelet() + if err != nil { + return fmt.Errorf("failed to start kubelet: %v", err) + } } e.services, err = e.startInternalServices() return err @@ -96,14 +98,16 @@ func (e *E2EServices) Start() error { // Stop stops the e2e services. func (e *E2EServices) Stop() { defer func() { - // Collect log files. - e.getLogFiles() - // Cleanup the manifest path for kubelet. - manifestPath := framework.TestContext.ManifestPath - if manifestPath != "" { - err := os.RemoveAll(manifestPath) - if err != nil { - glog.Errorf("Failed to delete static pod manifest directory %s: %v", manifestPath, err) + if !framework.TestContext.NodeConformance { + // Collect log files. + e.getLogFiles() + // Cleanup the manifest path for kubelet. + manifestPath := framework.TestContext.ManifestPath + if manifestPath != "" { + err := os.RemoveAll(manifestPath) + if err != nil { + glog.Errorf("Failed to delete static pod manifest directory %s: %v", manifestPath, err) + } } } }()