@@ -366,6 +366,7 @@ subtest 'retry delay configurable' => sub {
366366
367367subtest ' send status' => sub {
368368 my $ws = OpenQA::Test::FakeWebSocketTransaction-> new;
369+ $client -> worker-> current_error(' some error' );
369370 $client -> websocket_connection($ws );
370371 $client -> send_status();
371372 is_deeply($ws -> sent_messages, [{json => {fake_status => 1, reason => ' some error' }}], ' status sent' )
@@ -424,6 +425,7 @@ subtest 'command handler' => sub {
424425 my $command_handler = OpenQA::Worker::CommandHandler-> new($client );
425426 my $ws = OpenQA::Test::FakeWebSocketTransaction-> new;
426427 my $worker = $client -> worker;
428+ $worker -> current_error(' some error' );
427429 $client -> websocket_connection($ws );
428430
429431 # test at least some of the error cases
@@ -437,13 +439,13 @@ qr/Ignoring WS message from http:\/\/test-host with type livelog_stop and job ID
437439 my %job = (id => 42, settings => {});
438440 combined_like { $command_handler -> handle_command(undef , {type => WORKER_COMMAND_GRAB_JOB, job => \%job }) }
439441 qr / Refusing to grab job.*: some error/ , ' ignoring grab_job while in error-state' ;
440-
442+ is $worker -> current_job, undef , ' no job has been accepted while in error-state ' ;
441443 my %job_info = (sequence => [$job {id }], data => {42 => \%job });
442444 combined_like {
443445 $command_handler -> handle_command(undef , {type => WORKER_COMMAND_GRAB_JOBS, job_info => \%job_info })
444446 }
445447 qr / Refusing to grab job.*: some error/ , ' ignoring grab_jobs while in error-state' ;
446- is( $worker -> current_job, undef , ' no job has been accepted while in error-state' ) ;
448+ is $worker -> current_job, undef , ' no jobs have been accepted while in error-state' ;
447449
448450 $worker -> current_error(undef );
449451 $worker -> is_stopping(1);
@@ -497,11 +499,12 @@ qr/Ignoring WS message from http:\/\/test-host with type livelog_stop and job ID
497499 $worker -> current_job_ids([]);
498500 $worker -> is_busy(0);
499501 my $rejection = sub { {json => {job_ids => shift , reason => shift , type => ' rejected' }} };
502+ my %fake_error_status = (json => {fake_status => 1, reason => ' some error' });
500503 is_deeply(
501504 $ws -> sent_messages,
502505 [
503- $rejection -> ([42], ' some error' ),
504- $rejection -> ([42], ' some error' ),
506+ \ %fake_error_status , $rejection -> ([42], ' some error' ), # status + rejection due to error state
507+ \ %fake_error_status , $rejection -> ([42], ' some error' ), # status + rejection due to error state
505508 $rejection -> ([' but no settings' ], ' the provided job is invalid' ),
506509 $rejection -> ([' 42' ], ' job info lacks execution sequence' ),
507510 $rejection -> ([' 42' ], ' already busy with a job from foo' ),
@@ -512,8 +515,8 @@ qr/Ignoring WS message from http:\/\/test-host with type livelog_stop and job ID
512515
513516 # test accepting a job
514517 is($worker -> current_job, undef , ' no job accepted so far' );
515- $command_handler -> handle_command( undef ,
516- { type => WORKER_COMMAND_GRAB_JOB, job => { id => 25, settings => { FOO => ' bar ' }}} );
518+ my %cmd = ( type => WORKER_COMMAND_GRAB_JOB, job => { id => 25, settings => { FOO => ' bar ' }});
519+ $command_handler -> handle_command( undef , \ %cmd );
517520 my $accepted_job = $worker -> current_job;
518521 is_deeply($accepted_job -> info, {id => 25, settings => {FOO => ' bar' }}, ' job accepted' );
519522
@@ -587,8 +590,10 @@ qr/Ignoring WS message from http:\/\/test-host with type livelog_stop and job ID
587590 is_deeply $worker -> skipped_jobs, [[43, ' quit' ]], ' pending job is going to be skipped' ;
588591
589592 # reacting to info message
593+ $worker -> current_error(' yet another error' );
594+ $client -> send_status;
590595 ok !$client -> {_send_status_timer }, ' sending status update not scheduled yet' ;
591- combined_like { $command_handler -> handle_command(undef , {type => ' info' , seen => 1}) } qr /some error/ ,
596+ combined_like { $command_handler -> handle_command(undef , {type => ' info' , seen => 1}) } qr /yet another error/ ,
592597 ' status update logged' ;
593598 ok $client -> {_send_status_timer }, ' sending status update with delay after receiving "seen" message' ;
594599};
0 commit comments