class ResourceTest(TestCase, get_assert_pcs_effect_mixin(get_cib_resources)): empty_cib = rc("cib-empty.xml") temp_cib = rc("temp-cib.xml") def setUp(self): shutil.copy(self.empty_cib, self.temp_cib) self.pcs_runner = PcsRunner(self.temp_cib)
class BundleCreateCommon( TestCase, get_assert_pcs_effect_mixin(lambda cib: etree.tostring( # pylint:disable=undefined-variable etree.parse(cib).findall(".//resources")[0]))): temp_cib = rc("temp-cib.xml") def setUp(self): shutil.copy(self.empty_cib, self.temp_cib) self.pcs_runner = PcsRunner(self.temp_cib)
class PropertyUnset( TestCase, get_assert_pcs_effect_mixin(lambda cib: etree.tostring( # pylint:disable=undefined-variable etree.parse(cib).findall(".//crm_config")[0]))): def setUp(self): self.empty_cib = empty_cib self.temp_cib = temp_cib shutil.copy(self.empty_cib, self.temp_cib) self.pcs_runner = PcsRunner(self.temp_cib) @staticmethod def fixture_xml_no_props(): # must match empty_cib return """ <crm_config /> """ @staticmethod def fixture_xml_empty_props(): # must match empty_cib return """ <crm_config> <cluster_property_set id="cib-bootstrap-options" /> </crm_config> """ @staticmethod def fixture_xml_with_props(): # must match empty_cib return """ <crm_config> <cluster_property_set id="cib-bootstrap-options"> <nvpair id="cib-bootstrap-options-batch-limit" name="batch-limit" value="100" /> </cluster_property_set> </crm_config> """ def test_keep_empty_nvset(self): self.assert_effect("property set batch-limit=100", self.fixture_xml_with_props()) self.assert_effect("property unset batch-limit", self.fixture_xml_empty_props()) def test_dont_create_nvset_on_removal(self): # pcs mimics crm_attribute. So this behaves differently than the rest # of pcs - instead of doing nothing it returns an error. # Should be changed to be consistent with the rest of pcs. self.assert_pcs_fail( "property unset batch-limit", "Error: can't remove property: 'batch-limit' that doesn't exist\n")
class ManageUnmanage( TestCase, get_assert_pcs_effect_mixin(lambda cib: etree.tostring( # pylint:disable=undefined-variable etree.parse(cib).findall(".//resources")[0]))): empty_cib = rc("cib-empty.xml") temp_cib = rc("temp-cib.xml") @staticmethod def fixture_cib_unmanaged_a(add_empty_meta_b=False): empty_meta_b = '<meta_attributes id="B-meta_attributes" />' return """ <resources> <primitive class="ocf" id="A" provider="heartbeat" type="Dummy"> <meta_attributes id="A-meta_attributes"> <nvpair id="A-meta_attributes-is-managed" name="is-managed" value="false" /> </meta_attributes> <operations> <op id="A-monitor-interval-10s" interval="10s" name="monitor" timeout="20s" /> </operations> </primitive> <primitive class="ocf" id="B" provider="heartbeat" type="Dummy"> {empty_meta_b}<operations> <op id="B-monitor-interval-10s" interval="10s" name="monitor" timeout="20s" /> </operations> </primitive> </resources> """.format(empty_meta_b=(empty_meta_b if add_empty_meta_b else "")) def setUp(self): shutil.copy(self.empty_cib, self.temp_cib) self.pcs_runner = PcsRunner(self.temp_cib) def fixture_resource(self, name, managed=True, with_monitors=False): self.assert_pcs_success( "resource create {0} ocf:heartbeat:Dummy --no-default-ops".format( name)) if not managed: self.assert_pcs_success("resource unmanage {0} {1}".format( name, "--monitor" if with_monitors else "")) def test_unmanage_none(self): self.assert_pcs_fail( "resource unmanage", "Error: You must specify resource(s) to unmanage\n") def test_manage_none(self): self.assert_pcs_fail( "resource manage", "Error: You must specify resource(s) to manage\n") def test_unmanage_one(self): self.fixture_resource("A") self.fixture_resource("B") self.assert_effect("resource unmanage A", self.fixture_cib_unmanaged_a()) def test_manage_one(self): self.fixture_resource("A", managed=False) self.fixture_resource("B", managed=False) self.assert_effect("resource manage B", self.fixture_cib_unmanaged_a(add_empty_meta_b=True)) def test_unmanage_monitor(self): self.fixture_resource("A") self.assert_effect( "resource unmanage A --monitor", """ <resources> <primitive class="ocf" id="A" provider="heartbeat" type="Dummy"> <meta_attributes id="A-meta_attributes"> <nvpair id="A-meta_attributes-is-managed" name="is-managed" value="false" /> </meta_attributes> <operations> <op id="A-monitor-interval-10s" interval="10s" name="monitor" timeout="20s" enabled="false" /> </operations> </primitive> </resources> """) def test_unmanage_monitor_enabled(self): self.fixture_resource("A") self.assert_effect( "resource unmanage A", """ <resources> <primitive class="ocf" id="A" provider="heartbeat" type="Dummy"> <meta_attributes id="A-meta_attributes"> <nvpair id="A-meta_attributes-is-managed" name="is-managed" value="false" /> </meta_attributes> <operations> <op id="A-monitor-interval-10s" interval="10s" name="monitor" timeout="20s" /> </operations> </primitive> </resources> """) def test_manage_monitor(self): self.fixture_resource("A", managed=True, with_monitors=True) self.assert_effect( "resource manage A --monitor", """ <resources> <primitive class="ocf" id="A" provider="heartbeat" type="Dummy"> <operations> <op id="A-monitor-interval-10s" interval="10s" name="monitor" timeout="20s" /> </operations> </primitive> </resources> """) def test_manage_monitor_disabled(self): self.fixture_resource("A", managed=False, with_monitors=True) self.assert_effect( "resource manage A", """ <resources> <primitive class="ocf" id="A" provider="heartbeat" type="Dummy"> <meta_attributes id="A-meta_attributes" /> <operations> <op id="A-monitor-interval-10s" interval="10s" name="monitor" timeout="20s" enabled="false" /> </operations> </primitive> </resources> """, "Warning: Resource 'A' has no enabled monitor operations." " Re-run with '--monitor' to enable them.\n") def test_unmanage_more(self): self.fixture_resource("A") self.fixture_resource("B") self.assert_effect( "resource unmanage A B", """ <resources> <primitive class="ocf" id="A" provider="heartbeat" type="Dummy"> <meta_attributes id="A-meta_attributes"> <nvpair id="A-meta_attributes-is-managed" name="is-managed" value="false" /> </meta_attributes> <operations> <op id="A-monitor-interval-10s" interval="10s" name="monitor" timeout="20s" /> </operations> </primitive> <primitive class="ocf" id="B" provider="heartbeat" type="Dummy"> <meta_attributes id="B-meta_attributes"> <nvpair id="B-meta_attributes-is-managed" name="is-managed" value="false" /> </meta_attributes> <operations> <op id="B-monitor-interval-10s" interval="10s" name="monitor" timeout="20s" /> </operations> </primitive> </resources> """) def test_manage_more(self): self.fixture_resource("A", managed=False) self.fixture_resource("B", managed=False) self.assert_effect( "resource manage A B", """ <resources> <primitive class="ocf" id="A" provider="heartbeat" type="Dummy"> <meta_attributes id="A-meta_attributes" /> <operations> <op id="A-monitor-interval-10s" interval="10s" name="monitor" timeout="20s" /> </operations> </primitive> <primitive class="ocf" id="B" provider="heartbeat" type="Dummy"> <meta_attributes id="B-meta_attributes" /> <operations> <op id="B-monitor-interval-10s" interval="10s" name="monitor" timeout="20s" /> </operations> </primitive> </resources> """) def test_unmanage_nonexistent(self): self.fixture_resource("A") self.assert_pcs_fail( "resource unmanage A B", "Error: bundle/clone/group/resource 'B' does not exist\n") self.assert_resources_xml_in_cib(""" <resources> <primitive class="ocf" id="A" provider="heartbeat" type="Dummy"> <operations> <op id="A-monitor-interval-10s" interval="10s" name="monitor" timeout="20s" /> </operations> </primitive> </resources> """) def test_manage_nonexistent(self): self.fixture_resource("A", managed=False) self.assert_pcs_fail( "resource manage A B", "Error: bundle/clone/group/resource 'B' does not exist\n") self.assert_resources_xml_in_cib(""" <resources> <primitive class="ocf" id="A" provider="heartbeat" type="Dummy"> <meta_attributes id="A-meta_attributes"> <nvpair id="A-meta_attributes-is-managed" name="is-managed" value="false" /> </meta_attributes> <operations> <op id="A-monitor-interval-10s" interval="10s" name="monitor" timeout="20s" /> </operations> </primitive> </resources> """)
class OperationAdd( TestCase, get_assert_pcs_effect_mixin(get_cib_resources) ): temp_cib = rc("temp-cib.xml") empty_cib = rc("cib-empty.xml") def setUp(self): self.prepare_cib_file() self.pcs_runner = PcsRunner(self.temp_cib) def prepare_cib_file(self): with open(self.temp_cib, "w") as temp_cib_file: temp_cib_file.write(self.fixture_cib_cache()) def fixture_cib_cache(self): if not hasattr(self.__class__, "cib_cache"): self.__class__.cib_cache = self.fixture_cib() return self.__class__.cib_cache def fixture_cib(self): shutil.copy(self.empty_cib, self.temp_cib) self.pcs_runner = PcsRunner(self.temp_cib) self.assert_pcs_success( "resource create --no-default-ops R ocf:heartbeat:Dummy" ) #add to cib: # <primitive class="ocf" id="R" provider="heartbeat" type="Dummy"> # <operations> # <op id="R-monitor-interval-60s" interval="60s" # name="monitor" # /> # </operations> # </primitive> cib_content = open(self.temp_cib).read() #clean self.pcs_runner = None shutil.copy(self.empty_cib, self.temp_cib) return cib_content def test_base_add(self): self.assert_effect( "resource op add R start interval=20s", """<resources> <primitive class="ocf" id="R" provider="heartbeat" type="Dummy"> <operations> <op id="R-monitor-interval-10" interval="10" name="monitor" timeout="20" /> <op id="R-start-interval-20s" interval="20s" name="start" /> </operations> </primitive> </resources>""" ) def test_add_with_OCF_CHECK_LEVEL(self): self.assert_effect( "resource op add R start interval=20s OCF_CHECK_LEVEL=1" " description=test-description" , """<resources> <primitive class="ocf" id="R" provider="heartbeat" type="Dummy"> <operations> <op id="R-monitor-interval-10" interval="10" name="monitor" timeout="20" /> <op description="test-description" name="start" id="R-start-interval-20s" interval="20s" > <instance_attributes id="params-R-start-interval-20s" > <nvpair id="R-start-interval-20s-OCF_CHECK_LEVEL-1" name="OCF_CHECK_LEVEL" value="1" /> </instance_attributes> </op> </operations> </primitive> </resources>""" ) def test_can_multiple_operation_add(self): self.assert_effect( "resource op add R start interval=20s", """<resources> <primitive class="ocf" id="R" provider="heartbeat" type="Dummy"> <operations> <op id="R-monitor-interval-10" interval="10" name="monitor" timeout="20" /> <op id="R-start-interval-20s" interval="20s" name="start" /> </operations> </primitive> </resources>""" ) self.assert_effect( "resource op add R stop interval=30s", """<resources> <primitive class="ocf" id="R" provider="heartbeat" type="Dummy"> <operations> <op id="R-monitor-interval-10" interval="10" name="monitor" timeout="20" /> <op id="R-start-interval-20s" interval="20s" name="start" /> <op id="R-stop-interval-30s" interval="30s" name="stop" /> </operations> </primitive> </resources>""" ) def test_id_specified(self): self.assert_effect( "resource op add R start timeout=30 id=abcd", """<resources> <primitive class="ocf" id="R" provider="heartbeat" type="Dummy"> <operations> <op id="R-monitor-interval-10" interval="10" name="monitor" timeout="20" /> <op id="abcd" interval="0s" name="start" timeout="30" /> </operations> </primitive> </resources>""" ) def test_invalid_id(self): self.assert_pcs_fail_regardless_of_force( "resource op add R start timeout=30 id=ab#cd", "Error: invalid operation id 'ab#cd', '#' is not a valid" " character for a operation id\n" ) def test_duplicate_id(self): self.assert_pcs_fail_regardless_of_force( "resource op add R start timeout=30 id=R", "Error: id 'R' is already in use, please specify another one\n" )
class Success(TestCase, get_assert_pcs_effect_mixin(get_cib_resources)): temp_cib = rc("temp-cib.xml") def setUp(self): self.prepare_cib_file() self.pcs_runner = PcsRunner(self.temp_cib) def prepare_cib_file(self): with open(self.temp_cib, "w") as temp_cib_file: temp_cib_file.write(self.fixture_cib_cache()) def fixture_cib_cache(self): if not hasattr(self.__class__, "cib_cache"): self.__class__.cib_cache = self.fixture_cib() return self.__class__.cib_cache def fixture_cib(self): shutil.copy(rc('cib-empty-1.2.xml'), self.temp_cib) self.pcs_runner = PcsRunner(self.temp_cib) self.assert_pcs_success( "resource create --no-default-ops R ocf:heartbeat:Dummy") #add to cib: # <primitive class="ocf" id="R" provider="heartbeat" type="Dummy"> # <operations> # <op id="R-monitor-interval-60s" interval="60s" # name="monitor" # /> # </operations> # </primitive> cib_content = open(self.temp_cib).read() #clean self.pcs_runner = None shutil.copy(rc('cib-empty-1.2.xml'), self.temp_cib) return cib_content def test_base_add(self): self.assert_effect( "resource op add R start interval=20s", """<resources> <primitive class="ocf" id="R" provider="heartbeat" type="Dummy"> <operations> <op id="R-monitor-interval-10" interval="10" name="monitor" timeout="20" /> <op id="R-start-interval-20s" interval="20s" name="start" /> </operations> </primitive> </resources>""") def test_add_with_OCF_CHECK_LEVEL(self): self.assert_effect( "resource op add R start interval=20s OCF_CHECK_LEVEL=1" " description=test-description", """<resources> <primitive class="ocf" id="R" provider="heartbeat" type="Dummy"> <operations> <op id="R-monitor-interval-10" interval="10" name="monitor" timeout="20" /> <op description="test-description" name="start" id="R-start-interval-20s" interval="20s" > <instance_attributes id="params-R-start-interval-20s" > <nvpair id="R-start-interval-20s-OCF_CHECK_LEVEL-1" name="OCF_CHECK_LEVEL" value="1" /> </instance_attributes> </op> </operations> </primitive> </resources>""") def test_can_multiple_operation_add(self): self.assert_effect( "resource op add R start interval=20s", """<resources> <primitive class="ocf" id="R" provider="heartbeat" type="Dummy"> <operations> <op id="R-monitor-interval-10" interval="10" name="monitor" timeout="20" /> <op id="R-start-interval-20s" interval="20s" name="start" /> </operations> </primitive> </resources>""") self.assert_effect( "resource op add R stop interval=30s", """<resources> <primitive class="ocf" id="R" provider="heartbeat" type="Dummy"> <operations> <op id="R-monitor-interval-10" interval="10" name="monitor" timeout="20" /> <op id="R-start-interval-20s" interval="20s" name="start" /> <op id="R-stop-interval-30s" interval="30s" name="stop" /> </operations> </primitive> </resources>""")
class NodeAttributeTest( TestCase, get_assert_pcs_effect_mixin(lambda cib: etree.tostring( # pylint:disable=undefined-variable etree.parse(cib).findall(".//nodes")[0]))): def setUp(self): self.empty_cib = empty_cib self.temp_cib = temp_cib shutil.copy(self.empty_cib, self.temp_cib) self.pcs_runner = PcsRunner(self.temp_cib) @staticmethod def fixture_attrs(nodes, attrs=None): attrs = dict() if attrs is None else attrs xml_lines = ['<nodes>'] for node_id, node_name in enumerate(nodes, 1): xml_lines.extend([ '<node id="{0}" uname="{1}">'.format(node_id, node_name), '<instance_attributes id="nodes-{0}">'.format(node_id), ]) nv = '<nvpair id="nodes-{id}-{name}" name="{name}" value="{val}"/>' for name, value in attrs.get(node_name, dict()).items(): xml_lines.append(nv.format(id=node_id, name=name, val=value)) xml_lines.extend(['</instance_attributes>', '</node>']) xml_lines.append('</nodes>') utils_usefile_original = utils.usefile utils_filename_original = utils.filename utils.usefile = True utils.filename = temp_cib output, retval = utils.run( ["cibadmin", "--modify", '--xml-text', "\n".join(xml_lines)]) utils.usefile = utils_usefile_original utils.filename = utils_filename_original assert output == "" assert retval == 0 @staticmethod def fixture_xml_no_attrs(): # must match empty_cib return """ <nodes> <node id="1" uname="rh7-1" /> <node id="2" uname="rh7-2" /> </nodes> """ @staticmethod def fixture_xml_empty_attrs(): # must match empty_cib return """ <nodes> <node id="1" uname="rh7-1"> <instance_attributes id="nodes-1" /> </node> <node id="2" uname="rh7-2" /> </nodes> """ @staticmethod def fixture_xml_with_attrs(): # must match empty_cib return """ <nodes> <node id="1" uname="rh7-1"> <instance_attributes id="nodes-1"> <nvpair id="nodes-1-test" name="test" value="100" /> </instance_attributes> </node> <node id="2" uname="rh7-2" /> </nodes> """ def test_show_empty(self): self.fixture_attrs(["rh7-1", "rh7-2"]) self.assert_pcs_success("node attribute", "Node Attributes:\n") def test_show_nonempty(self): self.fixture_attrs(["rh7-1", "rh7-2"], { "rh7-1": { "IP": "192.168.1.1", }, "rh7-2": { "IP": "192.168.1.2", }, }) self.assert_pcs_success( "node attribute", """\ Node Attributes: rh7-1: IP=192.168.1.1 rh7-2: IP=192.168.1.2 """) def test_show_multiple_per_node(self): self.fixture_attrs( ["rh7-1", "rh7-2"], { "rh7-1": { "IP": "192.168.1.1", "alias": "node1", }, "rh7-2": { "IP": "192.168.1.2", "alias": "node2", }, }) self.assert_pcs_success( "node attribute", """\ Node Attributes: rh7-1: IP=192.168.1.1 alias=node1 rh7-2: IP=192.168.1.2 alias=node2 """) def test_show_one_node(self): self.fixture_attrs( ["rh7-1", "rh7-2"], { "rh7-1": { "IP": "192.168.1.1", "alias": "node1", }, "rh7-2": { "IP": "192.168.1.2", "alias": "node2", }, }) self.assert_pcs_success( "node attribute rh7-1", """\ Node Attributes: rh7-1: IP=192.168.1.1 alias=node1 """) def test_show_missing_node(self): self.fixture_attrs( ["rh7-1", "rh7-2"], { "rh7-1": { "IP": "192.168.1.1", "alias": "node1", }, "rh7-2": { "IP": "192.168.1.2", "alias": "node2", }, }) self.assert_pcs_success("node attribute rh7-3", """\ Node Attributes: """) def test_show_name(self): self.fixture_attrs( ["rh7-1", "rh7-2"], { "rh7-1": { "IP": "192.168.1.1", "alias": "node1", }, "rh7-2": { "IP": "192.168.1.2", "alias": "node2", }, }) self.assert_pcs_success( "node attribute --name alias", """\ Node Attributes: rh7-1: alias=node1 rh7-2: alias=node2 """) def test_show_missing_name(self): self.fixture_attrs( ["rh7-1", "rh7-2"], { "rh7-1": { "IP": "192.168.1.1", "alias": "node1", }, "rh7-2": { "IP": "192.168.1.2", "alias": "node2", }, }) self.assert_pcs_success("node attribute --name missing", """\ Node Attributes: """) def test_show_node_and_name(self): self.fixture_attrs( ["rh7-1", "rh7-2"], { "rh7-1": { "IP": "192.168.1.1", "alias": "node1", }, "rh7-2": { "IP": "192.168.1.2", "alias": "node2", }, }) self.assert_pcs_success("node attribute --name alias rh7-1", """\ Node Attributes: rh7-1: alias=node1 """) def test_set_new(self): self.fixture_attrs(["rh7-1", "rh7-2"]) self.assert_pcs_success("node attribute rh7-1 IP=192.168.1.1") self.assert_pcs_success( "node attribute", """\ Node Attributes: rh7-1: IP=192.168.1.1 """) self.assert_pcs_success("node attribute rh7-2 IP=192.168.1.2") self.assert_pcs_success( "node attribute", """\ Node Attributes: rh7-1: IP=192.168.1.1 rh7-2: IP=192.168.1.2 """) def test_set_existing(self): self.fixture_attrs(["rh7-1", "rh7-2"], { "rh7-1": { "IP": "192.168.1.1", }, "rh7-2": { "IP": "192.168.1.2", }, }) self.assert_pcs_success("node attribute rh7-2 IP=192.168.2.2") self.assert_pcs_success( "node attribute", """\ Node Attributes: rh7-1: IP=192.168.1.1 rh7-2: IP=192.168.2.2 """) def test_unset(self): self.fixture_attrs(["rh7-1", "rh7-2"], { "rh7-1": { "IP": "192.168.1.1", }, "rh7-2": { "IP": "192.168.1.2", }, }) self.assert_pcs_success("node attribute rh7-2 IP=") self.assert_pcs_success( "node attribute", """\ Node Attributes: rh7-1: IP=192.168.1.1 """) def test_unset_nonexisting(self): self.fixture_attrs(["rh7-1", "rh7-2"], { "rh7-1": { "IP": "192.168.1.1", }, "rh7-2": { "IP": "192.168.1.2", }, }) self.assert_pcs_result( "node attribute rh7-1 missing=", "Error: attribute: 'missing' doesn't exist for node: 'rh7-1'\n", returncode=2) def test_unset_nonexisting_forced(self): self.fixture_attrs(["rh7-1", "rh7-2"], { "rh7-1": { "IP": "192.168.1.1", }, "rh7-2": { "IP": "192.168.1.2", }, }) self.assert_pcs_success("node attribute rh7-1 missing= --force", "") def test_keep_empty_nvset(self): self.assert_effect("node attribute rh7-1 test=100", self.fixture_xml_with_attrs()) self.assert_effect("node attribute rh7-1 test=", self.fixture_xml_empty_attrs()) def test_dont_create_nvset_on_removal(self): # pcs does not actually do cib editing, it passes it to crm_node. So # this behaves differently than the rest of pcs - instead of doing # nothing it returns an error. # Should be changed to be consistent with the rest of pcs. output, retval = pcs(self.temp_cib, "node attribute rh7-1 test=") self.assertEqual( output, "Error: attribute: 'test' doesn't exist for node: 'rh7-1'\n") self.assertEqual(retval, 2)
class NodeUtilizationSet( TestCase, get_assert_pcs_effect_mixin(lambda cib: etree.tostring( # pylint:disable=undefined-variable etree.parse(cib).findall(".//nodes")[0]))): def setUp(self): self.empty_cib = empty_cib self.temp_cib = temp_cib shutil.copy(self.empty_cib, self.temp_cib) self.pcs_runner = PcsRunner(self.temp_cib) @staticmethod def fixture_xml_no_utilization(): # must match empty_cib return """ <nodes> <node id="1" uname="rh7-1" /> <node id="2" uname="rh7-2" /> </nodes> """ @staticmethod def fixture_xml_empty_utilization(): # must match empty_cib return """ <nodes> <node id="1" uname="rh7-1"> <utilization id="nodes-1-utilization" /> </node> <node id="2" uname="rh7-2" /> </nodes> """ @staticmethod def fixture_xml_with_utilization(): # must match empty_cib return """ <nodes> <node id="1" uname="rh7-1"> <utilization id="nodes-1-utilization"> <nvpair id="nodes-1-utilization-test" name="test" value="100" /> </utilization> </node> <node id="2" uname="rh7-2" /> </nodes> """ def test_node_utilization_set(self): output, returnVal = pcs(temp_cib, "node utilization rh7-1 test1=10") ac("", output) self.assertEqual(0, returnVal) output, returnVal = pcs(temp_cib, "node utilization rh7-2") expected_out = """\ Node Utilization: """ ac(expected_out, output) self.assertEqual(0, returnVal) output, returnVal = pcs(temp_cib, "node utilization rh7-1") expected_out = """\ Node Utilization: rh7-1: test1=10 """ ac(expected_out, output) self.assertEqual(0, returnVal) output, returnVal = pcs(temp_cib, "node utilization rh7-1 test1=-10 test4=1234") ac("", output) self.assertEqual(0, returnVal) output, returnVal = pcs(temp_cib, "node utilization rh7-1") expected_out = """\ Node Utilization: rh7-1: test1=-10 test4=1234 """ ac(expected_out, output) self.assertEqual(0, returnVal) output, returnVal = pcs(temp_cib, "node utilization rh7-2 test2=321 empty=") ac("", output) self.assertEqual(0, returnVal) output, returnVal = pcs(temp_cib, "node utilization rh7-2") expected_out = """\ Node Utilization: rh7-2: test2=321 """ ac(expected_out, output) self.assertEqual(0, returnVal) output, returnVal = pcs(temp_cib, "node utilization") expected_out = """\ Node Utilization: rh7-1: test1=-10 test4=1234 rh7-2: test2=321 """ ac(expected_out, output) self.assertEqual(0, returnVal) output, returnVal = pcs(temp_cib, "node utilization rh7-2 test1=-20") ac("", output) self.assertEqual(0, returnVal) output, returnVal = pcs(temp_cib, "node utilization --name test1") expected_out = """\ Node Utilization: rh7-1: test1=-10 rh7-2: test1=-20 """ ac(expected_out, output) self.assertEqual(0, returnVal) output, returnVal = pcs(temp_cib, "node utilization --name test1 rh7-2") expected_out = """\ Node Utilization: rh7-2: test1=-20 """ ac(expected_out, output) self.assertEqual(0, returnVal) def test_refuse_non_option_attribute_parameter_among_options(self): self.assert_pcs_fail("node utilization rh7-1 net", "Error: missing value of 'net' option\n") def test_refuse_option_without_key(self): self.assert_pcs_fail( "node utilization rh7-1 =1", "Error: missing key in '=1' option\n", ) def test_refuse_unknown_node(self): self.assert_pcs_fail( "node utilization rh7-0 test=10", "Error: Unable to find a node: rh7-0\n", ) def test_refuse_value_not_int(self): self.assert_pcs_fail( "node utilization rh7-1 test1=10 test=int", "Error: Value of utilization attribute must be integer: " "'test=int'\n") def test_keep_empty_nvset(self): self.assert_effect("node utilization rh7-1 test=100", self.fixture_xml_with_utilization()) self.assert_effect("node utilization rh7-1 test=", self.fixture_xml_empty_utilization()) def test_dont_create_nvset_on_removal(self): self.assert_effect("node utilization rh7-1 test=", self.fixture_xml_no_utilization())