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(
23 my $db2 = DBM::Deep->new(
30 is( $db1->{x}, 'y', "Before transaction, DB1's X is Y" );
31 is( $db2->{x}, 'y', "Before transaction, DB2's X is Y" );
35 cmp_bag( [ keys %$db1 ], [qw( x )], "DB1 keys correct" );
36 cmp_bag( [ keys %$db2 ], [qw( x )], "DB2 keys correct" );
38 # Add enough keys to force a reindex
39 $db1->{"K$_"} = "V$_" for 1 .. 16;
41 cmp_bag( [ keys %$db1 ], ['x', (map { "K$_" } 1 .. 16)], "DB1 keys correct" );
42 cmp_bag( [ keys %$db2 ], [qw( x )], "DB2 keys correct" );
46 cmp_bag( [ keys %$db1 ], [qw( x )], "DB1 keys correct" );
47 cmp_bag( [ keys %$db2 ], [qw( x )], "DB2 keys correct" );
49 ok( !exists $db1->{"K$_"}, "DB1: Key K$_ doesn't exist" ) for 1 .. 16;
50 ok( !exists $db2->{"K$_"}, "DB2: Key K$_ doesn't exist" ) for 1 .. 16;
54 my ($fh, $filename) = new_fh();
55 my $db1 = DBM::Deep->new(
61 my $db2 = DBM::Deep->new(
68 is( $db1->{x}, 'y', "Before transaction, DB1's X is Y" );
69 is( $db2->{x}, 'y', "Before transaction, DB2's X is Y" );
73 cmp_bag( [ keys %$db1 ], [qw( x )], "DB1 keys correct" );
74 cmp_bag( [ keys %$db2 ], [qw( x )], "DB2 keys correct" );
76 # Add enough keys to force a reindex
77 $db1->{"K$_"} = "V$_" for 1 .. 16;
79 cmp_bag( [ keys %$db1 ], ['x', (map { "K$_" } 1 .. 16)], "DB1 keys correct" );
80 cmp_bag( [ keys %$db2 ], [qw( x )], "DB2 keys correct" );
84 cmp_bag( [ keys %$db1 ], ['x', (map { "K$_" } 1 .. 16)], "DB1 keys correct" );
85 cmp_bag( [ keys %$db2 ], ['x', (map { "K$_" } 1 .. 16)], "DB2 keys correct" );
87 ok( exists $db1->{"K$_"}, "DB1: Key K$_ doesn't exist" ) for 1 .. 16;
88 ok( exists $db2->{"K$_"}, "DB2: Key K$_ doesn't exist" ) for 1 .. 16;