@@ -299,4 +299,59 @@ public void testUnscheduleAll() throws Exception {
299
299
// And that the future is cancelled
300
300
Assert .assertTrue (future .isCancelled ());
301
301
}
302
+
303
+ @ Test
304
+ public void testDayRangeAndHashmarkSyntax () throws Exception {
305
+ assertEquals (_ingestionScheduler .nextIngestionSourceExecutionCache .size (), 1 );
306
+
307
+ // Create two ingestion sources with different cron syntax methods
308
+ // need to affirm both '0 0 1-7 * 0' and the equivalent '0 0 0 * 0#2' work
309
+ final Urn dayRangeUrn = Urn .createFromString ("urn:li:dataHubIngestionSourceUrn:day-range" );
310
+ final DataHubIngestionSourceInfo dayRangeInfo = new DataHubIngestionSourceInfo ();
311
+ dayRangeInfo .setSchedule (
312
+ new DataHubIngestionSourceSchedule ().setInterval ("0 0 1-7 * 0" ).setTimezone ("UTC" ));
313
+ dayRangeInfo .setType ("mysql" );
314
+ dayRangeInfo .setName ("Day Range Syntax Test Source" );
315
+ dayRangeInfo .setConfig (
316
+ new DataHubIngestionSourceConfig ()
317
+ .setExecutorId ("default" )
318
+ .setRecipe ("{ type: \" type\" }" )
319
+ .setVersion ("0.8.18" ));
320
+
321
+ final Urn hashmarkUrn = Urn .createFromString ("urn:li:dataHubIngestionSourceUrn:hashmark" );
322
+ final DataHubIngestionSourceInfo hashmarkInfo = new DataHubIngestionSourceInfo ();
323
+ hashmarkInfo .setSchedule (
324
+ new DataHubIngestionSourceSchedule ().setInterval ("0 0 * * 0#1" ).setTimezone ("UTC" ));
325
+ hashmarkInfo .setType ("mysql" );
326
+ hashmarkInfo .setName ("Hashmark Syntax Test Source" );
327
+ hashmarkInfo .setConfig (
328
+ new DataHubIngestionSourceConfig ()
329
+ .setExecutorId ("default" )
330
+ .setRecipe ("{ type: \" type\" }" )
331
+ .setVersion ("0.8.18" ));
332
+
333
+ // Schedule both sources
334
+ _ingestionScheduler .scheduleNextIngestionSourceExecution (dayRangeUrn , dayRangeInfo );
335
+ _ingestionScheduler .scheduleNextIngestionSourceExecution (hashmarkUrn , hashmarkInfo );
336
+
337
+ // Verify both were scheduled successfully
338
+ assertEquals (_ingestionScheduler .nextIngestionSourceExecutionCache .size (), 3 );
339
+ assertTrue (_ingestionScheduler .nextIngestionSourceExecutionCache .containsKey (dayRangeUrn ));
340
+ assertTrue (_ingestionScheduler .nextIngestionSourceExecutionCache .containsKey (hashmarkUrn ));
341
+
342
+ // Get both scheduled futures
343
+ ScheduledFuture <?> dayRangeFuture =
344
+ _ingestionScheduler .nextIngestionSourceExecutionCache .get (dayRangeUrn );
345
+ ScheduledFuture <?> hashmarkFuture =
346
+ _ingestionScheduler .nextIngestionSourceExecutionCache .get (hashmarkUrn );
347
+
348
+ // Both should be valid futures
349
+ assertFalse (dayRangeFuture .isCancelled ());
350
+ assertFalse (hashmarkFuture .isCancelled ());
351
+
352
+ // Clean up
353
+ _ingestionScheduler .unscheduleNextIngestionSourceExecution (dayRangeUrn );
354
+ _ingestionScheduler .unscheduleNextIngestionSourceExecution (hashmarkUrn );
355
+ assertEquals (_ingestionScheduler .nextIngestionSourceExecutionCache .size (), 1 );
356
+ }
302
357
}
0 commit comments