From 2f2696f5a90049dc08f332dab15e2d62f24234bc Mon Sep 17 00:00:00 2001 From: Drew Bailey <2614075+drewbailey@users.noreply.github.com> Date: Fri, 16 Oct 2020 13:32:52 -0400 Subject: [PATCH] add msgtype to upsert evals signature, update test call sites with test setup msg type handle snapshot upsert eval outside of FSM and ignore eval event remove placeholder upsertevalsmsgtype handle job plan rpc and prevent event creation for plan msgtype cleanup upsertnodeevents updatenodedrain msgtype msg type 0 is a node registration event, so set the default to the ignore type --- client/client_test.go | 6 +- client/gc_test.go | 2 +- command/agent/deployment_endpoint_test.go | 10 +- command/agent/eval_endpoint_test.go | 8 +- command/agent/fs_endpoint_test.go | 2 +- command/agent/job_endpoint_test.go | 2 +- command/agent/search_endpoint_test.go | 7 +- command/eval_status_test.go | 2 +- command/job_deployments_test.go | 8 +- command/job_dispatch_test.go | 3 +- command/job_eval_test.go | 4 +- command/job_history_test.go | 3 +- command/job_inspect_test.go | 3 +- command/job_periodic_force_test.go | 4 +- command/job_promote_test.go | 3 +- command/job_revert_test.go | 3 +- command/job_status_test.go | 6 +- command/job_stop_test.go | 3 +- command/status_test.go | 12 +- nomad/client_alloc_endpoint_test.go | 28 +- nomad/client_fs_endpoint_test.go | 40 +-- nomad/core_sched_test.go | 68 ++-- nomad/deployment_endpoint_test.go | 48 +-- .../deployments_watcher_test.go | 58 ++-- nomad/deploymentwatcher/testutil_test.go | 2 +- nomad/drainer/draining_node_test.go | 16 +- nomad/drainer/watch_jobs_test.go | 8 +- nomad/drainer/watch_nodes_test.go | 4 +- nomad/eval_endpoint_test.go | 30 +- nomad/fsm.go | 11 +- nomad/fsm_test.go | 34 +- nomad/job_endpoint.go | 7 +- nomad/job_endpoint_test.go | 82 +++-- nomad/node_endpoint_test.go | 16 +- nomad/operator_endpoint_test.go | 2 +- nomad/periodic_endpoint_test.go | 6 +- nomad/periodic_test.go | 14 +- nomad/plan_apply_test.go | 4 +- nomad/search_endpoint_test.go | 10 +- nomad/state/deployment_events_test.go | 2 +- nomad/state/events_test.go | 12 +- nomad/state/state_changes.go | 1 + nomad/state/state_store.go | 58 +--- nomad/state/state_store_test.go | 238 +++++++------- nomad/system_endpoint_test.go | 6 +- nomad/volumewatcher/volumes_watcher_test.go | 2 +- nomad/worker_test.go | 16 +- scheduler/feasible_test.go | 2 +- scheduler/generic_sched_test.go | 296 +++++++++--------- scheduler/system_sched_test.go | 134 ++++---- 50 files changed, 652 insertions(+), 694 deletions(-) diff --git a/client/client_test.go b/client/client_test.go index 7418a950058..a0d0de87cb8 100644 --- a/client/client_test.go +++ b/client/client_test.go @@ -484,7 +484,7 @@ func TestClient_WatchAllocs(t *testing.T) { alloc2.Job = job state := s1.State() - if err := state.UpsertJob(100, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 100, job); err != nil { t.Fatal(err) } if err := state.UpsertJobSummary(101, mock.JobSummary(alloc1.JobID)); err != nil { @@ -581,7 +581,7 @@ func TestClient_SaveRestoreState(t *testing.T) { alloc1.ClientStatus = structs.AllocClientStatusRunning state := s1.State() - if err := state.UpsertJob(100, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 100, job); err != nil { t.Fatal(err) } if err := state.UpsertJobSummary(101, mock.JobSummary(alloc1.JobID)); err != nil { @@ -687,7 +687,7 @@ func TestClient_AddAllocError(t *testing.T) { alloc1.TaskResources = nil state := s1.State() - err := state.UpsertJob(100, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 100, job) require.Nil(err) err = state.UpsertJobSummary(101, mock.JobSummary(alloc1.JobID)) diff --git a/client/gc_test.go b/client/gc_test.go index 93e6c93df1b..fd0061f47a3 100644 --- a/client/gc_test.go +++ b/client/gc_test.go @@ -383,7 +383,7 @@ func TestAllocGarbageCollector_MakeRoomFor_MaxAllocs(t *testing.T) { upsertJobFn := func(server *nomad.Server, j *structs.Job) { state := server.State() - require.NoError(state.UpsertJob(nextIndex(), j)) + require.NoError(state.UpsertJob(structs.MsgTypeTestSetup, nextIndex(), j)) require.NoError(state.UpsertJobSummary(nextIndex(), mock.JobSummary(j.ID))) } diff --git a/command/agent/deployment_endpoint_test.go b/command/agent/deployment_endpoint_test.go index 95a09d7a348..db83c4e8605 100644 --- a/command/agent/deployment_endpoint_test.go +++ b/command/agent/deployment_endpoint_test.go @@ -107,7 +107,7 @@ func TestHTTP_DeploymentAllocations(t *testing.T) { a2.TaskStates = make(map[string]*structs.TaskState) a2.TaskStates["test"] = taskState2 - assert.Nil(state.UpsertJob(998, j), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 998, j), "UpsertJob") assert.Nil(state.UpsertDeployment(999, d), "UpsertDeployment") assert.Nil(state.UpsertAllocs(structs.MsgTypeTestSetup, 1000, []*structs.Allocation{a1, a2}), "UpsertAllocs") @@ -174,7 +174,7 @@ func TestHTTP_DeploymentPause(t *testing.T) { j := mock.Job() d := mock.Deployment() d.JobID = j.ID - assert.Nil(state.UpsertJob(999, j), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, j), "UpsertJob") assert.Nil(state.UpsertDeployment(1000, d), "UpsertDeployment") // Create the pause request @@ -215,7 +215,7 @@ func TestHTTP_DeploymentPromote(t *testing.T) { j := mock.Job() d := mock.Deployment() d.JobID = j.ID - assert.Nil(state.UpsertJob(999, j), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, j), "UpsertJob") assert.Nil(state.UpsertDeployment(1000, d), "UpsertDeployment") // Create the pause request @@ -259,7 +259,7 @@ func TestHTTP_DeploymentAllocHealth(t *testing.T) { a := mock.Alloc() a.JobID = j.ID a.DeploymentID = d.ID - assert.Nil(state.UpsertJob(998, j), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 998, j), "UpsertJob") assert.Nil(state.UpsertDeployment(999, d), "UpsertDeployment") assert.Nil(state.UpsertAllocs(structs.MsgTypeTestSetup, 1000, []*structs.Allocation{a}), "UpsertAllocs") @@ -301,7 +301,7 @@ func TestHTTP_DeploymentFail(t *testing.T) { j := mock.Job() d := mock.Deployment() d.JobID = j.ID - assert.Nil(state.UpsertJob(998, j), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 998, j), "UpsertJob") assert.Nil(state.UpsertDeployment(999, d), "UpsertDeployment") // Make the HTTP request diff --git a/command/agent/eval_endpoint_test.go b/command/agent/eval_endpoint_test.go index 4d3fec7d58f..6f82cbc8f9c 100644 --- a/command/agent/eval_endpoint_test.go +++ b/command/agent/eval_endpoint_test.go @@ -16,8 +16,7 @@ func TestHTTP_EvalList(t *testing.T) { state := s.Agent.server.State() eval1 := mock.Eval() eval2 := mock.Eval() - err := state.UpsertEvals(1000, - []*structs.Evaluation{eval1, eval2}) + err := state.UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval1, eval2}) if err != nil { t.Fatalf("err: %v", err) } @@ -63,8 +62,7 @@ func TestHTTP_EvalPrefixList(t *testing.T) { eval1.ID = "aaabbbbb-e8f7-fd38-c855-ab94ceb89706" eval2 := mock.Eval() eval2.ID = "aaabbbbb-e8f7-fd38-c855-ab94ceb89706" - err := state.UpsertEvals(1000, - []*structs.Evaluation{eval1, eval2}) + err := state.UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval1, eval2}) if err != nil { t.Fatalf("err: %v", err) } @@ -160,7 +158,7 @@ func TestHTTP_EvalQuery(t *testing.T) { // Directly manipulate the state state := s.Agent.server.State() eval := mock.Eval() - err := state.UpsertEvals(1000, []*structs.Evaluation{eval}) + err := state.UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval}) if err != nil { t.Fatalf("err: %v", err) } diff --git a/command/agent/fs_endpoint_test.go b/command/agent/fs_endpoint_test.go index 57c5c753b45..7e0f286b6fc 100644 --- a/command/agent/fs_endpoint_test.go +++ b/command/agent/fs_endpoint_test.go @@ -62,7 +62,7 @@ func addAllocToClient(agent *TestAgent, alloc *structs.Allocation, wait clientAl // Upsert the allocation state := agent.server.State() - require.Nil(state.UpsertJob(999, alloc.Job)) + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, alloc.Job)) require.Nil(state.UpsertAllocs(structs.MsgTypeTestSetup, 1003, []*structs.Allocation{alloc})) if wait == noWaitClientAlloc { diff --git a/command/agent/job_endpoint_test.go b/command/agent/job_endpoint_test.go index 4779297ad75..990c7143493 100644 --- a/command/agent/job_endpoint_test.go +++ b/command/agent/job_endpoint_test.go @@ -407,7 +407,7 @@ func TestHTTP_JobQuery_Payload(t *testing.T) { // Directly manipulate the state state := s.Agent.server.State() - if err := state.UpsertJob(1000, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job); err != nil { t.Fatalf("Failed to upsert job: %v", err) } diff --git a/command/agent/search_endpoint_test.go b/command/agent/search_endpoint_test.go index 2b04f3a5e9f..e1ddd47575a 100644 --- a/command/agent/search_endpoint_test.go +++ b/command/agent/search_endpoint_test.go @@ -31,7 +31,7 @@ func createJobForTest(jobID string, s *TestAgent, t *testing.T) { job.TaskGroups[0].Count = 1 state := s.Agent.server.State() - err := state.UpsertJob(1000, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) assert.Nil(err) } @@ -147,8 +147,7 @@ func TestHTTP_Search_Evaluation(t *testing.T) { state := s.Agent.server.State() eval1 := mock.Eval() eval2 := mock.Eval() - err := state.UpsertEvals(9000, - []*structs.Evaluation{eval1, eval2}) + err := state.UpsertEvals(structs.MsgTypeTestSetup, 9000, []*structs.Evaluation{eval1, eval2}) assert.Nil(err) prefix := eval1.ID[:len(eval1.ID)-2] @@ -307,7 +306,7 @@ func TestHTTP_Search_AllContext(t *testing.T) { state := s.Agent.server.State() eval1 := mock.Eval() eval1.ID = testJobID - err := state.UpsertEvals(8000, []*structs.Evaluation{eval1}) + err := state.UpsertEvals(structs.MsgTypeTestSetup, 8000, []*structs.Evaluation{eval1}) assert.Nil(err) data := structs.SearchRequest{Prefix: testJobPrefix, Context: structs.All} diff --git a/command/eval_status_test.go b/command/eval_status_test.go index 2c37a8ebcb0..f66d2c0f2b0 100644 --- a/command/eval_status_test.go +++ b/command/eval_status_test.go @@ -74,7 +74,7 @@ func TestEvalStatusCommand_AutocompleteArgs(t *testing.T) { // Create a fake eval state := srv.Agent.Server().State() e := mock.Eval() - assert.Nil(state.UpsertEvals(1000, []*structs.Evaluation{e})) + assert.Nil(state.UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{e})) prefix := e.ID[:5] args := complete.Args{Last: prefix} diff --git a/command/job_deployments_test.go b/command/job_deployments_test.go index fb365caf4d0..eb764ba2b5a 100644 --- a/command/job_deployments_test.go +++ b/command/job_deployments_test.go @@ -4,6 +4,8 @@ import ( "strings" "testing" + "github.com/hashicorp/nomad/nomad/structs" + "github.com/hashicorp/nomad/nomad/mock" "github.com/mitchellh/cli" "github.com/posener/complete" @@ -55,7 +57,7 @@ func TestJobDeploymentsCommand_Run(t *testing.T) { // Create a job without a deployment job := mock.Job() state := srv.Agent.Server().State() - assert.Nil(state.UpsertJob(100, job)) + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 100, job)) // Should display no match if the job doesn't have deployments if code := cmd.Run([]string{"-address=" + url, job.ID}); code != 0 { @@ -99,7 +101,7 @@ func TestJobDeploymentsCommand_Run_Latest(t *testing.T) { // Create a job without a deployment job := mock.Job() state := srv.Agent.Server().State() - assert.Nil(state.UpsertJob(100, job)) + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 100, job)) // Should display no match if the job doesn't have deployments if code := cmd.Run([]string{"-address=" + url, "-latest", job.ID}); code != 0 { @@ -139,7 +141,7 @@ func TestJobDeploymentsCommand_AutocompleteArgs(t *testing.T) { // Create a fake job state := srv.Agent.Server().State() j := mock.Job() - assert.Nil(state.UpsertJob(1000, j)) + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 1000, j)) prefix := j.ID[:len(j.ID)-5] args := complete.Args{Last: prefix} diff --git a/command/job_dispatch_test.go b/command/job_dispatch_test.go index b6b36e8c50d..9070e92c7a3 100644 --- a/command/job_dispatch_test.go +++ b/command/job_dispatch_test.go @@ -1,6 +1,7 @@ package command import ( + structs2 "github.com/hashicorp/nomad/nomad/structs" "strings" "testing" @@ -60,7 +61,7 @@ func TestJobDispatchCommand_AutocompleteArgs(t *testing.T) { // Create a fake job state := srv.Agent.Server().State() j := mock.Job() - assert.Nil(state.UpsertJob(1000, j)) + assert.Nil(state.UpsertJob(structs2.MsgTypeTestSetup, 1000, j)) prefix := j.ID[:len(j.ID)-5] args := complete.Args{Last: prefix} diff --git a/command/job_eval_test.go b/command/job_eval_test.go index 3b209f2364c..6bc72df8adc 100644 --- a/command/job_eval_test.go +++ b/command/job_eval_test.go @@ -74,7 +74,7 @@ func TestJobEvalCommand_Run(t *testing.T) { // Create a job job := mock.Job() - err := state.UpsertJob(11, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 11, job) require.Nil(err) job, err = state.JobByID(nil, structs.DefaultNamespace, job.ID) @@ -115,7 +115,7 @@ func TestJobEvalCommand_AutocompleteArgs(t *testing.T) { // Create a fake job state := srv.Agent.Server().State() j := mock.Job() - assert.Nil(state.UpsertJob(1000, j)) + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 1000, j)) prefix := j.ID[:len(j.ID)-5] args := complete.Args{Last: prefix} diff --git a/command/job_history_test.go b/command/job_history_test.go index 13be00b2905..e5cc6ba213e 100644 --- a/command/job_history_test.go +++ b/command/job_history_test.go @@ -1,6 +1,7 @@ package command import ( + structs2 "github.com/hashicorp/nomad/nomad/structs" "strings" "testing" @@ -51,7 +52,7 @@ func TestJobHistoryCommand_AutocompleteArgs(t *testing.T) { // Create a fake job state := srv.Agent.Server().State() j := mock.Job() - assert.Nil(state.UpsertJob(1000, j)) + assert.Nil(state.UpsertJob(structs2.MsgTypeTestSetup, 1000, j)) prefix := j.ID[:len(j.ID)-5] args := complete.Args{Last: prefix} diff --git a/command/job_inspect_test.go b/command/job_inspect_test.go index 6d4e2216604..6f72b4254e4 100644 --- a/command/job_inspect_test.go +++ b/command/job_inspect_test.go @@ -5,6 +5,7 @@ import ( "testing" "github.com/hashicorp/nomad/nomad/mock" + "github.com/hashicorp/nomad/nomad/structs" "github.com/mitchellh/cli" "github.com/posener/complete" "github.com/stretchr/testify/assert" @@ -71,7 +72,7 @@ func TestInspectCommand_AutocompleteArgs(t *testing.T) { state := srv.Agent.Server().State() j := mock.Job() - assert.Nil(state.UpsertJob(1000, j)) + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 1000, j)) prefix := j.ID[:len(j.ID)-5] args := complete.Args{Last: prefix} diff --git a/command/job_periodic_force_test.go b/command/job_periodic_force_test.go index dd57623ae02..8197d0fed61 100644 --- a/command/job_periodic_force_test.go +++ b/command/job_periodic_force_test.go @@ -49,7 +49,7 @@ func TestJobPeriodicForceCommand_AutocompleteArgs(t *testing.T) { // Create a fake job, not periodic state := srv.Agent.Server().State() j := mock.Job() - require.NoError(t, state.UpsertJob(1000, j)) + require.NoError(t, state.UpsertJob(structs.MsgTypeTestSetup, 1000, j)) predictor := cmd.AutocompleteArgs() @@ -66,7 +66,7 @@ func TestJobPeriodicForceCommand_AutocompleteArgs(t *testing.T) { ProhibitOverlap: true, TimeZone: "test zone", } - require.NoError(t, state.UpsertJob(1000, j2)) + require.NoError(t, state.UpsertJob(structs.MsgTypeTestSetup, 1000, j2)) res = predictor.Predict(complete.Args{Last: j2.ID[:len(j.ID)-5]}) require.Equal(t, []string{j2.ID}, res) diff --git a/command/job_promote_test.go b/command/job_promote_test.go index 22d51c78195..832cade454f 100644 --- a/command/job_promote_test.go +++ b/command/job_promote_test.go @@ -1,6 +1,7 @@ package command import ( + structs2 "github.com/hashicorp/nomad/nomad/structs" "strings" "testing" @@ -51,7 +52,7 @@ func TestJobPromoteCommand_AutocompleteArgs(t *testing.T) { // Create a fake job state := srv.Agent.Server().State() j := mock.Job() - assert.Nil(state.UpsertJob(1000, j)) + assert.Nil(state.UpsertJob(structs2.MsgTypeTestSetup, 1000, j)) prefix := j.ID[:len(j.ID)-5] args := complete.Args{Last: prefix} diff --git a/command/job_revert_test.go b/command/job_revert_test.go index c968b4c800a..93948eec99d 100644 --- a/command/job_revert_test.go +++ b/command/job_revert_test.go @@ -1,6 +1,7 @@ package command import ( + structs2 "github.com/hashicorp/nomad/nomad/structs" "strings" "testing" @@ -51,7 +52,7 @@ func TestJobRevertCommand_AutocompleteArgs(t *testing.T) { // Create a fake job state := srv.Agent.Server().State() j := mock.Job() - assert.Nil(state.UpsertJob(1000, j)) + assert.Nil(state.UpsertJob(structs2.MsgTypeTestSetup, 1000, j)) prefix := j.ID[:len(j.ID)-5] args := complete.Args{Last: prefix} diff --git a/command/job_status_test.go b/command/job_status_test.go index 989206021c3..b516a46ea21 100644 --- a/command/job_status_test.go +++ b/command/job_status_test.go @@ -254,7 +254,7 @@ func TestJobStatusCommand_AutocompleteArgs(t *testing.T) { // Create a fake job state := srv.Agent.Server().State() j := mock.Job() - assert.Nil(state.UpsertJob(1000, j)) + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 1000, j)) prefix := j.ID[:len(j.ID)-5] args := complete.Args{Last: prefix} @@ -361,11 +361,11 @@ func TestJobStatusCommand_RescheduleEvals(t *testing.T) { // Create state store objects for job, alloc and followup eval with a future WaitUntil value j := mock.Job() - require.Nil(state.UpsertJob(900, j)) + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 900, j)) e := mock.Eval() e.WaitUntil = time.Now().Add(1 * time.Hour) - require.Nil(state.UpsertEvals(902, []*structs.Evaluation{e})) + require.Nil(state.UpsertEvals(structs.MsgTypeTestSetup, 902, []*structs.Evaluation{e})) a := mock.Alloc() a.Job = j a.JobID = j.ID diff --git a/command/job_stop_test.go b/command/job_stop_test.go index effc00bbc8f..25fde8c2e64 100644 --- a/command/job_stop_test.go +++ b/command/job_stop_test.go @@ -1,6 +1,7 @@ package command import ( + structs2 "github.com/hashicorp/nomad/nomad/structs" "strings" "testing" @@ -63,7 +64,7 @@ func TestStopCommand_AutocompleteArgs(t *testing.T) { // Create a fake job state := srv.Agent.Server().State() j := mock.Job() - assert.Nil(state.UpsertJob(1000, j)) + assert.Nil(state.UpsertJob(structs2.MsgTypeTestSetup, 1000, j)) prefix := j.ID[:len(j.ID)-5] args := complete.Args{Last: prefix} diff --git a/command/status_test.go b/command/status_test.go index 0bd0bfe82c5..810bec86ea3 100644 --- a/command/status_test.go +++ b/command/status_test.go @@ -26,7 +26,7 @@ func TestStatusCommand_Run_JobStatus(t *testing.T) { // Create a fake job state := srv.Agent.Server().State() j := mock.Job() - assert.Nil(state.UpsertJob(1000, j)) + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 1000, j)) // Query to check the job status if code := cmd.Run([]string{"-address=" + url, j.ID}); code != 0 { @@ -54,8 +54,8 @@ func TestStatusCommand_Run_JobStatus_MultiMatch(t *testing.T) { j := mock.Job() j2 := mock.Job() j2.ID = fmt.Sprintf("%s-more", j.ID) - assert.Nil(state.UpsertJob(1000, j)) - assert.Nil(state.UpsertJob(1001, j2)) + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 1000, j)) + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 1001, j2)) // Query to check the job status if code := cmd.Run([]string{"-address=" + url, j.ID}); code != 0 { @@ -81,7 +81,7 @@ func TestStatusCommand_Run_EvalStatus(t *testing.T) { // Create a fake eval state := srv.Agent.Server().State() eval := mock.Eval() - assert.Nil(state.UpsertEvals(1000, []*structs.Evaluation{eval})) + assert.Nil(state.UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval})) // Query to check the eval status if code := cmd.Run([]string{"-address=" + url, eval.ID}); code != 0 { @@ -198,7 +198,7 @@ func TestStatusCommand_Run_NoPrefix(t *testing.T) { // Create a fake job state := srv.Agent.Server().State() job := mock.Job() - assert.Nil(state.UpsertJob(1000, job)) + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 1000, job)) // Query to check status if code := cmd.Run([]string{"-address=" + url}); code != 0 { @@ -224,7 +224,7 @@ func TestStatusCommand_AutocompleteArgs(t *testing.T) { // Create a fake job state := srv.Agent.Server().State() job := mock.Job() - assert.Nil(state.UpsertJob(1000, job)) + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 1000, job)) prefix := job.ID[:len(job.ID)-5] args := complete.Args{Last: prefix} diff --git a/nomad/client_alloc_endpoint_test.go b/nomad/client_alloc_endpoint_test.go index b3d9af55ec8..2693abb8f04 100644 --- a/nomad/client_alloc_endpoint_test.go +++ b/nomad/client_alloc_endpoint_test.go @@ -324,7 +324,7 @@ func TestClientAllocations_GarbageCollect_Local(t *testing.T) { // Upsert the allocation state := s.State() - require.Nil(state.UpsertJob(999, a.Job)) + require.Nil(state.UpsertJob(nstructs.MsgTypeTestSetup, 999, a.Job)) require.Nil(state.UpsertAllocs(nstructs.MsgTypeTestSetup, 1003, []*structs.Allocation{a})) // Wait for the client to run the allocation @@ -382,7 +382,7 @@ func TestClientAllocations_GarbageCollect_Local_ACL(t *testing.T) { // Upsert the allocation state := s.State() alloc := mock.Alloc() - require.NoError(t, state.UpsertJob(1010, alloc.Job)) + require.NoError(t, state.UpsertJob(nstructs.MsgTypeTestSetup, 1010, alloc.Job)) require.NoError(t, state.UpsertAllocs(nstructs.MsgTypeTestSetup, 1011, []*structs.Allocation{alloc})) cases := []struct { @@ -492,9 +492,9 @@ func TestClientAllocations_GarbageCollect_Remote(t *testing.T) { // Upsert the allocation state1 := s1.State() state2 := s2.State() - require.Nil(state1.UpsertJob(999, a.Job)) + require.Nil(state1.UpsertJob(nstructs.MsgTypeTestSetup, 999, a.Job)) require.Nil(state1.UpsertAllocs(nstructs.MsgTypeTestSetup, 1003, []*structs.Allocation{a})) - require.Nil(state2.UpsertJob(999, a.Job)) + require.Nil(state2.UpsertJob(nstructs.MsgTypeTestSetup, 999, a.Job)) require.Nil(state2.UpsertAllocs(nstructs.MsgTypeTestSetup, 1003, []*structs.Allocation{a})) // Wait for the client to run the allocation @@ -613,7 +613,7 @@ func TestClientAllocations_Stats_Local(t *testing.T) { // Upsert the allocation state := s.State() - require.Nil(state.UpsertJob(999, a.Job)) + require.Nil(state.UpsertJob(nstructs.MsgTypeTestSetup, 999, a.Job)) require.Nil(state.UpsertAllocs(nstructs.MsgTypeTestSetup, 1003, []*structs.Allocation{a})) // Wait for the client to run the allocation @@ -672,7 +672,7 @@ func TestClientAllocations_Stats_Local_ACL(t *testing.T) { // Upsert the allocation state := s.State() alloc := mock.Alloc() - require.NoError(t, state.UpsertJob(1010, alloc.Job)) + require.NoError(t, state.UpsertJob(nstructs.MsgTypeTestSetup, 1010, alloc.Job)) require.NoError(t, state.UpsertAllocs(nstructs.MsgTypeTestSetup, 1011, []*structs.Allocation{alloc})) cases := []struct { @@ -769,9 +769,9 @@ func TestClientAllocations_Stats_Remote(t *testing.T) { // Upsert the allocation state1 := s1.State() state2 := s2.State() - require.Nil(state1.UpsertJob(999, a.Job)) + require.Nil(state1.UpsertJob(nstructs.MsgTypeTestSetup, 999, a.Job)) require.Nil(state1.UpsertAllocs(nstructs.MsgTypeTestSetup, 1003, []*structs.Allocation{a})) - require.Nil(state2.UpsertJob(999, a.Job)) + require.Nil(state2.UpsertJob(nstructs.MsgTypeTestSetup, 999, a.Job)) require.Nil(state2.UpsertAllocs(nstructs.MsgTypeTestSetup, 1003, []*structs.Allocation{a})) // Wait for the client to run the allocation @@ -853,7 +853,7 @@ func TestClientAllocations_Restart_Local(t *testing.T) { // Upsert the allocation state := s.State() - require.Nil(state.UpsertJob(999, a.Job)) + require.Nil(state.UpsertJob(nstructs.MsgTypeTestSetup, 999, a.Job)) require.Nil(state.UpsertAllocs(nstructs.MsgTypeTestSetup, 1003, []*structs.Allocation{a})) // Wait for the client to run the allocation @@ -967,9 +967,9 @@ func TestClientAllocations_Restart_Remote(t *testing.T) { // Upsert the allocation state1 := s1.State() state2 := s2.State() - require.Nil(state1.UpsertJob(999, a.Job)) + require.Nil(state1.UpsertJob(nstructs.MsgTypeTestSetup, 999, a.Job)) require.Nil(state1.UpsertAllocs(nstructs.MsgTypeTestSetup, 1003, []*structs.Allocation{a})) - require.Nil(state2.UpsertJob(999, a.Job)) + require.Nil(state2.UpsertJob(nstructs.MsgTypeTestSetup, 999, a.Job)) require.Nil(state2.UpsertAllocs(nstructs.MsgTypeTestSetup, 1003, []*structs.Allocation{a})) // Wait for the client to run the allocation @@ -1026,7 +1026,7 @@ func TestClientAllocations_Restart_ACL(t *testing.T) { // Upsert the allocation state := s.State() alloc := mock.Alloc() - require.NoError(t, state.UpsertJob(1010, alloc.Job)) + require.NoError(t, state.UpsertJob(nstructs.MsgTypeTestSetup, 1010, alloc.Job)) require.NoError(t, state.UpsertAllocs(nstructs.MsgTypeTestSetup, 1011, []*structs.Allocation{alloc})) cases := []struct { @@ -1134,10 +1134,10 @@ func TestAlloc_ExecStreaming(t *testing.T) { // Upsert the allocation localState := localServer.State() - require.Nil(t, localState.UpsertJob(999, a.Job)) + require.Nil(t, localState.UpsertJob(nstructs.MsgTypeTestSetup, 999, a.Job)) require.Nil(t, localState.UpsertAllocs(nstructs.MsgTypeTestSetup, 1003, []*structs.Allocation{a})) remoteState := remoteServer.State() - require.Nil(t, remoteState.UpsertJob(999, a.Job)) + require.Nil(t, remoteState.UpsertJob(nstructs.MsgTypeTestSetup, 999, a.Job)) require.Nil(t, remoteState.UpsertAllocs(nstructs.MsgTypeTestSetup, 1003, []*structs.Allocation{a})) // Wait for the client to run the allocation diff --git a/nomad/client_fs_endpoint_test.go b/nomad/client_fs_endpoint_test.go index afdde92618d..88db141fd82 100644 --- a/nomad/client_fs_endpoint_test.go +++ b/nomad/client_fs_endpoint_test.go @@ -64,7 +64,7 @@ func TestClientFS_List_Local(t *testing.T) { // Upsert the allocation state := s.State() - require.Nil(state.UpsertJob(999, a.Job)) + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, a.Job)) require.Nil(state.UpsertAllocs(structs.MsgTypeTestSetup, 1003, []*structs.Allocation{a})) // Wait for the client to run the allocation @@ -124,7 +124,7 @@ func TestClientFS_List_ACL(t *testing.T) { // Upsert the allocation state := s.State() alloc := mock.Alloc() - require.NoError(t, state.UpsertJob(1010, alloc.Job)) + require.NoError(t, state.UpsertJob(structs.MsgTypeTestSetup, 1010, alloc.Job)) require.NoError(t, state.UpsertAllocs(structs.MsgTypeTestSetup, 1011, []*structs.Allocation{alloc})) cases := []struct { @@ -224,9 +224,9 @@ func TestClientFS_List_Remote(t *testing.T) { // Upsert the allocation state1 := s1.State() state2 := s2.State() - require.Nil(state1.UpsertJob(999, a.Job)) + require.Nil(state1.UpsertJob(structs.MsgTypeTestSetup, 999, a.Job)) require.Nil(state1.UpsertAllocs(structs.MsgTypeTestSetup, 1003, []*structs.Allocation{a})) - require.Nil(state2.UpsertJob(999, a.Job)) + require.Nil(state2.UpsertJob(structs.MsgTypeTestSetup, 999, a.Job)) require.Nil(state2.UpsertAllocs(structs.MsgTypeTestSetup, 1003, []*structs.Allocation{a})) // Wait for the client to run the allocation @@ -340,7 +340,7 @@ func TestClientFS_Stat_Local(t *testing.T) { // Upsert the allocation state := s.State() - require.Nil(state.UpsertJob(999, a.Job)) + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, a.Job)) require.Nil(state.UpsertAllocs(structs.MsgTypeTestSetup, 1003, []*structs.Allocation{a})) // Wait for the client to run the allocation @@ -400,7 +400,7 @@ func TestClientFS_Stat_ACL(t *testing.T) { // Upsert the allocation state := s.State() alloc := mock.Alloc() - require.NoError(t, state.UpsertJob(1010, alloc.Job)) + require.NoError(t, state.UpsertJob(structs.MsgTypeTestSetup, 1010, alloc.Job)) require.NoError(t, state.UpsertAllocs(structs.MsgTypeTestSetup, 1011, []*structs.Allocation{alloc})) cases := []struct { @@ -500,9 +500,9 @@ func TestClientFS_Stat_Remote(t *testing.T) { // Upsert the allocation state1 := s1.State() state2 := s2.State() - require.Nil(state1.UpsertJob(999, a.Job)) + require.Nil(state1.UpsertJob(structs.MsgTypeTestSetup, 999, a.Job)) require.Nil(state1.UpsertAllocs(structs.MsgTypeTestSetup, 1003, []*structs.Allocation{a})) - require.Nil(state2.UpsertJob(999, a.Job)) + require.Nil(state2.UpsertJob(structs.MsgTypeTestSetup, 999, a.Job)) require.Nil(state2.UpsertAllocs(structs.MsgTypeTestSetup, 1003, []*structs.Allocation{a})) // Wait for the client to run the allocation @@ -632,7 +632,7 @@ func TestClientFS_Streaming_ACL(t *testing.T) { // Upsert the allocation state := s.State() alloc := mock.Alloc() - require.NoError(t, state.UpsertJob(1010, alloc.Job)) + require.NoError(t, state.UpsertJob(structs.MsgTypeTestSetup, 1010, alloc.Job)) require.NoError(t, state.UpsertAllocs(structs.MsgTypeTestSetup, 1011, []*structs.Allocation{alloc})) cases := []struct { @@ -773,7 +773,7 @@ func TestClientFS_Streaming_Local(t *testing.T) { // Upsert the allocation state := s.State() - require.Nil(state.UpsertJob(999, a.Job)) + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, a.Job)) require.Nil(state.UpsertAllocs(structs.MsgTypeTestSetup, 1003, []*structs.Allocation{a})) // Wait for the client to run the allocation @@ -909,7 +909,7 @@ func TestClientFS_Streaming_Local_Follow(t *testing.T) { // Upsert the allocation state := s.State() - require.Nil(state.UpsertJob(999, a.Job)) + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, a.Job)) require.Nil(state.UpsertAllocs(structs.MsgTypeTestSetup, 1003, []*structs.Allocation{a})) // Wait for the client to run the allocation @@ -1052,9 +1052,9 @@ func TestClientFS_Streaming_Remote_Server(t *testing.T) { // Upsert the allocation state1 := s1.State() state2 := s2.State() - require.Nil(state1.UpsertJob(999, a.Job)) + require.Nil(state1.UpsertJob(structs.MsgTypeTestSetup, 999, a.Job)) require.Nil(state1.UpsertAllocs(structs.MsgTypeTestSetup, 1003, []*structs.Allocation{a})) - require.Nil(state2.UpsertJob(999, a.Job)) + require.Nil(state2.UpsertJob(structs.MsgTypeTestSetup, 999, a.Job)) require.Nil(state2.UpsertAllocs(structs.MsgTypeTestSetup, 1003, []*structs.Allocation{a})) // Wait for the client to run the allocation @@ -1198,7 +1198,7 @@ func TestClientFS_Streaming_Remote_Region(t *testing.T) { // Upsert the allocation state2 := s2.State() - require.Nil(state2.UpsertJob(999, a.Job)) + require.Nil(state2.UpsertJob(structs.MsgTypeTestSetup, 999, a.Job)) require.Nil(state2.UpsertAllocs(structs.MsgTypeTestSetup, 1003, []*structs.Allocation{a})) // Wait for the client to run the allocation @@ -1461,7 +1461,7 @@ func TestClientFS_Logs_ACL(t *testing.T) { // Upsert the allocation state := s.State() alloc := mock.Alloc() - require.NoError(t, state.UpsertJob(1010, alloc.Job)) + require.NoError(t, state.UpsertJob(structs.MsgTypeTestSetup, 1010, alloc.Job)) require.NoError(t, state.UpsertAllocs(structs.MsgTypeTestSetup, 1011, []*structs.Allocation{alloc})) cases := []struct { @@ -1602,7 +1602,7 @@ func TestClientFS_Logs_Local(t *testing.T) { // Upsert the allocation state := s.State() - require.Nil(state.UpsertJob(999, a.Job)) + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, a.Job)) require.Nil(state.UpsertAllocs(structs.MsgTypeTestSetup, 1003, []*structs.Allocation{a})) // Wait for the client to run the allocation @@ -1739,7 +1739,7 @@ func TestClientFS_Logs_Local_Follow(t *testing.T) { // Upsert the allocation state := s.State() - require.Nil(state.UpsertJob(999, a.Job)) + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, a.Job)) require.Nil(state.UpsertAllocs(structs.MsgTypeTestSetup, 1003, []*structs.Allocation{a})) // Wait for the client to run the allocation @@ -1883,9 +1883,9 @@ func TestClientFS_Logs_Remote_Server(t *testing.T) { // Upsert the allocation state1 := s1.State() state2 := s2.State() - require.Nil(state1.UpsertJob(999, a.Job)) + require.Nil(state1.UpsertJob(structs.MsgTypeTestSetup, 999, a.Job)) require.Nil(state1.UpsertAllocs(structs.MsgTypeTestSetup, 1003, []*structs.Allocation{a})) - require.Nil(state2.UpsertJob(999, a.Job)) + require.Nil(state2.UpsertJob(structs.MsgTypeTestSetup, 999, a.Job)) require.Nil(state2.UpsertAllocs(structs.MsgTypeTestSetup, 1003, []*structs.Allocation{a})) // Wait for the client to run the allocation @@ -2030,7 +2030,7 @@ func TestClientFS_Logs_Remote_Region(t *testing.T) { // Upsert the allocation state2 := s2.State() - require.Nil(state2.UpsertJob(999, a.Job)) + require.Nil(state2.UpsertJob(structs.MsgTypeTestSetup, 999, a.Job)) require.Nil(state2.UpsertAllocs(structs.MsgTypeTestSetup, 1003, []*structs.Allocation{a})) // Wait for the client to run the allocation diff --git a/nomad/core_sched_test.go b/nomad/core_sched_test.go index 632873bd678..b785a47ae43 100644 --- a/nomad/core_sched_test.go +++ b/nomad/core_sched_test.go @@ -32,7 +32,7 @@ func TestCoreScheduler_EvalGC(t *testing.T) { eval := mock.Eval() eval.Status = structs.EvalStatusFailed state.UpsertJobSummary(999, mock.JobSummary(eval.JobID)) - err := state.UpsertEvals(1000, []*structs.Evaluation{eval}) + err := state.UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval}) require.Nil(err) // Insert mock job with rescheduling disabled @@ -42,7 +42,7 @@ func TestCoreScheduler_EvalGC(t *testing.T) { Attempts: 0, Interval: 0 * time.Second, } - err = state.UpsertJob(1001, job) + err = state.UpsertJob(structs.MsgTypeTestSetup, 1001, job) require.Nil(err) // Insert "dead" alloc @@ -126,21 +126,21 @@ func TestCoreScheduler_EvalGC_ReschedulingAllocs(t *testing.T) { eval := mock.Eval() eval.Status = structs.EvalStatusFailed state.UpsertJobSummary(999, mock.JobSummary(eval.JobID)) - err := state.UpsertEvals(1000, []*structs.Evaluation{eval}) + err := state.UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval}) require.Nil(err) // Insert "pending" eval for same job eval2 := mock.Eval() eval2.JobID = eval.JobID state.UpsertJobSummary(999, mock.JobSummary(eval2.JobID)) - err = state.UpsertEvals(1003, []*structs.Evaluation{eval2}) + err = state.UpsertEvals(structs.MsgTypeTestSetup, 1003, []*structs.Evaluation{eval2}) require.Nil(err) // Insert mock job with default reschedule policy of 2 in 10 minutes job := mock.Job() job.ID = eval.JobID - err = state.UpsertJob(1001, job) + err = state.UpsertJob(structs.MsgTypeTestSetup, 1001, job) require.Nil(err) // Insert failed alloc with an old reschedule attempt, can be GCed @@ -231,7 +231,7 @@ func TestCoreScheduler_EvalGC_StoppedJob_Reschedulable(t *testing.T) { eval := mock.Eval() eval.Status = structs.EvalStatusFailed state.UpsertJobSummary(999, mock.JobSummary(eval.JobID)) - err := state.UpsertEvals(1000, []*structs.Evaluation{eval}) + err := state.UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval}) require.Nil(err) // Insert mock stopped job with default reschedule policy of 2 in 10 minutes @@ -239,7 +239,7 @@ func TestCoreScheduler_EvalGC_StoppedJob_Reschedulable(t *testing.T) { job.ID = eval.JobID job.Stop = true - err = state.UpsertJob(1001, job) + err = state.UpsertJob(structs.MsgTypeTestSetup, 1001, job) require.Nil(err) // Insert failed alloc with a recent reschedule attempt @@ -306,7 +306,7 @@ func TestCoreScheduler_EvalGC_Batch(t *testing.T) { job := mock.Job() job.Type = structs.JobTypeBatch job.Status = structs.JobStatusDead - err := state.UpsertJob(1000, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) if err != nil { t.Fatalf("err: %v", err) } @@ -316,7 +316,7 @@ func TestCoreScheduler_EvalGC_Batch(t *testing.T) { eval.Status = structs.EvalStatusComplete eval.Type = structs.JobTypeBatch eval.JobID = job.ID - err = state.UpsertEvals(1001, []*structs.Evaluation{eval}) + err = state.UpsertEvals(structs.MsgTypeTestSetup, 1001, []*structs.Evaluation{eval}) if err != nil { t.Fatalf("err: %v", err) } @@ -410,7 +410,7 @@ func TestCoreScheduler_EvalGC_Batch_OldVersion(t *testing.T) { job := mock.Job() job.Type = structs.JobTypeBatch job.Status = structs.JobStatusDead - err := state.UpsertJob(1000, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) if err != nil { t.Fatalf("err: %v", err) } @@ -420,7 +420,7 @@ func TestCoreScheduler_EvalGC_Batch_OldVersion(t *testing.T) { eval.Status = structs.EvalStatusComplete eval.Type = structs.JobTypeBatch eval.JobID = job.ID - err = state.UpsertEvals(1001, []*structs.Evaluation{eval}) + err = state.UpsertEvals(structs.MsgTypeTestSetup, 1001, []*structs.Evaluation{eval}) if err != nil { t.Fatalf("err: %v", err) } @@ -539,7 +539,7 @@ func TestCoreScheduler_EvalGC_BatchStopped(t *testing.T) { Attempts: 0, Interval: 0 * time.Second, } - err := state.UpsertJob(1001, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1001, job) require.Nil(err) // Insert "complete" eval @@ -547,7 +547,7 @@ func TestCoreScheduler_EvalGC_BatchStopped(t *testing.T) { eval.Status = structs.EvalStatusComplete eval.Type = structs.JobTypeBatch eval.JobID = job.ID - err = state.UpsertEvals(1002, []*structs.Evaluation{eval}) + err = state.UpsertEvals(structs.MsgTypeTestSetup, 1002, []*structs.Evaluation{eval}) require.Nil(err) // Insert "failed" alloc @@ -630,7 +630,7 @@ func TestCoreScheduler_EvalGC_Partial(t *testing.T) { eval := mock.Eval() eval.Status = structs.EvalStatusComplete state.UpsertJobSummary(999, mock.JobSummary(eval.JobID)) - err := state.UpsertEvals(1000, []*structs.Evaluation{eval}) + err := state.UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval}) if err != nil { t.Fatalf("err: %v", err) } @@ -675,7 +675,7 @@ func TestCoreScheduler_EvalGC_Partial(t *testing.T) { Attempts: 0, Interval: 0 * time.Second, } - err = state.UpsertJob(1001, job) + err = state.UpsertJob(structs.MsgTypeTestSetup, 1001, job) require.Nil(err) // Update the time tables to make this work @@ -755,7 +755,7 @@ func TestCoreScheduler_EvalGC_Force(t *testing.T) { eval := mock.Eval() eval.Status = structs.EvalStatusFailed state.UpsertJobSummary(999, mock.JobSummary(eval.JobID)) - err := state.UpsertEvals(1000, []*structs.Evaluation{eval}) + err := state.UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval}) if err != nil { t.Fatalf("err: %v", err) } @@ -767,7 +767,7 @@ func TestCoreScheduler_EvalGC_Force(t *testing.T) { Attempts: 0, Interval: 0 * time.Second, } - err = state.UpsertJob(1001, job) + err = state.UpsertJob(structs.MsgTypeTestSetup, 1001, job) require.Nil(err) // Insert "dead" alloc @@ -1046,7 +1046,7 @@ func TestCoreScheduler_JobGC_OutstandingEvals(t *testing.T) { job := mock.Job() job.Type = structs.JobTypeBatch job.Status = structs.JobStatusDead - err := state.UpsertJob(1000, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) if err != nil { t.Fatalf("err: %v", err) } @@ -1059,7 +1059,7 @@ func TestCoreScheduler_JobGC_OutstandingEvals(t *testing.T) { eval2 := mock.Eval() eval2.JobID = job.ID eval2.Status = structs.EvalStatusPending - err = state.UpsertEvals(1001, []*structs.Evaluation{eval, eval2}) + err = state.UpsertEvals(structs.MsgTypeTestSetup, 1001, []*structs.Evaluation{eval, eval2}) if err != nil { t.Fatalf("err: %v", err) } @@ -1110,7 +1110,7 @@ func TestCoreScheduler_JobGC_OutstandingEvals(t *testing.T) { // Update the second eval to be terminal eval2.Status = structs.EvalStatusComplete - err = state.UpsertEvals(1003, []*structs.Evaluation{eval2}) + err = state.UpsertEvals(structs.MsgTypeTestSetup, 1003, []*structs.Evaluation{eval2}) if err != nil { t.Fatalf("err: %v", err) } @@ -1174,7 +1174,7 @@ func TestCoreScheduler_JobGC_OutstandingAllocs(t *testing.T) { Attempts: 0, Interval: 0 * time.Second, } - err := state.UpsertJob(1000, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) if err != nil { t.Fatalf("err: %v", err) } @@ -1183,7 +1183,7 @@ func TestCoreScheduler_JobGC_OutstandingAllocs(t *testing.T) { eval := mock.Eval() eval.JobID = job.ID eval.Status = structs.EvalStatusComplete - err = state.UpsertEvals(1001, []*structs.Evaluation{eval}) + err = state.UpsertEvals(structs.MsgTypeTestSetup, 1001, []*structs.Evaluation{eval}) if err != nil { t.Fatalf("err: %v", err) } @@ -1315,7 +1315,7 @@ func TestCoreScheduler_JobGC_OneShot(t *testing.T) { state := s1.fsm.State() job := mock.Job() job.Type = structs.JobTypeBatch - err := state.UpsertJob(1000, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) if err != nil { t.Fatalf("err: %v", err) } @@ -1329,7 +1329,7 @@ func TestCoreScheduler_JobGC_OneShot(t *testing.T) { eval2.JobID = job.ID eval2.Status = structs.EvalStatusComplete - err = state.UpsertEvals(1001, []*structs.Evaluation{eval, eval2}) + err = state.UpsertEvals(structs.MsgTypeTestSetup, 1001, []*structs.Evaluation{eval, eval2}) if err != nil { t.Fatalf("err: %v", err) } @@ -1432,7 +1432,7 @@ func TestCoreScheduler_JobGC_Stopped(t *testing.T) { Attempts: 0, Interval: 0 * time.Second, } - err := state.UpsertJob(1000, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) if err != nil { t.Fatalf("err: %v", err) } @@ -1446,7 +1446,7 @@ func TestCoreScheduler_JobGC_Stopped(t *testing.T) { eval2.JobID = job.ID eval2.Status = structs.EvalStatusComplete - err = state.UpsertEvals(1001, []*structs.Evaluation{eval, eval2}) + err = state.UpsertEvals(structs.MsgTypeTestSetup, 1001, []*structs.Evaluation{eval, eval2}) if err != nil { t.Fatalf("err: %v", err) } @@ -1537,7 +1537,7 @@ func TestCoreScheduler_JobGC_Force(t *testing.T) { job := mock.Job() job.Type = structs.JobTypeBatch job.Status = structs.JobStatusDead - err := state.UpsertJob(1000, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) if err != nil { t.Fatalf("err: %v", err) } @@ -1546,7 +1546,7 @@ func TestCoreScheduler_JobGC_Force(t *testing.T) { eval := mock.Eval() eval.JobID = job.ID eval.Status = structs.EvalStatusComplete - err = state.UpsertEvals(1001, []*structs.Evaluation{eval}) + err = state.UpsertEvals(structs.MsgTypeTestSetup, 1001, []*structs.Evaluation{eval}) if err != nil { t.Fatalf("err: %v", err) } @@ -1605,7 +1605,7 @@ func TestCoreScheduler_JobGC_Parameterized(t *testing.T) { job.ParameterizedJob = &structs.ParameterizedJobConfig{ Payload: structs.DispatchPayloadRequired, } - err := state.UpsertJob(1000, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) if err != nil { t.Fatalf("err: %v", err) } @@ -1637,7 +1637,7 @@ func TestCoreScheduler_JobGC_Parameterized(t *testing.T) { // Mark the job as stopped and try again job2 := job.Copy() job2.Stop = true - err = state.UpsertJob(2000, job2) + err = state.UpsertJob(structs.MsgTypeTestSetup, 2000, job2) if err != nil { t.Fatalf("err: %v", err) } @@ -1680,7 +1680,7 @@ func TestCoreScheduler_JobGC_Periodic(t *testing.T) { // Insert a parameterized job. state := s1.fsm.State() job := mock.PeriodicJob() - err := state.UpsertJob(1000, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) if err != nil { t.Fatalf("err: %v", err) } @@ -1712,7 +1712,7 @@ func TestCoreScheduler_JobGC_Periodic(t *testing.T) { // Mark the job as stopped and try again job2 := job.Copy() job2.Stop = true - err = state.UpsertJob(2000, job2) + err = state.UpsertJob(structs.MsgTypeTestSetup, 2000, job2) if err != nil { t.Fatalf("err: %v", err) } @@ -2318,14 +2318,14 @@ func TestCoreScheduler_CSIVolumeClaimGC(t *testing.T) { index++ state.UpsertJobSummary(index, mock.JobSummary(eval.JobID)) index++ - err = state.UpsertEvals(index, []*structs.Evaluation{eval}) + err = state.UpsertEvals(structs.MsgTypeTestSetup, index, []*structs.Evaluation{eval}) require.Nil(err) job := mock.Job() job.ID = eval.JobID job.Status = structs.JobStatusRunning index++ - err = state.UpsertJob(index, job) + err = state.UpsertJob(structs.MsgTypeTestSetup, index, job) require.NoError(err) alloc1, alloc2 := mock.Alloc(), mock.Alloc() diff --git a/nomad/deployment_endpoint_test.go b/nomad/deployment_endpoint_test.go index c459697c39d..300d7790cc4 100644 --- a/nomad/deployment_endpoint_test.go +++ b/nomad/deployment_endpoint_test.go @@ -29,7 +29,7 @@ func TestDeploymentEndpoint_GetDeployment(t *testing.T) { d.JobID = j.ID state := s1.fsm.State() - assert.Nil(state.UpsertJob(999, j), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, j), "UpsertJob") assert.Nil(state.UpsertDeployment(1000, d), "UpsertDeployment") // Lookup the deployments @@ -61,7 +61,7 @@ func TestDeploymentEndpoint_GetDeployment_ACL(t *testing.T) { d.JobID = j.ID state := s1.fsm.State() - assert.Nil(state.UpsertJob(999, j), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, j), "UpsertJob") assert.Nil(state.UpsertDeployment(1000, d), "UpsertDeployment") // Create the namespace policy and tokens @@ -118,8 +118,8 @@ func TestDeploymentEndpoint_GetDeployment_Blocking(t *testing.T) { d2 := mock.Deployment() d2.JobID = j2.ID - assert.Nil(state.UpsertJob(98, j1), "UpsertJob") - assert.Nil(state.UpsertJob(99, j2), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 98, j1), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 99, j2), "UpsertJob") // Upsert a deployment we are not interested in first. time.AfterFunc(100*time.Millisecond, func() { @@ -167,7 +167,7 @@ func TestDeploymentEndpoint_Fail(t *testing.T) { d.JobID = j.ID state := s1.fsm.State() - assert.Nil(state.UpsertJob(999, j), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, j), "UpsertJob") assert.Nil(state.UpsertDeployment(1000, d), "UpsertDeployment") // Mark the deployment as failed @@ -217,7 +217,7 @@ func TestDeploymentEndpoint_Fail_ACL(t *testing.T) { d.JobID = j.ID state := s1.fsm.State() - assert.Nil(state.UpsertJob(999, j), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, j), "UpsertJob") assert.Nil(state.UpsertDeployment(1000, d), "UpsertDeployment") // Create the namespace policy and tokens @@ -294,7 +294,7 @@ func TestDeploymentEndpoint_Fail_Rollback(t *testing.T) { j.TaskGroups[0].Update = structs.DefaultUpdateStrategy.Copy() j.TaskGroups[0].Update.MaxParallel = 2 j.TaskGroups[0].Update.AutoRevert = true - assert.Nil(state.UpsertJob(998, j), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 998, j), "UpsertJob") // Create the second job, deployment and alloc j2 := j.Copy() @@ -311,7 +311,7 @@ func TestDeploymentEndpoint_Fail_Rollback(t *testing.T) { a.JobID = j.ID a.DeploymentID = d.ID - assert.Nil(state.UpsertJob(999, j2), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, j2), "UpsertJob") assert.Nil(state.UpsertDeployment(1000, d), "UpsertDeployment") assert.Nil(state.UpsertAllocs(structs.MsgTypeTestSetup, 1001, []*structs.Allocation{a}), "UpsertAllocs") @@ -371,7 +371,7 @@ func TestDeploymentEndpoint_Pause(t *testing.T) { d.JobID = j.ID state := s1.fsm.State() - assert.Nil(state.UpsertJob(999, j), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, j), "UpsertJob") assert.Nil(state.UpsertDeployment(1000, d), "UpsertDeployment") // Mark the deployment as failed @@ -414,7 +414,7 @@ func TestDeploymentEndpoint_Pause_ACL(t *testing.T) { d.JobID = j.ID state := s1.fsm.State() - assert.Nil(state.UpsertJob(999, j), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, j), "UpsertJob") assert.Nil(state.UpsertDeployment(1000, d), "UpsertDeployment") // Create the namespace policy and tokens @@ -493,7 +493,7 @@ func TestDeploymentEndpoint_Promote(t *testing.T) { } state := s1.fsm.State() - assert.Nil(state.UpsertJob(999, j), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, j), "UpsertJob") assert.Nil(state.UpsertDeployment(1000, d), "UpsertDeployment") assert.Nil(state.UpsertAllocs(structs.MsgTypeTestSetup, 1001, []*structs.Allocation{a}), "UpsertAllocs") @@ -558,7 +558,7 @@ func TestDeploymentEndpoint_Promote_ACL(t *testing.T) { } state := s1.fsm.State() - assert.Nil(state.UpsertJob(999, j), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, j), "UpsertJob") assert.Nil(state.UpsertDeployment(1000, d), "UpsertDeployment") assert.Nil(state.UpsertAllocs(structs.MsgTypeTestSetup, 1001, []*structs.Allocation{a}), "UpsertAllocs") @@ -644,7 +644,7 @@ func TestDeploymentEndpoint_SetAllocHealth(t *testing.T) { a.DeploymentID = d.ID state := s1.fsm.State() - assert.Nil(state.UpsertJob(999, j), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, j), "UpsertJob") assert.Nil(state.UpsertDeployment(1000, d), "UpsertDeployment") assert.Nil(state.UpsertAllocs(structs.MsgTypeTestSetup, 1001, []*structs.Allocation{a}), "UpsertAllocs") @@ -712,7 +712,7 @@ func TestDeploymentEndpoint_SetAllocHealth_ACL(t *testing.T) { a.DeploymentID = d.ID state := s1.fsm.State() - assert.Nil(state.UpsertJob(999, j), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, j), "UpsertJob") assert.Nil(state.UpsertDeployment(1000, d), "UpsertDeployment") assert.Nil(state.UpsertAllocs(structs.MsgTypeTestSetup, 1001, []*structs.Allocation{a}), "UpsertAllocs") @@ -802,7 +802,7 @@ func TestDeploymentEndpoint_SetAllocHealth_Rollback(t *testing.T) { j.TaskGroups[0].Update = structs.DefaultUpdateStrategy.Copy() j.TaskGroups[0].Update.MaxParallel = 2 j.TaskGroups[0].Update.AutoRevert = true - assert.Nil(state.UpsertJob(998, j), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 998, j), "UpsertJob") // Create the second job, deployment and alloc j2 := j.Copy() @@ -818,7 +818,7 @@ func TestDeploymentEndpoint_SetAllocHealth_Rollback(t *testing.T) { a.JobID = j.ID a.DeploymentID = d.ID - assert.Nil(state.UpsertJob(999, j2), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, j2), "UpsertJob") assert.Nil(state.UpsertDeployment(1000, d), "UpsertDeployment") assert.Nil(state.UpsertAllocs(structs.MsgTypeTestSetup, 1001, []*structs.Allocation{a}), "UpsertAllocs") @@ -892,7 +892,7 @@ func TestDeploymentEndpoint_SetAllocHealth_NoRollback(t *testing.T) { j.TaskGroups[0].Update = structs.DefaultUpdateStrategy.Copy() j.TaskGroups[0].Update.MaxParallel = 2 j.TaskGroups[0].Update.AutoRevert = true - assert.Nil(state.UpsertJob(998, j), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 998, j), "UpsertJob") // Create the second job, deployment and alloc. Job has same spec as original j2 := j.Copy() @@ -907,7 +907,7 @@ func TestDeploymentEndpoint_SetAllocHealth_NoRollback(t *testing.T) { a.JobID = j.ID a.DeploymentID = d.ID - assert.Nil(state.UpsertJob(999, j2), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, j2), "UpsertJob") assert.Nil(state.UpsertDeployment(1000, d), "UpsertDeployment") assert.Nil(state.UpsertAllocs(structs.MsgTypeTestSetup, 1001, []*structs.Allocation{a}), "UpsertAllocs") @@ -976,7 +976,7 @@ func TestDeploymentEndpoint_List(t *testing.T) { d.JobID = j.ID state := s1.fsm.State() - assert.Nil(state.UpsertJob(999, j), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, j), "UpsertJob") assert.Nil(state.UpsertDeployment(1000, d), "UpsertDeployment") // Lookup the deployments @@ -1023,7 +1023,7 @@ func TestDeploymentEndpoint_List_ACL(t *testing.T) { d.JobID = j.ID state := s1.fsm.State() - assert.Nil(state.UpsertJob(999, j), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, j), "UpsertJob") assert.Nil(state.UpsertDeployment(1000, d), "UpsertDeployment") // Create the namespace policy and tokens @@ -1092,7 +1092,7 @@ func TestDeploymentEndpoint_List_Blocking(t *testing.T) { d := mock.Deployment() d.JobID = j.ID - assert.Nil(state.UpsertJob(999, j), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, j), "UpsertJob") // Upsert alloc triggers watches time.AfterFunc(100*time.Millisecond, func() { @@ -1153,7 +1153,7 @@ func TestDeploymentEndpoint_Allocations(t *testing.T) { summary := mock.JobSummary(a.JobID) state := s1.fsm.State() - assert.Nil(state.UpsertJob(998, j), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 998, j), "UpsertJob") assert.Nil(state.UpsertJobSummary(999, summary), "UpsertJobSummary") assert.Nil(state.UpsertDeployment(1000, d), "UpsertDeployment") assert.Nil(state.UpsertAllocs(structs.MsgTypeTestSetup, 1001, []*structs.Allocation{a}), "UpsertAllocs") @@ -1191,7 +1191,7 @@ func TestDeploymentEndpoint_Allocations_ACL(t *testing.T) { summary := mock.JobSummary(a.JobID) state := s1.fsm.State() - assert.Nil(state.UpsertJob(998, j), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 998, j), "UpsertJob") assert.Nil(state.UpsertJobSummary(999, summary), "UpsertJobSummary") assert.Nil(state.UpsertDeployment(1000, d), "UpsertDeployment") assert.Nil(state.UpsertAllocs(structs.MsgTypeTestSetup, 1001, []*structs.Allocation{a}), "UpsertAllocs") @@ -1266,7 +1266,7 @@ func TestDeploymentEndpoint_Allocations_Blocking(t *testing.T) { a.DeploymentID = d.ID summary := mock.JobSummary(a.JobID) - assert.Nil(state.UpsertJob(1, j), "UpsertJob") + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 1, j), "UpsertJob") assert.Nil(state.UpsertDeployment(2, d), "UpsertDeployment") assert.Nil(state.UpsertJobSummary(3, summary), "UpsertJobSummary") diff --git a/nomad/deploymentwatcher/deployments_watcher_test.go b/nomad/deploymentwatcher/deployments_watcher_test.go index d6c3e7c57d9..8777a398f05 100644 --- a/nomad/deploymentwatcher/deployments_watcher_test.go +++ b/nomad/deploymentwatcher/deployments_watcher_test.go @@ -39,9 +39,9 @@ func TestWatcher_WatchDeployments(t *testing.T) { // Create three jobs j1, j2, j3 := mock.Job(), mock.Job(), mock.Job() - require.Nil(m.state.UpsertJob(100, j1)) - require.Nil(m.state.UpsertJob(101, j2)) - require.Nil(m.state.UpsertJob(102, j3)) + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, 100, j1)) + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, 101, j2)) + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, 102, j3)) // Create three deployments all running d1, d2, d3 := mock.Deployment(), mock.Deployment(), mock.Deployment() @@ -154,7 +154,7 @@ func TestWatcher_SetAllocHealth_Unknown(t *testing.T) { j := mock.Job() d := mock.Deployment() d.JobID = j.ID - require.Nil(m.state.UpsertJob(m.nextIndex(), j), "UpsertJob") + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, m.nextIndex(), j), "UpsertJob") require.Nil(m.state.UpsertDeployment(m.nextIndex(), d), "UpsertDeployment") // require that we get a call to UpsertDeploymentAllocHealth @@ -200,7 +200,7 @@ func TestWatcher_SetAllocHealth_Healthy(t *testing.T) { d.JobID = j.ID a := mock.Alloc() a.DeploymentID = d.ID - require.Nil(m.state.UpsertJob(m.nextIndex(), j), "UpsertJob") + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, m.nextIndex(), j), "UpsertJob") require.Nil(m.state.UpsertDeployment(m.nextIndex(), d), "UpsertDeployment") require.Nil(m.state.UpsertAllocs(structs.MsgTypeTestSetup, m.nextIndex(), []*structs.Allocation{a}), "UpsertAllocs") @@ -245,7 +245,7 @@ func TestWatcher_SetAllocHealth_Unhealthy(t *testing.T) { d.JobID = j.ID a := mock.Alloc() a.DeploymentID = d.ID - require.Nil(m.state.UpsertJob(m.nextIndex(), j), "UpsertJob") + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, m.nextIndex(), j), "UpsertJob") require.Nil(m.state.UpsertDeployment(m.nextIndex(), d), "UpsertDeployment") require.Nil(m.state.UpsertAllocs(structs.MsgTypeTestSetup, m.nextIndex(), []*structs.Allocation{a}), "UpsertAllocs") @@ -303,7 +303,7 @@ func TestWatcher_SetAllocHealth_Unhealthy_Rollback(t *testing.T) { d.TaskGroups["web"].AutoRevert = true a := mock.Alloc() a.DeploymentID = d.ID - require.Nil(m.state.UpsertJob(m.nextIndex(), j), "UpsertJob") + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, m.nextIndex(), j), "UpsertJob") require.Nil(m.state.UpsertDeployment(m.nextIndex(), d), "UpsertDeployment") require.Nil(m.state.UpsertAllocs(structs.MsgTypeTestSetup, m.nextIndex(), []*structs.Allocation{a}), "UpsertAllocs") @@ -313,7 +313,7 @@ func TestWatcher_SetAllocHealth_Unhealthy_Rollback(t *testing.T) { // Modify the job to make its specification different j2.Meta["foo"] = "bar" - require.Nil(m.state.UpsertJob(m.nextIndex(), j2), "UpsertJob2") + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, m.nextIndex(), j2), "UpsertJob2") // require that we get a call to UpsertDeploymentAllocHealth matchConfig := &matchDeploymentAllocHealthRequestConfig{ @@ -370,7 +370,7 @@ func TestWatcher_SetAllocHealth_Unhealthy_NoRollback(t *testing.T) { d.TaskGroups["web"].AutoRevert = true a := mock.Alloc() a.DeploymentID = d.ID - require.Nil(m.state.UpsertJob(m.nextIndex(), j), "UpsertJob") + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, m.nextIndex(), j), "UpsertJob") require.Nil(m.state.UpsertDeployment(m.nextIndex(), d), "UpsertDeployment") require.Nil(m.state.UpsertAllocs(structs.MsgTypeTestSetup, m.nextIndex(), []*structs.Allocation{a}), "UpsertAllocs") @@ -378,7 +378,7 @@ func TestWatcher_SetAllocHealth_Unhealthy_NoRollback(t *testing.T) { j2 := j.Copy() j2.Stable = false - require.Nil(m.state.UpsertJob(m.nextIndex(), j2), "UpsertJob2") + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, m.nextIndex(), j2), "UpsertJob2") // require that we get a call to UpsertDeploymentAllocHealth matchConfig := &matchDeploymentAllocHealthRequestConfig{ @@ -438,7 +438,7 @@ func TestWatcher_PromoteDeployment_HealthyCanaries(t *testing.T) { Healthy: helper.BoolToPtr(true), } a.DeploymentID = d.ID - require.Nil(m.state.UpsertJob(m.nextIndex(), j), "UpsertJob") + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, m.nextIndex(), j), "UpsertJob") require.Nil(m.state.UpsertDeployment(m.nextIndex(), d), "UpsertDeployment") require.Nil(m.state.UpsertAllocs(structs.MsgTypeTestSetup, m.nextIndex(), []*structs.Allocation{a}), "UpsertAllocs") @@ -495,7 +495,7 @@ func TestWatcher_PromoteDeployment_UnhealthyCanaries(t *testing.T) { d.TaskGroups[a.TaskGroup].PlacedCanaries = []string{a.ID} d.TaskGroups[a.TaskGroup].DesiredCanaries = 2 a.DeploymentID = d.ID - require.Nil(m.state.UpsertJob(m.nextIndex(), j), "UpsertJob") + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, m.nextIndex(), j), "UpsertJob") require.Nil(m.state.UpsertDeployment(m.nextIndex(), d), "UpsertDeployment") require.Nil(m.state.UpsertAllocs(structs.MsgTypeTestSetup, m.nextIndex(), []*structs.Allocation{a}), "UpsertAllocs") @@ -574,7 +574,7 @@ func TestWatcher_AutoPromoteDeployment(t *testing.T) { d.TaskGroups[a.TaskGroup].PlacedCanaries = []string{a.ID, b.ID} d.TaskGroups[a.TaskGroup].DesiredCanaries = 2 - require.NoError(t, m.state.UpsertJob(m.nextIndex(), j), "UpsertJob") + require.NoError(t, m.state.UpsertJob(structs.MsgTypeTestSetup, m.nextIndex(), j), "UpsertJob") require.NoError(t, m.state.UpsertDeployment(m.nextIndex(), d), "UpsertDeployment") require.NoError(t, m.state.UpsertAllocs(structs.MsgTypeTestSetup, m.nextIndex(), []*structs.Allocation{a, b}), "UpsertAllocs") @@ -667,7 +667,7 @@ func TestWatcher_PauseDeployment_Pause_Running(t *testing.T) { j := mock.Job() d := mock.Deployment() d.JobID = j.ID - require.Nil(m.state.UpsertJob(m.nextIndex(), j), "UpsertJob") + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, m.nextIndex(), j), "UpsertJob") require.Nil(m.state.UpsertDeployment(m.nextIndex(), d), "UpsertDeployment") // require that we get a call to UpsertDeploymentStatusUpdate @@ -710,7 +710,7 @@ func TestWatcher_PauseDeployment_Pause_Paused(t *testing.T) { d := mock.Deployment() d.JobID = j.ID d.Status = structs.DeploymentStatusPaused - require.Nil(m.state.UpsertJob(m.nextIndex(), j), "UpsertJob") + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, m.nextIndex(), j), "UpsertJob") require.Nil(m.state.UpsertDeployment(m.nextIndex(), d), "UpsertDeployment") // require that we get a call to UpsertDeploymentStatusUpdate @@ -750,7 +750,7 @@ func TestWatcher_PauseDeployment_Unpause_Paused(t *testing.T) { d := mock.Deployment() d.JobID = j.ID d.Status = structs.DeploymentStatusPaused - require.Nil(m.state.UpsertJob(m.nextIndex(), j), "UpsertJob") + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, m.nextIndex(), j), "UpsertJob") require.Nil(m.state.UpsertDeployment(m.nextIndex(), d), "UpsertDeployment") // require that we get a call to UpsertDeploymentStatusUpdate @@ -790,7 +790,7 @@ func TestWatcher_PauseDeployment_Unpause_Running(t *testing.T) { j := mock.Job() d := mock.Deployment() d.JobID = j.ID - require.Nil(m.state.UpsertJob(m.nextIndex(), j), "UpsertJob") + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, m.nextIndex(), j), "UpsertJob") require.Nil(m.state.UpsertDeployment(m.nextIndex(), d), "UpsertDeployment") // require that we get a call to UpsertDeploymentStatusUpdate @@ -830,7 +830,7 @@ func TestWatcher_FailDeployment_Running(t *testing.T) { j := mock.Job() d := mock.Deployment() d.JobID = j.ID - require.Nil(m.state.UpsertJob(m.nextIndex(), j), "UpsertJob") + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, m.nextIndex(), j), "UpsertJob") require.Nil(m.state.UpsertDeployment(m.nextIndex(), d), "UpsertDeployment") // require that we get a call to UpsertDeploymentStatusUpdate @@ -878,7 +878,7 @@ func TestDeploymentWatcher_Watch_NoProgressDeadline(t *testing.T) { d.TaskGroups["web"].AutoRevert = true a := mock.Alloc() a.DeploymentID = d.ID - require.Nil(m.state.UpsertJob(m.nextIndex(), j), "UpsertJob") + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, m.nextIndex(), j), "UpsertJob") require.Nil(m.state.UpsertDeployment(m.nextIndex(), d), "UpsertDeployment") require.Nil(m.state.UpsertAllocs(structs.MsgTypeTestSetup, m.nextIndex(), []*structs.Allocation{a}), "UpsertAllocs") @@ -887,7 +887,7 @@ func TestDeploymentWatcher_Watch_NoProgressDeadline(t *testing.T) { // Modify the job to make its specification different j2.Meta["foo"] = "bar" j2.Stable = false - require.Nil(m.state.UpsertJob(m.nextIndex(), j2), "UpsertJob2") + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, m.nextIndex(), j2), "UpsertJob2") // require that we will get a update allocation call only once. This will // verify that the watcher is batching allocation changes @@ -1000,7 +1000,7 @@ func TestDeploymentWatcher_Watch_ProgressDeadline(t *testing.T) { a.CreateTime = now.UnixNano() a.ModifyTime = now.UnixNano() a.DeploymentID = d.ID - require.Nil(m.state.UpsertJob(m.nextIndex(), j), "UpsertJob") + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, m.nextIndex(), j), "UpsertJob") require.Nil(m.state.UpsertDeployment(m.nextIndex(), d), "UpsertDeployment") require.Nil(m.state.UpsertAllocs(structs.MsgTypeTestSetup, m.nextIndex(), []*structs.Allocation{a}), "UpsertAllocs") @@ -1095,7 +1095,7 @@ func TestDeploymentWatcher_ProgressCutoff(t *testing.T) { a2.ModifyTime = now.UnixNano() a2.DeploymentID = d.ID - require.Nil(m.state.UpsertJob(m.nextIndex(), j), "UpsertJob") + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, m.nextIndex(), j), "UpsertJob") require.Nil(m.state.UpsertDeployment(m.nextIndex(), d), "UpsertDeployment") require.Nil(m.state.UpsertAllocs(structs.MsgTypeTestSetup, m.nextIndex(), []*structs.Allocation{a, a2}), "UpsertAllocs") @@ -1189,7 +1189,7 @@ func TestDeploymentWatcher_Watch_ProgressDeadline_Canaries(t *testing.T) { a.CreateTime = now.UnixNano() a.ModifyTime = now.UnixNano() a.DeploymentID = d.ID - require.Nil(m.state.UpsertJob(m.nextIndex(), j), "UpsertJob") + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, m.nextIndex(), j), "UpsertJob") require.Nil(m.state.UpsertDeployment(m.nextIndex(), d), "UpsertDeployment") require.Nil(m.state.UpsertAllocs(structs.MsgTypeTestSetup, m.nextIndex(), []*structs.Allocation{a}), "UpsertAllocs") @@ -1281,7 +1281,7 @@ func TestDeploymentWatcher_PromotedCanary_UpdatedAllocs(t *testing.T) { Healthy: helper.BoolToPtr(true), Timestamp: now, } - require.Nil(m.state.UpsertJob(m.nextIndex(), j), "UpsertJob") + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, m.nextIndex(), j), "UpsertJob") require.Nil(m.state.UpsertDeployment(m.nextIndex(), d), "UpsertDeployment") require.Nil(m.state.UpsertAllocs(structs.MsgTypeTestSetup, m.nextIndex(), []*structs.Allocation{a}), "UpsertAllocs") @@ -1354,7 +1354,7 @@ func TestDeploymentWatcher_Watch_StartWithoutProgressDeadline(t *testing.T) { d := mock.Deployment() d.JobID = j.ID - require.Nil(m.state.UpsertJob(m.nextIndex(), j), "UpsertJob") + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, m.nextIndex(), j), "UpsertJob") require.Nil(m.state.UpsertDeployment(m.nextIndex(), d), "UpsertDeployment") a := mock.Alloc() @@ -1415,7 +1415,7 @@ func TestDeploymentWatcher_RollbackFailed(t *testing.T) { d.TaskGroups["web"].AutoRevert = true a := mock.Alloc() a.DeploymentID = d.ID - require.Nil(m.state.UpsertJob(m.nextIndex(), j), "UpsertJob") + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, m.nextIndex(), j), "UpsertJob") require.Nil(m.state.UpsertDeployment(m.nextIndex(), d), "UpsertDeployment") require.Nil(m.state.UpsertAllocs(structs.MsgTypeTestSetup, m.nextIndex(), []*structs.Allocation{a}), "UpsertAllocs") @@ -1423,7 +1423,7 @@ func TestDeploymentWatcher_RollbackFailed(t *testing.T) { j2 := j.Copy() // Modify the job to make its specification different j2.Stable = false - require.Nil(m.state.UpsertJob(m.nextIndex(), j2), "UpsertJob2") + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, m.nextIndex(), j2), "UpsertJob2") // require that we will get a createEvaluation call only once. This will // verify that the watcher is batching allocation changes @@ -1538,8 +1538,8 @@ func TestWatcher_BatchAllocUpdates(t *testing.T) { a2.JobID = j2.ID a2.DeploymentID = d2.ID - require.Nil(m.state.UpsertJob(m.nextIndex(), j1), "UpsertJob") - require.Nil(m.state.UpsertJob(m.nextIndex(), j2), "UpsertJob") + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, m.nextIndex(), j1), "UpsertJob") + require.Nil(m.state.UpsertJob(structs.MsgTypeTestSetup, m.nextIndex(), j2), "UpsertJob") require.Nil(m.state.UpsertDeployment(m.nextIndex(), d1), "UpsertDeployment") require.Nil(m.state.UpsertDeployment(m.nextIndex(), d2), "UpsertDeployment") require.Nil(m.state.UpsertAllocs(structs.MsgTypeTestSetup, m.nextIndex(), []*structs.Allocation{a1}), "UpsertAllocs") diff --git a/nomad/deploymentwatcher/testutil_test.go b/nomad/deploymentwatcher/testutil_test.go index 87cd492fe61..d81db310333 100644 --- a/nomad/deploymentwatcher/testutil_test.go +++ b/nomad/deploymentwatcher/testutil_test.go @@ -89,7 +89,7 @@ func matchUpdateAllocDesiredTransitionReschedule(allocIDs []string) func(update func (m *mockBackend) UpsertJob(job *structs.Job) (uint64, error) { m.Called(job) i := m.nextIndex() - return i, m.state.UpsertJob(i, job) + return i, m.state.UpsertJob(structs.MsgTypeTestSetup, i, job) } func (m *mockBackend) UpdateDeploymentStatus(u *structs.DeploymentStatusUpdateRequest) (uint64, error) { diff --git a/nomad/drainer/draining_node_test.go b/nomad/drainer/draining_node_test.go index 226a660b741..9a069a84809 100644 --- a/nomad/drainer/draining_node_test.go +++ b/nomad/drainer/draining_node_test.go @@ -66,7 +66,7 @@ func TestDrainingNode_Table(t *testing.T) { setup: func(t *testing.T, dn *drainingNode) { alloc := mock.BatchAlloc() alloc.NodeID = dn.node.ID - require.Nil(t, dn.state.UpsertJob(101, alloc.Job)) + require.Nil(t, dn.state.UpsertJob(structs.MsgTypeTestSetup, 101, alloc.Job)) require.Nil(t, dn.state.UpsertAllocs(structs.MsgTypeTestSetup, 102, []*structs.Allocation{alloc})) }, }, @@ -78,7 +78,7 @@ func TestDrainingNode_Table(t *testing.T) { setup: func(t *testing.T, dn *drainingNode) { alloc := mock.Alloc() alloc.NodeID = dn.node.ID - require.Nil(t, dn.state.UpsertJob(101, alloc.Job)) + require.Nil(t, dn.state.UpsertJob(structs.MsgTypeTestSetup, 101, alloc.Job)) require.Nil(t, dn.state.UpsertAllocs(structs.MsgTypeTestSetup, 102, []*structs.Allocation{alloc})) }, }, @@ -90,7 +90,7 @@ func TestDrainingNode_Table(t *testing.T) { setup: func(t *testing.T, dn *drainingNode) { alloc := mock.SystemAlloc() alloc.NodeID = dn.node.ID - require.Nil(t, dn.state.UpsertJob(101, alloc.Job)) + require.Nil(t, dn.state.UpsertJob(structs.MsgTypeTestSetup, 101, alloc.Job)) require.Nil(t, dn.state.UpsertAllocs(structs.MsgTypeTestSetup, 102, []*structs.Allocation{alloc})) }, }, @@ -103,7 +103,7 @@ func TestDrainingNode_Table(t *testing.T) { allocs := []*structs.Allocation{mock.Alloc(), mock.BatchAlloc(), mock.SystemAlloc()} for _, a := range allocs { a.NodeID = dn.node.ID - require.Nil(t, dn.state.UpsertJob(101, a.Job)) + require.Nil(t, dn.state.UpsertJob(structs.MsgTypeTestSetup, 101, a.Job)) } require.Nil(t, dn.state.UpsertAllocs(structs.MsgTypeTestSetup, 102, allocs)) @@ -125,7 +125,7 @@ func TestDrainingNode_Table(t *testing.T) { allocs := []*structs.Allocation{mock.Alloc(), mock.BatchAlloc(), mock.SystemAlloc()} for _, a := range allocs { a.NodeID = dn.node.ID - require.Nil(t, dn.state.UpsertJob(101, a.Job)) + require.Nil(t, dn.state.UpsertJob(structs.MsgTypeTestSetup, 101, a.Job)) } require.Nil(t, dn.state.UpsertAllocs(structs.MsgTypeTestSetup, 102, allocs)) @@ -143,7 +143,7 @@ func TestDrainingNode_Table(t *testing.T) { allocs := []*structs.Allocation{mock.Alloc(), mock.BatchAlloc(), mock.SystemAlloc()} for _, a := range allocs { a.NodeID = dn.node.ID - require.Nil(t, dn.state.UpsertJob(101, a.Job)) + require.Nil(t, dn.state.UpsertJob(structs.MsgTypeTestSetup, 101, a.Job)) } require.Nil(t, dn.state.UpsertAllocs(structs.MsgTypeTestSetup, 102, allocs)) @@ -162,7 +162,7 @@ func TestDrainingNode_Table(t *testing.T) { allocs := []*structs.Allocation{mock.Alloc(), mock.BatchAlloc(), mock.SystemAlloc()} for _, a := range allocs { a.NodeID = dn.node.ID - require.Nil(t, dn.state.UpsertJob(101, a.Job)) + require.Nil(t, dn.state.UpsertJob(structs.MsgTypeTestSetup, 101, a.Job)) } require.Nil(t, dn.state.UpsertAllocs(structs.MsgTypeTestSetup, 102, allocs)) @@ -188,7 +188,7 @@ func TestDrainingNode_Table(t *testing.T) { } for _, a := range allocs { a.NodeID = dn.node.ID - require.Nil(t, dn.state.UpsertJob(101, a.Job)) + require.Nil(t, dn.state.UpsertJob(structs.MsgTypeTestSetup, 101, a.Job)) } require.Nil(t, dn.state.UpsertAllocs(structs.MsgTypeTestSetup, 102, allocs)) diff --git a/nomad/drainer/watch_jobs_test.go b/nomad/drainer/watch_jobs_test.go index 4be21dadabe..ab8dcada8c3 100644 --- a/nomad/drainer/watch_jobs_test.go +++ b/nomad/drainer/watch_jobs_test.go @@ -128,7 +128,7 @@ func TestDrainingJobWatcher_DrainJobs(t *testing.T) { jnss[i] = structs.NamespacedID{Namespace: job.Namespace, ID: job.ID} job.TaskGroups[0].Migrate.MaxParallel = 3 job.TaskGroups[0].Count = count - require.Nil(state.UpsertJob(index, job)) + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, index, job)) index++ var allocs []*structs.Allocation @@ -562,7 +562,7 @@ func testHandleTaskGroup(t *testing.T, tc handleTaskGroupTestCase) { if tc.MaxParallel > 0 { job.TaskGroups[0].Migrate.MaxParallel = tc.MaxParallel } - require.Nil(state.UpsertJob(102, job)) + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 102, job)) var allocs []*structs.Allocation for i := 0; i < 10; i++ { @@ -614,7 +614,7 @@ func TestHandleTaskGroup_Migrations(t *testing.T) { require.Nil(state.UpsertNode(structs.MsgTypeTestSetup, n, 100)) job := mock.Job() - require.Nil(state.UpsertJob(101, job)) + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 101, job)) // Create 10 done allocs var allocs []*structs.Allocation @@ -683,7 +683,7 @@ func TestHandleTaskGroup_GarbageCollectedNode(t *testing.T) { require.Nil(state.UpsertNode(structs.MsgTypeTestSetup, n, 100)) job := mock.Job() - require.Nil(state.UpsertJob(101, job)) + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 101, job)) // Create 10 done allocs var allocs []*structs.Allocation diff --git a/nomad/drainer/watch_nodes_test.go b/nomad/drainer/watch_nodes_test.go index 7faedf561ff..abb01e6b92d 100644 --- a/nomad/drainer/watch_nodes_test.go +++ b/nomad/drainer/watch_nodes_test.go @@ -88,7 +88,7 @@ func TestNodeDrainWatcher_Remove(t *testing.T) { require.Equal(n, tracked[n.ID]) // Change the node to be not draining and wait for it to be untracked - require.Nil(state.UpdateNodeDrain(101, n.ID, nil, false, 0, nil)) + require.Nil(state.UpdateNodeDrain(structs.MsgTypeTestSetup, 101, n.ID, nil, false, 0, nil)) testutil.WaitForResult(func() (bool, error) { return len(m.events()) == 2, nil }, func(err error) { @@ -166,7 +166,7 @@ func TestNodeDrainWatcher_Update(t *testing.T) { // Change the node to have a new spec s2 := n.DrainStrategy.Copy() s2.Deadline += time.Hour - require.Nil(state.UpdateNodeDrain(101, n.ID, s2, false, 0, nil)) + require.Nil(state.UpdateNodeDrain(structs.MsgTypeTestSetup, 101, n.ID, s2, false, 0, nil)) // Wait for it to be updated testutil.WaitForResult(func() (bool, error) { diff --git a/nomad/eval_endpoint_test.go b/nomad/eval_endpoint_test.go index fa1303861c8..a95a898b6cc 100644 --- a/nomad/eval_endpoint_test.go +++ b/nomad/eval_endpoint_test.go @@ -29,7 +29,7 @@ func TestEvalEndpoint_GetEval(t *testing.T) { // Create the register request eval1 := mock.Eval() - s1.fsm.State().UpsertEvals(1000, []*structs.Evaluation{eval1}) + s1.fsm.State().UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval1}) // Lookup the eval get := &structs.EvalSpecificRequest{ @@ -73,7 +73,7 @@ func TestEvalEndpoint_GetEval_ACL(t *testing.T) { // Create the register request eval1 := mock.Eval() state := s1.fsm.State() - state.UpsertEvals(1000, []*structs.Evaluation{eval1}) + state.UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval1}) // Create ACL tokens validToken := mock.CreatePolicyAndToken(t, state, 1003, "test-valid", @@ -137,7 +137,7 @@ func TestEvalEndpoint_GetEval_Blocking(t *testing.T) { // First create an unrelated eval time.AfterFunc(100*time.Millisecond, func() { - err := state.UpsertEvals(100, []*structs.Evaluation{eval1}) + err := state.UpsertEvals(structs.MsgTypeTestSetup, 100, []*structs.Evaluation{eval1}) if err != nil { t.Fatalf("err: %v", err) } @@ -145,7 +145,7 @@ func TestEvalEndpoint_GetEval_Blocking(t *testing.T) { // Upsert the eval we are watching later time.AfterFunc(200*time.Millisecond, func() { - err := state.UpsertEvals(200, []*structs.Evaluation{eval2}) + err := state.UpsertEvals(structs.MsgTypeTestSetup, 200, []*structs.Evaluation{eval2}) if err != nil { t.Fatalf("err: %v", err) } @@ -260,9 +260,9 @@ func TestEvalEndpoint_Dequeue_WaitIndex_Snapshot(t *testing.T) { eval1 := mock.Eval() eval2 := mock.Eval() eval2.JobID = eval1.JobID - s1.fsm.State().UpsertEvals(1000, []*structs.Evaluation{eval1}) + s1.fsm.State().UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval1}) s1.evalBroker.Enqueue(eval1) - s1.fsm.State().UpsertEvals(1001, []*structs.Evaluation{eval2}) + s1.fsm.State().UpsertEvals(structs.MsgTypeTestSetup, 1001, []*structs.Evaluation{eval2}) // Dequeue the eval get := &structs.EvalDequeueRequest{ @@ -310,7 +310,7 @@ func TestEvalEndpoint_Dequeue_WaitIndex_Eval(t *testing.T) { eval1 := mock.Eval() eval2 := mock.Eval() eval2.JobID = eval1.JobID - s1.fsm.State().UpsertEvals(1000, []*structs.Evaluation{eval1}) + s1.fsm.State().UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval1}) eval2.ModifyIndex = 1001 s1.evalBroker.Enqueue(eval2) @@ -351,7 +351,7 @@ func TestEvalEndpoint_Dequeue_UpdateWaitIndex(t *testing.T) { state := s1.fsm.State() - if err := state.UpsertJob(999, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 999, job); err != nil { t.Fatalf("err: %v", err) } @@ -359,7 +359,7 @@ func TestEvalEndpoint_Dequeue_UpdateWaitIndex(t *testing.T) { eval.JobID = job.ID // Create an eval - if err := state.UpsertEvals(1, []*structs.Evaluation{eval}); err != nil { + if err := state.UpsertEvals(structs.MsgTypeTestSetup, 1, []*structs.Evaluation{eval}); err != nil { t.Fatalf("err: %v", err) } @@ -636,7 +636,7 @@ func TestEvalEndpoint_Reap(t *testing.T) { // Create the register request eval1 := mock.Eval() - s1.fsm.State().UpsertEvals(1000, []*structs.Evaluation{eval1}) + s1.fsm.State().UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval1}) // Reap the eval get := &structs.EvalDeleteRequest{ @@ -675,7 +675,7 @@ func TestEvalEndpoint_List(t *testing.T) { eval1.ID = "aaaaaaaa-3350-4b4b-d185-0e1992ed43e9" eval2 := mock.Eval() eval2.ID = "aaaabbbb-3350-4b4b-d185-0e1992ed43e9" - s1.fsm.State().UpsertEvals(1000, []*structs.Evaluation{eval1, eval2}) + s1.fsm.State().UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval1, eval2}) // Lookup the eval get := &structs.EvalListRequest{ @@ -733,7 +733,7 @@ func TestEvalEndpoint_List_ACL(t *testing.T) { eval2 := mock.Eval() eval2.ID = "aaaabbbb-3350-4b4b-d185-0e1992ed43e9" state := s1.fsm.State() - assert.Nil(state.UpsertEvals(1000, []*structs.Evaluation{eval1, eval2})) + assert.Nil(state.UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval1, eval2})) // Create ACL tokens validToken := mock.CreatePolicyAndToken(t, state, 1003, "test-valid", @@ -798,7 +798,7 @@ func TestEvalEndpoint_List_Blocking(t *testing.T) { // Upsert eval triggers watches time.AfterFunc(100*time.Millisecond, func() { - if err := state.UpsertEvals(2, []*structs.Evaluation{eval}); err != nil { + if err := state.UpsertEvals(structs.MsgTypeTestSetup, 2, []*structs.Evaluation{eval}); err != nil { t.Fatalf("err: %v", err) } }) @@ -1067,7 +1067,7 @@ func TestEvalEndpoint_Reblock_NonBlocked(t *testing.T) { s1.evalBroker.Enqueue(eval1) // Insert it into the state store - if err := s1.fsm.State().UpsertEvals(1000, []*structs.Evaluation{eval1}); err != nil { + if err := s1.fsm.State().UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval1}); err != nil { t.Fatal(err) } @@ -1111,7 +1111,7 @@ func TestEvalEndpoint_Reblock(t *testing.T) { s1.evalBroker.Enqueue(eval1) // Insert it into the state store - if err := s1.fsm.State().UpsertEvals(1000, []*structs.Evaluation{eval1}); err != nil { + if err := s1.fsm.State().UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval1}); err != nil { t.Fatal(err) } diff --git a/nomad/fsm.go b/nomad/fsm.go index 4049700fad1..5bde78acd6b 100644 --- a/nomad/fsm.go +++ b/nomad/fsm.go @@ -433,7 +433,7 @@ func (n *nomadFSM) applyDrainUpdate(reqType structs.MessageType, buf []byte, ind } } - if err := n.state.UpdateNodeDrainMsgType(reqType, index, req.NodeID, req.DrainStrategy, req.MarkEligible, req.UpdatedAt, req.NodeEvent); err != nil { + if err := n.state.UpdateNodeDrain(reqType, index, req.NodeID, req.DrainStrategy, req.MarkEligible, req.UpdatedAt, req.NodeEvent); err != nil { n.logger.Error("UpdateNodeDrain failed", "error", err) return err } @@ -500,7 +500,7 @@ func (n *nomadFSM) applyUpsertJob(msgType structs.MessageType, buf []byte, index */ req.Job.Canonicalize() - if err := n.state.UpsertJobMsgType(msgType, index, req.Job); err != nil { + if err := n.state.UpsertJob(msgType, index, req.Job); err != nil { n.logger.Error("UpsertJob failed", "error", err) return err } @@ -708,7 +708,7 @@ func (n *nomadFSM) applyUpdateEval(msgType structs.MessageType, buf []byte, inde } func (n *nomadFSM) upsertEvals(msgType structs.MessageType, index uint64, evals []*structs.Evaluation) error { - if err := n.state.UpsertEvalsMsgType(msgType, index, evals); err != nil { + if err := n.state.UpsertEvals(msgType, index, evals); err != nil { n.logger.Error("UpsertEvals failed", "error", err) return err } @@ -892,7 +892,7 @@ func (n *nomadFSM) applyUpsertNodeEvent(msgType structs.MessageType, buf []byte, panic(fmt.Errorf("failed to decode EmitNodeEventsRequest: %v", err)) } - if err := n.state.UpsertNodeEventsMsgType(msgType, index, req.NodeEvents); err != nil { + if err := n.state.UpsertNodeEvents(msgType, index, req.NodeEvents); err != nil { n.logger.Error("failed to add node events", "error", err) return err } @@ -1711,7 +1711,8 @@ func (n *nomadFSM) reconcileQueuedAllocations(index uint64) error { Status: structs.EvalStatusPending, AnnotatePlan: true, } - snap.UpsertEvals(100, []*structs.Evaluation{eval}) + // Ignore eval event creation during snapshot restore + snap.UpsertEvals(structs.IgnoreUnknownTypeFlag, 100, []*structs.Evaluation{eval}) // Create the scheduler and run it sched, err := scheduler.NewScheduler(eval.Type, n.logger, snap, planner) if err != nil { diff --git a/nomad/fsm_test.go b/nomad/fsm_test.go index 1239dea2cfc..e0695229bbf 100644 --- a/nomad/fsm_test.go +++ b/nomad/fsm_test.go @@ -1817,7 +1817,7 @@ func TestFSM_ApplyPlanResults(t *testing.T) { eval := mock.Eval() eval.JobID = job.ID - fsm.State().UpsertEvals(1, []*structs.Evaluation{eval}) + fsm.State().UpsertEvals(structs.MsgTypeTestSetup, 1, []*structs.Evaluation{eval}) fsm.State().UpsertJobSummary(1, mock.JobSummary(alloc.JobID)) @@ -1908,7 +1908,7 @@ func TestFSM_ApplyPlanResults(t *testing.T) { eval = mock.Eval() eval.JobID = job.ID - fsm.State().UpsertEvals(2, []*structs.Evaluation{eval}) + fsm.State().UpsertEvals(structs.MsgTypeTestSetup, 2, []*structs.Evaluation{eval}) evictAlloc.Job = nil evictAlloc.DesiredStatus = structs.AllocDesiredStatusEvict @@ -2018,7 +2018,7 @@ func TestFSM_JobStabilityUpdate(t *testing.T) { // Upsert a deployment job := mock.Job() - if err := state.UpsertJob(1, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 1, job); err != nil { t.Fatalf("bad: %v", err) } @@ -2063,7 +2063,7 @@ func TestFSM_DeploymentPromotion(t *testing.T) { tg2 := tg1.Copy() tg2.Name = "foo" j.TaskGroups = append(j.TaskGroups, tg2) - if err := state.UpsertJob(1, j); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 1, j); err != nil { t.Fatalf("bad: %v", err) } @@ -2521,9 +2521,9 @@ func TestFSM_SnapshotRestore_Jobs(t *testing.T) { fsm := testFSM(t) state := fsm.State() job1 := mock.Job() - state.UpsertJob(1000, job1) + state.UpsertJob(structs.MsgTypeTestSetup, 1000, job1) job2 := mock.Job() - state.UpsertJob(1001, job2) + state.UpsertJob(structs.MsgTypeTestSetup, 1001, job2) // Verify the contents ws := memdb.NewWatchSet() @@ -2545,9 +2545,9 @@ func TestFSM_SnapshotRestore_Evals(t *testing.T) { fsm := testFSM(t) state := fsm.State() eval1 := mock.Eval() - state.UpsertEvals(1000, []*structs.Evaluation{eval1}) + state.UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval1}) eval2 := mock.Eval() - state.UpsertEvals(1001, []*structs.Evaluation{eval2}) + state.UpsertEvals(structs.MsgTypeTestSetup, 1001, []*structs.Evaluation{eval2}) // Verify the contents fsm2 := testSnapshotRestore(t, fsm) @@ -2701,12 +2701,12 @@ func TestFSM_SnapshotRestore_JobSummary(t *testing.T) { state := fsm.State() job1 := mock.Job() - state.UpsertJob(1000, job1) + state.UpsertJob(structs.MsgTypeTestSetup, 1000, job1) ws := memdb.NewWatchSet() js1, _ := state.JobSummaryByID(ws, job1.Namespace, job1.ID) job2 := mock.Job() - state.UpsertJob(1001, job2) + state.UpsertJob(structs.MsgTypeTestSetup, 1001, job2) js2, _ := state.JobSummaryByID(ws, job2.Namespace, job2.ID) // Verify the contents @@ -2751,10 +2751,10 @@ func TestFSM_SnapshotRestore_JobVersions(t *testing.T) { fsm := testFSM(t) state := fsm.State() job1 := mock.Job() - state.UpsertJob(1000, job1) + state.UpsertJob(structs.MsgTypeTestSetup, 1000, job1) job2 := mock.Job() job2.ID = job1.ID - state.UpsertJob(1001, job2) + state.UpsertJob(structs.MsgTypeTestSetup, 1001, job2) // Verify the contents ws := memdb.NewWatchSet() @@ -2785,7 +2785,7 @@ func TestFSM_SnapshotRestore_Deployments(t *testing.T) { d1.JobID = j.ID d2.JobID = j.ID - state.UpsertJob(999, j) + state.UpsertJob(structs.MsgTypeTestSetup, 999, j) state.UpsertDeployment(1000, d1) state.UpsertDeployment(1001, d2) @@ -2896,12 +2896,12 @@ func TestFSM_ReconcileSummaries(t *testing.T) { // Make a job so that none of the tasks can be placed job1 := mock.Job() job1.TaskGroups[0].Tasks[0].Resources.CPU = 5000 - require.NoError(t, state.UpsertJob(1000, job1)) + require.NoError(t, state.UpsertJob(structs.MsgTypeTestSetup, 1000, job1)) // make a job which can make partial progress alloc := mock.Alloc() alloc.NodeID = node.ID - require.NoError(t, state.UpsertJob(1010, alloc.Job)) + require.NoError(t, state.UpsertJob(structs.MsgTypeTestSetup, 1010, alloc.Job)) require.NoError(t, state.UpsertAllocs(structs.MsgTypeTestSetup, 1011, []*structs.Allocation{alloc})) // Delete the summaries @@ -2982,7 +2982,7 @@ func TestFSM_ReconcileParentJobSummary(t *testing.T) { Payload: "random", } job1.TaskGroups[0].Count = 1 - state.UpsertJob(1000, job1) + state.UpsertJob(structs.MsgTypeTestSetup, 1000, job1) // Make a child job childJob := job1.Copy() @@ -2998,7 +2998,7 @@ func TestFSM_ReconcileParentJobSummary(t *testing.T) { alloc.JobID = childJob.ID alloc.ClientStatus = structs.AllocClientStatusRunning - state.UpsertJob(1010, childJob) + state.UpsertJob(structs.MsgTypeTestSetup, 1010, childJob) state.UpsertAllocs(structs.MsgTypeTestSetup, 1011, []*structs.Allocation{alloc}) // Make the summary incorrect in the state store diff --git a/nomad/job_endpoint.go b/nomad/job_endpoint.go index e9f55e10dc4..ed16809d12a 100644 --- a/nomad/job_endpoint.go +++ b/nomad/job_endpoint.go @@ -1704,13 +1704,13 @@ func (j *Job) Plan(args *structs.JobPlanRequest, reply *structs.JobPlanResponse) if oldJob.SpecChanged(args.Job) { // Insert the updated Job into the snapshot updatedIndex = oldJob.JobModifyIndex + 1 - if err := snap.UpsertJob(updatedIndex, args.Job); err != nil { + if err := snap.UpsertJob(structs.IgnoreUnknownTypeFlag, updatedIndex, args.Job); err != nil { return err } } } else if oldJob == nil { // Insert the updated Job into the snapshot - err := snap.UpsertJob(100, args.Job) + err := snap.UpsertJob(structs.IgnoreUnknownTypeFlag, 100, args.Job) if err != nil { return err } @@ -1733,7 +1733,8 @@ func (j *Job) Plan(args *structs.JobPlanRequest, reply *structs.JobPlanResponse) ModifyTime: now, } - snap.UpsertEvals(100, []*structs.Evaluation{eval}) + // Ignore eval event creation during snapshot eval creation + snap.UpsertEvals(structs.IgnoreUnknownTypeFlag, 100, []*structs.Evaluation{eval}) // Create an in-memory Planner that returns no errors and stores the // submitted plan and created evals. diff --git a/nomad/job_endpoint_test.go b/nomad/job_endpoint_test.go index 997bd5a94b6..461bac236ce 100644 --- a/nomad/job_endpoint_test.go +++ b/nomad/job_endpoint_test.go @@ -2528,12 +2528,12 @@ func TestJobEndpoint_Revert_ACL(t *testing.T) { // Create the jobs job := mock.Job() - err := state.UpsertJob(300, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 300, job) require.Nil(err) job2 := job.Copy() job2.Priority = 1 - err = state.UpsertJob(400, job2) + err = state.UpsertJob(structs.MsgTypeTestSetup, 400, job2) require.Nil(err) // Create revert request and enforcing it be at the current version @@ -2656,7 +2656,7 @@ func TestJobEndpoint_Stable_ACL(t *testing.T) { // Register the job job := mock.Job() - err := state.UpsertJob(1000, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) require.Nil(err) // Create stability request @@ -2887,7 +2887,7 @@ func TestJobEndpoint_Evaluate_ACL(t *testing.T) { // Create the job job := mock.Job() - err := state.UpsertJob(300, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 300, job) require.Nil(err) // Force a re-evaluation @@ -3141,7 +3141,7 @@ func TestJobEndpoint_Deregister_ACL(t *testing.T) { // Create and register a job job := mock.Job() - err := state.UpsertJob(100, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 100, job) require.Nil(err) // Deregister and purge @@ -3683,8 +3683,8 @@ func TestJobEndpoint_BatchDeregister_ACL(t *testing.T) { // Create and register a job job, job2 := mock.Job(), mock.Job() - require.Nil(state.UpsertJob(100, job)) - require.Nil(state.UpsertJob(101, job2)) + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 100, job)) + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 101, job2)) // Deregister req := &structs.JobBatchDeregisterRequest{ @@ -3828,7 +3828,7 @@ func TestJobEndpoint_GetJob_ACL(t *testing.T) { // Create the job job := mock.Job() - err := state.UpsertJob(1000, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) require.Nil(err) // Lookup the job @@ -3889,14 +3889,14 @@ func TestJobEndpoint_GetJob_Blocking(t *testing.T) { // Upsert a job we are not interested in first. time.AfterFunc(100*time.Millisecond, func() { - if err := state.UpsertJob(100, job1); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 100, job1); err != nil { t.Fatalf("err: %v", err) } }) // Upsert another job later which should trigger the watch. time.AfterFunc(200*time.Millisecond, func() { - if err := state.UpsertJob(200, job2); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 200, job2); err != nil { t.Fatalf("err: %v", err) } }) @@ -4037,11 +4037,11 @@ func TestJobEndpoint_GetJobVersions_ACL(t *testing.T) { // Create two versions of a job with different priorities job := mock.Job() job.Priority = 88 - err := state.UpsertJob(10, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 10, job) require.Nil(err) job.Priority = 100 - err = state.UpsertJob(100, job) + err = state.UpsertJob(structs.MsgTypeTestSetup, 100, job) require.Nil(err) // Lookup the job @@ -4206,14 +4206,14 @@ func TestJobEndpoint_GetJobVersions_Blocking(t *testing.T) { // Upsert a job we are not interested in first. time.AfterFunc(100*time.Millisecond, func() { - if err := state.UpsertJob(100, job1); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 100, job1); err != nil { t.Fatalf("err: %v", err) } }) // Upsert another job later which should trigger the watch. time.AfterFunc(200*time.Millisecond, func() { - if err := state.UpsertJob(200, job2); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 200, job2); err != nil { t.Fatalf("err: %v", err) } }) @@ -4244,7 +4244,7 @@ func TestJobEndpoint_GetJobVersions_Blocking(t *testing.T) { // Upsert the job again which should trigger the watch. time.AfterFunc(100*time.Millisecond, func() { - if err := state.UpsertJob(300, job3); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 300, job3); err != nil { t.Fatalf("err: %v", err) } }) @@ -4435,7 +4435,7 @@ func TestJobEndpoint_GetJobSummary_Blocking(t *testing.T) { // Create a job and insert it job1 := mock.Job() time.AfterFunc(200*time.Millisecond, func() { - if err := state.UpsertJob(100, job1); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 100, job1); err != nil { t.Fatalf("err: %v", err) } }) @@ -4528,7 +4528,7 @@ func TestJobEndpoint_ListJobs(t *testing.T) { // Create the register request job := mock.Job() state := s1.fsm.State() - err := state.UpsertJob(1000, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) if err != nil { t.Fatalf("err: %v", err) } @@ -4593,7 +4593,7 @@ func TestJobEndpoint_ListJobs_AllNamespaces_OSS(t *testing.T) { // Create the register request job := mock.Job() state := s1.fsm.State() - err := state.UpsertJob(1000, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) if err != nil { t.Fatalf("err: %v", err) } @@ -4660,7 +4660,7 @@ func TestJobEndpoint_ListJobs_WithACL(t *testing.T) { // Create the register request job := mock.Job() - err = state.UpsertJob(1000, job) + err = state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) require.Nil(err) req := &structs.JobListRequest{ @@ -4718,7 +4718,7 @@ func TestJobEndpoint_ListJobs_Blocking(t *testing.T) { // Upsert job triggers watches time.AfterFunc(100*time.Millisecond, func() { - if err := state.UpsertJob(100, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 100, job); err != nil { t.Fatalf("err: %v", err) } }) @@ -4969,8 +4969,7 @@ func TestJobEndpoint_Evaluations(t *testing.T) { eval2 := mock.Eval() eval2.JobID = eval1.JobID state := s1.fsm.State() - err := state.UpsertEvals(1000, - []*structs.Evaluation{eval1, eval2}) + err := state.UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval1, eval2}) if err != nil { t.Fatalf("err: %v", err) } @@ -5010,8 +5009,7 @@ func TestJobEndpoint_Evaluations_ACL(t *testing.T) { eval1 := mock.Eval() eval2 := mock.Eval() eval2.JobID = eval1.JobID - err := state.UpsertEvals(1000, - []*structs.Evaluation{eval1, eval2}) + err := state.UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval1, eval2}) require.Nil(err) // Lookup the jobs @@ -5073,7 +5071,7 @@ func TestJobEndpoint_Evaluations_Blocking(t *testing.T) { // First upsert an unrelated eval time.AfterFunc(100*time.Millisecond, func() { - err := state.UpsertEvals(100, []*structs.Evaluation{eval1}) + err := state.UpsertEvals(structs.MsgTypeTestSetup, 100, []*structs.Evaluation{eval1}) if err != nil { t.Fatalf("err: %v", err) } @@ -5081,7 +5079,7 @@ func TestJobEndpoint_Evaluations_Blocking(t *testing.T) { // Upsert an eval for the job we are interested in later time.AfterFunc(200*time.Millisecond, func() { - err := state.UpsertEvals(200, []*structs.Evaluation{eval2}) + err := state.UpsertEvals(structs.MsgTypeTestSetup, 200, []*structs.Evaluation{eval2}) if err != nil { t.Fatalf("err: %v", err) } @@ -5129,7 +5127,7 @@ func TestJobEndpoint_Deployments(t *testing.T) { d2 := mock.Deployment() d1.JobID = j.ID d2.JobID = j.ID - require.Nil(state.UpsertJob(1000, j), "UpsertJob") + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 1000, j), "UpsertJob") d1.JobCreateIndex = j.CreateIndex d2.JobCreateIndex = j.CreateIndex @@ -5166,7 +5164,7 @@ func TestJobEndpoint_Deployments_ACL(t *testing.T) { d2 := mock.Deployment() d1.JobID = j.ID d2.JobID = j.ID - require.Nil(state.UpsertJob(1000, j), "UpsertJob") + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 1000, j), "UpsertJob") d1.JobCreateIndex = j.CreateIndex d2.JobCreateIndex = j.CreateIndex require.Nil(state.UpsertDeployment(1001, d1), "UpsertDeployment") @@ -5229,7 +5227,7 @@ func TestJobEndpoint_Deployments_Blocking(t *testing.T) { d1 := mock.Deployment() d2 := mock.Deployment() d2.JobID = j.ID - require.Nil(state.UpsertJob(50, j), "UpsertJob") + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 50, j), "UpsertJob") d2.JobCreateIndex = j.CreateIndex // First upsert an unrelated eval time.AfterFunc(100*time.Millisecond, func() { @@ -5279,7 +5277,7 @@ func TestJobEndpoint_LatestDeployment(t *testing.T) { d2.JobID = j.ID d2.CreateIndex = d1.CreateIndex + 100 d2.ModifyIndex = d2.CreateIndex + 100 - require.Nil(state.UpsertJob(1000, j), "UpsertJob") + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 1000, j), "UpsertJob") d1.JobCreateIndex = j.CreateIndex d2.JobCreateIndex = j.CreateIndex require.Nil(state.UpsertDeployment(1001, d1), "UpsertDeployment") @@ -5318,7 +5316,7 @@ func TestJobEndpoint_LatestDeployment_ACL(t *testing.T) { d2.JobID = j.ID d2.CreateIndex = d1.CreateIndex + 100 d2.ModifyIndex = d2.CreateIndex + 100 - require.Nil(state.UpsertJob(1000, j), "UpsertJob") + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 1000, j), "UpsertJob") d1.JobCreateIndex = j.CreateIndex d2.JobCreateIndex = j.CreateIndex require.Nil(state.UpsertDeployment(1001, d1), "UpsertDeployment") @@ -5384,7 +5382,7 @@ func TestJobEndpoint_LatestDeployment_Blocking(t *testing.T) { d1 := mock.Deployment() d2 := mock.Deployment() d2.JobID = j.ID - require.Nil(state.UpsertJob(50, j), "UpsertJob") + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 50, j), "UpsertJob") d2.JobCreateIndex = j.CreateIndex // First upsert an unrelated eval @@ -5937,7 +5935,7 @@ func TestJobEndpoint_Dispatch_ACL(t *testing.T) { // Create a parameterized job job := mock.BatchJob() job.ParameterizedJob = &structs.ParameterizedJobConfig{} - err := state.UpsertJob(400, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 400, job) require.Nil(err) req := &structs.JobDispatchRequest{ @@ -6287,7 +6285,7 @@ func TestJobEndpoint_Scale(t *testing.T) { job := mock.Job() originalCount := job.TaskGroups[0].Count - err := state.UpsertJob(1000, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) require.Nil(err) groupName := job.TaskGroups[0].Name @@ -6344,7 +6342,7 @@ func TestJobEndpoint_Scale_DeploymentBlocking(t *testing.T) { for _, tc := range cases { // create a job with a deployment history job := mock.Job() - require.Nil(state.UpsertJob(1000, job), "UpsertJob") + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 1000, job), "UpsertJob") d1 := mock.Deployment() d1.Status = structs.DeploymentStatusCancelled d1.StatusDescription = structs.DeploymentStatusDescriptionNewerJob @@ -6439,7 +6437,7 @@ func TestJobEndpoint_Scale_InformationalEventsShouldNotBeBlocked(t *testing.T) { for _, tc := range cases { // create a job with a deployment history job := mock.Job() - require.Nil(state.UpsertJob(1000, job), "UpsertJob") + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 1000, job), "UpsertJob") d1 := mock.Deployment() d1.Status = structs.DeploymentStatusCancelled d1.StatusDescription = structs.DeploymentStatusDescriptionNewerJob @@ -6505,7 +6503,7 @@ func TestJobEndpoint_Scale_ACL(t *testing.T) { state := s1.fsm.State() job := mock.Job() - err := state.UpsertJob(1000, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) require.Nil(err) scale := &structs.JobScaleRequest{ @@ -6619,7 +6617,7 @@ func TestJobEndpoint_Scale_Invalid(t *testing.T) { require.Contains(err.Error(), "not found") // register the job - err = state.UpsertJob(1000, job) + err = state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) require.Nil(err) scale.Count = helper.Int64ToPtr(10) @@ -6706,7 +6704,7 @@ func TestJobEndpoint_InvalidCount(t *testing.T) { state := s1.fsm.State() job := mock.Job() - err := state.UpsertJob(1000, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) require.Nil(err) scale := &structs.JobScaleRequest{ @@ -6751,7 +6749,7 @@ func TestJobEndpoint_GetScaleStatus(t *testing.T) { require.Nil(resp2.JobScaleStatus) // stopped (previous version) - require.NoError(state.UpsertJob(1000, jobV1), "UpsertJob") + require.NoError(state.UpsertJob(structs.MsgTypeTestSetup, 1000, jobV1), "UpsertJob") a0 := mock.Alloc() a0.Job = jobV1 a0.Namespace = jobV1.Namespace @@ -6760,7 +6758,7 @@ func TestJobEndpoint_GetScaleStatus(t *testing.T) { require.NoError(state.UpsertAllocs(structs.MsgTypeTestSetup, 1010, []*structs.Allocation{a0}), "UpsertAllocs") jobV2 := jobV1.Copy() - require.NoError(state.UpsertJob(1100, jobV2), "UpsertJob") + require.NoError(state.UpsertJob(structs.MsgTypeTestSetup, 1100, jobV2), "UpsertJob") a1 := mock.Alloc() a1.Job = jobV2 a1.Namespace = jobV2.Namespace @@ -6853,7 +6851,7 @@ func TestJobEndpoint_GetScaleStatus_ACL(t *testing.T) { // Create the job job := mock.Job() - err := state.UpsertJob(1000, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) require.Nil(err) // Get the job scale status diff --git a/nomad/node_endpoint_test.go b/nomad/node_endpoint_test.go index a5c80b1dd85..7c78db46fa9 100644 --- a/nomad/node_endpoint_test.go +++ b/nomad/node_endpoint_test.go @@ -584,7 +584,7 @@ func TestClientEndpoint_Register_GetEvals(t *testing.T) { // Register a system job. job := mock.SystemJob() state := s1.fsm.State() - if err := state.UpsertJob(1, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 1, job); err != nil { t.Fatalf("err: %v", err) } @@ -679,7 +679,7 @@ func TestClientEndpoint_UpdateStatus_GetEvals(t *testing.T) { // Register a system job. job := mock.SystemJob() state := s1.fsm.State() - if err := state.UpsertJob(1, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 1, job); err != nil { t.Fatalf("err: %v", err) } @@ -938,7 +938,7 @@ func TestClientEndpoint_UpdateDrain(t *testing.T) { // Register a system job job := mock.SystemJob() - require.Nil(s1.State().UpsertJob(10, job)) + require.Nil(s1.State().UpsertJob(structs.MsgTypeTestSetup, 10, job)) // Update the eligibility and expect evals dereg.DrainStrategy = nil @@ -1200,7 +1200,7 @@ func TestClientEndpoint_UpdateEligibility(t *testing.T) { // Register a system job job := mock.SystemJob() - require.Nil(s1.State().UpsertJob(10, job)) + require.Nil(s1.State().UpsertJob(structs.MsgTypeTestSetup, 10, job)) // Update the eligibility and expect evals elig.Eligibility = structs.NodeSchedulingEligible @@ -2103,7 +2103,7 @@ func TestClientEndpoint_UpdateAlloc(t *testing.T) { // Inject mock job job := mock.Job() job.ID = "mytestjob" - err := state.UpsertJob(101, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 101, job) require.Nil(err) // Inject fake allocations @@ -2271,7 +2271,7 @@ func TestClientEndpoint_UpdateAlloc_Vault(t *testing.T) { // Inject mock job job := mock.Job() job.ID = alloc.JobID - err := state.UpsertJob(101, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 101, job) if err != nil { t.Fatalf("err: %v", err) } @@ -2330,7 +2330,7 @@ func TestClientEndpoint_CreateNodeEvals(t *testing.T) { // Inject a fake system job. job := mock.SystemJob() - if err := state.UpsertJob(3, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 3, job); err != nil { t.Fatalf("err: %v", err) } @@ -2762,7 +2762,7 @@ func TestClientEndpoint_ListNodes_Blocking(t *testing.T) { Deadline: 10 * time.Second, }, } - errCh <- state.UpdateNodeDrain(3, node.ID, s, false, 0, nil) + errCh <- state.UpdateNodeDrain(structs.MsgTypeTestSetup, 3, node.ID, s, false, 0, nil) }) req.MinQueryIndex = 2 diff --git a/nomad/operator_endpoint_test.go b/nomad/operator_endpoint_test.go index b78e075b6fd..47c632351bc 100644 --- a/nomad/operator_endpoint_test.go +++ b/nomad/operator_endpoint_test.go @@ -762,7 +762,7 @@ func generateSnapshot(t *testing.T) (*snapshot.Snapshot, *structs.Job) { err = msgpackrpc.CallWithCodec(codec, "Job.Register", jobReq, &jobResp) require.NoError(t, err) - err = s.State().UpsertJob(1000, job) + err = s.State().UpsertJob(structs.MsgTypeTestSetup, 1000, job) require.NoError(t, err) snapshot, err := snapshot.New(s.logger, s.raft) diff --git a/nomad/periodic_endpoint_test.go b/nomad/periodic_endpoint_test.go index 45b70b8802a..b4dd8ec26e5 100644 --- a/nomad/periodic_endpoint_test.go +++ b/nomad/periodic_endpoint_test.go @@ -26,7 +26,7 @@ func TestPeriodicEndpoint_Force(t *testing.T) { // Create and insert a periodic job. job := mock.PeriodicJob() job.Periodic.ProhibitOverlap = true // Shouldn't affect anything. - if err := state.UpsertJob(100, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 100, job); err != nil { t.Fatalf("err: %v", err) } s1.periodicDispatcher.Add(job) @@ -78,7 +78,7 @@ func TestPeriodicEndpoint_Force_ACL(t *testing.T) { // Create and insert a periodic job. job := mock.PeriodicJob() job.Periodic.ProhibitOverlap = true // Shouldn't affect anything. - assert.Nil(state.UpsertJob(100, job)) + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 100, job)) err := s1.periodicDispatcher.Add(job) assert.Nil(err) @@ -157,7 +157,7 @@ func TestPeriodicEndpoint_Force_NonPeriodic(t *testing.T) { // Create and insert a non-periodic job. job := mock.Job() - if err := state.UpsertJob(100, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 100, job); err != nil { t.Fatalf("err: %v", err) } diff --git a/nomad/periodic_test.go b/nomad/periodic_test.go index b860bcdf6d2..7618dacd59e 100644 --- a/nomad/periodic_test.go +++ b/nomad/periodic_test.go @@ -658,7 +658,7 @@ func TestPeriodicDispatch_RunningChildren_NoEvals(t *testing.T) { // Insert job. state := s1.fsm.State() job := mock.PeriodicJob() - if err := state.UpsertJob(1000, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job); err != nil { t.Fatalf("UpsertJob failed: %v", err) } @@ -682,12 +682,12 @@ func TestPeriodicDispatch_RunningChildren_ActiveEvals(t *testing.T) { // Insert periodic job and child. state := s1.fsm.State() job := mock.PeriodicJob() - if err := state.UpsertJob(1000, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job); err != nil { t.Fatalf("UpsertJob failed: %v", err) } childjob := deriveChildJob(job) - if err := state.UpsertJob(1001, childjob); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 1001, childjob); err != nil { t.Fatalf("UpsertJob failed: %v", err) } @@ -695,7 +695,7 @@ func TestPeriodicDispatch_RunningChildren_ActiveEvals(t *testing.T) { eval := mock.Eval() eval.JobID = childjob.ID eval.Status = structs.EvalStatusPending - if err := state.UpsertEvals(1002, []*structs.Evaluation{eval}); err != nil { + if err := state.UpsertEvals(structs.MsgTypeTestSetup, 1002, []*structs.Evaluation{eval}); err != nil { t.Fatalf("UpsertEvals failed: %v", err) } @@ -719,12 +719,12 @@ func TestPeriodicDispatch_RunningChildren_ActiveAllocs(t *testing.T) { // Insert periodic job and child. state := s1.fsm.State() job := mock.PeriodicJob() - if err := state.UpsertJob(1000, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job); err != nil { t.Fatalf("UpsertJob failed: %v", err) } childjob := deriveChildJob(job) - if err := state.UpsertJob(1001, childjob); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 1001, childjob); err != nil { t.Fatalf("UpsertJob failed: %v", err) } @@ -732,7 +732,7 @@ func TestPeriodicDispatch_RunningChildren_ActiveAllocs(t *testing.T) { eval := mock.Eval() eval.JobID = childjob.ID eval.Status = structs.EvalStatusPending - if err := state.UpsertEvals(1002, []*structs.Evaluation{eval}); err != nil { + if err := state.UpsertEvals(structs.MsgTypeTestSetup, 1002, []*structs.Evaluation{eval}); err != nil { t.Fatalf("UpsertEvals failed: %v", err) } diff --git a/nomad/plan_apply_test.go b/nomad/plan_apply_test.go index 6a80323f9a7..e76e6e0ce0f 100644 --- a/nomad/plan_apply_test.go +++ b/nomad/plan_apply_test.go @@ -100,7 +100,7 @@ func TestPlanApply_applyPlan(t *testing.T) { // Create an eval eval := mock.Eval() eval.JobID = alloc.JobID - if err := s1.State().UpsertEvals(1, []*structs.Evaluation{eval}); err != nil { + if err := s1.State().UpsertEvals(structs.MsgTypeTestSetup, 1, []*structs.Evaluation{eval}); err != nil { t.Fatalf("err: %v", err) } @@ -288,7 +288,7 @@ func TestPlanApply_applyPlanWithNormalizedAllocs(t *testing.T) { // Create an eval eval := mock.Eval() eval.JobID = alloc.JobID - if err := s1.State().UpsertEvals(1, []*structs.Evaluation{eval}); err != nil { + if err := s1.State().UpsertEvals(structs.MsgTypeTestSetup, 1, []*structs.Evaluation{eval}); err != nil { t.Fatalf("err: %v", err) } diff --git a/nomad/search_endpoint_test.go b/nomad/search_endpoint_test.go index ae7e62c8626..6d4726dfcac 100644 --- a/nomad/search_endpoint_test.go +++ b/nomad/search_endpoint_test.go @@ -22,7 +22,7 @@ func registerAndVerifyJob(s *Server, t *testing.T, prefix string, counter int) * job := mock.Job() job.ID = prefix + strconv.Itoa(counter) state := s.fsm.State() - if err := state.UpsertJob(jobIndex, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, jobIndex, job); err != nil { t.Fatalf("err: %v", err) } @@ -319,7 +319,7 @@ func TestSearch_PrefixSearch_AllWithJob(t *testing.T) { eval1 := mock.Eval() eval1.ID = job.ID - s.fsm.State().UpsertEvals(2000, []*structs.Evaluation{eval1}) + s.fsm.State().UpsertEvals(structs.MsgTypeTestSetup, 2000, []*structs.Evaluation{eval1}) req := &structs.SearchRequest{ Prefix: prefix, @@ -354,7 +354,7 @@ func TestSearch_PrefixSearch_Evals(t *testing.T) { testutil.WaitForLeader(t, s.RPC) eval1 := mock.Eval() - s.fsm.State().UpsertEvals(2000, []*structs.Evaluation{eval1}) + s.fsm.State().UpsertEvals(structs.MsgTypeTestSetup, 2000, []*structs.Evaluation{eval1}) prefix := eval1.ID[:len(eval1.ID)-2] @@ -453,7 +453,7 @@ func TestSearch_PrefixSearch_All_UUID(t *testing.T) { eval1 := mock.Eval() eval1.ID = node.ID - if err := state.UpsertEvals(1002, []*structs.Evaluation{eval1}); err != nil { + if err := state.UpsertEvals(structs.MsgTypeTestSetup, 1002, []*structs.Evaluation{eval1}); err != nil { t.Fatalf("err: %v", err) } @@ -575,7 +575,7 @@ func TestSearch_PrefixSearch_AllContext(t *testing.T) { eval1 := mock.Eval() eval1.ID = node.ID - if err := state.UpsertEvals(1000, []*structs.Evaluation{eval1}); err != nil { + if err := state.UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval1}); err != nil { t.Fatalf("err: %v", err) } diff --git a/nomad/state/deployment_events_test.go b/nomad/state/deployment_events_test.go index 08e06e45a8d..6786b6d5dd9 100644 --- a/nomad/state/deployment_events_test.go +++ b/nomad/state/deployment_events_test.go @@ -79,7 +79,7 @@ func WaitForEvents(t *testing.T, s *StateStore, index uint64, minEvents int, tim } maxAttempts-- if maxAttempts == 0 { - require.Fail(t, "reached max attempts waiting for desired event count") + require.Failf(t, "reached max attempts waiting for desired event count", "count %d", len(got)) } time.Sleep(10 * time.Millisecond) } diff --git a/nomad/state/events_test.go b/nomad/state/events_test.go index c69b34f1073..d7a7a2a7a62 100644 --- a/nomad/state/events_test.go +++ b/nomad/state/events_test.go @@ -263,7 +263,7 @@ func TestGenericEventsFromChanges_UpsertNodeEventsType(t *testing.T) { }, } - require.NoError(t, s.UpsertNodeEventsMsgType(msgType, 100, req.NodeEvents)) + require.NoError(t, s.UpsertNodeEvents(msgType, 100, req.NodeEvents)) events := WaitForEvents(t, s, 100, 1, 1*time.Second) require.Len(t, events, 2) @@ -315,7 +315,7 @@ func TestGenericEventsFromChanges_EvalUpdateRequestType(t *testing.T) { // setup e1 := mock.Eval() - require.NoError(t, s.UpsertEvals(10, []*structs.Evaluation{e1})) + require.NoError(t, s.UpsertEvals(structs.MsgTypeTestSetup, 10, []*structs.Evaluation{e1})) e2 := mock.Eval() e2.ID = e1.ID @@ -327,7 +327,7 @@ func TestGenericEventsFromChanges_EvalUpdateRequestType(t *testing.T) { Evals: []*structs.Evaluation{e2}, } - require.NoError(t, s.UpsertEvalsMsgType(msgType, 100, req.Evals)) + require.NoError(t, s.UpsertEvals(msgType, 100, req.Evals)) events := WaitForEvents(t, s, 100, 1, 1*time.Second) require.Len(t, events, 1) @@ -355,13 +355,13 @@ func TestGenericEventsFromChanges_ApplyPlanResultsRequestType(t *testing.T) { alloc.DeploymentID = d.ID alloc2.DeploymentID = d.ID - require.NoError(t, s.UpsertJob(9, job)) + require.NoError(t, s.UpsertJob(structs.MsgTypeTestSetup, 9, job)) eval := mock.Eval() eval.JobID = job.ID // Create an eval - require.NoError(t, s.UpsertEvals(10, []*structs.Evaluation{eval})) + require.NoError(t, s.UpsertEvals(structs.MsgTypeTestSetup, 10, []*structs.Evaluation{eval})) msgType := structs.ApplyPlanResultsRequestType req := &structs.ApplyPlanResultsRequest{ @@ -502,7 +502,7 @@ func TestGenericEventsFromChanges_AllocUpdateDesiredTransitionRequestType(t *tes alloc := mock.Alloc() - require.Nil(t, s.UpsertJob(10, alloc.Job)) + require.Nil(t, s.UpsertJob(structs.MsgTypeTestSetup, 10, alloc.Job)) require.Nil(t, s.UpsertAllocs(structs.MsgTypeTestSetup, 11, []*structs.Allocation{alloc})) msgType := structs.AllocUpdateDesiredTransitionRequestType diff --git a/nomad/state/state_changes.go b/nomad/state/state_changes.go index fa4c27a7b83..7b8f6420ef1 100644 --- a/nomad/state/state_changes.go +++ b/nomad/state/state_changes.go @@ -72,6 +72,7 @@ func (c *changeTrackerDB) WriteTxn(idx uint64) *txn { Txn: c.memdb.Txn(true), Index: idx, publish: c.publish, + msgType: structs.IgnoreUnknownTypeFlag, // The zero value of structs.MessageType is noderegistration. } t.Txn.TrackChanges() return t diff --git a/nomad/state/state_store.go b/nomad/state/state_store.go index 3eb825b7779..068c9454e14 100644 --- a/nomad/state/state_store.go +++ b/nomad/state/state_store.go @@ -952,20 +952,7 @@ func (s *StateStore) BatchUpdateNodeDrain(msgType structs.MessageType, index uin } // UpdateNodeDrain is used to update the drain of a node -func (s *StateStore) UpdateNodeDrainMsgType(msgType structs.MessageType, index uint64, nodeID string, - drain *structs.DrainStrategy, markEligible bool, updatedAt int64, event *structs.NodeEvent) error { - - txn := s.db.WriteTxnMsgT(msgType, index) - defer txn.Abort() - if err := s.updateNodeDrainImpl(txn, index, nodeID, drain, markEligible, updatedAt, event); err != nil { - return err - } - return txn.Commit() -} - -// UpdateNodeDrain is used to update the drain of a node -func (s *StateStore) UpdateNodeDrain(index uint64, nodeID string, - drain *structs.DrainStrategy, markEligible bool, updatedAt int64, event *structs.NodeEvent) error { +func (s *StateStore) UpdateNodeDrain(msgType structs.MessageType, index uint64, nodeID string, drain *structs.DrainStrategy, markEligible bool, updatedAt int64, event *structs.NodeEvent) error { txn := s.db.WriteTxn(index) defer txn.Abort() @@ -1064,23 +1051,10 @@ func (s *StateStore) UpdateNodeEligibility(msgType structs.MessageType, index ui return txn.Commit() } -func (s *StateStore) UpsertNodeEventsMsgType(msgType structs.MessageType, index uint64, nodeEvents map[string][]*structs.NodeEvent) error { - txn := s.db.WriteTxnMsgT(msgType, index) - defer txn.Abort() - - for nodeID, events := range nodeEvents { - if err := s.upsertNodeEvents(index, nodeID, events, txn); err != nil { - return err - } - } - - return txn.Commit() -} - // UpsertNodeEvents adds the node events to the nodes, rotating events as // necessary. -func (s *StateStore) UpsertNodeEvents(index uint64, nodeEvents map[string][]*structs.NodeEvent) error { - txn := s.db.WriteTxn(index) +func (s *StateStore) UpsertNodeEvents(msgType structs.MessageType, index uint64, nodeEvents map[string][]*structs.NodeEvent) error { + txn := s.db.WriteTxnMsgT(msgType, index) defer txn.Abort() for nodeID, events := range nodeEvents { @@ -1469,7 +1443,7 @@ func (s *StateStore) Nodes(ws memdb.WatchSet) (memdb.ResultIterator, error) { } // UpsertJob is used to register a job or update a job definition -func (s *StateStore) UpsertJob(index uint64, job *structs.Job) error { +func (s *StateStore) UpsertJob(msgType structs.MessageType, index uint64, job *structs.Job) error { txn := s.db.WriteTxn(index) defer txn.Abort() if err := s.upsertJobImpl(index, job, false, txn); err != nil { @@ -1478,16 +1452,6 @@ func (s *StateStore) UpsertJob(index uint64, job *structs.Job) error { return txn.Commit() } -// UpsertJob is used to register a job or update a job definition -func (s *StateStore) UpsertJobMsgType(msgType structs.MessageType, index uint64, job *structs.Job) error { - txn := s.db.WriteTxnMsgT(msgType, index) - defer txn.Abort() - if err := s.upsertJobImpl(index, job, false, txn); err != nil { - return err - } - return txn.Commit() -} - // UpsertJobTxn is used to register a job or update a job definition, like UpsertJob, // but in a transaction. Useful for when making multiple modifications atomically func (s *StateStore) UpsertJobTxn(index uint64, job *structs.Job, txn Txn) error { @@ -2684,19 +2648,7 @@ func (s *StateStore) PeriodicLaunches(ws memdb.WatchSet) (memdb.ResultIterator, } // UpsertEvals is used to upsert a set of evaluations -func (s *StateStore) UpsertEvals(index uint64, evals []*structs.Evaluation) error { - txn := s.db.WriteTxn(index) - defer txn.Abort() - - err := s.UpsertEvalsTxn(index, evals, txn) - if err == nil { - return txn.Commit() - } - return err -} - -// UpsertEvals is used to upsert a set of evaluations -func (s *StateStore) UpsertEvalsMsgType(msgType structs.MessageType, index uint64, evals []*structs.Evaluation) error { +func (s *StateStore) UpsertEvals(msgType structs.MessageType, index uint64, evals []*structs.Evaluation) error { txn := s.db.WriteTxnMsgT(msgType, index) defer txn.Abort() diff --git a/nomad/state/state_store_test.go b/nomad/state/state_store_test.go index 82329db2563..340d7d955fd 100644 --- a/nomad/state/state_store_test.go +++ b/nomad/state/state_store_test.go @@ -106,7 +106,7 @@ func TestStateStore_UpsertPlanResults_AllocationsCreated_Denormalized(t *testing job := alloc.Job alloc.Job = nil - if err := state.UpsertJob(999, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 999, job); err != nil { t.Fatalf("err: %v", err) } @@ -114,7 +114,7 @@ func TestStateStore_UpsertPlanResults_AllocationsCreated_Denormalized(t *testing eval.JobID = job.ID // Create an eval - if err := state.UpsertEvals(1, []*structs.Evaluation{eval}); err != nil { + if err := state.UpsertEvals(structs.MsgTypeTestSetup, 1, []*structs.Evaluation{eval}); err != nil { t.Fatalf("err: %v", err) } @@ -177,19 +177,19 @@ func TestStateStore_UpsertPlanResults_AllocationsDenormalized(t *testing.T) { require := require.New(t) require.NoError(state.UpsertAllocs(structs.MsgTypeTestSetup, 900, []*structs.Allocation{stoppedAlloc, preemptedAlloc})) - require.NoError(state.UpsertJob(999, job)) + require.NoError(state.UpsertJob(structs.MsgTypeTestSetup, 999, job)) // modify job and ensure that stopped and preempted alloc point to original Job mJob := job.Copy() mJob.TaskGroups[0].Name = "other" - require.NoError(state.UpsertJob(1001, mJob)) + require.NoError(state.UpsertJob(structs.MsgTypeTestSetup, 1001, mJob)) eval := mock.Eval() eval.JobID = job.ID // Create an eval - require.NoError(state.UpsertEvals(1, []*structs.Evaluation{eval})) + require.NoError(state.UpsertEvals(structs.MsgTypeTestSetup, 1, []*structs.Evaluation{eval})) // Create a plan result res := structs.ApplyPlanResultsRequest{ @@ -262,7 +262,7 @@ func TestStateStore_UpsertPlanResults_Deployment(t *testing.T) { alloc.DeploymentID = d.ID alloc2.DeploymentID = d.ID - if err := state.UpsertJob(999, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 999, job); err != nil { t.Fatalf("err: %v", err) } @@ -270,7 +270,7 @@ func TestStateStore_UpsertPlanResults_Deployment(t *testing.T) { eval.JobID = job.ID // Create an eval - if err := state.UpsertEvals(1, []*structs.Evaluation{eval}); err != nil { + if err := state.UpsertEvals(structs.MsgTypeTestSetup, 1, []*structs.Evaluation{eval}); err != nil { t.Fatalf("err: %v", err) } @@ -365,13 +365,13 @@ func TestStateStore_UpsertPlanResults_PreemptedAllocs(t *testing.T) { alloc.Job = nil // Insert job - err := state.UpsertJob(999, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 999, job) require.NoError(err) // Create an eval eval := mock.Eval() eval.JobID = job.ID - err = state.UpsertEvals(1, []*structs.Evaluation{eval}) + err = state.UpsertEvals(structs.MsgTypeTestSetup, 1, []*structs.Evaluation{eval}) require.NoError(err) // Insert alloc that will be preempted in the plan @@ -442,7 +442,7 @@ func TestStateStore_UpsertPlanResults_DeploymentUpdates(t *testing.T) { // Create a job that applies to all job := mock.Job() - if err := state.UpsertJob(998, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 998, job); err != nil { t.Fatalf("err: %v", err) } @@ -458,7 +458,7 @@ func TestStateStore_UpsertPlanResults_DeploymentUpdates(t *testing.T) { eval.JobID = job.ID // Create an eval - if err := state.UpsertEvals(1, []*structs.Evaluation{eval}); err != nil { + if err := state.UpsertEvals(structs.MsgTypeTestSetup, 1, []*structs.Evaluation{eval}); err != nil { t.Fatalf("err: %v", err) } alloc := mock.Alloc() @@ -570,7 +570,7 @@ func TestStateStore_OldDeployment(t *testing.T) { state := testStateStore(t) job := mock.Job() job.ID = "job1" - state.UpsertJob(1000, job) + state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) deploy1 := mock.Deployment() deploy1.JobID = job.ID @@ -1002,7 +1002,7 @@ func TestStateStore_UpdateNodeDrain_Node(t *testing.T) { Subsystem: structs.NodeEventSubsystemDrain, Timestamp: time.Now(), } - require.Nil(state.UpdateNodeDrain(1001, node.ID, expectedDrain, false, 7, event)) + require.Nil(state.UpdateNodeDrain(structs.MsgTypeTestSetup, 1001, node.ID, expectedDrain, false, 7, event)) require.True(watchFired(ws)) ws = memdb.NewWatchSet() @@ -1050,7 +1050,7 @@ func TestStateStore_AddSingleNodeEvent(t *testing.T) { nodeEvents := map[string][]*structs.NodeEvent{ node.ID: {nodeEvent}, } - err = state.UpsertNodeEvents(uint64(1001), nodeEvents) + err = state.UpsertNodeEvents(structs.MsgTypeTestSetup, uint64(1001), nodeEvents) require.Nil(err) require.True(watchFired(ws)) @@ -1096,7 +1096,7 @@ func TestStateStore_NodeEvents_RetentionWindow(t *testing.T) { nodeEvents := map[string][]*structs.NodeEvent{ out.ID: {nodeEvent}, } - err := state.UpsertNodeEvents(uint64(i), nodeEvents) + err := state.UpsertNodeEvents(structs.MsgTypeTestSetup, uint64(i), nodeEvents) require.Nil(err) require.True(watchFired(ws)) @@ -1138,7 +1138,7 @@ func TestStateStore_UpdateNodeDrain_ResetEligiblity(t *testing.T) { Subsystem: structs.NodeEventSubsystemDrain, Timestamp: time.Now(), } - require.Nil(state.UpdateNodeDrain(1001, node.ID, drain, false, 7, event1)) + require.Nil(state.UpdateNodeDrain(structs.MsgTypeTestSetup, 1001, node.ID, drain, false, 7, event1)) require.True(watchFired(ws)) // Remove the drain @@ -1147,7 +1147,7 @@ func TestStateStore_UpdateNodeDrain_ResetEligiblity(t *testing.T) { Subsystem: structs.NodeEventSubsystemDrain, Timestamp: time.Now(), } - require.Nil(state.UpdateNodeDrain(1002, node.ID, nil, true, 9, event2)) + require.Nil(state.UpdateNodeDrain(structs.MsgTypeTestSetup, 1002, node.ID, nil, true, 9, event2)) ws = memdb.NewWatchSet() out, err := state.NodeByID(ws, node.ID) @@ -1213,7 +1213,7 @@ func TestStateStore_UpdateNodeEligibility(t *testing.T) { Deadline: -1 * time.Second, }, } - require.Nil(state.UpdateNodeDrain(1002, node.ID, expectedDrain, false, 7, nil)) + require.Nil(state.UpdateNodeDrain(structs.MsgTypeTestSetup, 1002, node.ID, expectedDrain, false, 7, nil)) // Try to set the node to eligible err = state.UpdateNodeEligibility(structs.MsgTypeTestSetup, 1003, node.ID, structs.NodeSchedulingEligible, 9, nil) @@ -1394,7 +1394,7 @@ func TestStateStore_UpsertJob_Job(t *testing.T) { t.Fatalf("bad: %v", err) } - if err := state.UpsertJob(1000, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job); err != nil { t.Fatalf("err: %v", err) } if !watchFired(ws) { @@ -1474,14 +1474,14 @@ func TestStateStore_UpdateUpsertJob_Job(t *testing.T) { t.Fatalf("bad: %v", err) } - if err := state.UpsertJob(1000, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job); err != nil { t.Fatalf("err: %v", err) } job2 := mock.Job() job2.ID = job.ID job2.AllAtOnce = true - err = state.UpsertJob(1001, job2) + err = state.UpsertJob(structs.MsgTypeTestSetup, 1001, job2) if err != nil { t.Fatalf("err: %v", err) } @@ -1579,7 +1579,7 @@ func TestStateStore_UpdateUpsertJob_PeriodicJob(t *testing.T) { t.Fatalf("bad: %v", err) } - if err := state.UpsertJob(1000, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job); err != nil { t.Fatalf("err: %v", err) } @@ -1587,21 +1587,21 @@ func TestStateStore_UpdateUpsertJob_PeriodicJob(t *testing.T) { job2 := job.Copy() job2.Periodic = nil job2.ID = fmt.Sprintf("%v/%s-1490635020", job.ID, structs.PeriodicLaunchSuffix) - err = state.UpsertJob(1001, job2) + err = state.UpsertJob(structs.MsgTypeTestSetup, 1001, job2) if err != nil { t.Fatalf("err: %v", err) } eval := mock.Eval() eval.JobID = job2.ID - err = state.UpsertEvals(1002, []*structs.Evaluation{eval}) + err = state.UpsertEvals(structs.MsgTypeTestSetup, 1002, []*structs.Evaluation{eval}) if err != nil { t.Fatalf("err: %v", err) } job3 := job.Copy() job3.TaskGroups[0].Tasks[0].Name = "new name" - err = state.UpsertJob(1003, job3) + err = state.UpsertJob(structs.MsgTypeTestSetup, 1003, job3) if err != nil { t.Fatalf("err: %v", err) } @@ -1630,7 +1630,7 @@ func TestStateStore_UpsertJob_BadNamespace(t *testing.T) { job := mock.Job() job.Namespace = "foo" - err := state.UpsertJob(1000, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) assert.Contains(err.Error(), "nonexistent namespace") ws := memdb.NewWatchSet() @@ -1654,13 +1654,13 @@ func TestStateStore_UpsertJob_ChildJob(t *testing.T) { t.Fatalf("bad: %v", err) } - if err := state.UpsertJob(1000, parent); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, parent); err != nil { t.Fatalf("err: %v", err) } child := mock.Job() child.ParentID = parent.ID - if err := state.UpsertJob(1001, child); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 1001, child); err != nil { t.Fatalf("err: %v", err) } @@ -1702,7 +1702,7 @@ func TestStateStore_UpdateUpsertJob_JobVersion(t *testing.T) { t.Fatalf("bad: %v", err) } - if err := state.UpsertJob(1000, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job); err != nil { t.Fatalf("err: %v", err) } @@ -1715,7 +1715,7 @@ func TestStateStore_UpdateUpsertJob_JobVersion(t *testing.T) { finalJob = mock.Job() finalJob.ID = job.ID finalJob.Name = fmt.Sprintf("%d", i) - err = state.UpsertJob(uint64(1000+i), finalJob) + err = state.UpsertJob(structs.MsgTypeTestSetup, uint64(1000+i), finalJob) if err != nil { t.Fatalf("err: %v", err) } @@ -1782,7 +1782,7 @@ func TestStateStore_DeleteJob_Job(t *testing.T) { state := testStateStore(t) job := mock.Job() - err := state.UpsertJob(1000, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) if err != nil { t.Fatalf("err: %v", err) } @@ -1872,7 +1872,7 @@ func TestStateStore_DeleteJobTxn_BatchDeletes(t *testing.T) { stateIndex++ job := mock.BatchJob() - err := state.UpsertJob(stateIndex, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, stateIndex, job) require.NoError(t, err) jobs[i] = job @@ -1886,7 +1886,7 @@ func TestStateStore_DeleteJobTxn_BatchDeletes(t *testing.T) { "Version": fmt.Sprintf("%d", vi), } - require.NoError(t, state.UpsertJob(stateIndex, job)) + require.NoError(t, state.UpsertJob(structs.MsgTypeTestSetup, stateIndex, job)) } } @@ -1943,7 +1943,7 @@ func TestStateStore_DeleteJob_MultipleVersions(t *testing.T) { ws := memdb.NewWatchSet() _, err := state.JobVersionsByID(ws, job.Namespace, job.ID) assert.Nil(err) - assert.Nil(state.UpsertJob(1000, job)) + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 1000, job)) assert.True(watchFired(ws)) var finalJob *structs.Job @@ -1951,7 +1951,7 @@ func TestStateStore_DeleteJob_MultipleVersions(t *testing.T) { finalJob = mock.Job() finalJob.ID = job.ID finalJob.Priority = i - assert.Nil(state.UpsertJob(uint64(1000+i), finalJob)) + assert.Nil(state.UpsertJob(structs.MsgTypeTestSetup, uint64(1000+i), finalJob)) } assert.Nil(state.DeleteJob(1020, job.Namespace, job.ID)) @@ -1991,14 +1991,14 @@ func TestStateStore_DeleteJob_ChildJob(t *testing.T) { state := testStateStore(t) parent := mock.Job() - if err := state.UpsertJob(998, parent); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 998, parent); err != nil { t.Fatalf("err: %v", err) } child := mock.Job() child.ParentID = parent.ID - if err := state.UpsertJob(999, child); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 999, child); err != nil { t.Fatalf("err: %v", err) } @@ -2048,7 +2048,7 @@ func TestStateStore_Jobs(t *testing.T) { job := mock.Job() jobs = append(jobs, job) - err := state.UpsertJob(1000+uint64(i), job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000+uint64(i), job) if err != nil { t.Fatalf("err: %v", err) } @@ -2090,7 +2090,7 @@ func TestStateStore_JobVersions(t *testing.T) { job := mock.Job() jobs = append(jobs, job) - err := state.UpsertJob(1000+uint64(i), job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000+uint64(i), job) if err != nil { t.Fatalf("err: %v", err) } @@ -2129,7 +2129,7 @@ func TestStateStore_JobsByIDPrefix(t *testing.T) { job := mock.Job() job.ID = "redis" - err := state.UpsertJob(1000, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) if err != nil { t.Fatalf("err: %v", err) } @@ -2172,7 +2172,7 @@ func TestStateStore_JobsByIDPrefix(t *testing.T) { job = mock.Job() job.ID = "riak" - err = state.UpsertJob(1001, job) + err = state.UpsertJob(structs.MsgTypeTestSetup, 1001, job) if err != nil { t.Fatalf("err: %v", err) } @@ -2216,7 +2216,7 @@ func TestStateStore_JobsByPeriodic(t *testing.T) { job := mock.Job() nonPeriodic = append(nonPeriodic, job) - err := state.UpsertJob(1000+uint64(i), job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000+uint64(i), job) if err != nil { t.Fatalf("err: %v", err) } @@ -2226,7 +2226,7 @@ func TestStateStore_JobsByPeriodic(t *testing.T) { job := mock.PeriodicJob() periodic = append(periodic, job) - err := state.UpsertJob(2000+uint64(i), job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 2000+uint64(i), job) if err != nil { t.Fatalf("err: %v", err) } @@ -2289,7 +2289,7 @@ func TestStateStore_JobsByScheduler(t *testing.T) { job := mock.Job() serviceJobs = append(serviceJobs, job) - err := state.UpsertJob(1000+uint64(i), job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000+uint64(i), job) if err != nil { t.Fatalf("err: %v", err) } @@ -2300,7 +2300,7 @@ func TestStateStore_JobsByScheduler(t *testing.T) { job.Status = structs.JobStatusRunning sysJobs = append(sysJobs, job) - err := state.UpsertJob(2000+uint64(i), job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 2000+uint64(i), job) if err != nil { t.Fatalf("err: %v", err) } @@ -2367,7 +2367,7 @@ func TestStateStore_JobsByGC(t *testing.T) { } nonGc[job.ID] = struct{}{} - if err := state.UpsertJob(1000+uint64(i), job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 1000+uint64(i), job); err != nil { t.Fatalf("err: %v", err) } } @@ -2377,7 +2377,7 @@ func TestStateStore_JobsByGC(t *testing.T) { job.Type = structs.JobTypeBatch gc[job.ID] = struct{}{} - if err := state.UpsertJob(2000+uint64(i), job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 2000+uint64(i), job); err != nil { t.Fatalf("err: %v", err) } @@ -2385,7 +2385,7 @@ func TestStateStore_JobsByGC(t *testing.T) { eval := mock.Eval() eval.JobID = job.ID eval.Status = structs.EvalStatusComplete - if err := state.UpsertEvals(2000+uint64(i+1), []*structs.Evaluation{eval}); err != nil { + if err := state.UpsertEvals(structs.MsgTypeTestSetup, 2000+uint64(i+1), []*structs.Evaluation{eval}); err != nil { t.Fatalf("err: %v", err) } @@ -3536,11 +3536,11 @@ func TestStateStore_CSIPluginJobs(t *testing.T) { Type: structs.CSIPluginTypeNode, } - err := s.UpsertJob(index, controllerJob) + err := s.UpsertJob(structs.MsgTypeTestSetup, index, controllerJob) require.NoError(t, err) index++ - err = s.UpsertJob(index, nodeJob) + err = s.UpsertJob(structs.MsgTypeTestSetup, index, nodeJob) require.NoError(t, err) index++ @@ -3701,7 +3701,7 @@ func TestStateStore_LatestIndex(t *testing.T) { } exp := uint64(2000) - if err := state.UpsertJob(exp, mock.Job()); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, exp, mock.Job()); err != nil { t.Fatalf("err: %v", err) } @@ -3755,7 +3755,7 @@ func TestStateStore_UpsertEvals_Eval(t *testing.T) { t.Fatalf("bad: %v", err) } - err := state.UpsertEvals(1000, []*structs.Evaluation{eval}) + err := state.UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval}) if err != nil { t.Fatalf("err: %v", err) } @@ -3800,7 +3800,7 @@ func TestStateStore_UpsertEvals_CancelBlocked(t *testing.T) { b2.JobID = j b2.Status = structs.EvalStatusBlocked - err := state.UpsertEvals(999, []*structs.Evaluation{b1, b2}) + err := state.UpsertEvals(structs.MsgTypeTestSetup, 999, []*structs.Evaluation{b1, b2}) if err != nil { t.Fatalf("err: %v", err) } @@ -3820,7 +3820,7 @@ func TestStateStore_UpsertEvals_CancelBlocked(t *testing.T) { t.Fatalf("bad: %v", err) } - if err := state.UpsertEvals(1000, []*structs.Evaluation{eval}); err != nil { + if err := state.UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval}); err != nil { t.Fatalf("err: %v", err) } @@ -3872,7 +3872,7 @@ func TestStateStore_Update_UpsertEvals_Eval(t *testing.T) { state := testStateStore(t) eval := mock.Eval() - err := state.UpsertEvals(1000, []*structs.Evaluation{eval}) + err := state.UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval}) if err != nil { t.Fatalf("err: %v", err) } @@ -3891,7 +3891,7 @@ func TestStateStore_Update_UpsertEvals_Eval(t *testing.T) { eval2 := mock.Eval() eval2.ID = eval.ID eval2.JobID = eval.JobID - err = state.UpsertEvals(1001, []*structs.Evaluation{eval2}) + err = state.UpsertEvals(structs.MsgTypeTestSetup, 1001, []*structs.Evaluation{eval2}) if err != nil { t.Fatalf("err: %v", err) } @@ -3939,14 +3939,14 @@ func TestStateStore_UpsertEvals_Eval_ChildJob(t *testing.T) { state := testStateStore(t) parent := mock.Job() - if err := state.UpsertJob(998, parent); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 998, parent); err != nil { t.Fatalf("err: %v", err) } child := mock.Job() child.ParentID = parent.ID - if err := state.UpsertJob(999, child); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 999, child); err != nil { t.Fatalf("err: %v", err) } @@ -3968,7 +3968,7 @@ func TestStateStore_UpsertEvals_Eval_ChildJob(t *testing.T) { t.Fatalf("bad: %v", err) } - err := state.UpsertEvals(1000, []*structs.Evaluation{eval}) + err := state.UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval}) if err != nil { t.Fatalf("err: %v", err) } @@ -4078,7 +4078,7 @@ func TestStateStore_DeleteEval_Eval(t *testing.T) { state.UpsertJobSummary(901, mock.JobSummary(eval2.JobID)) state.UpsertJobSummary(902, mock.JobSummary(alloc1.JobID)) state.UpsertJobSummary(903, mock.JobSummary(alloc2.JobID)) - err := state.UpsertEvals(1000, []*structs.Evaluation{eval1, eval2}) + err := state.UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval1, eval2}) if err != nil { t.Fatalf("err: %v", err) } @@ -4163,14 +4163,14 @@ func TestStateStore_DeleteEval_ChildJob(t *testing.T) { state := testStateStore(t) parent := mock.Job() - if err := state.UpsertJob(998, parent); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 998, parent); err != nil { t.Fatalf("err: %v", err) } child := mock.Job() child.ParentID = parent.ID - if err := state.UpsertJob(999, child); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 999, child); err != nil { t.Fatalf("err: %v", err) } @@ -4179,7 +4179,7 @@ func TestStateStore_DeleteEval_ChildJob(t *testing.T) { alloc1 := mock.Alloc() alloc1.JobID = child.ID - err := state.UpsertEvals(1000, []*structs.Evaluation{eval1}) + err := state.UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval1}) if err != nil { t.Fatalf("err: %v", err) } @@ -4238,11 +4238,11 @@ func TestStateStore_EvalsByJob(t *testing.T) { eval3 := mock.Eval() evals := []*structs.Evaluation{eval1, eval2} - err := state.UpsertEvals(1000, evals) + err := state.UpsertEvals(structs.MsgTypeTestSetup, 1000, evals) if err != nil { t.Fatalf("err: %v", err) } - err = state.UpsertEvals(1001, []*structs.Evaluation{eval3}) + err = state.UpsertEvals(structs.MsgTypeTestSetup, 1001, []*structs.Evaluation{eval3}) if err != nil { t.Fatalf("err: %v", err) } @@ -4275,7 +4275,7 @@ func TestStateStore_Evals(t *testing.T) { eval := mock.Eval() evals = append(evals, eval) - err := state.UpsertEvals(1000+uint64(i), []*structs.Evaluation{eval}) + err := state.UpsertEvals(structs.MsgTypeTestSetup, 1000+uint64(i), []*structs.Evaluation{eval}) if err != nil { t.Fatalf("err: %v", err) } @@ -4331,7 +4331,7 @@ func TestStateStore_EvalsByIDPrefix(t *testing.T) { evals = append(evals, eval) } - err := state.UpsertEvals(1000, evals) + err := state.UpsertEvals(structs.MsgTypeTestSetup, 1000, evals) if err != nil { t.Fatalf("err: %v", err) } @@ -4415,13 +4415,13 @@ func TestStateStore_UpdateAllocsFromClient(t *testing.T) { state := testStateStore(t) parent := mock.Job() - if err := state.UpsertJob(998, parent); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 998, parent); err != nil { t.Fatalf("err: %v", err) } child := mock.Job() child.ParentID = parent.ID - if err := state.UpsertJob(999, child); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 999, child); err != nil { t.Fatalf("err: %v", err) } @@ -4506,10 +4506,10 @@ func TestStateStore_UpdateAllocsFromClient_ChildJob(t *testing.T) { alloc1 := mock.Alloc() alloc2 := mock.Alloc() - if err := state.UpsertJob(999, alloc1.Job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 999, alloc1.Job); err != nil { t.Fatalf("err: %v", err) } - if err := state.UpsertJob(999, alloc2.Job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 999, alloc2.Job); err != nil { t.Fatalf("err: %v", err) } @@ -4641,7 +4641,7 @@ func TestStateStore_UpdateMultipleAllocsFromClient(t *testing.T) { state := testStateStore(t) alloc := mock.Alloc() - if err := state.UpsertJob(999, alloc.Job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 999, alloc.Job); err != nil { t.Fatalf("err: %v", err) } err := state.UpsertAllocs(structs.MsgTypeTestSetup, 1000, []*structs.Allocation{alloc}) @@ -4720,7 +4720,7 @@ func TestStateStore_UpdateAllocsFromClient_Deployment(t *testing.T) { deployment.TaskGroups[alloc.TaskGroup].ProgressDeadline = pdeadline alloc.DeploymentID = deployment.ID - require.Nil(state.UpsertJob(999, alloc.Job)) + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, alloc.Job)) require.Nil(state.UpsertDeployment(1000, deployment)) require.Nil(state.UpsertAllocs(structs.MsgTypeTestSetup, 1001, []*structs.Allocation{alloc})) @@ -4766,7 +4766,7 @@ func TestStateStore_UpdateAllocsFromClient_DeploymentStateMerges(t *testing.T) { Canary: true, } - require.Nil(state.UpsertJob(999, alloc.Job)) + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, alloc.Job)) require.Nil(state.UpsertDeployment(1000, deployment)) require.Nil(state.UpsertAllocs(structs.MsgTypeTestSetup, 1001, []*structs.Allocation{alloc})) @@ -4797,7 +4797,7 @@ func TestStateStore_UpsertAlloc_Alloc(t *testing.T) { state := testStateStore(t) alloc := mock.Alloc() - if err := state.UpsertJob(999, alloc.Job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 999, alloc.Job); err != nil { t.Fatalf("err: %v", err) } @@ -4880,7 +4880,7 @@ func TestStateStore_UpsertAlloc_Deployment(t *testing.T) { deployment.TaskGroups[alloc.TaskGroup].ProgressDeadline = pdeadline alloc.DeploymentID = deployment.ID - require.Nil(state.UpsertJob(999, alloc.Job)) + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, alloc.Job)) require.Nil(state.UpsertDeployment(1000, deployment)) // Create a watch set so we can test that update fires the watch @@ -4939,14 +4939,14 @@ func TestStateStore_UpsertAlloc_ChildJob(t *testing.T) { state := testStateStore(t) parent := mock.Job() - if err := state.UpsertJob(998, parent); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 998, parent); err != nil { t.Fatalf("err: %v", err) } child := mock.Job() child.ParentID = parent.ID - if err := state.UpsertJob(999, child); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 999, child); err != nil { t.Fatalf("err: %v", err) } @@ -4998,7 +4998,7 @@ func TestStateStore_UpdateAlloc_Alloc(t *testing.T) { state := testStateStore(t) alloc := mock.Alloc() - if err := state.UpsertJob(999, alloc.Job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 999, alloc.Job); err != nil { t.Fatalf("err: %v", err) } @@ -5100,7 +5100,7 @@ func TestStateStore_UpdateAlloc_Lost(t *testing.T) { alloc := mock.Alloc() alloc.ClientStatus = "foo" - if err := state.UpsertJob(999, alloc.Job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 999, alloc.Job); err != nil { t.Fatalf("err: %v", err) } @@ -5138,7 +5138,7 @@ func TestStateStore_UpdateAlloc_NoJob(t *testing.T) { // Upsert a job state.UpsertJobSummary(998, mock.JobSummary(alloc.JobID)) - if err := state.UpsertJob(999, alloc.Job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 999, alloc.Job); err != nil { t.Fatalf("err: %v", err) } @@ -5181,7 +5181,7 @@ func TestStateStore_UpdateAllocDesiredTransition(t *testing.T) { state := testStateStore(t) alloc := mock.Alloc() - require.Nil(state.UpsertJob(999, alloc.Job)) + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 999, alloc.Job)) require.Nil(state.UpsertAllocs(structs.MsgTypeTestSetup, 1000, []*structs.Allocation{alloc})) t1 := &structs.DesiredTransition{ @@ -5249,7 +5249,7 @@ func TestStateStore_JobSummary(t *testing.T) { // Add a job job := mock.Job() - state.UpsertJob(900, job) + state.UpsertJob(structs.MsgTypeTestSetup, 900, job) // Get the job back ws := memdb.NewWatchSet() @@ -5331,7 +5331,7 @@ func TestStateStore_JobSummary(t *testing.T) { // Re-register the same job job1 := mock.Job() job1.ID = job.ID - state.UpsertJob(1000, job1) + state.UpsertJob(structs.MsgTypeTestSetup, 1000, job1) outJob2, _ := state.JobByID(ws, job1.Namespace, job1.ID) if outJob2.CreateIndex != 1000 { t.Fatalf("bad create index: %v", outJob2.CreateIndex) @@ -5378,7 +5378,7 @@ func TestStateStore_ReconcileJobSummary(t *testing.T) { tg2 := alloc.Job.TaskGroups[0].Copy() tg2.Name = "db" alloc.Job.TaskGroups = append(alloc.Job.TaskGroups, tg2) - state.UpsertJob(100, alloc.Job) + state.UpsertJob(structs.MsgTypeTestSetup, 100, alloc.Job) // Create one more alloc for the db task group alloc2 := mock.Alloc() @@ -5474,7 +5474,7 @@ func TestStateStore_ReconcileParentJobSummary(t *testing.T) { Payload: "random", } job1.TaskGroups[0].Count = 1 - state.UpsertJob(100, job1) + state.UpsertJob(structs.MsgTypeTestSetup, 100, job1) // Make a child job childJob := job1.Copy() @@ -5496,7 +5496,7 @@ func TestStateStore_ReconcileParentJobSummary(t *testing.T) { alloc2.JobID = childJob.ID alloc2.ClientStatus = structs.AllocClientStatusFailed - require.Nil(state.UpsertJob(110, childJob)) + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 110, childJob)) require.Nil(state.UpsertAllocs(structs.MsgTypeTestSetup, 111, []*structs.Allocation{alloc, alloc2})) // Make the summary incorrect in the state store @@ -5553,7 +5553,7 @@ func TestStateStore_UpdateAlloc_JobNotPresent(t *testing.T) { state := testStateStore(t) alloc := mock.Alloc() - state.UpsertJob(100, alloc.Job) + state.UpsertJob(structs.MsgTypeTestSetup, 100, alloc.Job) state.UpsertAllocs(structs.MsgTypeTestSetup, 200, []*structs.Allocation{alloc}) // Delete the job @@ -5569,7 +5569,7 @@ func TestStateStore_UpdateAlloc_JobNotPresent(t *testing.T) { } // Re-Register the job - state.UpsertJob(500, alloc.Job) + state.UpsertJob(structs.MsgTypeTestSetup, 500, alloc.Job) // Update the alloc again alloc2 := alloc.Copy() @@ -5783,7 +5783,7 @@ func TestStateStore_AllocsForRegisteredJob(t *testing.T) { job := mock.Job() job.ID = "foo" - state.UpsertJob(100, job) + state.UpsertJob(structs.MsgTypeTestSetup, 100, job) for i := 0; i < 3; i++ { alloc := mock.Alloc() alloc.Job = job @@ -5801,7 +5801,7 @@ func TestStateStore_AllocsForRegisteredJob(t *testing.T) { job1 := mock.Job() job1.ID = "foo" job1.CreateIndex = 50 - state.UpsertJob(300, job1) + state.UpsertJob(structs.MsgTypeTestSetup, 300, job1) for i := 0; i < 4; i++ { alloc := mock.Alloc() alloc.Job = job1 @@ -6219,7 +6219,7 @@ func TestStateStore_GetJobStatus_DeadEvalsAndAllocs(t *testing.T) { eval := mock.Eval() eval.JobID = job.ID eval.Status = structs.EvalStatusComplete - if err := state.UpsertEvals(1001, []*structs.Evaluation{eval}); err != nil { + if err := state.UpsertEvals(structs.MsgTypeTestSetup, 1001, []*structs.Evaluation{eval}); err != nil { t.Fatalf("err: %v", err) } @@ -6327,7 +6327,7 @@ func TestStateStore_SetJobStatus_PendingEval(t *testing.T) { eval := mock.Eval() eval.JobID = job.ID eval.Status = structs.EvalStatusPending - if err := state.UpsertEvals(1000, []*structs.Evaluation{eval}); err != nil { + if err := state.UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval}); err != nil { t.Fatalf("err: %v", err) } @@ -6355,7 +6355,7 @@ func TestStateStore_SetJobStatus_SystemJob(t *testing.T) { eval.JobID = job.ID eval.Type = job.Type eval.Status = structs.EvalStatusComplete - if err := state.UpsertEvals(1000, []*structs.Evaluation{eval}); err != nil { + if err := state.UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval}); err != nil { t.Fatalf("err: %v", err) } @@ -6395,7 +6395,7 @@ func TestStateJobSummary_UpdateJobCount(t *testing.T) { t.Fatalf("bad: %v", err) } - if err := state.UpsertJob(1000, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job); err != nil { t.Fatalf("err: %v", err) } @@ -6528,7 +6528,7 @@ func TestJobSummary_UpdateClientStatus(t *testing.T) { alloc3.Job = job alloc3.JobID = job.ID - err := state.UpsertJob(1000, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) if err != nil { t.Fatalf("err: %v", err) } @@ -6704,7 +6704,7 @@ func TestStateStore_UpsertDeploymentStatusUpdate_Successful(t *testing.T) { // Insert a job job := mock.Job() - if err := state.UpsertJob(1, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 1, job); err != nil { t.Fatalf("bad: %v", err) } @@ -6761,11 +6761,11 @@ func TestStateStore_UpdateJobStability(t *testing.T) { // Insert a job twice to get two versions job := mock.Job() - if err := state.UpsertJob(1, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 1, job); err != nil { t.Fatalf("bad: %v", err) } - if err := state.UpsertJob(2, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 2, job); err != nil { t.Fatalf("bad: %v", err) } @@ -6862,7 +6862,7 @@ func TestStateStore_UpsertDeploymentPromotion_Unhealthy(t *testing.T) { // Create a job j := mock.Job() - require.Nil(state.UpsertJob(1, j)) + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 1, j)) // Create a deployment d := mock.Deployment() @@ -6911,7 +6911,7 @@ func TestStateStore_UpsertDeploymentPromotion_NoCanaries(t *testing.T) { // Create a job j := mock.Job() - require.Nil(state.UpsertJob(1, j)) + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 1, j)) // Create a deployment d := mock.Deployment() @@ -6943,7 +6943,7 @@ func TestStateStore_UpsertDeploymentPromotion_All(t *testing.T) { tg2 := tg1.Copy() tg2.Name = "foo" j.TaskGroups = append(j.TaskGroups, tg2) - if err := state.UpsertJob(1, j); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 1, j); err != nil { t.Fatalf("bad: %v", err) } @@ -7043,7 +7043,7 @@ func TestStateStore_UpsertDeploymentPromotion_Subset(t *testing.T) { tg2 := tg1.Copy() tg2.Name = "foo" j.TaskGroups = append(j.TaskGroups, tg2) - require.Nil(state.UpsertJob(1, j)) + require.Nil(state.UpsertJob(structs.MsgTypeTestSetup, 1, j)) // Create a deployment d := mock.Deployment() @@ -7216,7 +7216,7 @@ func TestStateStore_UpsertDeploymentAlloc_Canaries(t *testing.T) { // Create a Job job := mock.Job() - require.NoError(t, state.UpsertJob(3, job)) + require.NoError(t, state.UpsertJob(structs.MsgTypeTestSetup, 3, job)) // Create alloc with canary status a := mock.Alloc() @@ -7286,7 +7286,7 @@ func TestStateStore_UpsertDeploymentAlloc_NoCanaries(t *testing.T) { // Create a Job job := mock.Job() - require.NoError(t, state.UpsertJob(3, job)) + require.NoError(t, state.UpsertJob(structs.MsgTypeTestSetup, 3, job)) // Create alloc with canary status a := mock.Alloc() @@ -8738,7 +8738,7 @@ func TestStateStore_UpsertJob_UpsertScalingPolicies(t *testing.T) { require.Nil(out) var newIndex uint64 = 1000 - err = state.UpsertJob(newIndex, job) + err = state.UpsertJob(structs.MsgTypeTestSetup, newIndex, job) require.NoError(err) require.True(watchFired(ws), "watch did not fire") @@ -8766,7 +8766,7 @@ func TestStateStore_UpsertJob_PreserveScalingPolicyIDsAndIndex(t *testing.T) { job, policy := mock.JobWithScalingPolicy() var newIndex uint64 = 1000 - err := state.UpsertJob(newIndex, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, newIndex, job) require.NoError(err) ws := memdb.NewWatchSet() @@ -8784,7 +8784,7 @@ func TestStateStore_UpsertJob_PreserveScalingPolicyIDsAndIndex(t *testing.T) { // update the job job.Meta["new-meta"] = "new-value" newIndex += 100 - err = state.UpsertJob(newIndex, job) + err = state.UpsertJob(structs.MsgTypeTestSetup, newIndex, job) require.NoError(err) require.False(watchFired(ws), "watch should not have fired") @@ -8811,7 +8811,7 @@ func TestStateStore_UpsertJob_UpdateScalingPolicy(t *testing.T) { job, policy := mock.JobWithScalingPolicy() var oldIndex uint64 = 1000 - require.NoError(state.UpsertJob(oldIndex, job)) + require.NoError(state.UpsertJob(structs.MsgTypeTestSetup, oldIndex, job)) ws := memdb.NewWatchSet() p1, err := state.ScalingPolicyByTargetAndType(ws, policy.Target, policy.Type) @@ -8830,7 +8830,7 @@ func TestStateStore_UpsertJob_UpdateScalingPolicy(t *testing.T) { newPolicy := p1.Copy() newPolicy.Policy["new-field"] = "new-value" job.TaskGroups[0].Scaling = newPolicy - require.NoError(state.UpsertJob(oldIndex+100, job)) + require.NoError(state.UpsertJob(structs.MsgTypeTestSetup, oldIndex+100, job)) require.True(watchFired(ws), "watch should have fired") p2, err := state.ScalingPolicyByTargetAndType(nil, policy.Target, policy.Type) @@ -8910,7 +8910,7 @@ func TestStateStore_StopJob_DeleteScalingPolicies(t *testing.T) { job := mock.Job() - err := state.UpsertJob(1000, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) require.NoError(err) policy := mock.ScalingPolicy() @@ -8931,7 +8931,7 @@ func TestStateStore_StopJob_DeleteScalingPolicies(t *testing.T) { job, err = state.JobByID(nil, job.Namespace, job.ID) require.NoError(err) job.Stop = true - err = state.UpsertJob(1200, job) + err = state.UpsertJob(structs.MsgTypeTestSetup, 1200, job) require.NoError(err) // Ensure: @@ -8965,7 +8965,7 @@ func TestStateStore_UnstopJob_UpsertScalingPolicies(t *testing.T) { require.Nil(list.Next()) // upsert a stopped job, verify that we don't fire the watcher or add any scaling policies - err = state.UpsertJob(1000, job) + err = state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) require.NoError(err) require.False(watchFired(ws)) // stopped job should have no scaling policies, watcher doesn't fire @@ -8979,7 +8979,7 @@ func TestStateStore_UnstopJob_UpsertScalingPolicies(t *testing.T) { require.NoError(err) // Unstop this job, say you'll run it again... job.Stop = false - err = state.UpsertJob(1100, job) + err = state.UpsertJob(structs.MsgTypeTestSetup, 1100, job) require.NoError(err) // Ensure the scaling policy was added, watch was fired, index was advanced @@ -9001,7 +9001,7 @@ func TestStateStore_DeleteJob_DeleteScalingPolicies(t *testing.T) { job := mock.Job() - err := state.UpsertJob(1000, job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) require.NoError(err) policy := mock.ScalingPolicy() @@ -9031,10 +9031,10 @@ func TestStateStore_DeleteJob_DeleteScalingPoliciesPrefixBug(t *testing.T) { state := testStateStore(t) job := mock.Job() - require.NoError(state.UpsertJob(1000, job)) + require.NoError(state.UpsertJob(structs.MsgTypeTestSetup, 1000, job)) job2 := job.Copy() job2.ID = job.ID + "-but-longer" - require.NoError(state.UpsertJob(1001, job2)) + require.NoError(state.UpsertJob(structs.MsgTypeTestSetup, 1001, job2)) policy := mock.ScalingPolicy() policy.Target[structs.ScalingTargetJob] = job.ID @@ -9069,7 +9069,7 @@ func TestStateStore_DeleteJob_ScalingPolicyIndexNoop(t *testing.T) { prevIndex, err := state.Index("scaling_policy") require.NoError(err) - err = state.UpsertJob(1000, job) + err = state.UpsertJob(structs.MsgTypeTestSetup, 1000, job) require.NoError(err) newIndex, err := state.Index("scaling_policy") @@ -9575,7 +9575,7 @@ func TestStateSnapshot_DenormalizeAllocationDiffSlice_AllocDoesNotExist(t *testi require := require.New(t) // Insert job - err := state.UpsertJob(999, alloc.Job) + err := state.UpsertJob(structs.MsgTypeTestSetup, 999, alloc.Job) require.NoError(err) allocDiffs := []*structs.AllocationDiff{ diff --git a/nomad/system_endpoint_test.go b/nomad/system_endpoint_test.go index 96628cf3a91..ee5eabd4683 100644 --- a/nomad/system_endpoint_test.go +++ b/nomad/system_endpoint_test.go @@ -27,14 +27,14 @@ func TestSystemEndpoint_GarbageCollect(t *testing.T) { job := mock.Job() job.Type = structs.JobTypeBatch job.Stop = true - if err := state.UpsertJob(1000, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job); err != nil { t.Fatalf("UpsertJob() failed: %v", err) } eval := mock.Eval() eval.Status = structs.EvalStatusComplete eval.JobID = job.ID - if err := state.UpsertEvals(1001, []*structs.Evaluation{eval}); err != nil { + if err := state.UpsertEvals(structs.MsgTypeTestSetup, 1001, []*structs.Evaluation{eval}); err != nil { t.Fatalf("UpsertEvals() failed: %v", err) } @@ -122,7 +122,7 @@ func TestSystemEndpoint_ReconcileSummaries(t *testing.T) { state := s1.fsm.State() s1.fsm.State() job := mock.Job() - if err := state.UpsertJob(1000, job); err != nil { + if err := state.UpsertJob(structs.MsgTypeTestSetup, 1000, job); err != nil { t.Fatalf("UpsertJob() failed: %v", err) } diff --git a/nomad/volumewatcher/volumes_watcher_test.go b/nomad/volumewatcher/volumes_watcher_test.go index a9c72d3e1ca..76083677486 100644 --- a/nomad/volumewatcher/volumes_watcher_test.go +++ b/nomad/volumewatcher/volumes_watcher_test.go @@ -111,7 +111,7 @@ func TestVolumeWatch_StartStop(t *testing.T) { alloc2.Job = alloc1.Job alloc2.ClientStatus = structs.AllocClientStatusRunning index++ - err := srv.State().UpsertJob(index, alloc1.Job) + err := srv.State().UpsertJob(structs.MsgTypeTestSetup, index, alloc1.Job) require.NoError(err) index++ err = srv.State().UpsertAllocs(structs.MsgTypeTestSetup, index, []*structs.Allocation{alloc1, alloc2}) diff --git a/nomad/worker_test.go b/nomad/worker_test.go index 2e82627aeae..733741f3ec9 100644 --- a/nomad/worker_test.go +++ b/nomad/worker_test.go @@ -100,7 +100,7 @@ func TestWorker_dequeueEvaluation_SerialJobs(t *testing.T) { eval2.JobID = eval1.JobID // Insert the evals into the state store - if err := s1.fsm.State().UpsertEvals(1000, []*structs.Evaluation{eval1, eval2}); err != nil { + if err := s1.fsm.State().UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval1, eval2}); err != nil { t.Fatal(err) } @@ -128,7 +128,7 @@ func TestWorker_dequeueEvaluation_SerialJobs(t *testing.T) { } // Update the modify index of the first eval - if err := s1.fsm.State().UpsertEvals(2000, []*structs.Evaluation{eval1}); err != nil { + if err := s1.fsm.State().UpsertEvals(structs.MsgTypeTestSetup, 2000, []*structs.Evaluation{eval1}); err != nil { t.Fatal(err) } @@ -355,8 +355,8 @@ func TestWorker_SubmitPlan(t *testing.T) { job := mock.Job() eval1 := mock.Eval() eval1.JobID = job.ID - s1.fsm.State().UpsertJob(1000, job) - s1.fsm.State().UpsertEvals(1000, []*structs.Evaluation{eval1}) + s1.fsm.State().UpsertJob(structs.MsgTypeTestSetup, 1000, job) + s1.fsm.State().UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval1}) // Create the register request s1.evalBroker.Enqueue(eval1) @@ -422,8 +422,8 @@ func TestWorker_SubmitPlanNormalizedAllocations(t *testing.T) { job := mock.Job() eval1 := mock.Eval() eval1.JobID = job.ID - s1.fsm.State().UpsertJob(0, job) - s1.fsm.State().UpsertEvals(0, []*structs.Evaluation{eval1}) + s1.fsm.State().UpsertJob(structs.MsgTypeTestSetup, 0, job) + s1.fsm.State().UpsertEvals(structs.MsgTypeTestSetup, 0, []*structs.Evaluation{eval1}) stoppedAlloc := mock.Alloc() preemptedAlloc := mock.Alloc() @@ -472,7 +472,7 @@ func TestWorker_SubmitPlan_MissingNodeRefresh(t *testing.T) { // Create the job job := mock.Job() - s1.fsm.State().UpsertJob(1000, job) + s1.fsm.State().UpsertJob(structs.MsgTypeTestSetup, 1000, job) // Create the register request eval1 := mock.Eval() @@ -640,7 +640,7 @@ func TestWorker_ReblockEval(t *testing.T) { eval1.QueuedAllocations = map[string]int{"cache": 100} // Insert it into the state store - if err := s1.fsm.State().UpsertEvals(1000, []*structs.Evaluation{eval1}); err != nil { + if err := s1.fsm.State().UpsertEvals(structs.MsgTypeTestSetup, 1000, []*structs.Evaluation{eval1}); err != nil { t.Fatal(err) } diff --git a/scheduler/feasible_test.go b/scheduler/feasible_test.go index 82bc1520ff9..d75f70ed54b 100644 --- a/scheduler/feasible_test.go +++ b/scheduler/feasible_test.go @@ -318,7 +318,7 @@ func TestCSIVolumeChecker(t *testing.T) { Source: vid2, }, } - err = state.UpsertJob(index, alloc.Job) + err = state.UpsertJob(structs.MsgTypeTestSetup, index, alloc.Job) require.NoError(t, err) index++ summary := mock.JobSummary(alloc.JobID) diff --git a/scheduler/generic_sched_test.go b/scheduler/generic_sched_test.go index 7d86dbe8d39..5720c0b4b83 100644 --- a/scheduler/generic_sched_test.go +++ b/scheduler/generic_sched_test.go @@ -28,7 +28,7 @@ func TestServiceSched_JobRegister(t *testing.T) { // Create a job job := mock.Job() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock evaluation to register the job eval := &structs.Evaluation{ @@ -40,7 +40,7 @@ func TestServiceSched_JobRegister(t *testing.T) { Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -119,7 +119,7 @@ func TestServiceSched_JobRegister_StickyAllocs(t *testing.T) { // Create a job job := mock.Job() job.TaskGroups[0].EphemeralDisk.Sticky = true - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock evaluation to register the job eval := &structs.Evaluation{ @@ -130,7 +130,7 @@ func TestServiceSched_JobRegister_StickyAllocs(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation if err := h.Process(NewServiceScheduler, eval); err != nil { @@ -152,7 +152,7 @@ func TestServiceSched_JobRegister_StickyAllocs(t *testing.T) { // Update the job to force a rolling upgrade updated := job.Copy() updated.TaskGroups[0].Tasks[0].Resources.CPU += 10 - require.NoError(t, h.State.UpsertJob(h.NextIndex(), updated)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), updated)) // Create a mock evaluation to handle the update eval = &structs.Evaluation{ @@ -163,7 +163,7 @@ func TestServiceSched_JobRegister_StickyAllocs(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) h1 := NewHarnessWithState(t, h.State) if err := h1.Process(NewServiceScheduler, eval); err != nil { t.Fatalf("err: %v", err) @@ -211,7 +211,7 @@ func TestServiceSched_JobRegister_DiskConstraints(t *testing.T) { job := mock.Job() job.TaskGroups[0].Count = 2 job.TaskGroups[0].EphemeralDisk.SizeMB = 88 * 1024 - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock evaluation to register the job eval := &structs.Evaluation{ @@ -223,7 +223,7 @@ func TestServiceSched_JobRegister_DiskConstraints(t *testing.T) { Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -287,7 +287,7 @@ func TestServiceSched_JobRegister_DistinctHosts(t *testing.T) { job := mock.Job() job.TaskGroups[0].Count = 11 job.Constraints = append(job.Constraints, &structs.Constraint{Operand: structs.ConstraintDistinctHosts}) - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock evaluation to register the job eval := &structs.Evaluation{ @@ -299,7 +299,7 @@ func TestServiceSched_JobRegister_DistinctHosts(t *testing.T) { Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -379,7 +379,7 @@ func TestServiceSched_JobRegister_DistinctProperty(t *testing.T) { LTarget: "${meta.rack}", RTarget: "2", }) - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock evaluation to register the job eval := &structs.Evaluation{ @@ -391,7 +391,7 @@ func TestServiceSched_JobRegister_DistinctProperty(t *testing.T) { Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -474,7 +474,7 @@ func TestServiceSched_JobRegister_DistinctProperty_TaskGroup(t *testing.T) { job.TaskGroups[1].Name = "tg2" job.TaskGroups[1].Count = 2 - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock evaluation to register the job eval := &structs.Evaluation{ @@ -485,7 +485,7 @@ func TestServiceSched_JobRegister_DistinctProperty_TaskGroup(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -543,7 +543,7 @@ func TestServiceSched_JobRegister_DistinctProperty_TaskGroup_Incr(t *testing.T) Operand: structs.ConstraintDistinctProperty, LTarget: "${node.unique.id}", }) - assert.Nil(h.State.UpsertJob(h.NextIndex(), job), "UpsertJob") + assert.Nil(h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job), "UpsertJob") // Create some nodes var nodes []*structs.Node @@ -568,7 +568,7 @@ func TestServiceSched_JobRegister_DistinctProperty_TaskGroup_Incr(t *testing.T) // Update the count job2 := job.Copy() job2.TaskGroups[0].Count = 6 - assert.Nil(h.State.UpsertJob(h.NextIndex(), job2), "UpsertJob") + assert.Nil(h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job2), "UpsertJob") // Create a mock evaluation to register the job eval := &structs.Evaluation{ @@ -579,7 +579,7 @@ func TestServiceSched_JobRegister_DistinctProperty_TaskGroup_Incr(t *testing.T) JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation assert.Nil(h.Process(NewServiceScheduler, eval), "Process") @@ -643,7 +643,7 @@ func TestServiceSched_Spread(t *testing.T) { }, }, }) - assert.Nil(h.State.UpsertJob(h.NextIndex(), job), "UpsertJob") + assert.Nil(h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job), "UpsertJob") // Create some nodes, half in dc2 var nodes []*structs.Node nodeMap := make(map[string]*structs.Node) @@ -666,7 +666,7 @@ func TestServiceSched_Spread(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation assert.Nil(h.Process(NewServiceScheduler, eval), "Process") @@ -720,7 +720,7 @@ func TestServiceSched_EvenSpread(t *testing.T) { Attribute: "${node.datacenter}", Weight: 100, }) - assert.Nil(h.State.UpsertJob(h.NextIndex(), job), "UpsertJob") + assert.Nil(h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job), "UpsertJob") // Create some nodes, half in dc2 var nodes []*structs.Node nodeMap := make(map[string]*structs.Node) @@ -743,7 +743,7 @@ func TestServiceSched_EvenSpread(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation assert.Nil(h.Process(NewServiceScheduler, eval), "Process") @@ -791,7 +791,7 @@ func TestServiceSched_JobRegister_Annotate(t *testing.T) { // Create a job job := mock.Job() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock evaluation to register the job eval := &structs.Evaluation{ @@ -803,7 +803,7 @@ func TestServiceSched_JobRegister_Annotate(t *testing.T) { AnnotatePlan: true, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -871,7 +871,7 @@ func TestServiceSched_JobRegister_CountZero(t *testing.T) { // Create a job and set the task group count to zero. job := mock.Job() job.TaskGroups[0].Count = 0 - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock evaluation to register the job eval := &structs.Evaluation{ @@ -882,7 +882,7 @@ func TestServiceSched_JobRegister_CountZero(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -914,7 +914,7 @@ func TestServiceSched_JobRegister_AllocFail(t *testing.T) { // Create NO nodes // Create a job job := mock.Job() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock evaluation to register the job eval := &structs.Evaluation{ @@ -926,7 +926,7 @@ func TestServiceSched_JobRegister_AllocFail(t *testing.T) { Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -1003,7 +1003,7 @@ func TestServiceSched_JobRegister_CreateBlockedEval(t *testing.T) { // Create a jobs job := mock.Job() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock evaluation to register the job eval := &structs.Evaluation{ @@ -1015,7 +1015,7 @@ func TestServiceSched_JobRegister_CreateBlockedEval(t *testing.T) { Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -1103,7 +1103,7 @@ func TestServiceSched_JobRegister_FeasibleAndInfeasibleTG(t *testing.T) { tg2.Name = "web2" tg2.Constraints[1].RTarget = "class_1" job.TaskGroups = append(job.TaskGroups, tg2) - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock evaluation to register the job eval := &structs.Evaluation{ @@ -1114,7 +1114,7 @@ func TestServiceSched_JobRegister_FeasibleAndInfeasibleTG(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) if err != nil { @@ -1180,7 +1180,7 @@ func TestServiceSched_EvaluateMaxPlanEval(t *testing.T) { // Create a job and set the task group count to zero. job := mock.Job() job.TaskGroups[0].Count = 0 - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock blocked evaluation eval := &structs.Evaluation{ @@ -1193,7 +1193,7 @@ func TestServiceSched_EvaluateMaxPlanEval(t *testing.T) { } // Insert it into the state store - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -1221,7 +1221,7 @@ func TestServiceSched_Plan_Partial_Progress(t *testing.T) { job := mock.Job() job.TaskGroups[0].Count = 3 job.TaskGroups[0].Tasks[0].Resources.CPU = 3600 - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock evaluation to register the job eval := &structs.Evaluation{ @@ -1233,7 +1233,7 @@ func TestServiceSched_Plan_Partial_Progress(t *testing.T) { Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -1284,7 +1284,7 @@ func TestServiceSched_EvaluateBlockedEval(t *testing.T) { // Create a job job := mock.Job() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock blocked evaluation eval := &structs.Evaluation{ @@ -1297,7 +1297,7 @@ func TestServiceSched_EvaluateBlockedEval(t *testing.T) { } // Insert it into the state store - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -1335,7 +1335,7 @@ func TestServiceSched_EvaluateBlockedEval_Finished(t *testing.T) { // Create a job and set the task group count to zero. job := mock.Job() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock blocked evaluation eval := &structs.Evaluation{ @@ -1348,7 +1348,7 @@ func TestServiceSched_EvaluateBlockedEval_Finished(t *testing.T) { } // Insert it into the state store - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -1421,7 +1421,7 @@ func TestServiceSched_JobModify(t *testing.T) { // Generate a fake job with allocations job := mock.Job() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) var allocs []*structs.Allocation for i := 0; i < 10; i++ { @@ -1453,7 +1453,7 @@ func TestServiceSched_JobModify(t *testing.T) { // Update the task, such that it cannot be done in-place job2.TaskGroups[0].Tasks[0].Config["command"] = "/bin/other" - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job2)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job2)) // Create a mock evaluation to deal with drain eval := &structs.Evaluation{ @@ -1464,7 +1464,7 @@ func TestServiceSched_JobModify(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -1525,7 +1525,7 @@ func TestServiceSched_JobModify_IncrCount_NodeLimit(t *testing.T) { job := mock.Job() job.TaskGroups[0].Tasks[0].Resources.CPU = 256 job2 := job.Copy() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) var allocs []*structs.Allocation alloc := mock.Alloc() @@ -1539,7 +1539,7 @@ func TestServiceSched_JobModify_IncrCount_NodeLimit(t *testing.T) { // Update the job to count 3 job2.TaskGroups[0].Count = 3 - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job2)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job2)) // Create a mock evaluation to deal with drain eval := &structs.Evaluation{ @@ -1550,7 +1550,7 @@ func TestServiceSched_JobModify_IncrCount_NodeLimit(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -1618,7 +1618,7 @@ func TestServiceSched_JobModify_CountZero(t *testing.T) { // Generate a fake job with allocations job := mock.Job() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) var allocs []*structs.Allocation for i := 0; i < 10; i++ { @@ -1648,7 +1648,7 @@ func TestServiceSched_JobModify_CountZero(t *testing.T) { job2 := mock.Job() job2.ID = job.ID job2.TaskGroups[0].Count = 0 - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job2)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job2)) // Create a mock evaluation to deal with drain eval := &structs.Evaluation{ @@ -1659,7 +1659,7 @@ func TestServiceSched_JobModify_CountZero(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -1718,7 +1718,7 @@ func TestServiceSched_JobModify_Rolling(t *testing.T) { // Generate a fake job with allocations job := mock.Job() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) var allocs []*structs.Allocation for i := 0; i < 10; i++ { @@ -1744,7 +1744,7 @@ func TestServiceSched_JobModify_Rolling(t *testing.T) { // Update the task, such that it cannot be done in-place job2.TaskGroups[0].Tasks[0].Config["command"] = "/bin/other" - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job2)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job2)) // Create a mock evaluation to deal with drain eval := &structs.Evaluation{ @@ -1755,7 +1755,7 @@ func TestServiceSched_JobModify_Rolling(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -1845,7 +1845,7 @@ func TestServiceSched_JobModify_Rolling_FullNode(t *testing.T) { job := mock.Job() job.TaskGroups[0].Count = 1 job.TaskGroups[0].Tasks[0].Resources = request - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) alloc := mock.Alloc() alloc.AllocatedResources = allocated @@ -1869,7 +1869,7 @@ func TestServiceSched_JobModify_Rolling_FullNode(t *testing.T) { // Update the task, such that it cannot be done in-place job2.TaskGroups[0].Tasks[0].Config["command"] = "/bin/other" - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job2)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job2)) eval := &structs.Evaluation{ Namespace: structs.DefaultNamespace, @@ -1879,7 +1879,7 @@ func TestServiceSched_JobModify_Rolling_FullNode(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -1944,7 +1944,7 @@ func TestServiceSched_JobModify_Canaries(t *testing.T) { // Generate a fake job with allocations job := mock.Job() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) var allocs []*structs.Allocation for i := 0; i < 10; i++ { @@ -1971,7 +1971,7 @@ func TestServiceSched_JobModify_Canaries(t *testing.T) { // Update the task, such that it cannot be done in-place job2.TaskGroups[0].Tasks[0].Config["command"] = "/bin/other" - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job2)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job2)) // Create a mock evaluation to deal with drain eval := &structs.Evaluation{ @@ -1982,7 +1982,7 @@ func TestServiceSched_JobModify_Canaries(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -2070,7 +2070,7 @@ func TestServiceSched_JobModify_InPlace(t *testing.T) { job := mock.Job() d := mock.Deployment() d.JobID = job.ID - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) require.NoError(t, h.State.UpsertDeployment(h.NextIndex(), d)) taskName := job.TaskGroups[0].Tasks[0].Name @@ -2107,7 +2107,7 @@ func TestServiceSched_JobModify_InPlace(t *testing.T) { MinHealthyTime: 10 * time.Second, HealthyDeadline: 10 * time.Minute, } - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job2)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job2)) // Create a mock evaluation to deal with drain eval := &structs.Evaluation{ @@ -2118,7 +2118,7 @@ func TestServiceSched_JobModify_InPlace(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -2208,7 +2208,7 @@ func TestServiceSched_JobModify_InPlace08(t *testing.T) { // Generate a fake job with 0.8 allocations job := mock.Job() job.TaskGroups[0].Count = 1 - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create 0.8 alloc alloc := mock.Alloc() @@ -2222,7 +2222,7 @@ func TestServiceSched_JobModify_InPlace08(t *testing.T) { job2 := job.Copy() job2.TaskGroups[0].Tasks[0].Services[0].Tags[0] = "newtag" - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job2)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job2)) // Create a mock evaluation eval := &structs.Evaluation{ @@ -2233,7 +2233,7 @@ func TestServiceSched_JobModify_InPlace08(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -2296,7 +2296,7 @@ func TestServiceSched_JobModify_DistinctProperty(t *testing.T) { Operand: structs.ConstraintDistinctProperty, LTarget: "${meta.rack}", }) - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) oldJob := job.Copy() oldJob.JobModifyIndex -= 1 @@ -2323,7 +2323,7 @@ func TestServiceSched_JobModify_DistinctProperty(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -2412,7 +2412,7 @@ func TestServiceSched_JobModify_NodeReschedulePenalty(t *testing.T) { tgName := job.TaskGroups[0].Name now := time.Now() - require.NoError(h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) var allocs []*structs.Allocation for i := 0; i < 2; i++ { @@ -2443,7 +2443,7 @@ func TestServiceSched_JobModify_NodeReschedulePenalty(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) require.NoError(h.Process(NewServiceScheduler, eval)) // Ensure we have one plan @@ -2479,7 +2479,7 @@ func TestServiceSched_JobModify_NodeReschedulePenalty(t *testing.T) { // Update the job, such that it cannot be done in-place job2 := job.Copy() job2.TaskGroups[0].Tasks[0].Config["command"] = "/bin/other" - require.NoError(h.State.UpsertJob(h.NextIndex(), job2)) + require.NoError(h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job2)) // Create and process a mock evaluation eval = &structs.Evaluation{ @@ -2490,7 +2490,7 @@ func TestServiceSched_JobModify_NodeReschedulePenalty(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) require.NoError(h.Process(NewServiceScheduler, eval)) // Lookup the new allocations by JobID @@ -2541,7 +2541,7 @@ func TestServiceSched_JobDeregister_Purged(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -2588,7 +2588,7 @@ func TestServiceSched_JobDeregister_Stopped(t *testing.T) { // Generate a fake job with allocations job := mock.Job() job.Stop = true - require.NoError(h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) var allocs []*structs.Allocation for i := 0; i < 10; i++ { @@ -2615,7 +2615,7 @@ func TestServiceSched_JobDeregister_Stopped(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation require.NoError(h.Process(NewServiceScheduler, eval)) @@ -2709,7 +2709,7 @@ func TestServiceSched_NodeDown(t *testing.T) { // Generate a fake job with allocations and an update policy. job := mock.Job() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) alloc := mock.Alloc() alloc.Job = job @@ -2736,7 +2736,7 @@ func TestServiceSched_NodeDown(t *testing.T) { NodeID: node.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -2807,7 +2807,7 @@ func TestServiceSched_StopAfterClientDisconnect(t *testing.T) { job := mock.Job() job.TaskGroups[0].Count = 1 job.TaskGroups[0].StopAfterClientDisconnect = &tc.stop - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Alloc for the running group alloc := mock.Alloc() @@ -2838,7 +2838,7 @@ func TestServiceSched_StopAfterClientDisconnect(t *testing.T) { Status: structs.EvalStatusPending, }} eval := evals[0] - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), evals)) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), evals)) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -2939,7 +2939,7 @@ func TestServiceSched_NodeUpdate(t *testing.T) { // Generate a fake job with allocations and an update policy. job := mock.Job() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) var allocs []*structs.Allocation for i := 0; i < 10; i++ { @@ -2970,7 +2970,7 @@ func TestServiceSched_NodeUpdate(t *testing.T) { NodeID: node.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -3000,7 +3000,7 @@ func TestServiceSched_NodeDrain(t *testing.T) { // Generate a fake job with allocations and an update policy. job := mock.Job() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) var allocs []*structs.Allocation for i := 0; i < 10; i++ { @@ -3024,7 +3024,7 @@ func TestServiceSched_NodeDrain(t *testing.T) { NodeID: node.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -3077,7 +3077,7 @@ func TestServiceSched_NodeDrain_Down(t *testing.T) { // Generate a fake job with allocations job := mock.Job() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) var allocs []*structs.Allocation for i := 0; i < 10; i++ { @@ -3139,7 +3139,7 @@ func TestServiceSched_NodeDrain_Down(t *testing.T) { Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -3189,7 +3189,7 @@ func TestServiceSched_NodeDrain_Queued_Allocations(t *testing.T) { // Generate a fake job with allocations and an update policy. job := mock.Job() job.TaskGroups[0].Count = 2 - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) var allocs []*structs.Allocation for i := 0; i < 2; i++ { @@ -3216,7 +3216,7 @@ func TestServiceSched_NodeDrain_Queued_Allocations(t *testing.T) { NodeID: node.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -3242,7 +3242,7 @@ func TestServiceSched_RetryLimit(t *testing.T) { // Create a job job := mock.Job() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock evaluation to register the job eval := &structs.Evaluation{ @@ -3253,7 +3253,7 @@ func TestServiceSched_RetryLimit(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -3304,7 +3304,7 @@ func TestServiceSched_Reschedule_OnceNow(t *testing.T) { tgName := job.TaskGroups[0].Name now := time.Now() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) var allocs []*structs.Allocation for i := 0; i < 2; i++ { @@ -3334,7 +3334,7 @@ func TestServiceSched_Reschedule_OnceNow(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -3379,7 +3379,7 @@ func TestServiceSched_Reschedule_OnceNow(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err = h.Process(NewServiceScheduler, eval) @@ -3417,7 +3417,7 @@ func TestServiceSched_Reschedule_Later(t *testing.T) { tgName := job.TaskGroups[0].Name now := time.Now() - require.NoError(h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) var allocs []*structs.Allocation for i := 0; i < 2; i++ { @@ -3446,7 +3446,7 @@ func TestServiceSched_Reschedule_Later(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -3504,7 +3504,7 @@ func TestServiceSched_Reschedule_MultipleNow(t *testing.T) { tgName := job.TaskGroups[0].Name now := time.Now() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) var allocs []*structs.Allocation for i := 0; i < 2; i++ { @@ -3533,7 +3533,7 @@ func TestServiceSched_Reschedule_MultipleNow(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) expectedNumAllocs := 3 expectedNumReschedTrackers := 1 @@ -3604,7 +3604,7 @@ func TestServiceSched_Reschedule_MultipleNow(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) expectedNumAllocs += 1 expectedNumReschedTrackers += 1 } @@ -3641,7 +3641,7 @@ func TestServiceSched_Reschedule_PruneEvents(t *testing.T) { Delay: 5 * time.Second, Unlimited: true, } - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) var allocs []*structs.Allocation for i := 0; i < 2; i++ { @@ -3709,7 +3709,7 @@ func TestServiceSched_Reschedule_PruneEvents(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -3773,7 +3773,7 @@ func TestDeployment_FailedAllocs_Reschedule(t *testing.T) { Interval: 15 * time.Minute, } jobIndex := h.NextIndex() - require.Nil(h.State.UpsertJob(jobIndex, job)) + require.Nil(h.State.UpsertJob(structs.MsgTypeTestSetup, jobIndex, job)) deployment := mock.Deployment() deployment.JobID = job.ID @@ -3813,7 +3813,7 @@ func TestDeployment_FailedAllocs_Reschedule(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.Nil(h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.Nil(h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation require.Nil(h.Process(NewServiceScheduler, eval)) @@ -3849,7 +3849,7 @@ func TestBatchSched_Run_CompleteAlloc(t *testing.T) { job := mock.Job() job.Type = structs.JobTypeBatch job.TaskGroups[0].Count = 1 - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a complete alloc alloc := mock.Alloc() @@ -3869,7 +3869,7 @@ func TestBatchSched_Run_CompleteAlloc(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewBatchScheduler, eval) @@ -3906,7 +3906,7 @@ func TestBatchSched_Run_FailedAlloc(t *testing.T) { job := mock.Job() job.Type = structs.JobTypeBatch job.TaskGroups[0].Count = 1 - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) tgName := job.TaskGroups[0].Name now := time.Now() @@ -3932,7 +3932,7 @@ func TestBatchSched_Run_FailedAlloc(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewBatchScheduler, eval) @@ -3977,7 +3977,7 @@ func TestBatchSched_Run_LostAlloc(t *testing.T) { job.ID = "my-job" job.Type = structs.JobTypeBatch job.TaskGroups[0].Count = 3 - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Desired = 3 // Mark one as lost and then schedule @@ -4015,7 +4015,7 @@ func TestBatchSched_Run_LostAlloc(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewBatchScheduler, eval) @@ -4064,7 +4064,7 @@ func TestBatchSched_Run_FailedAllocQueuedAllocations(t *testing.T) { job := mock.Job() job.Type = structs.JobTypeBatch job.TaskGroups[0].Count = 1 - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) tgName := job.TaskGroups[0].Name now := time.Now() @@ -4090,7 +4090,7 @@ func TestBatchSched_Run_FailedAllocQueuedAllocations(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewBatchScheduler, eval) @@ -4121,7 +4121,7 @@ func TestBatchSched_ReRun_SuccessfullyFinishedAlloc(t *testing.T) { job := mock.Job() job.Type = structs.JobTypeBatch job.TaskGroups[0].Count = 1 - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a successful alloc alloc := mock.Alloc() @@ -4152,7 +4152,7 @@ func TestBatchSched_ReRun_SuccessfullyFinishedAlloc(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewBatchScheduler, eval) @@ -4194,7 +4194,7 @@ func TestBatchSched_JobModify_InPlace_Terminal(t *testing.T) { // Generate a fake job with allocations job := mock.Job() job.Type = structs.JobTypeBatch - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) var allocs []*structs.Allocation for i := 0; i < 10; i++ { @@ -4217,7 +4217,7 @@ func TestBatchSched_JobModify_InPlace_Terminal(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewBatchScheduler, eval) @@ -4246,7 +4246,7 @@ func TestBatchSched_JobModify_Destructive_Terminal(t *testing.T) { // Generate a fake job with allocations job := mock.Job() job.Type = structs.JobTypeBatch - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) var allocs []*structs.Allocation for i := 0; i < 10; i++ { @@ -4266,7 +4266,7 @@ func TestBatchSched_JobModify_Destructive_Terminal(t *testing.T) { job2.Type = structs.JobTypeBatch job2.Version++ job2.TaskGroups[0].Tasks[0].Env = map[string]string{"foo": "bar"} - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job2)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job2)) allocs = nil for i := 0; i < 10; i++ { @@ -4300,7 +4300,7 @@ func TestBatchSched_JobModify_Destructive_Terminal(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewBatchScheduler, eval) @@ -4331,7 +4331,7 @@ func TestBatchSched_NodeDrain_Running_OldJob(t *testing.T) { job := mock.Job() job.Type = structs.JobTypeBatch job.TaskGroups[0].Count = 1 - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a running alloc alloc := mock.Alloc() @@ -4346,7 +4346,7 @@ func TestBatchSched_NodeDrain_Running_OldJob(t *testing.T) { job2 := job.Copy() job2.TaskGroups[0].Tasks[0].Env = map[string]string{"foo": "bar"} job2.Version++ - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job2)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job2)) // Create a mock evaluation to register the job eval := &structs.Evaluation{ @@ -4358,7 +4358,7 @@ func TestBatchSched_NodeDrain_Running_OldJob(t *testing.T) { Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewBatchScheduler, eval) @@ -4403,7 +4403,7 @@ func TestBatchSched_NodeDrain_Complete(t *testing.T) { job := mock.Job() job.Type = structs.JobTypeBatch job.TaskGroups[0].Count = 1 - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a complete alloc alloc := mock.Alloc() @@ -4434,7 +4434,7 @@ func TestBatchSched_NodeDrain_Complete(t *testing.T) { Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewBatchScheduler, eval) @@ -4464,7 +4464,7 @@ func TestBatchSched_ScaleDown_SameName(t *testing.T) { job := mock.Job() job.Type = structs.JobTypeBatch job.TaskGroups[0].Count = 1 - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) scoreMetric := &structs.AllocMetric{ NodesEvaluated: 10, @@ -4495,7 +4495,7 @@ func TestBatchSched_ScaleDown_SameName(t *testing.T) { // Update the job's modify index to force an inplace upgrade updatedJob := job.Copy() updatedJob.JobModifyIndex = job.JobModifyIndex + 1 - require.NoError(t, h.State.UpsertJob(h.NextIndex(), updatedJob)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), updatedJob)) // Create a mock evaluation to register the job eval := &structs.Evaluation{ @@ -4507,7 +4507,7 @@ func TestBatchSched_ScaleDown_SameName(t *testing.T) { Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewBatchScheduler, eval) @@ -4616,7 +4616,7 @@ func TestGenericSched_AllocFit(t *testing.T) { // Create a job with sidecar & init tasks job := mock.VariableLifecycleJob(testCase.TaskResources, testCase.MainTaskCount, testCase.InitTaskCount, testCase.SideTaskCount) - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock evaluation to register the job eval := &structs.Evaluation{ @@ -4627,7 +4627,7 @@ func TestGenericSched_AllocFit(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -4664,7 +4664,7 @@ func TestGenericSched_ChainedAlloc(t *testing.T) { // Create a job job := mock.Job() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock evaluation to register the job eval := &structs.Evaluation{ @@ -4675,7 +4675,7 @@ func TestGenericSched_ChainedAlloc(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation if err := h.Process(NewServiceScheduler, eval); err != nil { t.Fatalf("err: %v", err) @@ -4695,7 +4695,7 @@ func TestGenericSched_ChainedAlloc(t *testing.T) { job1.ID = job.ID job1.TaskGroups[0].Tasks[0].Env["foo"] = "bar" job1.TaskGroups[0].Count = 12 - require.NoError(t, h1.State.UpsertJob(h1.NextIndex(), job1)) + require.NoError(t, h1.State.UpsertJob(structs.MsgTypeTestSetup, h1.NextIndex(), job1)) // Create a mock evaluation to update the job eval1 := &structs.Evaluation{ @@ -4706,7 +4706,7 @@ func TestGenericSched_ChainedAlloc(t *testing.T) { JobID: job1.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval1})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval1})) // Process the evaluation if err := h1.Process(NewServiceScheduler, eval1); err != nil { @@ -4757,7 +4757,7 @@ func TestServiceSched_NodeDrain_Sticky(t *testing.T) { alloc.Job.TaskGroups[0].Count = 1 alloc.Job.TaskGroups[0].EphemeralDisk.Sticky = true alloc.DesiredTransition.Migrate = helper.BoolToPtr(true) - require.NoError(t, h.State.UpsertJob(h.NextIndex(), alloc.Job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), alloc.Job)) require.NoError(t, h.State.UpsertAllocs(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Allocation{alloc})) // Create a mock evaluation to deal with drain @@ -4771,7 +4771,7 @@ func TestServiceSched_NodeDrain_Sticky(t *testing.T) { Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -4812,7 +4812,7 @@ func TestServiceSched_CancelDeployment_Stopped(t *testing.T) { job.JobModifyIndex = job.CreateIndex + 1 job.ModifyIndex = job.CreateIndex + 1 job.Stop = true - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a deployment d := mock.Deployment() @@ -4831,7 +4831,7 @@ func TestServiceSched_CancelDeployment_Stopped(t *testing.T) { Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -4883,7 +4883,7 @@ func TestServiceSched_CancelDeployment_NewerJob(t *testing.T) { // Generate a fake job job := mock.Job() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a deployment for an old version of the job d := mock.Deployment() @@ -4891,7 +4891,7 @@ func TestServiceSched_CancelDeployment_NewerJob(t *testing.T) { require.NoError(t, h.State.UpsertDeployment(h.NextIndex(), d)) // Upsert again to bump job version - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock evaluation to kick the job eval := &structs.Evaluation{ @@ -4903,7 +4903,7 @@ func TestServiceSched_CancelDeployment_NewerJob(t *testing.T) { Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -5235,7 +5235,7 @@ func TestServiceSched_Preemption(t *testing.T) { r1.CPU = 500 r1.MemoryMB = 1024 r1.Networks = nil - require.NoError(h.State.UpsertJob(h.NextIndex(), job1)) + require.NoError(h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job1)) job2 := mock.Job() job2.TaskGroups[0].Count = 1 @@ -5244,7 +5244,7 @@ func TestServiceSched_Preemption(t *testing.T) { r2.CPU = 350 r2.MemoryMB = 512 r2.Networks = nil - require.NoError(h.State.UpsertJob(h.NextIndex(), job2)) + require.NoError(h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job2)) // Create a mock evaluation to register the jobs eval1 := &structs.Evaluation{ @@ -5264,7 +5264,7 @@ func TestServiceSched_Preemption(t *testing.T) { Status: structs.EvalStatusPending, } - require.NoError(h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval1, eval2})) + require.NoError(h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval1, eval2})) expectedPreemptedAllocs := make(map[string]struct{}) // Process the two evals for job1 and job2 and make sure they allocated @@ -5298,7 +5298,7 @@ func TestServiceSched_Preemption(t *testing.T) { r3.CPU = 900 r3.MemoryMB = 1700 r3.Networks = nil - require.NoError(h.State.UpsertJob(h.NextIndex(), job3)) + require.NoError(h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job3)) // Create a mock evaluation to register the job eval := &structs.Evaluation{ @@ -5310,7 +5310,7 @@ func TestServiceSched_Preemption(t *testing.T) { Status: structs.EvalStatusPending, } - require.NoError(h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -5358,7 +5358,7 @@ func TestServiceSched_Migrate_NonCanary(t *testing.T) { MaxParallel: 1, Canary: 1, } - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) deployment := &structs.Deployment{ ID: uuid.Generate(), @@ -5395,7 +5395,7 @@ func TestServiceSched_Migrate_NonCanary(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -5431,7 +5431,7 @@ func TestServiceSched_Migrate_CanaryStatus(t *testing.T) { MaxParallel: 1, Canary: desiredCanaries, } - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) deployment := &structs.Deployment{ ID: uuid.Generate(), @@ -5464,7 +5464,7 @@ func TestServiceSched_Migrate_CanaryStatus(t *testing.T) { job2 := job.Copy() job2.Stable = false job2.TaskGroups[0].Tasks[0].Config["command"] = "/bin/other" - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job2)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job2)) // Create a mock evaluation eval := &structs.Evaluation{ @@ -5475,7 +5475,7 @@ func TestServiceSched_Migrate_CanaryStatus(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -5529,7 +5529,7 @@ func TestServiceSched_Migrate_CanaryStatus(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{neval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{neval})) // Process the evaluation err = h.Process(NewServiceScheduler, eval) @@ -5594,7 +5594,7 @@ func TestServiceSched_RunningWithNextAllocation(t *testing.T) { job.Stable = true job.TaskGroups[0].Count = totalCount job.TaskGroups[0].Update = nil - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) var allocs []*structs.Allocation for i := 0; i < totalCount+1; i++ { @@ -5615,7 +5615,7 @@ func TestServiceSched_RunningWithNextAllocation(t *testing.T) { job2 := job.Copy() job2.Version = 1 job2.TaskGroups[0].Tasks[0].Config["command"] = "/bin/other" - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job2)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job2)) // Create a mock evaluation eval := &structs.Evaluation{ @@ -5626,7 +5626,7 @@ func TestServiceSched_RunningWithNextAllocation(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) diff --git a/scheduler/system_sched_test.go b/scheduler/system_sched_test.go index e4e9aacaa35..c4cb5ebc6d5 100644 --- a/scheduler/system_sched_test.go +++ b/scheduler/system_sched_test.go @@ -26,7 +26,7 @@ func TestSystemSched_JobRegister(t *testing.T) { // Create a job job := mock.SystemJob() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock evaluation to deregister the job eval := &structs.Evaluation{ @@ -37,7 +37,7 @@ func TestSystemSched_JobRegister(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewSystemScheduler, eval) @@ -101,7 +101,7 @@ func TestSystemSched_JobRegister_StickyAllocs(t *testing.T) { // Create a job job := mock.SystemJob() job.TaskGroups[0].EphemeralDisk.Sticky = true - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock evaluation to register the job eval := &structs.Evaluation{ @@ -112,7 +112,7 @@ func TestSystemSched_JobRegister_StickyAllocs(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation if err := h.Process(NewSystemScheduler, eval); err != nil { @@ -143,7 +143,7 @@ func TestSystemSched_JobRegister_StickyAllocs(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) h1 := NewHarnessWithState(t, h.State) if err := h1.Process(NewSystemScheduler, eval); err != nil { t.Fatalf("err: %v", err) @@ -175,13 +175,13 @@ func TestSystemSched_JobRegister_EphemeralDiskConstraint(t *testing.T) { // Create a job job := mock.SystemJob() job.TaskGroups[0].EphemeralDisk.SizeMB = 60 * 1024 - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create another job with a lot of disk resource ask so that it doesn't fit // the node job1 := mock.SystemJob() job1.TaskGroups[0].EphemeralDisk.SizeMB = 60 * 1024 - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job1)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job1)) // Create a mock evaluation to register the job eval := &structs.Evaluation{ @@ -192,7 +192,7 @@ func TestSystemSched_JobRegister_EphemeralDiskConstraint(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation if err := h.Process(NewSystemScheduler, eval); err != nil { @@ -220,7 +220,7 @@ func TestSystemSched_JobRegister_EphemeralDiskConstraint(t *testing.T) { JobID: job1.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval1})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval1})) // Process the evaluation if err := h1.Process(NewSystemScheduler, eval1); err != nil { @@ -252,7 +252,7 @@ func TestSystemSched_ExhaustResources(t *testing.T) { svcJob := mock.Job() svcJob.TaskGroups[0].Count = 1 svcJob.TaskGroups[0].Tasks[0].Resources.CPU = 3600 - require.NoError(t, h.State.UpsertJob(h.NextIndex(), svcJob)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), svcJob)) // Create a mock evaluation to register the job eval := &structs.Evaluation{ @@ -263,7 +263,7 @@ func TestSystemSched_ExhaustResources(t *testing.T) { JobID: svcJob.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) if err != nil { @@ -272,7 +272,7 @@ func TestSystemSched_ExhaustResources(t *testing.T) { // Create a system job job := mock.SystemJob() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock evaluation to register the job eval1 := &structs.Evaluation{ @@ -283,7 +283,7 @@ func TestSystemSched_ExhaustResources(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval1})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval1})) // Process the evaluation if err := h.Process(NewSystemScheduler, eval1); err != nil { t.Fatalf("err: %v", err) @@ -335,7 +335,7 @@ func TestSystemSched_JobRegister_Annotate(t *testing.T) { Operand: "==", } job.Constraints = append(job.Constraints, fooConstraint) - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock evaluation to deregister the job eval := &structs.Evaluation{ @@ -347,7 +347,7 @@ func TestSystemSched_JobRegister_Annotate(t *testing.T) { AnnotatePlan: true, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewSystemScheduler, eval) @@ -421,7 +421,7 @@ func TestSystemSched_JobRegister_AddNode(t *testing.T) { // Generate a fake job with allocations job := mock.SystemJob() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) var allocs []*structs.Allocation for _, node := range nodes { @@ -447,7 +447,7 @@ func TestSystemSched_JobRegister_AddNode(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewSystemScheduler, eval) if err != nil { @@ -504,7 +504,7 @@ func TestSystemSched_JobRegister_AllocFail(t *testing.T) { // Create NO nodes // Create a job job := mock.SystemJob() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock evaluation to register the job eval := &structs.Evaluation{ @@ -515,7 +515,7 @@ func TestSystemSched_JobRegister_AllocFail(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewSystemScheduler, eval) if err != nil { @@ -543,7 +543,7 @@ func TestSystemSched_JobModify(t *testing.T) { // Generate a fake job with allocations job := mock.SystemJob() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) var allocs []*structs.Allocation for _, node := range nodes { @@ -575,7 +575,7 @@ func TestSystemSched_JobModify(t *testing.T) { // Update the task, such that it cannot be done in-place job2.TaskGroups[0].Tasks[0].Config["command"] = "/bin/other" - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job2)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job2)) // Create a mock evaluation to deal with drain eval := &structs.Evaluation{ @@ -586,7 +586,7 @@ func TestSystemSched_JobModify(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewSystemScheduler, eval) @@ -645,7 +645,7 @@ func TestSystemSched_JobModify_Rolling(t *testing.T) { // Generate a fake job with allocations job := mock.SystemJob() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) var allocs []*structs.Allocation for _, node := range nodes { @@ -668,7 +668,7 @@ func TestSystemSched_JobModify_Rolling(t *testing.T) { // Update the task, such that it cannot be done in-place job2.TaskGroups[0].Tasks[0].Config["command"] = "/bin/other" - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job2)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job2)) // Create a mock evaluation to deal with drain eval := &structs.Evaluation{ @@ -679,7 +679,7 @@ func TestSystemSched_JobModify_Rolling(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewSystemScheduler, eval) if err != nil { @@ -748,7 +748,7 @@ func TestSystemSched_JobModify_InPlace(t *testing.T) { // Generate a fake job with allocations job := mock.SystemJob() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) var allocs []*structs.Allocation for _, node := range nodes { @@ -764,7 +764,7 @@ func TestSystemSched_JobModify_InPlace(t *testing.T) { // Update the job job2 := mock.SystemJob() job2.ID = job.ID - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job2)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job2)) // Create a mock evaluation to deal with drain eval := &structs.Evaluation{ @@ -775,7 +775,7 @@ func TestSystemSched_JobModify_InPlace(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewSystemScheduler, eval) @@ -871,7 +871,7 @@ func TestSystemSched_JobDeregister_Purged(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewSystemScheduler, eval) @@ -920,7 +920,7 @@ func TestSystemSched_JobDeregister_Stopped(t *testing.T) { // Generate a fake job with allocations job := mock.SystemJob() job.Stop = true - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) var allocs []*structs.Allocation for _, node := range nodes { @@ -945,7 +945,7 @@ func TestSystemSched_JobDeregister_Stopped(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewSystemScheduler, eval) @@ -990,7 +990,7 @@ func TestSystemSched_NodeDown(t *testing.T) { // Generate a fake job allocated on that node. job := mock.SystemJob() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) alloc := mock.Alloc() alloc.Job = job @@ -1010,7 +1010,7 @@ func TestSystemSched_NodeDown(t *testing.T) { NodeID: node.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewSystemScheduler, eval) @@ -1058,7 +1058,7 @@ func TestSystemSched_NodeDrain_Down(t *testing.T) { // Generate a fake job allocated on that node. job := mock.SystemJob() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) alloc := mock.Alloc() alloc.Job = job @@ -1077,7 +1077,7 @@ func TestSystemSched_NodeDrain_Down(t *testing.T) { NodeID: node.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewServiceScheduler, eval) @@ -1119,7 +1119,7 @@ func TestSystemSched_NodeDrain(t *testing.T) { // Generate a fake job allocated on that node. job := mock.SystemJob() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) alloc := mock.Alloc() alloc.Job = job @@ -1139,7 +1139,7 @@ func TestSystemSched_NodeDrain(t *testing.T) { NodeID: node.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewSystemScheduler, eval) @@ -1185,7 +1185,7 @@ func TestSystemSched_NodeUpdate(t *testing.T) { // Generate a fake job allocated on that node. job := mock.SystemJob() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) alloc := mock.Alloc() alloc.Job = job @@ -1204,7 +1204,7 @@ func TestSystemSched_NodeUpdate(t *testing.T) { NodeID: node.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewSystemScheduler, eval) @@ -1232,7 +1232,7 @@ func TestSystemSched_RetryLimit(t *testing.T) { // Create a job job := mock.SystemJob() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock evaluation to deregister the job eval := &structs.Evaluation{ @@ -1243,7 +1243,7 @@ func TestSystemSched_RetryLimit(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewSystemScheduler, eval) @@ -1283,7 +1283,7 @@ func TestSystemSched_Queued_With_Constraints(t *testing.T) { // Generate a system job which can't be placed on the node job := mock.SystemJob() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock evaluation to deal eval := &structs.Evaluation{ @@ -1295,7 +1295,7 @@ func TestSystemSched_Queued_With_Constraints(t *testing.T) { NodeID: node.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewSystemScheduler, eval) @@ -1354,7 +1354,7 @@ func TestSystemSched_JobConstraint_AddNode(t *testing.T) { // Upsert Job job.TaskGroups = []*structs.TaskGroup{tgA, tgB} - require.Nil(t, h.State.UpsertJob(h.NextIndex(), job)) + require.Nil(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Evaluate the job eval := &structs.Evaluation{ @@ -1366,7 +1366,7 @@ func TestSystemSched_JobConstraint_AddNode(t *testing.T) { Status: structs.EvalStatusPending, } - require.Nil(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.Nil(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) require.Nil(t, h.Process(NewSystemScheduler, eval)) require.Equal(t, "complete", h.Evals[0].Status) @@ -1398,7 +1398,7 @@ func TestSystemSched_JobConstraint_AddNode(t *testing.T) { Status: structs.EvalStatusPending, } - require.Nil(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval2})) + require.Nil(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval2})) require.Nil(t, h.Process(NewSystemScheduler, eval2)) require.Equal(t, "complete", h.Evals[1].Status) @@ -1430,7 +1430,7 @@ func TestSystemSched_JobConstraint_AddNode(t *testing.T) { } // Ensure New eval is complete - require.Nil(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval3})) + require.Nil(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval3})) require.Nil(t, h.Process(NewSystemScheduler, eval3)) require.Equal(t, "complete", h.Evals[2].Status) @@ -1472,7 +1472,7 @@ func TestSystemSched_ExistingAllocNoNodes(t *testing.T) { // Make a job job := mock.SystemJob() - require.Nil(t, h.State.UpsertJob(h.NextIndex(), job)) + require.Nil(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Evaluate the job eval := &structs.Evaluation{ @@ -1484,7 +1484,7 @@ func TestSystemSched_ExistingAllocNoNodes(t *testing.T) { Status: structs.EvalStatusPending, } - require.Nil(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.Nil(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) require.Nil(t, h.Process(NewSystemScheduler, eval)) require.Equal(t, "complete", h.Evals[0].Status) @@ -1508,14 +1508,14 @@ func TestSystemSched_ExistingAllocNoNodes(t *testing.T) { NodeID: node.ID, Status: structs.EvalStatusPending, } - require.Nil(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval2})) + require.Nil(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval2})) require.Nil(t, h.Process(NewSystemScheduler, eval2)) require.Equal(t, "complete", h.Evals[1].Status) // Create a new job version, deploy job2 := job.Copy() job2.Meta["version"] = "2" - require.Nil(t, h.State.UpsertJob(h.NextIndex(), job2)) + require.Nil(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job2)) // Run evaluation as a plan eval3 := &structs.Evaluation{ @@ -1529,7 +1529,7 @@ func TestSystemSched_ExistingAllocNoNodes(t *testing.T) { } // Ensure New eval is complete - require.Nil(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval3})) + require.Nil(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval3})) require.Nil(t, h.Process(NewSystemScheduler, eval3)) require.Equal(t, "complete", h.Evals[2].Status) @@ -1565,7 +1565,7 @@ func TestSystemSched_ConstraintErrors(t *testing.T) { Operand: "=", }) - require.Nil(t, h.State.UpsertJob(h.NextIndex(), job)) + require.Nil(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Evaluate the job eval := &structs.Evaluation{ @@ -1577,7 +1577,7 @@ func TestSystemSched_ConstraintErrors(t *testing.T) { Status: structs.EvalStatusPending, } - require.Nil(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.Nil(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) require.Nil(t, h.Process(NewSystemScheduler, eval)) require.Equal(t, "complete", h.Evals[0].Status) @@ -1621,7 +1621,7 @@ func TestSystemSched_ChainedAlloc(t *testing.T) { // Create a job job := mock.SystemJob() - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock evaluation to register the job eval := &structs.Evaluation{ @@ -1632,7 +1632,7 @@ func TestSystemSched_ChainedAlloc(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation if err := h.Process(NewSystemScheduler, eval); err != nil { t.Fatalf("err: %v", err) @@ -1652,7 +1652,7 @@ func TestSystemSched_ChainedAlloc(t *testing.T) { job1.ID = job.ID job1.TaskGroups[0].Tasks[0].Env = make(map[string]string) job1.TaskGroups[0].Tasks[0].Env["foo"] = "bar" - require.NoError(t, h1.State.UpsertJob(h1.NextIndex(), job1)) + require.NoError(t, h1.State.UpsertJob(structs.MsgTypeTestSetup, h1.NextIndex(), job1)) // Insert two more nodes for i := 0; i < 2; i++ { @@ -1669,7 +1669,7 @@ func TestSystemSched_ChainedAlloc(t *testing.T) { JobID: job1.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval1})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval1})) // Process the evaluation if err := h1.Process(NewSystemScheduler, eval1); err != nil { t.Fatalf("err: %v", err) @@ -1733,7 +1733,7 @@ func TestSystemSched_PlanWithDrainedNode(t *testing.T) { tg2.Name = "web2" tg2.Constraints[0].RTarget = "blue" job.TaskGroups = append(job.TaskGroups, tg2) - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create an allocation on each node alloc := mock.Alloc() @@ -1762,7 +1762,7 @@ func TestSystemSched_PlanWithDrainedNode(t *testing.T) { NodeID: node.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewSystemScheduler, eval) @@ -1823,7 +1823,7 @@ func TestSystemSched_QueuedAllocsMultTG(t *testing.T) { tg2.Name = "web2" tg2.Constraints[0].RTarget = "blue" job.TaskGroups = append(job.TaskGroups, tg2) - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock evaluation to deal with drain eval := &structs.Evaluation{ @@ -1835,7 +1835,7 @@ func TestSystemSched_QueuedAllocsMultTG(t *testing.T) { NodeID: node.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewSystemScheduler, eval) @@ -1969,7 +1969,7 @@ func TestSystemSched_Preemption(t *testing.T) { }, } - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job1)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job1)) job2 := mock.BatchJob() job2.Type = structs.JobTypeBatch @@ -2012,7 +2012,7 @@ func TestSystemSched_Preemption(t *testing.T) { DiskMB: 5 * 1024, }, } - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job2)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job2)) job3 := mock.Job() job3.Type = structs.JobTypeBatch @@ -2104,7 +2104,7 @@ func TestSystemSched_Preemption(t *testing.T) { DiskMB: 2 * 1024, }, } - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job4)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job4)) require.NoError(t, h.State.UpsertAllocs(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Allocation{alloc4})) // Create a system job such that it would need to preempt both allocs to succeed @@ -2119,7 +2119,7 @@ func TestSystemSched_Preemption(t *testing.T) { }, }, } - require.NoError(t, h.State.UpsertJob(h.NextIndex(), job)) + require.NoError(t, h.State.UpsertJob(structs.MsgTypeTestSetup, h.NextIndex(), job)) // Create a mock evaluation to register the job eval := &structs.Evaluation{ @@ -2130,7 +2130,7 @@ func TestSystemSched_Preemption(t *testing.T) { JobID: job.ID, Status: structs.EvalStatusPending, } - require.NoError(t, h.State.UpsertEvals(h.NextIndex(), []*structs.Evaluation{eval})) + require.NoError(t, h.State.UpsertEvals(structs.MsgTypeTestSetup, h.NextIndex(), []*structs.Evaluation{eval})) // Process the evaluation err := h.Process(NewSystemScheduler, eval)