diff options
author | George Goldberg <george@gberg.me> | 2017-07-07 15:21:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-07 15:21:02 +0100 |
commit | 0495a519499d6cefa289982a94d8f42de541c1f0 (patch) | |
tree | 94b6145daa41ca4d1d4a172f030071076852a09a /api4/job_test.go | |
parent | 6e0f5f096986dad11ef182ddb51d4bfb0e558860 (diff) | |
download | chat-0495a519499d6cefa289982a94d8f42de541c1f0.tar.gz chat-0495a519499d6cefa289982a94d8f42de541c1f0.tar.bz2 chat-0495a519499d6cefa289982a94d8f42de541c1f0.zip |
PLT-6916: Redesign the jobs package and Jobserver. (#6733)
This commit redesigns the jobserver to be based around an architecture
of "workers", which carry out jobs of a particular type, and "jobs"
which are a unit of work carried by a particular worker. It also
introduces "schedulers" which are responsible for scheduling jobs of a
particular type automatically (jobs can also be scheduled manually when
apropriate).
Workers may be run many times, either in instances of the platform
binary, or the standalone jobserver binary. In any mattermost cluster,
only one instance of platform OR jobserver must run the schedulers. At
the moment this is controlled by a config variable, but in future will
be controlled through the cluster leader election process.
Diffstat (limited to 'api4/job_test.go')
-rw-r--r-- | api4/job_test.go | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/api4/job_test.go b/api4/job_test.go index 0f39fc306..8bbea83e1 100644 --- a/api4/job_test.go +++ b/api4/job_test.go @@ -16,30 +16,30 @@ func TestGetJobStatus(t *testing.T) { th := Setup().InitBasic().InitSystemAdmin() defer TearDown() - status := &model.JobStatus{ + status := &model.Job{ Id: model.NewId(), Status: model.NewId(), } - if result := <-app.Srv.Store.JobStatus().SaveOrUpdate(status); result.Err != nil { + if result := <-app.Srv.Store.Job().Save(status); result.Err != nil { t.Fatal(result.Err) } - defer app.Srv.Store.JobStatus().Delete(status.Id) + defer app.Srv.Store.Job().Delete(status.Id) - received, resp := th.SystemAdminClient.GetJobStatus(status.Id) + received, resp := th.SystemAdminClient.GetJob(status.Id) CheckNoError(t, resp) if received.Id != status.Id || received.Status != status.Status { t.Fatal("incorrect job status received") } - _, resp = th.SystemAdminClient.GetJobStatus("1234") + _, resp = th.SystemAdminClient.GetJob("1234") CheckBadRequestStatus(t, resp) - _, resp = th.Client.GetJobStatus(status.Id) + _, resp = th.Client.GetJob(status.Id) CheckForbiddenStatus(t, resp) - _, resp = th.SystemAdminClient.GetJobStatus(model.NewId()) + _, resp = th.SystemAdminClient.GetJob(model.NewId()) CheckNotFoundStatus(t, resp) } @@ -49,7 +49,7 @@ func TestGetJobStatusesByType(t *testing.T) { jobType := model.NewId() - statuses := []*model.JobStatus{ + statuses := []*model.Job{ { Id: model.NewId(), Type: jobType, @@ -68,11 +68,11 @@ func TestGetJobStatusesByType(t *testing.T) { } for _, status := range statuses { - store.Must(app.Srv.Store.JobStatus().SaveOrUpdate(status)) - defer app.Srv.Store.JobStatus().Delete(status.Id) + store.Must(app.Srv.Store.Job().Save(status)) + defer app.Srv.Store.Job().Delete(status.Id) } - received, resp := th.SystemAdminClient.GetJobStatusesByType(jobType, 0, 2) + received, resp := th.SystemAdminClient.GetJobsByType(jobType, 0, 2) CheckNoError(t, resp) if len(received) != 2 { @@ -83,7 +83,7 @@ func TestGetJobStatusesByType(t *testing.T) { t.Fatal("should've received second newest job second") } - received, resp = th.SystemAdminClient.GetJobStatusesByType(jobType, 1, 2) + received, resp = th.SystemAdminClient.GetJobsByType(jobType, 1, 2) CheckNoError(t, resp) if len(received) != 1 { @@ -92,12 +92,12 @@ func TestGetJobStatusesByType(t *testing.T) { t.Fatal("should've received oldest job last") } - _, resp = th.SystemAdminClient.GetJobStatusesByType("", 0, 60) + _, resp = th.SystemAdminClient.GetJobsByType("", 0, 60) CheckNotFoundStatus(t, resp) - _, resp = th.SystemAdminClient.GetJobStatusesByType(strings.Repeat("a", 33), 0, 60) + _, resp = th.SystemAdminClient.GetJobsByType(strings.Repeat("a", 33), 0, 60) CheckBadRequestStatus(t, resp) - _, resp = th.Client.GetJobStatusesByType(jobType, 0, 60) + _, resp = th.Client.GetJobsByType(jobType, 0, 60) CheckForbiddenStatus(t, resp) } |