[Bps-public-commit] r11315 - in SVN-PropDB: . doc lib/Prophet t
jesse at bestpractical.com
jesse at bestpractical.com
Mon Mar 31 21:47:45 EDT 2008
Author: jesse
Date: Mon Mar 31 21:47:45 2008
New Revision: 11315
Added:
SVN-PropDB/lib/Prophet/Test/
SVN-PropDB/lib/Prophet/Test/Arena.pm
SVN-PropDB/lib/Prophet/Test/Participant.pm
SVN-PropDB/t/generalized_sync_n_merge.t
Modified:
SVN-PropDB/ (props changed)
SVN-PropDB/doc/todo
SVN-PropDB/lib/Prophet/Collection.pm
SVN-PropDB/lib/Prophet/Handle.pm
SVN-PropDB/lib/Prophet/Test.pm
Log:
r28863 at 70-5-78-234: jesse | 2008-03-31 15:47:36 -1000
* Start of massively multiplayer offline testing
Modified: SVN-PropDB/doc/todo
==============================================================================
--- SVN-PropDB/doc/todo (original)
+++ SVN-PropDB/doc/todo Mon Mar 31 21:47:45 2008
@@ -1,59 +1,3 @@
-alice: status: new
-bob: sync from alice
-bob: new->stalled
-alice: new->open
-bob: sync from alice
-bob: CONFLICT
-bob: resolve in favor of "open"
-bob: write resolution (as r3): OPEN IS BETTER
-bob: nullify stalled->new
-bob: record new->open
-alice: sync from bob
-alice: gets resolution
-alice:
-
-
-
-
-
-
-
-
-
-Serializing a conflict resolution
-
-we have a record in
-Data we must record:
- * md5 of neutralized conflict
- * each prop that might conflict
- * possible resolutions
- * chosen resolution
-
-
-/_prophet/conflict_resolutions/851bd6a627b419cfb815d008c8e7c3a8 (md5)
- _meta: delete-file
- or
- _meta: update-file
-
-
---- !!perl/hash:Prophet::ConflictingChange
-change_type: update_file
-file_op_conflict: ''
-node_type: Bug
-node_uuid: 6B865DF2-FF6C-11DC-9FF9-6E0949FE7D50
-prop_conflicts:
- - !!perl/hash:Prophet::ConflictingPropChange
- choices:
- - open
- - stalled
- name: status
- source_old_value: new
-target_node_exists: 1
-
-status: open
-status-options: new, open
-foo: bar
-
Todo
@@ -81,4 +25,3 @@
- implement merge of conflicts with: "local always wins"
- record conflict resolution data
- reuse conflict resolution data on repeated resolve
-
Modified: SVN-PropDB/lib/Prophet/Collection.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Collection.pm (original)
+++ SVN-PropDB/lib/Prophet/Collection.pm Mon Mar 31 21:47:45 2008
@@ -46,6 +46,9 @@
my $self = shift;
my $coderef = shift;
+
+ return undef unless $self->handle->type_exists( type => $self->type);
+
# find all items,
my $nodes = $self->handle->current_root->dir_entries($self->handle->db_root.'/'.$self->type.'/');
# run coderef against each item;
Modified: SVN-PropDB/lib/Prophet/Handle.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Handle.pm (original)
+++ SVN-PropDB/lib/Prophet/Handle.pm Mon Mar 31 21:47:45 2008
@@ -339,18 +339,28 @@
my $self = shift;
my %args = validate( @_, { uuid => 1, type => 1 } );
Carp::cluck unless $args{uuid};
- my $file = join( "/", $self->db_root ,$args{'type'}, $args{'uuid'} );
+ my $file = join( "/", $self->directory_for_type(type => $args{'type'}), $args{'uuid'} );
return $file;
}
+
+sub directory_for_type {
+ my $self = shift;
+ my %args = validate( @_, { type => 1 } );
+ return join( "/", $self->db_root ,$args{'type'});
+
+}
+
+
+
=head2 node_exists {uuid => $uuid, type => $type, root => $root }
Returns true if the node in question exists. False otherwise
=cut
-sub node_exists{
+sub node_exists {
my $self = shift;
my %args = validate( @_, { uuid => 1, type => 1, root => undef } );
@@ -360,6 +370,16 @@
}
+sub type_exists {
+ my $self = shift;
+ my %args = validate( @_, { type => 1, root => undef } );
+
+ my $root = $args{'root'} || $self->current_root;
+ return $root->check_path( $self->directory_for_type( type => $args{'type'}, ) );
+
+}
+
+
our $MERGETICKET_METATYPE = '_merge_tickets';
Modified: SVN-PropDB/lib/Prophet/Test.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Test.pm (original)
+++ SVN-PropDB/lib/Prophet/Test.pm Mon Mar 31 21:47:45 2008
@@ -2,7 +2,7 @@
use warnings;
package Prophet::Test;
use base qw/Test::More Exporter/;
-our @EXPORT = qw/as_alice as_bob as_charlie as_david run_ok repo_uri_for run_script run_output_matches replica_last_rev replica_merge_tickets replica_uuid_for fetch_newest_changesets ok_added_revisions
+our @EXPORT = qw/as_alice as_bob as_charlie as_david as_user run_ok repo_uri_for run_script run_output_matches replica_last_rev replica_merge_tickets replica_uuid_for fetch_newest_changesets ok_added_revisions
serialize_conflict serialize_changeset
/;
@@ -52,7 +52,7 @@
sub run_script {
my $script = shift;
- my $args = shift;
+ my $args = shift || [];
my ($stdout, $stderr);
my @cmd = _get_perl_cmd($script);
my $ret = run3 [@cmd, @$args], undef, \$stdout, \$stderr;
Added: SVN-PropDB/lib/Prophet/Test/Arena.pm
==============================================================================
--- (empty file)
+++ SVN-PropDB/lib/Prophet/Test/Arena.pm Mon Mar 31 21:47:45 2008
@@ -0,0 +1,41 @@
+use warnings;
+use strict;
+
+
+package Prophet::Test::Arena;
+use base qw/Class::Accessor/;
+
+
+use Acme::MetaSyntactic;
+use Prophet::Test;
+__PACKAGE__->mk_accessors(qw/chickens/);
+
+
+sub setup {
+ my $self = shift;
+ my $count = shift;
+ # create a set of n test participants
+ # that should initialize their environments
+
+ my @chickens;
+
+ my $meta = Acme::MetaSyntactic->new();
+
+ for my $name ($meta->name(pause_id => $count)) {
+ push @chickens,Prophet::Test::Participant->new( { name => $name } );
+
+ }
+
+ $self->chickens(\@chickens);
+
+}
+
+sub act_like_chickens {
+ # for x rounds, have each participant execute a random action
+}
+
+sub sync_all_pairs {
+
+
+}
+1;
\ No newline at end of file
Added: SVN-PropDB/lib/Prophet/Test/Participant.pm
==============================================================================
--- (empty file)
+++ SVN-PropDB/lib/Prophet/Test/Participant.pm Mon Mar 31 21:47:45 2008
@@ -0,0 +1,35 @@
+use warnings;
+use strict;
+
+
+package Prophet::Test::Participant;
+use base qw/Class::Accessor/;
+__PACKAGE__->mk_accessors(qw/name/);
+use Prophet::Test;
+
+
+sub new {
+
+ my $self = shift->SUPER::new(@_);
+ $self->_setup();
+
+}
+
+sub _setup {
+ my $self = shift;
+ as_user($self->name, sub { run_ok('prophet-node-search', [qw(--type Bug --regex .)])});
+
+
+}
+
+
+
+
+sub create_random_record {}
+sub update_random_record {}
+sub sync_from_random_peer {}
+sub sync_from_all_peers {}
+sub dump_state {}
+sub dump_history {}
+
+1;
\ No newline at end of file
Added: SVN-PropDB/t/generalized_sync_n_merge.t
==============================================================================
--- (empty file)
+++ SVN-PropDB/t/generalized_sync_n_merge.t Mon Mar 31 21:47:45 2008
@@ -0,0 +1,27 @@
+use warnings;
+use strict;
+
+use Prophet::Test 'no_plan';
+use Test::Exception;
+
+use_ok('Prophet::Test::Arena');
+use_ok('Prophet::Test::Participant');
+
+my $arena = Prophet::Test::Arena->new();
+$arena->setup(30);
+
+exit;
+
+
+# helper routines
+
+sub as_user {}
+
+
+
+
+
+
+
+
+1;
\ No newline at end of file
More information about the Bps-public-commit
mailing list