1 #
2 # CDDL HEADER START
3 #
4 # The contents of this file are subject to the terms of the
5 # Common Development and Distribution License (the "License").
6 # You may not use this file except in compliance with the License.
7 #
8 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 # or http://www.opensolaris.org/os/licensing.
10 # See the License for the specific language governing permissions
11 # and limitations under the License.
12 #
13 # When distributing Covered Code, include this CDDL HEADER in each
14 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 # If applicable, add the following below this CDDL HEADER, with the
16 # fields enclosed by brackets "[]" replaced with your own identifying
17 # information: Portions Copyright [yyyy] [name of copyright owner]
18 #
19 # CDDL HEADER END
20 #
21
22 #
23 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
25 #
26
27 . ${STF_TOOLS}/contrib/include/smftest_svc_conversion.shlib
28
29
30 # Purpose:
31 # Run basic service conversion sanity checks on all the
32 # instances of the specified service.
33 #
34 # Arguments:
35 # $1: Path to service manifest file
36 #
37 # Algorithm:
38 # Reload service manifest
39 # foreach service instance
40 # loop SVCCONV_NUM_RETRIES
41 # - enables the service
42 # - checks
43 # - service is running
44 # - disables the service
45 # - checks
46 # - exec method is no longer running (kill)
47 # - stop exec method is run (non-kill stop method)
48 #
49 # restores the services to their original state
50 # /foreach
51 #
52 svcconv_multiple_instances_test() {
53
54 typeset fn_name="svcconv_multiple_instances_test"
55
56 if [ $# -ne 1 ]; then
57 smftest_log "--DIAG: ${fn_name}\n\tIncorrect number of arguments: $#\n\tUsage: ${fn_name} <manifest_path>"
58 smftest_restore_service_state
59 smftest_cleanup
60 exit $STF_UNRESOLVED
61 fi
62
63 SVCCONV_MANIFEST=$1
64
65 # validate manifest
66 smftest_validate_manifest $SVCCONV_MANIFEST
67 smftest_check_retval "$?" "fatal"
68
69 # do setup required...
70 smftest_setup
71
72 # extract svc name, instances, restarter and dependencies...
73 SVCCONV_SERVICES=`smftest_get_svcname_from_manifest $SVCCONV_MANIFEST`
74 smftest_check_retval "$?" "fatal"
75
76 # multiple services can be defined in manifests...
77 for SVCCONV_SERVICE in $SVCCONV_SERVICES
78 do
79 SVCCONV_SERVICE=`smftest_fix_fmri $SVCCONV_SERVICE`
80 smftest_check_retval "$?" "fatal"
81
82 SVCCONV_INSTANCES=`smftest_get_svc_instances $SVCCONV_MANIFEST $SVCCONV_SERVICE`
83 smftest_check_retval "$?" "fatal"
84
85 smftest_reload_service $SVCCONV_MANIFEST $SVCCONV_SERVICE disabled
86
87 SVCCONV_NUM_INSTANCES=`echo $SVCCONV_INSTANCES | wc -w`
88 if [ "$SVCCONV_NUM_INSTANCES" = "0" ]; then
89 smftest_log "--DIAG: ${fn_name}\n\tNo instances defined!"
90 smftest_restore_service_state
91 smftest_cleanup
92 exit $STF_FAIL
93 fi
94
95 for SVCCONV_INSTANCE in $SVCCONV_INSTANCES
96 do
97 smftest_log "--INFO: ${fn_name}\n\tinstance = $SVCCONV_INSTANCE"
98 SVCCONV_INSTANCE_FMRI="${SVCCONV_SERVICE}:${SVCCONV_INSTANCE}"
99 smftest_log "--INFO: ${fn_name}\n\tservice : $SVCCONV_INSTANCE_FMRI"
100
101 SVCCONV_START_METHOD=`smftest_get_svc_start_method $SVCCONV_MANIFEST $SVCCONV_INSTANCE_FMRI`
102 smftest_check_retval "$?" "fatal"
103 SVCCONV_STOP_METHOD=`smftest_get_svc_stop_method $SVCCONV_MANIFEST $SVCCONV_INSTANCE_FMRI`
104 smftest_check_retval "$?" "fatal"
105
106 smftest_log "--INFO: ${fn_name}\n\t${SVCCONV_INSTANCE_FMRI} start method $SVCCONV_START_METHOD"
107 smftest_log "--INFO: ${fn_name}\n\t${SVCCONV_INSTANCE_FMRI} stop method $SVCCONV_STOP_METHOD"
108
109 if [ -z "$SVCCONV_NUM_RETRIES" ]; then
110 SVCCONV_NUM_RETRIES=3
111 fi
112
113 smftest_log "--INFO: ${fn_name}\n\tTest loop to be executed $SVCCONV_NUM_RETRIES times"
114
115 SVCCONV_TSS_COUNT=0
116 while [ "$SVCCONV_TSS_COUNT" -lt "$SVCCONV_NUM_RETRIES" ]; do
117 smftest_log \
118 "--INFO: ${fn_name}\n\tIteration through test loop: $SVCCONV_TSS_COUNT"
119 smftest_check_start_method_run $SVCCONV_INSTANCE_FMRI $SVCCONV_START_METHOD
120
121 SVCCONV_SVC_STATE=`svcs -H $SVCCONV_INSTANCE_FMRI`
122 smftest_log "--INFO: ${fn_name}\n\tState of $SVCCONV_INSTANCE_FMRI is $SVCCONV_SVC_STATE"
123
124 smftest_check_stop_method_run $SVCCONV_INSTANCE_FMRI $SVCCONV_STOP_METHOD
125
126 SVCCONV_SVC_STATE=`svcs -H $SVCCONV_INSTANCE_FMRI`
127 smftest_log "--INFO: ${fn_name}\n\tState of $SVCCONV_INSTANCE_FMRI is $SVCCONV_SVC_STATE"
128 SVCCONV_TSS_COUNT=`expr $SVCCONV_TSS_COUNT + 1`
129 done
130 done
131 done
132
133 smftest_restore_service_state
134
135 smftest_cleanup
136 }