def test_rgw_update_fail(self, _send_command, _get_connection, _save_host, _rm_host, cephadm_module): with self._with_host(cephadm_module, 'host1'): with self._with_host(cephadm_module, 'host2'): ps = PlacementSpec(hosts=['host1'], count=1) c = cephadm_module.add_rgw( RGWSpec('realm', 'zone1', placement=ps)) [out] = wait(cephadm_module, c) match_glob(out, "Deployed rgw.realm.zone1.host1.* on host 'host1'") ps = PlacementSpec(hosts=['host2'], count=1) c = cephadm_module.add_rgw( RGWSpec('realm', 'zone2', placement=ps)) [out] = wait(cephadm_module, c) match_glob(out, "Deployed rgw.realm.zone2.host2.* on host 'host2'") c = cephadm_module.list_daemons() r = wait(cephadm_module, c) assert len(r) == 2 with pytest.raises(OrchestratorError): ps = PlacementSpec(hosts=['host1', 'host2'], count=2) c = cephadm_module.add_rgw( RGWSpec('realm', 'zone1', placement=ps)) [out] = wait(cephadm_module, c)
def test_mon_update(self, _send_command, _get_connection, _save_host, _rm_host, cephadm_module): with self._with_host(cephadm_module, 'test'): ps = PlacementSpec(hosts=['test:0.0.0.0=a'], count=1) c = cephadm_module.add_mon(ServiceSpec('mon', placement=ps)) assert wait(cephadm_module, c) == ["Deployed mon.a on host 'test'"] with pytest.raises(OrchestratorError, match="is missing a network spec"): ps = PlacementSpec(hosts=['test'], count=1) c = cephadm_module.add_mon(ServiceSpec('mon', placement=ps)) wait(cephadm_module, c)
def test_rgw_update(self, _send_command, _get_connection, _save_host, _rm_host, cephadm_module): with self._with_host(cephadm_module, 'host1'): with self._with_host(cephadm_module, 'host2'): ps = PlacementSpec(hosts=['host1'], count=1) c = cephadm_module.add_rgw(RGWSpec('realm', 'zone1', placement=ps)) [out] = wait(cephadm_module, c) match_glob(out, "Deployed rgw.realm.zone1.host1.* on host 'host1'") ps = PlacementSpec(hosts=['host1', 'host2'], count=2) c = cephadm_module._apply_service(RGWSpec('realm', 'zone1', placement=ps)) [out] = wait(cephadm_module, c) match_glob(out, "Deployed rgw.realm.zone1.host2.* on host 'host2'")
def test_prometheus(self, _send_command, _get_connection, cephadm_module): with self._with_host(cephadm_module, 'test'): ps = PlacementSpec(hosts=['test'], count=1) c = cephadm_module.add_prometheus(ServiceSpec(placement=ps)) [out] = wait(cephadm_module, c) assert "Deployed prometheus." in out assert " on host 'test'" in out ps = PlacementSpec(hosts=['test'], count=2) c = cephadm_module.apply_prometheus(ServiceSpec(placement=ps)) [out] = wait(cephadm_module, c) assert "Deployed prometheus." in out assert " on host 'test'" in out
def test_rgw_update(self, cephadm_module): with self._with_host(cephadm_module, 'host1'): with self._with_host(cephadm_module, 'host2'): ps = PlacementSpec(hosts=['host1'], count=1) c = cephadm_module.add_rgw( RGWSpec('realm', 'zone1', placement=ps)) [out] = wait(cephadm_module, c) match_glob(out, "Deployed rgw.realm.zone1.host1.* on host 'host1'") ps = PlacementSpec(hosts=['host1', 'host2'], count=2) r = cephadm_module._apply_service( RGWSpec('realm', 'zone1', placement=ps)) assert r
def test_mon_add(self, cephadm_module): with self._with_host(cephadm_module, 'test'): ps = PlacementSpec(hosts=['test:0.0.0.0=a'], count=1) c = cephadm_module.add_mon(ServiceSpec('mon', placement=ps)) assert wait(cephadm_module, c) == ["Deployed mon.a on host 'test'"] with pytest.raises( OrchestratorError, match= "Must set public_network config option or specify a CIDR network," ): ps = PlacementSpec(hosts=['test'], count=1) c = cephadm_module.add_mon(ServiceSpec('mon', placement=ps)) wait(cephadm_module, c)
def test_mgr_update(self, _send_command, _get_connection, _save_host, _rm_host, cephadm_module): with self._with_host(cephadm_module, 'test'): ps = PlacementSpec(hosts=['test:0.0.0.0=a'], count=1) c = cephadm_module.apply_mgr(ServiceSpec(placement=ps)) [out] = wait(cephadm_module, c) match_glob(out, "Deployed mgr.* on host 'test'")
def test_apply_prometheus_save(self, _save_spec, cephadm_module): with self._with_host(cephadm_module, 'test'): ps = PlacementSpec(hosts=['test'], count=1) spec = ServiceSpec('prometheus', placement=ps) c = cephadm_module.apply_prometheus(spec) _save_spec.assert_called_with(spec) assert wait(cephadm_module, c) == 'Scheduled prometheus update...'
def test_apply_rbd_mirror_save(self, _save_spec, cephadm_module): with self._with_host(cephadm_module, 'test'): ps = PlacementSpec(hosts=['test'], count=1) spec = ServiceSpec('rbd-mirror', placement=ps) c = cephadm_module.apply_rbd_mirror(spec) _save_spec.assert_called_with(spec) assert wait(cephadm_module, c) == 'Scheduled rbd-mirror update...'
def test_rbd_mirror(self, cephadm_module): with self._with_host(cephadm_module, 'test'): ps = PlacementSpec(hosts=['test'], count=1) c = cephadm_module.add_rbd_mirror( ServiceSpec('rbd-mirror', placement=ps)) [out] = wait(cephadm_module, c) match_glob(out, "Deployed rbd-mirror.* on host 'test'")
def test_mds(self, cephadm_module): with self._with_host(cephadm_module, 'test'): ps = PlacementSpec(hosts=['test'], count=1) c = cephadm_module.add_mds(ServiceSpec('mds', 'name', placement=ps)) [out] = wait(cephadm_module, c) match_glob(out, "Deployed mds.name.* on host 'test'")
def test_mds(self, _send_command, _get_connection, cephadm_module): with self._with_host(cephadm_module, 'test'): ps = PlacementSpec(hosts=['test'], count=1) c = cephadm_module.add_mds(StatelessServiceSpec('name', placement=ps)) [out] = self._wait(cephadm_module, c) assert "Deployed mds.name." in out assert " on host 'test'" in out
def test_rgw(self, _send_command, _get_connection, ssh_module): with self._with_host(ssh_module, 'test'): ps = PlacementSpec(nodes=['test']) c = ssh_module.add_rgw(RGWSpec('name', ps)) [out] = self._wait(ssh_module, c) assert "(Re)deployed rgw.name." in out assert " on host 'test'" in out
def test_rbd_mirror(self, _send_command, _get_connection, cephadm_module): with self._with_host(cephadm_module, 'test'): ps = PlacementSpec(nodes=['test']) c = cephadm_module.add_rbd_mirror(StatelessServiceSpec('name', ps)) [out] = self._wait(cephadm_module, c) assert "(Re)deployed rbd-mirror." in out assert " on host 'test'" in out
def test_rbd_mirror(self, _send_command, _get_connection, cephadm_module): with self._with_host(cephadm_module, 'test'): ps = PlacementSpec(hosts=['test'], count=1) c = cephadm_module.add_rbd_mirror( ServiceSpec(name='name', placement=ps)) [out] = wait(cephadm_module, c) match_glob(out, "Deployed rbd-mirror.* on host 'test'")
def test_apply_node_exporter_save(self, _send_command, _get_connection, _save_spec, _save_host, _rm_host, cephadm_module): with self._with_host(cephadm_module, 'test'): ps = PlacementSpec(hosts=['test'], count=1) spec = ServiceSpec('node_exporter', placement=ps) c = cephadm_module.apply_node_exporter(spec) _save_spec.assert_called_with(spec) assert wait(cephadm_module, c) == 'Scheduled node_exporter update...'
def test_rgw(self, _send_command, _get_connection, cephadm_module): with self._with_host(cephadm_module, 'test'): ps = PlacementSpec(nodes=['test']) c = cephadm_module.add_rgw(RGWSpec('realm', 'zone', ps)) [out] = self._wait(cephadm_module, c) assert "(Re)deployed rgw.realm.zone." in out assert " on host 'test'" in out
def test_rbd_mirror(self, _send_command, _get_connection, _save_host, _rm_host, cephadm_module): # type: (mock.Mock, mock.Mock, mock.Mock, mock.Mock, CephadmOrchestrator) -> None with self._with_host(cephadm_module, 'test'): ps = PlacementSpec(hosts=['test'], count=1) c = cephadm_module.add_rbd_mirror(ServiceSpec('rbd-mirror', placement=ps)) [out] = wait(cephadm_module, c) match_glob(out, "Deployed rbd-mirror.* on host 'test'")
def test_prometheus(self, _send_command, _get_connection, _save_host, _rm_host, cephadm_module): with self._with_host(cephadm_module, 'test'): ps = PlacementSpec(hosts=['test'], count=1) c = cephadm_module.add_prometheus(ServiceSpec('prometheus', placement=ps)) [out] = wait(cephadm_module, c) match_glob(out, "Deployed prometheus.* on host 'test'")
def test_rgw(self, _send_command, _get_connection, _save_host, _rm_host, cephadm_module): with self._with_host(cephadm_module, 'test'): ps = PlacementSpec(hosts=['test'], count=1) c = cephadm_module.add_rgw(RGWSpec('realm', 'zone', placement=ps)) [out] = wait(cephadm_module, c) match_glob(out, "Deployed rgw.realm.zone.* on host 'test'")
def test_mgr_update(self, _send_command, _get_connection, cephadm_module): with self._with_host(cephadm_module, 'test'): ps = PlacementSpec(hosts=['test:0.0.0.0=a'], count=1) c = cephadm_module.update_mgrs(StatefulServiceSpec(placement=ps)) [out] = wait(cephadm_module, c) assert "Deployed mgr." in out assert " on host 'test'" in out
def test_grafana(self, cephadm_module): with self._with_host(cephadm_module, 'test'): ps = PlacementSpec(hosts=['test'], count=1) c = cephadm_module.add_grafana(ServiceSpec('grafana', placement=ps)) [out] = wait(cephadm_module, c) match_glob(out, "Deployed grafana.* on host 'test'")
def test_alertmanager(self, cephadm_module): with self._with_host(cephadm_module, 'test'): ps = PlacementSpec(hosts=['test'], count=1) c = cephadm_module.add_alertmanager( ServiceSpec('alertmanager', placement=ps)) [out] = wait(cephadm_module, c) match_glob(out, "Deployed alertmanager.* on host 'test'")
def test_mgr_update(self, cephadm_module): with self._with_host(cephadm_module, 'test'): ps = PlacementSpec(hosts=['test:0.0.0.0=a'], count=1) r = cephadm_module._apply_service(ServiceSpec('mgr', placement=ps)) assert r
def test_parse_placement_specs(test_input, expected): ret = PlacementSpec.from_strings(test_input.split()) assert str(ret) == expected
def test_bad_placements(placement): try: s = PlacementSpec.from_strings(placement.split(' ')) assert False except OrchestratorValidationError as e: pass
class NodeAssignmentTest(NamedTuple): service_type: str placement: PlacementSpec hosts: List[str] daemons: List[DaemonDescription] expected: List[str] @pytest.mark.parametrize( "service_type,placement,hosts,daemons,expected", [ # just hosts NodeAssignmentTest( 'mon', PlacementSpec(hosts=[ 'smithi060:[v2:172.21.15.60:3301,v1:172.21.15.60:6790]=c' ]), ['smithi060'], [], ['smithi060']), # all_hosts NodeAssignmentTest('mon', PlacementSpec(all_hosts=True), 'host1 host2 host3'.split(), [ DaemonDescription('mon', 'a', 'host1'), DaemonDescription('mon', 'b', 'host2'), ], ['host1', 'host2', 'host3']), # count + partial host list NodeAssignmentTest('mon', PlacementSpec(count=3, hosts=['host3']), 'host1 host2 host3'.split(), [ DaemonDescription('mon', 'a', 'host1'), DaemonDescription('mon', 'b', 'host2'), ], ['host1', 'host2', 'host3']), # count + partial host list + existing NodeAssignmentTest('mon', PlacementSpec(count=2, hosts=['host3']),
def test_mon_update(self, _send_command, _get_connection, cephadm_module): with self._with_host(cephadm_module, 'test'): ps = PlacementSpec(hosts=['test:0.0.0.0=a'], count=1) c = cephadm_module.update_mons(StatefulServiceSpec(placement=ps)) assert wait(cephadm_module, c) == ["Deployed mon.a on host 'test'"]