def setUp(self): """ Set up :class:`RCv3Tests`. """ self.reactor = object() self.patch(_rcv3.cc_rcv3, "bulk_add", intent_func("ba")) self.patch(_rcv3.cc_rcv3, "bulk_delete", intent_func("bd"))
def _invoke(self): return get_scaling_group_servers('tid', 'gid', self.now, cache_class=EffectServersCache, all_as_servers=intent_func("all-as"), all_servers=intent_func("alls"))
def test_release_performs(self): """ release performs effect from release_eff """ self.lock.dispatcher = SequenceDispatcher([(("release", ), const("ret"))]) self.lock.release_eff = intent_func("release") self.assertEqual(self.successResultOf(self.lock.release()), "ret")
def test_release_performs(self): """ release performs effect from release_eff """ self.lock.dispatcher = SequenceDispatcher([ (("release",), const("ret"))]) self.lock.release_eff = intent_func("release") self.assertEqual(self.successResultOf(self.lock.release()), "ret")
def test_is_acquired_performs(self): """ is_acquired performs effect from is_acquired_eff """ self.lock.dispatcher = SequenceDispatcher([ (("is_acquired",), const("ret"))]) self.lock.is_acquired_eff = intent_func("is_acquired") self.assertEqual(self.successResultOf(self.lock.is_acquired()), "ret")
def test_is_acquired_performs(self): """ is_acquired performs effect from is_acquired_eff """ self.lock.dispatcher = SequenceDispatcher([(("is_acquired", ), const("ret"))]) self.lock.is_acquired_eff = intent_func("is_acquired") self.assertEqual(self.successResultOf(self.lock.is_acquired()), "ret")
def setUp(self): """mock `extract_clb_drained_at`""" self.feeds = {'11feed': 1.0, '22feed': 2.0} self.mock_eda = patch( self, 'otter.convergence.gathering.extract_clb_drained_at', side_effect=lambda f: self.feeds[f]) patch(self, "otter.convergence.gathering.get_clb_node_feed", side_effect=intent_func("gcnf"))
def test_acquire_performs(self): """ acquire performs effect from acquire_eff """ self.lock.dispatcher = SequenceDispatcher([ (("acquire", "blocking", "timeout"), const("ret"))]) self.lock.acquire_eff = intent_func("acquire") self.assertEqual( self.successResultOf(self.lock.acquire("blocking", "timeout")), "ret")
def setUp(self): self.patch(sh, "trigger_convergence", intent_func("tg")) self.state = GroupState("tid", "gid", 'group-name', {}, {}, None, {}, False, ScalingGroupStatus.ACTIVE, desired=2) self.manifest = {"state": self.state}
def setUp(self): """mock `extract_clb_drained_at`""" self.feeds = {'11feed': 1.0, '22feed': 2.0} self.mock_eda = patch( self, 'otter.convergence.gathering.extract_clb_drained_at', side_effect=lambda f: self.feeds[f]) patch(self, "otter.convergence.gathering.get_clb_node_feed", side_effect=intent_func("gcnf"))
def setUp(self): self.clock = Clock() self.log = mock_log() self.patch(sh, "get_groups_to_converge", intent_func("ggtc")) self.patch(sh, "check_and_trigger", lambda t, g: t + g) self.s = sh.SelfHeal(self.clock, base_dispatcher, "cf", 300.0, self.log) self.groups = [ {"tenantId": "t{}".format(i), "groupId": "g{}".format(i)} for i in range(5)]
def setUp(self): self.clock = Clock() self.log = mock_log() self.patch(sh, "get_groups_to_converge", intent_func("ggtc")) self.patch(sh, "check_and_trigger", lambda t, g: t + g) self.s = sh.SelfHeal(self.clock, base_dispatcher, "cf", 300.0, self.log) self.groups = [{ "tenantId": "t{}".format(i), "groupId": "g{}".format(i) } for i in range(5)]
def test_acquire_performs(self): """ acquire performs effect from acquire_eff """ self.lock.dispatcher = SequenceDispatcher([ (("acquire", "blocking", "timeout"), const("ret")) ]) self.lock.acquire_eff = intent_func("acquire") self.assertEqual( self.successResultOf(self.lock.acquire("blocking", "timeout")), "ret")
def test_calls_read_entries(self): """ Calls `cf.read_entries` with CLB servicetype and atom URL and returns the feed part of the result """ from otter.cloud_client.clb import cf self.patch(cf, "read_entries", intent_func("re")) eff = get_clb_node_feed("12", "13") seq = [(("re", ServiceType.CLOUD_LOAD_BALANCERS, "loadbalancers/12/nodes/13.atom", {}, cf.Direction.NEXT, "request-get-clb-node-feed"), const((["feed1"], { "param": "2" })))] self.assertEqual(perform_sequence(seq, eff), ["feed1"])
def test_calls_read_entries(self): """ Calls `cf.read_entries` with CLB servicetype and atom URL and returns the feed part of the result """ from otter.cloud_client.clb import cf self.patch(cf, "read_entries", intent_func("re")) eff = get_clb_node_feed("12", "13") seq = [ (("re", ServiceType.CLOUD_LOAD_BALANCERS, "loadbalancers/12/nodes/13.atom", {}, cf.Direction.NEXT, "request-get-clb-node-feed"), const((["feed1"], {"param": "2"}))) ] self.assertEqual(perform_sequence(seq, eff), ["feed1"])
def setUp(self): from otter.convergence.steps import rcv3 as step_rcv3 self.patch(step_rcv3, "bulk_add", intent_func("ba")) self.pairs = pset([("l1", "n1"), ("l2", "n2")]) self.step = BulkAddToRCv3(lb_node_pairs=self.pairs)
def setUp(self): self.patch(sh, "trigger_convergence", intent_func("tg")) self.state = GroupState("tid", "gid", 'group-name', {}, {}, None, {}, False, ScalingGroupStatus.ACTIVE, desired=2) self.manifest = {"state": self.state}
def setUp(self): """ mock dependent functions """ self.connect_cass_servers = patch( self, 'otter.metrics.connect_cass_servers') self.client = mock.Mock(spec=['disconnect']) self.client.disconnect.return_value = succeed(None) self.connect_cass_servers.return_value = self.client self.log = mock_log() self.get_all_metrics = patch(self, 'otter.metrics.get_all_metrics', return_value=succeed("metrics")) self.groups = [{ "tenantId": "t1", "groupId": "g1", "launch_config": '{"type": "launch_server"}' }, { "tenantId": "t1", "groupId": "g2", "paused": False, "launch_config": '{"type": "launch_server"}' }, { "tenantId": "t1", "groupId": "gp", "paused": True, "launch_config": '{"type": "launch_server"}' }, { "tenantId": "t1", "groupId": "g12", "launch_config": '{"type": "launch_stack"}' }, { "tenantId": "t3", "groupId": "g3", "launch_config": '{"type": "launch_stack"}' }, { "tenantId": "t2", "groupId": "g11", "launch_config": '{"type": "launch_server"}' }] self.lc_groups = {"t1": self.groups[:2], "t2": [self.groups[-1]]} self.add_to_cloud_metrics = patch(self, 'otter.metrics.add_to_cloud_metrics', side_effect=intent_func("atcm")) self.config = { 'cassandra': 'c', 'identity': identity_config, 'metrics': { 'service': 'ms', 'tenant_id': 'tid', 'region': 'IAD', 'ttl': 200, "last_tenant_fpath": "lpath" }, 'region': 'r', 'cloudServersOpenStack': 'nova', 'cloudLoadBalancers': 'clb', 'cloudOrchestration': 'orch', 'rackconnect': 'rc', "non-convergence-tenants": ["ct"] } self.sequence = SequenceDispatcher([ (GetAllValidGroups(), const(self.groups)), (TenantScope(mock.ANY, "tid"), nested_sequence([(("atcm", 200, "r", "metrics", 2, self.config, self.log, False), noop)])) ]) self.get_dispatcher = patch(self, "otter.metrics.get_dispatcher", return_value=self.sequence)
def setUp(self): from otter.convergence.steps import rcv3 as step_rcv3 self.patch(step_rcv3, "bulk_delete", intent_func("bd")) self.pairs = pset([("l1", "n1"), ("l2", "n2")]) self.step = BulkRemoveFromRCv3(lb_node_pairs=self.pairs)
def _invoke(self): return get_scaling_group_servers( 'tid', 'gid', self.now, cache_class=EffectServersCache, all_as_servers=intent_func("all-as"), all_servers=intent_func("alls"))