Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release-22.2: backupccl: deflake TestScheduleChainingLifecycle #95635

Merged
merged 1 commit into from
Jan 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion pkg/ccl/backupccl/schedule_pts_chaining_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
"github.com/cockroachdb/cockroach/pkg/testutils"
"github.com/cockroachdb/cockroach/pkg/testutils/skip"
"github.com/cockroachdb/cockroach/pkg/util/hlc"
"github.com/cockroachdb/cockroach/pkg/util/leaktest"
"github.com/cockroachdb/cockroach/pkg/util/log"
Expand All @@ -44,7 +45,7 @@ func (th *testHelper) createSchedules(
}
backupQuery := fmt.Sprintf("%s%s", backupStmt, backupOpts)
schedules, err := th.createBackupSchedule(t,
fmt.Sprintf("CREATE SCHEDULE FOR %s RECURRING '*/5 * * * *'", backupQuery))
fmt.Sprintf("CREATE SCHEDULE FOR %s RECURRING '*/2 * * * *'", backupQuery))
require.NoError(t, err)

// We expect full & incremental schedule to be created.
Expand Down Expand Up @@ -95,6 +96,19 @@ func TestScheduleChainingLifecycle(t *testing.T) {
th, cleanup := newTestHelper(t)
defer cleanup()

roundedCurrentTime := th.cfg.DB.Clock().PhysicalTime().Round(time.Minute * 5)
if roundedCurrentTime.Hour() == 0 && roundedCurrentTime.Minute() == 0 {
// The backup schedule in this test uses the following crontab recurrence:
// '*/2 * * * *'. In english, this means "run a full backup now, and then
// run a full backup every day at midnight, and an incremental every 2
// minutes. This test relies on an incremental backup running after the
// first full backup. But, what happens if the first full backup gets
// scheduled to run within 5 minutes of midnight? A second full backup may
// get scheduled before the expected incremental backup, breaking the
// invariant the test expects. For this reason, skip the test if it's
// running close to midnight #spooky.
skip.WithIssue(t, 91640, "test flakes when the machine clock is too close to midnight")
}
th.sqlDB.Exec(t, `
CREATE DATABASE db;
USE db;
Expand Down