summaryrefslogtreecommitdiff
path: root/test/tcl/rep106script.tcl
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2015-02-17 17:25:57 +0000
committer <>2015-03-17 16:26:24 +0000
commit780b92ada9afcf1d58085a83a0b9e6bc982203d1 (patch)
tree598f8b9fa431b228d29897e798de4ac0c1d3d970 /test/tcl/rep106script.tcl
parent7a2660ba9cc2dc03a69ddfcfd95369395cc87444 (diff)
downloadberkeleydb-master.tar.gz
Imported from /home/lorry/working-area/delta_berkeleydb/db-6.1.23.tar.gz.HEADdb-6.1.23master
Diffstat (limited to 'test/tcl/rep106script.tcl')
-rw-r--r--test/tcl/rep106script.tcl122
1 files changed, 122 insertions, 0 deletions
diff --git a/test/tcl/rep106script.tcl b/test/tcl/rep106script.tcl
new file mode 100644
index 00000000..2d27a23e
--- /dev/null
+++ b/test/tcl/rep106script.tcl
@@ -0,0 +1,122 @@
+# See the file LICENSE for redistribution information.
+#
+# Copyright (c) 2012, 2015 Oracle and/or its affiliates. All rights reserved.
+#
+# $Id$
+#
+# Rep106 script - Master leases.
+#
+# Test master leases and write operations.
+#
+# Usage: rep106script masterdir dbfile method
+# masterdir: master env directory
+# dbfile: name of database file
+# method: access method
+#
+source ./include.tcl
+source $test_path/test.tcl
+source $test_path/testutils.tcl
+source $test_path/reputils.tcl
+
+set usage "repscript masterdir dbfile method"
+
+# Verify usage
+if { $argc != 3 } {
+ puts stderr "FAIL:[timestamp] Usage: $usage"
+ exit
+}
+
+# Initialize arguments
+set masterdir [ lindex $argv 0 ]
+set dbfile [ lindex $argv 1 ]
+set method [ lindex $argv 2 ]
+
+# Join the queue env. We assume the rep test convention of
+# placing the messages in $testdir/MSGQUEUEDIR.
+set queueenv [eval berkdb_env -home $testdir/MSGQUEUEDIR]
+error_check_good script_qenv_open [is_valid_env $queueenv] TRUE
+
+#
+# We need to set up our own machids.
+# Add 2 for master env id, and the rest for the clientenv ids.
+#
+repladd 2
+repladd 3
+repladd 4
+repladd 5
+
+# Join the master env.
+set ma_cmd "berkdb_env_noerr -home $masterdir \
+ -txn -rep_transport \[list 2 replsend\]"
+# set ma_cmd "berkdb_env_noerr -home $masterdir \
+# -verbose {rep on} -errfile /dev/stderr \
+# -txn -rep_transport \[list 2 replsend\]"
+puts "Joining master env"
+set masterenv [eval $ma_cmd]
+error_check_good script_menv_open [is_valid_env $masterenv] TRUE
+
+# Create a marker file. Don't put anything in it yet. The parent
+# process will be processing messages while it looks for our
+# marker.
+puts "Create marker file"
+set markerenv [berkdb_env -create -home $testdir -txn]
+error_check_good markerenv_open [is_valid_env $markerenv] TRUE
+set marker \
+ [eval "berkdb_open -create -btree -auto_commit -env $markerenv marker.db"]
+
+#
+# Create the database and then do a lease operation. Don't
+# process messages in the child process.
+#
+puts "Open database"
+set args [convert_args $method]
+puts "args is $args"
+set omethod [convert_method $method]
+set db [eval "berkdb_open -env $masterenv -auto_commit -create \
+ $omethod $args $dbfile"]
+error_check_good script_db_open [is_valid_db $db] TRUE
+
+puts "Do lease op"
+set key 1
+do_leaseop $masterenv $db $method $key NULL 0
+
+puts "Put CHILD1"
+error_check_good child_key \
+ [$marker put CHILD1 $key] 0
+
+puts "Wait for PARENT1"
+# Give the parent a chance to process messages and check leases.
+while { [llength [$marker get PARENT1]] == 0 } {
+ tclsleep 1
+}
+
+puts "Do lease op 2"
+incr key
+do_leaseop $masterenv $db $method $key NULL 0
+puts "Put CHILD2"
+error_check_good child2_key \
+ [$marker put CHILD2 $key] 0
+
+puts "Wait for PARENT2"
+# Give the parent a chance to process messages and check leases.
+while { [llength [$marker get PARENT2]] == 0 } {
+ tclsleep 1
+}
+
+#
+# After we get PARENT2, do a checkpoint.
+# Then our work is done and we clean up.
+#
+puts "Write a checkpoint"
+$masterenv txn_checkpoint
+puts "Put CHILD3"
+error_check_good child2_key \
+ [$marker put CHILD3 $key] 0
+
+puts "Clean up and exit"
+# Clean up the child so the parent can go forward.
+error_check_good master_db_close [$db close] 0
+error_check_good marker_db_close [$marker close] 0
+error_check_good markerenv_close [$markerenv close] 0
+error_check_good script_master_close [$masterenv close] 0
+replclose $testdir/MSGQUEUEDIR