From e38d0af6b609a4ebcf07f6b19535e51ed9a105b4 Mon Sep 17 00:00:00 2001 From: Greg Sabino Mullane Date: Thu, 2 Sep 2010 00:36:46 -0400 Subject: [PATCH] More sequence testing --- t/10-pushdelta.t | 3 ++- t/10-swap.t | 32 +++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/t/10-pushdelta.t b/t/10-pushdelta.t index 12cc0fb69..38e87dc01 100644 --- a/t/10-pushdelta.t +++ b/t/10-pushdelta.t @@ -16,7 +16,8 @@ my $bct = BucardoTesting->new() or BAIL_OUT "Creation of BucardoTesting object f $location = 'pushdelta'; my $numtabletypes = keys %tabletype; -plan tests => 41 + ($numtabletypes * 19); +my $numsequences = keys %sequences; +plan tests => 41 + ($numtabletypes * 15) + ($numsequences * 4); pass("*** Beginning pushdelta tests"); diff --git a/t/10-swap.t b/t/10-swap.t index baa7580ec..fe859053f 100644 --- a/t/10-swap.t +++ b/t/10-swap.t @@ -16,7 +16,8 @@ my $bct = BucardoTesting->new() or BAIL_OUT "Creation of BucardoTesting object f $location = 'swap'; my $numtabletypes = keys %tabletype; -plan tests => 11 + ($numtabletypes * 24); +my $numsequences = keys %sequences; +plan tests => 12 + ($numtabletypes * 24) + ($numsequences + 1); pass("*** Beginning swap tests"); @@ -193,6 +194,17 @@ for my $table (sort keys %tabletype) { ## Kick the sync and wait for it to finish $bct->ctl('kick sync swaptest 0'); +for my $seq (sort keys %sequences) { + + $t = qq{Sequence $seq is copied to database B}; + + $SQL = "SELECT sequence_name, last_value, increment_by, max_value, min_value, is_cycled FROM $seq"; + my $seqA = $dbhA->selectall_arrayref($SQL)->[0]; + my $seqB = $dbhB->selectall_arrayref($SQL)->[0]; + is_deeply($seqA, $seqB, $t); + +} + ## Rows should be gone from B now for my $table (sort keys %tabletype) { @@ -373,6 +385,7 @@ for my $table (sort keys %tabletype) { } ## Insert same rows to A and B, change B, extra rows to B +## Also tweak some sequences for my $table (sort keys %tabletype) { my $type = $tabletype{$table}; @@ -399,6 +412,13 @@ for my $table (sort keys %tabletype) { $dbhA->do($SQL); $SQL = "UPDATE $table SET inty = 777 WHERE inty <> 66"; $dbhB->do($SQL); + + ## Change a sequence on A + $SQL = q{SELECT setval('bucardo_test_seq1', 45)}; + $dbhA->do($SQL); + $SQL = q{ALTER SEQUENCE bucardo_test_seq1 MAXVALUE 400}; + $dbhA->do($SQL); + } $dbhA->commit(); $dbhB->commit(); @@ -415,8 +435,16 @@ for my $table (sort keys %tabletype) { bc_deeply($res, $dbhA, $sql{select}{$table}, $t); $res = [[55],[66],[77]]; bc_deeply($res, $dbhB, $sql{select}{$table}, $t); + } +$t = qq{Sequence bucardo_test_seq1 is copied to database B}; + +$SQL = 'SELECT sequence_name, last_value, increment_by, max_value, min_value, is_cycled FROM bucardo_test_seq1'; +my $seqA = $dbhA->selectall_arrayref($SQL)->[0]; +my $seqB = $dbhB->selectall_arrayref($SQL)->[0]; +is_deeply($seqA, $seqB, $t); + ## Make B the "master" $command = "bucardo_ctl update all tables standard_conflict=target"; @@ -495,4 +523,6 @@ for my $table (sort keys %tabletype) { bc_deeply($res, $dbhB, $sql{select}{$table}, $t); } +pass('Done with swap testing'); + exit; -- 2.39.5