-
Notifications
You must be signed in to change notification settings - Fork 901
feat: update workspace deadline when workspace ttl updated #2165
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
johnstcn
merged 20 commits into
main
from
cj/1783/updating-workspace-ttl-updates-deadline
Jun 9, 2022
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
5c443de
RED: update unit test with new desired behaviour
johnstcn c2127c1
cli: warn user upon ttl-triggered workspace shutdown
johnstcn 07320a4
GREEN: do the thing
johnstcn 7846dd8
REFACTOR: coderd: putWorkspaceTTL: wrap in tx
johnstcn 6d7187d
update unit tests
johnstcn daa9a5f
feat: WorkspaceScheduleForm: show shutdown time when editing workspac…
johnstcn fe79c0c
make it prettier
johnstcn 85da57b
hopefully fix unit tests
johnstcn 8c38a74
Merge remote-tracking branch 'origin/main' into cj/1783/updating-work…
johnstcn a4c07df
Address PR comments
johnstcn 582873a
Merge origin/main
greyscaled 9a7c623
chore: WorkspaceScheduleForm: add unit tests
johnstcn 0278a93
WorkspaceScheduleForm: refactor ttlShutdownAt
johnstcn a372dce
apply suggestions from code review
johnstcn ac1d29a
fixup! apply suggestions from code review
johnstcn 23b474c
yarn lint; more pr comments
johnstcn de28477
bump ci
johnstcn a52d815
Merge remote-tracking branch 'origin/main' into cj/1783/updating-work…
johnstcn fd86474
mind your language
johnstcn 2b9f93c
fumpt
johnstcn 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
GREEN: do the thing
- Loading branch information
commit 07320a42a94185c9bc539c73e1fe61514c7f7e33
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
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 |
---|---|---|
|
@@ -521,19 +521,16 @@ func TestWorkspaceUpdateAutostart(t *testing.T) { | |
name: "invalid location", | ||
schedule: ptr.Ref("CRON_TZ=Imaginary/Place 30 9 * * 1-5"), | ||
expectedError: "parse schedule: provided bad location Imaginary/Place: unknown time zone Imaginary/Place", | ||
// expectedError: "status code 500: Invalid autostart schedule\n\tError: parse schedule: provided bad location Imaginary/Place: unknown time zone Imaginary/Place", | ||
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. Nit: Are these leftover debug? 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. Yep, left over from some previous PR where they snuck in! |
||
}, | ||
{ | ||
name: "invalid schedule", | ||
schedule: ptr.Ref("asdf asdf asdf "), | ||
expectedError: `validate weekly schedule: expected schedule to consist of 5 fields with an optional CRON_TZ=<timezone> prefix`, | ||
// expectedError: "status code 500: Invalid autostart schedule\n\tError: validate weekly schedule: expected schedule to consist of 5 fields with an optional CRON_TZ=<timezone> prefix", | ||
}, | ||
{ | ||
name: "only 3 values", | ||
schedule: ptr.Ref("CRON_TZ=Europe/Dublin 30 9 *"), | ||
expectedError: `validate weekly schedule: expected schedule to consist of 5 fields with an optional CRON_TZ=<timezone> prefix`, | ||
// expectedError: "status code 500: Invalid autostart schedule\n\tError: validate weekly schedule: expected schedule to consist of 5 fields with an optional CRON_TZ=<timezone> prefix", | ||
}, | ||
} | ||
|
||
|
@@ -611,16 +608,23 @@ func TestWorkspaceUpdateTTL(t *testing.T) { | |
t.Parallel() | ||
|
||
testCases := []struct { | ||
name string | ||
ttlMillis *int64 | ||
expectedError string | ||
modifyTemplate func(*codersdk.CreateTemplateRequest) | ||
name string | ||
ttlMillis *int64 | ||
expectedError string | ||
expectedDeadline time.Time | ||
modifyTemplate func(*codersdk.CreateTemplateRequest) | ||
}{ | ||
{ | ||
name: "disable ttl", | ||
ttlMillis: nil, | ||
expectedError: "", | ||
}, | ||
{ | ||
name: "update ttl", | ||
ttlMillis: ptr.Ref(12 * time.Hour.Milliseconds()), | ||
expectedError: "", | ||
expectedDeadline: time.Now().Add(12 * time.Hour), | ||
}, | ||
{ | ||
name: "below minimum ttl", | ||
ttlMillis: ptr.Ref((30 * time.Second).Milliseconds()), | ||
|
@@ -686,6 +690,9 @@ func TestWorkspaceUpdateTTL(t *testing.T) { | |
require.NoError(t, err, "fetch updated workspace") | ||
|
||
require.Equal(t, testCase.ttlMillis, updated.TTLMillis, "expected autostop ttl to equal requested") | ||
if !testCase.expectedDeadline.IsZero() { | ||
require.WithinDuration(t, testCase.expectedDeadline, updated.LatestBuild.Deadline, time.Minute, "expected autostop deadline to be equal expected") | ||
} | ||
}) | ||
} | ||
|
||
|
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.
Uh oh!
There was an error while loading. Please reload this page.