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 { func testJob(jobID string) *api.Job {
task := api.NewTask("task1", "exec"). task := api.NewTask("task1", "exec").
Require(&api.Resources{MemoryMB: 256}) Require(&api.Resources{
MemoryMB: 256,
DiskMB: 20,
CPU: 100,
})
group := api.NewTaskGroup("group1", 1). group := api.NewTaskGroup("group1", 1).
AddTask(task) AddTask(task)

View file

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

View file

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

View file

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