- Notifications
You must be signed in to change notification settings - Fork928
fix: reduce cost of prebuild failure#17697
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes from1 commit
Commits
Show all changes
51 commits Select commitHold shift + click to select a range
fcb3e5d
fix: limit prebuild failure cost
evgeniy-scherbina701e2a8
refactor: CR's fixes
evgeniy-scherbina0fdd096
refactor: CR's fixes
evgeniy-scherbina13c0e28
refactor: CR's fixes
evgeniy-scherbina29e9cff
refactor: CR's fixes
evgeniy-scherbina1d51dfc
Merge remote-tracking branch 'origin/main' into 17432-limit-prebuild-…
evgeniy-scherbina5c60065
feat: add notification for prebuilds failure
evgeniy-scherbinab0248c3
test: fix tests
evgeniy-scherbina08b18b0
test: add a notification test
evgeniy-scherbina0fd347a
fix: add prebuild_status migration
evgeniy-scherbina08981a4
generate.sh
evgeniy-scherbina0e4600c
fix: using prebuild status
evgeniy-scherbina107879b
fix: migrations numbers
evgeniy-scherbina2dea5ab
make gen
evgeniy-scherbinae252093
make gen/golden-files
evgeniy-scherbina906ceb9
fix: fix dbauthz
evgeniy-scherbina3a0284f
Merge remote-tracking branch 'origin/main' into 17432-limit-prebuild-…
evgeniy-scherbina13fb1af
fix: minor fix
evgeniy-scherbina108ea0a
test: fix tests
evgeniy-scherbina7cd2799
test: fix dbmem
evgeniy-scherbinaf9148e2
make gen/golden-files
evgeniy-scherbina315acfa
Remove outdated TODOs
evgeniy-scherbina1679ac9
fix: enhance notification template
evgeniy-scherbinad9c9d17
Merge remote-tracking branch 'origin/main' into 17432-limit-prebuild-…
evgeniy-scherbinac47ddaa
make gen/golden-files
evgeniy-scherbinac19f28a
refactor: minor improvements
evgeniy-scherbinab18730f
fix: minor fix in template
evgeniy-scherbina37173b0
fix: minor improvement to template
evgeniy-scherbina0e3cc40
fix: minor fixes
evgeniy-scherbina784adba
fix: fix TODO
evgeniy-scherbina50bd9b4
refactor: CR's fixes
evgeniy-scherbina8a33ac8
refactor: CR's fixes
evgeniy-scherbina9439fa1
refactor: use not null for prebuild_status
evgeniy-scherbinae667dad
refactor: fix dbauthz test
evgeniy-scherbina8a51702
refactor: use healthy enum option instead of normal
evgeniy-scherbinaa793e18
refactor: minor refactoring in tests
evgeniy-scherbinaa0fb69c
refactor: rename DB method
evgeniy-scherbinac6f209c
refactor: make fmt
evgeniy-scherbina9dccf3e
refactor: make gen + reorder methods
evgeniy-scherbinac19ae04
refactor: make fmt
evgeniy-scherbina4b145cc
refactor: CR's fixes
evgeniy-scherbina80f3677
refactor: make gen
evgeniy-scherbina2144d13
refactor: CR's fixes
evgeniy-scherbina79725b3
refactor: CR's fixes
evgeniy-scherbina7e8b4b6
refactor: improve comments for test
evgeniy-scherbinaab5acfb
refactor: CR's fixes
evgeniy-scherbina7c09465
refactor: CR's fixes
evgeniy-scherbinab7a34c5
refactor: improve notification template
evgeniy-scherbinae1e141d
refactor: CR's fixes
evgeniy-scherbina354aeb4
refactor: CR's fixes
evgeniy-scherbina7564178
Merge remote-tracking branch 'origin/main' into 17432-limit-prebuild-…
evgeniy-scherbinaFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
test: add a notification test
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commit08b18b09c5535a77f04cb5b70db48b8f03db829d
There are no files selected for viewing
31 changes: 26 additions & 5 deletionsenterprise/coderd/prebuilds/reconcile_test.go
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 |
---|---|---|
@@ -689,7 +689,13 @@ func TestSkippingHardLimitedPresets(t *testing.T) { | ||
t, &slogtest.Options{IgnoreErrors: true}, | ||
).Leveled(slog.LevelDebug) | ||
db, pubSub := dbtestutil.NewDB(t) | ||
fakeEnqueuer := newFakeEnqueuer() | ||
controller := prebuilds.NewStoreReconciler(db, pubSub, cfg, logger, clock, prometheus.NewRegistry(), fakeEnqueuer) | ||
// Template admin to receive a notification. | ||
templateAdmin := dbgen.User(t, db, database.User{ | ||
RBACRoles: []string{codersdk.RoleTemplateAdmin}, | ||
}) | ||
// Set up test environment with a template, version, and preset | ||
ownerID := uuid.New() | ||
@@ -731,13 +737,28 @@ func TestSkippingHardLimitedPresets(t *testing.T) { | ||
workspaces, err = db.GetWorkspacesByTemplateID(ctx, template.ID) | ||
require.NoError(t, err) | ||
if !tc.isHardLimitHit { | ||
dannykopping marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
// When hard limit is not reached, a new workspace should be created | ||
require.Equal(t, 2, len(workspaces)) | ||
return | ||
} | ||
// When hard limit is reached, no new workspace should be created | ||
require.Equal(t, 1, len(workspaces)) | ||
// When hard limit is reached, a notification should be sent. | ||
matching := fakeEnqueuer.Sent(func(notification *notificationstest.FakeNotification) bool { | ||
if !assert.Equal(t, notification.TemplateID, notifications.PrebuildFailureLimitReached, "unexpected template") { | ||
return false | ||
} | ||
if !assert.Equal(t, templateAdmin.ID, notification.UserID, "unexpected receiver") { | ||
return false | ||
} | ||
return true | ||
}) | ||
require.Len(t, matching, 1) | ||
dannykopping marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
}) | ||
} | ||
} | ||
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
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.