1
# See the file LICENSE for redistribution information.
3
# Copyright (c) 1996-2002
4
# Sleepycat Software. All rights reserved.
9
# TEST Test recovery and security. This is basically a watered
10
# TEST down version of recd001 just to verify that encrypted environments
11
# TEST can be recovered.
12
proc recd017 { method {select 0} args} {
18
set orig_fixed_len $fixed_len
19
set opts [convert_args $method $args]
20
set omethod [convert_method $method]
22
puts "Recd017: $method operation/transaction tests"
24
# Create the database and environment.
27
# The recovery tests were originally written to
28
# do a command, abort, do it again, commit, and then
29
# repeat the sequence with another command. Each command
30
# tends to require that the previous command succeeded and
31
# left the database a certain way. To avoid cluttering up the
32
# op_recover interface as well as the test code, we create two
33
# databases; one does abort and then commit for each op, the
34
# other does prepare, prepare-abort, and prepare-commit for each
35
# op. If all goes well, this allows each command to depend
36
# exactly one successful iteration of the previous command.
37
set testfile recd017.db
38
set testfile2 recd017-2.db
40
set flags "-create -encryptaes $passwd -txn -home $testdir"
42
puts "\tRecd017.a.0: creating environment"
43
set env_cmd "berkdb_env $flags"
44
convert_encrypt $env_cmd
45
set dbenv [eval $env_cmd]
46
error_check_good dbenv [is_valid_env $dbenv] TRUE
49
# We need to create a database to get the pagesize (either
50
# the default or whatever might have been specified).
51
# Then remove it so we can compute fixed_len and create the
53
set oflags "-create $omethod -mode 0644 \
54
-env $dbenv -encrypt $opts $testfile"
55
set db [eval {berkdb_open} $oflags]
56
error_check_good db_open [is_valid_db $db] TRUE
59
# Compute the fixed_len based on the pagesize being used.
60
# We want the fixed_len to be 1/4 the pagesize.
62
set pg [get_pagesize $stat]
63
error_check_bad get_pagesize $pg -1
64
set fixed_len [expr $pg / 4]
65
error_check_good db_close [$db close] 0
66
error_check_good dbremove [berkdb dbremove -env $dbenv $testfile] 0
68
# Convert the args again because fixed_len is now real.
69
# Create the databases and close the environment.
70
# cannot specify db truncate in txn protected env!!!
71
set opts [convert_args $method ""]
72
convert_encrypt $env_cmd
73
set omethod [convert_method $method]
74
set oflags "-create $omethod -mode 0644 \
75
-env $dbenv -encrypt $opts $testfile"
76
set db [eval {berkdb_open} $oflags]
77
error_check_good db_open [is_valid_db $db] TRUE
78
error_check_good db_close [$db close] 0
80
set oflags "-create $omethod -mode 0644 \
81
-env $dbenv -encrypt $opts $testfile2"
82
set db [eval {berkdb_open} $oflags]
83
error_check_good db_open [is_valid_db $db] TRUE
84
error_check_good db_close [$db close] 0
86
error_check_good env_close [$dbenv close] 0
88
puts "\tRecd017.a.1: Verify db_printlog can read logfile"
89
set tmpfile $testdir/printlog.out
90
set stat [catch {exec $util_path/db_printlog -h $testdir -P $passwd \
92
error_check_good db_printlog $stat 0
95
# List of recovery tests: {CMD MSG} pairs.
97
{ {DB put -txn TXNID $key $data} "Recd017.b: put"}
98
{ {DB del -txn TXNID $key} "Recd017.c: delete"}
101
# These are all the data values that we're going to need to read
102
# through the operation table and run the recovery tests.
104
if { [is_record_based $method] == 1 } {
109
set data recd017_data
110
foreach pair $rlist {
111
set cmd [subst [lindex $pair 0]]
112
set msg [lindex $pair 1]
113
if { $select != 0 } {
114
set tag [lindex $msg 0]
115
set tail [expr [string length $tag] - 2]
116
set tag [string range $tag $tail $tail]
117
if { [lsearch $select $tag] == -1 } {
122
if { [is_queue $method] != 1 } {
123
if { [string first append $cmd] != -1 } {
126
if { [string first consume $cmd] != -1 } {
131
# if { [is_fixed_length $method] == 1 } {
132
# if { [string first partial $cmd] != -1 } {
136
op_recover abort $testdir $env_cmd $testfile $cmd $msg
137
op_recover commit $testdir $env_cmd $testfile $cmd $msg
139
# Note that since prepare-discard ultimately aborts
140
# the txn, it must come before prepare-commit.
142
op_recover prepare-abort $testdir $env_cmd $testfile2 \
144
op_recover prepare-discard $testdir $env_cmd $testfile2 \
146
op_recover prepare-commit $testdir $env_cmd $testfile2 \
149
set fixed_len $orig_fixed_len