-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix dispatched optional meta correctly #4403
Changes from all commits
8e453d0
e8f9b40
e325e85
81abf0a
304b752
e79d314
f00875a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -458,6 +458,33 @@ func TestJobEndpoint_Register_ParameterizedJob(t *testing.T) { | |
} | ||
} | ||
|
||
func TestJobEndpoint_Register_Dispatched(t *testing.T) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
t.Parallel() | ||
require := require.New(t) | ||
s1 := TestServer(t, func(c *Config) { | ||
c.NumSchedulers = 0 // Prevent automatic dequeue | ||
}) | ||
defer s1.Shutdown() | ||
codec := rpcClient(t, s1) | ||
testutil.WaitForLeader(t, s1.RPC) | ||
|
||
// Create the register request with a job with 'Dispatch' set to true | ||
job := mock.Job() | ||
job.Dispatched = true | ||
req := &structs.JobRegisterRequest{ | ||
Job: job, | ||
WriteRequest: structs.WriteRequest{ | ||
Region: "global", | ||
Namespace: job.Namespace, | ||
}, | ||
} | ||
|
||
// Fetch the response | ||
var resp structs.JobRegisterResponse | ||
err := msgpackrpc.CallWithCodec(codec, "Job.Register", req, &resp) | ||
require.Error(err) | ||
require.Contains(err.Error(), "job can't be submitted with 'Dispatched'") | ||
} | ||
func TestJobEndpoint_Register_EnforceIndex(t *testing.T) { | ||
t.Parallel() | ||
s1 := TestServer(t, func(c *Config) { | ||
|
@@ -3959,6 +3986,7 @@ func TestJobEndpoint_ValidateJob_KillSignal(t *testing.T) { | |
|
||
func TestJobEndpoint_ValidateJobUpdate(t *testing.T) { | ||
t.Parallel() | ||
require := require.New(t) | ||
old := mock.Job() | ||
new := mock.Job() | ||
|
||
|
@@ -3988,6 +4016,16 @@ func TestJobEndpoint_ValidateJobUpdate(t *testing.T) { | |
} else { | ||
t.Log(err) | ||
} | ||
|
||
new = mock.Job() | ||
new.Dispatched = true | ||
require.Error(validateJobUpdate(old, new), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generally you want to assert the error you are expecting. require.Contains(err.Error(), "foo bar") |
||
"expected err when setting new job to dispatched") | ||
require.Error(validateJobUpdate(nil, new), | ||
"expected err when setting new job to dispatched") | ||
require.Error(validateJobUpdate(new, old), | ||
"expected err when setting dispatched to false") | ||
require.NoError(validateJobUpdate(nil, old)) | ||
} | ||
|
||
func TestJobEndpoint_ValidateJobUpdate_ACL(t *testing.T) { | ||
|
@@ -4343,6 +4381,15 @@ func TestJobEndpoint_Dispatch(t *testing.T) { | |
if out.ParentID != tc.parameterizedJob.ID { | ||
t.Fatalf("bad parent ID") | ||
} | ||
if !out.Dispatched { | ||
t.Fatal("expected dispatched job") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a test that the parameterized stanza is on the job There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
} | ||
if out.IsParameterized() { | ||
t.Fatal("dispatched job should not be parameterized") | ||
} | ||
if out.ParameterizedJob == nil { | ||
t.Fatal("parameter job config should exist") | ||
} | ||
|
||
if tc.noEval { | ||
return | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to delete https://github.com/hashicorp/nomad/pull/4403/files#diff-35c6f86a8cbf16fa487e40ebbc528dadR1410?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔️ e79d314#diff-35c6f86a8cbf16fa487e40ebbc528dadL1410