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: context_031
32 # DESCRIPTION:
33 # Attempting to start a service with an invalid resource_pool
34 # will result in an error. svc.startd will re-attempt to start
35 # the service until the error threshold is reached and, at that
36 # point, the service will be placed into maintenance state.
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/svc.startd/include/svc.startd_common.kshlib
45
46 zone=`/bin/zonename`
47 if [ "$zone" != "global" ]
48 then
49 exit $STF_UNSUPPORTED
50 fi
51
52 typeset service_setup=0
53 function cleanup {
54 common_cleanup
55 }
56
57 trap cleanup 0 1 2 15
58
59 readonly ME=$(whence -p ${0})
60 readonly MYLOC=$(dirname ${ME})
61
62 DATA=$MYLOC
63
64 readonly registration_template=$DATA/service_031.xml
65
66 extract_assertion_info $ME
67
68 # make sure that the svc.startd is running
69 verify_daemon
70 if [ $? -ne 0 ]; then
71 print -- "--DIAG: $assertion: svc.startd is not executing. Cannot "
72 print -- " continue"
73 exit $STF_UNRESOLVED
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 if [ $? -ne 0 ]; then
80 print -- "--DIAG: $assertion: cleanup of a previous instance failed"
81 exit $STF_UNRESOLVED
82 fi
83
84 print -- "--INFO: create world read/writeable log file for the service"
85 rm -f $service_log
86 touch $service_log
87 if [ $? -ne 0 ]; then
88 print -- "--DIAG: $assertion: could not create log file"
89 exit $STF_UNRESOLVED
90 fi
91 chmod a+rw $service_log
92 if [ $? -ne 0 ]; then
93 print -- "--DIAG: $assertion: could not make log file world writeable"
94 exit $STF_UNRESOLVED
95 fi
96 chmod a+rwx $RUNDIR
97 if [ $? -ne 0 ]; then
98 print -- "--DIAG: $assertion: could not make $RUNDIR world rwx"
99 exit $STF_UNRESOLVED
100 fi
101
102 print -- "--INFO: generating manifest for importation into repository"
103 manifest_generate $registration_template \
104 TEST_SERVICE=$test_service \
105 TEST_INSTANCE=$test_instance \
106 SERVICE_APP=$service_app \
107 LOGFILE=$service_log \
108 RESOURCEPOOL=${ctx_resourcepool}_with_badgers \
109 PROJECT=$ctx_project \
110 STATEFILE=$service_state > $registration_file
111 manifest_zone_clean $registration_file
112
113 print -- "--INFO: Importing service into repository"
114 manifest_purgemd5 $registration_file
115 svccfg -v import $registration_file >$svccfg_errfile 2>&1
116
117 if [ $? -ne 0 ]; then
118 print -- "--DIAG: $assertion: Unable to import the service $test_FMRI"
119 print -- " error messages from svccfg: \"$(cat $svccfg_errfile)\""
120 exit $STF_UNRESOLVED
121 fi
122 service_setup=1
123
124 print -- "--INFO: Wait for $test_FMRI to enter maintenance state"
125 service_wait_state $test_FMRI maintenance
126 if [ $? -ne 0 ]; then
127 print -- "--DIAG: $assertion: Service $test_FMRI did not"
128 print -- " enter maintenance state."
129 print -- " It's in '$(svcs -H -o STATE $test_FMRI)' state."
130 exit $STF_FAIL
131 fi
132
133 print -- "--INFO: Cleaning up service"
134 cleanup
135
136 exit $STF_PASS