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_048
32 # DESCRIPTION:
33 # A service with a dependency of optional_all will go online even if
34 # that dependency is in the maintenance state.
35 # The test service has multiple optional_all dependencies.
36 #
37 # end __stf_assertion__
38 #
39
40 . ${STF_TOOLS}/include/stf.kshlib
41 . ${STF_SUITE}/include/gltest.kshlib
42 . ${STF_SUITE}/include/svc.startd_config.kshlib
43 . ${STF_SUITE}/tests/svc.startd/include/svc.startd_common.kshlib
44
45 typeset service_setup=0
46 function cleanup {
47 common_cleanup
48 rm -f $service_state1 $service_state2 $service_state3
49 }
50
51 trap cleanup 0 1 2 15
52
53 readonly ME=$(whence -p ${0})
54 readonly MYLOC=$(dirname ${ME})
55
56 DATA=$MYLOC
57
58 readonly registration_template=$DATA/service_048.xml
59
60 extract_assertion_info $ME
61
62 # make sure that the svc.startd is running
63 verify_daemon
64 if [ $? -ne 0 ]; then
65 echo "--DIAG: $assertion: svc.startd is not executing. Cannot "
66 echo " continue"
67 exit $STF_UNRESOLVED
68 fi
69
70 # Make sure the environment is clean - the test service isn't running
71 echo "--INFO: Cleanup any old $test_service state"
72 service_cleanup $test_service
73 if [ $? -ne 0 ]; then
74 echo "--DIAG: $assertion: cleanup of a previous instance failed"
75 exit $STF_UNRESOLVED
76 fi
77
78 echo "--INFO: generating manifest for importation into repository"
79 manifest_generate $registration_template \
80 TEST_SERVICE=$test_service \
81 TEST_INSTANCE1=$test_instance1 \
82 TEST_INSTANCE2=$test_instance2 \
83 TEST_INSTANCE3=$test_instance3 \
84 SERVICE_APP=$service_app \
85 LOGFILE=$service_log \
86 STATEFILE1=$service_state1 \
87 STATEFILE2=$service_state2 \
88 STATEFILE3=$service_state3 \
89 > $registration_file
90
91 echo "--INFO: Importing service into repository"
92 manifest_purgemd5 $registration_file
93 svccfg -v import $registration_file >$svccfg_errfile 2>&1
94
95 if [ $? -ne 0 ]; then
96 echo "--DIAG: $assertion: Unable to import $test_service."
97 echo " Error messages from svccfg: "
98 echo " \"$(cat $svccfg_errfile)\""
99 exit $STF_UNRESOLVED
100 fi
101 service_setup=1
102
103 print -- "--INFO: List service dependencies"
104 for svc in $test_FMRI1 $test_FMRI2 $test_FMRI3; do
105 svcs -l $svc | grep ^[fd]
106 print " "
107 done
108
109 echo "--INFO: Ensuring $test_FMRI1 comes online"
110 service_wait_state $test_FMRI1 online
111 if [ $? -ne 0 ]; then
112 echo "--DIAG: $assertion: Service $test_FMRI1 didn't come online"
113 exit $STF_UNRESOLVED
114 fi
115
116 echo "--INFO: [ Phase 1 ] Transition dependency $test_FMRI2 to maintenance"
117 svcadm mark maintenance $test_FMRI2
118 if [ $? -ne 0 ]; then
119 echo "--DIAG: $assertion: service $test_FMRI2 could not be set to"
120 echo " maintenance mode."
121 exit $STF_UNRESOLVED
122 fi
123 service_wait_state $test_FMRI2 maintenance
124 if [ $? -ne 0 ]; then
125 echo "--DIAG: $assertion: Service $test_FMRI2 is not in maintenance"
126 echo " It is in '$(svcprop -p restarter/state $test_FMRI2)' state,"
127 exit $STF_UNRESOLVED
128 fi
129
130 echo "--INFO: Checking that $test_FMRI1 is online"
131 service_wait_state $test_FMRI1 online
132 if [ $? -ne 0 ]; then
133 echo "--DIAG: $assertion: Service $test_FMRI1 is not online"
134 echo " It is in '$(svcprop -p restarter/state $test_FMRI1)' state,"
135 echo " $test_FMRI2 is in '$(svcprop -p restarter/state $test_FMRI2)'
136 state."
137 exit $STF_FAIL
138 fi
139
140 echo "--INFO: [ Phase 2 ] Transition dependency $test_FMRI3 to maintenance"
141 svcadm mark maintenance $test_FMRI3
142 if [ $? -ne 0 ]; then
143 echo "--DIAG: $assertion: service $test_FMRI3 could not be set to"
144 echo " maintenance mode."
145 exit $STF_UNRESOLVED
146 fi
147 service_wait_state $test_FMRI3 maintenance
148 if [ $? -ne 0 ]; then
149 echo "--DIAG: $assertion: Service $test_FMRI3 is not in maintenance"
150 echo " It is in '$(svcprop -p restarter/state $test_FMRI3)' state,"
151 exit $STF_UNRESOLVED
152 fi
153
154
155 echo "--INFO: Checking that $test_FMRI1 is online"
156 service_wait_state $test_FMRI1 online
157 if [ $? -ne 0 ]; then
158 echo "--DIAG: $assertion: Service $test_FMRI1 is not online"
159 echo " It is in '$(svcprop -p restarter/state $test_FMRI1)' state,"
160 echo " $test_FMRI3 is in '$(svcprop -p restarter/state $test_FMRI3)'
161 state."
162 exit $STF_FAIL
163 fi
164
165 echo "--INFO: [ Phase 3 ] Clear maintenance state of $test_FMRI2"
166 svcadm clear $test_FMRI2
167 if [ $? -ne 0 ]; then
168 echo "--DIAG: $assertion: could not clear maintenance of $test_FMRI2"
169 exit $STF_UNRESOLVED
170 fi
171
172 echo "--INFO: wait for $test_FMRI2 to come online"
173 service_wait_state $test_FMRI2 online
174 if [ $? -ne 0 ]; then
175 echo "--DIAG: $assertion: service $test_FMRI2 is not online"
176 echo " it is in '$(svcprop -p restarter/state $test_FMRI2)' state."
177 exit $STF_UNRESOLVED
178 fi
179
180 echo "--INFO: Checking that $test_FMRI1 is online"
181 service_wait_state $test_FMRI1 online
182 if [ $? -ne 0 ]; then
183 echo "--DIAG: $assertion: Service $test_FMRI1 is not online"
184 echo " It is in '$(svcprop -p restarter/state $test_FMRI1)' state,"
185 echo " $test_FMRI2 is in '$(svcprop -p restarter/state $test_FMRI2)'
186 state."
187 exit $STF_FAIL
188 fi
189
190 echo "--INFO: [Phase 4] clearing maintenance state $test_FMRI3"
191 svcadm clear $test_FMRI3
192 if [ $? -ne 0 ]; then
193 echo "--DIAG: $assertion: service $test_FMRI3 would not clear state"
194 exit $STF_UNRESOLVED
195 fi
196
197 echo "--INFO: check that $test_FMRI1 is online"
198 service_wait_state $test_FMRI1 online
199 if [ $? -ne 0 ]; then
200 echo "--DIAG: $assertion: Service $test_FMRI1 didn't stay online"
201 exit $STF_FAIL
202 fi
203
204 echo "--INFO: [ Phase 5 ] marking maintenance on $test_FMRI3"
205 svcadm mark maintenance $test_FMRI3
206 if [ $? -ne 0 ]; then
207 echo "--DIAG: $assertion: $test_FMRI3 would not mark maintenance"
208 exit $STF_UNRESOLVED
209 fi
210 service_wait_state $test_FMRI3 maintenance
211 if [ $? -ne 0 ]; then
212 echo "--DIAG: $assertion: Service $test_FMRI3 is not in maintenance"
213 echo " It is in '$(svcprop -p restarter/state $test_FMRI3)' state,"
214 exit $STF_UNRESOLVED
215 fi
216
217 echo "--INFO: wait for $test_FMRI1 to go online"
218 service_wait_state $test_FMRI1 online
219 if [ $? -ne 0 ]; then
220 echo "--DIAG: $assertion: service $test_FMRI1 isn't online"
221 echo " It's in '$(svcprop -p restarter/state $test_FMRI1)' state.
222 exit $STF_FAIL"
223 fi
224
225 echo "--INFO: [ Phase 6 ] Clear maintenance state of $test_FMRI3"
226 svcadm clear $test_FMRI3
227 if [ $? -ne 0 ]; then
228 echo "--DIAG: $assertion: could not clear maintenance of $test_FMRI3"
229 exit $STF_UNRESOLVED
230 fi
231
232 echo "--INFO: wait for $test_FMRI3 to come online"
233 service_wait_state $test_FMRI3 online
234 if [ $? -ne 0 ]; then
235 echo "--DIAG: $assertion: service $test_FMRI3 is not online"
236 echo " it is in the '$(svcprop -p restarter/state $test_FMRI3)' state."
237 exit $STF_UNRESOLVED
238 fi
239
240 echo "--INFO: check that $test_FMRI1 is still online"
241 service_wait_state $test_FMRI1 online
242 if [ $? -ne 0 ]; then
243 echo "--DIAG: $assertion: service $test_FMRI1 is not online"
244 echo " it is in the '$(svcprop -p restarter/state $test_FMRI1)' state."
245 exit $STF_FAIL
246 fi
247
248 echo "--INFO: [ Phase 7 ] disabling $test_FMRI2"
249 svcadm disable $test_FMRI2
250 if [ $? -ne 0 ]; then
251 echo "--DIAG: $assertion: service $test_FMRI2 would not disable"
252 exit $STF_UNRESOLVED
253 fi
254
255 echo "--INFO: check that $test_FMRI1 is still online"
256 service_wait_state $test_FMRI1 online
257 if [ $? -ne 0 ]; then
258 echo "--DIAG: $assertion: Service $test_FMRI1 didn't stay online"
259 exit $STF_FAIL
260 fi
261
262 echo "--INFO: [ Phase 8 ] disabling $test_FMRI3"
263 svcadm disable $test_FMRI3
264 if [ $? -ne 0 ]; then
265 echo "--DIAG: $assertion: service $test_FMRI3 would not disable"
266 exit $STF_UNRESOLVED
267 fi
268
269 echo "--INFO: check that $test_FMRI1 is still online"
270 service_wait_state $test_FMRI1 online
271 if [ $? -ne 0 ]; then
272 echo "--DIAG: $assertion: Service $test_FMRI1 didn't stay online"
273 exit $STF_FAIL
274 fi
275
276 echo "--INFO: Cleaning up service"
277 cleanup
278
279 exit $STF_PASS