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_025
32 # DESCRIPTION:
33 # Pair of dependent services.
34 # If an online service, service_A, has a dependency on another service,
35 # service_B, and service_B encounters an error and is transitioned
36 # into maintenance mode, then service_A is transitioned offline.
37 # Once service_B transitions to online then service_A will transition
38 # to online as well.
39 #
40 # end __stf_assertion__
41 #
42
43 . ${STF_TOOLS}/include/stf.kshlib
44 . ${STF_SUITE}/include/gltest.kshlib
45 . ${STF_SUITE}/include/svc.startd_config.kshlib
46 . ${STF_SUITE}/tests/svc.startd/include/svc.startd_common.kshlib
47
48 typeset service_setup=0
49 function cleanup {
50 common_cleanup
51 rm -f $service_state1 $service_state2
52 }
53
54 trap cleanup 0 1 2 15
55
56 readonly ME=$(whence -p ${0})
57 readonly MYLOC=$(dirname ${ME})
58
59 DATA=$MYLOC
60
61 readonly registration_template=$DATA/service_025.xml
62
63 extract_assertion_info $ME
64
65 # make sure that the svc.startd is running
66 verify_daemon
67 if [ $? -ne 0 ]; then
68 print -- "--DIAG: $assertion: svc.startd is not executing. Cannot "
69 print -- " continue"
70 exit $STF_UNRESOLVED
71 fi
72
73 # Make sure the environment is clean - the test service isn't running
74 print -- "--INFO: Cleanup any old $test_FMRI1, $test_FMRI2 state"
75 service_cleanup $test_service
76 if [ $? -ne 0 ]; then
77 print -- "--DIAG: $assertion: cleanup of a previous instance failed"
78 exit $STF_UNRESOLVED
79 fi
80
81 print -- "--INFO: generating manifest for importation into repository"
82 manifest_generate $registration_template \
83 TEST_SERVICE=$test_service \
84 TEST_INSTANCE1=$test_instance1 \
85 TEST_INSTANCE2=$test_instance2 \
86 SERVICE_APP=$service_app \
87 LOGFILE=$service_log \
88 STATEFILE1=$service_state1 \
89 STATEFILE2=$service_state2 > $registration_file
90
91 print -- "--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 print -- "--DIAG: $assertion: Unable to import the services $test_FMRI1"
97 print -- " and $test_FMRI2 error messages from svccfg: "
98 print -- " \"$(cat $svccfg_errfile)\""
99 exit $STF_UNRESOLVED
100 fi
101 service_setup=1
102
103 print -- "--INFO: Wait for $test_FMRI2 to come online"
104 service_wait_state $test_FMRI2 online
105 if [ $? -ne 0 ]; then
106 print -- "--DIAG: $assertion: Service $test_FMRI2 dodn't come online"
107 exit $STF_FAIL
108 fi
109
110 print -- "--INFO: Waiting for $test_FMRI1 to come online"
111 service_wait_state $test_FMRI1 online
112 if [ $? -ne 0 ]; then
113 print -- "--DIAG: $assertion: Service $test_FMRI1 did not come online"
114 exit $STF_FAIL
115 fi
116
117 echo "--INFO: Sending $test_FMRI1 to maintenance mode"
118 svcadm mark maintenance $test_FMRI1
119
120 echo "--INFO: Wait for service to enter maintenance mode"
121 service_wait_state $test_FMRI1 maintenance
122 if [ $? -ne 0 ]; then
123 echo "--DIAG: $assertion: Service $test_FMRI1 didn't enter "
124 echo " maintenance mode"
125 exit $STF_FAIL
126 fi
127
128 echo "--INFO: Checking that $test_FMRI2 goes offline"
129 service_wait_state $test_FMRI2 offline
130 if [ $? -ne 0 ]; then
131 echo "--DIAG: $assertion: Service $test_FMRI2 didn't enter "
132 echo " offline mode"
133 exit $STF_FAIL
134 fi
135
136 print -- "--INFO: Cleaning up service"
137 cleanup
138
139 exit $STF_PASS