2 use Test::More tests => 81;
4 use t::common qw( new_fh );
8 # This testfile is in sections because the goal is to verify the behavior
9 # when a reindex occurs during an active transaction, both as a result of the
10 # transaction's actions as well as the result of the HEAD's actions. In order
11 # to keep this test quick, it's easier to restart and hit the known
12 # reindexing at 17 keys vs. attempting to hit the second-level reindex which
13 # can occur as early as 18 keys and as late as 4097 (256*16+1) keys.
16 my ($fh, $filename) = new_fh();
17 my $db1 = DBM::Deep->new(
24 my $db2 = DBM::Deep->new(
32 is( $db1->{x}, 'y', "Before transaction, DB1's X is Y" );
33 is( $db2->{x}, 'y', "Before transaction, DB2's X is Y" );
37 cmp_bag( [ keys %$db1 ], [qw( x )], "DB1 keys correct" );
38 cmp_bag( [ keys %$db2 ], [qw( x )], "DB2 keys correct" );
40 # Add enough keys to force a reindex
41 $db1->{"K$_"} = "V$_" for 1 .. 16;
43 cmp_bag( [ keys %$db1 ], ['x', (map { "K$_" } 1 .. 16)], "DB1 keys correct" );
44 cmp_bag( [ keys %$db2 ], [qw( x )], "DB2 keys correct" );
48 cmp_bag( [ keys %$db1 ], [qw( x )], "DB1 keys correct" );
49 cmp_bag( [ keys %$db2 ], [qw( x )], "DB2 keys correct" );
51 ok( !exists $db1->{"K$_"}, "DB1: Key K$_ doesn't exist" ) for 1 .. 16;
52 ok( !exists $db2->{"K$_"}, "DB2: Key K$_ doesn't exist" ) for 1 .. 16;
56 my ($fh, $filename) = new_fh();
57 my $db1 = DBM::Deep->new(
64 my $db2 = DBM::Deep->new(
72 is( $db1->{x}, 'y', "Before transaction, DB1's X is Y" );
73 is( $db2->{x}, 'y', "Before transaction, DB2's X is Y" );
77 cmp_bag( [ keys %$db1 ], [qw( x )], "DB1 keys correct" );
78 cmp_bag( [ keys %$db2 ], [qw( x )], "DB2 keys correct" );
80 # Add enough keys to force a reindex
81 $db1->{"K$_"} = "V$_" for 1 .. 16;
83 cmp_bag( [ keys %$db1 ], ['x', (map { "K$_" } 1 .. 16)], "DB1 keys correct" );
84 cmp_bag( [ keys %$db2 ], [qw( x )], "DB2 keys correct" );
88 cmp_bag( [ keys %$db1 ], ['x', (map { "K$_" } 1 .. 16)], "DB1 keys correct" );
89 cmp_bag( [ keys %$db2 ], ['x', (map { "K$_" } 1 .. 16)], "DB2 keys correct" );
91 ok( exists $db1->{"K$_"}, "DB1: Key K$_ doesn't exist" ) for 1 .. 16;
92 ok( exists $db2->{"K$_"}, "DB2: Key K$_ doesn't exist" ) for 1 .. 16;