diff --git a/command/alloc_status.go b/command/alloc_status.go index 9c60ce51e18e..c71dd865b2dd 100644 --- a/command/alloc_status.go +++ b/command/alloc_status.go @@ -220,6 +220,7 @@ func (c *AllocStatusCommand) Run(args []string) int { fmt.Sprintf("Node ID|%s", limit(alloc.NodeID, length)), fmt.Sprintf("Job ID|%s", alloc.JobID), fmt.Sprintf("Client Status|%s", alloc.ClientStatus), + fmt.Sprintf("Created At|%s", formatUnixNanoTime(alloc.CreateTime)), } if verbose { diff --git a/command/alloc_status_test.go b/command/alloc_status_test.go index b284ee15ac18..d966b53b9619 100644 --- a/command/alloc_status_test.go +++ b/command/alloc_status_test.go @@ -4,6 +4,7 @@ import ( "strings" "testing" + "github.com/hashicorp/nomad/testutil" "github.com/mitchellh/cli" ) @@ -71,3 +72,53 @@ func TestAllocStatusCommand_Fails(t *testing.T) { t.Fatalf("expected getting formatter error, got: %s", out) } } + +func TestAllocStatusCommand_Run(t *testing.T) { + srv, client, url := testServer(t, func(c *testutil.TestServerConfig) { + c.DevMode = true + }) + defer srv.Stop() + ui := new(cli.MockUi) + cmd := &AllocStatusCommand{Meta: Meta{Ui: ui}} + + jobID := "job1_sfx" + job1 := testJob(jobID) + evalId1, _, err := client.Jobs().Register(job1, nil) + if err != nil { + t.Fatalf("err: %s", err) + } + if code := waitForSuccess(ui, client, fullId, t, evalId1); code != 0 { + t.Fatalf("status code non zero saw %d", code) + } + // get an alloc id + allocId1 := "" + if allocs, _, err := client.Jobs().Allocations(jobID, nil); err == nil { + if len(allocs) > 0 { + allocId1 = allocs[0].ID + } + } + if allocId1 == "" { + t.Fatal("unable to find an allocation") + } + + if code := cmd.Run([]string{"-address=" + url, allocId1}); code != 0 { + t.Fatalf("expected exit 0, got: %d", code) + } + out := ui.OutputWriter.String() + if !strings.Contains(out, "Created At") { + t.Fatalf("expected to have 'Created At' but saw: %s", out) + } + ui.OutputWriter.Reset() + + if code := cmd.Run([]string{"-address=" + url, "-verbose", allocId1}); code != 0 { + t.Fatalf("expected exit 0, got: %d", code) + } + out = ui.OutputWriter.String() + if !strings.Contains(out, allocId1) { + t.Fatal("expected to find alloc id in output"); + } + if !strings.Contains(out, "Created At") { + t.Fatalf("expected to have 'Created At' but saw: %s", out) + } + ui.OutputWriter.Reset() +} diff --git a/website/source/docs/commands/alloc-status.html.md.erb b/website/source/docs/commands/alloc-status.html.md.erb index 11a592016097..66707e99050e 100644 --- a/website/source/docs/commands/alloc-status.html.md.erb +++ b/website/source/docs/commands/alloc-status.html.md.erb @@ -46,6 +46,7 @@ Name = example.cache[0] Node ID = 1f029d38 Job ID = example Client Status = running +Created At = 29/03/16 03:04:53 UTC ==> Tasks Name State Last Event Time @@ -63,6 +64,7 @@ Name = example.cache[0] Node ID = 1f029d38 Job ID = example Client Status = running +Created At = 29/03/16 03:04:53 UTC ==> Task Resources Task: "redis" @@ -91,13 +93,14 @@ Time Type Description Verbose status can also be accessed: ``` -$ nomad alloc-status a7365fe4 +$ nomad alloc-status --verbose a7365fe4 ID = a7365fe4-cb28-a6e9-f3d4-f99e49c89776 Eval ID = c3c9a1db-dbeb-8afa-0a83-4f1b8b5a03f5 Name = example.cache[0] Node ID = 1f029d38-8d4b-a552-261f-e457b60f9b4b Job ID = example Client Status = running +Created At = 29/03/16 03:04:53 UTC Evaluated Nodes = 1 Filtered Nodes = 0 Exhausted Nodes = 0 diff --git a/website/source/docs/jobops/inspecting.html.md b/website/source/docs/jobops/inspecting.html.md index 9b18f2cfd980..3e83861794fc 100644 --- a/website/source/docs/jobops/inspecting.html.md +++ b/website/source/docs/jobops/inspecting.html.md @@ -90,6 +90,7 @@ Name = example.cache[1] Node ID = 4beef22f Job ID = example Client Status = running +Created At = 06/28/16 15:37:44 UTC Task "redis" is "running" Task Resources @@ -126,6 +127,7 @@ Name = example.cache[0] Node ID = 13063955 Job ID = example Client Status = failed +Created At = 06/28/16 15:50:22 UTC Task "redis" is "dead" Task Resources @@ -153,6 +155,7 @@ Name = example.cache[0] Node ID = 83ef596c Job ID = example Client Status = pending +Created At = 06/28/16 15:55:48 Task "redis" is "pending" Task Resources diff --git a/website/source/docs/jobops/resources.html.md b/website/source/docs/jobops/resources.html.md index d374d68d627a..ff1069c960a0 100644 --- a/website/source/docs/jobops/resources.html.md +++ b/website/source/docs/jobops/resources.html.md @@ -24,6 +24,7 @@ Name = example.cache[0] Node ID = 39acd6e0 Job ID = example Client Status = running +Created At = 06/28/16 16:42:42 UTC Task "redis" is "running" Task Resources diff --git a/website/source/intro/getting-started/jobs.html.md b/website/source/intro/getting-started/jobs.html.md index df15dd161ded..34d32391ef5f 100644 --- a/website/source/intro/getting-started/jobs.html.md +++ b/website/source/intro/getting-started/jobs.html.md @@ -93,6 +93,7 @@ Name = example.cache[0] Node ID = 72687b1a Job ID = example Client Status = running +Created At = 06/23/16 01:41:13 UTC Task "redis" is "running" Task Resources