MCPcopy Create free account
hub / github.com/coder/coder / TestReconcilerLifecycle

Function TestReconcilerLifecycle

enterprise/coderd/prebuilds/reconcile_test.go:1796–1838  ·  view source on GitHub ↗

TestReconcilerLifecycle tests that a StoreReconciler can be stopped and a new one created to simulate the prebuilds feature being disabled and re-enabled.

(t *testing.T)

Source from the content-addressed store, hash-verified

1794// TestReconcilerLifecycle tests that a StoreReconciler can be stopped and a new one
1795// created to simulate the prebuilds feature being disabled and re-enabled.
1796func TestReconcilerLifecycle(t *testing.T) {
1797 t.Parallel()
1798
1799 ctx := testutil.Context(t, testutil.WaitLong)
1800 logger := testutil.Logger(t)
1801 db, ps := dbtestutil.NewDB(t)
1802 cfg := codersdk.PrebuildsConfig{
1803 ReconciliationInterval: serpent.Duration(testutil.WaitLong),
1804 }
1805 registry := prometheus.NewRegistry()
1806 cache := files.New(prometheus.NewRegistry(), &coderdtest.FakeAuthorizer{})
1807
1808 // Given: a running reconciler (simulating the prebuilds feature being enabled)
1809 reconciler := prebuilds.NewStoreReconciler(
1810 db, ps, cache, cfg, logger,
1811 quartz.NewMock(t),
1812 registry,
1813 newNoopEnqueuer(),
1814 newNoopUsageCheckerPtr(),
1815 noop.NewTracerProvider(),
1816 10,
1817 nil,
1818 )
1819
1820 // When: the reconciler is stopped (simulating the prebuilds feature being disabled)
1821 reconciler.Stop(ctx, xerrors.New("entitlements change"))
1822
1823 // Then: a new reconciler can be created without error
1824 // (simulating the prebuilds feature being re-enabled)
1825 reconciler = prebuilds.NewStoreReconciler(
1826 db, ps, cache, cfg, logger,
1827 quartz.NewMock(t),
1828 registry,
1829 newNoopEnqueuer(),
1830 newNoopUsageCheckerPtr(),
1831 noop.NewTracerProvider(),
1832 10,
1833 nil,
1834 )
1835
1836 // Gracefully stop the reconciliation loop
1837 reconciler.Stop(ctx, nil)
1838}
1839
1840func TestFailedBuildBackoff(t *testing.T) {
1841 t.Parallel()

Callers

nothing calls this directly

Calls 10

StopMethod · 0.95
ContextFunction · 0.92
LoggerFunction · 0.92
NewDBFunction · 0.92
NewFunction · 0.92
NewStoreReconcilerFunction · 0.92
newNoopEnqueuerFunction · 0.85
newNoopUsageCheckerPtrFunction · 0.85
DurationMethod · 0.80
NewMethod · 0.65

Tested by

no test coverage detected