Merge pull request #6388 from ixdy/e2e-sigterm-sigint

Convert SIGTERM into SIGINT in e2e test runner
pull/6/head
Quinton Hoole 2015-04-02 17:03:55 -07:00
commit dca645d416
1 changed files with 21 additions and 1 deletions

View File

@ -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