Ejemplo n.º 1
0
// Test cleanup when remote closes the connection.
func TestConnCloseRemote(t *testing.T) {
	testutils.CheckGoroutines(t, func() {
		local, remote := net.Pipe()
		WrapConn(local)
		remote.Close()
	})
}
Ejemplo n.º 2
0
// 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()
	})
}
Ejemplo n.º 3
0
// 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")
		}
	})
}
Ejemplo n.º 4
0
func TestPoolNoop(t *testing.T) {
	testutils.CheckGoroutines(t, func() {
		f := SetupPoolFixture(t, 1)
		f.TearDown()
	})
}
Ejemplo n.º 5
0
func TestQueueNoop(t *testing.T) {
	testutils.CheckGoroutines(t, func() {
		f := SetupQueueFixture(t, 500, 2)
		f.TearDown()
	})
}
Ejemplo n.º 6
0
// 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")
	})
}