@@ -27,6 +27,7 @@ use daphne::{
2727 BatchId , BatchSelector , PartialBatchSelector , TaskId ,
2828 } ,
2929 metrics:: DaphneMetrics ,
30+ protocol:: ReadyAggregationJobResp ,
3031 testing:: report_generator:: ReportGenerator ,
3132 vdaf:: VdafConfig ,
3233 DapAggregateShare , DapAggregateSpan , DapAggregationParam , DapBatchMode , DapMeasurement ,
@@ -511,7 +512,7 @@ impl Test {
511512 let _guard = load_control. wait ( ) . await ;
512513 info ! ( "Starting AggregationJobInitReq" ) ;
513514 let start = Instant :: now ( ) ;
514- let agg_job_resp = self
515+ let mut agg_job_resp = self
515516 . http_client
516517 . submit_aggregation_job_init_req (
517518 self . helper_url . join ( & format ! (
@@ -528,14 +529,42 @@ impl Test {
528529 )
529530 . await ?;
530531 let duration = start. elapsed ( ) ;
531- info ! ( "Finished AggregationJobInitReq in {duration:#?}" ) ;
532+ info ! ( "Finished submitting AggregationJobInitReq in {duration:#?}" ) ;
533+ let mut poll_count = 1 ;
534+ let ready = loop {
535+ agg_job_resp = match agg_job_resp {
536+ messages:: AggregationJobResp :: Ready { prep_resps } => {
537+ if poll_count != 1 {
538+ info ! (
539+ "Finished polling for AggregationJobResp after {:#?}" ,
540+ start. elapsed( )
541+ ) ;
542+ }
543+ break ReadyAggregationJobResp { prep_resps } ;
544+ }
545+ messages:: AggregationJobResp :: Processing => {
546+ if poll_count == 1 {
547+ info ! ( "Polling for AggregationJobResp" ) ;
548+ }
549+ tokio:: time:: sleep ( Duration :: from_millis ( poll_count * 200 ) ) . await ;
550+ poll_count += 1 ;
551+ self . http_client
552+ . poll_aggregation_job_init (
553+ self . helper_url
554+ . join ( & format ! ( "tasks/{task_id}/aggregation_jobs/{agg_job_id}" ) ) ?,
555+ task_config. version ,
556+ functions:: helper:: Options {
557+ taskprov_advertisement : taskprov_advertisement. as_ref ( ) ,
558+ bearer_token : self . bearer_token . as_ref ( ) ,
559+ } ,
560+ )
561+ . await ?
562+ }
563+ } ;
564+ } ;
532565
533- let agg_share_span = task_config. consume_agg_job_resp (
534- task_id,
535- agg_job_state,
536- agg_job_resp. unwrap_ready ( ) , // TODO: implement polling
537- self . metrics ( ) ,
538- ) ?;
566+ let agg_share_span =
567+ task_config. consume_agg_job_resp ( task_id, agg_job_state, ready, self . metrics ( ) ) ?;
539568
540569 let aggregated_report_count = agg_share_span
541570 . iter ( )
0 commit comments