@@ -10,7 +10,7 @@ import { TestReplicationClickhouseFactory } from "./utils/testReplicationClickho
1010
1111vi . setConfig ( { testTimeout : 60_000 } ) ;
1212
13- describe ( "RunsReplicationService (part 5/6 )" , ( ) => {
13+ describe ( "RunsReplicationService (part 5/7 )" , ( ) => {
1414 replicationContainerTest (
1515 "should replicate all events in a single transaction (insert, update)" ,
1616 async ( { clickhouseContainer, redisOptions, postgresContainer, prisma } ) => {
@@ -145,111 +145,4 @@ describe("RunsReplicationService (part 5/6)", () => {
145145 }
146146 ) ;
147147
148- replicationContainerTest (
149- "should be able to handle processing transactions for a long period of time" ,
150- { timeout : 60_000 * 5 } ,
151- async ( { clickhouseContainer, redisOptions, postgresContainer, prisma } ) => {
152- await prisma . $executeRawUnsafe ( `ALTER TABLE public."TaskRun" REPLICA IDENTITY FULL;` ) ;
153-
154- const clickhouse = new ClickHouse ( {
155- url : clickhouseContainer . getConnectionUrl ( ) ,
156- name : "runs-replication-long-tx" ,
157- logLevel : "warn" ,
158- } ) ;
159-
160- const runsReplicationService = new RunsReplicationService ( {
161- clickhouseFactory : new TestReplicationClickhouseFactory ( clickhouse ) ,
162- pgConnectionUrl : postgresContainer . getConnectionUri ( ) ,
163- serviceName : "runs-replication-long-tx" ,
164- slotName : "task_runs_to_clickhouse_v1" ,
165- publicationName : "task_runs_to_clickhouse_v1_publication" ,
166- redisOptions,
167- maxFlushConcurrency : 1 ,
168- flushIntervalMs : 100 ,
169- flushBatchSize : 10 ,
170- leaderLockTimeoutMs : 5000 ,
171- leaderLockExtendIntervalMs : 1000 ,
172- ackIntervalSeconds : 5 ,
173- logLevel : "warn" ,
174- } ) ;
175-
176- await runsReplicationService . start ( ) ;
177-
178- const organization = await prisma . organization . create ( {
179- data : {
180- title : "test-long-tx" ,
181- slug : "test-long-tx" ,
182- } ,
183- } ) ;
184-
185- const project = await prisma . project . create ( {
186- data : {
187- name : "test-long-tx" ,
188- slug : "test-long-tx" ,
189- organizationId : organization . id ,
190- externalRef : "test-long-tx" ,
191- } ,
192- } ) ;
193-
194- const runtimeEnvironment = await prisma . runtimeEnvironment . create ( {
195- data : {
196- slug : "test-long-tx" ,
197- type : "DEVELOPMENT" ,
198- projectId : project . id ,
199- organizationId : organization . id ,
200- apiKey : "test-long-tx" ,
201- pkApiKey : "test-long-tx" ,
202- shortcode : "test-long-tx" ,
203- } ,
204- } ) ;
205-
206- // Start an interval that will create a new run every 500ms for 4 minutes
207- const interval = setInterval ( async ( ) => {
208- await prisma . taskRun . create ( {
209- data : {
210- friendlyId : `run_long_tx_${ Date . now ( ) } ` ,
211- taskIdentifier : "my-task-long-tx" ,
212- payload : JSON . stringify ( { long : 1 } ) ,
213- payloadType : "application/json" ,
214- traceId : `long-${ Date . now ( ) } ` ,
215- spanId : `long-${ Date . now ( ) } ` ,
216- queue : "test-long-tx" ,
217- runtimeEnvironmentId : runtimeEnvironment . id ,
218- projectId : project . id ,
219- organizationId : organization . id ,
220- environmentType : "DEVELOPMENT" ,
221- engine : "V2" ,
222- status : "PENDING" ,
223- attemptNumber : 1 ,
224- createdAt : new Date ( ) ,
225- updatedAt : new Date ( ) ,
226- } ,
227- } ) ;
228- } , 500 ) ;
229-
230- // Wait for 1 minute
231- await setTimeout ( 1 * 60 * 1000 ) ;
232-
233- // Stop the interval
234- clearInterval ( interval ) ;
235-
236- // Wait for replication
237- await setTimeout ( 1000 ) ;
238-
239- // Query ClickHouse for all runs using FINAL
240- const queryRuns = clickhouse . reader . query ( {
241- name : "runs-replication-long-tx" ,
242- query : `SELECT * FROM trigger_dev.task_runs_v2 FINAL` ,
243- schema : z . any ( ) ,
244- } ) ;
245-
246- const [ queryError , result ] = await queryRuns ( { } ) ;
247- expect ( queryError ) . toBeNull ( ) ;
248-
249- expect ( result ?. length ) . toBeGreaterThanOrEqual ( 50 ) ;
250-
251- await runsReplicationService . stop ( ) ;
252- }
253- ) ;
254-
255148} ) ;
0 commit comments