[Bps-public-commit] r11334 - in SVN-PropDB: . t
jesse at bestpractical.com
jesse at bestpractical.com
Tue Apr 1 05:17:24 EDT 2008
Author: jesse
Date: Tue Apr 1 05:16:45 2008
New Revision: 11334
Modified:
SVN-PropDB/ (props changed)
SVN-PropDB/lib/Prophet/Test/Arena.pm
SVN-PropDB/lib/Prophet/Test/Participant.pm
SVN-PropDB/t/generalized_sync_n_merge.t
Log:
r28895 at 68-246-174-125: jesse | 2008-03-31 22:58:14 -1000
* now we can fully dump out the state of a replica
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 05:16:45 2008
@@ -37,6 +37,16 @@
# for x rounds, have each participant execute a random action
}
+sub dump_state {
+ my $self = shift;
+ my %state;
+ for my $chicken ( @{ $self->chickens } ) {
+ $state{ $chicken->name } = as_user( $chicken->name, sub { $chicken->dump_state } );
+ }
+ return \%state;
+}
+
+
use List::Util qw/shuffle/;
sub sync_all_pairs {
my $self = shift;
@@ -53,7 +63,7 @@
next if $a->name eq $b->name;
next if ($seen_pairs{$b->name."-".$a->name});
diag($a->name, $b->name);
- $a->sync_from_peer($b);
+ as_user($a->name, sub {$a->sync_from_peer($b) });
$seen_pairs{$a->name."-".$b->name} =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 05:16:45 2008
@@ -125,7 +125,34 @@
sub sync_from_all_peers {}
-sub dump_state {}
+sub dump_state {
+ my $self = shift;
+ my $cli = Prophet::CLI->new();
+
+ my $state;
+
+ my $nodes = Prophet::Collection->new(handle => $cli->handle, type => 'Scratch');
+ my $merges = Prophet::Collection->new(handle => $cli->handle, type => $Prophet::Handle::MERGETICKET_METATYPE);
+ my $resolutions = Prophet::Collection->new(handle => $cli->resdb_handle, type => '_prophet_resolution');
+
+ $nodes->matching(sub {1});
+ $resolutions->matching(sub {1});
+ $merges->matching(sub {1});
+
+ %{$state->{nodes}}= map { $_->uuid => $_->get_props} @{$nodes->as_array_ref};
+ %{$state->{merges}} =map { $_->uuid => $_->get_props} @{ $merges->as_array_ref};
+ %{$state->{resolutions}} = map { $_->uuid => $_->get_props} @{$resolutions->as_array_ref};
+
+
+
+
+
+ return $state;
+
+}
+
+
+
sub dump_history {}
sub record_action {
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 05:16:45 2008
@@ -20,11 +20,14 @@
$arena->sync_all_pairs;
$arena->sync_all_pairs;
+my $third = $arena->dump_state;
diag("now every txn has gotten to every peer. we could probably do more optimal routing, but that's not what we're testing");
# dump all chickens to a datastructure;
$arena->sync_all_pairs;
# dump all chickens to a datastructure and compare to the previous rev
+my $fourth = $arena->dump_state;
+is_deeply($third,$fourth);
my $Test = Test::Builder->new;
if (grep { !$_ } $Test->summary) {
my $fname = join('-', sort map { $_->name } @{$arena->chickens}).'.yml';
More information about the Bps-public-commit
mailing list