t_smf.py revision 3046
2310N/A#!/usr/bin/python
2310N/A#
2310N/A# CDDL HEADER START
2310N/A#
2310N/A# The contents of this file are subject to the terms of the
2310N/A# Common Development and Distribution License (the "License").
2310N/A# You may not use this file except in compliance with the License.
2310N/A#
2310N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2310N/A# or http://www.opensolaris.org/os/licensing.
2310N/A# See the License for the specific language governing permissions
2310N/A# and limitations under the License.
2310N/A#
2310N/A# When distributing Covered Code, include this CDDL HEADER in each
2310N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2310N/A# If applicable, add the following below this CDDL HEADER, with the
2310N/A# fields enclosed by brackets "[]" replaced with your own identifying
2310N/A# information: Portions Copyright [yyyy] [name of copyright owner]
2310N/A#
2310N/A# CDDL HEADER END
2310N/A#
2310N/A
3014N/A# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
2310N/A
2310N/Aimport testutils
2310N/Aif __name__ == "__main__":
2310N/A testutils.setup_environment("../../../proto")
2310N/A
2310N/Aimport os
2310N/Aimport pkg5unittest
2310N/Aimport unittest
2310N/A
2310N/Aimport pkg.smf as smf
2310N/A
3046N/Afrom pkg.client.debugvalues import DebugValues
3046N/A
2310N/Aclass TestSMF(pkg5unittest.SingleDepotTestCase):
2310N/A # Only start/stop the depot once (instead of for every test)
2310N/A persistent_setup = True
2310N/A
2310N/A smf_cmds = { \
2310N/A "usr/bin/svcprop" : """\
2310N/A#!/usr/bin/python
2310N/A
2310N/Aimport getopt
2310N/Aimport os
2310N/Aimport sys
2310N/A
2310N/Aif __name__ == "__main__":
2310N/A try:
2310N/A opts, pargs = getopt.getopt(sys.argv[1:], "cp:")
2310N/A except getopt.GetoptError, e:
2310N/A usage(_("illegal global option -- %s") % e.opt)
2310N/A
2310N/A found_c = False
2310N/A prop = None
2310N/A for opt, arg in opts:
2310N/A if opt == "-c":
2310N/A found_c = True
2310N/A elif opt == "-p":
2310N/A prop = arg
2310N/A with open(os.path.join(os.environ["PKG_TEST_DIR"],
2310N/A os.environ["PKG_SVCPROP_OUTPUT"]), "rb") as fh:
2310N/A s = fh.read()
2310N/A if prop:
2310N/A prop_dict = {}
2310N/A for l in s.splitlines():
2310N/A t = l.split(None, 2)
2310N/A if len(t) == 3:
2310N/A prop_dict[t[0]] = t[2]
2310N/A prop = prop_dict.get(prop, None)
2310N/A if not found_c or not prop:
2310N/A sys.exit(1)
2310N/A print prop
2310N/A sys.exit(0)
2310N/A print s
2310N/A sys.exit(0)
2310N/A""",
2310N/A "usr/sbin/svcadm" : \
2310N/A"""#!/bin/sh
2310N/Aecho $0 "$@" >> $PKG_TEST_DIR/svcadm_arguments
2310N/Aexit $PKG_SVCADM_EXIT_CODE
2310N/A""",
2310N/A "usr/bin/svcs" : \
2310N/A"""#!/bin/sh
2310N/A
2310N/A# called from pkg.client.actuator using 'svcs -H -o fmri <string>'
2310N/A# so $4 is the FMRI pattern that we're interested in resolving
2310N/ARETURN=0
2310N/A
2310N/Acase $4 in
2310N/A svc:/system/test_refresh_svc:default)
2310N/A FMRI=$4
2310N/A ;;
2310N/A svc:/system/test_multi_svc?:default)
2310N/A FMRI=$4
2310N/A ;;
2310N/A # the following are too relaxed, eg.
2310N/A # "svcs sys/foo/tZst_suspend_svc:defXX"
2310N/A # would match, but is sufficient for this test case as we only
2310N/A # ever resolve services that truely exist here.
2310N/A *sy*t?st_suspend_svc:def*)
2310N/A FMRI=svc:/system/test_suspend_svc:default
2310N/A ;;
2310N/A *test_disable_svc*)
2310N/A FMRI=svc:/system/test_disable_svc:default
2310N/A ;;
2310N/A *test_restart_svc*)
2310N/A FMRI=svc:/system/test_restart_svc:default
2310N/A ;;
2310N/A *)
2310N/A FMRI="ERROR - t_actuators.py svcs wrapper failed to match $4"
2310N/A RETURN=1
2310N/A ;;
2310N/Aesac
2310N/Aecho $FMRI
2310N/Aexit $RETURN
3046N/A""",
3046N/A "bin_zlogin" : \
3046N/A"""#!/bin/ksh
3046N/Azone_name=$1
3046N/Ashift
3046N/Aecho "zlogin $zone_name" >> $PKG_TEST_DIR/zlogin_arguments
3046N/A($*)""",
2310N/A}
2310N/A misc_files = { \
2310N/A "svcprop_enabled" :
2310N/A"""general/enabled boolean true
2310N/Ageneral/entity_stability astring Unstable
2310N/Ageneral/single_instance boolean true
2310N/Arestarter/start_pid count 4172
2310N/Arestarter/start_method_timestamp time 1222382991.639687000
2310N/Arestarter/start_method_waitstatus integer 0
2310N/Arestarter/transient_contract count
2310N/Arestarter/auxiliary_state astring none
2310N/Arestarter/next_state astring none
2310N/Arestarter/state astring online
2310N/Arestarter/state_timestamp time 1222382991.644413000
2310N/Arestarter_actions/refresh integer
2310N/Arestarter_actions/maint_on integer
2310N/Arestarter_actions/maint_off integer
2310N/Arestarter_actions/restart integer
2310N/Alocal-filesystems/entities fmri svc:/system/filesystem/local
2310N/Alocal-filesystems/grouping astring require_all
2310N/Alocal-filesystems/restart_on astring none
2310N/Alocal-filesystems/type astring service
2310N/Aremote-filesystems/entities fmri svc:/network/nfs/client svc:/system/filesystem/autofs
2310N/Aremote-filesystems/grouping astring optional_all
2310N/Aremote-filesystems/restart_on astring none
2310N/Aremote-filesystems/type astring service
2310N/Astartd/duration astring transient
2310N/Astart/timeout_seconds count 0
2310N/Astart/type astring method
2310N/Astop/exec astring :true
2310N/Astop/timeout_seconds count 0
2310N/Astop/type astring method""",
2310N/A
2310N/A "svcprop_disabled" :
2310N/A"""general/enabled boolean false
2310N/Ageneral/entity_stability astring Unstable
2310N/Ageneral/single_instance boolean true
2310N/Arestarter/start_pid count 4172
2310N/Arestarter/start_method_timestamp time 1222382991.639687000
2310N/Arestarter/start_method_waitstatus integer 0
2310N/Arestarter/transient_contract count
2310N/Arestarter/auxiliary_state astring none
2310N/Arestarter/next_state astring none
2310N/Arestarter/state astring disabled
2310N/Arestarter/state_timestamp time 1222992132.445811000
2310N/Arestarter_actions/refresh integer
2310N/Arestarter_actions/maint_on integer
2310N/Arestarter_actions/maint_off integer
2310N/Arestarter_actions/restart integer
2310N/Alocal-filesystems/entities fmri svc:/system/filesystem/local
2310N/Alocal-filesystems/grouping astring require_all
2310N/Alocal-filesystems/restart_on astring none
2310N/Alocal-filesystems/type astring service
2310N/Aremote-filesystems/entities fmri svc:/network/nfs/client svc:/system/filesystem/autofs
2310N/Aremote-filesystems/grouping astring optional_all
2310N/Aremote-filesystems/restart_on astring none
2310N/Aremote-filesystems/type astring service
2310N/Astartd/duration astring transient
2310N/Astart/timeout_seconds count 0
2310N/Astart/type astring method
2310N/Astop/exec astring :true
2310N/Astop/timeout_seconds count 0
2310N/Astop/type astring method""",
2310N/A
2310N/A "svcprop_temp_enabled" :
2310N/A"""general/enabled boolean false
2310N/Ageneral/entity_stability astring Unstable
2310N/Ageneral/single_instance boolean true
2310N/Arestarter/start_pid count 7816
2310N/Arestarter/start_method_timestamp time 1222992237.506096000
2310N/Arestarter/start_method_waitstatus integer 0
2310N/Arestarter/transient_contract count
2310N/Arestarter/auxiliary_state astring none
2310N/Arestarter/next_state astring none
2310N/Arestarter/state astring online
2310N/Arestarter/state_timestamp time 1222992237.527408000
2310N/Arestarter_actions/refresh integer
2310N/Arestarter_actions/maint_on integer
2310N/Arestarter_actions/maint_off integer
2310N/Arestarter_actions/restart integer
2310N/Ageneral_ovr/enabled boolean true
2310N/Alocal-filesystems/entities fmri svc:/system/filesystem/local
2310N/Alocal-filesystems/grouping astring require_all
2310N/Alocal-filesystems/restart_on astring none
2310N/Alocal-filesystems/type astring service
2310N/Aremote-filesystems/entities fmri svc:/network/nfs/client svc:/system/filesystem/autofs
2310N/Aremote-filesystems/grouping astring optional_all
2310N/Aremote-filesystems/restart_on astring none
2310N/Aremote-filesystems/type astring service
2310N/Astartd/duration astring transient
2310N/Astart/timeout_seconds count 0
2310N/Astart/type astring method
2310N/Astop/exec astring :true
2310N/Astop/timeout_seconds count 0
2310N/Astop/type astring method""",
2310N/A
2375N/A "svcprop_temp_enabled2" :
2375N/A"""general/enabled boolean true
2375N/Ageneral/entity_stability astring Unstable
2375N/Ageneral/single_instance boolean true
2375N/Arestarter/start_pid count 7816
2375N/Arestarter/start_method_timestamp time 1222992237.506096000
2375N/Arestarter/start_method_waitstatus integer 0
2375N/Arestarter/transient_contract count
2375N/Arestarter/auxiliary_state astring none
2375N/Arestarter/next_state astring none
2375N/Arestarter/state astring online
2375N/Arestarter/state_timestamp time 1222992237.527408000
2375N/Arestarter_actions/refresh integer
2375N/Arestarter_actions/maint_on integer
2375N/Arestarter_actions/maint_off integer
2375N/Arestarter_actions/restart integer
2375N/Ageneral_ovr/enabled boolean true
2375N/Alocal-filesystems/entities fmri svc:/system/filesystem/local
2375N/Alocal-filesystems/grouping astring require_all
2375N/Alocal-filesystems/restart_on astring none
2375N/Alocal-filesystems/type astring service
2375N/Aremote-filesystems/entities fmri svc:/network/nfs/client svc:/system/filesystem/autofs
2375N/Aremote-filesystems/grouping astring optional_all
2375N/Aremote-filesystems/restart_on astring none
2375N/Aremote-filesystems/type astring service
2375N/Astartd/duration astring transient
2375N/Astart/timeout_seconds count 0
2375N/Astart/type astring method
2375N/Astop/exec astring :true
2375N/Astop/timeout_seconds count 0
2375N/Astop/type astring method""",
2375N/A
2310N/A "svcprop_temp_disabled" :
2310N/A"""general/enabled boolean true
2310N/Ageneral/entity_stability astring Unstable
2310N/Ageneral/single_instance boolean true
2310N/Arestarter/start_pid count 7816
2310N/Arestarter/start_method_timestamp time 1222992237.506096000
2310N/Arestarter/start_method_waitstatus integer 0
2310N/Arestarter/transient_contract count
2310N/Arestarter/auxiliary_state astring none
2310N/Arestarter/next_state astring none
2310N/Arestarter/state astring disabled
2310N/Arestarter/state_timestamp time 1222992278.822335000
2310N/Arestarter_actions/refresh integer
2310N/Arestarter_actions/maint_on integer
2310N/Arestarter_actions/maint_off integer
2310N/Arestarter_actions/restart integer
2310N/Ageneral_ovr/enabled boolean false
2310N/Alocal-filesystems/entities fmri svc:/system/filesystem/local
2310N/Alocal-filesystems/grouping astring require_all
2310N/Alocal-filesystems/restart_on astring none
2310N/Alocal-filesystems/type astring service
2310N/Aremote-filesystems/entities fmri svc:/network/nfs/client svc:/system/filesystem/autofs
2310N/Aremote-filesystems/grouping astring optional_all
2310N/Aremote-filesystems/restart_on astring none
2310N/Aremote-filesystems/type astring service
2310N/Astartd/duration astring transient
2310N/Astart/timeout_seconds count 0
2310N/Astart/type astring method
2310N/Astop/exec astring :true
2310N/Astop/timeout_seconds count 0
2310N/Astop/type astring method""",
2310N/A
2375N/A "svcprop_temp_disabled2" :
2375N/A"""general/enabled boolean false
2375N/Ageneral/entity_stability astring Unstable
2375N/Ageneral/single_instance boolean true
2375N/Arestarter/start_pid count 7816
2375N/Arestarter/start_method_timestamp time 1222992237.506096000
2375N/Arestarter/start_method_waitstatus integer 0
2375N/Arestarter/transient_contract count
2375N/Arestarter/auxiliary_state astring none
2375N/Arestarter/next_state astring none
2375N/Arestarter/state astring disabled
2375N/Arestarter/state_timestamp time 1222992278.822335000
2375N/Arestarter_actions/refresh integer
2375N/Arestarter_actions/maint_on integer
2375N/Arestarter_actions/maint_off integer
2375N/Arestarter_actions/restart integer
2375N/Ageneral_ovr/enabled boolean false
2375N/Alocal-filesystems/entities fmri svc:/system/filesystem/local
2375N/Alocal-filesystems/grouping astring require_all
2375N/Alocal-filesystems/restart_on astring none
2375N/Alocal-filesystems/type astring service
2375N/Aremote-filesystems/entities fmri svc:/network/nfs/client svc:/system/filesystem/autofs
2375N/Aremote-filesystems/grouping astring optional_all
2375N/Aremote-filesystems/restart_on astring none
2375N/Aremote-filesystems/type astring service
2375N/Astartd/duration astring transient
2375N/Astart/timeout_seconds count 0
2375N/Astart/type astring method
2375N/Astop/exec astring :true
2375N/Astop/timeout_seconds count 0
2375N/Astop/type astring method""",
2375N/A
2310N/A "svcprop_maintenance":
2310N/A"""general/enabled boolean true
2310N/Ageneral/entity_stability astring Unstable
2310N/Ageneral/single_instance boolean true
2310N/Arestarter/start_pid count 4172
2310N/Arestarter/start_method_timestamp time 1222382991.639687000
2310N/Arestarter/start_method_waitstatus integer 0
2310N/Arestarter/transient_contract count
2310N/Arestarter/auxiliary_state astring none
2310N/Arestarter/next_state astring none
2310N/Arestarter/state astring maintenance
2310N/Arestarter/state_timestamp time 1222382991.644413000
2310N/Arestarter_actions/refresh integer
2310N/Arestarter_actions/maint_on integer
2310N/Arestarter_actions/maint_off integer
2310N/Arestarter_actions/restart integer
2310N/Alocal-filesystems/entities fmri svc:/system/filesystem/local
2310N/Alocal-filesystems/grouping astring require_all
2310N/Alocal-filesystems/restart_on astring none
2310N/Alocal-filesystems/type astring service
2310N/Aremote-filesystems/entities fmri svc:/network/nfs/client svc:/system/filesystem/autofs
2310N/Aremote-filesystems/grouping astring optional_all
2310N/Aremote-filesystems/restart_on astring none
2310N/Aremote-filesystems/type astring service
2310N/Astartd/duration astring transient
2310N/Astart/timeout_seconds count 0
2310N/Astart/type astring method
2310N/Astop/exec astring :true
2310N/Astop/timeout_seconds count 0
2310N/Astop/type astring method""",
2310N/A
2310N/A "empty": "",
2310N/A}
3046N/A
2310N/A def setUp(self):
2310N/A pkg5unittest.SingleDepotTestCase.setUp(self)
2310N/A self.make_misc_files(self.misc_files, prefix="testdata")
2310N/A
2310N/A def test_smf(self):
2310N/A """Test that the smf interface performs as expected."""
2310N/A
2310N/A testdata_dir = os.path.join(self.test_root, "testdata")
2310N/A svcadm_output = os.path.join(testdata_dir,
2310N/A "svcadm_arguments")
2310N/A os.environ["PKG_TEST_DIR"] = testdata_dir
2310N/A os.environ["PKG_SVCADM_EXIT_CODE"] = "0"
2310N/A os.environ["PKG_SVCPROP_EXIT_CODE"] = "0"
2310N/A
2310N/A smf.restart("svc:/system/test_restart_svc:default")
2310N/A self.file_contains(svcadm_output,
2310N/A "svcadm restart svc:/system/test_restart_svc:default")
2310N/A os.unlink(svcadm_output)
2310N/A
3014N/A smf.restart("svc:/system/test_restart_svc:default",
3014N/A sync_timeout=0)
3014N/A self.file_contains(svcadm_output,
3014N/A "svcadm restart svc:/system/test_restart_svc:default")
3014N/A os.unlink(svcadm_output)
3014N/A
3014N/A smf.restart("svc:/system/test_restart_svc:default",
3014N/A sync_timeout=-1)
3014N/A self.file_contains(svcadm_output,
3014N/A "svcadm restart -s svc:/system/test_restart_svc:default")
3014N/A os.unlink(svcadm_output)
3014N/A
3014N/A smf.restart("svc:/system/test_restart_svc:default",
3014N/A sync_timeout=10)
3014N/A self.file_contains(svcadm_output,
3014N/A "svcadm restart -s -T 10 svc:/system/test_restart_svc:default")
3014N/A os.unlink(svcadm_output)
3014N/A
2310N/A smf.refresh("svc:/system/test_refresh_svc:default")
2310N/A self.file_contains(svcadm_output,
2310N/A "svcadm refresh svc:/system/test_refresh_svc:default")
2310N/A os.unlink(svcadm_output)
2310N/A
3014N/A smf.refresh("svc:/system/test_refresh_svc:default",
3014N/A sync_timeout=0)
3014N/A self.file_contains(svcadm_output,
3014N/A "svcadm refresh svc:/system/test_refresh_svc:default")
3014N/A os.unlink(svcadm_output)
3014N/A
3014N/A smf.refresh("svc:/system/test_refresh_svc:default",
3014N/A sync_timeout=-1)
3014N/A self.file_contains(svcadm_output,
3014N/A "svcadm refresh -s svc:/system/test_refresh_svc:default")
3014N/A os.unlink(svcadm_output)
3014N/A
3014N/A smf.refresh("svc:/system/test_refresh_svc:default",
3014N/A sync_timeout=10)
3014N/A self.file_contains(svcadm_output,
3014N/A "svcadm refresh -s -T 10 svc:/system/test_refresh_svc:default")
3014N/A os.unlink(svcadm_output)
3014N/A
2310N/A smf.mark("maintenance", "svc:/system/test_mark_svc:default")
2310N/A self.file_contains(svcadm_output,
2310N/A "svcadm mark maintenance svc:/system/test_mark_svc:default")
2310N/A os.unlink(svcadm_output)
2310N/A
2310N/A smf.mark("degraded", "svc:/system/test_mark_svc:default")
2310N/A self.file_contains(svcadm_output,
2310N/A "svcadm mark degraded svc:/system/test_mark_svc:default")
2310N/A os.unlink(svcadm_output)
2310N/A
2310N/A smf.disable("svc:/system/test_disable_svc:default")
2310N/A self.file_contains(svcadm_output,
2310N/A "svcadm disable -s svc:/system/test_disable_svc:default")
2310N/A os.unlink(svcadm_output)
2310N/A
2310N/A smf.disable("svc:/system/test_disable_svc:default",
2310N/A temporary=True)
2310N/A self.file_contains(svcadm_output,
2310N/A "svcadm disable -s -t svc:/system/test_disable_svc:default")
2310N/A os.unlink(svcadm_output)
2310N/A
2310N/A smf.enable("svc:/system/test_enable_svc:default")
2310N/A self.file_contains(svcadm_output,
2310N/A "svcadm enable svc:/system/test_enable_svc:default")
2310N/A os.unlink(svcadm_output)
2310N/A
2310N/A smf.enable("svc:/system/test_enable_svc:default",
2310N/A temporary=True)
2310N/A self.file_contains(svcadm_output,
2310N/A "svcadm enable -t svc:/system/test_enable_svc:default")
2310N/A os.unlink(svcadm_output)
2310N/A
3014N/A smf.enable("svc:/system/test_enable_svc:default",
3014N/A sync_timeout=-1)
3014N/A self.file_contains(svcadm_output,
3014N/A "svcadm enable -s svc:/system/test_enable_svc:default")
3014N/A os.unlink(svcadm_output)
3014N/A
3014N/A smf.enable("svc:/system/test_enable_svc:default",
3014N/A sync_timeout=0)
3014N/A self.file_contains(svcadm_output,
3014N/A "svcadm enable svc:/system/test_enable_svc:default")
3014N/A os.unlink(svcadm_output)
3014N/A
3014N/A smf.enable("svc:/system/test_enable_svc:default",
3014N/A sync_timeout=10)
3014N/A self.file_contains(svcadm_output,
3014N/A "svcadm enable -s -T 10 svc:/system/test_enable_svc:default")
3014N/A os.unlink(svcadm_output)
3014N/A
2310N/A os.environ["PKG_SVCPROP_OUTPUT"] = "svcprop_enabled"
2310N/A self.assertEqual(smf.get_prop("foo", "start/timeout_seconds"),
2310N/A "0")
2310N/A self.assertEqual(smf.get_prop("foo", "stop/exec"), ":true")
2310N/A
2310N/A p = smf.get_props("foo")
2310N/A self.assert_("start/timeout_seconds" in p)
2310N/A self.assert_("0" in p["start/timeout_seconds"])
2310N/A self.assert_("stop/exec" in p)
2310N/A self.assert_("true" in p["stop/exec"])
2310N/A
2310N/A # "a" should be removed from the list of fmris since it's not
2310N/A # an instance.
2310N/A fmris = smf.check_fmris("foo", set(["a"]))
2310N/A self.assertEqual(fmris, set([]))
2310N/A
2310N/A fmris = smf.check_fmris("foo",
2310N/A set(["test_disable_svc:default"]))
2310N/A self.assertEqual(fmris, set(["test_disable_svc:default"]))
2310N/A
2310N/A fmris = smf.check_fmris("foo", set(["test_disable_svc*"]))
2310N/A self.assertEqual(fmris,
2310N/A set(["svc:/system/test_disable_svc:default"]))
2310N/A
2310N/A self.assertEqual(smf.get_state("foo"), smf.SMF_SVC_ENABLED)
2310N/A self.assert_(not smf.is_disabled("foo"))
2310N/A
2310N/A os.environ["PKG_SVCPROP_OUTPUT"] = "svcprop_disabled"
2310N/A self.assertEqual(smf.get_state("foo"), smf.SMF_SVC_DISABLED)
2310N/A self.assert_(smf.is_disabled("foo"))
2310N/A
2310N/A os.environ["PKG_SVCPROP_OUTPUT"] = "svcprop_temp_enabled"
2310N/A self.assertEqual(smf.get_state("foo"), smf.SMF_SVC_TMP_ENABLED)
2310N/A self.assert_(not smf.is_disabled("foo"))
2310N/A
2375N/A os.environ["PKG_SVCPROP_OUTPUT"] = "svcprop_temp_enabled2"
2375N/A self.assertEqual(smf.get_state("foo"), smf.SMF_SVC_TMP_ENABLED)
2375N/A self.assert_(not smf.is_disabled("foo"))
2375N/A
2310N/A os.environ["PKG_SVCPROP_OUTPUT"] = "svcprop_temp_disabled"
2310N/A self.assertEqual(smf.get_state("foo"), smf.SMF_SVC_TMP_DISABLED)
2310N/A self.assert_(smf.is_disabled("foo"))
2310N/A
2375N/A os.environ["PKG_SVCPROP_OUTPUT"] = "svcprop_temp_disabled2"
2375N/A self.assertEqual(smf.get_state("foo"), smf.SMF_SVC_TMP_DISABLED)
2375N/A self.assert_(smf.is_disabled("foo"))
2375N/A
2310N/A os.environ["PKG_SVCPROP_OUTPUT"] = "svcprop_maintenance"
2310N/A self.assertEqual(smf.get_state("foo"), smf.SMF_SVC_MAINTENANCE)
2310N/A self.assert_(smf.is_disabled("foo"))
3024N/A
3024N/A # test if supplying tuples and lists as arguments works
3024N/A smf.enable(["svc:/system/test_enable_svc:default", "foo"])
3024N/A self.file_contains(svcadm_output,
3024N/A "svcadm enable svc:/system/test_enable_svc:default foo")
3024N/A os.unlink(svcadm_output)
3024N/A smf.enable(("svc:/system/test_enable_svc:default", "foo"))
3024N/A self.file_contains(svcadm_output,
3024N/A "svcadm enable svc:/system/test_enable_svc:default foo")
3024N/A os.unlink(svcadm_output)
3024N/A
3024N/A smf.disable(["svc:/system/test_enable_svc:default", "foo"])
3024N/A self.file_contains(svcadm_output,
3024N/A "svcadm disable -s svc:/system/test_enable_svc:default foo")
3024N/A os.unlink(svcadm_output)
3024N/A smf.disable(("svc:/system/test_enable_svc:default", "foo"))
3024N/A self.file_contains(svcadm_output,
3024N/A "svcadm disable -s svc:/system/test_enable_svc:default foo")
3024N/A os.unlink(svcadm_output)
3024N/A
3024N/A smf.refresh(["svc:/system/test_enable_svc:default", "foo"])
3024N/A self.file_contains(svcadm_output,
3024N/A "svcadm refresh svc:/system/test_enable_svc:default foo")
3024N/A os.unlink(svcadm_output)
3024N/A smf.refresh(("svc:/system/test_enable_svc:default", "foo"))
3024N/A self.file_contains(svcadm_output,
3024N/A "svcadm refresh svc:/system/test_enable_svc:default foo")
3024N/A os.unlink(svcadm_output)
3024N/A
3024N/A smf.restart(["svc:/system/test_enable_svc:default", "foo"])
3024N/A self.file_contains(svcadm_output,
3024N/A "svcadm restart svc:/system/test_enable_svc:default foo")
3024N/A os.unlink(svcadm_output)
3024N/A smf.restart(("svc:/system/test_enable_svc:default", "foo"))
3024N/A self.file_contains(svcadm_output,
3024N/A "svcadm restart svc:/system/test_enable_svc:default foo")
3024N/A os.unlink(svcadm_output)
3024N/A
3024N/A smf.mark("degraded", ["svc:/system/test_enable_svc:default", "foo"])
3024N/A self.file_contains(svcadm_output,
3024N/A "svcadm mark degraded svc:/system/test_enable_svc:default foo")
3024N/A os.unlink(svcadm_output)
3024N/A smf.mark("degraded", ("svc:/system/test_enable_svc:default", "foo"))
3024N/A self.file_contains(svcadm_output,
3024N/A "svcadm mark degraded svc:/system/test_enable_svc:default foo")
3024N/A os.unlink(svcadm_output)
3046N/A
3046N/A def test_zone_actuators(self):
3046N/A """Test that the smf interface for zones performs as
3046N/A expected."""
3046N/A
3046N/A testdata_dir = os.path.join(self.test_root, "testdata")
3046N/A svcadm_output = os.path.join(testdata_dir,
3046N/A "svcadm_arguments")
3046N/A zlogin_output = os.path.join(testdata_dir,
3046N/A "zlogin_arguments")
3046N/A os.environ["PKG_TEST_DIR"] = testdata_dir
3046N/A DebugValues["bin_zlogin"] = os.path.join(self.test_root,
3046N/A "smf_cmds", "bin_zlogin")
3046N/A
3046N/A zone = "z1"
3046N/A
3046N/A smf.restart("svc:/system/test_restart_svc:default", zone=zone)
3046N/A self.file_contains(zlogin_output,
3046N/A "zlogin "+zone)
3046N/A os.unlink(zlogin_output)
3046N/A self.file_contains(svcadm_output,
3046N/A "svcadm restart svc:/system/test_restart_svc:default")
3046N/A os.unlink(svcadm_output)
3046N/A
3046N/A smf.refresh("svc:/system/test_refresh_svc:default", zone=zone)
3046N/A self.file_contains(zlogin_output,
3046N/A "zlogin "+zone)
3046N/A os.unlink(zlogin_output)
3046N/A self.file_contains(svcadm_output,
3046N/A "svcadm refresh svc:/system/test_refresh_svc:default")
3046N/A os.unlink(svcadm_output)
3046N/A
3046N/A smf.mark("maintenance", "svc:/system/test_mark_svc:default", zone=zone)
3046N/A self.file_contains(zlogin_output,
3046N/A "zlogin "+zone)
3046N/A os.unlink(zlogin_output)
3046N/A self.file_contains(svcadm_output,
3046N/A "svcadm mark maintenance svc:/system/test_mark_svc:default")
3046N/A os.unlink(svcadm_output)
3046N/A
3046N/A smf.enable("svc:/system/test_enable_svc:default", zone=zone)
3046N/A self.file_contains(zlogin_output,
3046N/A "zlogin "+zone)
3046N/A os.unlink(zlogin_output)
3046N/A self.file_contains(svcadm_output,
3046N/A "svcadm enable svc:/system/test_enable_svc:default")
3046N/A os.unlink(svcadm_output)
3046N/A
3046N/A smf.disable("svc:/system/test_disable_svc:default", zone=zone)
3046N/A self.file_contains(zlogin_output,
3046N/A "zlogin "+zone)
3046N/A os.unlink(zlogin_output)
3046N/A self.file_contains(svcadm_output,
3046N/A "svcadm disable -s svc:/system/test_disable_svc:default")
3046N/A os.unlink(svcadm_output)
3046N/A
3046N/A os.environ["PKG_SVCPROP_OUTPUT"] = "svcprop_enabled"
3046N/A smf.get_prop("foo", "start/timeout_seconds", zone=zone)
3046N/A self.file_contains(zlogin_output,
3046N/A "zlogin "+zone)
3046N/A os.unlink(zlogin_output)
3046N/A
3046N/A smf.is_disabled("foo", zone=zone)
3046N/A self.file_contains(zlogin_output,
3046N/A "zlogin "+zone)
3046N/A os.unlink(zlogin_output)
3046N/A
3046N/A smf.get_state("foo", zone=zone)
3046N/A self.file_contains(zlogin_output,
3046N/A "zlogin "+zone)
3046N/A os.unlink(zlogin_output)