From e3a56adad0fd44e6b26f55aeb7be5af1b24302bc Mon Sep 17 00:00:00 2001 From: Yash Bhardwaj Date: Wed, 6 Sep 2023 13:24:50 +0530 Subject: [PATCH] =?UTF-8?q?fix:=20filter=20false=20SLA=20alerts=20honor=20?= =?UTF-8?q?nil=20job=20end=20times=20instead=20of=20lon=E2=80=A6=20(#137)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: filter false sla alerts, honnor nil job end times instead of long future date * fix: handle nil end time for operator runs * fix: add testcase --- core/scheduler/job_run.go | 24 +++-- core/scheduler/job_test.go | 63 +++++++++++++ core/scheduler/service/job_run_service.go | 41 ++++++++- .../scheduler/service/job_run_service_test.go | 83 ++++++++++++++++- .../scheduler/job_operator_repository.go | 4 +- .../postgres/scheduler/job_run_repository.go | 92 ++++++++++++++----- .../scheduler/job_run_repository_test.go | 8 +- tests/bench/scheduler/job_run_repo_test.go | 7 +- 8 files changed, 270 insertions(+), 52 deletions(-) diff --git a/core/scheduler/job_run.go b/core/scheduler/job_run.go index faae276a15..d68ad15c0f 100644 --- a/core/scheduler/job_run.go +++ b/core/scheduler/job_run.go @@ -35,17 +35,25 @@ func (i JobRunID) IsEmpty() bool { type JobRun struct { ID uuid.UUID - JobName JobName - Tenant tenant.Tenant - State State - ScheduledAt time.Time - StartTime time.Time - SLAAlert bool - EndTime time.Time + JobName JobName + Tenant tenant.Tenant + State State + ScheduledAt time.Time + SLAAlert bool + StartTime time.Time + EndTime *time.Time + SLADefinition int64 Monitoring map[string]any } +func (j *JobRun) HasSLABreached() bool { + if j.EndTime != nil { + return j.EndTime.After(j.StartTime.Add(time.Second * time.Duration(j.SLADefinition))) + } + return time.Now().After(j.StartTime.Add(time.Second * time.Duration(j.SLADefinition))) +} + type OperatorRun struct { ID uuid.UUID Name string @@ -53,7 +61,7 @@ type OperatorRun struct { OperatorType OperatorType Status State StartTime time.Time - EndTime time.Time + EndTime *time.Time } type NotifyAttrs struct { diff --git a/core/scheduler/job_test.go b/core/scheduler/job_test.go index 35033d995f..e1fea88020 100644 --- a/core/scheduler/job_test.go +++ b/core/scheduler/job_test.go @@ -2,6 +2,7 @@ package scheduler_test import ( "testing" + "time" "github.com/google/uuid" "github.com/stretchr/testify/assert" @@ -73,6 +74,68 @@ func TestJob(t *testing.T) { assert.Equal(t, "jobName", jobWithDetails.GetName()) }) t.Run("SLADuration", func(t *testing.T) { + t.Run("has job breached SLA", func(t *testing.T) { + t.Run("duration 1.5 hr", func(t *testing.T) { + jobEndTime := time.Now().Add(-1*time.Hour - 30*time.Minute) + jobRun := scheduler.JobRun{ + ID: uuid.UUID{}, + JobName: "", + Tenant: tenant.Tenant{}, + State: "", + ScheduledAt: time.Time{}, + SLAAlert: false, + StartTime: time.Now().Add(-3 * time.Hour), + EndTime: &jobEndTime, + SLADefinition: 3600, + } + + assert.True(t, jobRun.HasSLABreached()) + }) + t.Run("duration .5 hr", func(t *testing.T) { + jobEndTime := time.Now().Add(-2*time.Hour - 30*time.Minute) + jobRun := scheduler.JobRun{ + ID: uuid.UUID{}, + JobName: "", + Tenant: tenant.Tenant{}, + State: "", + ScheduledAt: time.Time{}, + SLAAlert: false, + StartTime: time.Now().Add(-3 * time.Hour), + EndTime: &jobEndTime, + SLADefinition: 3600, + } + assert.False(t, jobRun.HasSLABreached()) + }) + t.Run("should breach sla based on current time if job end time is nil", func(t *testing.T) { + jobRun := scheduler.JobRun{ + ID: uuid.UUID{}, + JobName: "", + Tenant: tenant.Tenant{}, + State: "", + ScheduledAt: time.Time{}, + SLAAlert: false, + StartTime: time.Now().Add(-3 * time.Hour), + EndTime: nil, + SLADefinition: 3600, + } + assert.True(t, jobRun.HasSLABreached()) + }) + t.Run("should 'not report SLA breach' based on current time if job end time is nil", func(t *testing.T) { + jobRun := scheduler.JobRun{ + ID: uuid.UUID{}, + JobName: "", + Tenant: tenant.Tenant{}, + State: "", + ScheduledAt: time.Time{}, + SLAAlert: false, + StartTime: time.Now().Add(-30 * time.Minute), // job started 30 min ago + EndTime: nil, + SLADefinition: 3600, + } + assert.False(t, jobRun.HasSLABreached()) + }) + }) + t.Run("should return 0 and error if duration is incorrect format", func(t *testing.T) { jobWithDetails := scheduler.JobWithDetails{ Name: "jobName", diff --git a/core/scheduler/service/job_run_service.go b/core/scheduler/service/job_run_service.go index 0c581d05ad..ca4e363e2c 100644 --- a/core/scheduler/service/job_run_service.go +++ b/core/scheduler/service/job_run_service.go @@ -41,10 +41,11 @@ type JobRepository interface { type JobRunRepository interface { GetByID(ctx context.Context, id scheduler.JobRunID) (*scheduler.JobRun, error) GetByScheduledAt(ctx context.Context, tenant tenant.Tenant, name scheduler.JobName, scheduledAt time.Time) (*scheduler.JobRun, error) + GetByScheduledTimes(ctx context.Context, tenant tenant.Tenant, jobName scheduler.JobName, scheduledTimes []time.Time) ([]*scheduler.JobRun, error) Create(ctx context.Context, tenant tenant.Tenant, name scheduler.JobName, scheduledAt time.Time, slaDefinitionInSec int64) error Update(ctx context.Context, jobRunID uuid.UUID, endTime time.Time, jobRunStatus scheduler.State) error UpdateState(ctx context.Context, jobRunID uuid.UUID, jobRunStatus scheduler.State) error - UpdateSLA(ctx context.Context, slaObjects []*scheduler.SLAObject) error + UpdateSLA(ctx context.Context, jobName scheduler.JobName, project tenant.ProjectName, scheduledTimes []time.Time) error UpdateMonitoring(ctx context.Context, jobRunID uuid.UUID, monitoring map[string]any) error } @@ -311,15 +312,47 @@ func (*JobRunService) getMonitoringValues(event *scheduler.Event) map[string]any } func (s *JobRunService) updateJobRunSLA(ctx context.Context, event *scheduler.Event) error { + if len(event.SLAObjectList) < 1 { + return nil + } + var scheduleTimesList []time.Time + for _, SLAObject := range event.SLAObjectList { + scheduleTimesList = append(scheduleTimesList, SLAObject.JobScheduledAt) + } + jobRuns, err := s.repo.GetByScheduledTimes(ctx, event.Tenant, event.JobName, scheduleTimesList) + if err != nil { + s.l.Error("error getting job runs by schedule time", err) + return err + } + + var slaBreachedJobRunScheduleTimes []time.Time + var filteredSLAObject []*scheduler.SLAObject + for _, jobRun := range jobRuns { + if !jobRun.HasSLABreached() { + s.l.Error("received sla miss callback for job run that has not breached SLA, jobName: %s, scheduled_at: %s, start_time: %s, end_time: %s, SLA definition: %s", + jobRun.JobName, jobRun.ScheduledAt.String(), jobRun.StartTime, jobRun.EndTime, time.Second*time.Duration(jobRun.SLADefinition)) + continue + } + filteredSLAObject = append(filteredSLAObject, &scheduler.SLAObject{ + JobName: jobRun.JobName, + JobScheduledAt: jobRun.ScheduledAt, + }) + slaBreachedJobRunScheduleTimes = append(slaBreachedJobRunScheduleTimes, jobRun.ScheduledAt) + } + + event.SLAObjectList = filteredSLAObject + + err = s.repo.UpdateSLA(ctx, event.JobName, event.Tenant.ProjectName(), slaBreachedJobRunScheduleTimes) + if err != nil { + s.l.Error("error updating job run sla status", err) + return err + } telemetry.NewCounter(metricJobRunEvents, map[string]string{ "project": event.Tenant.ProjectName().String(), "namespace": event.Tenant.NamespaceName().String(), "name": event.JobName.String(), "status": scheduler.SLAMissEvent.String(), }).Inc() - if len(event.SLAObjectList) > 0 { - return s.repo.UpdateSLA(ctx, event.SLAObjectList) - } return nil } diff --git a/core/scheduler/service/job_run_service_test.go b/core/scheduler/service/job_run_service_test.go index bef2d232d4..09e410093b 100644 --- a/core/scheduler/service/job_run_service_test.go +++ b/core/scheduler/service/job_run_service_test.go @@ -634,6 +634,80 @@ func TestJobRunService(t *testing.T) { assert.EqualError(t, err, "error in getting operator run") }) }) + + t.Run("updateJobRunSLA", func(t *testing.T) { + t.Run("scenario false sla notification", func(t *testing.T) { + scheduledAtTimeStamp, _ := time.Parse(scheduler.ISODateFormat, "2022-01-02T15:04:05Z") + eventTime := time.Now() + // example of an hourly job + slaBreachedJobRunScheduleTimes := []time.Time{ + time.Now().Add(time.Hour * time.Duration(-3)), + time.Now().Add(time.Hour * time.Duration(-2)), + time.Now().Add(time.Hour * time.Duration(-1)), + } + var slaObjectList []*scheduler.SLAObject + for _, scheduleTime := range slaBreachedJobRunScheduleTimes { + slaObjectList = append(slaObjectList, &scheduler.SLAObject{ + JobName: jobName, + JobScheduledAt: scheduleTime, + }) + } + + event := &scheduler.Event{ + JobName: jobName, + Tenant: tnnt, + Type: scheduler.SLAMissEvent, + EventTime: eventTime, + OperatorName: "task_bq2bq", + Status: scheduler.StateSuccess, + JobScheduledAt: scheduledAtTimeStamp, + Values: map[string]any{ + "status": "success", + }, + SLAObjectList: slaObjectList, + } + + var jobRuns []*scheduler.JobRun + for _, slaBreachedJobRunScheduleTime := range slaBreachedJobRunScheduleTimes { + jobRuns = append(jobRuns, &scheduler.JobRun{ + JobName: jobName, + Tenant: tnnt, + ScheduledAt: slaBreachedJobRunScheduleTime, + SLAAlert: false, + StartTime: slaBreachedJobRunScheduleTime.Add(time.Second * time.Duration(1)), + SLADefinition: 100, + }) + } + + endTime0 := slaBreachedJobRunScheduleTimes[0].Add(time.Second * time.Duration(40)) // duration 40-1 = 39 Sec (Not an SLA breach) + jobRuns[0].EndTime = &endTime0 + endTime1 := slaBreachedJobRunScheduleTimes[1].Add(time.Second * time.Duration(120)) // duration 120-1 = 119 Sec + jobRuns[1].EndTime = &endTime1 + endTime2 := slaBreachedJobRunScheduleTimes[2].Add(time.Second * time.Duration(200)) // duration 200-1 = 199 Sec + jobRuns[2].EndTime = &endTime2 + + jobRunRepo := new(mockJobRunRepository) + jobRunRepo.On("GetByScheduledTimes", ctx, tnnt, jobName, slaBreachedJobRunScheduleTimes).Return(jobRuns, nil).Once() + jobRunRepo.On("UpdateSLA", ctx, event.JobName, event.Tenant.ProjectName(), []time.Time{ + slaBreachedJobRunScheduleTimes[1], slaBreachedJobRunScheduleTimes[2], + }).Return(nil).Once() + defer jobRunRepo.AssertExpectations(t) + + runService := service.NewJobRunService(logger, + nil, jobRunRepo, nil, nil, nil, nil, nil, nil) + + err := runService.UpdateJobState(ctx, event) + assert.Nil(t, err) + + t.Run("scenario false sla notification, filter the false sla alert", func(t *testing.T) { + assert.Equal(t, 2, len(event.SLAObjectList)) + for _, slaObject := range event.SLAObjectList { + // slaBreachedJobRunScheduleTimes [0] should not be in the list as that is a false alert + assert.False(t, slaObject.JobScheduledAt.Equal(slaBreachedJobRunScheduleTimes[0])) + } + }) + }) + }) }) t.Run("JobRunInput", func(t *testing.T) { @@ -1324,8 +1398,13 @@ func (m *mockJobRunRepository) UpdateState(ctx context.Context, jobRunID uuid.UU return args.Error(0) } -func (m *mockJobRunRepository) UpdateSLA(ctx context.Context, slaObjects []*scheduler.SLAObject) error { - args := m.Called(ctx, slaObjects) +func (m *mockJobRunRepository) GetByScheduledTimes(ctx context.Context, tenant tenant.Tenant, jobName scheduler.JobName, scheduledTimes []time.Time) ([]*scheduler.JobRun, error) { + args := m.Called(ctx, tenant, jobName, scheduledTimes) + return args.Get(0).([]*scheduler.JobRun), args.Error(1) +} + +func (m *mockJobRunRepository) UpdateSLA(ctx context.Context, jobName scheduler.JobName, project tenant.ProjectName, scheduledTimes []time.Time) error { + args := m.Called(ctx, jobName, project, scheduledTimes) return args.Error(0) } diff --git a/internal/store/postgres/scheduler/job_operator_repository.go b/internal/store/postgres/scheduler/job_operator_repository.go index c8560c0e28..637547b61d 100644 --- a/internal/store/postgres/scheduler/job_operator_repository.go +++ b/internal/store/postgres/scheduler/job_operator_repository.go @@ -35,7 +35,7 @@ type operatorRun struct { Status string StartTime time.Time - EndTime time.Time + EndTime *time.Time CreatedAt time.Time UpdatedAt time.Time @@ -96,7 +96,7 @@ func (o *OperatorRunRepository) CreateOperatorRun(ctx context.Context, name stri if err != nil { return err } - insertOperatorRun := "INSERT INTO " + operatorTableName + " ( " + jobOperatorColumnsToStore + ", created_at, updated_at) values ( $1, $2, $3, $4, TIMESTAMP '3000-01-01 00:00:00', NOW(), NOW())" + insertOperatorRun := "INSERT INTO " + operatorTableName + " ( " + jobOperatorColumnsToStore + ", created_at, updated_at) values ( $1, $2, $3, $4, null, NOW(), NOW())" _, err = o.db.Exec(ctx, insertOperatorRun, name, jobRunID, scheduler.StateRunning, startTime) return errors.WrapIfErr(scheduler.EntityJobRun, "error while inserting the run", err) } diff --git a/internal/store/postgres/scheduler/job_run_repository.go b/internal/store/postgres/scheduler/job_run_repository.go index 1a85edf0f5..f3aa2c939f 100644 --- a/internal/store/postgres/scheduler/job_run_repository.go +++ b/internal/store/postgres/scheduler/job_run_repository.go @@ -3,7 +3,7 @@ package scheduler import ( "context" "encoding/json" - "fmt" + "strings" "time" "github.com/google/uuid" @@ -18,6 +18,7 @@ import ( const ( columnsToStore = `job_name, namespace_name, project_name, scheduled_at, start_time, end_time, status, sla_definition, sla_alert` jobRunColumns = `id, ` + columnsToStore + `, monitoring` + dbTimeFormat = "2006-01-02 15:04:05.000000" ) type JobRunRepository struct { @@ -33,7 +34,7 @@ type jobRun struct { ScheduledAt time.Time StartTime time.Time - EndTime time.Time + EndTime *time.Time Status string SLAAlert bool @@ -61,15 +62,16 @@ func (j *jobRun) toJobRun() (*scheduler.JobRun, error) { } } return &scheduler.JobRun{ - ID: j.ID, - JobName: scheduler.JobName(j.JobName), - Tenant: t, - State: state, - ScheduledAt: j.ScheduledAt, - StartTime: j.StartTime, - SLAAlert: j.SLAAlert, - EndTime: j.EndTime, - Monitoring: monitoring, + ID: j.ID, + JobName: scheduler.JobName(j.JobName), + Tenant: t, + State: state, + ScheduledAt: j.ScheduledAt, + SLAAlert: j.SLAAlert, + StartTime: j.StartTime, + EndTime: j.EndTime, + SLADefinition: j.SLADefinition, + Monitoring: monitoring, }, nil } @@ -90,8 +92,9 @@ func (j *JobRunRepository) GetByID(ctx context.Context, id scheduler.JobRunID) ( func (j *JobRunRepository) GetByScheduledAt(ctx context.Context, t tenant.Tenant, jobName scheduler.JobName, scheduledAt time.Time) (*scheduler.JobRun, error) { var jr jobRun - getJobRunByID := `SELECT ` + jobRunColumns + `, created_at FROM job_run j where project_name = $1 and namespace_name = $2 and job_name = $3 and scheduled_at = $4 order by created_at desc limit 1` - err := j.db.QueryRow(ctx, getJobRunByID, t.ProjectName(), t.NamespaceName(), jobName, scheduledAt). + // todo: check if `order by created_at desc limit 1` is required + getJobRunByScheduledAt := `SELECT ` + jobRunColumns + `, created_at FROM job_run j where project_name = $1 and namespace_name = $2 and job_name = $3 and scheduled_at = $4 order by created_at desc limit 1` + err := j.db.QueryRow(ctx, getJobRunByScheduledAt, t.ProjectName(), t.NamespaceName(), jobName, scheduledAt). Scan(&jr.ID, &jr.JobName, &jr.NamespaceName, &jr.ProjectName, &jr.ScheduledAt, &jr.StartTime, &jr.EndTime, &jr.Status, &jr.SLADefinition, &jr.SLAAlert, &jr.Monitoring, &jr.CreatedAt) if err != nil { @@ -103,6 +106,38 @@ func (j *JobRunRepository) GetByScheduledAt(ctx context.Context, t tenant.Tenant return jr.toJobRun() } +func (j *JobRunRepository) GetByScheduledTimes(ctx context.Context, t tenant.Tenant, jobName scheduler.JobName, scheduleTimes []time.Time) ([]*scheduler.JobRun, error) { + var jobRunList []*scheduler.JobRun + var scheduledTimesString []string + for _, scheduleTime := range scheduleTimes { + scheduledTimesString = append(scheduledTimesString, scheduleTime.UTC().Format(dbTimeFormat)) + } + + getJobRunByScheduledTimesTemp := `SELECT ` + jobRunColumns + `,created_at FROM job_run j where project_name = $1 and namespace_name = $2 and job_name = $3 and scheduled_at in ('` + strings.Join(scheduledTimesString, "', '") + `')` + rows, err := j.db.Query(ctx, getJobRunByScheduledTimesTemp, t.ProjectName(), t.NamespaceName(), jobName.String()) + if err != nil { + return nil, errors.Wrap(scheduler.EntityJobRun, "error while getting job runs", err) + } + for rows.Next() { + var jr jobRun + err := rows.Scan(&jr.ID, &jr.JobName, &jr.NamespaceName, &jr.ProjectName, &jr.ScheduledAt, &jr.StartTime, &jr.EndTime, + &jr.Status, &jr.SLADefinition, &jr.SLAAlert, &jr.Monitoring, &jr.CreatedAt) + if err != nil { + if errors.Is(err, pgx.ErrNoRows) { + return nil, errors.NotFound(scheduler.EntityJobRun, "no record of job run :"+jobName.String()+" for schedule Times : "+strings.Join(scheduledTimesString, ", ")) + } + return nil, errors.Wrap(scheduler.EntityJobRun, "error while getting job runs", err) + } + jobRun, err := jr.toJobRun() + if err != nil { + return nil, errors.Wrap(scheduler.EntityJobRun, "error while getting job runs", err) + } + jobRunList = append(jobRunList, jobRun) + } + + return jobRunList, nil +} + func (j *JobRunRepository) UpdateState(ctx context.Context, jobRunID uuid.UUID, status scheduler.State) error { updateJobRun := "update job_run set status = $1, updated_at = NOW() where id = $2" _, err := j.db.Exec(ctx, updateJobRun, status, jobRunID) @@ -115,18 +150,24 @@ func (j *JobRunRepository) Update(ctx context.Context, jobRunID uuid.UUID, endTi return errors.WrapIfErr(scheduler.EntityJobRun, "unable to update job run", err) } -func (j *JobRunRepository) UpdateSLA(ctx context.Context, slaObjects []*scheduler.SLAObject) error { - var jobIDListString string - totalIds := len(slaObjects) - for i, slaObject := range slaObjects { - jobIDListString += fmt.Sprintf("('%s','%s')", slaObject.JobName, slaObject.JobScheduledAt.UTC().Format("2006-01-02 15:04:05.000000")) - if !(i == totalIds-1) { - jobIDListString += ", " - } +func (j *JobRunRepository) UpdateSLA(ctx context.Context, jobName scheduler.JobName, projectName tenant.ProjectName, scheduleTimes []time.Time) error { + if len(scheduleTimes) == 0 { + return nil + } + var scheduleTimesListString []string + for _, scheduleTime := range scheduleTimes { + scheduleTimesListString = append(scheduleTimesListString, scheduleTime.UTC().Format(dbTimeFormat)) } - query := "update job_run set sla_alert = True, updated_at = NOW() where (job_name, scheduled_at) IN (" + jobIDListString + ")" - _, err := j.db.Exec(ctx, query) - return errors.WrapIfErr(scheduler.EntityJobRun, "unable to update SLA", err) + query := ` +update + job_run +set + sla_alert = True, updated_at = NOW() +where + job_name = $1 and project_name = $2 and scheduled_at IN ('` + strings.Join(scheduleTimesListString, "', '") + "')" + _, err := j.db.Exec(ctx, query, jobName, projectName) + + return errors.WrapIfErr(scheduler.EntityJobRun, "cannot update job Run State as Sla miss", err) } func (j *JobRunRepository) UpdateMonitoring(ctx context.Context, jobRunID uuid.UUID, monitoringValues map[string]any) error { @@ -140,7 +181,8 @@ func (j *JobRunRepository) UpdateMonitoring(ctx context.Context, jobRunID uuid.U } func (j *JobRunRepository) Create(ctx context.Context, t tenant.Tenant, jobName scheduler.JobName, scheduledAt time.Time, slaDefinitionInSec int64) error { - insertJobRun := `INSERT INTO job_run (` + columnsToStore + `, created_at, updated_at) values ($1, $2, $3, $4, NOW(), TIMESTAMP '3000-01-01 00:00:00', $5, $6, FALSE, NOW(), NOW()) ON CONFLICT DO NOTHING` + // TODO: startTime should be event time + insertJobRun := `INSERT INTO job_run (` + columnsToStore + `, created_at, updated_at) values ($1, $2, $3, $4, NOW(), null, $5, $6, FALSE, NOW(), NOW()) ON CONFLICT DO NOTHING` _, err := j.db.Exec(ctx, insertJobRun, jobName, t.NamespaceName(), t.ProjectName(), scheduledAt, scheduler.StateRunning, slaDefinitionInSec) return errors.WrapIfErr(scheduler.EntityJobRun, "unable to create job run", err) } diff --git a/internal/store/postgres/scheduler/job_run_repository_test.go b/internal/store/postgres/scheduler/job_run_repository_test.go index 11f1244545..fd3f09c10d 100644 --- a/internal/store/postgres/scheduler/job_run_repository_test.go +++ b/internal/store/postgres/scheduler/job_run_repository_test.go @@ -79,13 +79,9 @@ func TestPostgresJobRunRepository(t *testing.T) { jobRun, err := jobRunRepo.GetByScheduledAt(ctx, tnnt, jobAName, scheduledAt) assert.Nil(t, err) - slaObject := scheduler.SLAObject{ - JobName: jobAName, - JobScheduledAt: scheduledAt, - } - slaObjects := []*scheduler.SLAObject{&slaObject} + scheduleTimes := []time.Time{scheduledAt} - err = jobRunRepo.UpdateSLA(ctx, slaObjects) + err = jobRunRepo.UpdateSLA(ctx, jobAName, tnnt.ProjectName(), scheduleTimes) assert.Nil(t, err) jobRunByID, err := jobRunRepo.GetByID(ctx, scheduler.JobRunID(jobRun.ID)) diff --git a/tests/bench/scheduler/job_run_repo_test.go b/tests/bench/scheduler/job_run_repo_test.go index d0ebc8403f..f222a537ed 100644 --- a/tests/bench/scheduler/job_run_repo_test.go +++ b/tests/bench/scheduler/job_run_repo_test.go @@ -213,12 +213,9 @@ func BenchmarkJobRunRepository(b *testing.B) { jobNameForJobRun, err := serviceScheduler.JobNameFrom(job.GetName()) assert.NoError(b, err) - slaObject := serviceScheduler.SLAObject{ - JobName: jobNameForJobRun, - JobScheduledAt: scheduledAts[jobRunIdx], - } + scheduledTimeList := []time.Time{scheduledAts[jobRunIdx]} - actualError := schedulerJobRunRepo.UpdateSLA(ctx, []*serviceScheduler.SLAObject{&slaObject}) + actualError := schedulerJobRunRepo.UpdateSLA(ctx, jobNameForJobRun, tnnt.ProjectName(), scheduledTimeList) assert.NoError(b, actualError) } })