def test_update_route53_records(self, cli, res):
     cli.return_value.list_hosted_zones_by_name.return_value = {'HostedZones': [{'Id': '', 'Name': 'test.'}]}
     res.return_value.instances.filter.return_value = instances()
     autoscaling_members = self.manager.get_autoscaling_members()
     self.assertIsNone(self.keeper.update_route53_records(autoscaling_members))
     self.keeper.hosted_zone = 'bla'
     self.assertRaises(Exception, self.keeper.update_route53_records, autoscaling_members)
Ejemplo n.º 2
0
 def setUp(self, res):
     res.return_value.instances.filter.return_value = instances()
     self.manager = EtcdManager()
     self.manager.instance_id = 'i-deadbeef3'
     self.manager.region = 'eu-west-1'
     self.cluster = EtcdCluster(self.manager)
     self.cluster.load_members()
Ejemplo n.º 3
0
 def setUp(self, res):
     res.return_value.instances.filter.return_value = instances()
     self.manager = EtcdManager()
     self.manager.instance_id = 'i-deadbeef3'
     self.manager.region = 'eu-west-1'
     self.cluster = EtcdCluster(self.manager)
     self.cluster.load_members()
 def setUp(self, res):
     res.return_value.instances.filter.return_value = instances()
     self.manager = EtcdManager()
     self.manager.get_my_instance()
     self.manager.instance_id = 'i-deadbeef3'
     self.manager.region = 'eu-west-1'
     self.keeper = HouseKeeper(self.manager, 'test.')
     self.members_changed = self.keeper.members_changed()
 def setUp(self, res):
     res.return_value.instances.filter.return_value = instances()
     self.manager = EtcdManager()
     self.manager.get_my_instance()
     self.manager.instance_id = 'i-deadbeef3'
     self.manager.region = 'eu-west-1'
     self.keeper = HouseKeeper(self.manager, 'test.')
     self.members_changed = self.keeper.members_changed()
 def test_run(self, cli, res):
     cli.return_value.list_hosted_zones_by_name.return_value = {'HostedZones': [{'Id': '', 'Name': 'test.'}]}
     res.return_value.instances.filter.return_value = instances()
     self.assertRaises(Exception, self.keeper.run)
     self.keeper.manager.etcd_pid = 1
     self.assertRaises(Exception, self.keeper.run)
     self.keeper.is_leader = Mock(side_effect=Exception)
     self.assertRaises(Exception, self.keeper.run)
 def setUp(self, res):
     res.return_value.instances.filter.return_value = instances()
     self.manager = EtcdManager()
     self.manager.instance_id = 'i-deadbeef3'
     self.manager.region = 'eu-west-1'
     EtcdCluster.REGIONS = ['eu-west-1']
     self.cluster = EtcdCluster(self.manager)
     self.cluster.load_members()
     self.assertFalse(EtcdCluster.is_multiregion())
 def setUp(self, res):
     res.return_value.instances.filter.return_value = instances()
     self.manager = EtcdManager()
     self.manager.instance_id = "i-deadbeef3"
     self.manager.region = "eu-west-1"
     EtcdCluster.REGIONS = ["eu-west-1"]
     self.cluster = EtcdCluster(self.manager)
     self.cluster.load_members()
     self.assertFalse(EtcdCluster.is_multiregion())
 def test_run(self, cli, res):
     cli.return_value.list_hosted_zones_by_name.return_value = {
         'HostedZones': [{
             'Id': '',
             'Name': 'test.'
         }]
     }
     res.return_value.instances.filter.return_value = instances()
     self.assertRaises(Exception, self.keeper.run)
     self.keeper.manager.etcd_pid = 1
     self.assertRaises(Exception, self.keeper.run)
     self.keeper.is_leader = Mock(side_effect=Exception)
     self.assertRaises(Exception, self.keeper.run)
 def test_update_route53_records(self, cli, res):
     cli.return_value.list_hosted_zones_by_name.return_value = {
         'HostedZones': [{
             'Id': '',
             'Name': 'test.'
         }]
     }
     res.return_value.instances.filter.return_value = instances()
     autoscaling_members = self.manager.get_autoscaling_members()
     self.assertIsNone(
         self.keeper.update_route53_records(autoscaling_members))
     self.keeper.hosted_zone = 'bla'
     self.assertRaises(Exception, self.keeper.update_route53_records,
                       autoscaling_members)
 def test_run(self, cli, res):
     cli.return_value.list_hosted_zones_by_name.return_value = {'HostedZones': [{'Id': '', 'Name': 'test.'}]}
     res.return_value.instances.filter.return_value = instances()
     self.assertRaises(Exception, self.keeper.run)
     self.keeper.manager.etcd_pid = 1
     self.assertRaises(Exception, self.keeper.run)
     self.keeper.is_leader = Mock(side_effect=Exception)
     self.assertRaises(Exception, self.keeper.run)
     with patch('time.sleep', Mock()):
         self.keeper.is_leader = Mock(return_value=False)
         self.keeper.manager.runv2 = True
         self.keeper.cluster_unhealthy = Mock(side_effect=[False, True, False])
         self.assertRaises(Exception, self.keeper.run)
         self.keeper.cluster_unhealthy = Mock(side_effect=[False] + [True]*100)
         self.assertRaises(Exception, self.keeper.run)
 def test_run(self, cli, res):
     cli.return_value.list_hosted_zones_by_name.return_value = {
         'HostedZones': [{
             'Id': '',
             'Name': 'test.'
         }]
     }
     res.return_value.instances.filter.return_value = instances()
     self.assertRaises(Exception, self.keeper.run)
     self.keeper.manager.etcd_pid = 1
     self.assertRaises(Exception, self.keeper.run)
     self.keeper.is_leader = Mock(side_effect=Exception)
     self.assertRaises(Exception, self.keeper.run)
     with patch('time.sleep', Mock()):
         self.keeper.is_leader = Mock(return_value=False)
         self.keeper.manager.run_old = True
         self.keeper.cluster_unhealthy = Mock(
             side_effect=[False, True, False])
         self.assertRaises(Exception, self.keeper.run)
         self.keeper.cluster_unhealthy = Mock(side_effect=[False] +
                                              [True] * 100)
         self.assertRaises(Exception, self.keeper.run)
 def test_remove_unhealthy_members(self, res):
     res.return_value.instances.filter.return_value = instances()
     autoscaling_members = self.manager.get_autoscaling_members()
     self.assertIsNone(
         self.keeper.remove_unhealthy_members(autoscaling_members))
Ejemplo n.º 14
0
 def test_load_members(self, res):
     res.return_value.instances.filter.return_value = instances()
     self.assertEqual(len(self.cluster.members), 4)
     with patch('requests.get', Mock(side_effect=Exception)):
         self.cluster.load_members()
 def test_remove_unhealthy_members(self, res):
     res.return_value.instances.filter.return_value = instances()
     autoscaling_members = self.manager.get_autoscaling_members()
     self.assertIsNone(self.keeper.remove_unhealthy_members(autoscaling_members))
Ejemplo n.º 16
0
 def test_load_members(self, res):
     res.return_value.instances.filter.return_value = instances()
     self.assertEqual(len(self.cluster.members), 4)
     with patch('requests.get', Mock(side_effect=Exception)):
         self.cluster.load_members()