From b671cd4134f814f3dd181797caac4c5203edf26d Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Sun, 12 Jun 2016 11:14:17 -0700 Subject: [PATCH] Test fixes --- client/task_runner_test.go | 50 ++------------------------------------ 1 file changed, 2 insertions(+), 48 deletions(-) diff --git a/client/task_runner_test.go b/client/task_runner_test.go index 00472fb70..ea4f42d2c 100644 --- a/client/task_runner_test.go +++ b/client/task_runner_test.go @@ -13,7 +13,6 @@ import ( "github.com/hashicorp/nomad/client/allocdir" "github.com/hashicorp/nomad/client/config" "github.com/hashicorp/nomad/client/driver" - cstructs "github.com/hashicorp/nomad/client/driver/structs" "github.com/hashicorp/nomad/nomad/mock" "github.com/hashicorp/nomad/nomad/structs" "github.com/hashicorp/nomad/testutil" @@ -133,8 +132,8 @@ func TestTaskRunner_Destroy(t *testing.T) { // Make sure we are collecting afew stats time.Sleep(2 * time.Second) - stats := tr.StatsReporter().ResourceUsage() - if len(stats) == 0 { + stats := tr.LatestResourceUsage() + if len(stats.Pids) == 0 || stats.ResourceUsage == nil || stats.ResourceUsage.MemoryStats.RSS == 0 { t.Fatalf("expected task runner to have some stats") } @@ -404,49 +403,4 @@ func TestTaskRunner_Validate_UserEnforcement(t *testing.T) { if err := tr.validateTask(); err != nil { t.Fatalf("unexpected error: %v", err) } - -} - -func TestTaskRunnerResouseUsageTS(t *testing.T) { - _, tr := testTaskRunner(false) - - t1, _ := time.Parse(time.RFC822, "02 Jan 06 15:03 MST") - t2, _ := time.Parse(time.RFC822, "02 Jan 06 15:05 MST") - t3, _ := time.Parse(time.RFC822, "02 Jan 06 15:06 MST") - t4, _ := time.Parse(time.RFC822, "02 Jan 06 15:07 MST") - t5, _ := time.Parse(time.RFC822, "02 Jan 06 15:08 MST") - - ru1 := cstructs.TaskResourceUsage{Timestamp: t1.UnixNano()} - ru2 := cstructs.TaskResourceUsage{Timestamp: t2.UnixNano()} - ru3 := cstructs.TaskResourceUsage{Timestamp: t3.UnixNano()} - ru4 := cstructs.TaskResourceUsage{Timestamp: t4.UnixNano()} - ru5 := cstructs.TaskResourceUsage{Timestamp: t5.UnixNano()} - - tr.resourceUsage.Enqueue(&ru1) - tr.resourceUsage.Enqueue(&ru2) - tr.resourceUsage.Enqueue(&ru3) - tr.resourceUsage.Enqueue(&ru4) - tr.resourceUsage.Enqueue(&ru5) - - values := tr.ResourceUsageTS(t3.Add(-1 * time.Second).UnixNano()) - if len(values) != 3 { - t.Fatalf("expected values: 3, actual: %v", len(values)) - } - - values = tr.ResourceUsageTS(t3.UnixNano()) - if len(values) != 3 { - t.Fatalf("expected values: 3, actual: %v", len(values)) - } - - begenning, _ := time.Parse(time.RFC822, "01 Jan 1970 00:00 UTC") - values = tr.ResourceUsageTS(begenning.UnixNano()) - if len(values) != 5 { - t.Fatalf("expected values: 5, actual: %v", len(values)) - } - - values = tr.ResourceUsageTS(t5.Add(1 * time.Second).UnixNano()) - if len(values) != 0 { - t.Fatalf("expected values: 3, actual: %v", len(values)) - } - }