def skip_unless_pacemaker_version(version_tuple, feature): return skipUnless( is_minimum_pacemaker_version(*version_tuple), "Pacemaker version is too old (must be >= {version}) to test {feature}" .format( version=".".join([str(x) for x in version_tuple]), feature=feature ) )
def skip_unless_pacemaker_supports_systemd(): output, dummy_retval = utils.run(["pacemakerd", "--features"]) return skipUnless("systemd" in output, "Pacemaker does not support systemd resources")
def skip_unless_pacemaker_features(version_tuple, feature): return skipUnless( is_minimum_pacemaker_features(*version_tuple), "Pacemaker must support feature set version {version} to test {feature}" .format(version=".".join([str(x) for x in version_tuple]), feature=feature))
def skip_unless_pacemaker_version(version_tuple, feature): return skipUnless( is_minimum_pacemaker_version(*version_tuple), "Pacemaker version is too old (must be >= {version}) to test {feature}" .format(version=".".join([str(x) for x in version_tuple]), feature=feature))
def skip_if_service_enabled(service_name): return skipUnless( not is_service_enabled(runner, service_name), "Service {0} must be disabled".format(service_name), )
from pcs.test.tools.misc import get_test_resource as rc from pcs.test.tools.pcs_runner import PcsRunner EMPTY_CIB = rc("cib-empty.xml") TEMP_CIB = rc("temp-cib.xml") BOOTH_CONFIG_FILE = rc("temp-booth.cfg") BOOTH_KEY_FILE = rc("temp-booth.key") BOOTH_RESOURCE_AGENT_INSTALLED = os.path.exists( "/usr/lib/ocf/resource.d/pacemaker/booth-site" ) need_booth_resource_agent = unittest.skipUnless( BOOTH_RESOURCE_AGENT_INSTALLED, "test requires resource agent ocf:pacemaker:booth-site" " which is not istalled" ) def fake_file(command): return "{0} --booth-conf={1} --booth-key={2}".format( command, BOOTH_CONFIG_FILE, BOOTH_KEY_FILE, ) def ensure_booth_config_exists(): if not os.path.exists(BOOTH_CONFIG_FILE): with open(BOOTH_CONFIG_FILE, "w") as config_file: config_file.write("")
from __future__ import ( absolute_import, division, print_function, unicode_literals, ) from pcs import utils from pcs.test.cib_resource.common import ResourceTest from pcs.test.tools import pcs_unittest as unittest from pcs.test.cib_resource.stonith_common import need_load_xvm_fence_agent need_fence_scsi_providing_unfencing = unittest.skipUnless( not utils.is_rhel6(), "test requires system where stonith agent 'fence_scsi' provides unfencing") class PlainStonith(ResourceTest): @need_load_xvm_fence_agent def test_simplest(self): self.assert_effect( "stonith create S fence_xvm", """<resources> <primitive class="stonith" id="S" type="fence_xvm"> <operations> <op id="S-monitor-interval-60s" interval="60s" name="monitor" /> </operations> </primitive> </resources>""")
from pcs.test.tools.misc import get_test_resource as rc from pcs.test.tools.pcs_runner import PcsRunner EMPTY_CIB = rc("cib-empty.xml") TEMP_CIB = rc("temp-cib.xml") BOOTH_CONFIG_FILE = rc("temp-booth.cfg") BOOTH_KEY_FILE = rc("temp-booth.key") BOOTH_RESOURCE_AGENT_INSTALLED = os.path.exists( "/usr/lib/ocf/resource.d/pacemaker/booth-site" ) need_booth_resource_agent = unittest.skipUnless( BOOTH_RESOURCE_AGENT_INSTALLED, "test requires resource agent ocf:pacemaker:booth-site" " which is not installed" ) def fake_file(command): return "{0} --booth-conf={1} --booth-key={2}".format( command, BOOTH_CONFIG_FILE, BOOTH_KEY_FILE, ) def ensure_booth_config_exists(): if not os.path.exists(BOOTH_CONFIG_FILE): with open(BOOTH_CONFIG_FILE, "w") as config_file: config_file.write("")
from __future__ import ( absolute_import, division, print_function, ) import logging from pcs.cli.common.reports import (LibraryReportProcessorToConsole as ReportProcessor) from pcs.lib.external import CommandRunner from pcs.lib.resource_agent import StonithAgent from pcs.test.tools import pcs_unittest as unittest def __can_load_xvm_fence_agent(): try: runner = CommandRunner(logging.getLogger("test"), ReportProcessor()) StonithAgent(runner, "fence_xvm").validate_metadata() return True except: return False need_load_xvm_fence_agent = unittest.skipUnless( __can_load_xvm_fence_agent(), "test requires the successful load of 'fence_xvm' agent")
from __future__ import ( absolute_import, division, print_function, unicode_literals, ) from pcs import utils from pcs.test.cib_resource.common import ResourceTest from pcs.test.tools import pcs_unittest as unittest from pcs.test.cib_resource.stonith_common import need_load_xvm_fence_agent need_fence_scsi_providing_unfencing = unittest.skipUnless( not utils.is_rhel6(), "test requires system where stonith agent 'fence_scsi' provides unfencing" ) class PlainStonith(ResourceTest): @need_load_xvm_fence_agent def test_simplest(self): self.assert_effect( "stonith create S fence_xvm", """<resources> <primitive class="stonith" id="S" type="fence_xvm"> <operations> <op id="S-monitor-interval-60s" interval="60s" name="monitor" /> </operations> </primitive> </resources>"""
from __future__ import ( absolute_import, division, print_function, unicode_literals, ) import sys from pcs.test.tools.pcs_unittest import TestCase, skipUnless #python 2.6 does not support sys.version_info.major need_python3 = skipUnless(sys.version_info[0] == 3, "test requires python3") need_python2 = skipUnless(sys.version_info[0] == 2, "test requires python2") import pcs.lib.node as lib class NodeAddressesContainHost(TestCase): def test_return_true_if_is_as_ring0(self): self.assertTrue( lib.node_addresses_contain_host( [lib.NodeAddresses("HOST")], "HOST" ) ) def test_return_true_if_is_as_ring1(self): self.assertTrue( lib.node_addresses_contain_host( [lib.NodeAddresses("SOME", ring1="HOST")], "HOST"
def skip_unless_pacemaker_supports_systemd(): output, dummy_retval = utils.run(["pacemakerd", "--features"]) return skipUnless( "systemd" in output, "Pacemaker does not support systemd resources" )