From 8905afa4b18a7099966af86b44c4faf32250843f Mon Sep 17 00:00:00 2001 From: Taras Date: Sun, 18 Feb 2024 19:27:37 +0000 Subject: [PATCH] Enable labels filter test and improve logging --- cli/docker-labels_test.go | 11 ++++++----- core/scheduler.go | 5 +++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/cli/docker-labels_test.go b/cli/docker-labels_test.go index 8c5049d1e..402138a6d 100644 --- a/cli/docker-labels_test.go +++ b/cli/docker-labels_test.go @@ -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", }, } @@ -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) } diff --git a/core/scheduler.go b/core/scheduler.go index 7733889df..d1ef8d9df 100644 --- a/core/scheduler.go +++ b/core/scheduler.go @@ -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 }