1# See the file LICENSE for redistribution information.
2#
3# Copyright (c) 2004,2008 Oracle.  All rights reserved.
4#
5# $Id: rep035script.tcl,v 12.10 2008/01/08 20:58:53 bostic Exp $
6#
7# Rep035 script - continually calls lock_detect, txn_checkpoint,
8# or mpool_trickle.
9#
10# Usage: repscript clientdir apicall
11# clientdir: client env directory
12# apicall: detect, checkpoint, or trickle.
13source ./include.tcl
14source $test_path/test.tcl
15source $test_path/testutils.tcl
16source $test_path/reputils.tcl
17
18set usage "repscript clientdir apicall"
19
20# Verify usage
21if { $argc != 2 } {
22	puts stderr "FAIL:[timestamp] Usage: $usage"
23	exit
24}
25
26# Initialize arguments
27set clientdir [ lindex $argv 0 ]
28set apicall [ lindex $argv 1 ]
29
30# Join the queue env.  We assume the rep test convention of
31# placing the messages in $testdir/MSGQUEUEDIR.
32set queueenv [eval berkdb_env -home $testdir/MSGQUEUEDIR]
33error_check_good script_qenv_open [is_valid_env $queueenv] TRUE
34
35# Join the client env.
36repladd 3
37set envid 3
38set cl2_cmd "berkdb_env_noerr -home $clientdir \
39	-errfile /dev/stderr -errpfx CLIENT.$apicall \
40	-txn -rep_client -rep_transport \[list $envid replsend\]"
41# set cl2_cmd "berkdb_env_noerr -home $clientdir \
42#	-errfile /dev/stderr -errpfx CLIENT.$apicall \
43# 	-verbose {rep on} \
44# 	-txn -rep_client -rep_transport \[list $envid replsend\]"
45set clientenv [eval $cl2_cmd]
46error_check_good script_c2env_open [is_valid_env $clientenv] TRUE
47
48# Run chosen call continuously until the parent script creates
49# a marker file to indicate completion.
50switch -exact -- $apicall {
51	archive {
52		while { [file exists $testdir/marker.db] == 0 } {
53			$clientenv log_archive -arch_remove
54#			tclsleep 1
55		}
56	}
57	detect {
58		while { [file exists $testdir/marker.db] == 0 } {
59			$clientenv lock_detect default
60#			tclsleep 1
61		}
62	}
63	checkpoint {
64		while { [file exists $testdir/marker.db] == 0 } {
65			$clientenv txn_checkpoint -force
66			tclsleep 1
67		}
68	}
69	trickle {
70		while { [file exists $testdir/marker.db] == 0 } {
71			$clientenv mpool_trickle 90
72#			tclsleep 1
73		}
74	}
75	default {
76		puts "FAIL: unrecognized API call $apicall
77	}
78}
79
80error_check_good clientenv_close [$clientenv close] 0
81
82