This commit is contained in:
Alex Dadgar 2016-02-02 13:50:30 -08:00
parent f83b26029e
commit 4748bfd869
4 changed files with 15 additions and 6 deletions

View File

@ -40,7 +40,11 @@ func testServer(
func testJob(jobID string) *api.Job {
task := api.NewTask("task1", "exec").
Require(&api.Resources{MemoryMB: 256})
Require(&api.Resources{
MemoryMB: 256,
DiskMB: 20,
CPU: 100,
})
group := api.NewTaskGroup("group1", 1).
AddTask(task)

View File

@ -106,6 +106,7 @@ func Job() *structs.Job {
Resources: &structs.Resources{
CPU: 500,
MemoryMB: 256,
DiskMB: 100,
Networks: []*structs.NetworkResource{
&structs.NetworkResource{
MBits: 50,

View File

@ -1616,8 +1616,7 @@ func (t *Task) Validate() error {
// Validate the resources.
if t.Resources == nil {
mErr.Errors = append(mErr.Errors, errors.New("Missing task resources"))
}
if err := t.Resources.MeetsMinResources(); err != nil {
} else if err := t.Resources.MeetsMinResources(); err != nil {
mErr.Errors = append(mErr.Errors, err)
}

View File

@ -254,7 +254,12 @@ func TestTask_Validate(t *testing.T) {
task = &Task{
Name: "web",
Driver: "docker",
Resources: &Resources{},
Resources: &Resources{
CPU: 100,
DiskMB: 100,
MemoryMB: 100,
IOPS: 10,
},
}
err = task.Validate()
if err != nil {