@@ -252,10 +252,7 @@ pub async fn build_queue(
252
252
}
253
253
254
254
/// Enqueue the job into the job_queue
255
- async fn enqueue_next_job (
256
- conn : & mut dyn database:: pool:: Connection ,
257
- should_add_to_db : bool ,
258
- ) -> anyhow:: Result < ( ) > {
255
+ async fn enqueue_next_job ( conn : & mut dyn database:: pool:: Connection ) -> anyhow:: Result < ( ) > {
259
256
// We draw back all completed requests
260
257
let completed: HashSet < String > = conn
261
258
. get_benchmark_requests_by_status ( & [ BenchmarkRequestStatus :: Completed ] )
@@ -269,31 +266,24 @@ async fn enqueue_next_job(
269
266
if let Some ( request) = queue. into_iter ( ) . next ( ) {
270
267
if request. status != BenchmarkRequestStatus :: InProgress {
271
268
// TODO:
272
- // - Remove this if condition
269
+ // - Uncomment
273
270
// - Actually enqueue the jobs
274
- if !should_add_to_db {
275
- log:: info!( "{:?} would have been marked as InProgress" , request) ;
276
- } else {
277
- conn. update_benchmark_request_status ( & request, BenchmarkRequestStatus :: InProgress )
278
- . await ?;
279
- }
271
+ // conn.update_benchmark_request_status(&request, BenchmarkRequestStatus::InProgress)
272
+ // .await?;
280
273
}
281
274
}
282
275
283
276
Ok ( ( ) )
284
277
}
285
278
286
279
/// For queueing jobs, add the jobs you want to queue to this function
287
- async fn cron_enqueue_jobs (
288
- site_ctxt : & Arc < SiteCtxt > ,
289
- should_add_to_db : bool ,
290
- ) -> anyhow:: Result < ( ) > {
280
+ async fn cron_enqueue_jobs ( site_ctxt : & Arc < SiteCtxt > ) -> anyhow:: Result < ( ) > {
291
281
let mut conn = site_ctxt. conn ( ) . await ;
292
282
// Put the master commits into the `benchmark_requests` queue
293
283
create_benchmark_request_master_commits ( site_ctxt, & * conn) . await ?;
294
284
// Put the releases into the `benchmark_requests` queue
295
285
create_benchmark_request_releases ( & * conn) . await ?;
296
- enqueue_next_job ( & mut * conn, should_add_to_db ) . await ?;
286
+ enqueue_next_job ( & mut * conn) . await ?;
297
287
Ok ( ( ) )
298
288
}
299
289
@@ -309,7 +299,7 @@ pub async fn cron_main(site_ctxt: Arc<RwLock<Option<Arc<SiteCtxt>>>>, seconds: u
309
299
let guard = ctxt. read ( ) ;
310
300
guard. as_ref ( ) . cloned ( )
311
301
} {
312
- match cron_enqueue_jobs ( & ctxt_clone, false ) . await {
302
+ match cron_enqueue_jobs ( & ctxt_clone) . await {
313
303
Ok ( _) => log:: info!( "Cron job executed at: {:?}" , std:: time:: SystemTime :: now( ) ) ,
314
304
Err ( e) => log:: error!( "Cron job failed to execute {}" , e) ,
315
305
}
@@ -399,16 +389,6 @@ mod tests {
399
389
}
400
390
}
401
391
402
- /// Get an `InProgress` item out of the `benchmark_requests` table. In
403
- /// practice this is the job that has been enqueued.
404
- async fn get_in_progress ( conn : & dyn database:: pool:: Connection ) -> Option < BenchmarkRequest > {
405
- conn. get_benchmark_requests_by_status ( & [ BenchmarkRequestStatus :: InProgress ] )
406
- . await
407
- . unwrap ( )
408
- . first ( )
409
- . cloned ( )
410
- }
411
-
412
392
fn queue_order_matches ( queue : & [ BenchmarkRequest ] , expected : & [ & str ] ) {
413
393
let queue_shas: Vec < & str > = queue. iter ( ) . map ( |req| req. tag ( ) ) . collect ( ) ;
414
394
assert_eq ! ( queue_shas, expected)
@@ -425,206 +405,6 @@ mod tests {
425
405
}
426
406
}
427
407
428
- /// Nothing to do, empty table
429
- #[ tokio:: test]
430
- async fn enqueue_next_job_no_jobs ( ) {
431
- run_postgres_test ( |ctx| async {
432
- let mut db = ctx. db_client ( ) . connection ( ) . await ;
433
-
434
- enqueue_next_job ( & mut * db, true ) . await ?;
435
-
436
- let in_progress = get_in_progress ( & * db) . await ;
437
-
438
- assert ! ( in_progress. is_none( ) ) ;
439
- Ok ( ctx)
440
- } )
441
- . await ;
442
- }
443
-
444
- /// Parent completed -> child is picked
445
- #[ tokio:: test]
446
- async fn get_next_benchmark_request_completed_parent ( ) {
447
- run_postgres_test ( |ctx| async {
448
- let mut db = ctx. db_client ( ) . connection ( ) . await ;
449
- let parent =
450
- create_master ( "a" , "x" , 1 , "days5" ) . with_status ( BenchmarkRequestStatus :: Completed ) ;
451
- let child = create_master ( "b" , "a" , 1 , "days5" ) ;
452
-
453
- db_insert_requests ( & * db, & [ parent, child] ) . await ;
454
-
455
- enqueue_next_job ( & mut * db, true ) . await ?;
456
-
457
- let in_progress = get_in_progress ( & * db) . await ;
458
-
459
- assert_eq ! ( in_progress. unwrap( ) . tag( ) , "b" ) ;
460
- Ok ( ctx)
461
- } )
462
- . await ;
463
- }
464
-
465
- /// Release (no parent) is always eligible
466
- #[ tokio:: test]
467
- async fn get_next_benchmark_request_no_parent_release ( ) {
468
- run_postgres_test ( |ctx| async {
469
- let mut db = ctx. db_client ( ) . connection ( ) . await ;
470
- let release = create_release ( "v1.2.3" , "days2" ) ;
471
-
472
- db_insert_requests ( & * db, & [ release] ) . await ;
473
-
474
- enqueue_next_job ( & mut * db, true ) . await ?;
475
-
476
- let in_progress = get_in_progress ( & * db) . await ;
477
-
478
- assert_eq ! ( in_progress. unwrap( ) . tag( ) , "v1.2.3" ) ;
479
- Ok ( ctx)
480
- } )
481
- . await ;
482
- }
483
-
484
- /// Parent exists but is older -> parent gets picked
485
- #[ tokio:: test]
486
- async fn get_next_benchmark_request_oldest_first ( ) {
487
- run_postgres_test ( |ctx| async {
488
- let mut db = ctx. db_client ( ) . connection ( ) . await ;
489
- let c1 = create_master ( "x" , "x" , 1 , "days521" )
490
- . with_status ( BenchmarkRequestStatus :: Completed ) ;
491
- let c2 = create_master ( "y" , "y" , 2 , "days521" )
492
- . with_status ( BenchmarkRequestStatus :: Completed ) ;
493
-
494
- let m1 = create_master ( "old" , "x" , 3 , "days45" ) ;
495
- let m2 = create_master ( "new" , "y" , 4 , "days1" ) ;
496
-
497
- db_insert_requests ( & * db, & [ c1, c2, m1, m2] ) . await ;
498
- enqueue_next_job ( & mut * db, true ) . await ?;
499
-
500
- let in_progress = get_in_progress ( & * db) . await ;
501
-
502
- assert_eq ! ( in_progress. unwrap( ) . tag( ) , "old" ) ;
503
- Ok ( ctx)
504
- } )
505
- . await ;
506
- }
507
-
508
- /// Parent SHA missing entirely -> child is ready
509
- #[ cfg( unix) ] // test will not panic on windows and would be skipped entirely
510
- #[ tokio:: test]
511
- #[ should_panic( expected = "No commit is ready for benchmarking" ) ]
512
- async fn get_next_benchmark_request_missing_parent ( ) {
513
- run_postgres_test ( |ctx| async {
514
- let mut db = ctx. db_client ( ) . connection ( ) . await ;
515
- let orphan = create_master ( "orphan" , "gone" , 42 , "days1" ) ;
516
-
517
- db_insert_requests ( & * db, & [ orphan] ) . await ;
518
- enqueue_next_job ( & mut * db, true ) . await ?;
519
-
520
- let in_progress = get_in_progress ( & * db) . await ;
521
- assert_eq ! ( in_progress. unwrap( ) . tag( ) , "orphan" ) ;
522
-
523
- Ok ( ctx)
524
- } )
525
- . await ;
526
- }
527
-
528
- #[ tokio:: test]
529
- async fn get_next_benchmark_request_large_mixture ( ) {
530
- run_postgres_test ( |ctx| async {
531
- let mut db = ctx. db_client ( ) . connection ( ) . await ;
532
- // Fresh parents that will unblock some children
533
- let parent_master = create_master ( "parent_m" , "x" , 911 , "days5" )
534
- . with_status ( BenchmarkRequestStatus :: Completed ) ;
535
- let parent_try = create_try ( "parent_t" , "x" , 888 , "days4" )
536
- . with_status ( BenchmarkRequestStatus :: Completed ) ;
537
- let parent_master_two = create_master ( "gp" , "x" , 922 , "days5" )
538
- . with_status ( BenchmarkRequestStatus :: Completed ) ;
539
- let parent_master_three = create_master ( "blocked_p" , "x" , 932 , "days5" )
540
- . with_status ( BenchmarkRequestStatus :: Completed ) ;
541
-
542
- // Two releases, the older one should win overall
543
- let rel_old = create_release ( "v0.8.0" , "days40" ) ; // 40days old
544
- let rel_new = create_release ( "v1.0.0" , "days10" ) ;
545
-
546
- // Ready masters (parents completed)
547
- let master_low_pr = create_master ( "m_low" , "parent_m" , 1 , "days12" ) ;
548
- let master_high_pr = create_master ( "m_high" , "parent_m" , 7 , "days8" ) ;
549
-
550
- let blocked_parent = create_master ( "blocked_p" , "gp" , 0 , "days3" ) ;
551
- let master_blocked = create_master ( "blocked_c" , "blocked_p" , 0 , "days1" ) ;
552
-
553
- // A try commit that is ready
554
- let try_ready = create_try ( "t_ready" , "parent_t" , 42 , "days2" ) ;
555
-
556
- let requests = vec ! [
557
- parent_master,
558
- parent_master_two,
559
- parent_master_three,
560
- parent_try,
561
- master_high_pr,
562
- master_low_pr,
563
- master_blocked,
564
- blocked_parent,
565
- try_ready,
566
- rel_old,
567
- rel_new,
568
- ] ;
569
-
570
- db_insert_requests ( & * db, & requests) . await ;
571
- enqueue_next_job ( & mut * db, true ) . await ?;
572
-
573
- // The oldest release ("v0.8.0") outranks everything else
574
- let in_progress = get_in_progress ( & * db) . await ;
575
- assert_eq ! ( in_progress. unwrap( ) . tag( ) , "v0.8.0" ) ;
576
- Ok ( ctx)
577
- } )
578
- . await ;
579
- }
580
-
581
- #[ tokio:: test]
582
- async fn get_next_benchmark_request_large_mixture_no_release ( ) {
583
- run_postgres_test ( |ctx| async {
584
- let mut db = ctx. db_client ( ) . connection ( ) . await ;
585
- // Fresh parents that will unblock some children
586
- let parent_master = create_master ( "parent_m" , "x" , 8 , "days5" )
587
- . with_status ( BenchmarkRequestStatus :: Completed ) ;
588
- let parent_try = create_try ( "parent_t" , "x" , 9 , "days4" )
589
- . with_status ( BenchmarkRequestStatus :: Completed ) ;
590
- let parent_master_two = create_master ( "gp" , "x" , 10 , "days5" )
591
- . with_status ( BenchmarkRequestStatus :: Completed ) ;
592
- let parent_master_three = create_master ( "blocked_p" , "x" , 11 , "days5" )
593
- . with_status ( BenchmarkRequestStatus :: Completed ) ;
594
-
595
- // Ready masters (parents completed)
596
- let m1 = create_master ( "m_low" , "parent_m" , 3 , "days12" ) ;
597
- let m2 = create_master ( "m_high" , "parent_m" , 7 , "days8" ) ;
598
-
599
- let m3 = create_master ( "B" , "gp" , 1 , "days3" ) ;
600
- let m4 = create_master ( "C" , "blocked_p" , 2 , "days1" ) ;
601
-
602
- // A try commit that is ready
603
- let t1 = create_try ( "t_ready" , "parent_t" , 42 , "days2" ) ;
604
-
605
- let requests = vec ! [
606
- parent_master,
607
- parent_master_two,
608
- parent_master_three,
609
- parent_try,
610
- m2,
611
- m1,
612
- m4,
613
- m3,
614
- t1,
615
- ] ;
616
-
617
- db_insert_requests ( & * db, & requests) . await ;
618
- enqueue_next_job ( & mut * db, true ) . await ?;
619
-
620
- // The oldest release ("v0.8.0") outranks everything else
621
- let in_progress = get_in_progress ( & * db) . await ;
622
- assert_eq ! ( in_progress. unwrap( ) . tag( ) , "B" ) ;
623
- Ok ( ctx)
624
- } )
625
- . await ;
626
- }
627
-
628
408
#[ tokio:: test]
629
409
async fn queue_ordering ( ) {
630
410
run_postgres_test ( |ctx| async {
0 commit comments