~ubuntu-branches/ubuntu/edgy/rpm/edgy

« back to all changes in this revision

Viewing changes to db/test/recd004.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Joey Hess
  • Date: 2002-01-22 20:56:57 UTC
  • Revision ID: james.westby@ubuntu.com-20020122205657-l74j50mr9z8ofcl5
Tags: upstream-4.0.3
ImportĀ upstreamĀ versionĀ 4.0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# See the file LICENSE for redistribution information.
 
2
#
 
3
# Copyright (c) 1996-2001
 
4
#       Sleepycat Software.  All rights reserved.
 
5
#
 
6
# $Id: recd004.tcl,v 11.26 2001/05/16 19:01:16 sue Exp $
 
7
#
 
8
# Recovery Test #4.
 
9
# Verify that we work correctly when big keys get elevated.
 
10
proc recd004 { method {select 0} args} {
 
11
        source ./include.tcl
 
12
        global rand_init
 
13
 
 
14
        set opts [convert_args $method $args]
 
15
        set omethod [convert_method $method]
 
16
 
 
17
        set pgindex [lsearch -exact $args "-pagesize"]
 
18
        if { $pgindex != -1 } {
 
19
                puts "Recd004: skipping for specific pagesizes"
 
20
                return
 
21
        }
 
22
        if { [is_record_based $method] == 1 } {
 
23
                puts "Recd004 skipping for method $method"
 
24
                return
 
25
        }
 
26
        puts "Recd004: $method big-key on internal page recovery tests"
 
27
 
 
28
        berkdb srand $rand_init
 
29
 
 
30
        env_cleanup $testdir
 
31
        set testfile recd004.db
 
32
        set testfile2 recd004-2.db
 
33
        set eflags "-create -txn -home $testdir"
 
34
        puts "\tRecd004.a: creating environment"
 
35
        set env_cmd "berkdb env $eflags"
 
36
        set dbenv [eval $env_cmd]
 
37
        error_check_bad dbenv $dbenv NULL
 
38
 
 
39
        # Create the databases. We will use a small page size so that we
 
40
        # elevate quickly
 
41
        set oflags "-create -mode 0644 \
 
42
            $omethod -env $dbenv $opts -pagesize 512 $testfile"
 
43
        set db [eval {berkdb_open} $oflags]
 
44
        error_check_bad db_open $db NULL
 
45
        error_check_good db_open [is_substr $db db] 1
 
46
        error_check_good db_close [$db close] 0
 
47
        set oflags "-create -mode 0644 \
 
48
            $omethod -env $dbenv $opts -pagesize 512 $testfile2"
 
49
        set db [eval {berkdb_open} $oflags]
 
50
        error_check_bad db_open $db NULL
 
51
        error_check_good db_open [is_substr $db db] 1
 
52
        error_check_good db_close [$db close] 0
 
53
        reset_env $dbenv
 
54
 
 
55
        # List of recovery tests: {CMD MSG} pairs
 
56
        set slist {
 
57
                { {big_populate DB TXNID $n} "Recd004.b: big key elevation"}
 
58
                { {unpopulate DB TXNID 0} "Recd004.c: Remove keys"}
 
59
        }
 
60
 
 
61
        # If pages are 512 bytes, then adding 512 key/data pairs
 
62
        # should be more than sufficient.
 
63
        set n 512
 
64
        foreach pair $slist {
 
65
                set cmd [subst [lindex $pair 0]]
 
66
                set msg [lindex $pair 1]
 
67
                if { $select != 0 } {
 
68
                        set tag [lindex $msg 0]
 
69
                        set tail [expr [string length $tag] - 2]
 
70
                        set tag [string range $tag $tail $tail]
 
71
                        if { [lsearch $select $tag] == -1 } {
 
72
                                continue
 
73
                        }
 
74
                }
 
75
                op_recover abort $testdir $env_cmd $testfile $cmd $msg
 
76
                op_recover commit $testdir $env_cmd $testfile $cmd $msg
 
77
                #
 
78
                # Note that since prepare-discard ultimately aborts
 
79
                # the txn, it must come before prepare-commit.
 
80
                #
 
81
                op_recover prepare-abort $testdir $env_cmd $testfile2 \
 
82
                        $cmd $msg
 
83
                op_recover prepare-discard $testdir $env_cmd $testfile2 \
 
84
                        $cmd $msg
 
85
                op_recover prepare-commit $testdir $env_cmd $testfile2 \
 
86
                        $cmd $msg
 
87
        }
 
88
 
 
89
        puts "\tRecd004.d: Verify db_printlog can read logfile"
 
90
        set tmpfile $testdir/printlog.out
 
91
        set stat [catch {exec $util_path/db_printlog -h $testdir \
 
92
            > $tmpfile} ret]
 
93
        error_check_good db_printlog $stat 0
 
94
        fileremove $tmpfile
 
95
}