Пример #1
0
func TestTimer(t *testing.T) {

	signal := test.NewSignalTester(t)

	pipe := cellnet.NewEventPipe()

	evq := pipe.AddQueue()

	pipe.Start()

	const testTimes = 3

	var count int = testTimes

	cellnet.NewTimer(evq, time.Second, func(t *cellnet.Timer) {
		log.Debugln("timer 1 sec tick")

		signal.Done(1)

		count--

		if count == 0 {
			t.Stop()
			signal.Done(2)
		}
	})

	for i := 0; i < testTimes; i++ {
		signal.WaitAndExpect(1, "timer not tick")
	}

	signal.WaitAndExpect(2, "timer not stop")

}
Пример #2
0
func TestRPC(t *testing.T) {

	signal = test.NewSignalTester(t)

	server()

	client()

}
Пример #3
0
func TestClose(t *testing.T) {

	signal = test.NewSignalTester(t)

	runServer()

	testConnActiveClose()
	testRecvDisconnected()
}
Пример #4
0
func TestGate(t *testing.T) {

	signal = test.NewSignalTester(t)

	routerServer()
	backendServer()
	client()

}
Пример #5
0
func TestIO(t *testing.T) {

	// 屏蔽socket层的调试日志
	golog.SetLevelByString("socket", "error")

	signal = test.NewSignalTester(t)

	// 超时时间为测试时间延迟一会
	signal.SetTimeout((benchmarkSeconds + 5) * time.Second)

	server()

	for i := 0; i < clientCount; i++ {
		go client()
	}

	signal.WaitAndExpect(1, "recv time out")

}
Пример #6
0
func TestDelay(t *testing.T) {

	signal := test.NewSignalTester(t)

	pipe := cellnet.NewEventPipe()

	evq := pipe.AddQueue()

	pipe.Start()

	log.Debugln("delay 1 sec begin")

	evq.DelayPostData(time.Second, func() {

		log.Debugln("delay done")
		signal.Done(1)
	})

	signal.WaitAndExpect(1, "delay not work")
}
Пример #7
0
func TestMongoDB(t *testing.T) {

	signal = test.NewSignalTester(t)

	db()
}