integration: Workaround flaky test around signal

This commit is contained in:
Tatsuhiro Tsujikawa 2015-09-24 00:11:14 +09:00
parent a54062bd5e
commit 25db23e3c8
3 changed files with 6 additions and 0 deletions

View File

@ -10,6 +10,7 @@ import (
"net/http" "net/http"
"syscall" "syscall"
"testing" "testing"
"time"
) )
// TestH1H1PlainGET tests whether simple HTTP/1 GET request works. // TestH1H1PlainGET tests whether simple HTTP/1 GET request works.
@ -140,6 +141,7 @@ func TestH1H1GracefulShutdown(t *testing.T) {
} }
st.cmd.Process.Signal(syscall.SIGQUIT) st.cmd.Process.Signal(syscall.SIGQUIT)
time.Sleep(150 * time.Millisecond)
res, err = st.http1(requestParam{ res, err = st.http1(requestParam{
name: "TestH1H1GracefulShutdown-2", name: "TestH1H1GracefulShutdown-2",

View File

@ -11,6 +11,7 @@ import (
"strings" "strings"
"syscall" "syscall"
"testing" "testing"
"time"
) )
// TestH2H1PlainGET tests whether simple HTTP/2 GET request works. // TestH2H1PlainGET tests whether simple HTTP/2 GET request works.
@ -1175,6 +1176,7 @@ func TestH2H1GracefulShutdown(t *testing.T) {
// send SIGQUIT signal to nghttpx to perform graceful shutdown // send SIGQUIT signal to nghttpx to perform graceful shutdown
st.cmd.Process.Signal(syscall.SIGQUIT) st.cmd.Process.Signal(syscall.SIGQUIT)
time.Sleep(150 * time.Millisecond)
// after signal, finish request body // after signal, finish request body
if err := st.fr.WriteData(1, true, nil); err != nil { if err := st.fr.WriteData(1, true, nil); err != nil {

View File

@ -205,6 +205,8 @@ func (st *serverTester) Close() {
if st.cmd != nil { if st.cmd != nil {
st.cmd.Process.Kill() st.cmd.Process.Kill()
st.cmd.Wait() st.cmd.Wait()
// workaround to unreliable Process.Signal()
time.Sleep(150 * time.Millisecond)
} }
if st.ts != nil { if st.ts != nil {
st.ts.Close() st.ts.Close()