def test_more_nodes(self): self.assert_maintenance_none() self.assert_pcs_success( "node maintenance rh7-1 rh7-2" ) self.assert_pcs_success( "node attribute", outdent( """\ Node Attributes: rh7-1: maintenance=on rh7-2: maintenance=on """ ) ) self.fixture_maintenance_all() self.assert_pcs_success( "node unmaintenance rh7-1 rh7-2" ) self.assert_pcs_success( "node attribute", outdent( """\ Node Attributes: rh7-3: maintenance=on """ ) )
def test_more_nodes(self): self.assert_standby_none() self.assert_pcs_success( "node standby rh7-1 rh7-2" ) self.assert_pcs_success( "node attribute", outdent( """\ Node Attributes: rh7-1: standby=on rh7-2: standby=on """ ) ) self.fixture_standby_all() self.assert_pcs_success( "node unstandby rh7-1 rh7-2" ) self.assert_pcs_success( "node attribute", outdent( """\ Node Attributes: rh7-3: standby=on """ ) )
def test_add_node_attribute(self): self.fixture_stonith_resource("F1") self.assert_pcs_success( "stonith level add 1 attrib%fencewith=levels F1" ) self.assert_pcs_success( "stonith level", outdent( """\ Target: fencewith=levels Level 1 - F1 """ ) ) self.assert_pcs_fail( "stonith level add 1 attrib%fencewith=levels F1", "Error: Fencing level for 'fencewith=levels' at level '1' with " "device(s) 'F1' already exists\n" ) self.assert_pcs_success( "stonith level", outdent( """\ Target: fencewith=levels Level 1 - F1 """ ) )
def test_multiple(self): self.assert_pcs_success( "alert config", outdent("""\ Alerts: No alerts defined """ ) ) self.assert_pcs_success("alert create path=test id=alert1") self.assert_pcs_success("alert create path=test id=alert2") self.assert_pcs_success("alert create path=test id=alert3") self.assert_pcs_success( "alert config", outdent("""\ Alerts: Alert: alert1 (path=test) Alert: alert2 (path=test) Alert: alert3 (path=test) """ ) ) self.assert_pcs_success("alert remove alert1 alert3") self.assert_pcs_success( "alert config", outdent("""\ Alerts: Alert: alert2 (path=test) """ ) )
def test_add_node_pattern(self): self.fixture_stonith_resource("F1") self.assert_pcs_success("stonith level add 1 regexp%rh7-\d F1") self.assert_pcs_success( "stonith level", outdent( """\ Target: rh7-\d Level 1 - F1 """ ) ) self.assert_pcs_fail( "stonith level add 1 regexp%rh7-\d F1", "Error: Fencing level for 'rh7-\d' at level '1' with device(s) " "'F1' already exists\n" ) self.assert_pcs_success( "stonith level", outdent( """\ Target: rh7-\d Level 1 - F1 """ ) )
def test_all(self): self.assert_pcs_success(""" resource bundle create B1 container docker image=pcs:test masters=2 replicas=4 options='a b c' network host-interface=eth0 host-netmask=24 control-port=12345 port-map id=B1-port-map-1001 internal-port=2002 port=2000 port-map range=3000-3300 storage-map source-dir=/tmp/docker1a target-dir=/tmp/docker1b storage-map id=my-storage-map source-dir=/tmp/docker2a target-dir=/tmp/docker2b meta target-role=Stopped is-managed=false """) self.assert_pcs_success( "resource create A ocf:pacemaker:Dummy bundle B1 --no-default-ops") self.assert_pcs_success( "resource show B1", outdent( # pylint:disable=trailing-whitespace """\ Bundle: B1 Docker: image=pcs:test masters=2 options="a b c" replicas=4 Network: control-port=12345 host-interface=eth0 host-netmask=24 Port Mapping: internal-port=2002 port=2000 (B1-port-map-1001) range=3000-3300 (B1-port-map-3000-3300) Storage Mapping: source-dir=/tmp/docker1a target-dir=/tmp/docker1b (B1-storage-map) source-dir=/tmp/docker2a target-dir=/tmp/docker2b (my-storage-map) Meta Attrs: is-managed=false target-role=Stopped Resource: A (class=ocf provider=pacemaker type=Dummy) Operations: monitor interval=10 timeout=20 (A-monitor-interval-10) """))
def test_missing_info(self): config = outdent(""" <cluster> <clusternodes> <clusternode nodeid="1"/> <clusternode name="node2"> <altname/> </clusternode> <clusternode/> </clusternodes> </cluster> """) self.assert_equal_nodelist([{ "ring0": None, "ring1": None, "name": None, "id": "1", }, { "ring0": "node2", "ring1": None, "name": None, "id": None, }, { "ring0": None, "ring1": None, "name": None, "id": None, }], lib.ClusterConfFacade( etree.XML(config)).get_nodes())
def test_success(self): config = outdent(""" <cluster> <clusternodes> <clusternode name="node1" nodeid="1"> <altname name="node1-altname"/> </clusternode> <clusternode name="node2" nodeid="2"/> <clusternode name="node3" nodeid="3"/> </clusternodes> </cluster> """) self.assert_equal_nodelist([{ "ring0": "node1", "ring1": "node1-altname", "name": None, "id": "1", }, { "ring0": "node2", "ring1": None, "name": None, "id": "2", }, { "ring0": "node3", "ring1": None, "name": None, "id": "3", }], lib.ClusterConfFacade( etree.XML(config)).get_nodes())
def fixture_nolive_remove_report(host_list): return outdent("""\ running 'pacemaker_remote stop' on {hosts} was skipped because command does not run on live cluster (e.g. -f was used). You will have to run it manually. running 'pacemaker_remote disable' on {hosts} was skipped because command does not run on live cluster (e.g. -f was used). You will have to run it manually. 'pacemaker authkey' remove from {hosts} was skipped because command does not run on live cluster (e.g. -f was used). You will have to do it manually. """).format(hosts=", ".join("'{0}'".format(host) for host in host_list))
def _test_success_remove_by_host(self): self.fixture_remote_node() self.assert_effect( f"cluster node {self.command} NODE-HOST", "<resources/>", fixture_nolive_remove_report(["NODE-NAME"]) + outdent("""\ Deleting Resource - NODE-NAME """))
def fixture_nolive_remove_report(host_list): return outdent( """\ Running action(s) 'pacemaker_remote disable', 'pacemaker_remote stop' on {hosts} was skipped because the command does not run on a live cluster (e.g. -f was used). Please, run the action(s) manually. Removing 'pacemaker authkey' from {hosts} was skipped because the command does not run on a live cluster (e.g. -f was used). Please, remove the file(s) manually. """ ).format(hosts=", ".join("'{0}'".format(host) for host in host_list))
def test_success_remove_by_node_name(self): self.fixture_remote_node() self.assert_effect( "cluster node remove-remote NODE-NAME", "<resources/>", fixture_nolive_remove_report(["NODE-NAME"]) + outdent("""\ Deleting Resource - NODE-NAME """))
def fixture_logger_call_debug_data(url, data): send_msg = outdent("""\ Communication debug info for calling: {url} --Debug Communication Info Start-- {data} --Debug Communication Info End--""") return mock.call.debug(send_msg.format(url=url, data=data))
def test_returns_the_same_text_when_not_indented(self): text = "\n".join([ "first line", " second line", " third line", ]) self.assertEqual(text, outdent(text))
def test_all_posibilities(self): self.fixture_full_configuration() self.assert_pcs_success("stonith level config", self.config) self.assert_pcs_success("stonith level", self.config) self.assert_pcs_success( "stonith", outdent("""\ F1\t(stonith:fence_apc):\tStopped F2\t(stonith:fence_apc):\tStopped F3\t(stonith:fence_apc):\tStopped """) + "\n".join(indent(self.config_lines, 1)) + "\n") self.assert_pcs_success( "config", self.full_config.format( devices=""" Resource: F1 (class=stonith type=fence_apc) Attributes: ipaddr=ip login=lgn pcmk_host_list="rh7-1 rh7-2," Operations: monitor interval=60s (F1-monitor-interval-60s) Resource: F2 (class=stonith type=fence_apc) Attributes: ipaddr=ip login=lgn pcmk_host_list="rh7-1 rh7-2," Operations: monitor interval=60s (F2-monitor-interval-60s) Resource: F3 (class=stonith type=fence_apc) Attributes: ipaddr=ip login=lgn pcmk_host_list="rh7-1 rh7-2," Operations: monitor interval=60s (F3-monitor-interval-60s)\ """, levels=("\n" + "\n".join(indent(self.config_lines, 2)))))
def test_all_posibilities(self): self.fixture_full_configuration() self.assert_pcs_success("stonith level config", self.config) self.assert_pcs_success("stonith level", self.config) self.assert_pcs_success( "stonith", outdent( """\ F1\t(stonith:fence_apc):\tStopped F2\t(stonith:fence_apc):\tStopped F3\t(stonith:fence_apc):\tStopped """ ) + "\n".join(indent(self.config_lines, 1)) + "\n" ) self.assert_pcs_success( "config", self.full_config.format( devices=""" Resource: F1 (class=stonith type=fence_apc) Attributes: pcmk_host_list="rh7-1 rh7-2," ipaddr=ip login=lgn Operations: monitor interval=60s (F1-monitor-interval-60s) Resource: F2 (class=stonith type=fence_apc) Attributes: pcmk_host_list="rh7-1 rh7-2," ipaddr=ip login=lgn Operations: monitor interval=60s (F2-monitor-interval-60s) Resource: F3 (class=stonith type=fence_apc) Attributes: pcmk_host_list="rh7-1 rh7-2," ipaddr=ip login=lgn Operations: monitor interval=60s (F3-monitor-interval-60s)\ """, levels=("\n" + "\n".join(indent(self.config_lines, 2))) ) )
def assert_wait_fail(self, command, cib_resources_xml): wait_error_message = outdent( """\ Pending actions: Action 39: stonith-vm-rhel72-1-reboot on vm-rhel72-1 Error performing operation: Timer expired """ ) runner.set_runs(fixture_pre_timeout_calls(cib_resources_xml) + [ Call( "crm_resource --wait --timeout=10", stderr=wait_error_message, returncode=62, ), ]) assert_raise_library_error( command, ( severities.ERROR, report_codes.WAIT_FOR_IDLE_TIMED_OUT, { "reason": wait_error_message.strip(), }, None ) ) runner.assert_everything_launched()
def test_comments_sections_closing_brace(self): string = outdent("""\ section { #} """) self.assertRaises(config_parser.MissingClosingBraceException, config_parser.parse_string, string)
def fixture_nolive_add_report(node_name): return outdent(f"""\ Unable to check if there is a conflict with nodes set in corosync because the command does not run on a live cluster (e.g. -f was used) Distribution of 'pacemaker authkey' to '{node_name}' was skipped because the command does not run on a live cluster (e.g. -f was used). Please, distribute the file(s) manually. Running action(s) 'pacemaker_remote enable', 'pacemaker_remote start' on '{node_name}' was skipped because the command does not run on a live cluster (e.g. -f was used). Please, run the action(s) manually. """ )
def test_comments_sections_opening_brace(self): string = outdent("""\ #section { } """) self.assertRaises(config_parser.UnexpectedClosingBraceException, config_parser.parse_string, string)
def test_more_errors(self): self.assert_pcs_fail_regardless_of_force( "resource bundle create B#1 container docker replicas=x", outdent("""\ Error: invalid bundle name 'B#1', '#' is not a valid character for a bundle name Error: required container option 'image' is missing Error: 'x' is not a valid replicas value, use a positive integer """))
def reload(self, name="runner.corosync.reload"): self.__calls.place( name, RunnerCall("corosync-cfgtool -R", stdout=outdent("""\ Reloading corosync.conf... Done """)))
def version(self, name="runner.corosync.version", version="2.4.0"): self.__calls.place( name, RunnerCall("corosync -v", stdout=outdent("""\ Corosync Cluster Engine, version '{0}' Copyright... """.format(version))))
def test_nonexisting_level_node_device(self): self.assert_pcs_fail( "stonith level remove 1 rh7-1 F3", outdent("""\ Error: Fencing level for 'rh7-1' at level '1' with device(s) 'F3' does not exist Error: Fencing level at level '1' with device(s) 'rh7-1,F3' does not exist """)) self.assert_pcs_success("stonith level config", self.config)
def test_errors(self): self.fixture_stonith_resource("F1") self.assert_pcs_success("stonith level add 1 rh7-1 F1") self.assert_pcs_success( "stonith level add 2 rh7-1 FX --force", "Warning: Stonith resource(s) 'FX' do not exist\n" ) self.assert_pcs_success( "stonith level add 1 rh7-X FX --force", outdent( """\ Warning: Node 'rh7-X' does not appear to exist in configuration Warning: Stonith resource(s) 'FX' do not exist """ ) ) self.assert_pcs_success( "stonith level add 2 rh7-Y FY --force", outdent( """\ Warning: Node 'rh7-Y' does not appear to exist in configuration Warning: Stonith resource(s) 'FY' do not exist """ ) ) self.assert_pcs_success( "stonith level add 4 regexp%rh7-\d FX --force", "Warning: Stonith resource(s) 'FX' do not exist\n" ) self.assert_pcs_success( "stonith level add 3 regexp%rh7-\d FY FZ --force", "Warning: Stonith resource(s) 'FY', 'FZ' do not exist\n" ) self.assert_pcs_fail( "stonith level verify", outdent( """\ Error: Stonith resource(s) 'FX', 'FY', 'FZ' do not exist Error: Node 'rh7-X' does not appear to exist in configuration Error: Node 'rh7-Y' does not appear to exist in configuration """ ) )
def test_section_add(self): root = config_parser.Section("root") child1 = config_parser.Section("child1") child1a = config_parser.Section("child1a") child2 = config_parser.Section("child2") root.add_section(child1) child1.add_section(child1a) root.add_section(child2) self.assertEqual(root.parent, None) self.assertEqual(child1.parent.name, "root") self.assertEqual(child1a.parent.name, "child1") self.assertEqual(child2.parent.name, "root") self.assertEqual( str(root), outdent("""\ child1 { child1a { } } child2 { } """)) child2.add_section(child1a) self.assertEqual(child1a.parent.name, "child2") self.assertEqual( str(root), outdent("""\ child1 { } child2 { child1a { } } """)) self.assertRaises(config_parser.CircularParentshipException, child1a.add_section, child1a) self.assertRaises(config_parser.CircularParentshipException, child1a.add_section, child2) self.assertRaises(config_parser.CircularParentshipException, child1a.add_section, root)
def test_minimal(self): self.assert_pcs_success( "resource bundle create B1 container docker image=pcs:test") self.assert_pcs_success( "resource show B1", outdent("""\ Bundle: B1 Docker: image=pcs:test """))
def test_no_recipient(self): self.assert_pcs_success("alert create path=test id=alert1") self.assert_pcs_success( "alert recipient add alert1 value=rec_value1 id=rec1") self.assert_pcs_fail( "alert recipient remove rec1 rec2 rec3", outdent("""\ Error: recipient 'rec2' does not exist Error: recipient 'rec3' does not exist """)) self.assert_pcs_success( "alert config", outdent("""\ Alerts: Alert: alert1 (path=test) Recipients: Recipient: rec1 (value=rec_value1) """))
def assert_maintenance_all(self): self.assert_pcs_success( "node attribute", outdent("""\ Node Attributes: rh7-1: maintenance=on rh7-2: maintenance=on rh7-3: maintenance=on """))
def assert_standby_all(self): self.assert_pcs_success( "node attribute", outdent("""\ Node Attributes: rh7-1: standby=on rh7-2: standby=on rh7-3: standby=on """))
def test_device_not_defined(self, mock_sbd_config, mock_config_exists): mock_config_exists.return_value = True mock_sbd_config.return_value = outdent(""" SBD_WATCHDOG=/dev/watchdog SBD_WATCHDOG_TIMEOUT=10 """) self.assertEqual([], lib_sbd.get_local_sbd_device_list()) mock_config_exists.assert_called_once_with(settings.sbd_config) mock_sbd_config.assert_called_once_with()
def test_comments_attributes(self): string = outdent("""\ # junk1 name1: value1 #junk2 name2: value2#junk3 name3: value3 #junk4 name4 # junk5: value4 #junk6 name5: value5 #junk7 """) parsed = outdent("""\ name1: value1 name2: value2#junk3 name3: value3 #junk4 name4 # junk5: value4 """) self.assertEqual(str(config_parser.parse_string(string)), parsed)
def reload(self, name="runner.corosync.reload", instead=None, before=None): self.__calls.place(name, RunnerCall("corosync-cfgtool -R", stdout=outdent("""\ Reloading corosync.conf... Done """)), before=before, instead=instead)
def test_success_remove_multiple_nodes(self): self.fixture_multiple_remote_nodes() self.assert_effect( "cluster node remove-remote HOST-A --force", "<resources/>", "Warning: multiple resource for 'HOST-A' found: 'HOST-A', 'NODE-NAME'\n" + fixture_nolive_remove_report(["HOST-A", "HOST-B"]) + outdent("""\ Deleting Resource - NODE-NAME Deleting Resource - HOST-A """))
def test_add_more_errors(self): self.assert_pcs_fail( "stonith level add x rh7-X F0 dev@ce", outdent("""\ Error: 'x' is not a valid level value, use a positive integer Error: Node 'rh7-X' does not appear to exist in configuration, use --force to override Error: invalid device id 'dev@ce', '@' is not a valid character for a device id Error: Stonith resource(s) 'F0' do not exist, use --force to override """)) self.assert_pcs_fail( "stonith level add x rh7-X F0 dev@ce --force", outdent("""\ Error: 'x' is not a valid level value, use a positive integer Error: invalid device id 'dev@ce', '@' is not a valid character for a device id Warning: Node 'rh7-X' does not appear to exist in configuration Warning: Stonith resource(s) 'F0' do not exist """))
def test_add_level_leading_zero(self): self.fixture_stonith_resource("F1") self.assert_pcs_success("stonith level add 0002 rh7-1 F1") self.assert_pcs_success( "stonith level", outdent("""\ Target: rh7-1 Level 2 - F1 """))
def fixture_full_configuration(self): self.fixture_stonith_resource("F1") self.fixture_stonith_resource("F2") self.fixture_stonith_resource("F3") self.assert_pcs_success("stonith level add 1 rh7-1 F1") self.assert_pcs_success("stonith level add 2 rh7-1 F2") self.assert_pcs_success("stonith level add 2 rh7-2 F1") self.assert_pcs_success("stonith level add 1 rh7-2 F2") self.assert_pcs_success("stonith level add 4 regexp%rh7-\d F3") self.assert_pcs_success("stonith level add 3 regexp%rh7-\d F2 F1") self.config = outdent( """\ Target: rh7-1 Level 1 - F1 Level 2 - F2 Target: rh7-2 Level 1 - F2 Level 2 - F1 Target: rh7-\d Level 3 - F2,F1 Level 4 - F3 """ ) self.config_lines = self.config.splitlines() if not fencing_level_attribute_supported: return self.assert_pcs_success( "stonith level add 5 attrib%fencewith=levels1 F3 F2" ) self.assert_pcs_success( "stonith level add 6 attrib%fencewith=levels2 F3 F1" ) self.config += outdent( """\ Target: fencewith=levels1 Level 5 - F3,F2 Target: fencewith=levels2 Level 6 - F3,F1 """) self.config_lines = self.config.splitlines()
def test_nonexisting_level_node_device(self): self.assert_pcs_fail( "stonith level remove 1 rh7-1 F3", outdent( """\ Error: Fencing level for 'rh7-1' at level '1' with device(s) 'F3' does not exist Error: Fencing level at level '1' with device(s) 'rh7-1,F3' does not exist """ ) ) self.assert_pcs_success("stonith level config", self.config)
def test_no_recipient(self): self.assert_pcs_success("alert create path=test id=alert1") self.assert_pcs_success( "alert recipient add alert1 value=rec_value1 id=rec1" ) self.assert_pcs_fail( "alert recipient remove rec1 rec2 rec3", outdent("""\ Error: recipient 'rec2' does not exist Error: recipient 'rec3' does not exist """ ) ) self.assert_pcs_success( "alert config", outdent("""\ Alerts: Alert: alert1 (path=test) Recipients: Recipient: rec1 (value=rec_value1) """ ) )
def assert_maintenance_all(self): self.assert_pcs_success( "node attribute", outdent( """\ Node Attributes: rh7-1: maintenance=on rh7-2: maintenance=on rh7-3: maintenance=on """ ) )
def test_add_level_leading_zero(self): self.fixture_stonith_resource("F1") self.assert_pcs_success("stonith level add 0002 rh7-1 F1") self.assert_pcs_success( "stonith level", outdent( """\ Target: rh7-1 Level 2 - F1 """ ) )
def assert_standby_all(self): self.assert_pcs_success( "node attribute", outdent( """\ Node Attributes: rh7-1: standby=on rh7-2: standby=on rh7-3: standby=on """ ) )
def test_very_ugly_indented_text(self): self.assertEqual( """\ Cluster Name: test99 Options: """, outdent("""\ Cluster Name: test99 Options: """ ) )
def test_multiple(self): self.assert_pcs_success("alert create path=test id=alert1") self.assert_pcs_success("alert create path=test id=alert2") self.assert_pcs_success( "alert recipient add alert1 value=rec_value1 id=rec1" ) self.assert_pcs_success( "alert recipient add alert1 value=rec_value2 id=rec2" ) self.assert_pcs_success( "alert recipient add alert2 value=rec_value3 id=rec3" ) self.assert_pcs_success( "alert recipient add alert2 value=rec_value4 id=rec4" ) self.assert_pcs_success( "alert config", outdent("""\ Alerts: Alert: alert1 (path=test) Recipients: Recipient: rec1 (value=rec_value1) Recipient: rec2 (value=rec_value2) Alert: alert2 (path=test) Recipients: Recipient: rec3 (value=rec_value3) Recipient: rec4 (value=rec_value4) """ ) ) self.assert_pcs_success("alert recipient remove rec1 rec2 rec4") self.assert_pcs_success( "alert config", outdent("""\ Alerts: Alert: alert1 (path=test) Alert: alert2 (path=test) Recipients: Recipient: rec3 (value=rec_value3) """ ) )
def test_add_more_devices_old_syntax(self): self.fixture_stonith_resource("F1") self.fixture_stonith_resource("F2") self.fixture_stonith_resource("F3") self.assert_pcs_success("stonith level add 1 rh7-1 F1,F2") self.assert_pcs_success( "stonith level", outdent( """\ Target: rh7-1 Level 1 - F1,F2 """ ) ) self.assert_pcs_success("stonith level add 2 rh7-1 F1,F2 F3") self.assert_pcs_success( "stonith level", outdent( """\ Target: rh7-1 Level 1 - F1,F2 Level 2 - F1,F2,F3 """ ) ) self.assert_pcs_success("stonith level add 3 rh7-1 F1 F2,F3") self.assert_pcs_success( "stonith level", outdent( """\ Target: rh7-1 Level 1 - F1,F2 Level 2 - F1,F2,F3 Level 3 - F1,F2,F3 """ ) )
def test_one(self): self.assert_pcs_success("alert create path=test") self.assert_pcs_success( "alert recipient add alert value=rec_value id=rec" ) self.assert_pcs_success( "alert config", outdent("""\ Alerts: Alert: alert (path=test) Recipients: Recipient: rec (value=rec_value) """ ) ) self.assert_pcs_success("alert recipient remove rec") self.assert_pcs_success( "alert config", outdent("""\ Alerts: Alert: alert (path=test) """ ) )
def test_add_more_devices(self): self.fixture_stonith_resource("F1") self.fixture_stonith_resource("F2") self.assert_pcs_success("stonith level add 1 rh7-1 F1 F2") self.assert_pcs_success( "stonith level", outdent( """\ Target: rh7-1 Level 1 - F1,F2 """ ) )
def test_remove_the_smallest_indentation(self): self.assertEqual( "\n".join([ " first line", "second line", " third line", ]), outdent("\n".join([ " first line", " second line", " third line", ])) )
def test_add_more_errors(self): self.assert_pcs_fail( "stonith level add x rh7-X F0 dev@ce", outdent( """\ Error: 'x' is not a valid level value, use a positive integer Error: Node 'rh7-X' does not appear to exist in configuration, use --force to override Error: invalid device id 'dev@ce', '@' is not a valid character for a device id Error: Stonith resource(s) 'F0' do not exist, use --force to override """ ) ) self.assert_pcs_fail( "stonith level add x rh7-X F0 dev@ce --force", outdent( """\ Error: 'x' is not a valid level value, use a positive integer Error: invalid device id 'dev@ce', '@' is not a valid character for a device id Warning: Node 'rh7-X' does not appear to exist in configuration Warning: Stonith resource(s) 'F0' do not exist """ ) )
def test_regexp(self): self.fixture_stonith_resource("F1") self.assert_pcs_success( "stonith level add 1 regexp%node-\d+ F1", "CIB has been upgraded to the latest schema version.\n" ) self.assert_pcs_success( "stonith level", outdent( """\ Target: node-\d+ Level 1 - F1 """ ) )
def test_attribute(self): self.fixture_stonith_resource("F1") self.assert_pcs_success( "stonith level add 1 attrib%fencewith=levels F1", "CIB has been upgraded to the latest schema version.\n" ) self.assert_pcs_success( "stonith level", outdent( """\ Target: fencewith=levels Level 1 - F1 """ ) )
def test_nonexistant_device(self): self.assert_pcs_fail( "stonith level add 1 rh7-1 F1", "Error: Stonith resource(s) 'F1' do not exist" ", use --force to override\n" ) self.assert_pcs_success( "stonith level add 1 rh7-1 F1 --force", "Warning: Stonith resource(s) 'F1' do not exist\n" ) self.assert_pcs_success( "stonith level", outdent( """\ Target: rh7-1 Level 1 - F1 """ ) )
def test_nonexistant_devices(self): self.fixture_stonith_resource("F1") self.assert_pcs_fail( "stonith level add 1 rh7-1 F1 F2 F3", "Error: Stonith resource(s) 'F2', 'F3' do not exist" ", use --force to override\n" ) self.assert_pcs_success( "stonith level add 1 rh7-1 F1 F2 F3 --force", "Warning: Stonith resource(s) 'F2', 'F3' do not exist\n" ) self.assert_pcs_success( "stonith level", outdent( """\ Target: rh7-1 Level 1 - F1,F2,F3 """ ) )
def test_nonexistant_node(self): self.fixture_stonith_resource("F1") self.assert_pcs_fail( "stonith level add 1 rh7-X F1", "Error: Node 'rh7-X' does not appear to exist in configuration" ", use --force to override\n" ) self.assert_pcs_success( "stonith level add 1 rh7-X F1 --force", "Warning: Node 'rh7-X' does not appear to exist in configuration\n" ) self.assert_pcs_success( "stonith level", outdent( """\ Target: rh7-X Level 1 - F1 """ ) )