test fixes

This commit is contained in:
Alex Dadgar
2017-07-07 13:55:39 -07:00
parent 50e3178d2d
commit beb01f1754
9 changed files with 14 additions and 9 deletions

View File

@@ -206,6 +206,7 @@ func setupTaskEnv(t *testing.T, driver string) (*allocdir.TaskDir, map[string]st
"HELLO": "world",
"lorem": "ipsum",
"NOMAD_ALLOC_ID": alloc.ID,
"NOMAD_ALLOC_INDEX": "0",
"NOMAD_ALLOC_NAME": alloc.Name,
"NOMAD_TASK_NAME": task.Name,
"NOMAD_JOB_NAME": alloc.Job.Name,

View File

@@ -203,6 +203,7 @@ func TestEnvironment_AsList(t *testing.T) {
"NOMAD_META_owner=armon",
"NOMAD_JOB_NAME=my-job",
fmt.Sprintf("NOMAD_ALLOC_ID=%s", a.ID),
"NOMAD_ALLOC_INDEX=0",
}
sort.Strings(act)
sort.Strings(exp)

View File

@@ -965,7 +965,7 @@ func TestHTTP_JobStable(t *testing.T) {
// Check the response
stableResp := obj.(structs.JobStabilityResponse)
if stableResp.JobModifyIndex == 0 {
if stableResp.Index == 0 {
t.Fatalf("bad: %v", stableResp)
}

View File

@@ -27,6 +27,14 @@ func TestDeploymentPromoteCommand_Fails(t *testing.T) {
if code := cmd.Run([]string{"-address=nope", "12"}); code != 1 {
t.Fatalf("expected exit code 1, got: %d", code)
}
if out := ui.ErrorWriter.String(); !strings.Contains(out, "flags must be specified") {
t.Fatalf("expected missing flags error, got: %s", out)
}
ui.ErrorWriter.Reset()
if code := cmd.Run([]string{"-address=nope", "-all", "12"}); code != 1 {
t.Fatalf("expected exit code 1, got: %d", code)
}
if out := ui.ErrorWriter.String(); !strings.Contains(out, "Error retrieving deployment") {
t.Fatalf("expected failed query error, got: %s", out)
}

View File

@@ -48,7 +48,7 @@ func TestNodeStatusCommand_Self(t *testing.T) {
if !strings.Contains(out, "mynode") {
t.Fatalf("expect to find mynode, got: %s", out)
}
if strings.Contains(out, "Allocations") {
if !strings.Contains(out, "No allocations placed") {
t.Fatalf("should not dump allocations")
}
ui.OutputWriter.Reset()
@@ -119,7 +119,7 @@ func TestNodeStatusCommand_Run(t *testing.T) {
if !strings.Contains(out, "mynode") {
t.Fatalf("expect to find mynode, got: %s", out)
}
if strings.Contains(out, "Allocations") {
if !strings.Contains(out, "No allocations placed") {
t.Fatalf("should not dump allocations")
}

View File

@@ -46,7 +46,7 @@ func TestParse(t *testing.T) {
},
Update: &api.UpdateStrategy{
Stagger: 60 * time.Second,
Stagger: helper.TimeToPtr(60 * time.Second),
MaxParallel: helper.IntToPtr(2),
HealthCheck: helper.StringToPtr("manual"),
MinHealthyTime: helper.TimeToPtr(10 * time.Second),

View File

@@ -430,7 +430,6 @@ func (j *Job) Stable(args *structs.JobStabilityRequest, reply *structs.JobStabil
}
// Setup the reply
reply.JobModifyIndex = modifyIndex
reply.Index = modifyIndex
return nil
}

View File

@@ -919,9 +919,6 @@ func TestJobEndpoint_Stable(t *testing.T) {
if !out.Stable {
t.Fatalf("Job is not marked stable")
}
if out.JobModifyIndex != stableResp.JobModifyIndex {
t.Fatalf("got job modify index %d; want %d", out.JobModifyIndex, stableResp.JobModifyIndex)
}
}
func TestJobEndpoint_Evaluate(t *testing.T) {

View File

@@ -332,7 +332,6 @@ type JobStabilityRequest struct {
// JobStabilityResponse is the response when marking a job as stable.
type JobStabilityResponse struct {
JobModifyIndex uint64
WriteMeta
}