rpc002.tcl 4.22 KB
Newer Older
ram@mysql.r18.ru's avatar
ram@mysql.r18.ru committed
1
# Sel the file LICENSE for redistribution information.
2
#
ram@mysql.r18.ru's avatar
ram@mysql.r18.ru committed
3
# Copyright (c) 1999-2002
4 5
#	Sleepycat Software.  All rights reserved.
#
ram@mysql.r18.ru's avatar
ram@mysql.r18.ru committed
6
# $Id: rpc002.tcl,v 1.17 2002/07/16 20:53:03 bostic Exp $
7
#
ram@mysql.r18.ru's avatar
ram@mysql.r18.ru committed
8 9
# TEST	rpc002
# TEST	Test invalid RPC functions and make sure we error them correctly
10 11 12 13
proc rpc002 { } {
	global __debug_on
	global __debug_print
	global errorInfo
ram@mysql.r18.ru's avatar
ram@mysql.r18.ru committed
14
	global rpc_svc
15 16 17 18 19 20 21 22 23
	source ./include.tcl

	set testfile "rpc002.db"
	set home [file tail $rpc_testdir]
	#
	# First start the server.
	#
	puts "Rpc002: Unsupported interface test"
	if { [string compare $rpc_server "localhost"] == 0 } {
ram@mysql.r18.ru's avatar
ram@mysql.r18.ru committed
24
	       set dpid [exec $util_path/$rpc_svc -h $rpc_testdir &]
25
	} else {
ram@mysql.r18.ru's avatar
ram@mysql.r18.ru committed
26
	       set dpid [exec rsh $rpc_server $rpc_path/$rpc_svc \
27 28 29 30 31 32 33 34 35
		   -h $rpc_testdir &]
	}
	puts "\tRpc002.a: Started server, pid $dpid"
	tclsleep 2
	remote_cleanup $rpc_server $rpc_testdir $testdir

	puts "\tRpc002.b: Unsupported env options"
	#
	# Test each "pre-open" option for env's.  These need to be
ram@mysql.r18.ru's avatar
ram@mysql.r18.ru committed
36
	# tested on the 'berkdb_env' line.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
	#
	set rlist {
	{ "-data_dir $rpc_testdir"	"Rpc002.b0"}
	{ "-log_buffer 512"		"Rpc002.b1"}
	{ "-log_dir $rpc_testdir"	"Rpc002.b2"}
	{ "-log_max 100"		"Rpc002.b3"}
	{ "-lock_conflict {3 {0 0 0 0 0 1 0 1 1}}"	"Rpc002.b4"}
	{ "-lock_detect default"	"Rpc002.b5"}
	{ "-lock_max 100"		"Rpc002.b6"}
	{ "-mmapsize 100"		"Rpc002.b7"}
	{ "-shm_key 100"		"Rpc002.b9"}
	{ "-tmp_dir $rpc_testdir"	"Rpc002.b10"}
	{ "-txn_max 100"		"Rpc002.b11"}
	{ "-txn_timestamp 100"		"Rpc002.b12"}
	{ "-verbose {recovery on}"		"Rpc002.b13"}
	}

ram@mysql.r18.ru's avatar
ram@mysql.r18.ru committed
54 55
	set e "berkdb_env_noerr -create -mode 0644 -home $home \
	    -server $rpc_server -client_timeout 10000 -txn"
56 57 58 59 60 61 62 63
	foreach pair $rlist {
		set cmd [lindex $pair 0]
		set msg [lindex $pair 1]
		puts "\t$msg: $cmd"

		set stat [catch {eval $e $cmd} ret]
		error_check_good $cmd $stat 1
		error_check_good $cmd.err \
ram@mysql.r18.ru's avatar
ram@mysql.r18.ru committed
64
		    [is_substr $errorInfo "meaningless in an RPC env"] 1
65 66 67 68 69 70 71
	}

	#
	# Open an env with all the subsystems (-txn implies all
	# the rest)
	#
	puts "\tRpc002.c: Unsupported env related interfaces"
ram@mysql.r18.ru's avatar
ram@mysql.r18.ru committed
72
	set env [eval {berkdb_env_noerr -create -mode 0644 -home $home \
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
	    -server $rpc_server -client_timeout 10000 -txn}]
	error_check_good envopen [is_valid_env $env] TRUE
	set dbcmd "berkdb_open_noerr -create -btree -mode 0644 -env $env \
	    $testfile"
	set db [eval $dbcmd]
	error_check_good dbopen [is_valid_db $db] TRUE

	#
	# Test each "post-open" option relating to envs, txns, locks,
	# logs and mpools.
	#
	set rlist {
	{ " lock_detect default"	"Rpc002.c0"}
	{ " lock_get read 1 $env"	"Rpc002.c1"}
	{ " lock_id"			"Rpc002.c2"}
	{ " lock_stat"			"Rpc002.c3"}
	{ " lock_vec 1 {get $env read}"	"Rpc002.c4"}
	{ " log_archive"		"Rpc002.c5"}
	{ " log_file {0 0}"		"Rpc002.c6"}
	{ " log_flush"			"Rpc002.c7"}
ram@mysql.r18.ru's avatar
ram@mysql.r18.ru committed
93 94 95 96 97 98 99 100
	{ " log_cursor"			"Rpc002.c8"}
	{ " log_stat"			"Rpc002.c9"}
	{ " mpool -create -pagesize 512"	"Rpc002.c10"}
	{ " mpool_stat"			"Rpc002.c11"}
	{ " mpool_sync {0 0}"		"Rpc002.c12"}
	{ " mpool_trickle 50"		"Rpc002.c13"}
	{ " txn_checkpoint -min 1"	"Rpc002.c14"}
	{ " txn_stat"			"Rpc002.c15"}
101 102 103 104 105 106 107 108 109 110
	}

	foreach pair $rlist {
		set cmd [lindex $pair 0]
		set msg [lindex $pair 1]
		puts "\t$msg: $cmd"

		set stat [catch {eval $env $cmd} ret]
		error_check_good $cmd $stat 1
		error_check_good $cmd.err \
ram@mysql.r18.ru's avatar
ram@mysql.r18.ru committed
111
		    [is_substr $errorInfo "meaningless in an RPC env"] 1
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
	}
	error_check_good dbclose [$db close] 0

	#
	# The database operations that aren't supported are few
	# because mostly they are the ones Tcl doesn't support
	# either so we have no way to get at them.  Test what we can.
	#
	puts "\tRpc002.d: Unsupported database related interfaces"
	#
	# NOTE: the type of database doesn't matter, just use btree.
	#
	puts "\tRpc002.d0: -cachesize"
	set dbcmd "berkdb_open_noerr -create -btree -mode 0644 -env $env \
	    -cachesize {0 65536 0} $testfile"
	set stat [catch {eval $dbcmd} ret]
	error_check_good dbopen_cache $stat 1
	error_check_good dbopen_cache_err \
ram@mysql.r18.ru's avatar
ram@mysql.r18.ru committed
130
	    [is_substr $errorInfo "meaningless in an RPC env"] 1
131 132 133 134 135 136 137

	puts "\tRpc002.d1: Try to upgrade a database"
	#
	# NOTE: the type of database doesn't matter, just use btree.
	set stat [catch {eval {berkdb upgrade -env} $env $testfile} ret]
	error_check_good dbupgrade $stat 1
	error_check_good dbupgrade_err \
ram@mysql.r18.ru's avatar
ram@mysql.r18.ru committed
138
	    [is_substr $errorInfo "meaningless in an RPC env"] 1
139 140 141

	error_check_good envclose [$env close] 0

ram@mysql.r18.ru's avatar
ram@mysql.r18.ru committed
142
	tclkill $dpid
143
}