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

clkao at bestpractical.com clkao at bestpractical.com
Thu Apr 3 01:43:28 EDT 2008


Author: clkao
Date: Thu Apr  3 01:43:27 2008
New Revision: 11418

Added:
   SVN-PropDB/t/simple-push.t
Modified:
   SVN-PropDB/lib/Prophet/Sync/Source/SVN.pm

Log:
stub func for generating new changesets for other replica.


Modified: SVN-PropDB/lib/Prophet/Sync/Source/SVN.pm
==============================================================================
--- SVN-PropDB/lib/Prophet/Sync/Source/SVN.pm	(original)
+++ SVN-PropDB/lib/Prophet/Sync/Source/SVN.pm	Thu Apr  3 01:43:27 2008
@@ -169,4 +169,20 @@
 
 }
 
+=head2 news_changesets_for
+
+Returns the local changesets that are new to the replica $other.
+
+=cut
+
+sub new_changesets_for {
+    my ($self, $other) = @_;
+
+    my $since = $other->last_changeset_from_source( $self->uuid );
+    warn $since;
+    
+}
+
+
+
 1;

Added: SVN-PropDB/t/simple-push.t
==============================================================================
--- (empty file)
+++ SVN-PropDB/t/simple-push.t	Thu Apr  3 01:43:27 2008
@@ -0,0 +1,139 @@
+#!/usr/bin/perl 
+#
+use warnings;
+use strict;
+
+use Prophet::Test tests => 25;
+
+as_alice {
+    run_ok( 'prophet-node-create', [qw(--type Bug --status new --from alice )], "Created a record as alice" );
+    run_output_matches( 'prophet-node-search', [qw(--type Bug --regex .)], [qr/new/], " Found our record" );
+
+    # update the node
+    # show the node history
+    # show the node
+};
+
+as_bob {
+    run_ok( 'prophet-node-create', [qw(--type Bug --status open --from bob )], "Created a record as bob" );
+    run_output_matches( 'prophet-node-search', [qw(--type Bug --regex .)], [qr/open/], " Found our record" );
+
+    # update the node
+    # show the node history
+    # show the node
+
+};
+
+use_ok('Prophet::Sync::Source::SVN');
+
+my $alice = Prophet::Sync::Source->new( { url => repo_uri_for('alice') } );
+my $bob = Prophet::Sync::Source->new( { url => repo_uri_for('bob') } );
+
+my $changesets = $bob->new_changesets_for($alice);
+
+
+as_alice {
+
+    # sync from bob
+    diag('Alice syncs from bob');
+    run_ok( 'prophet-merge', [ '--from', repo_uri_for('bob'), '--to', repo_uri_for('alice') ], "Sync ran ok!" );
+
+    run_ok( 'prophet-node-create', [qw(--type Bug --status new --from alice )], "Created a record as alice" );
+};
+
+
+my $changesets = $bob->new_changesets_for($alice);
+__END__
+as_alice {
+
+    # sync from bob
+    diag('Alice syncs from bob');
+    run_ok( 'prophet-merge', [ '--from', repo_uri_for('bob'), '--to', repo_uri_for('alice') ], "Sync ran ok!" );
+
+    # check our local replicas
+    my ( $ret, $out, $err ) = run_script( 'prophet-node-search', [qw(--type Bug --regex .)] );
+    like( $out, qr/open/ );
+    like( $out, qr/new/ );
+    my @out = split( /\n/, $out );
+    is( scalar @out, 2, "We found only two rows of output" );
+
+    my $last_rev = replica_last_rev();
+
+    diag('Alice syncs from bob again. There will be no new changes from bob');
+
+    # sync from bob
+    run_ok( 'prophet-merge', [ '--from', repo_uri_for('bob'), '--to', repo_uri_for('alice') ], "Sync ran ok!" );
+
+    # check our local replicas
+    ( $ret, $out, $err ) = run_script( 'prophet-node-search', [qw(--type Bug --regex .)] );
+    like( $out, qr/open/ );
+    like( $out, qr/new/ );
+    @out = split( /\n/, $out );
+    is( scalar @out, 2, "We found only two rows of output" );
+
+    is( replica_last_rev(), $last_rev, "We have not recorded another transaction" );
+    is_deeply( replica_merge_tickets(), { replica_uuid_for('bob') => as_bob { replica_last_rev() } } );
+
+};
+
+diag('Bob syncs from alice');
+
+as_bob {
+    my $last_rev = replica_last_rev();
+
+    my ( $ret, $out, $err ) = run_script( 'prophet-node-search', [qw(--type Bug --regex .)] );
+    unlike( $out, qr/new/, "bob doesn't have alice's yet" );
+
+    # sync from alice
+
+    run_ok( 'prophet-merge', [ '--to', repo_uri_for('bob'), '--from', repo_uri_for('alice') ], "Sync ran ok!" );
+
+    # check our local replicas
+    ( $ret, $out, $err ) = run_script( 'prophet-node-search', [qw(--type Bug --regex .)] );
+    like( $out, qr/open/ );
+    like( $out, qr/new/ );
+    is( replica_last_rev, $last_rev + 1, "only one rev from alice is sycned" );
+
+   # last rev of alice is originated from bob (us), so not synced to bob, hence the merge ticket is at the previous rev.
+    is_deeply( replica_merge_tickets(), { replica_uuid_for('alice') => as_alice { replica_last_rev() - 1 } } );
+    $last_rev = replica_last_rev();
+
+    diag('Sync from alice to bob again');
+    run_ok( 'prophet-merge', [ '--to', repo_uri_for('bob'), '--from', repo_uri_for('alice') ], "Sync ran ok!" );
+
+    is_deeply( replica_merge_tickets(), { replica_uuid_for('alice') => as_alice { replica_last_rev() - 1 } } );
+    is( replica_last_rev(), $last_rev, "We have not recorded another transaction after a second sync" );
+
+};
+
+as_alice {
+    my $last_rev = replica_last_rev();
+    run_ok( 'prophet-merge', [ '--to', repo_uri_for('alice'), '--from', repo_uri_for('bob') ], "Sync ran ok!" );
+    is( replica_last_rev(), $last_rev,
+        "We have not recorded another transaction after bob had fully synced from alice" );
+
+}
+
+# create 1 node
+# search for the node
+#
+# clone the replica to a second replica
+# compare the second replica to the first replica
+#   search
+#   node history
+#   node basics
+#
+# update the first replica
+# merge the first replica to the second replica
+#   does node history on the second replica reflect the first replica
+
+# merge the second replica to the first replica
+# ensure that no new transactions aside from a merge ticket are added to the first replica
+
+# update the second replica
+# merge the second replica to the first replica
+# make sure that the first replica has the change from the second replica
+#
+#
+# TODO: this doesn't test conflict resolution at all
+# TODO: this doesn't peer to peer sync at all



More information about the Bps-public-commit mailing list