1 #! /usr/bin/ksh -p
2 #
3 # CDDL HEADER START
4 #
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
8 #
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
13 #
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 #
20 # CDDL HEADER END
21 #
22
23 #
24 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
26 #
27
28 #
29 # start __stf_assertion__
30 #
31 # ASSERTION: depends_026
32 # DESCRIPTION:
33 # If an online service, service_A, has a dependency on another service,
34 # service_B, and service_B is transitioned into offline mode, then
35 # service_A is transitioned offline. Once service_B transitions to
36 # online then service_A will transition to online as well.
37 #
38 # end __stf_assertion__
39 #
40
41 . ${STF_TOOLS}/include/stf.kshlib
42 . ${STF_SUITE}/include/gltest.kshlib
43 . ${STF_SUITE}/include/svc.startd_config.kshlib
44 . ${STF_SUITE}/tests/svc.startd/include/svc.startd_common.kshlib
45
46 typeset service_setup=0
47 function cleanup {
48 common_cleanup
49 rm -f $service_state1 $service_state2 $service_state3
50 }
51
52 trap cleanup 0 1 2 15
53
54 readonly ME=$(whence -p ${0})
55 readonly MYLOC=$(dirname ${ME})
56
57 DATA=$MYLOC
58
59 readonly registration_template=$DATA/service_026.xml
60
61 extract_assertion_info $ME
62
63 # make sure that the svc.startd is running
64 verify_daemon
65 if [ $? -ne 0 ]; then
66 print -- "--DIAG: $assertion: svc.startd is not executing. Cannot "
67 print -- " continue"
68 exit $STF_UNRESOLVED
69 fi
70
71 typeset startdpid=$(pgrep -z `zonename` svc.startd)
72 typeset -i count=$(set -- $startdpid; echo $#)
73
74 if [ $count -ne 1 ]; then
75 print -- "--DIAG: there are $count instances of svc.startd running"
76 [ $count -ne 0 ] && print -- " pids are: $startdpid"
77 print -- " There should be only one(1) svc.startd instance"
78 exit $STF_UNRESOLVED
79 fi
80
81 # Make sure the environment is clean - the test service isn't running
82 print -- "--INFO: Cleanup any old $test_FMRI1, $test_FMRI2, $test_FMRI3 state"
83 service_cleanup $test_service
84 if [ $? -ne 0 ]; then
85 print -- "--DIAG: $assertion: cleanup of a previous instance failed"
86 exit $STF_UNRESOLVED
87 fi
88
89 print -- "--INFO: generating manifest for importation into repository"
90 manifest_generate $registration_template \
91 TEST_SERVICE=$test_service \
92 TEST_INSTANCE1=$test_instance1 \
93 TEST_INSTANCE2=$test_instance2 \
94 TEST_INSTANCE3=$test_instance3 \
95 SERVICE_APP=$service_app \
96 LOGFILE=$service_log \
97 STATEFILE1=$service_state1 \
98 STATEFILE2=$service_state2 \
99 STATEFILE3=$service_state3 \
100 > $registration_file
101
102 print -- "--INFO: Importing service into repository"
103 manifest_purgemd5 $registration_file
104 svccfg -v import $registration_file >$svccfg_errfile 2>&1
105
106 if [ $? -ne 0 ]; then
107 print -- "--DIAG: $assertion: Unable to import the services $test_FMRI1"
108 print -- " $test_FMRI2 and $test_FMRI3 error messages from svccfg: "
109 print -- " \"$(cat $svccfg_errfile)\""
110 exit $STF_UNRESOLVED
111 fi
112 service_setup=1
113
114 print -- "--INFO: Wait for $test_FMRI3 to come online"
115 service_wait_state $test_FMRI3 online
116 if [ $? -ne 0 ]; then
117 print -- "--DIAG: $assertion: Service $test_FMRI3 didn't come online"
118 exit $STF_FAIL
119 fi
120
121 print -- "--INFO: Wait for $test_FMRI2 to come online"
122 service_wait_state $test_FMRI2 online
123 if [ $? -ne 0 ]; then
124 print -- "--DIAG: $assertion: Service $test_FMRI2 didn't come online"
125 exit $STF_FAIL
126 fi
127
128 print -- "--INFO: Wait for $test_FMRI1 to come online"
129 service_wait_state $test_FMRI1 online
130 if [ $? -ne 0 ]; then
131 print -- "--DIAG: $assertion: Service $test_FMRI1 didn't come online"
132 exit $STF_FAIL
133 fi
134
135 echo "--INFO: Sending service $test_FMRI1 to maintenance"
136 svcadm mark maintenance $test_FMRI1
137 if [ $? -ne 0 ]; then
138 echo "--DIAG: $assertion: Service $test_FMRI1 didn't set"
139 echo " maintenance mode"
140 exit $STF_FAIL
141 fi
142
143 echo "--INFO: Verify maintenance mode for $test_FMRI1"
144 service_wait_state $test_FMRI1 maintenance
145 if [ $? -ne 0 ]; then
146 echo "--DIAG: $assertion: service $test_FMRI1 didn't enter"
147 echo " maintenance"
148 exit $STF_FAIL
149 fi
150
151 echo "--INFO: Verify offline for $test_FMRI2"
152 service_wait_state $test_FMRI2 offline
153 if [ $? -ne 0 ]; then
154 echo "--DIAG: $assertion: service $test_FMRI2 didn't enter offline"
155 exit $STF_FAIL
156 fi
157
158 echo "--INFO: Verify offline for $test_FMRI3"
159 service_wait_state $test_FMRI3 offline
160 if [ $? -ne 0 ]; then
161 echo "--DIAG: $assertion: service $test_FMRI3 didn't enter offline"
162 exit $STF_FAIL
163 fi
164
165 echo "--INFO: clear maintenance of service $test_FMRI1"
166 svcadm clear $test_FMRI1
167 if [ $? -ne 0 ]; then
168 echo "--DIAG: $assertion: service $test_FMRI1 would not clear state"
169 exit $STF_UNRESOLVED
170 fi
171
172 echo "--INFO: Waiting for $test_FMRI1 to enter online"
173 service_wait_state $test_FMRI1 online
174 if [ $? -ne 0 ]; then
175 echo "--DIAG: $assertion: service $test_FMRI1 didn't go online"
176 exit $STF_FAIL
177 fi
178
179 echo "--INFO: Waiting for $test_FMRI2 to enter online"
180 service_wait_state $test_FMRI2 online
181 if [ $? -ne 0 ]; then
182 echo "--DIAG: $assertion: service $test_FMRI2 didn't go online"
183 exit $STF_FAIL
184 fi
185
186 echo "--INFO: Waiting for $test_FMRI3 to enter online"
187 service_wait_state $test_FMRI3 online
188 if [ $? -ne 0 ]; then
189 echo "--DIAG: $assertion: service $test_FMRI3 didn't go online"
190 exit $STF_FAIL
191 fi
192
193 print -- "--INFO: Checking that startd didn't crash during this test"
194 typeset endpid=$(pgrep -z `zonename` svc.startd)
195 typeset -i count=$(set -- $endpid; echo $#)
196
197 if [ $count -ne 1 ]; then
198 print -- "--DIAG: there are $count instances of svc.startd running"
199 [ $count -ne 0 ] && print -- " pids are: $startdpid"
200 print -- " There should be only one(1) svc.startd instance"
201 exit $STF_UNRESOLVED
202 fi
203 if [ $startdpid != $endpid ]; then
204 print -- "--DIAG: svc.startd changed pid during execution"
205 print " it was $startpid, it is now $endpid"
206 exit $STF_UNRESOLVED
207 fi
208
209 print -- "--INFO: Cleaning up service"
210 cleanup
211
212 exit $STF_PASS