@@ -182,7 +182,16 @@ fn sort_benchmark_requests(done: &HashSet<String>, request_queue: &mut [Benchmar
182182 )
183183 } ) ;
184184 for c in level {
185- done. insert ( c. tag ( ) . to_string ( ) ) ;
185+ // As the only `commit_type` that will not have a `tag` is a `Try`
186+ // with the status of `AwaitingArtifacts` and we have asserted above
187+ // that all of the statuses of the benchmark requests are
188+ // `ArtifactsReady` it is implausable for this `expect(...)` to be
189+ // hit.
190+ done. insert (
191+ c. tag ( )
192+ . expect ( "Tag should exist on a benchmark request being sorted" )
193+ . to_string ( ) ,
194+ ) ;
186195 }
187196 finished += level_len;
188197 }
@@ -241,7 +250,7 @@ pub async fn build_queue(
241250
242251 release_artifacts. sort_unstable_by ( |a, b| {
243252 a. tag ( )
244- . cmp ( b. tag ( ) )
253+ . cmp ( & b. tag ( ) )
245254 . then_with ( || a. created_at . cmp ( & b. created_at ) )
246255 } ) ;
247256
@@ -258,7 +267,7 @@ async fn enqueue_next_job(conn: &mut dyn database::pool::Connection) -> anyhow::
258267 . get_benchmark_requests_by_status ( & [ BenchmarkRequestStatus :: Completed ] )
259268 . await ?
260269 . into_iter ( )
261- . map ( |request| request. tag ( ) . to_string ( ) )
270+ . filter_map ( |request| request. tag ( ) . map ( |tag| tag . to_string ( ) ) )
262271 . collect ( ) ;
263272
264273 let queue = build_queue ( conn, & completed) . await ?;
@@ -360,7 +369,7 @@ mod tests {
360369
361370 fn create_try ( sha : & str , parent : & str , pr : u32 , age_days : & str ) -> BenchmarkRequest {
362371 BenchmarkRequest :: create_try (
363- sha,
372+ Some ( sha) ,
364373 Some ( parent) ,
365374 pr,
366375 days_ago ( age_days) ,
@@ -390,7 +399,10 @@ mod tests {
390399 }
391400
392401 fn queue_order_matches ( queue : & [ BenchmarkRequest ] , expected : & [ & str ] ) {
393- let queue_shas: Vec < & str > = queue. iter ( ) . map ( |req| req. tag ( ) ) . collect ( ) ;
402+ let queue_shas: Vec < & str > = queue
403+ . iter ( )
404+ . filter_map ( |request| request. tag ( ) . map ( |tag| tag) )
405+ . collect ( ) ;
394406 assert_eq ! ( queue_shas, expected)
395407 }
396408
@@ -423,23 +435,23 @@ mod tests {
423435 * +------------+
424436 * | r "v1.2.3" |
425437 * +------------+
438+ *
439+ *
440+ *
426441 * 1: Currently `in_progress`
427- * +---------------+
428- * +--->| t "t1" IP pr1 |
429- * | +---------------+
430- * +-----------+ |
431- * | m "rrr" C | -----+-->
432- * +-----------+ |
433- * | +---------------+
434- * +--->| t "yee" R pr1 | 3: a try with a low pr
435- * +---------------+
442+ * +-----------+ +---------------+
443+ * | m "rrr" C | -----+--->| t "t1" IP pr1 |
444+ * +-----------+ +---------------+
445+ *
446+ *
447+ *
436448 * +-----------+
437449 * | m "aaa" C |
438450 * +-----------+
439451 * |
440452 * V
441453 * +----------------+
442- * | m "mmm" R pr88 | 6 : a master commit
454+ * | m "mmm" R pr88 | 5 : a master commit
443455 * +----------------+
444456 *
445457 * +-----------+
@@ -448,7 +460,7 @@ mod tests {
448460 * |
449461 * V
450462 * +----------------+
451- * | m "123" R pr11 | 4 : a master commit, high pr number
463+ * | m "123" R pr11 | 3 : a master commit, high pr number
452464 * +----------------+
453465 *
454466 *
@@ -458,12 +470,12 @@ mod tests {
458470 * |
459471 * V
460472 * +----------------+
461- * | m "foo" R pr77 | 5 : a master commit
473+ * | m "foo" R pr77 | 4 : a master commit
462474 * +----------------+
463475 * |
464476 * V
465477 * +---------------+
466- * | t "baz" R pr4 | 7 : a try with a low pr, blocked by parent
478+ * | t "baz" R pr4 | 6 : a try with a low pr, blocked by parent
467479 * +---------------+
468480 *
469481 * The master commits should take priority, then "yee" followed
@@ -476,7 +488,6 @@ mod tests {
476488 create_master( "123" , "345" , 11 , "days2" ) ,
477489 create_try( "baz" , "foo" , 4 , "days1" ) ,
478490 create_release( "v.1.2.3" , "days2" ) ,
479- create_try( "yee" , "rrr" , 1 , "days2" ) , // lower PR number takes priority
480491 create_try( "t1" , "rrr" , 1 , "days1" ) . with_status( BenchmarkRequestStatus :: InProgress ) ,
481492 create_master( "mmm" , "aaa" , 88 , "days2" ) ,
482493 ] ;
@@ -492,10 +503,7 @@ mod tests {
492503
493504 let sorted: Vec < BenchmarkRequest > = build_queue ( & mut * db, & completed) . await . unwrap ( ) ;
494505
495- queue_order_matches (
496- & sorted,
497- & [ "t1" , "v.1.2.3" , "yee" , "123" , "foo" , "mmm" , "baz" ] ,
498- ) ;
506+ queue_order_matches ( & sorted, & [ "t1" , "v.1.2.3" , "123" , "foo" , "mmm" , "baz" ] ) ;
499507 Ok ( ctx)
500508 } )
501509 . await ;
0 commit comments