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_020
  32 # DESCRIPTION:
  33 #  Service with a multiple processes
  34 #  If all processes associated with an online service exit then the 
  35 #  svc.startd should attempt to restart the service.
  36 #
  37 # end __stf_assertion__
  38 #
  39 
  40 . ${STF_TOOLS}/include/stf.kshlib
  41 . ${STF_SUITE}/include/gltest.kshlib
  42 . ${STF_SUITE}/include/svc.startd_config.kshlib
  43 . ${STF_SUITE}/tests/include/svc.startd_fileops.kshlib
  44 . ${STF_SUITE}/tests/svc.startd/include/svc.startd_common.kshlib
  45 
  46 typeset service_setup=0
  47 function cleanup {
  48         common_cleanup
  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_020.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 the environment is clean - the test service isn't running
  71 print -- "--INFO: Cleanup any old $test_FMRI state"
  72 service_cleanup $test_service
  73 rm -f $service_state
  74 if [ $? -ne 0 ]; then
  75         print -- "--DIAG: $assertion: unable to clean up any pre-existing state"
  76         exit $STF_UNRESOLVED
  77 fi
  78 
  79 print -- "--INFO: generating manifest for importation into repository"
  80 manifest_generate $registration_template \
  81         TEST_SERVICE=$test_service \
  82         TEST_INSTANCE=$test_instance \
  83         SERVICE_APP=$service_app \
  84         LOGFILE=$service_log \
  85         STATEFILE=$service_state \
  86         > $registration_file
  87 
  88 print -- "--INFO: Importing service into repository"
  89 manifest_purgemd5 $registration_file
  90 svccfg -v import $registration_file >$svccfg_errfile 2>&1
  91 if [ $? -ne 0 ]; then
  92         print -- "--DIAG: $assertion: Unable to import the service $test_FMRI"
  93         print -- "  error messages from svccfg: \"$(cat $svccfg_errfile)\""
  94         exit $STF_UNRESOLVED
  95 fi
  96 service_setup=1
  97 
  98 print -- "--INFO: enabling $test_FMRI"
  99 svcadm enable $test_FMRI
 100 if [ $? -ne 0 ]; then
 101         print -- "--DIAG: $assertion: enable command of $test_FMRI failed"
 102         exit $STF_FAIL
 103 fi
 104 
 105 print -- "--INFO: waiting for execution of start method"
 106 service_wait_method $test_FMRI start
 107 if [ $? -ne 0 ]; then
 108         print -- "--DIAG: $assertion: Service $test_FMRI didn't issue start"
 109         exit $STF_UNRESOLVED
 110 fi
 111 
 112 print -- "--INFO: Validating service reaches online mode"
 113 service_wait_state $test_FMRI online
 114 if [ $? -ne 0 ]; then
 115         print -- "--DIAG: $assertion: Service $test_FMRI didn't"
 116         print -- "  transition to online mode"
 117         exit $STF_FAIL
 118 fi
 119 
 120 print -- "--INFO: make one service process stop... use dummy method"
 121 $service_app -s $test_service -i $test_instance \
 122         -m trigger -r "triggerchildrv 0 0" -l $service_log
 123 
 124 print -- "--INFO: Waiting for start method to be invoked (it should not)"
 125 service_wait_method $test_FMRI start
 126 if [ $? -eq 0 ]; then
 127         print -- "--DIAG: $assertion: start method was invoked in error"
 128         exit $STF_FAIL
 129 fi
 130 
 131 print -- "--INFO: checking service is still online"
 132 service_check_state $test_FMRI online
 133 if [ $? -ne 0 ]; then
 134         print -- "--DIAG: $assertion: service is not online"
 135         exit $STF_FAIL
 136 fi
 137 
 138 SPIDS=`service_getpids -s $test_service -i $test_instance`
 139 print -- "--INFO: service pids are: $SPIDS"
 140 
 141 print -- "--INFO: make the other service process exit"
 142 $service_app -s $test_service -i $test_instance \
 143         -m trigger -r "triggerchildrv 1 0" -l $service_log
 144 
 145 print -- "--INFO: Waiting for start method to be invoked"
 146 service_wait_method $test_FMRI start
 147 if [ $? -ne 0 ]; then
 148         print -- "--DIAG: $assertion: start method was not invoked"
 149         exit $STF_FAIL
 150 fi
 151 
 152 print -- "--INFO: Waiting for service to reach online state"
 153 service_wait_state $test_FMRI online
 154 if [ $? -ne 0 ]; then
 155         print -- "--DIAG: $assertion: service $test_FMRI didn't"
 156         print -- "  come online"
 157         exit $STF_FAIL
 158 fi
 159 
 160 print -- "--INFO: Cleaning up service"
 161 
 162 cleanup
 163 
 164 exit $STF_PASS