1# See the file LICENSE for redistribution information. 2# 3# Copyright (c) 2003,2008 Oracle. All rights reserved. 4# 5# $Id: rep018script.tcl,v 12.11 2008/01/08 20:58:53 bostic Exp $ 6# 7# Rep018 script - concurrency with checkpoints. 8# 9# Test dbremove with replication. 10# 11# Usage: rep018script clientdir dbfile 12# clientdir: client env directory 13# niter: number of items in file 14# dbfile: name of database file 15# rep_verbose: Is the test doing verbose reporting? 16# verbose_type: What subset of verbose messages? 17# 18source ./include.tcl 19source $test_path/test.tcl 20source $test_path/testutils.tcl 21source $test_path/reputils.tcl 22 23set usage "repscript clientdir niter dbfile method rep_verbose verbose_type" 24 25# Verify usage 26if { $argc != 6 } { 27 puts stderr "FAIL:[timestamp] Usage: $usage" 28 exit 29} 30 31# Initialize arguments 32set clientdir [ lindex $argv 0 ] 33set niter [ lindex $argv 1 ] 34set dbfile [ lindex $argv 2 ] 35set method [ lindex $argv 3 ] 36set rep_verbose [ lindex $argv 4 ] 37set verbose_type [ lindex $argv 5 ] 38set verbargs "" 39if { $rep_verbose == 1 } { 40 set verbargs " -verbose {$verbose_type on} " 41} 42 43# Join the queue env. We assume the rep test convention of 44# placing the messages in $testdir/MSGQUEUEDIR. 45set queueenv [eval berkdb_env -home $testdir/MSGQUEUEDIR] 46error_check_good script_qenv_open [is_valid_env $queueenv] TRUE 47 48# 49# We need to set up our own machids. 50# Add 1 for master env id, and 2 for the clientenv id. 51# 52repladd 1 53repladd 2 54 55# Join the client env. 56set cl_cmd "berkdb_env_noerr -home $clientdir $verbargs -errpfx CHILD \ 57 -txn -rep_client -rep_transport \[list 2 replsend\]" 58set clientenv [eval $cl_cmd] 59error_check_good script_cenv_open [is_valid_env $clientenv] TRUE 60 61# Make sure we can read data on client. 62set db [eval "berkdb_open -env $clientenv $dbfile"] 63for { set i 1 } { $i <= $niter } { incr i } { 64 set ret [lindex [$db get $i] 0] 65 error_check_good db_get $ret [list $i [pad_data $method data$i]] 66} 67 68# Put a timestamp in a shared file. 69set markerenv [berkdb_env -create -home $testdir -txn] 70error_check_good markerenv_open [is_valid_env $markerenv] TRUE 71set marker \ 72 [eval "berkdb_open -create -btree -auto_commit -env $markerenv marker.db"] 73error_check_good timestamp_ready \ 74 [$marker put CHILDREADY [timestamp -r]] 0 75 76# Give the parent a chance to process messages and hang. 77tclsleep 30 78 79# Clean up the child so the parent can go forward. 80error_check_good timestamp_done \ 81 [$marker put CHILDDONE [timestamp -r]] 0 82error_check_good client_db_close [$db close] 0 83 84# Check that the master is done. 85while { [llength [$marker get PARENTDONE]] == 0 } { 86 tclsleep 1 87} 88 89# Verify that the newly recreated database is now empty. 90set db [eval "berkdb_open -env $clientenv $dbfile"] 91set cursor [$db cursor] 92error_check_good db_empty [llength [$cursor get -first]] 0 93error_check_good cursor_close [$cursor close] 0 94error_check_good db_close [$db close] 0 95error_check_good marker_db_close [$marker close] 0 96error_check_good markerenv_close [$markerenv close] 0 97error_check_good script_client_close [$clientenv close] 0 98 99