Add containerize flag to avoid starting kubelet and collecting logs.

This commit is contained in:
Random-Liu 2016-08-10 12:51:55 -07:00
parent f7e0c6c19e
commit 13a50e3b97
2 changed files with 31 additions and 18 deletions

View File

@ -102,6 +102,8 @@ type TestContextType struct {
type NodeTestContextType struct { type NodeTestContextType struct {
// Name of the node to run tests on (node e2e suite only). // Name of the node to run tests on (node e2e suite only).
NodeName string NodeName string
// NodeConformance indicates whether the test is running in node conformance mode.
NodeConformance bool
// DisableKubenet disables kubenet when starting kubelet. // DisableKubenet disables kubenet when starting kubelet.
DisableKubenet bool DisableKubenet bool
// Whether to enable the QoS Cgroup Hierarchy or not // Whether to enable the QoS Cgroup Hierarchy or not
@ -209,6 +211,13 @@ func RegisterClusterFlags() {
// Register flags specific to the node e2e test suite. // Register flags specific to the node e2e test suite.
func RegisterNodeFlags() { func RegisterNodeFlags() {
flag.StringVar(&TestContext.NodeName, "node-name", "", "Name of the node to run tests on (node e2e suite only).") 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): 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. // 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)") flag.BoolVar(&TestContext.DisableKubenet, "disable-kubenet", false, "If true, start kubelet without kubenet. (default false)")

View File

@ -78,16 +78,18 @@ func NewE2EServices(monitorParent bool) *E2EServices {
// standard kubelet launcher) // standard kubelet launcher)
func (e *E2EServices) Start() error { func (e *E2EServices) Start() error {
var err error var err error
// Start kubelet if !framework.TestContext.NodeConformance {
// Create the manifest path for kubelet. // Start kubelet
// TODO(random-liu): Remove related logic when we move kubelet starting logic out of the test. // Create the manifest path for kubelet.
framework.TestContext.ManifestPath, err = ioutil.TempDir("", "node-e2e-pod") // TODO(random-liu): Remove related logic when we move kubelet starting logic out of the test.
if err != nil { framework.TestContext.ManifestPath, err = ioutil.TempDir("", "node-e2e-pod")
return fmt.Errorf("failed to create static pod manifest directory: %v", err) if err != nil {
} return fmt.Errorf("failed to create static pod manifest directory: %v", err)
e.kubelet, err = e.startKubelet() }
if err != nil { e.kubelet, err = e.startKubelet()
return fmt.Errorf("failed to start kubelet: %v", err) if err != nil {
return fmt.Errorf("failed to start kubelet: %v", err)
}
} }
e.services, err = e.startInternalServices() e.services, err = e.startInternalServices()
return err return err
@ -96,14 +98,16 @@ func (e *E2EServices) Start() error {
// Stop stops the e2e services. // Stop stops the e2e services.
func (e *E2EServices) Stop() { func (e *E2EServices) Stop() {
defer func() { defer func() {
// Collect log files. if !framework.TestContext.NodeConformance {
e.getLogFiles() // Collect log files.
// Cleanup the manifest path for kubelet. e.getLogFiles()
manifestPath := framework.TestContext.ManifestPath // Cleanup the manifest path for kubelet.
if manifestPath != "" { manifestPath := framework.TestContext.ManifestPath
err := os.RemoveAll(manifestPath) if manifestPath != "" {
if err != nil { err := os.RemoveAll(manifestPath)
glog.Errorf("Failed to delete static pod manifest directory %s: %v", manifestPath, err) if err != nil {
glog.Errorf("Failed to delete static pod manifest directory %s: %v", manifestPath, err)
}
} }
} }
}() }()