Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9ddad0b

Browse files
committed
fix: only break pubsub after dbgen setup
Signed-off-by: Danny Kopping <dannykopping@gmail.com>
1 parent42cc3f5 commit9ddad0b

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

‎coderd/database/dbgen/dbgen.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,8 +643,8 @@ func ProvisionerJob(t testing.TB, db database.Store, ps pubsub.Pubsub, orig data
643643
})
644644
require.NoError(t,err,"insert job")
645645
ifps!=nil {
646-
// Advisory, but not essential since acquirer has a background poller to pick up missed jobs.
647-
_=provisionerjobs.PostJob(ps,job)
646+
err=provisionerjobs.PostJob(ps,job)
647+
require.NoError(t,err,"postjob to pubsub")
648648
}
649649
if!orig.StartedAt.Time.IsZero() {
650650
job,err=db.AcquireProvisionerJob(genCtx, database.AcquireProvisionerJobParams{

‎enterprise/coderd/prebuilds/reconcile_test.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,6 @@ func TestPrebuildReconciliation(t *testing.T) {
322322
t,&slogtest.Options{IgnoreErrors:true},
323323
).Leveled(slog.LevelDebug)
324324
db,pubSub:=dbtestutil.NewDB(t)
325-
ifuseBrokenPubsub {
326-
pubSub=&brokenPublisher{Pubsub:pubSub}
327-
}
328-
329-
controller:=prebuilds.NewStoreReconciler(db,pubSub,cfg,logger,quartz.NewMock(t),prometheus.NewRegistry())
330325

331326
ownerID:=uuid.New()
332327
dbgen.User(t,db, database.User{
@@ -369,6 +364,11 @@ func TestPrebuildReconciliation(t *testing.T) {
369364
setupTestDBTemplateVersion(ctx,t,clock,db,pubSub,org.ID,ownerID,template.ID)
370365
}
371366

367+
ifuseBrokenPubsub {
368+
pubSub=&brokenPublisher{Pubsub:pubSub}
369+
}
370+
controller:=prebuilds.NewStoreReconciler(db,pubSub,cfg,logger,quartz.NewMock(t),prometheus.NewRegistry())
371+
372372
// Run the reconciliation multiple times to ensure idempotency
373373
// 8 was arbitrary, but large enough to reasonably trust the result
374374
fori:=1;i<=8;i++ {
@@ -417,10 +417,13 @@ type brokenPublisher struct {
417417
pubsub.Pubsub
418418
}
419419

420+
// Publish deliberately fails.
421+
// I'm explicitly _not_ checking for EventJobPosted (coderd/database/provisionerjobs/provisionerjobs.go) since that
422+
// requires too much knowledge of the underlying implementation.
420423
func (*brokenPublisher)Publish(eventstring,_ []byte)error {
421-
//I'm explicitly _not_ checking for EventJobPosted (coderd/database/provisionerjobs/provisionerjobs.go) since that
422-
// requires too much knowledge of the underlying implementation.
423-
returnxerrors.Errorf("refusing to publish %q",event)
424+
//Mimick some work being done.
425+
<-time.After(testutil.IntervalFast)
426+
returnxerrors.Errorf("failed to publish %q",event)
424427
}
425428

426429
funcTestMultiplePresetsPerTemplateVersion(t*testing.T) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp