1 #
2 # CDDL HEADER START
3 #
4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
7 #
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
12 #
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
18 #
19 # CDDL HEADER END
20 #
21
22 #
23 # Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
25 #
26 # NFSv4 server state recovery test - negative tests
27 # - network partition
28
29 # include all test enironment
30 source LOCKsid.env
31
32 # connect to the test server
33 Connect
34
35 # setting local variables
36 set TNAME $argv0
37 set bfh [get_fh $BASEDIRS]
38
39 # Get server lease time
40 set leasetm $LEASE_TIME
41
42 # First, basic setup
43 putmsg stdout 0 \
44 "\n ** Frist basic setup for $TNAME, if fails, program will exit ..."
45
46 # Start testing
47 # --------------------------------------------------------------
48 # a: Setclientid/Setclient_confirm, expect OK
49 set expcode "OK"
50 set ASSERTION "Setclientid/Setclient_confirm, expect $expcode"
51 set tag "$TNAME{a}"
52 putmsg stdout 0 "$tag: $ASSERTION"
53 set hid "[pid]-[expr int([expr [expr rand()] * 100000000])]"
54 set cid [getclientid $hid]
55 if {$cid == -1} {
56 putmsg stderr 0 "Test FAIL: unable to get clientid"
57 exit $FAIL
58 } else {
59 logres PASS
60 }
61
62
63 # b: Open a test file w/good clientid, expect OK
64 set expcode "OK"
65 set ASSERTION "Open a test file w/good clientid, expect $expcode"
66 set tag "$TNAME{b}"
67 putmsg stdout 0 "$tag: $ASSERTION"
68 set oseqid 1
69 set TFILE "$TNAME.[pid]-b"
70 set open_owner $TFILE
71 set res [compound {Putfh $bfh;
72 Open $oseqid 3 0 "$cid $open_owner" {1 0 {{mode 0644}}} {0 $TFILE};
73 Putfh $bfh; Lookup $TFILE; Getfh}]
74 if { [ckres "Open" $status $expcode $res $PASS] == "true" } {
75 set osid [lindex [lindex $res 1] 2]
76 set nfh [lindex [lindex $res 4] 2]
77 incr oseqid
78 } else {
79 putmsg stderr 1 "\t\t Res=($res)"
80 putmsg stderr 0 \
81 "\t ... the following assertions (c,d,e) will not be run."
82 exit $FAIL
83 }
84
85 putmsg stdout 0 \
86 " ** Now wait for lease($leasetm) to expire, then do the following (c,d,e):"
87 exec sleep [expr $leasetm + 12]
88
89 # c: Now try to READ the test file w/osid, expect EXPIRED|BAD_STATEID
90 set expcode "EXPIRED|BAD_STATEID"
91 set ASSERTION "Now try to READ the test file w/osid, expect $expcode"
92 set tag "$TNAME{c}"
93 putmsg stdout 0 "$tag: $ASSERTION"
94 set res [compound {Putfh $nfh; Read "$osid" 0 64}]
95 ckres "Read" $status $expcode $res $PASS
96
97
98 # d: Try to CLOSE the test file w/expired-osid, expect EXPIRED|BAD_STATEID
99 set expcode "EXPIRED|BAD_STATEID"
100 set ASSERTION "Try to CLOSE the test file w/expired-osid, expect $expcode"
101 set tag "$TNAME{d}"
102 putmsg stdout 0 "$tag: $ASSERTION"
103 set res [compound {Putfh $nfh; Close $oseqid $osid}]
104 ckres "Close" $status $expcode $res $PASS
105
106
107 # e: OPEN the file again w/same cid, expect EXPIRED|BAD_STATEID
108 set expcode "EXPIRED|BAD_STATEID"
109 set ASSERTION "OPEN the file again w/same cid, expect $expcode"
110 set tag "$TNAME{e}"
111 putmsg stdout 0 "$tag: $ASSERTION"
112 set res [compound {Putfh $bfh;
113 Open $oseqid 3 0 "$cid $open_owner" {0 0 {{mode 0644}}} {0 $TFILE}}]
114 ckres "Open2" $status $expcode $res $PASS
115
116
117
118 # --------------------------------------------------------------
119 # Now cleanup, and removed created tmp file
120 set res [compound {Putfh $bfh; Remove $TFILE}]
121 if {($status != "OK") && ($status != "NOENT")} {
122 putmsg stderr 0 "\t WARNING: cleanup to remove created tmp file failed"
123 putmsg stderr 0 "\t status=$status; please cleanup manually."
124 putmsg stderr 1 "\t res=($res)"
125 putmsg stderr 1 " "
126 exit $WARNING
127 }
128
129 # --------------------------------------------------------------
130 # disconnect and exit
131 Disconnect
132 exit $PASS