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_026
32 # DESCRIPTION:
33 # A service possesses more than one process.
34 # If a service instance in the degraded state dies due to receipt of
35 # a fatal signal from another process then the svc.startd should attempt
36 # to restart the service.
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/include/svc.startd_fileops.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 }
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 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 # Make sure the environment is clean - the test service isn't running
72 print -- "--INFO: Cleanup any old $test_FMRI state"
73 service_cleanup $test_service
74 rm -f $service_state
75 if [ $? -ne 0 ]; then
76 print -- "--DIAG: $assertion: unable to clean up any pre-existing state"
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_INSTANCE=$test_instance \
84 SERVICE_APP=$service_app \
85 LOGFILE=$service_log \
86 STATEFILE=$service_state \
87 MONITOR_RESULT="returncode $SVC_DEGRADED" \
88 > $registration_file
89
90 print -- "--INFO: Importing service into repository"
91 manifest_purgemd5 $registration_file
92 svccfg -v import $registration_file >$svccfg_errfile 2>&1
93 if [ $? -ne 0 ]; then
94 print -- "--DIAG: $assertion: Unable to import the service $test_FMRI"
95 print -- " error messages from svccfg: \"$(cat $svccfg_errfile)\""
96 exit $STF_UNRESOLVED
97 fi
98 service_setup=1
99
100 print -- "--INFO: enabling $test_FMRI"
101 svcadm enable $test_FMRI
102 if [ $? -ne 0 ]; then
103 print -- "--DIAG: $assertion: enable command of $test_FMRI failed"
104 exit $STF_FAIL
105 fi
106
107 print -- "--INFO: waiting for execution of start method"
108 service_wait_method $test_FMRI start
109 if [ $? -ne 0 ]; then
110 print -- "--DIAG: $assertion: Service $test_FMRI didn't issue start"
111 exit $STF_UNRESOLVED
112 fi
113
114 print -- "--INFO: sending service to degraded state"
115 svcadm mark degraded $test_FMRI
116 if [ $? -ne 0 ]; then
117 print -- "--DIAG: Could not send service $test_FMRI to degraded"
118 exit $STF_FAIL
119 fi
120
121 print -- "--INFO: Validating service reaches degraded mode"
122 service_wait_state $test_FMRI degraded
123 if [ $? -ne 0 ]; then
124 print -- "--DIAG: $assertion: Service $test_FMRI didn't"
125 print -- " transition to degraded mode"
126 exit $STF_FAIL
127 fi
128
129 PIDS=`service_getpids -s $test_service -i $test_instance -f $service_state`
130 print -- "--INFO: child pids are: $PIDS"
131
132 echo $pids | read pid1 pid2
133
134 # pad run log
135 $service_app -s $test_service -i $test_instance -l $service_log -m "blank"
136
137 print -- "--INFO: issue a kill to the service pid $pid2"
138 kill $pid2
139 if [ $? -ne 0 ]; then
140 print "--DIAG: $assertion: could not issue kill to $pid2"
141 exit $STF_UNRESOLVED
142 fi
143
144 print -- "--INFO: Waiting for service's start method"
145 service_wait_method $test_FMRI start
146 if [ $? -ne 0 ]; then
147 print -- "--DIAG: $assertion: didn't issue start method"
148 exit $STF_FAIL
149 fi
150
151 print -- "--INFO: verify that process $pid1 is no longer executing"
152 kill -0 $pid1
153 if [ $? -ne 0 ]; then
154 print -- "--DIAG: service $pid1 is still executing"
155 exit $STF_FAIL
156 fi
157
158 print -- "--INFO: Waiting for service to reach degraded state"
159 service_wait_state $test_FMRI degraded
160 if [ $? -ne 0 ]; then
161 print -- "--DIAG: $assertion: service $test_FMRI didn't"
162 print -- " come degraded"
163 exit $STF_FAIL
164 fi
165
166 print -- "--INFO: Cleaning up service"
167 cleanup
168
169 exit $STF_PASS