Пример #1
0
func (ts *testSystem) runTest(timeout int) {
	lspnet.SetWriteDropPercent(ts.dropPercent)
	defer lspnet.ResetDropPercent()

	fmt.Printf("=== %s (%d clients, %d msgs/client, %d%% drop rate, %d window size)\n",
		ts.desc, ts.numClients, ts.numMsgs, ts.dropPercent, ts.params.WindowSize)

	clientDoneChan := make(chan bool, ts.numClients)
	go ts.runServer()
	for i := range ts.clients {
		go ts.runClient(i, clientDoneChan)
	}
	timeoutChan := time.After(time.Duration(timeout) * time.Millisecond)
	for _ = range ts.clients {
		select {
		case <-timeoutChan:
			close(ts.exitChan)
			ts.t.Fatalf("Test timed out after %.2f secs", float64(timeout)/1000.0)
		case ok := <-clientDoneChan:
			if !ok {
				// May or may not close the server goroutine. There's no guarantee
				// since we do not explicitly test the students' Close implementations
				// in these basic tests.
				close(ts.exitChan)
				ts.t.Fatal("Client failed due to an error.")
			}
		}
	}
	close(ts.exitChan)
}
Пример #2
0
func (ts *windowTestSystem) runTest() {
	defer lspnet.ResetDropPercent()
	fmt.Printf("=== %s (%d clients, %d msgs/client, %d window size, %d max epochs)\n",
		ts.desc, ts.numClients, ts.numMsgs, ts.params.WindowSize, ts.maxEpochs)
	ts.timeoutChan = time.After(time.Duration(ts.timeout) * time.Millisecond)
	switch ts.mode {
	case doMaxCapacity:
		ts.runMaxCapacityTest()
	case doScatteredMsgs:
		ts.runScatteredMsgsTest()
	}
}
Пример #3
0
func (ts *syncTestSystem) runTest() {
	defer lspnet.ResetDropPercent()
	fmt.Printf("=== %s (%d clients, %d msgs/client, %d max epochs, %d window size)\n",
		ts.desc, ts.numClients, ts.numMsgs, ts.maxEpochs, ts.params.WindowSize)
	go ts.runNetwork()
	go ts.runServer()
	for i := range ts.clients {
		go ts.runClient(i)
	}
	ts.t.Logf("Setting test to timeout after %d epochs.", ts.maxEpochs)
	ts.timeoutChan = time.After(time.Duration(ts.maxEpochs*ts.params.EpochMillis) * time.Millisecond)
	ts.master()
	close(ts.exitChan)
}