From 0495a519499d6cefa289982a94d8f42de541c1f0 Mon Sep 17 00:00:00 2001 From: George Goldberg Date: Fri, 7 Jul 2017 15:21:02 +0100 Subject: 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. --- app/job_test.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'app/job_test.go') diff --git a/app/job_test.go b/app/job_test.go index 20e9dee8a..ced65788f 100644 --- a/app/job_test.go +++ b/app/job_test.go @@ -13,17 +13,17 @@ import ( func TestGetJobStatus(t *testing.T) { Setup() - status := &model.JobStatus{ + status := &model.Job{ Id: model.NewId(), Status: model.NewId(), } - if result := <-Srv.Store.JobStatus().SaveOrUpdate(status); result.Err != nil { + if result := <-Srv.Store.Job().Save(status); result.Err != nil { t.Fatal(result.Err) } - defer Srv.Store.JobStatus().Delete(status.Id) + defer Srv.Store.Job().Delete(status.Id) - if received, err := GetJobStatus(status.Id); err != nil { + if received, err := GetJob(status.Id); err != nil { t.Fatal(err) } else if received.Id != status.Id || received.Status != status.Status { t.Fatal("inccorrect job status received") @@ -35,7 +35,7 @@ func TestGetJobStatusesByType(t *testing.T) { jobType := model.NewId() - statuses := []*model.JobStatus{ + statuses := []*model.Job{ { Id: model.NewId(), Type: jobType, @@ -54,11 +54,11 @@ func TestGetJobStatusesByType(t *testing.T) { } for _, status := range statuses { - store.Must(Srv.Store.JobStatus().SaveOrUpdate(status)) - defer Srv.Store.JobStatus().Delete(status.Id) + store.Must(Srv.Store.Job().Save(status)) + defer Srv.Store.Job().Delete(status.Id) } - if received, err := GetJobStatusesByType(jobType, 0, 2); err != nil { + if received, err := GetJobsByType(jobType, 0, 2); err != nil { t.Fatal(err) } else if len(received) != 2 { t.Fatal("received wrong number of statuses") @@ -68,7 +68,7 @@ func TestGetJobStatusesByType(t *testing.T) { t.Fatal("should've received second newest job second") } - if received, err := GetJobStatusesByType(jobType, 2, 2); err != nil { + if received, err := GetJobsByType(jobType, 2, 2); err != nil { t.Fatal(err) } else if len(received) != 1 { t.Fatal("received wrong number of statuses") -- cgit v1.2.3-1-g7c22