1# See the file LICENSE for redistribution information. 2# 3# Copyright (c) 2001,2008 Oracle. All rights reserved. 4# 5# $Id: rep008.tcl,v 12.18 2008/01/08 20:58:53 bostic Exp $ 6# 7# TEST rep008 8# TEST Replication, back up and synchronizing 9# TEST 10# TEST Run a modified version of test001 in a replicated master 11# TEST environment. 12# TEST Close master and client. 13# TEST Copy the master log to the client. 14# TEST Clean the master. 15# TEST Reopen the master and client. 16proc rep008 { method { niter 10 } { tnum "008" } args } { 17 18 source ./include.tcl 19 if { $is_windows9x_test == 1 } { 20 puts "Skipping replication test on Win 9x platform." 21 return 22 } 23 24 # Run for btree only. 25 if { $checking_valid_methods } { 26 set test_methods { btree } 27 return $test_methods 28 } 29 if { [is_btree $method] == 0 } { 30 puts "Rep$tnum: Skipping for method $method." 31 return 32 } 33 34 # This test depends on copying logs, so can't be run with 35 # in-memory logging. 36 global mixed_mode_logging 37 if { $mixed_mode_logging > 0 } { 38 puts "Rep$tnum: Skipping for mixed-mode logging." 39 return 40 } 41 42 set args [convert_args $method $args] 43 44 # Run the body of the test with and without recovery. 45 foreach r $test_recopts { 46 puts "Rep$tnum ($method $r):\ 47 Replication backup and synchronizing." 48 rep008_sub $method $niter $tnum $r $args 49 } 50} 51 52proc rep008_sub { method niter tnum recargs largs } { 53 global testdir 54 global util_path 55 global rep_verbose 56 global verbose_type 57 58 set verbargs "" 59 if { $rep_verbose == 1 } { 60 set verbargs " -verbose {$verbose_type on} " 61 } 62 63 env_cleanup $testdir 64 65 replsetup $testdir/MSGQUEUEDIR 66 67 set masterdir $testdir/MASTERDIR 68 set clientdir $testdir/CLIENTDIR 69 70 file mkdir $masterdir 71 file mkdir $clientdir 72 73 # Open a master. 74 repladd 1 75 set ma_envcmd "berkdb_env_noerr -create -txn nosync $verbargs \ 76 -home $masterdir -errpfx MASTER \ 77 -rep_transport \[list 1 replsend\]" 78 set masterenv [eval $ma_envcmd $recargs -rep_master] 79 80 # Open a client 81 repladd 2 82 set cl_envcmd "berkdb_env_noerr -create -txn nosync $verbargs \ 83 -home $clientdir -errpfx CLIENT \ 84 -rep_transport \[list 2 replsend\]" 85 set clientenv [eval $cl_envcmd $recargs -rep_client] 86 87 # Bring the clients online by processing the startup messages. 88 set envlist "{$masterenv 1} {$clientenv 2}" 89 process_msgs $envlist 90 91 # Run a modified test001 in the master (and update client). 92 puts "\tRep$tnum.a: Running test001 in replicated env." 93 eval test001 $method $niter 0 0 $tnum -env $masterenv $largs 94 process_msgs $envlist 95 96 puts "\tRep$tnum.b: Close client and master. Copy logs." 97 error_check_good client_close [$clientenv close] 0 98 error_check_good master_close [$masterenv close] 0 99 file copy -force $masterdir/log.0000000001 $testdir/log.save 100 101 puts "\tRep$tnum.c: Clean master and reopen" 102 # 103 # Add sleep calls to ensure master's new log doesn't match 104 # its old one in the ckp timestamp. 105 # 106 tclsleep 1 107 env_cleanup $masterdir 108 tclsleep 1 109 env_cleanup $clientdir 110 file copy -force $testdir/log.save $clientdir/log.0000000001 111 set masterenv [eval $ma_envcmd $recargs -rep_master] 112 error_check_good master_env [is_valid_env $masterenv] TRUE 113 114 set clientenv [eval $cl_envcmd $recargs -rep_client] 115 error_check_good client_env [is_valid_env $clientenv] TRUE 116 # 117 # We'll only catch this error if we turn on no-autoinit. 118 # Otherwise, the system will throw away everything on the 119 # client and resync. 120 # 121 $clientenv rep_config {noautoinit on} 122 123 # Process the messages to get them out of the db. 124 # 125 set envlist "{$masterenv 1} {$clientenv 2}" 126 process_msgs $envlist 0 NONE err 127 error_check_bad err $err 0 128 error_check_good errchk [is_substr $err "DB_REP_JOIN_FAILURE"] 1 129 130 error_check_good masterenv_close [$masterenv close] 0 131 error_check_good clientenv_close [$clientenv close] 0 132 replclose $testdir/MSGQUEUEDIR 133} 134