// Test cleanup when remote closes the connection. func TestConnCloseRemote(t *testing.T) { testutils.CheckGoroutines(t, func() { local, remote := net.Pipe() WrapConn(local) remote.Close() }) }
// Test cleanup when closing the connection on our side. func TestConnCloseLocal(t *testing.T) { testutils.CheckGoroutines(t, func() { local, _ := net.Pipe() conn := WrapConn(local) conn.Close() }) }
// Check that a connection closes when no keep-alive messages are sent func TestConnKeepAliveClose(t *testing.T) { KeepAliveInterval = 10 * time.Millisecond addr, err := LocalAddr() if err != nil { t.Fatal(err) } l, err := net.Listen(addr.Network(), addr.String()) if err != nil { t.Fatal(err) } defer l.Close() go func() { for { if _, err := l.Accept(); err == nil { t.Log("New connection") } else { break } } }() testutils.CheckGoroutines(t, func() { conn, err := Dial(addr) if err != nil { t.Fatal(err) } defer conn.Close() timer := time.NewTimer(100 * time.Millisecond) defer timer.Stop() select { case msg, ok := <-conn.Receive(): if ok { t.Error("Unexpected message", msg) } case <-timer.C: t.Error("Timeout") } }) }
func TestPoolNoop(t *testing.T) { testutils.CheckGoroutines(t, func() { f := SetupPoolFixture(t, 1) f.TearDown() }) }
func TestQueueNoop(t *testing.T) { testutils.CheckGoroutines(t, func() { f := SetupQueueFixture(t, 500, 2) f.TearDown() }) }
// Check that the goroutines are cleaned correctly. func TestJobCleanup(t *testing.T) { testutils.CheckGoroutines(t, func() { run(t, "hello-world", "", pythia.Success, "Hello world!\n") }) }