proc recd014 { method args} {
global fixed_len
source ./include.tcl
if { ![is_queueext $method] == 1 } {
puts "Recd014: Skipping for method $method"
return
}
set pgindex [lsearch -exact $args "-pagesize"]
if { $pgindex != -1 } {
puts "Recd014: skipping for specific pagesizes"
return
}
set orig_fixed_len $fixed_len
set fixed_len 300
set opts [convert_args $method $args]
set omethod [convert_method $method]
set exti [lsearch -exact $opts "-extent"]
incr exti
set opts [lreplace $opts $exti $exti 1]
puts "Recd014: $method extent creation/deletion tests"
env_cleanup $testdir
set testfile recd014.db
set flags "-create -txn -home $testdir"
puts "\tRecd014.a: creating environment"
set env_cmd "berkdb_env $flags"
puts "\tRecd014.b: Create test commit"
ext_recover_create $testdir $env_cmd $omethod \
$opts $testfile commit
puts "\tRecd014.b: Create test abort"
ext_recover_create $testdir $env_cmd $omethod \
$opts $testfile abort
puts "\tRecd014.c: Consume test commit"
ext_recover_consume $testdir $env_cmd $omethod \
$opts $testfile commit
puts "\tRecd014.c: Consume test abort"
ext_recover_consume $testdir $env_cmd $omethod \
$opts $testfile abort
set fixed_len $orig_fixed_len
puts "\tRecd014.d: Verify db_printlog can read logfile"
set tmpfile $testdir/printlog.out
set stat [catch {exec $util_path/db_printlog -h $testdir \
> $tmpfile} ret]
error_check_good db_printlog $stat 0
fileremove $tmpfile
}
proc ext_recover_create { dir env_cmd method opts dbfile txncmd } {
global log_log_record_types
global fixed_len
global alphabet
source ./include.tcl
if { $log_log_record_types == 1} {
logtrack_read $dir
}
env_cleanup $dir
set env [eval $env_cmd]
set init_file $dir/$dbfile.init
set noenvflags "-create $method -mode 0644 -pagesize 512 $opts $dbfile"
set oflags "-env $env $noenvflags"
set t [$env txn]
error_check_good txn_begin [is_valid_txn $t $env] TRUE
set ret [catch {eval {berkdb_open} -txn $t $oflags} db]
error_check_good txn_commit [$t commit] 0
set t [$env txn]
error_check_good txn_begin [is_valid_txn $t $env] TRUE
set extnum 0
set data [chop_data $method [replicate $alphabet 512]]
puts "\t\tExecuting command"
set putrecno [$db put -txn $t -append $data]
error_check_good db_put $putrecno 1
puts "\t\tSyncing"
error_check_good db_sync [$db sync] 0
catch { file copy -force $dir/$dbfile $dir/$dbfile.afterop } res
copy_extent_file $dir $dbfile afterop
error_check_good txn_$txncmd:$t [$t $txncmd] 0
set dbq [make_ext_filename $dir $dbfile $extnum]
error_check_good extput:exists1 [file exists $dbq] 1
set ret [$db get $putrecno]
if {$txncmd == "abort"} {
puts "\t\tCommand executed and aborted."
error_check_good db_get [llength $ret] 0
} else {
puts "\t\tCommand executed and committed."
error_check_good db_get [llength $ret] 1
catch { file copy -force $dir/$dbfile $init_file } res
copy_extent_file $dir $dbfile init
}
set t [$env txn]
error_check_good txn_begin [is_valid_txn $t $env] TRUE
error_check_good db_close [$db close] 0
error_check_good txn_commit [$t commit] 0
error_check_good env_close [$env close] 0
berkdb debug_check
puts -nonewline "\t\tAbout to run recovery (no-op) ... "
flush stdout
set stat [catch {exec $util_path/db_recover -h $dir -c} result]
if { $stat == 1 } {
error "FAIL: Recovery error: $result."
return
}
puts "complete"
error_check_good extput:exists2 [file exists $dbq] 1
ext_create_check $dir $txncmd $init_file $dbfile $noenvflags $putrecno
catch { file copy -force $dir/$dbfile $init_file } res
copy_extent_file $dir $dbfile init
file copy -force $dir/$dbfile.afterop $dir/$dbfile
move_file_extent $dir $dbfile afterop copy
berkdb debug_check
puts -nonewline "\t\tAbout to run recovery (afterop) ... "
flush stdout
set stat [catch {exec $util_path/db_recover -h $dir -c} result]
if { $stat == 1 } {
error "FAIL: Recovery error: $result."
return
}
puts "complete"
ext_create_check $dir $txncmd $init_file $dbfile $noenvflags $putrecno
catch { file rename -force $dir/$dbfile $dir/$dbfile.renamed } res
copy_extent_file $dir $dbfile renamed rename
berkdb debug_check
puts -nonewline "\t\tAbout to run recovery (init) ... "
flush stdout
set stat [catch {exec $util_path/db_recover -h $dir -c} result]
if { $stat == 1 && [is_substr $result "warning"] == 0 } {
error "FAIL: Recovery error: $result."
return
}
puts "complete"
if {$txncmd == "abort"} {
error_check_good extput:exists3 [file exists $dbq] 0
} else {
error_check_good extput:exists3 [file exists $dbq] 1
}
}
proc ext_create_check { dir txncmd init_file dbfile oflags putrecno } {
if { $txncmd == "commit" } {
error_check_good \
diff(initial,post-recover2):diff($init_file,$dir/$dbfile) \
[dbdump_diff "-dar" $init_file $dir $dbfile] 0
} else {
set xdb [eval {berkdb_open} $oflags]
error_check_good db_open [is_valid_db $xdb] TRUE
set ret [$xdb get $putrecno]
error_check_good db_get [llength $ret] 0
error_check_good db_close [$xdb close] 0
}
}
proc ext_recover_consume { dir env_cmd method opts dbfile txncmd} {
global log_log_record_types
global alphabet
source ./include.tcl
if { $log_log_record_types == 1} {
logtrack_read $dir
}
env_cleanup $dir
set env [eval $env_cmd]
set oflags "-create -auto_commit $method -mode 0644 -pagesize 512 \
-env $env $opts $dbfile"
set db [eval {berkdb_open} $oflags]
error_check_good db_open [is_valid_db $db] TRUE
set extnum 0
set data [chop_data $method [replicate $alphabet 512]]
set txn [$env txn]
error_check_good txn_begin [is_valid_txn $txn $env] TRUE
set putrecno [$db put -txn $txn -append $data]
error_check_good db_put $putrecno 1
error_check_good commit [$txn commit] 0
error_check_good db_close [$db close] 0
puts "\t\tExecuting command"
set init_file $dir/$dbfile.init
catch { file copy -force $dir/$dbfile $init_file } res
copy_extent_file $dir $dbfile init
set db [eval {berkdb_open} $oflags]
error_check_good db_open [is_valid_db $db] TRUE
set t [$env txn]
error_check_good txn_begin [is_valid_txn $t $env] TRUE
set dbcmd "$db get -txn $t -consume"
set ret [eval $dbcmd]
error_check_good db_sync [$db sync] 0
catch { file copy -force $dir/$dbfile $dir/$dbfile.afterop } res
copy_extent_file $dir $dbfile afterop
error_check_good txn_$txncmd:$t [$t $txncmd] 0
error_check_good db_sync [$db sync] 0
set dbq [make_ext_filename $dir $dbfile $extnum]
if {$txncmd == "abort"} {
puts "\t\tCommand executed and aborted."
error_check_good postconsume.1 [file exists $dbq] 1
error_check_good \
diff(init,postconsume.2):diff($init_file,$dir/$dbfile)\
[dbdump_diff "-dar" $init_file $dir $dbfile] 0
} else {
puts "\t\tCommand executed and committed."
error_check_good consume_exists [file exists $dbq] 0
}
error_check_good db_close [$db close] 0
error_check_good env_close [$env close] 0
berkdb debug_check
puts -nonewline "\t\tAbout to run recovery (no-op) ... "
flush stdout
set stat [catch {exec $util_path/db_recover -h $dir -c} result]
if { $stat == 1 } {
error "FAIL: Recovery error: $result."
return
}
puts "complete"
if { $txncmd == "abort"} {
error_check_good \
diff(initial,post-recover1):diff($init_file,$dir/$dbfile) \
[dbdump_diff "-dar" $init_file $dir $dbfile] 0
} else {
error_check_good after_recover1 [file exists $dbq] 0
}
catch { file copy -force $dir/$dbfile $init_file } res
copy_extent_file $dir $dbfile init
berkdb debug_check
puts -nonewline "\t\tAbout to run recovery (init) ... "
flush stdout
set stat [catch {exec $util_path/db_recover -h $dir -c} result]
if { $stat == 1 } {
error "FAIL: Recovery error: $result."
return
}
puts "complete"
if { $txncmd == "abort"} {
error_check_good \
diff(initial,post-recover1):diff($init_file,$dir/$dbfile) \
[dbdump_diff "-dar" $init_file $dir $dbfile] 0
} else {
error_check_good after_recover2 [file exists $dbq] 0
}
set filecopy [glob $dir/*.afterop]
set afterop [lindex $filecopy 0]
file rename -force $afterop $dir/$dbfile
set afterop [string range $afterop \
[expr [string last "/" $afterop] + 1] \
[string last "." $afterop]]
move_file_extent $dir $dbfile afterop rename
berkdb debug_check
puts -nonewline "\t\tAbout to run recovery (afterop) ... "
flush stdout
set stat [catch {exec $util_path/db_recover -h $dir -c} result]
if { $stat == 1 } {
error "FAIL: Recovery error: $result."
return
}
puts "complete"
if { $txncmd == "abort"} {
error_check_good \
diff(initial,post-recover2):diff($init_file,$dir/$dbfile) \
[dbdump_diff "-dar" $init_file $dir $dbfile] 0
} else {
error_check_good after_recover3 [file exists $dbq] 0
}
}