From bff5d01d0727a1c5fe21fb9041f39f750a5a9499 Mon Sep 17 00:00:00 2001 From: Adam King Date: Mon, 5 Oct 2020 08:07:00 -0400 Subject: [PATCH] mgr/cephadm: mon to mgr service type in scheduler tests now that we're not deploying even number of mons, need to use different service type for scheduler tests Signed-off-by: Adam King --- .../mgr/cephadm/tests/test_scheduling.py | 98 +++++++++---------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/src/pybind/mgr/cephadm/tests/test_scheduling.py b/src/pybind/mgr/cephadm/tests/test_scheduling.py index efbbb9b99d90b..205b48d95b887 100644 --- a/src/pybind/mgr/cephadm/tests/test_scheduling.py +++ b/src/pybind/mgr/cephadm/tests/test_scheduling.py @@ -89,12 +89,12 @@ def get_result(key, results): def mk_spec_and_host(spec_section, hosts, explicit_key, explicit, count): if spec_section == 'hosts': - mk_spec = lambda: ServiceSpec('mon', placement=PlacementSpec( + mk_spec = lambda: ServiceSpec('mgr', placement=PlacementSpec( hosts=explicit, count=count, )) elif spec_section == 'label': - mk_spec = lambda: ServiceSpec('mon', placement=PlacementSpec( + mk_spec = lambda: ServiceSpec('mgr', placement=PlacementSpec( label='mylabel', count=count, )) @@ -105,7 +105,7 @@ def mk_spec_and_host(spec_section, hosts, explicit_key, explicit, count): '12': '[1-2]', '123': '*', }[explicit_key] - mk_spec = lambda: ServiceSpec('mon', placement=PlacementSpec( + mk_spec = lambda: ServiceSpec('mgr', placement=PlacementSpec( host_pattern=pattern, count=count, )) @@ -162,17 +162,17 @@ def run_scheduler_test(results, mk_spec, hosts, get_daemons_func, key_elems): # | | | | | test_explicit_scheduler_results = [ (k("* * 0 *"), error(ServiceSpecValidationError, 'num/count must be > 1')), - (k("* e N l"), error(OrchestratorValidationError, 'Cannot place : No matching hosts for label mylabel')), - (k("* e N p"), error(OrchestratorValidationError, 'Cannot place : No matching hosts')), + (k("* e N l"), error(OrchestratorValidationError, 'Cannot place : No matching hosts for label mylabel')), + (k("* e N p"), error(OrchestratorValidationError, 'Cannot place : No matching hosts')), (k("* e N h"), error(OrchestratorValidationError, 'placement spec is empty: no hosts, no label, no pattern, no count')), (k("* e * *"), none), - (k("1 12 * h"), error(OrchestratorValidationError, "Cannot place on 2: Unknown hosts")), - (k("1 123 * h"), error(OrchestratorValidationError, "Cannot place on 2, 3: Unknown hosts")), + (k("1 12 * h"), error(OrchestratorValidationError, "Cannot place on 2: Unknown hosts")), + (k("1 123 * h"), error(OrchestratorValidationError, "Cannot place on 2, 3: Unknown hosts")), (k("1 * * *"), exactly('1')), (k("12 1 * *"), exactly('1')), (k("12 12 1 *"), one_of('1', '2')), (k("12 12 * *"), exactly('1', '2')), - (k("12 123 * h"), error(OrchestratorValidationError, "Cannot place on 3: Unknown hosts")), + (k("12 123 * h"), error(OrchestratorValidationError, "Cannot place on 3: Unknown hosts")), (k("12 123 1 *"), one_of('1', '2', '3')), (k("12 123 * *"), two_of('1', '2', '3')), (k("123 1 * *"), exactly('1')), @@ -237,9 +237,9 @@ def test_explicit_scheduler(host_key, hosts, # | | | | | | test_scheduler_daemons_results = [ (k("* 1 * * *"), exactly('1')), - (k("1 123 * * h"), error(OrchestratorValidationError, 'Cannot place on 2, 3: Unknown hosts')), + (k("1 123 * * h"), error(OrchestratorValidationError, 'Cannot place on 2, 3: Unknown hosts')), (k("1 123 * * *"), exactly('1')), - (k("12 123 * * h"), error(OrchestratorValidationError, 'Cannot place on 3: Unknown hosts')), + (k("12 123 * * h"), error(OrchestratorValidationError, 'Cannot place on 3: Unknown hosts')), (k("12 123 N * *"), exactly('1', '2')), (k("12 123 1 * *"), one_of('1', '2')), (k("12 123 2 * *"), exactly('1', '2')), @@ -304,7 +304,7 @@ def test_scheduler_daemons(host_key, hosts, spec_section_key, spec_section): mk_spec, hosts = mk_spec_and_host(spec_section, hosts, explicit_key, explicit, count) dds = [ - DaemonDescription('mon', d, d) + DaemonDescription('mgr', d, d) for d in daemons ] run_scheduler_test( @@ -330,7 +330,7 @@ class NodeAssignmentTest(NamedTuple): [ # just hosts NodeAssignmentTest( - 'mon', + 'mgr', PlacementSpec(hosts=['smithi060:[v2:172.21.15.60:3301,v1:172.21.15.60:6790]=c']), ['smithi060'], [], @@ -338,12 +338,12 @@ class NodeAssignmentTest(NamedTuple): ), # all_hosts NodeAssignmentTest( - 'mon', + 'mgr', PlacementSpec(host_pattern='*'), 'host1 host2 host3'.split(), [ - DaemonDescription('mon', 'a', 'host1'), - DaemonDescription('mon', 'b', 'host2'), + DaemonDescription('mgr', 'a', 'host1'), + DaemonDescription('mgr', 'b', 'host2'), ], ['host1', 'host2', 'host3'] ), @@ -358,59 +358,59 @@ class NodeAssignmentTest(NamedTuple): ), # count + partial host list NodeAssignmentTest( - 'mon', + 'mgr', PlacementSpec(count=3, hosts=['host3']), 'host1 host2 host3'.split(), [ - DaemonDescription('mon', 'a', 'host1'), - DaemonDescription('mon', 'b', 'host2'), + DaemonDescription('mgr', 'a', 'host1'), + DaemonDescription('mgr', 'b', 'host2'), ], ['host3'] ), # count 1 + partial host list NodeAssignmentTest( - 'mon', + 'mgr', PlacementSpec(count=1, hosts=['host3']), 'host1 host2 host3'.split(), [ - DaemonDescription('mon', 'a', 'host1'), - DaemonDescription('mon', 'b', 'host2'), + DaemonDescription('mgr', 'a', 'host1'), + DaemonDescription('mgr', 'b', 'host2'), ], ['host3'] ), # count + partial host list + existing NodeAssignmentTest( - 'mon', + 'mgr', PlacementSpec(count=2, hosts=['host3']), 'host1 host2 host3'.split(), [ - DaemonDescription('mon', 'a', 'host1'), + DaemonDescription('mgr', 'a', 'host1'), ], ['host3'] ), # count + partial host list + existing (deterministic) NodeAssignmentTest( - 'mon', + 'mgr', PlacementSpec(count=2, hosts=['host1']), 'host1 host2'.split(), [ - DaemonDescription('mon', 'a', 'host1'), + DaemonDescription('mgr', 'a', 'host1'), ], ['host1'] ), # count + partial host list + existing (deterministic) NodeAssignmentTest( - 'mon', + 'mgr', PlacementSpec(count=2, hosts=['host1']), 'host1 host2'.split(), [ - DaemonDescription('mon', 'a', 'host2'), + DaemonDescription('mgr', 'a', 'host2'), ], ['host1'] ), # label only NodeAssignmentTest( - 'mon', + 'mgr', PlacementSpec(label='foo'), 'host1 host2 host3'.split(), [], @@ -418,11 +418,11 @@ class NodeAssignmentTest(NamedTuple): ), # host_pattern NodeAssignmentTest( - 'mon', - PlacementSpec(host_pattern='mon*'), - 'monhost1 monhost2 datahost'.split(), + 'mgr', + PlacementSpec(host_pattern='mgr*'), + 'mgrhost1 mgrhost2 datahost'.split(), [], - ['monhost1', 'monhost2'] + ['mgrhost1', 'mgrhost2'] ), ]) def test_node_assignment(service_type, placement, hosts, daemons, expected): @@ -453,7 +453,7 @@ class NodeAssignmentTest2(NamedTuple): [ # just count NodeAssignmentTest2( - 'mon', + 'mgr', PlacementSpec(count=1), 'host1 host2 host3'.split(), [], @@ -463,7 +463,7 @@ class NodeAssignmentTest2(NamedTuple): # hosts + (smaller) count NodeAssignmentTest2( - 'mon', + 'mgr', PlacementSpec(count=1, hosts='host1 host2'.split()), 'host1 host2'.split(), [], @@ -472,28 +472,28 @@ class NodeAssignmentTest2(NamedTuple): ), # hosts + (smaller) count, existing NodeAssignmentTest2( - 'mon', + 'mgr', PlacementSpec(count=1, hosts='host1 host2 host3'.split()), 'host1 host2 host3'.split(), - [DaemonDescription('mon', 'mon.a', 'host1'),], + [DaemonDescription('mgr', 'mgr.a', 'host1'),], 1, ['host1', 'host2', 'host3'], ), # hosts + (smaller) count, (more) existing NodeAssignmentTest2( - 'mon', + 'mgr', PlacementSpec(count=1, hosts='host1 host2 host3'.split()), 'host1 host2 host3'.split(), [ - DaemonDescription('mon', 'a', 'host1'), - DaemonDescription('mon', 'b', 'host2'), + DaemonDescription('mgr', 'a', 'host1'), + DaemonDescription('mgr', 'b', 'host2'), ], 1, ['host1', 'host2'] ), # count + partial host list NodeAssignmentTest2( - 'mon', + 'mgr', PlacementSpec(count=2, hosts=['host3']), 'host1 host2 host3'.split(), [], @@ -502,7 +502,7 @@ class NodeAssignmentTest2(NamedTuple): ), # label + count NodeAssignmentTest2( - 'mon', + 'mgr', PlacementSpec(count=1, label='foo'), 'host1 host2 host3'.split(), [], @@ -524,7 +524,7 @@ def test_node_assignment2(service_type, placement, hosts, [ # hosts + (smaller) count, (more) existing NodeAssignmentTest2( - 'mon', + 'mgr', PlacementSpec(count=3, hosts='host3'.split()), 'host1 host2 host3'.split(), [], @@ -533,7 +533,7 @@ def test_node_assignment2(service_type, placement, hosts, ), # count + partial host list NodeAssignmentTest2( - 'mon', + 'mgr', PlacementSpec(count=2, hosts=['host3']), 'host1 host2 host3'.split(), [], @@ -577,27 +577,27 @@ class NodeAssignmentTestBadSpec(NamedTuple): [ # unknown host NodeAssignmentTestBadSpec( - 'mon', + 'mgr', PlacementSpec(hosts=['unknownhost']), ['knownhost'], [], - "Cannot place on unknownhost: Unknown hosts" + "Cannot place on unknownhost: Unknown hosts" ), # unknown host pattern NodeAssignmentTestBadSpec( - 'mon', + 'mgr', PlacementSpec(host_pattern='unknownhost'), ['knownhost'], [], - "Cannot place : No matching hosts" + "Cannot place : No matching hosts" ), # unknown label NodeAssignmentTestBadSpec( - 'mon', + 'mgr', PlacementSpec(label='unknownlabel'), [], [], - "Cannot place : No matching hosts for label unknownlabel" + "Cannot place : No matching hosts for label unknownlabel" ), ]) def test_bad_specs(service_type, placement, hosts, daemons, expected): -- 2.39.5