Tests
This commit is contained in:
parent
f83b26029e
commit
4748bfd869
|
@ -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)
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue