backfill region from job hcl in jobUpdate and jobPlan endpoints

- updated region in job metadata that gets persisted to nomad datastore
- fixed many unrelated unit tests that used an invalid region value
(they previously passed because hcl wasn't getting picked up and
the job would default to global region)
This commit is contained in:
Jasmine Dahilig
2019-05-02 13:00:21 -07:00
parent 01c267b92b
commit c467a94e2b
13 changed files with 210 additions and 22 deletions

View File

@@ -37,7 +37,7 @@ func TestCompose(t *testing.T) {
AddTask(task)
// Compose a job
job := NewServiceJob("job1", "myjob", "region1", 2).
job := NewServiceJob("job1", "myjob", "global", 2).
SetMeta("foo", "bar").
AddDatacenter("dc1").
Constrain(NewConstraint("kernel.name", "=", "linux")).
@@ -45,7 +45,7 @@ func TestCompose(t *testing.T) {
// Check that the composed result looks correct
expect := &Job{
Region: stringToPtr("region1"),
Region: stringToPtr("global"),
ID: stringToPtr("job1"),
Name: stringToPtr("myjob"),
Type: stringToPtr(JobTypeService),

View File

@@ -1206,9 +1206,9 @@ func TestJobs_JobSummary(t *testing.T) {
func TestJobs_NewBatchJob(t *testing.T) {
t.Parallel()
job := NewBatchJob("job1", "myjob", "region1", 5)
job := NewBatchJob("job1", "myjob", "global", 5)
expect := &Job{
Region: stringToPtr("region1"),
Region: stringToPtr("global"),
ID: stringToPtr("job1"),
Name: stringToPtr("myjob"),
Type: stringToPtr(JobTypeBatch),
@@ -1221,9 +1221,9 @@ func TestJobs_NewBatchJob(t *testing.T) {
func TestJobs_NewServiceJob(t *testing.T) {
t.Parallel()
job := NewServiceJob("job1", "myjob", "region1", 5)
job := NewServiceJob("job1", "myjob", "global", 5)
expect := &Job{
Region: stringToPtr("region1"),
Region: stringToPtr("global"),
ID: stringToPtr("job1"),
Name: stringToPtr("myjob"),
Type: stringToPtr(JobTypeService),

View File

@@ -39,7 +39,7 @@ func testJob() *Job {
SizeMB: intToPtr(25),
})
job := NewBatchJob("job1", "redis", "region1", 1).
job := NewBatchJob("job1", "redis", "global", 1).
AddDatacenter("dc1").
AddTaskGroup(group)