@@ -265,9 +265,11 @@ async fn enqueue_next_job(conn: &mut dyn database::pool::Connection) -> anyhow::
265
265
266
266
if let Some ( request) = queue. into_iter ( ) . next ( ) {
267
267
if request. status != BenchmarkRequestStatus :: InProgress {
268
- // TODO: actually enqueue the jobs
269
- conn. update_benchmark_request_status ( & request, BenchmarkRequestStatus :: InProgress )
270
- . await ?;
268
+ // TODO:
269
+ // - Uncomment
270
+ // - Actually enqueue the jobs
271
+ // conn.update_benchmark_request_status(&request, BenchmarkRequestStatus::InProgress)
272
+ // .await?;
271
273
}
272
274
}
273
275
@@ -387,16 +389,6 @@ mod tests {
387
389
}
388
390
}
389
391
390
- /// Get an `InProgress` item out of the `benchmark_requests` table. In
391
- /// practice this is the job that has been enqueued.
392
- async fn get_in_progress ( conn : & dyn database:: pool:: Connection ) -> Option < BenchmarkRequest > {
393
- conn. get_benchmark_requests_by_status ( & [ BenchmarkRequestStatus :: InProgress ] )
394
- . await
395
- . unwrap ( )
396
- . first ( )
397
- . cloned ( )
398
- }
399
-
400
392
fn queue_order_matches ( queue : & [ BenchmarkRequest ] , expected : & [ & str ] ) {
401
393
let queue_shas: Vec < & str > = queue. iter ( ) . map ( |req| req. tag ( ) ) . collect ( ) ;
402
394
assert_eq ! ( queue_shas, expected)
@@ -413,206 +405,6 @@ mod tests {
413
405
}
414
406
}
415
407
416
- /// Nothing to do, empty table
417
- #[ tokio:: test]
418
- async fn enqueue_next_job_no_jobs ( ) {
419
- run_postgres_test ( |ctx| async {
420
- let mut db = ctx. db_client ( ) . connection ( ) . await ;
421
-
422
- enqueue_next_job ( & mut * db) . await ?;
423
-
424
- let in_progress = get_in_progress ( & * db) . await ;
425
-
426
- assert ! ( in_progress. is_none( ) ) ;
427
- Ok ( ctx)
428
- } )
429
- . await ;
430
- }
431
-
432
- /// Parent completed -> child is picked
433
- #[ tokio:: test]
434
- async fn get_next_benchmark_request_completed_parent ( ) {
435
- run_postgres_test ( |ctx| async {
436
- let mut db = ctx. db_client ( ) . connection ( ) . await ;
437
- let parent =
438
- create_master ( "a" , "x" , 1 , "days5" ) . with_status ( BenchmarkRequestStatus :: Completed ) ;
439
- let child = create_master ( "b" , "a" , 1 , "days5" ) ;
440
-
441
- db_insert_requests ( & * db, & [ parent, child] ) . await ;
442
-
443
- enqueue_next_job ( & mut * db) . await ?;
444
-
445
- let in_progress = get_in_progress ( & * db) . await ;
446
-
447
- assert_eq ! ( in_progress. unwrap( ) . tag( ) , "b" ) ;
448
- Ok ( ctx)
449
- } )
450
- . await ;
451
- }
452
-
453
- /// Release (no parent) is always eligible
454
- #[ tokio:: test]
455
- async fn get_next_benchmark_request_no_parent_release ( ) {
456
- run_postgres_test ( |ctx| async {
457
- let mut db = ctx. db_client ( ) . connection ( ) . await ;
458
- let release = create_release ( "v1.2.3" , "days2" ) ;
459
-
460
- db_insert_requests ( & * db, & [ release] ) . await ;
461
-
462
- enqueue_next_job ( & mut * db) . await ?;
463
-
464
- let in_progress = get_in_progress ( & * db) . await ;
465
-
466
- assert_eq ! ( in_progress. unwrap( ) . tag( ) , "v1.2.3" ) ;
467
- Ok ( ctx)
468
- } )
469
- . await ;
470
- }
471
-
472
- /// Parent exists but is older -> parent gets picked
473
- #[ tokio:: test]
474
- async fn get_next_benchmark_request_oldest_first ( ) {
475
- run_postgres_test ( |ctx| async {
476
- let mut db = ctx. db_client ( ) . connection ( ) . await ;
477
- let c1 = create_master ( "x" , "x" , 1 , "days521" )
478
- . with_status ( BenchmarkRequestStatus :: Completed ) ;
479
- let c2 = create_master ( "y" , "y" , 2 , "days521" )
480
- . with_status ( BenchmarkRequestStatus :: Completed ) ;
481
-
482
- let m1 = create_master ( "old" , "x" , 3 , "days45" ) ;
483
- let m2 = create_master ( "new" , "y" , 4 , "days1" ) ;
484
-
485
- db_insert_requests ( & * db, & [ c1, c2, m1, m2] ) . await ;
486
- enqueue_next_job ( & mut * db) . await ?;
487
-
488
- let in_progress = get_in_progress ( & * db) . await ;
489
-
490
- assert_eq ! ( in_progress. unwrap( ) . tag( ) , "old" ) ;
491
- Ok ( ctx)
492
- } )
493
- . await ;
494
- }
495
-
496
- /// Parent SHA missing entirely -> child is ready
497
- #[ cfg( unix) ] // test will not panic on windows and would be skipped entirely
498
- #[ tokio:: test]
499
- #[ should_panic( expected = "No commit is ready for benchmarking" ) ]
500
- async fn get_next_benchmark_request_missing_parent ( ) {
501
- run_postgres_test ( |ctx| async {
502
- let mut db = ctx. db_client ( ) . connection ( ) . await ;
503
- let orphan = create_master ( "orphan" , "gone" , 42 , "days1" ) ;
504
-
505
- db_insert_requests ( & * db, & [ orphan] ) . await ;
506
- enqueue_next_job ( & mut * db) . await ?;
507
-
508
- let in_progress = get_in_progress ( & * db) . await ;
509
- assert_eq ! ( in_progress. unwrap( ) . tag( ) , "orphan" ) ;
510
-
511
- Ok ( ctx)
512
- } )
513
- . await ;
514
- }
515
-
516
- #[ tokio:: test]
517
- async fn get_next_benchmark_request_large_mixture ( ) {
518
- run_postgres_test ( |ctx| async {
519
- let mut db = ctx. db_client ( ) . connection ( ) . await ;
520
- // Fresh parents that will unblock some children
521
- let parent_master = create_master ( "parent_m" , "x" , 911 , "days5" )
522
- . with_status ( BenchmarkRequestStatus :: Completed ) ;
523
- let parent_try = create_try ( "parent_t" , "x" , 888 , "days4" )
524
- . with_status ( BenchmarkRequestStatus :: Completed ) ;
525
- let parent_master_two = create_master ( "gp" , "x" , 922 , "days5" )
526
- . with_status ( BenchmarkRequestStatus :: Completed ) ;
527
- let parent_master_three = create_master ( "blocked_p" , "x" , 932 , "days5" )
528
- . with_status ( BenchmarkRequestStatus :: Completed ) ;
529
-
530
- // Two releases, the older one should win overall
531
- let rel_old = create_release ( "v0.8.0" , "days40" ) ; // 40days old
532
- let rel_new = create_release ( "v1.0.0" , "days10" ) ;
533
-
534
- // Ready masters (parents completed)
535
- let master_low_pr = create_master ( "m_low" , "parent_m" , 1 , "days12" ) ;
536
- let master_high_pr = create_master ( "m_high" , "parent_m" , 7 , "days8" ) ;
537
-
538
- let blocked_parent = create_master ( "blocked_p" , "gp" , 0 , "days3" ) ;
539
- let master_blocked = create_master ( "blocked_c" , "blocked_p" , 0 , "days1" ) ;
540
-
541
- // A try commit that is ready
542
- let try_ready = create_try ( "t_ready" , "parent_t" , 42 , "days2" ) ;
543
-
544
- let requests = vec ! [
545
- parent_master,
546
- parent_master_two,
547
- parent_master_three,
548
- parent_try,
549
- master_high_pr,
550
- master_low_pr,
551
- master_blocked,
552
- blocked_parent,
553
- try_ready,
554
- rel_old,
555
- rel_new,
556
- ] ;
557
-
558
- db_insert_requests ( & * db, & requests) . await ;
559
- enqueue_next_job ( & mut * db) . await ?;
560
-
561
- // The oldest release ("v0.8.0") outranks everything else
562
- let in_progress = get_in_progress ( & * db) . await ;
563
- assert_eq ! ( in_progress. unwrap( ) . tag( ) , "v0.8.0" ) ;
564
- Ok ( ctx)
565
- } )
566
- . await ;
567
- }
568
-
569
- #[ tokio:: test]
570
- async fn get_next_benchmark_request_large_mixture_no_release ( ) {
571
- run_postgres_test ( |ctx| async {
572
- let mut db = ctx. db_client ( ) . connection ( ) . await ;
573
- // Fresh parents that will unblock some children
574
- let parent_master = create_master ( "parent_m" , "x" , 8 , "days5" )
575
- . with_status ( BenchmarkRequestStatus :: Completed ) ;
576
- let parent_try = create_try ( "parent_t" , "x" , 9 , "days4" )
577
- . with_status ( BenchmarkRequestStatus :: Completed ) ;
578
- let parent_master_two = create_master ( "gp" , "x" , 10 , "days5" )
579
- . with_status ( BenchmarkRequestStatus :: Completed ) ;
580
- let parent_master_three = create_master ( "blocked_p" , "x" , 11 , "days5" )
581
- . with_status ( BenchmarkRequestStatus :: Completed ) ;
582
-
583
- // Ready masters (parents completed)
584
- let m1 = create_master ( "m_low" , "parent_m" , 3 , "days12" ) ;
585
- let m2 = create_master ( "m_high" , "parent_m" , 7 , "days8" ) ;
586
-
587
- let m3 = create_master ( "B" , "gp" , 1 , "days3" ) ;
588
- let m4 = create_master ( "C" , "blocked_p" , 2 , "days1" ) ;
589
-
590
- // A try commit that is ready
591
- let t1 = create_try ( "t_ready" , "parent_t" , 42 , "days2" ) ;
592
-
593
- let requests = vec ! [
594
- parent_master,
595
- parent_master_two,
596
- parent_master_three,
597
- parent_try,
598
- m2,
599
- m1,
600
- m4,
601
- m3,
602
- t1,
603
- ] ;
604
-
605
- db_insert_requests ( & * db, & requests) . await ;
606
- enqueue_next_job ( & mut * db) . await ?;
607
-
608
- // The oldest release ("v0.8.0") outranks everything else
609
- let in_progress = get_in_progress ( & * db) . await ;
610
- assert_eq ! ( in_progress. unwrap( ) . tag( ) , "B" ) ;
611
- Ok ( ctx)
612
- } )
613
- . await ;
614
- }
615
-
616
408
#[ tokio:: test]
617
409
async fn queue_ordering ( ) {
618
410
run_postgres_test ( |ctx| async {
0 commit comments