Skip to content

Commit

Permalink
Enable labels filter test and improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
taraspos committed Feb 18, 2024
1 parent fe13b82 commit 8905afa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
11 changes: 6 additions & 5 deletions cli/docker-labels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ func (s *TestDockerSuit) TestLabelsFilterJobsCount(c *check.C) {
{
requiredLabel: "true",
filterLabel[0]: filterLabel[1],
labelPrefix + "." + jobExec + ".job2.schedule": "schedule2",
labelPrefix + "." + jobExec + ".job2.command": "command2",
labelPrefix + "." + jobExec + ".job2.schedule": "* * * * *",
labelPrefix + "." + jobExec + ".job2.command": "command2",
labelPrefix + "." + jobExec + ".job2.container": "container2",
},
{
requiredLabel: "true",
labelPrefix + "." + jobExec + ".job3.schedule": "schedule3",
labelPrefix + "." + jobExec + ".job3.command": "command3",
labelPrefix + "." + jobExec + ".job3.schedule": "* * * * *",
labelPrefix + "." + jobExec + ".job3.command": "command3",
labelPrefix + "." + jobExec + ".job3.container": "container3",
},
}

Expand All @@ -62,7 +64,6 @@ func (s *TestDockerSuit) TestLabelsFilterJobsCount(c *check.C) {
c.Assert(err, check.IsNil)
c.Assert(scheduler, check.NotNil)

c.Skip("This test will not work until https://github.com/fsouza/go-dockerclient/pull/1031 is merged")
c.Assert(scheduler.Jobs, check.HasLen, 1)
}

Expand Down
5 changes: 3 additions & 2 deletions core/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,18 @@ func NewScheduler(l Logger) *Scheduler {
}

func (s *Scheduler) AddJob(j Job) error {
s.Logger.Noticef("New job registered %q - %q - %q", j.GetName(), j.GetCommand(), j.GetSchedule())

if j.GetSchedule() == "" {
return ErrEmptySchedule
}

err := s.cron.AddJob(j.GetSchedule(), &jobWrapper{s, j})
if err != nil {
s.Logger.Warningf("Failed to register job %q - %q - %q", j.GetName(), j.GetCommand(), j.GetSchedule())
return err
}

s.Logger.Noticef("New job registered %q - %q - %q", j.GetName(), j.GetCommand(), j.GetSchedule())

s.Jobs = append(s.Jobs, j)
return nil
}
Expand Down

0 comments on commit 8905afa

Please sign in to comment.