@@ -23,7 +23,7 @@ vi.mock("~/services/clickhouse/clickhouseFactoryInstance.server", () => ({
2323import { ClickHouse } from "@internal/clickhouse" ;
2424import { RunEngine } from "@internal/run-engine" ;
2525import { setupAuthenticatedEnvironment , setupBackgroundWorker } from "@internal/run-engine/tests" ;
26- import { containerTest } from "@internal/testcontainers" ;
26+ import { containerTestWithClickhouse } from "@internal/testcontainers" ;
2727import { trace } from "@opentelemetry/api" ;
2828import { generateFriendlyId } from "@trigger.dev/core/v3/isomorphic" ;
2929import type { PrismaClient } from "@trigger.dev/database" ;
@@ -112,7 +112,7 @@ async function triggerOnQueue(
112112}
113113
114114describe ( "QueueListPresenter archived filter" , ( ) => {
115- containerTest (
115+ containerTestWithClickhouse (
116116 "exclude hides archived queues across list, search and counts; include keeps them" ,
117117 async ( { prisma, redisOptions } ) => {
118118 const engine = buildEngine ( prisma , redisOptions ) ;
@@ -159,7 +159,7 @@ describe("QueueListPresenter archived filter", () => {
159159 }
160160 ) ;
161161
162- containerTest (
162+ containerTestWithClickhouse (
163163 "returns archived queues with queued runs as active, and skips idle archived queues" ,
164164 async ( { prisma, redisOptions } ) => {
165165 const engine = buildEngine ( prisma , redisOptions ) ;
@@ -209,7 +209,7 @@ describe("QueueListPresenter archived filter", () => {
209209} ) ;
210210
211211describe ( "public queue shape" , ( ) => {
212- containerTest (
212+ containerTestWithClickhouse (
213213 "the public API item never exposes archive state" ,
214214 async ( { prisma, redisOptions } ) => {
215215 const engine = buildEngine ( prisma , redisOptions ) ;
@@ -229,32 +229,35 @@ describe("public queue shape", () => {
229229} ) ;
230230
231231describe ( "QueueAllocationPresenter" , ( ) => {
232- containerTest ( "excludes archived queues from the allocated sum" , async ( { prisma } ) => {
233- const environment = await setupAuthenticatedEnvironment ( prisma , "PRODUCTION" ) ;
234- await createQueue ( prisma , environment , "emails" , { concurrencyLimit : 20 } ) ;
235- await createQueue ( prisma , environment , "images" , { concurrencyLimit : 30 } ) ;
236- await createQueue ( prisma , environment , "old" , {
237- concurrencyLimit : 25 ,
238- archivedAt : new Date ( ) ,
239- } ) ;
240-
241- const allocation = await new QueueAllocationPresenter ( prisma , prisma ) . call ( {
242- environment : { ...environment , maximumConcurrencyLimit : 100 } ,
243- } ) ;
244-
245- expect ( allocation ) . toEqual ( { totalQueues : 2 , allocated : 50 , unlimitedCount : 0 } ) ;
246-
247- // With archiving disabled for the org, the tile counts every queue, like the list.
248- const unfiltered = await new QueueAllocationPresenter ( prisma , prisma ) . call ( {
249- environment : { ...environment , maximumConcurrencyLimit : 100 } ,
250- excludeArchived : false ,
251- } ) ;
252- expect ( unfiltered ) . toEqual ( { totalQueues : 3 , allocated : 75 , unlimitedCount : 0 } ) ;
253- } ) ;
232+ containerTestWithClickhouse (
233+ "excludes archived queues from the allocated sum" ,
234+ async ( { prisma } ) => {
235+ const environment = await setupAuthenticatedEnvironment ( prisma , "PRODUCTION" ) ;
236+ await createQueue ( prisma , environment , "emails" , { concurrencyLimit : 20 } ) ;
237+ await createQueue ( prisma , environment , "images" , { concurrencyLimit : 30 } ) ;
238+ await createQueue ( prisma , environment , "old" , {
239+ concurrencyLimit : 25 ,
240+ archivedAt : new Date ( ) ,
241+ } ) ;
242+
243+ const allocation = await new QueueAllocationPresenter ( prisma , prisma ) . call ( {
244+ environment : { ...environment , maximumConcurrencyLimit : 100 } ,
245+ } ) ;
246+
247+ expect ( allocation ) . toEqual ( { totalQueues : 2 , allocated : 50 , unlimitedCount : 0 } ) ;
248+
249+ // With archiving disabled for the org, the tile counts every queue, like the list.
250+ const unfiltered = await new QueueAllocationPresenter ( prisma , prisma ) . call ( {
251+ environment : { ...environment , maximumConcurrencyLimit : 100 } ,
252+ excludeArchived : false ,
253+ } ) ;
254+ expect ( unfiltered ) . toEqual ( { totalQueues : 3 , allocated : 75 , unlimitedCount : 0 } ) ;
255+ }
256+ ) ;
254257} ) ;
255258
256259describe ( "ArchiveQueueService" , ( ) => {
257- containerTest (
260+ containerTestWithClickhouse (
258261 "archives an idle queue without touching limits, overrides, paused state or worker links" ,
259262 async ( { prisma, redisOptions } ) => {
260263 const engine = buildEngine ( prisma , redisOptions ) ;
@@ -296,28 +299,31 @@ describe("ArchiveQueueService", () => {
296299 }
297300 ) ;
298301
299- containerTest ( "refuses to archive a queue with queued runs" , async ( { prisma, redisOptions } ) => {
300- const engine = buildEngine ( prisma , redisOptions ) ;
301- onTestFinished ( ( ) => engine . quit ( ) ) ;
302- const environment = await setupAuthenticatedEnvironment ( prisma , "PRODUCTION" ) ;
303- await setupBackgroundWorker ( engine , environment , "busy-task" ) ;
304- await deployWithout ( engine , environment ) ;
305- const queue = await prisma . taskQueue . findFirstOrThrow ( {
306- where : { runtimeEnvironmentId : environment . id , name : "task/busy-task" } ,
307- } ) ;
308- await triggerOnQueue ( engine , prisma , environment , "busy-task" , queue . name ) ;
309-
310- const result = await new ArchiveQueueService ( prisma , engine ) . archive (
311- environment ,
312- queue . friendlyId
313- ) ;
314- expect ( result . isErr ( ) && result . error . type ) . toBe ( "queue_has_active_runs" ) ;
302+ containerTestWithClickhouse (
303+ "refuses to archive a queue with queued runs" ,
304+ async ( { prisma, redisOptions } ) => {
305+ const engine = buildEngine ( prisma , redisOptions ) ;
306+ onTestFinished ( ( ) => engine . quit ( ) ) ;
307+ const environment = await setupAuthenticatedEnvironment ( prisma , "PRODUCTION" ) ;
308+ await setupBackgroundWorker ( engine , environment , "busy-task" ) ;
309+ await deployWithout ( engine , environment ) ;
310+ const queue = await prisma . taskQueue . findFirstOrThrow ( {
311+ where : { runtimeEnvironmentId : environment . id , name : "task/busy-task" } ,
312+ } ) ;
313+ await triggerOnQueue ( engine , prisma , environment , "busy-task" , queue . name ) ;
315314
316- const after = await prisma . taskQueue . findFirstOrThrow ( { where : { id : queue . id } } ) ;
317- expect ( after . archivedAt ) . toBeNull ( ) ;
318- } ) ;
315+ const result = await new ArchiveQueueService ( prisma , engine ) . archive (
316+ environment ,
317+ queue . friendlyId
318+ ) ;
319+ expect ( result . isErr ( ) && result . error . type ) . toBe ( "queue_has_active_runs" ) ;
320+
321+ const after = await prisma . taskQueue . findFirstOrThrow ( { where : { id : queue . id } } ) ;
322+ expect ( after . archivedAt ) . toBeNull ( ) ;
323+ }
324+ ) ;
319325
320- containerTest (
326+ containerTestWithClickhouse (
321327 "counts runs handed to a worker queue but not yet picked up as active" ,
322328 async ( { prisma, redisOptions } ) => {
323329 const engine = buildEngine ( prisma , redisOptions ) ;
@@ -364,7 +370,7 @@ describe("ArchiveQueueService", () => {
364370 }
365371 ) ;
366372
367- containerTest (
373+ containerTestWithClickhouse (
368374 "refuses to archive paused queues, limit-0 or combined-limit-0 queues and named concurrency limits" ,
369375 async ( { prisma, redisOptions } ) => {
370376 const engine = buildEngine ( prisma , redisOptions ) ;
@@ -404,7 +410,7 @@ describe("ArchiveQueueService", () => {
404410 }
405411 ) ;
406412
407- containerTest (
413+ containerTestWithClickhouse (
408414 "check reports the reason and run count without archiving" ,
409415 async ( { prisma, redisOptions } ) => {
410416 const engine = buildEngine ( prisma , redisOptions ) ;
@@ -430,7 +436,7 @@ describe("ArchiveQueueService", () => {
430436 }
431437 ) ;
432438
433- containerTest (
439+ containerTestWithClickhouse (
434440 "refuses to archive a queue the current or an unpromoted deploy declares" ,
435441 async ( { prisma, redisOptions } ) => {
436442 const engine = buildEngine ( prisma , redisOptions ) ;
@@ -470,7 +476,7 @@ describe("ArchiveQueueService", () => {
470476 }
471477 ) ;
472478
473- containerTest (
479+ containerTestWithClickhouse (
474480 "a deploy created in the same millisecond as the current one still blocks archiving" ,
475481 async ( { prisma, redisOptions } ) => {
476482 const engine = buildEngine ( prisma , redisOptions ) ;
@@ -506,7 +512,7 @@ describe("ArchiveQueueService", () => {
506512 }
507513 ) ;
508514
509- containerTest (
515+ containerTestWithClickhouse (
510516 "a queue update landing between the check and the write aborts the archive" ,
511517 async ( { prisma, redisOptions } ) => {
512518 const engine = buildEngine ( prisma , redisOptions ) ;
@@ -538,7 +544,7 @@ describe("ArchiveQueueService", () => {
538544 }
539545 ) ;
540546
541- containerTest (
547+ containerTestWithClickhouse (
542548 "unarchive brings the queue back to the default list" ,
543549 async ( { prisma, redisOptions } ) => {
544550 const engine = buildEngine ( prisma , redisOptions ) ;
@@ -565,7 +571,7 @@ describe("ArchiveQueueService", () => {
565571} ) ;
566572
567573describe ( "QueueListPresenter ranked sort" , ( ) => {
568- containerTest (
574+ containerTestWithClickhouse (
569575 "a busy archived queue doesn't take a slot or push queues off the last page" ,
570576 async ( { prisma, redisOptions, clickhouseContainer } ) => {
571577 const engine = buildEngine ( prisma , redisOptions ) ;
0 commit comments