-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -1767,9 +1767,13 @@ func (c *Cluster) GetStatus() *ClusterStatus { | |||||
| } | ||||||
|
|
||||||
| func (c *Cluster) GetSwitchoverSchedule() string { | ||||||
| now := time.Now().UTC() | ||||||
| return c.GetSwitchoverScheduleAtTime(now) | ||||||
| } | ||||||
|
|
||||||
| func (c *Cluster) GetSwitchoverScheduleAtTime(now time.Time) string { | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This method doesn't need to be exported |
||||||
| var possibleSwitchover, schedule time.Time | ||||||
|
|
||||||
| now := time.Now().UTC() | ||||||
| for _, window := range c.Spec.MaintenanceWindows { | ||||||
| // in the best case it is possible today | ||||||
| possibleSwitchover = time.Date(now.Year(), now.Month(), now.Day(), window.StartTime.Hour(), window.StartTime.Minute(), 0, 0, time.UTC) | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2116,7 +2116,7 @@ func TestCompareVolumeMounts(t *testing.T) { | |||||
| } | ||||||
|
|
||||||
| func TestGetSwitchoverSchedule(t *testing.T) { | ||||||
| now := time.Now() | ||||||
| now, _ := time.Parse(time.RFC3339, "2025-11-11T12:35:00Z") | ||||||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. jup, could reproduce. Thanks for the pointer |
||||||
|
|
||||||
| futureTimeStart := now.Add(1 * time.Hour) | ||||||
| futureWindowTimeStart := futureTimeStart.Format("15:04") | ||||||
|
|
@@ -2195,7 +2195,7 @@ func TestGetSwitchoverSchedule(t *testing.T) { | |||||
| for _, tt := range tests { | ||||||
| t.Run(tt.name, func(t *testing.T) { | ||||||
| cluster.Spec.MaintenanceWindows = tt.windows | ||||||
| schedule := cluster.GetSwitchoverSchedule() | ||||||
| schedule := cluster.GetSwitchoverScheduleAtTime(now) | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
see Mikkel's comment |
||||||
| if schedule != tt.expected { | ||||||
| t.Errorf("Expected GetSwitchoverSchedule to return %s, returned: %s", tt.expected, schedule) | ||||||
| } | ||||||
|
|
||||||
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.
see below