(t *testing.T)
| 1654 | } |
| 1655 | |
| 1656 | func TestRunLoop(t *testing.T) { |
| 1657 | t.Parallel() |
| 1658 | |
| 1659 | prebuildLatestTransition := database.WorkspaceTransitionStart |
| 1660 | prebuildJobStatus := database.ProvisionerJobStatusRunning |
| 1661 | templateDeleted := false |
| 1662 | |
| 1663 | clock := quartz.NewMock(t) |
| 1664 | ctx := testutil.Context(t, testutil.WaitShort) |
| 1665 | backoffInterval := time.Minute |
| 1666 | cfg := codersdk.PrebuildsConfig{ |
| 1667 | // Given: explicitly defined backoff configuration to validate timings. |
| 1668 | ReconciliationBackoffLookback: serpent.Duration(muchEarlier * -10), // Has to be positive. |
| 1669 | ReconciliationBackoffInterval: serpent.Duration(backoffInterval), |
| 1670 | ReconciliationInterval: serpent.Duration(time.Second), |
| 1671 | } |
| 1672 | // Do not ignore errors as we want a graceful stop |
| 1673 | logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: false}).Leveled(slog.LevelDebug) |
| 1674 | db, pubSub := dbtestutil.NewDB(t) |
| 1675 | cache := files.New(prometheus.NewRegistry(), &coderdtest.FakeAuthorizer{}) |
| 1676 | reconciler := prebuilds.NewStoreReconciler( |
| 1677 | db, pubSub, cache, cfg, logger, |
| 1678 | clock, |
| 1679 | prometheus.NewRegistry(), |
| 1680 | newNoopEnqueuer(), |
| 1681 | newNoopUsageCheckerPtr(), |
| 1682 | noop.NewTracerProvider(), |
| 1683 | 10, |
| 1684 | nil, |
| 1685 | ) |
| 1686 | |
| 1687 | ownerID := uuid.New() |
| 1688 | dbgen.User(t, db, database.User{ |
| 1689 | ID: ownerID, |
| 1690 | }) |
| 1691 | org, template := setupTestDBTemplate(t, db, ownerID, templateDeleted) |
| 1692 | templateVersionID := setupTestDBTemplateVersion( |
| 1693 | ctx, |
| 1694 | t, |
| 1695 | clock, |
| 1696 | db, |
| 1697 | pubSub, |
| 1698 | org.ID, |
| 1699 | ownerID, |
| 1700 | template.ID, |
| 1701 | ) |
| 1702 | preset := setupTestDBPreset( |
| 1703 | t, |
| 1704 | db, |
| 1705 | templateVersionID, |
| 1706 | 4, |
| 1707 | uuid.New().String(), |
| 1708 | ) |
| 1709 | preset2 := setupTestDBPreset( |
| 1710 | t, |
| 1711 | db, |
| 1712 | templateVersionID, |
| 1713 | 10, |
nothing calls this directly
no test coverage detected