[Bps-public-commit] r11333 - in SVN-PropDB: t

clkao at bestpractical.com clkao at bestpractical.com
Tue Apr 1 04:19:34 EDT 2008


Author: clkao
Date: Tue Apr  1 04:19:34 2008
New Revision: 11333

Modified:
   SVN-PropDB/lib/Prophet/Test/Arena.pm
   SVN-PropDB/lib/Prophet/Test/Participant.pm
   SVN-PropDB/t/generalized_sync_n_merge.t

Log:
arena surveillance.


Modified: SVN-PropDB/lib/Prophet/Test/Arena.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Test/Arena.pm	(original)
+++ SVN-PropDB/lib/Prophet/Test/Arena.pm	Tue Apr  1 04:19:34 2008
@@ -9,7 +9,6 @@
 use Acme::MetaSyntactic;
 use Prophet::Test;
 
-
 sub setup {
     my $self  = shift;
     my $count = shift;
@@ -62,4 +61,10 @@
     
 
 }
+
+sub record {
+    my ($self, $name, $action, @args) = @_;
+    push @{$self->{history} ||= []}, [$name, $action, @args];
+}
+
 1;

Modified: SVN-PropDB/lib/Prophet/Test/Participant.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Test/Participant.pm	(original)
+++ SVN-PropDB/lib/Prophet/Test/Participant.pm	Tue Apr  1 04:19:34 2008
@@ -79,7 +79,10 @@
 }
 sub create_record {
     my $self = shift;
-    run_ok('prophet-node-create', [qw(--type Scratch),   _random_props()    ], $self->name ." created a record");
+    my @props = @_ || _random_props();
+
+    $self->record_action('create_record', @props);
+    run_ok('prophet-node-create', [qw(--type Scratch),   @props    ], $self->name ." created a record");
 }
 
 sub update_record {
@@ -92,7 +95,9 @@
     delete $props{id};
     
     %props =      _permute_props(%props); 
-    
+
+    $self->record_action('update_record', %props);
+
     run_ok('prophet-node-update', [qw(--type Scratch --uuid), $update_record,        map { '--'.$_ => $props{$_} } keys %props  ], $self->name. " updated a record");
 
 
@@ -101,6 +106,9 @@
 sub sync_from_peer {
     my $self = shift;
     my $lucky = shift || (shuffle(grep { $_->name ne $self->name} @{$self->arena->chickens}))[0];
+
+    $self->record_action('sync_from_peer', $lucky->name);
+
   
 #    my $lucky = shift @peers;
     eval { run_ok('prophet-merge', ['--prefer','to','--from', repo_uri_for($lucky->name), '--to', repo_uri_for($self->name)],  $self->name. " sync from " .$lucky->name." ran ok!"); };
@@ -120,4 +128,10 @@
 sub dump_state {}
 sub dump_history {}
 
+sub record_action {
+    my ($self, $action, @arg) = @_;
+    $self->arena->record($self->name, $action, @arg);
+}
+
+
 1;

Modified: SVN-PropDB/t/generalized_sync_n_merge.t
==============================================================================
--- SVN-PropDB/t/generalized_sync_n_merge.t	(original)
+++ SVN-PropDB/t/generalized_sync_n_merge.t	Tue Apr  1 04:19:34 2008
@@ -8,7 +8,7 @@
 use_ok('Prophet::Test::Participant');
 
 my $arena = Prophet::Test::Arena->new();
-$arena->setup(5);
+$arena->setup(3);
 
 for(1..3) {
     $arena->step('create_record');
@@ -25,7 +25,16 @@
 $arena->sync_all_pairs;
 # dump all chickens to a datastructure and compare to the previous rev
 
-
+my $Test = Test::Builder->new;
+if (grep { !$_ } $Test->summary) {
+    my $fname = join('-', sort map { $_->name } @{$arena->chickens}).'.yml';
+    diag "test failed... dumping recipe to $fname";
+    use YAML;
+    YAML::DumpFile( $fname,
+        { chickens => [ map { $_->name } @{ $arena->chickens } ],
+            recipe => $arena->{history}
+        } );
+}
 
 exit;
 for (@{$arena->chickens}) {



More information about the Bps-public-commit mailing list