From c84a0004167ef266fa0f1c9acebd9b7def20b8f1 Mon Sep 17 00:00:00 2001 From: Diptanu Choudhury Date: Thu, 11 Feb 2016 22:33:41 -0800 Subject: [PATCH] Fixed some more tests --- command/util_test.go | 4 ++-- jobspec/parse_test.go | 14 ++++---------- nomad/structs/structs.go | 6 ++++-- 3 files changed, 10 insertions(+), 14 deletions(-) diff --git a/command/util_test.go b/command/util_test.go index a94497c37..7019b8286 100644 --- a/command/util_test.go +++ b/command/util_test.go @@ -46,8 +46,8 @@ func testJob(jobID string) *api.Job { CPU: 100, }). SetLogConfig(&api.LogConfig{ - MaxFiles: 10, - MaxFileSizeMB: 10, + MaxFiles: 1, + MaxFileSizeMB: 2, }) group := api.NewTaskGroup("group1", 1). diff --git a/jobspec/parse_test.go b/jobspec/parse_test.go index 00e5476c7..3ffb24fac 100644 --- a/jobspec/parse_test.go +++ b/jobspec/parse_test.go @@ -58,10 +58,7 @@ func TestParse(t *testing.T) { Meta: map[string]string{ "my-cool-key": "foobar", }, - LogConfig: &structs.LogConfig{ - MaxFiles: 10, - MaxFileSizeMB: 10, - }, + LogConfig: structs.DefaultLogConfig(), }, }, }, @@ -116,7 +113,7 @@ func TestParse(t *testing.T) { Resources: &structs.Resources{ CPU: 500, MemoryMB: 128, - DiskMB: 10, + DiskMB: 300, IOPS: 0, Networks: []*structs.NetworkResource{ &structs.NetworkResource{ @@ -141,7 +138,7 @@ func TestParse(t *testing.T) { Resources: &structs.Resources{ CPU: 500, MemoryMB: 128, - DiskMB: 10, + DiskMB: 300, IOPS: 30, }, Constraints: []*structs.Constraint{ @@ -151,10 +148,7 @@ func TestParse(t *testing.T) { Operand: "=", }, }, - LogConfig: &structs.LogConfig{ - MaxFiles: 10, - MaxFileSizeMB: 10, - }, + LogConfig: structs.DefaultLogConfig(), }, }, }, diff --git a/nomad/structs/structs.go b/nomad/structs/structs.go index a3e762a71..319baa5af 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -1803,8 +1803,10 @@ func (t *Task) Validate() error { } } - if t.Resources.DiskMB <= (t.LogConfig.MaxFiles * t.LogConfig.MaxFileSizeMB) { - mErr.Errors = append(mErr.Errors, fmt.Errorf("log storage exceeds requested disk capacity")) + if t.LogConfig != nil && t.Resources != nil { + if t.Resources.DiskMB <= (t.LogConfig.MaxFiles * t.LogConfig.MaxFileSizeMB) { + mErr.Errors = append(mErr.Errors, fmt.Errorf("log storage exceeds requested disk capacity")) + } } return mErr.ErrorOrNil() }