Skip to content

Commit

Permalink
Convert SIGTERM into SIGINT in e2e test runner.
Browse files Browse the repository at this point in the history
  • Loading branch information
ixdy committed Apr 2, 2015
1 parent 4a3b1a2 commit 8c7d680
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion test/e2e/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -51,13 +54,31 @@ 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) {
testContext = *context
util.ReallyCrash = true
util.InitLogs()
defer util.FlushLogs()
go convertSigTermIntoInterrupt()

if len(testList) != 0 {
if config.GinkgoConfig.FocusString != "" || config.GinkgoConfig.SkipString != "" {
Expand All @@ -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
Expand Down

0 comments on commit 8c7d680

Please sign in to comment.