-
Notifications
You must be signed in to change notification settings - Fork 875
fix: make GetWorkspacesEligibleForTransition return even less false positives #15594
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
78d9bef
fix: begin impl of reducing autostart false-positive rate
DanielleMaywood dea0c20
chore: update dbmem.go
DanielleMaywood d0f1851
fix: dbmem.go impl
DanielleMaywood 077439c
test: refactor test slightly
DanielleMaywood 3b41985
fix: update golden files
DanielleMaywood 1a66a14
fix: dbmem.go convertToWorkspaceRowsNoLock
DanielleMaywood 9725ec7
fix: pass currentTick to GetWorkspacesEligibleForTransition
DanielleMaywood 5e9b806
revert: query change
DanielleMaywood b2a037b
fix: ensure times are converted back to UTC
DanielleMaywood 997c902
Merge branch 'main' into dm-experiment-autostart
DanielleMaywood dd05558
test: next start at is only a valid value
DanielleMaywood 8bddfdf
fix: appease linter
DanielleMaywood 66a01a3
chore: add an index for next_start_at
DanielleMaywood b7434c0
fix: run 'make gen'
DanielleMaywood 100f54c
chore: begin impl of tests
DanielleMaywood d201025
Merge branch 'main' into dm-experiment-autostart
DanielleMaywood eac63b7
test: fix tests
DanielleMaywood 1b31cbb
fix: use american english
DanielleMaywood eaf32ee
fix: make NextAllowedAutostart look up to 7 days into the future
DanielleMaywood 1599b2a
fix: TestExecutorAutostartBlocked test
DanielleMaywood 142e335
fix: make enterprise template schedule store use quartz.clock
DanielleMaywood 3f17e46
fix: infinite loop
DanielleMaywood e993643
refactor: give template schedule store a quartz.clock
DanielleMaywood d349c56
fix: ensure tests give template schedule store a clock
DanielleMaywood a48fb99
fix: nullify next_start_at on schedule update
DanielleMaywood cc93075
fix: tests
DanielleMaywood 45350d1
chore: remove clock from test
DanielleMaywood c1648ae
Merge branch 'main' into dm-experiment-autostart
DanielleMaywood 03d0b7f
chore: relocate test
DanielleMaywood 23b2ec9
chore: nits
DanielleMaywood 18f3c8a
Merge branch 'main' into dm-experiment-autostart
DanielleMaywood 8b1b6d9
chore: bump migration number
DanielleMaywood 2d239a6
fix: stop query returning dormant workspaces
DanielleMaywood 2e2f13a
Merge branch 'main' into dm-experiment-autostart
DanielleMaywood df74e6f
Merge branch 'main' into dm-experiment-autostart
DanielleMaywood dec3d6c
chore: add index to template_id on workspaces
DanielleMaywood File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test: next start at is only a valid value
- Loading branch information
commit dd05558179e6d1cb3ed6195f21c945fbd65300d0
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package schedule_test | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/coder/coder/v2/coderd/schedule" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestNextAllowedAutostart(t *testing.T) { | ||
t.Parallel() | ||
|
||
t.Run("WhenScheduleOutOfSync", func(t *testing.T) { | ||
// 1st January 2024 is a Monday | ||
at := time.Date(2024, time.January, 1, 10, 0, 0, 0, time.UTC) | ||
// Monday-Friday 9:00AM UTC | ||
sched := "CRON_TZ=UTC 00 09 * * 1-5" | ||
// Only allow an autostart on mondays | ||
opts := schedule.TemplateScheduleOptions{ | ||
AutostartRequirement: schedule.TemplateAutostartRequirement{ | ||
DaysOfWeek: 0b00000001, | ||
}, | ||
} | ||
|
||
// NextAutostart wil, return a non-allowed autostart time as | ||
// our AutostartRequirement only allows Mondays but we expect | ||
// this to return a Tuesday. | ||
next, allowed := schedule.NextAutostart(at, sched, opts) | ||
require.False(t, allowed) | ||
require.Equal(t, time.Date(2024, time.January, 2, 9, 0, 0, 0, time.UTC), next) | ||
|
||
// NextAllowedAutostart should return the next allowed autostart time. | ||
next, err := schedule.NextAllowedAutostart(at, sched, opts) | ||
require.NoError(t, err) | ||
require.Equal(t, time.Date(2024, time.January, 8, 9, 0, 0, 0, time.UTC), next) | ||
}) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We have a new known case, reset by db trigger. Should we implement the trigger in memory db as well? (I know it's probably going away soon, but still, might cause flakes?)
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.
I don't think it'd cause flakes, but instead cause dbmem tests to fail when postgres tests do not. Happy to add it though
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.
On second thought, I've checked
dbmem.go
for how we emulate triggers and I'm not sure there is a good way to do it.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.
There is no good way to do it, just ad hoc code in various functions 😢
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.
Ah that's unfortunate.
I think attempting to emulate this trigger isn't worth it then. If someone writes a test that is dependent on the trigger (which they ideally shouldn't) then they'll have to disable it when running under
dbmem.go
.