Example #1
0
func getTestTask() (tm *metric.ToyMetric, testTask Task) {
	tm = metric.NewToyMetric()
	m := tm
	q := target.NewSimpleQueueLengthTarget(10)

	testTask = Task{
		Target:        q,
		Metric:        m,
		MinContainers: 1,
		MaxContainers: 5,
		MaxDelta:      2,
		IsScalable:    true,
	}

	return tm, testTask
}
Example #2
0
func TestIsRemainder(t *testing.T) {
	r := target.NewRemainderTarget(10)
	q := target.NewQueueLengthTarget(10)
	sq := target.NewSimpleQueueLengthTarget(10)

	testTask := Task{
		Target: r,
	}

	if !testTask.IsRemainder() {
		t.Fatalf("Didn't recognise a remainder task")
	}

	testTask.Target = q
	if testTask.IsRemainder() {
		t.Fatalf("Mistook a queue task for a remainder")
	}

	testTask.Target = sq
	if testTask.IsRemainder() {
		t.Fatalf("Mistook a simple queue task for a remainder")
	}
}