Merge pull request #31760 from Random-Liu/remove-stop-services-option

Automatic merge from submit-queue

Node E2E: Make sure the test framework collect log properly.

Fixes #31537.

It turns out that the service [stop function](https://github.com/kubernetes/kubernetes/blob/master/test/e2e_node/e2e_node_suite_test.go#L135-L139) is never called, because `stop-services` is [always `false`](https://github.com/kubernetes/kubernetes/blob/master/test/e2e_node/runner/remote/run_remote.go#L444). And currently we collect log in the `stop` function.

This PR makes sure the `stop-services` is always true in node e2e. This will fix #31537.

@yujuhong @dchen1107 @vishh
This commit is contained in:
Kubernetes Submit Queue 2016-08-30 22:12:54 -07:00 committed by GitHub
commit e3acd8df71
3 changed files with 13 additions and 5 deletions

View File

@ -168,7 +168,7 @@ else
# Test using the host the script was run on # Test using the host the script was run on
# Provided for backwards compatibility # Provided for backwards compatibility
go run test/e2e_node/runner/local/run_local.go --ginkgo-flags="$ginkgoflags" \ go run test/e2e_node/runner/local/run_local.go --ginkgo-flags="$ginkgoflags" \
--test-flags="--alsologtostderr --v 2 --report-dir=${report} --node-name $(hostname) \ --test-flags="--alsologtostderr --v 4 --report-dir=${report} --node-name $(hostname) \
--start-services=true --stop-services=true $test_args" --build-dependencies=true $test_args" --build-dependencies=true
exit $? exit $?
fi fi

View File

@ -195,8 +195,8 @@ func RunRemote(archive string, host string, cleanup bool, junitFilePrefix string
// Run the tests // Run the tests
cmd = getSshCommand(" && ", cmd = getSshCommand(" && ",
fmt.Sprintf("cd %s", tmp), fmt.Sprintf("cd %s", tmp),
fmt.Sprintf("timeout -k 30s %fs ./ginkgo %s ./e2e_node.test -- --logtostderr --v 2 --stop-services=%t --node-name=%s --report-dir=%s/results --report-prefix=%s %s", fmt.Sprintf("timeout -k 30s %fs ./ginkgo %s ./e2e_node.test -- --logtostderr --v 4 --node-name=%s --report-dir=%s/results --report-prefix=%s %s",
testTimeoutSeconds.Seconds(), ginkgoFlags, cleanup, host, tmp, junitFilePrefix, testArgs), testTimeoutSeconds.Seconds(), ginkgoFlags, host, tmp, junitFilePrefix, testArgs),
) )
aggErrs := []error{} aggErrs := []error{}

View File

@ -87,6 +87,7 @@ func (e *E2EServices) Start() error {
// "--cgroups-per-qos="+strconv.FormatBool(framework.TestContext.CgroupsPerQOS), // "--cgroups-per-qos="+strconv.FormatBool(framework.TestContext.CgroupsPerQOS),
"--manifest-path", framework.TestContext.ManifestPath, "--manifest-path", framework.TestContext.ManifestPath,
"--eviction-hard", framework.TestContext.EvictionHard, "--eviction-hard", framework.TestContext.EvictionHard,
"--logtostderr",
) )
e.services = newServer("services", startCmd, nil, nil, getHealthCheckURLs(), servicesLogFile, false) e.services = newServer("services", startCmd, nil, nil, getHealthCheckURLs(), servicesLogFile, false)
return e.services.start() return e.services.start()
@ -195,6 +196,7 @@ func (es *e2eService) run() error {
} }
func (es *e2eService) start() error { func (es *e2eService) start() error {
glog.Info("Starting e2e services...")
err := es.startEtcd() err := es.startEtcd()
if err != nil { if err != nil {
return err return err
@ -215,7 +217,7 @@ func (es *e2eService) start() error {
if err != nil { if err != nil {
return nil return nil
} }
glog.Info("E2E services started.")
return nil return nil
} }
@ -226,6 +228,7 @@ func (es *e2eService) getLogFiles() {
if framework.TestContext.ReportDir == "" { if framework.TestContext.ReportDir == "" {
return return
} }
glog.Info("Fetching log files...")
journaldFound := isJournaldAvailable() journaldFound := isJournaldAvailable()
for targetFileName, logFileData := range es.logFiles { for targetFileName, logFileData := range es.logFiles {
targetLink := path.Join(framework.TestContext.ReportDir, targetFileName) targetLink := path.Join(framework.TestContext.ReportDir, targetFileName)
@ -234,6 +237,7 @@ func (es *e2eService) getLogFiles() {
if len(logFileData.journalctlCommand) == 0 { if len(logFileData.journalctlCommand) == 0 {
continue continue
} }
glog.Infof("Get log file %q with journalctl command %v.", targetFileName, logFileData.journalctlCommand)
out, err := exec.Command("sudo", append([]string{"journalctl"}, logFileData.journalctlCommand...)...).CombinedOutput() out, err := exec.Command("sudo", append([]string{"journalctl"}, logFileData.journalctlCommand...)...).CombinedOutput()
if err != nil { if err != nil {
glog.Errorf("failed to get %q from journald: %v, %v", targetFileName, string(out), err) glog.Errorf("failed to get %q from journald: %v, %v", targetFileName, string(out), err)
@ -275,6 +279,7 @@ func isJournaldAvailable() bool {
} }
func (es *e2eService) stop() { func (es *e2eService) stop() {
glog.Info("Stopping e2e services...")
es.getLogFiles() es.getLogFiles()
// TODO(random-liu): Use a loop to stop all services after introducing service interface. // TODO(random-liu): Use a loop to stop all services after introducing service interface.
// Stop namespace controller // Stop namespace controller
@ -306,6 +311,7 @@ func (es *e2eService) stop() {
glog.Errorf("Failed to delete directory %s.\n%v", d, err) glog.Errorf("Failed to delete directory %s.\n%v", d, err)
} }
} }
glog.Info("E2E services stopped.")
} }
func (es *e2eService) startEtcd() error { func (es *e2eService) startEtcd() error {
@ -496,6 +502,7 @@ func readinessCheck(urls []string, errCh <-chan error) error {
// Note: restartOnExit == true requires len(s.healthCheckUrls) > 0 to work properly. // Note: restartOnExit == true requires len(s.healthCheckUrls) > 0 to work properly.
func (s *server) start() error { func (s *server) start() error {
glog.Infof("Start server %q with command %q", s.name, commandToString(s.startCommand))
errCh := make(chan error) errCh := make(chan error)
var stopRestartingCh, ackStopRestartingCh chan bool var stopRestartingCh, ackStopRestartingCh chan bool
@ -634,6 +641,7 @@ func (s *server) start() error {
} }
func (s *server) kill() error { func (s *server) kill() error {
glog.Infof("Kill server %q", s.name)
name := s.name name := s.name
cmd := s.startCommand cmd := s.startCommand