@@ -433,7 +433,6 @@ mod tests {
433433 use std:: collections:: BTreeSet ;
434434 use std:: str:: FromStr ;
435435
436- /// Create a Commit
437436 fn create_commit ( commit_sha : & str , time : chrono:: DateTime < Utc > , r#type : CommitType ) -> Commit {
438437 Commit {
439438 sha : commit_sha. into ( ) ,
@@ -442,43 +441,6 @@ mod tests {
442441 }
443442 }
444443
445- async fn complete_request (
446- db : & dyn Connection ,
447- request_tag : & str ,
448- collector_name : & str ,
449- benchmark_set : u32 ,
450- target : Target ,
451- ) {
452- /* Create job for the request */
453- db. enqueue_benchmark_job (
454- request_tag,
455- target,
456- CodegenBackend :: Llvm ,
457- Profile :: Opt ,
458- benchmark_set,
459- )
460- . await
461- . unwrap ( ) ;
462-
463- let ( job, _) = db
464- . dequeue_benchmark_job ( collector_name, target, BenchmarkSet ( benchmark_set) )
465- . await
466- . unwrap ( )
467- . unwrap ( ) ;
468-
469- assert_eq ! ( job. request_tag( ) , request_tag) ;
470-
471- /* Mark the job as complete */
472- db. mark_benchmark_job_as_completed ( job. id ( ) , BenchmarkJobConclusion :: Success )
473- . await
474- . unwrap ( ) ;
475-
476- assert ! ( db
477- . maybe_mark_benchmark_request_as_completed( request_tag)
478- . await
479- . unwrap( ) ) ;
480- }
481-
482444 #[ tokio:: test]
483445 async fn pstat_returns_empty_vector_when_empty ( ) {
484446 run_db_test ( |ctx| async {
@@ -564,37 +526,25 @@ mod tests {
564526 async fn multiple_non_completed_try_requests ( ) {
565527 run_postgres_test ( |ctx| async {
566528 let db = ctx. db ( ) ;
567- let target = Target :: X86_64UnknownLinuxGnu ;
568- let collector_name = "collector-1" ;
569- let benchmark_set = 1 ;
570-
571- db. add_collector_config ( collector_name, target, benchmark_set, true )
572- . await
573- . unwrap ( ) ;
574529
575- // Complete parent
576- let parent = BenchmarkRequest :: create_release ( "sha-parent-1" , Utc :: now ( ) ) ;
577- // Complete
578- let req_a = BenchmarkRequest :: create_try_without_artifacts ( 42 , "" , "" ) ;
579- // WaitingForArtifacts
580- let req_b = BenchmarkRequest :: create_try_without_artifacts ( 42 , "" , "" ) ;
581- let req_c = BenchmarkRequest :: create_try_without_artifacts ( 42 , "" , "" ) ;
582-
583- db. insert_benchmark_request ( & parent) . await . unwrap ( ) ;
584- db. insert_benchmark_request ( & req_a) . await . unwrap ( ) ;
585- db. attach_shas_to_try_benchmark_request ( 42 , "sha1" , "sha-parent-1" , Utc :: now ( ) )
530+ // Insert a try build
531+ ctx. insert_try_request ( 42 ) . await ;
532+ db. attach_shas_to_try_benchmark_request ( 42 , "sha-1" , "sha-parent-1" , Utc :: now ( ) )
586533 . await
587534 . unwrap ( ) ;
588535
589- complete_request ( db , "sha-parent-1" , collector_name , benchmark_set , target ) . await ;
590- complete_request ( db , "sha1" , collector_name , benchmark_set , target ) . await ;
536+ // Then finish it
537+ ctx . complete_request ( "sha-1" ) . await ;
591538
592- // This should be fine, req_a was completed
593- db. insert_benchmark_request ( & req_b) . await . unwrap ( ) ;
594- // This should fail, we can't have two queued requests at once
595- db. insert_benchmark_request ( & req_c) . await . expect_err (
596- "It was possible to record two try benchmark requests without artifacts" ,
597- ) ;
539+ // Insert a try build for the same PR again
540+ // This should be fine, because the previous request was already completed
541+ ctx. insert_try_request ( 42 ) . await ;
542+ // But this should fail, as we can't have two queued requests at once
543+ db. insert_benchmark_request ( & BenchmarkRequest :: create_try_without_artifacts (
544+ 42 , "" , "" ,
545+ ) )
546+ . await
547+ . expect_err ( "It was possible to record two try benchmark requests without artifacts" ) ;
598548
599549 Ok ( ctx)
600550 } )
0 commit comments