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: depends_038
  32 # DESCRIPTION:
  33 #  Dependencies can be added to an online service.
  34 #
  35 # end __stf_assertion__
  36 #
  37 
  38 . ${STF_TOOLS}/include/stf.kshlib
  39 . ${STF_SUITE}/include/gltest.kshlib
  40 . ${STF_SUITE}/include/svc.startd_config.kshlib
  41 . ${STF_SUITE}/tests/svc.startd/include/svc.startd_common.kshlib
  42 
  43 # Why are you reading this? the assertion is invalid.
  44 exit $STF_NOTINUSE
  45 
  46 typeset service_setup=0
  47 function cleanup {
  48         common_cleanup
  49         rm -f $service_state1 $service_state2 $service_state3
  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 readonly registration_template=$DATA/service_038.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 svc:/$test_service state"
  73 service_cleanup $test_service
  74 if [ $? -ne 0 ]; then
  75         print -- "--DIAG: $assertion: cleanup of a previous instance failed"
  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_INSTANCE1=$test_instance1 \
  83         TEST_INSTANCE2=$test_instance2 \
  84         TEST_INSTANCE3=$test_instance3 \
  85         SERVICE_APP=$service_app \
  86         LOGFILE=$service_log \
  87         STATEFILE1=$service_state1 \
  88         STATEFILE2=$service_state2 \
  89         STATEFILE3=$service_state3 \
  90         > $registration_file
  91 
  92 print -- "--INFO: Importing service into repository"
  93 manifest_purgemd5 $registration_file
  94 svccfg -v import $registration_file >$svccfg_errfile 2>&1
  95 
  96 if [ $? -ne 0 ]; then
  97         print -- "--DIAG: $assertion: Unable to import svc:/$test_service"
  98         print -- "  error messages from svccfg: "
  99         print -- "  \"$(cat $svccfg_errfile)\""
 100         exit $STF_UNRESOLVED
 101 fi
 102 service_setup=1
 103 
 104 print -- "--INFO: Waiting for $test_FMRI1 to come online"
 105 service_wait_state $test_FMRI1 online
 106 if [ $? -ne 0 ]; then
 107         print -- "--DIAG: $assertion: Service $test_FMRI1 did not come online"
 108         exit $STF_UNRESOLVED
 109 fi
 110 
 111 print -- "--INFO: Wait for $test_FMRI3 to come online"
 112 service_wait_state $test_FMRI3 online
 113 if [ $? -ne 0 ]; then
 114         print -- "--DIAG: $assertion: Service $test_FMRI3 did not go online"
 115         exit $STF_UNRESOLVED
 116 fi
 117 
 118 print -- "--INFO: Remove dependency from $test_FMRI3 -> $test_FMRI1"
 119 service_dependency_elt_remove $test_FMRI3 cdepab svc:/$test_FMRI1
 120 
 121 print -- "--INFO: Refresh $test_FMRI3"
 122 svcadm refresh $test_FMRI3
 123 if [ $? -ne 0 ]; then
 124         print -- "--DIAG: $assertion: Service $test_FMRI3 didn't refresh"
 125         exit $STF_FAIL
 126 fi
 127 
 128 print -- "--INFO: Refresh $test_FMRI2"
 129 svcadm refresh $test_FMRI2
 130 if [ $? -ne 0 ]; then
 131         print -- "--DIAG: $assertion: Service $test_FMRI2 didn't refresh"
 132         exit $STF_FAIL
 133 fi
 134 
 135 print -- "--INFO: Refresh $test_FMRI1"
 136 svcadm refresh $test_FMRI1
 137 if [ $? -ne 0 ]; then
 138         print -- "--DIAG: $assertion: Service $test_FMRI1 didn't refresh"
 139         exit $STF_FAIL
 140 fi
 141 
 142 print -- "--INFO: Verify service $test_FMRI3 is offline"
 143 service_wait_state $test_FMRI3 offline
 144 if [ $? -ne 0 ]; then
 145         print -- "--DIAG: $assertion: Service $test_FMRI3 isn't offline"
 146         exit $STF_FAIL
 147 fi
 148 
 149 print -- "--INFO: Cleaning up service"
 150 cleanup
 151 
 152 exit $STF_PASS