summaryrefslogtreecommitdiff
path: root/test/tcl/rep065script.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'test/tcl/rep065script.tcl')
-rw-r--r--test/tcl/rep065script.tcl224
1 files changed, 34 insertions, 190 deletions
diff --git a/test/tcl/rep065script.tcl b/test/tcl/rep065script.tcl
index 47a165be..9e09adea 100644
--- a/test/tcl/rep065script.tcl
+++ b/test/tcl/rep065script.tcl
@@ -1,96 +1,14 @@
# See the file LICENSE for redistribution information.
#
-# Copyright (c) 2006, 2012 Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2006, 2015 Oracle and/or its affiliates. All rights reserved.
#
# $Id$
#
# rep065script - procs to use at each replication site in the
# replication upgrade test.
#
-# type: START, PROCMSGS, VERIFY
-# START starts up a replication site and performs an operation.
-# the operations are:
-# REPTEST runs the rep_test_upg procedure on the master.
-# REPTEST_GET run a read-only test on a client.
-# REPTEST_ELECT runs an election on the site.
-# PROCMSGS processes messages until none are left.
-# VERIFY dumps the log and database contents.
-# role: master or client
-# op: operation to perform
-# envid: environment id number for use in replsend
-# allids: all env ids we need for sending
-# ctldir: controlling directory
-# mydir: directory where this participant runs
-# reputils_path: location of reputils.tcl
-proc rep065scr_elect { repenv oplist } {
- set ver [lindex $oplist 1]
- set pri [lindex $oplist 2]
-}
-
-proc rep065scr_reptest { repenv oplist markerdb } {
-
- set method [lindex $oplist 1]
- set niter [lindex $oplist 2]
- set loop [lindex $oplist 3]
- set start 0
- puts "REPTEST: method $method, niter $niter, loop $loop"
-
- for {set n 0} {$n < $loop} {incr n} {
- puts "REPTEST: call rep_test_upg $n"
- eval rep_test_upg $method $repenv NULL $niter $start $start 0 0
- incr start $niter
- tclsleep 3
- }
- #
- # Sleep a bunch to help get the messages worked through.
- #
- tclsleep 10
- puts "put DONE to marker"
- error_check_good marker_done [$markerdb put DONE DONE] 0
- error_check_good marker_sync [$markerdb sync] 0
-}
-
-proc rep065scr_repget { repenv oplist mydir markerfile } {
- set dbname "$mydir/DATADIR/test.db"
- set i 0
- while { [file exists $dbname] == 0 } {
- tclsleep 2
- incr i
- if { $i >= 15 && $i % 5 == 0 } {
- puts "After $i seconds, no database $dbname exists."
- }
- if { $i > 180 } {
- error "Database $dbname never created."
- }
- }
- set loop 1
- while { 1 } {
- set markerdb [berkdb_open $markerfile]
- error_check_good marker [is_valid_db $markerdb] TRUE
- set kd [$markerdb get DONE]
- error_check_good marker_close [$markerdb close] 0
- if { [llength $kd] != 0 } {
- break
- }
- set db [berkdb_open -env $repenv $dbname]
- error_check_good dbopen [is_valid_db $db] TRUE
- set dbc [$db cursor]
- set i 0
- error_check_good curs [is_valid_cursor $dbc $db] TRUE
- for { set dbt [$dbc get -first ] } \
- { [llength $dbt] > 0 } \
- { set dbt [$dbc get -next] } {
- incr i
- }
- error_check_good dbc_close [$dbc close] 0
- error_check_good db_close [$db close] 0
- puts "REPTEST_GET: after $loop loops: key count $i"
- incr loop
- tclsleep 2
- }
-}
-proc rep065scr_starttest { role oplist envid msgdir mydir allids markerfile } {
+proc rep065scr_starttest { role oplist envid msgdir mydir allids markerdir } {
global qtestdir
global util_path
global repfiles_in_memory
@@ -106,8 +24,6 @@ proc rep065scr_starttest { role oplist envid msgdir mydir allids markerfile } {
set repmemargs "-rep_inmem_files "
}
- set markerdb [berkdb_open -create -btree $markerfile]
- error_check_good marker [is_valid_db $markerdb] TRUE
puts "set up env cmd"
set lockmax 40000
set logbuf [expr 16 * 1024]
@@ -145,36 +61,22 @@ proc rep065scr_starttest { role oplist envid msgdir mydir allids markerfile } {
# Indicate that we're done starting up. Sleep to let
# others do the same.
#
- puts "put START$envid to marker"
- error_check_good marker_done [$markerdb put START$envid START$envid] 0
- error_check_good marker_sync [$markerdb sync] 0
+ puts "create START$envid marker file"
+ upgrade_create_markerfile $markerdir/START$envid
puts "sleeping after marker"
tclsleep 3
# Here is where the real test starts.
#
# Different operations may have different args in their list.
- # REPTEST: Args are method, niter, nloops
+ # REPTEST: Args are method, niter, nloops.
+ # REPTEST_GET: Does not use args.
set op [lindex $oplist 0]
if { $op == "REPTEST" } {
- #
- # This test writes the marker, so close after it runs.
- #
- rep065scr_reptest $repenv $oplist $markerdb
- error_check_good marker_close [$markerdb close] 0
+ upgradescr_reptest $repenv $oplist $markerdir
}
if { $op == "REPTEST_GET" } {
- #
- # This test needs to poll the marker. So close it now.
- #
- error_check_good marker_close [$markerdb close] 0
- rep065scr_repget $repenv $oplist $mydir $markerfile
- }
- if { $op == "REP_ELECT" } {
- #
- # This test writes the marker, so close after it runs.
- #
- rep065scr_elect $repenv $oplist $markerdb
+ upgradescr_repget $repenv $oplist $mydir $markerdir
}
puts "Closing env"
$repenv mpool_sync
@@ -182,7 +84,7 @@ proc rep065scr_starttest { role oplist envid msgdir mydir allids markerfile } {
}
-proc rep065scr_msgs { role envid msgdir mydir allids markerfile } {
+proc rep065scr_msgs { role envid msgdir mydir allids markerdir } {
global qtestdir
global repfiles_in_memory
@@ -192,21 +94,12 @@ proc rep065scr_msgs { role envid msgdir mydir allids markerfile } {
}
#
- # The main test process will write the marker file when it
- # has started and when it has completed. We need to
- # open/close the marker file because we are in a separate
- # process from the writer and we cannot share an env because
- # we might be a different BDB release version.
+ # The main test process will write a START marker file when it has
+ # started and a DONE marker file when it has completed. Wait here
+ # for the expected START marker file.
#
- set markerdb [berkdb_open -create -btree $markerfile]
- error_check_good marker [is_valid_db $markerdb] TRUE
- set s [$markerdb get START$envid]
- while { [llength $s] == 0 } {
- error_check_good marker_close [$markerdb close] 0
+ while { [file exists $markerdir/START$envid] == 0 } {
tclsleep 1
- set markerdb [berkdb_open $markerfile]
- error_check_good marker [is_valid_db $markerdb] TRUE
- set s [$markerdb get START$envid]
}
puts "repladd_noenv $allids"
@@ -239,14 +132,8 @@ proc rep065scr_msgs { role envid msgdir mydir allids markerfile } {
set envlist "{$repenv $envid}"
puts "repenv is $repenv"
- while { 1 } {
- if { [llength [$markerdb get DONE]] != 0 } {
- break
- }
+ while { [file exists $markerdir/DONE] == 0 } {
process_msgs $envlist 0 NONE NONE 1
- error_check_good marker_close [$markerdb close] 0
- set markerdb [berkdb_open $markerfile]
- error_check_good marker [is_valid_db $markerdb] TRUE
tclsleep 1
}
#
@@ -263,7 +150,6 @@ proc rep065scr_msgs { role envid msgdir mydir allids markerfile } {
set nummsg [replmsglen_noenv $envid from]
puts "Still have $nummsg not yet processed by others"
}
- error_check_good marker_close [$markerdb close] 0
replclear_noenv $envid from
tclsleep 1
replclear_noenv $envid
@@ -278,67 +164,26 @@ proc rep065scr_verify { oplist mydir id } {
-data_dir DATADIR \
-rep_transport \[list $id replnoop\]"
- # Change directories to where this will run.
- # !!!
- # mydir is an absolute path of the form
- # <path>/build_unix/TESTDIR/MASTERDIR or
- # <path>/build_unix/TESTDIR/CLIENTDIR.0
- #
- # So we want to run relative to the build_unix directory
- cd $mydir/../..
-
- foreach op $oplist {
- set repenv [eval $rep_env_cmd]
- error_check_good env_open [is_valid_env $repenv] TRUE
- if { $op == "DB" } {
- set dbname "$mydir/DATADIR/test.db"
- puts "Open db: $dbname"
- set db [berkdb_open -env $repenv -rdonly $dbname]
- error_check_good dbopen [is_valid_db $db] TRUE
- set txn ""
- set method [$db get_type]
- set dumpfile "$mydir/VERIFY/dbdump"
- if { [is_record_based $method] == 1 } {
- dump_file $db $txn $dumpfile \
- rep_test_upg.recno.check
- } else {
- dump_file $db $txn $dumpfile \
- rep_test_upg.check
- }
- puts "Done dumping $dbname to $dumpfile"
- error_check_good dbclose [$db close] 0
- }
- if { $op == "LOG" } {
- set lgstat [$repenv log_stat]
- set lgfile [stat_field $repenv log_stat "Current log file number"]
- set lgoff [stat_field $repenv log_stat "Current log file offset"]
- puts "Current LSN: $lgfile $lgoff"
- set f [open $mydir/VERIFY/loglsn w]
- puts $f $lgfile
- puts $f $lgoff
- close $f
-
- set stat [catch {eval exec $util_path/db_printlog \
- -h $mydir > $mydir/VERIFY/prlog} result]
- if { $stat != 0 } {
- puts "PRINTLOG: $result"
- }
- error_check_good stat_prlog $stat 0
- }
- error_check_good envclose [$repenv close] 0
- }
- #
- # Run recovery locally so that any later upgrades are ready
- # to be upgraded.
- #
- set stat [catch {eval exec $util_path/db_recover -h $mydir} result]
- if { $stat != 0 } {
- puts "RECOVERY: $result"
- }
- error_check_good stat_rec $stat 0
-
+ upgradescr_verify $oplist $mydir $rep_env_cmd
}
+#
+# Arguments:
+# type: START, PROCMSGS, VERIFY
+# START starts up a replication site and performs an operation.
+# the operations are:
+# REPTEST runs the rep_test_upg procedure on the master.
+# REPTEST_GET run a read-only test on a client.
+# PROCMSGS processes messages until none are left.
+# VERIFY dumps the log and database contents.
+# role: master or client
+# op: operation to perform
+# envid: environment id number for use in replsend
+# allids: all env ids we need for sending
+# ctldir: controlling directory
+# mydir: directory where this participant runs
+# reputils_path: location of reputils.tcl
+
set usage "upgradescript type role op envid allids ctldir mydir reputils_path"
# Verify usage
@@ -383,13 +228,12 @@ source $reputils_path/reputils.tcl
source $reputils_path/reputilsnoenv.tcl
set markerdir $msgtestdir/MARKER
-set markerfile $markerdir/marker.db
puts "Calling proc for type $type"
if { $type == "START" } {
- rep065scr_starttest $role $op $envid $msgtestdir $mydir $allids $markerfile
+ rep065scr_starttest $role $op $envid $msgtestdir $mydir $allids $markerdir
} elseif { $type == "PROCMSGS" } {
- rep065scr_msgs $role $envid $msgtestdir $mydir $allids $markerfile
+ rep065scr_msgs $role $envid $msgtestdir $mydir $allids $markerdir
} elseif { $type == "VERIFY" } {
file mkdir $mydir/VERIFY
rep065scr_verify $op $mydir $envid