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_005
32 # DESCRIPTION:
33 # A service that is online is given a request to refresh. It's refresh
34 # method will be invoked, and the service will not be stopped.
35 #
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/svc.startd/include/svc.startd_common.kshlib
43
44 typeset service_setup=0
45 function cleanup {
46 rm -f $svcadm_errfile
47 common_cleanup
48 return $?
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 registration_template=$DATA/service_005.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 print -- "--DIAG: $assertion: svc.startd is not executing. Cannot "
66 print -- "continue"
67 exit $STF_UNRESOLVED
68 fi
69
70 # make sure that the features are available
71 features=`feature_test REFRESH`
72 if [ $? -ne 0 ]; then
73 print -- "--DIAG: $assertion: $features missing from startd"
74 exit $STF_UNTESTED
75 fi
76
77 # Make sure the environment is clean - the test service isn't running
78 print -- "--INFO: Cleanup any old $test_FMRI state"
79 service_cleanup $test_service
80 rm -f $service_state
81 if [ $? -ne 0 ]; then
82 print -- "--DIAG: $assertion: cleanup of a previous instance failed"
83 exit $STF_UNRESOLVED
84 fi
85
86 print -- "--INFO: generating manifest for importation into repository"
87 manifest_generate $registration_template \
88 TEST_SERVICE=$test_service \
89 TEST_INSTANCE=$test_instance \
90 SERVICE_APP=$service_app \
91 LOGFILE=$service_log \
92 STATEFILE=$service_state \
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
99 if [ $? -ne 0 ]; then
100 print -- "--DIAG: $assertion: Unable to import the service $test_FMRI"
101 print -- " error messages from svccfg: \"$(cat $svccfg_errfile)\""
102 exit $STF_UNRESOLVED
103 fi
104 service_setup=1
105
106 print -- "--INFO: Wait for $test_FMRI to come online"
107 service_wait_state $test_FMRI online
108 if [ $? -ne 0 ]; then
109 print -- "--DIAG: $assertion: Service $test_FMRI didn't go online"
110 exit $STF_FAIL
111 fi
112
113 print -- "--INFO: refreshing service"
114 svcadm refresh $test_FMRI >$svcadm_errfile 2>&1
115 if [ $? -ne 0 -o -s $svcadm_errfile ]; then
116 print -- "--DIAG: $assertion: refresh command for Service "
117 print -- " $test_FMRI didn't succeed."
118 print -- " error message from command: \"$(cat $svcadm_errfile)\""
119 exit $STF_UNRESOLVED
120 fi
121
122 print -- "--INFO: Waiting for issue of $test_FMRI refresh method"
123 service_wait_method $test_FMRI refresh
124 if [ $? -ne 0 ]; then
125 print -- "--DIAG: $assertion: Service $test_FMRI didn't refresh"
126 exit $STF_FAIL
127 fi
128
129 print -- "--INFO: Validating no invocation of stop method"
130 service_offsetcall -f $service_state -s $test_service -i $test_instance stop
131 lastcalled=$?
132 if [ "$lastcalled" != "255" ]; then
133 print -- "--DIAG: $assertion: Service $test_FMRI called stop method"
134 print -- " when it shouldn't have"
135 exit $STF_FAIL
136 fi
137
138 print -- "--INFO: Cleaning up service"
139 cleanup
140
141 exit $STF_PASS