-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix switchover schedule tests #2995
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
base: master
Are you sure you want to change the base?
Conversation
Previously the tests would fail depending on the local time zone and the time of day the test was being run.
|
Cannot start a pipeline due to: Click on pipeline status check Details link below for more information. |
|
|
||
| func TestGetSwitchoverSchedule(t *testing.T) { | ||
| now := time.Now() | ||
| now, _ := time.Parse(time.RFC3339, "2025-11-11T12:35:00Z") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note that you can reproduce the test failures I had when running locally by passing in some other times here like
- 2025-11-11T20:35:00-08:00
- 2025-11-11T23:35:00Z
| return c.GetSwitchoverScheduleAtTime(now) | ||
| } | ||
|
|
||
| func (c *Cluster) GetSwitchoverScheduleAtTime(now time.Time) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| func (c *Cluster) GetSwitchoverScheduleAtTime(now time.Time) string { | |
| func (c *Cluster) getSwitchoverScheduleAtTime(now time.Time) string { |
This method doesn't need to be exported
Previously the tests would fail depending on the local time zone and the time of day the test was being run (even if you set the machine to UTC it would fail if run within an hour of midnight; similarly the tests would fail any time the date component of the local time and UTC was different as the schedule would not match on the right day). Changes the tests to pass in a consistent specific time for
nowso that the tests no longer have different behavior based on when (or where) they are run.