2015-09-09 01:42:34 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func assertQueryMeta(t *testing.T, qm *QueryMeta) {
|
|
|
|
if qm.LastIndex == 0 {
|
|
|
|
t.Fatalf("bad index: %d", qm.LastIndex)
|
|
|
|
}
|
|
|
|
if !qm.KnownLeader {
|
|
|
|
t.Fatalf("expected known leader, got none")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func assertWriteMeta(t *testing.T, wm *WriteMeta) {
|
|
|
|
if wm.LastIndex == 0 {
|
|
|
|
t.Fatalf("bad index: %d", wm.LastIndex)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func testJob() *Job {
|
2015-09-16 18:42:08 +00:00
|
|
|
task := NewTask("task1", "exec").
|
2016-02-02 21:26:12 +00:00
|
|
|
Require(&Resources{
|
|
|
|
CPU: 100,
|
|
|
|
MemoryMB: 256,
|
|
|
|
DiskMB: 25,
|
|
|
|
IOPS: 10,
|
|
|
|
})
|
2015-09-16 18:42:08 +00:00
|
|
|
|
|
|
|
group := NewTaskGroup("group1", 1).
|
|
|
|
AddTask(task)
|
|
|
|
|
|
|
|
job := NewBatchJob("job1", "redis", "region1", 1).
|
|
|
|
AddDatacenter("dc1").
|
|
|
|
AddTaskGroup(group)
|
|
|
|
|
|
|
|
return job
|
2015-09-09 01:42:34 +00:00
|
|
|
}
|
2016-01-13 18:19:53 +00:00
|
|
|
|
|
|
|
func testPeriodicJob() *Job {
|
|
|
|
job := testJob().AddPeriodicConfig(&PeriodicConfig{
|
|
|
|
Enabled: true,
|
|
|
|
Spec: "*/30 * * * *",
|
|
|
|
SpecType: "cron",
|
|
|
|
})
|
|
|
|
return job
|
|
|
|
}
|