Esempio n. 1
0
func TestPoolExceedCapacity(t *testing.T) {
	if testing.Short() {
		t.Skip("skipping timeout test in short mode")
	}
	task := pytest.ReadTask(t, "timeout")
	task.Limits.Time = 5
	f := SetupPoolFixture(t, 2)
	for i := 1; i <= 3; i++ {
		f.Conn.Send(pythia.Message{
			Message: pythia.LaunchMsg,
			Id:      fmt.Sprint(i),
			Task:    &task,
		})
	}
	f.Conn.Expect(2, pythia.Message{
		Message: pythia.DoneMsg,
		Id:      "3",
		Status:  pythia.Error,
		Output:  "Pool capacity exceeded",
	})
	f.Conn.Expect(6, pythia.Message{
		Message: pythia.DoneMsg,
		Id:      "1",
		Status:  pythia.Timeout,
		Output:  "Start\n",
	}, pythia.Message{
		Message: pythia.DoneMsg,
		Id:      "2",
		Status:  pythia.Timeout,
		Output:  "Start\n",
	})
	f.TearDown()
}
Esempio n. 2
0
func TestQueueSimple(t *testing.T) {
	f := SetupQueueFixture(t, 500, 2)
	frontend, pool := f.Clients[0], f.Clients[1]
	pool.Send(pythia.Message{
		Message:  pythia.RegisterPoolMsg,
		Capacity: 1,
	})
	task := pytest.ReadTask(t, "hello-world")
	frontend.Send(pythia.Message{
		Message: pythia.LaunchMsg,
		Id:      "test",
		Task:    &task,
		Input:   "Hello world",
	})
	pool.Expect(1, pythia.Message{
		Message: pythia.LaunchMsg,
		Id:      "0:test",
		Task:    &task,
		Input:   "Hello world",
	})
	pool.Send(pythia.Message{
		Message: pythia.DoneMsg,
		Id:      "0:test",
		Status:  pythia.Success,
		Output:  "Hi",
	})
	frontend.Expect(1, pythia.Message{
		Message: pythia.DoneMsg,
		Id:      "test",
		Status:  pythia.Success,
		Output:  "Hi",
	})
	f.TearDown()
}
Esempio n. 3
0
// Aborting a job shall be immediate.
func TestJobAbort(t *testing.T) {
	job := newTestJob(pytest.ReadTask(t, "timeout"), "")
	done := make(chan bool)
	go func() {
		wd := testutils.Watchdog(t, 2)
		status, output := job.Execute()
		wd.Stop()
		testutils.Expect(t, "status", pythia.Abort, status)
		testutils.Expect(t, "output", "Start\n", output)
		done <- true
	}()
	time.Sleep(1 * time.Second)
	job.Abort()
	<-done
}
Esempio n. 4
0
func TestPoolHelloWorld(t *testing.T) {
	task := pytest.ReadTask(t, "hello-world")
	f := SetupPoolFixture(t, 1)
	f.Conn.Send(pythia.Message{
		Message: pythia.LaunchMsg,
		Id:      "hello",
		Task:    &task,
		Input:   "",
	})
	f.Conn.Expect(5, pythia.Message{
		Message: pythia.DoneMsg,
		Id:      "hello",
		Status:  pythia.Success,
		Output:  "Hello world!\n",
	})
	f.TearDown()
}
Esempio n. 5
0
// This task should overflow the output buffer.
func TestJobOverflow(t *testing.T) {
	task := pytest.ReadTask(t, "overflow")
	t.Log("Trying limit 10")
	task.Limits.Output = 10
	runTaskCheck(t, task, "", pythia.Success, "abcde")
	t.Log("Trying limit 6")
	task.Limits.Output = 6
	runTaskCheck(t, task, "", pythia.Success, "abcde")
	t.Log("Trying limit 5")
	task.Limits.Output = 5
	runTaskCheck(t, task, "", pythia.Success, "abcde")
	t.Log("Trying limit 4")
	task.Limits.Output = 4
	runTaskCheck(t, task, "", pythia.Overflow, "abcd")
	t.Log("Trying limit 3")
	task.Limits.Output = 3
	runTaskCheck(t, task, "", pythia.Overflow, "abc")
}
Esempio n. 6
0
// Shortcut for runTask(t, pytest.ReadTask(t, basename), ...)
func run(t *testing.T, basename string, input string, status pythia.Status,
	output string) {
	runTaskCheck(t, pytest.ReadTask(t, basename), input, status, output)
}