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_006
32 # DESCRIPTION:
33 # A service with multiple dependencies in a "require_any" grouping
34 # property is set in a service's definition. Once at least one of the
35 # dependencies are satisfied then the svc.startd will transition
36 # the service into the online state.
37 # Services: a, b, c; a depends on b and c in a require_any relationship
38 #
39 # end __stf_assertion__
40 #
41
42 . ${STF_TOOLS}/include/stf.kshlib
43 . ${STF_SUITE}/include/gltest.kshlib
44 . ${STF_SUITE}/include/svc.startd_config.kshlib
45 . ${STF_SUITE}/tests/svc.startd/include/svc.startd_common.kshlib
46
47 typeset service_setup=0
48 function cleanup {
49 common_cleanup
50 rm -f $service_state1 $service_state2 $service_state3
51 }
52
53 trap cleanup 0 1 2 15
54
55 readonly ME=$(whence -p ${0})
56 readonly MYLOC=$(dirname ${ME})
57
58 DATA=$MYLOC
59
60 readonly registration_template=$DATA/service_006.xml
61
62 extract_assertion_info $ME
63
64 # make sure that the svc.startd is running
65 verify_daemon
66 if [ $? -ne 0 ]; then
67 print -- "--DIAG: $assertion: svc.startd is not executing. Cannot "
68 print -- " continue"
69 exit $STF_UNRESOLVED
70 fi
71
72 # Make sure the environment is clean - the test service isn't running
73 print -- "--INFO: Cleanup any old $test_FMRI1, $test_FMRI2, $test_FMRI3 state"
74 service_cleanup $test_service
75 if [ $? -ne 0 ]; then
76 print -- "--DIAG: $assertion: cleanup of a previous instance failed"
77 exit $STF_UNRESOLVED
78 fi
79
80 print -- "--INFO: generating manifest for importation into repository"
81 manifest_generate $registration_template \
82 TEST_SERVICE=$test_service \
83 TEST_INSTANCE1=$test_instance1 \
84 TEST_INSTANCE2=$test_instance2 \
85 TEST_INSTANCE3=$test_instance3 \
86 SERVICE_APP=$service_app \
87 LOGFILE=$service_log \
88 STATEFILE1=$service_state1 \
89 STATEFILE2=$service_state2 \
90 STATEFILE3=$service_state3 \
91 > $registration_file
92
93 print -- "--INFO: Importing service into repository"
94 manifest_purgemd5 $registration_file
95 svccfg -v import $registration_file >$svccfg_errfile 2>&1
96
97 if [ $? -ne 0 ]; then
98 print -- "--DIAG: $assertion: Unable to import the services $test_FMRI1"
99 print -- " $test_FMRI2 and $test_FMRI3 error messages from svccfg: "
100 print -- " \"$(cat $svccfg_errfile)\""
101 exit $STF_UNRESOLVED
102 fi
103 service_setup=1
104
105 print -- "--INFO: Wait for $test_FMRI3 to come online - it should not"
106 service_wait_state $test_FMRI3 online
107 if [ $? -eq 0 ]; then
108 print -- "--DIAG: $assertion: Service $test_FMRI3 came online"
109 exit $STF_FAIL
110 fi
111
112 print -- "--INFO: Enabling service $test_FMRI1"
113 svcadm enable $test_FMRI1
114 if [ $? -ne 0 ]; then
115 print -- "--DIAG: $assertion: Service $test_FMRI1 did not enable"
116 exit $STF_FAIL
117 fi
118
119 print -- "--INFO: Waiting for $test_FMRI1 to come online"
120 service_wait_state $test_FMRI1 online
121 if [ $? -ne 0 ]; then
122 print -- "--DIAG: $assertion: Service $test_FMRI1 did not come online"
123 exit $STF_FAIL
124 fi
125
126 print -- "--INFO: Wait for $test_FMRI3 to come online - it should"
127 service_wait_state $test_FMRI3 online
128 if [ $? -ne 0 ]; then
129 print -- "--DIAG: $assertion: Service $test_FMRI3 didn't come online"
130 print -- " it is in the '$(svcs -H -o STATE $test_FMRI3)' state"
131 exit $STF_FAIL
132 fi
133
134 print -- "--INFO: Disabling service $test_FMRI1"
135 svcadm disable $test_FMRI1
136 if [ $? -ne 0 ]; then
137 print -- "--DIAG: $assertion: Service $test_FMRI1 did not disable"
138 exit $STF_FAIL
139 fi
140
141 print -- "--INFO: Waiting for $test_FMRI1 to go disabled"
142 service_wait_state $test_FMRI1 disabled
143 if [ $? -ne 0 ]; then
144 print -- "--DIAG: $assertion: Service $test_FMRI1 did not goto disabled"
145 exit $STF_FAIL
146 fi
147
148 print -- "--INFO: Verifying that $test_FMRI3 goes offline"
149 service_wait_state $test_FMRI3 offline
150 if [ $? -ne 0 ]; then
151 print -- "--DIAG: $assertion: Service $test_FMRI3 did not go offline"
152 print -- " it is in the '$(svcs -H -o STATE $test_FMRI3)' state"
153 exit $STF_FAIL
154 fi
155
156 print -- "--INFO: Disabling $test_FMRI3"
157 svcadm disable $test_FMRI3
158 if [ $? -ne 0 ]; then
159 print -- "--DIAG: $assertion: Service $test_FMRI3 did not disable"
160 exit $STF_FAIL
161 fi
162
163 print -- "--INFO: Waiting for $test_FMRI3 to go disabled"
164 service_wait_state $test_FMRI3 disabled
165 if [ $? -ne 0 ]; then
166 print -- "--DIAG: $assertion: Service $test_FMRI3 did not goto disabled"
167 print -- " it's in: '$(svcs -H -o STATE $test_FMRI3)'"
168 exit $STF_FAIL
169 fi
170
171 print -- "--INFO: Enabling $test_FMRI3"
172 svcadm enable $test_FMRI3
173 if [ $? -ne 0 ]; then
174 print -- "--DIAG: $assertion: Service $test_FMRI3 did not enable"
175 exit $STF_FAIL
176 fi
177
178 print -- "--INFO: Waiting for $test_FMRI3 to stay offline"
179 service_wait_state $test_FMRI3 offline
180 if [ $? -ne 0 ]; then
181 print -- "--DIAG: $assertion: Service $test_FMRI3 did not goto offline"
182 print -- " it is in the '$(svcs -H -o STATE $test_FMRI3)' state"
183 exit $STF_FAIL
184 fi
185
186 print -- "--INFO: Enabling service $test_FMRI2"
187 svcadm enable $test_FMRI2
188 if [ $? -ne 0 ]; then
189 print -- "--DIAG: $assertion: Service $test_FMRI2 did not enable"
190 exit $STF_FAIL
191 fi
192
193 print -- "--INFO: Waiting for $test_FMRI2 to come online"
194 service_wait_state $test_FMRI2 online
195 if [ $? -ne 0 ]; then
196 print -- "--DIAG: $assertion: Service $test_FMRI2 did not come online"
197 exit $STF_FAIL
198 fi
199
200 print -- "--INFO: Waiting for $test_FMRI3 to come online"
201 service_wait_state $test_FMRI3 online
202 if [ $? -ne 0 ]; then
203 print -- "--DIAG: $assertion: Service $test_FMRI3 did not come online"
204 print -- " it is in the '$(svcs -H -o STATE $test_FMRI3)' state"
205 exit $STF_FAIL
206 fi
207
208 print -- "--INFO: Cleaning up service"
209 cleanup
210
211 exit $STF_PASS