Skip to content

Commit

Permalink
Clean up after SIGTERM (#145)
Browse files Browse the repository at this point in the history
Signed-off-by: Ken Sipe <[email protected]>
  • Loading branch information
kensipe authored Jun 26, 2020
1 parent 844073c commit 914c2ca
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/test/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"math/rand"
"os"
"os/exec"
"os/signal"
"path/filepath"
"strings"
"sync"
Expand Down Expand Up @@ -357,6 +358,17 @@ func (h *Harness) RunTests() {

// Run the test harness - start the control plane and then run the tests.
func (h *Harness) Run() {

// capture ctrl+c and provide clean up
go func() {
sigchan := make(chan os.Signal, 1)
signal.Notify(sigchan, os.Interrupt)
sig := <-sigchan
h.Stop()
h.T.Log("failed with", sig)
os.Exit(-1)
}()

h.Setup()
h.RunTests()
h.Report()
Expand Down Expand Up @@ -412,6 +424,7 @@ func (h *Harness) Setup() {

// Stop the test environment and clean up the harness.
func (h *Harness) Stop() {
h.T.Log("cleaning up")
if h.managerStopCh != nil {
close(h.managerStopCh)
h.managerStopCh = nil
Expand Down

0 comments on commit 914c2ca

Please sign in to comment.