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: methods_030
32 # DESCRIPTION:
33 # The service possesses more than one process.
34 # If a service instance in the degraded state dies due to a hwerr
35 # then the svc.startd should attempt to restart the service.
36 # end __stf_assertion__
37 #
38
39 . ${STF_TOOLS}/include/stf.kshlib
40 . ${STF_SUITE}/include/gltest.kshlib
41 . ${STF_SUITE}/include/svc.startd_config.kshlib
42 . ${STF_SUITE}/tests/include/svc.startd_fileops.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 }
49
50 trap cleanup 0 1 2 15
51
52 readonly ME=$(whence -p ${0})
53 readonly MYLOC=$(dirname ${ME})
54
55 DATA=$MYLOC
56
57 registration_template=$DATA/service_030.xml
58
59 extract_assertion_info $ME
60
61 # make sure that the svc.startd is running
62 verify_daemon
63 if [ $? -ne 0 ]; then
64 print -- "--DIAG: $assertion: svc.startd is not executing. Cannot "
65 print -- " continue"
66 exit $STF_UNRESOLVED
67 fi
68
69 # make sure that the features are available
70 features=`feature_test MTST`
71 if [ $? -ne 0 ]; then
72 print -- "--DIAG: $assertion: $features missing from startd"
73 exit $STF_UNTESTED
74 fi
75
76 # Make sure the environment is clean - the test service isn't running
77 print -- "--INFO: Cleanup any old $test_FMRI state"
78 service_cleanup $test_service
79 rm -f $service_state
80 if [ $? -ne 0 ]; then
81 print -- "--DIAG: $assertion: unable to clean up any pre-existing state"
82 exit $STF_UNRESOLVED
83 fi
84
85 print -- "--INFO: generating manifest for importation into repository"
86 manifest_generate $registration_template \
87 TEST_SERVICE=$test_service \
88 TEST_INSTANCE=$test_instance \
89 SERVICE_APP=$service_app \
90 LOGFILE=$service_log \
91 STATEFILE=$service_state \
92 MONITOR_RESULT="returncode $SVC_DEGRADED" \
93 > $registration_file
94
95 print -- "--INFO: Importing service into repository"
96 manifest_purgemd5 $registration_file
97 svccfg -v import $registration_file >$svccfg_errfile 2>&1
98 if [ $? -ne 0 ]; then
99 print -- "--DIAG: $assertion: Unable to import the service $test_FMRI"
100 print -- " error messages from svccfg: \"$(cat $svccfg_errfile)\""
101 exit $STF_UNRESOLVED
102 fi
103 service_setup=1
104
105 print -- "--INFO: enabling $test_FMRI"
106 svcadm enable $test_FMRI
107 if [ $? -ne 0 ]; then
108 print -- "--DIAG: $assertion: enable command of $test_FMRI failed"
109 exit $STF_FAIL
110 fi
111
112 print -- "--INFO: waiting for execution of start method"
113 service_wait_method $test_FMRI start
114 if [ $? -ne 0 ]; then
115 print -- "--DIAG: $assertion: Service $test_FMRI didn't issue start"
116 exit $STF_UNRESOLVED
117 fi
118
119 print -- "--INFO: sending service to degraded state"
120 svcadm mark degraded $test_FMRI
121 if [ $? -ne 0 ]; then
122 print -- "--DIAG: Could not send service $test_FMRI to degraded"
123 exit $STF_FAIL
124 fi
125
126 print -- "--INFO: Validating service reaches degraded mode"
127 service_wait_state $test_FMRI degraded
128 if [ $? -ne 0 ]; then
129 print -- "--DIAG: $assertion: Service $test_FMRI didn't"
130 print -- " transition to degraded mode"
131 exit $STF_FAIL
132 fi
133
134 PIDS=`service_getpids -s $test_service -i $test_instance -f $service_state`
135 print -- "--INFO: child pids are: $PIDS"
136
137 echo $pids | read pid1 pid2
138
139 # pad run log
140 $service_app -s $test_service -i $test_instance -l $service_log -m "blank"
141
142 print -- "--INFO: issue a hwerr via service pid $pid2"
143 $service_app -s $test_service -i $test_instance -l $service_log -m "trigger" \
144 -r "forkexec 1 mtst udue"
145
146 print -- "--INFO: Waiting for service's start method"
147 service_wait_method $test_FMRI start
148 if [ $? -ne 0 ]; then
149 print -- "--DIAG: $assertion: didn't issue start method"
150 exit $STF_FAIL
151 fi
152
153 print -- "--INFO: verify that process $pid1 is no longer executing"
154 kill -0 $pid1
155 if [ $? -ne 0 ]; then
156 print -- "--DIAG: service $pid1 is still executing"
157 exit $STF_FAIL
158 fi
159
160 print -- "--INFO: Waiting for service to reach degraded state"
161 service_wait_state $test_FMRI degraded
162 if [ $? -ne 0 ]; then
163 print -- "--DIAG: $assertion: service $test_FMRI didn't"
164 print -- " come degraded"
165 exit $STF_FAIL
166 fi
167
168 print -- "--INFO: Cleaning up service"
169 cleanup
170
171 exit $STF_PASS