github.com/mattyr/nomad@v0.3.3-0.20160919021406-3485a065154a/api/util_test.go (about)

     1  package api
     2  
     3  import "testing"
     4  
     5  func assertQueryMeta(t *testing.T, qm *QueryMeta) {
     6  	if qm.LastIndex == 0 {
     7  		t.Fatalf("bad index: %d", qm.LastIndex)
     8  	}
     9  	if !qm.KnownLeader {
    10  		t.Fatalf("expected known leader, got none")
    11  	}
    12  }
    13  
    14  func assertWriteMeta(t *testing.T, wm *WriteMeta) {
    15  	if wm.LastIndex == 0 {
    16  		t.Fatalf("bad index: %d", wm.LastIndex)
    17  	}
    18  }
    19  
    20  func testJob() *Job {
    21  	task := NewTask("task1", "exec").
    22  		SetConfig("command", "/bin/sleep").
    23  		Require(&Resources{
    24  			CPU:      100,
    25  			MemoryMB: 256,
    26  			IOPS:     10,
    27  		}).
    28  		SetLogConfig(&LogConfig{
    29  			MaxFiles:      1,
    30  			MaxFileSizeMB: 2,
    31  		})
    32  
    33  	group := NewTaskGroup("group1", 1).
    34  		AddTask(task).
    35  		RequireDisk(&EphemeralDisk{
    36  			SizeMB: 25,
    37  		})
    38  
    39  	job := NewBatchJob("job1", "redis", "region1", 1).
    40  		AddDatacenter("dc1").
    41  		AddTaskGroup(group)
    42  
    43  	return job
    44  }
    45  
    46  func testPeriodicJob() *Job {
    47  	job := testJob().AddPeriodicConfig(&PeriodicConfig{
    48  		Enabled:  true,
    49  		Spec:     "*/30 * * * *",
    50  		SpecType: "cron",
    51  	})
    52  	return job
    53  }