[Bps-public-commit] smokingit branch, master, updated. bca0d2c1f69ed2495ce7a9086d7075f5d5760ab5

Alex Vandiver alexmv at bestpractical.com
Thu Oct 10 16:46:07 EDT 2013


The branch, master has been updated
       via  bca0d2c1f69ed2495ce7a9086d7075f5d5760ab5 (commit)
      from  ccbe037b854946a394573d462bf2d7f2328f3e35 (commit)

Summary of changes:
 bin/local_updates                  | 13 +++++++
 lib/Smokingit/Model/SmokeResult.pm | 73 +++++++++++++++++++++++++-------------
 2 files changed, 61 insertions(+), 25 deletions(-)

- Log -----------------------------------------------------------------
commit bca0d2c1f69ed2495ce7a9086d7075f5d5760ab5
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Thu Oct 10 16:25:44 2013 -0400

    Push results one file at a time

diff --git a/bin/local_updates b/bin/local_updates
index c40add2..2bbf72d 100755
--- a/bin/local_updates
+++ b/bin/local_updates
@@ -37,9 +37,22 @@ Jifty->rpc->register(
 
 # Background task, from worker
 Jifty->rpc->register(
+    name => "post_file_results",
+    run  => sub {
+        my $data = shift;
+        return unless keys %{$data};
+        my $smoke = Smokingit::Model::SmokeResult->new(
+            current_user => Smokingit::CurrentUser->superuser,
+        );
+        my ($ok, $msg) = $smoke->post_file_result($data);
+        return $ok;
+    },
+);
+Jifty->rpc->register(
     name => "post_results",
     run  => sub {
         my $data = shift;
+        return unless keys %{$data};
         my $smoke = Smokingit::Model::SmokeResult->new(
             current_user => Smokingit::CurrentUser->superuser,
         );
diff --git a/lib/Smokingit/Model/SmokeResult.pm b/lib/Smokingit/Model/SmokeResult.pm
index 0e072cb..20fe776 100644
--- a/lib/Smokingit/Model/SmokeResult.pm
+++ b/lib/Smokingit/Model/SmokeResult.pm
@@ -95,6 +95,15 @@ sub run_smoke {
               $self->commit->short_sha
           )."\n";
 
+    # Delete all previous test file results
+    my $testfiles = Smokingit::Model::SmokeFileResultCollection->new(
+        current_user => Smokingit::CurrentUser->superuser,
+    );
+    $testfiles->limit( column => "smoke_result_id", value => $self->id );
+    while (my $fileresult = $testfiles->next) {
+        $fileresult->delete;
+    }
+
     my $status = Smokingit::Status->new( $self );
     Jifty->rpc->call(
         name => "run_tests",
@@ -144,8 +153,6 @@ sub post_result {
     delete $result{start};
     delete $result{end};
 
-    my %tests = %{ delete $result{test} };
-
     my $status = Smokingit::Status->new( $self );
 
     # Find the smoke
@@ -172,29 +179,6 @@ sub post_result {
     # Mark as no longer smoking
     $self->set_queue_status(undef);
 
-    # Delete all previous test file results
-    my $testfiles = Smokingit::Model::SmokeFileResultCollection->new(
-        current_user => Smokingit::CurrentUser->superuser,
-    );
-    $testfiles->limit( column => "smoke_result_id", value => $self->id );
-    while (my $fileresult = $testfiles->next) {
-        $fileresult->delete;
-    }
-
-    # Create rows for all test files
-    for my $filename (sort keys %tests) {
-        my $fileresult = Smokingit::Model::SmokeFileResult->new(
-            current_user => Smokingit::CurrentUser->superuser,
-        );
-        my ($ok, $msg) = $fileresult->create(
-            %{$tests{$filename}},
-            filename => $filename,
-            smoke_result_id => $self->id,
-        );
-        warn "Failed to create entry for $filename: $msg"
-            unless $ok;
-    }
-
     # And commit all of that
     Jifty->handle->commit;
 
@@ -208,6 +192,45 @@ sub post_result {
              .": ".($self->is_ok ? "OK" : "NOT OK"));
 }
 
+sub post_file_result {
+    my $self = shift;
+    my ($arg) = @_;
+
+    my %result = %{ $arg };
+
+    # Find the smoke
+    Jifty->handle->begin_transaction;
+    my $smokeid = $result{smoke_result_id};
+    $self->load( $smokeid );
+    if (not $self->id) {
+        Jifty->handle->rollback;
+        return (0, "Invalid smoke ID: $smokeid");
+    } elsif (not $self->queue_status) {
+        Jifty->handle->rollback;
+        return (0, "Smoke report on $smokeid which wasn't being smoked? (last report at @{[$self->submitted_at]})");
+    }
+
+    my $fileresult = Smokingit::Model::SmokeFileResult->new(
+        current_user => Smokingit::CurrentUser->superuser,
+    );
+    $fileresult->load_by_cols(
+        smoke_result_id => $self->id,
+        filename        => $result{filename},
+    );
+    $fileresult->delete if $fileresult->id;
+
+
+    my ($ok, $msg) = $fileresult->create( %result );
+    warn "Failed to create entry for $result{filename}: $msg"
+      unless $ok;
+
+    # And commit all of that
+    Jifty->handle->commit;
+
+    return ($fileresult->id, "$result{filename} committed");
+}
+
+
 
 sub current_user_can {
     my $self  = shift;

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



More information about the Bps-public-commit mailing list