[Bps-public-commit] smokingit-worker branch, master, updated. 70b792224fb180edf76cc9420fde52c131167b86

Alex Vandiver alexmv at bestpractical.com
Thu Oct 10 16:45:57 EDT 2013


The branch, master has been updated
       via  70b792224fb180edf76cc9420fde52c131167b86 (commit)
       via  a95563e93a2da44686a849c6e2ca01226095a016 (commit)
       via  c2080e3c3e5b2bee206abd03afacfd22d8557d72 (commit)
       via  fb61a9d7cfe9d4e1060fcd368ac5b9ae6f9e909c (commit)
      from  c50a81a0ddf6a002033a751cb2879a51d995aa62 (commit)

Summary of changes:
 lib/Smokingit/Worker.pm | 42 +++++++++++++++++++++++++++++++++++++-----
 1 file changed, 37 insertions(+), 5 deletions(-)

- Log -----------------------------------------------------------------
commit fb61a9d7cfe9d4e1060fcd368ac5b9ae6f9e909c
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Sat Aug 10 19:28:34 2013 -0400

    Only use the diag-merge feature if it exists

diff --git a/lib/Smokingit/Worker.pm b/lib/Smokingit/Worker.pm
index 7f4c64c..52d86ae 100644
--- a/lib/Smokingit/Worker.pm
+++ b/lib/Smokingit/Worker.pm
@@ -166,8 +166,8 @@ sub run_tests {
             jobs       => $jobs,
             lib        => [".", "lib"],
             switches   => "-w",
-            diag_merge => 1,
         } );
+    $harness->diag_merge(1) if $harness->can("diag_merge");
 
     $self->publish(
         smoke_id => $request->{smoke_id},

commit c2080e3c3e5b2bee206abd03afacfd22d8557d72
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu Oct 10 16:31:20 2013 -0400

    Submit results per-testfile

diff --git a/lib/Smokingit/Worker.pm b/lib/Smokingit/Worker.pm
index 52d86ae..a1c715f 100644
--- a/lib/Smokingit/Worker.pm
+++ b/lib/Smokingit/Worker.pm
@@ -185,12 +185,21 @@ sub run_tests {
                 = $parser->end_time - $parser->start_time;
             $result->{start} ||= $parser->start_time;
             $result->{end}     = $parser->end_time;
+            $self->call(
+                name => "post_file_results",
+                args => {
+                    filename => $filename,
+                    smoke_result_id => $request->{smoke_id},
+                    %{ $result->{test}{$filename} },
+                },
+            );
             $self->publish(
                 smoke_id => $request->{smoke_id},
                 status   => "testing",
                 complete => ++$done,
                 total    => scalar(@tests),
             );
+            return 1;
         }
     );
     $harness->callback(

commit a95563e93a2da44686a849c6e2ca01226095a016
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu Oct 10 16:32:55 2013 -0400

    Run tests inside Coro async{} block to return control to Anyevent
    
    While running tests, the main Anyevent loop is blocked.  This means
    that any process which involves events being received by the mainloop
    will not complete.  This affects creation of message queues used to
    submit test results, for instance, which require that
    AnyEvent::RabbitMQ::RPC read acknowledgements from the RabbitMQ server
    for each step of the queue creation.
    
    Solving this correctly would require that TAP::Harness use an
    event-based multiplexer and read loop, ensuring that blocking IO was
    never used.  This is a far more complex change than slapping an
    async{} block arount it, which allows event-based code to co-exist
    with explicit control.  However, async{} in itself is not sufficient
    to allow event-based loops to run; see the following commit for the
    remaining changes.

diff --git a/lib/Smokingit/Worker.pm b/lib/Smokingit/Worker.pm
index a1c715f..a7bf01c 100644
--- a/lib/Smokingit/Worker.pm
+++ b/lib/Smokingit/Worker.pm
@@ -5,6 +5,7 @@ package Smokingit::Worker;
 use base 'AnyEvent::RabbitMQ::RPC';
 
 use AnyMQ;
+use Coro;
 
 use TAP::Harness;
 use Storable qw( nfreeze thaw );
@@ -61,9 +62,12 @@ sub max_jobs {
 sub run {
     my $self = shift;
     chdir($self->repo_path);
-    $self->register(
+    $self->register_async(
         name => "run_tests",
-        run  => sub {$self->run_tests(@_)},
+        run  => sub {
+            my %args = @_;
+            async { $self->run_tests( %args ) };
+        },
     );
     AE::cv->recv;
 }
@@ -72,9 +76,10 @@ my %projects;
 
 sub run_tests {
     my $self = shift;
-    my $request = shift;
+    my %args = @_;
     my %ORIGINAL_ENV = %ENV;
 
+    my $request = $args{args};
     $self->publish(
         smoke_id => $request->{smoke_id},
         status   => "started",
@@ -122,6 +127,7 @@ sub run_tests {
             args => $result
         );
         $cleanup->();
+        $args{on_failure}->( $result->{error} );
     };
 
     # Check the SHA and check it out
@@ -238,7 +244,7 @@ sub run_tests {
 
     # Clean out
     $cleanup->();
-    return 1;
+    $args{on_success}->(1);
 }
 
 1;

commit 70b792224fb180edf76cc9420fde52c131167b86
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu Oct 10 16:38:59 2013 -0400

    Use Coro::AnyEvent::poll to provide hooks for events
    
    Place calls to Coro::AnyEvent::poll in locations which are called
    frequently, or which are liable to require event servicing shortly
    thereafter.  These would not be required if TAP parsing were done in
    an event-based manner.

diff --git a/lib/Smokingit/Worker.pm b/lib/Smokingit/Worker.pm
index a7bf01c..4fa4d40 100644
--- a/lib/Smokingit/Worker.pm
+++ b/lib/Smokingit/Worker.pm
@@ -6,6 +6,7 @@ use base 'AnyEvent::RabbitMQ::RPC';
 
 use AnyMQ;
 use Coro;
+use Coro::AnyEvent;
 
 use TAP::Harness;
 use Storable qw( nfreeze thaw );
@@ -45,6 +46,13 @@ sub publish {
     my (%msg) = @_;
     $msg{type} = "worker_progress";
     $self->{pubsub}->topic($msg{type})->publish(\%msg);
+    Coro::AnyEvent::poll;
+}
+
+sub call {
+    my $self = shift;
+    $self->SUPER::call(@_);
+    Coro::AnyEvent::poll;
 }
 
 sub repo_path {
@@ -216,6 +224,15 @@ sub run_tests {
             open($args->{spool}, ">", \$result->{test}{$filename}{raw_tap});
         }
     );
+    $harness->callback(
+        made_parser => sub {
+            my $parser = shift;
+            $parser->callback(
+                ALL => sub { Coro::AnyEvent::poll; }
+            );
+        }
+    );
+
     my $aggregator = eval {
         # Runtests apparently grows PERL5LIB -- local it so it doesn't
         # grow without bound

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list