1# See the file LICENSE for redistribution information.
2#
3# Copyright (c) 1996,2008 Oracle.  All rights reserved.
4#
5# $Id: test123.tcl,v 12.2 2008/01/08 20:58:53 bostic Exp $
6#
7# TEST	test123
8# TEST	Concurrent Data Store cdsgroup smoke test.
9# TEST
10# TEST	Open a CDS env with -cdb_alldb.
11# TEST	Start a "txn" with -cdsgroup.
12# TEST	Create two databases in the env, do a cursor put
13# TEST	in both within the same txn.  This should succeed.
14
15proc test123 { method args } {
16	source ./include.tcl
17
18	# If we are using an env, then skip this test.  It needs its own.
19	set eindex [lsearch -exact $args "-env"]
20	if { $eindex != -1 } {
21		incr eindex
22		set env [lindex $args $eindex]
23		puts "Skipping test123 for env $env"
24		return
25	}
26
27	if { [is_queue $method] == 1 } {
28		puts "Skipping test123 for method $method"
29		return
30	}
31	set args [convert_args $method $args]
32	set encargs ""
33	set args [split_encargs $args encargs]
34	set omethod [convert_method $method]
35	set dbname test123.db
36	set tnum "123"
37
38	puts "Test$tnum: CDB with cdsgroup ($method)"
39	env_cleanup $testdir
40
41	# Open environment and start cdsgroup "transaction".
42	puts "\tTest$tnum.a: Open env."
43	set env [eval {berkdb_env -create} $encargs -cdb -cdb_alldb -home $testdir]
44	error_check_good dbenv [is_valid_env $env] TRUE
45	set txn [$env cdsgroup]
46
47	# Env is created, now set up 2 databases
48	puts "\tTest$tnum.b: Open first database."
49	set db1 [eval {berkdb_open}\
50	    -create -env $env $args $omethod -txn $txn $dbname "A"]
51	puts "\tTest$tnum.b1: Open cursor."
52	set curs1 [eval {$db1 cursor} -update -txn $txn]
53	puts "\tTest$tnum.b2: Initialize cursor and do a put."
54	error_check_good curs1_put [eval {$curs1 put} -keyfirst 1 DATA1] 0
55
56	puts "\tTest$tnum.c: Open second database."
57	set db2 [eval {berkdb_open}\
58	    -create -env $env $args $omethod -txn $txn $dbname "B"]
59	puts "\tTest$tnum.c1: Open cursor."
60	set curs2 [eval {$db2 cursor} -update -txn $txn]
61	puts "\tTest$tnum.b2: Initialize cursor and do a put."
62	error_check_good curs2_put [eval {$curs2 put} -keyfirst 2 DATA2] 0
63
64	# Clean up.
65	$curs2 close
66	$curs1 close
67	$txn commit
68	$db2 close
69	$db1 close
70	$env close
71
72}
73
74