diff --git a/test/e2e/driver.go b/test/e2e/driver.go index e5113ffed6..29db19667d 100644 --- a/test/e2e/driver.go +++ b/test/e2e/driver.go @@ -18,9 +18,12 @@ package e2e import ( "fmt" + "os" + "os/signal" "path" "regexp" "strings" + "syscall" "github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/golang/glog" @@ -51,6 +54,23 @@ func init() { func (t *testResult) Fail() { *t = false } +// Convert any received TERM signals into INT signals. +// The Ginkgo runner only handles SIGINT, so if Jenkins aborts a run, +// we lose all reporting unless we also handle SIGTERM. +// This function never returns. +func convertSigTermIntoInterrupt() { + p, err := os.FindProcess(os.Getpid()) + if err != nil { + glog.Fatalf("Failed looking up own process: %s", err.Error()) + } + c := make(chan os.Signal, 1) + signal.Notify(c, syscall.SIGTERM) + for { + <-c + p.Signal(os.Interrupt) + } +} + // Run each Go end-to-end-test. This function assumes the // creation of a test cluster. func RunE2ETests(context *TestContextType, orderseed int64, times int, reportDir string, testList []string) { @@ -58,6 +78,7 @@ func RunE2ETests(context *TestContextType, orderseed int64, times int, reportDir util.ReallyCrash = true util.InitLogs() defer util.FlushLogs() + go convertSigTermIntoInterrupt() if len(testList) != 0 { if config.GinkgoConfig.FocusString != "" || config.GinkgoConfig.SkipString != "" { @@ -76,7 +97,6 @@ func RunE2ETests(context *TestContextType, orderseed int64, times int, reportDir } // TODO: Make orderseed work again. - var passed testResult = true gomega.RegisterFailHandler(ginkgo.Fail) // Run the existing tests with output to console + JUnit for Jenkins