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_039
  32 # DESCRIPTION:
  33 #  Dependencies can be removed from an offline service. If the
  34 #  dependency that is removed is the only dependency the offline service
  35 #  is dependent on then the service should transition to online.
  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/svc.startd/include/svc.startd_common.kshlib
  44 
  45 typeset service_setup=0
  46 function cleanup {
  47         common_cleanup
  48         rm -f $service_state1 $service_state2
  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 readonly registration_template=$DATA/service_039.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_FMRI1, $test_FMRI2 state"
  72 service_cleanup $test_service
  73 if [ $? -ne 0 ]; then
  74         print -- "--DIAG: $assertion: cleanup of a previous instance failed"
  75         exit $STF_UNRESOLVED
  76 fi
  77 
  78 print -- "--INFO: generating manifest for importation into repository"
  79 manifest_generate $registration_template \
  80         TEST_SERVICE=$test_service \
  81         TEST_INSTANCE1=$test_instance1 \
  82         TEST_INSTANCE2=$test_instance2 \
  83         SERVICE_APP=$service_app \
  84         LOGFILE=$service_log \
  85         STATEFILE1=$service_state1 \
  86         STATEFILE2=$service_state2 > $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 
  92 if [ $? -ne 0 ]; then
  93         print -- "--DIAG: $assertion: Unable to import the services $test_FMRI1"
  94         print -- "  and $test_FMRI2 error messages from svccfg: "
  95         print -- "  \"$(cat $svccfg_errfile)\""
  96         exit $STF_UNRESOLVED
  97 fi
  98 service_setup=1
  99 
 100 print -- "--INFO: Waiting for $test_FMRI2 to go to offline"
 101 service_wait_state $test_FMRI2 offline
 102 if [ $? -ne 0 ]; then
 103         print -- "--DIAG: $assertion: Service $test_FMRI2 did not go to offline"
 104         exit $STF_FAIL
 105 fi
 106 
 107 print -- "--INFO: Remove dependency from $test_FMRI2 -> $test_FMRI1"
 108 service_dependency_remove $test_FMRI2 bdepa
 109 
 110 print -- "--INFO: Refresh $test_FMRI2"
 111 svcadm refresh $test_FMRI2
 112 if [ $? -ne 0 ]; then
 113         print -- "--DIAG: $assertion: Service $test_FMRI2 didn't refresh"
 114         exit $STF_FAIL
 115 fi
 116 
 117 print -- "--INFO: Verfify service $test_FMRI2 is online"
 118 service_wait_state $test_FMRI2 online
 119 if [ $? -ne 0 ]; then
 120         print -- "--DIAG: $assertion: Service $test_FMRI2 isn't online"
 121         exit $STF_FAIL
 122 fi
 123 
 124 print -- "--INFO: Disable the service $test_FMRI1"
 125 svcadm disable $test_FMRI1
 126 if [ $? -ne 0 ]; then
 127         print -- "--DIAG: could not disable $test_FMRI1"
 128         exit $STF_FAIL
 129 fi
 130 
 131 print -- "--INFO: validating service $test_FMRI2 stays online"
 132 service_wait_state $test_FMRI2 offline
 133 if [ $? -eq 0 ]; then
 134         print -- "--DIAG: service $test_FMRI2 went offline"
 135         exit $STF_FAIL
 136 fi
 137 
 138 print -- "--INFO: Cleaning up service"
 139 cleanup
 140 
 141 exit $STF_PASS