示例#1
0
 def test_passes_default_probability_to_get_asg_instance_id(self):
     autoscaling = mock.Mock()
     asg = {"AutoScalingGroupName": "a", "Instances": ["i-11111111"]}
     default = mock.sentinel.default_probablity
     self.get_asg_instance_id.return_value = None
     self.get_all_asgs.return_value = iter([asg])
     chaos.get_targets(autoscaling, default)
     self.get_asg_instance_id.assert_called_once_with(asg, default)
示例#2
0
 def test_passes_default_probability_to_get_asg_instance_id(self):
     autoscaling = mock.Mock()
     asg = {"AutoScalingGroupName": "a", "Instances": ["i-11111111"]}
     default = mock.sentinel.default_probablity
     self.get_asg_instance_id.return_value = None
     self.get_all_asgs.return_value = iter([asg])
     chaos.get_targets(autoscaling, default)
     self.get_asg_instance_id.assert_called_once_with(asg, default)
示例#3
0
 def test_ignores_asgs_with_no_instances(self):
     autoscaling = mock.Mock()
     self.get_asg_instance_id.side_effect = lambda asg, default: \
         asg["Instances"][0] if len(asg["Instances"]) != 0 else None
     self.get_all_asgs.return_value = iter([
         {"AutoScalingGroupName": "a", "Instances": []},
         {"AutoScalingGroupName": "b", "Instances": ["i-22222222"]},
         {"AutoScalingGroupName": "c", "Instances": []}
     ])
     targets = chaos.get_targets(autoscaling, 0)
     self.assertEqual(targets, [("b", "i-22222222")])
示例#4
0
 def test_ignores_asgs_with_no_instances(self):
     self.get_asg_instance_id.side_effect = lambda asg: \
         asg["Instances"][0] if len(asg["Instances"]) != 0 else None
     self.describe.return_value = {
         "AutoScalingGroups": [
             {"AutoScalingGroupName": "a", "Instances": []},
             {"AutoScalingGroupName": "b", "Instances": ["i-22222222"]},
             {"AutoScalingGroupName": "c", "Instances": []}
         ]
     }
     targets = chaos.get_targets(self.autoscaling)
     self.assertEqual(targets, [("b", "i-22222222")])
示例#5
0
 def test_gets_instance_from_each_asg(self):
     autoscaling = mock.Mock()
     self.get_asg_instance_id.side_effect = lambda asg: asg["Instances"][0]
     self.get_all_asgs.return_value = iter([
         {"AutoScalingGroupName": "a", "Instances": ["i-11111111"]},
         {"AutoScalingGroupName": "b", "Instances": ["i-22222222"]},
         {"AutoScalingGroupName": "c", "Instances": ["i-33333333"]}
     ])
     targets = chaos.get_targets(autoscaling)
     self.assertEqual(set(targets), set([
         ("a", "i-11111111"),
         ("b", "i-22222222"),
         ("c", "i-33333333")
     ]))
示例#6
0
 def test_gets_instance_from_each_asg(self):
     self.get_asg_instance_id.side_effect = lambda asg: asg["Instances"][0]
     self.describe.return_value = {
         "AutoScalingGroups": [
             {"AutoScalingGroupName": "a", "Instances": ["i-11111111"]},
             {"AutoScalingGroupName": "b", "Instances": ["i-22222222"]},
             {"AutoScalingGroupName": "c", "Instances": ["i-33333333"]}
         ]
     }
     targets = chaos.get_targets(self.autoscaling)
     self.assertEqual(set(targets), set([
         ("a", "i-11111111"),
         ("b", "i-22222222"),
         ("c", "i-33333333")
     ]))
示例#7
0
 def test_ignores_asgs_with_no_instances(self):
     autoscaling = mock.Mock()
     self.get_asg_instance_id.side_effect = lambda asg, default: \
         asg["Instances"][0] if len(asg["Instances"]) != 0 else None
     self.get_all_asgs.return_value = iter([{
         "AutoScalingGroupName": "a",
         "Instances": []
     }, {
         "AutoScalingGroupName": "b",
         "Instances": ["i-22222222"]
     }, {
         "AutoScalingGroupName": "c",
         "Instances": []
     }])
     targets = chaos.get_targets(autoscaling, 0)
     self.assertEqual(targets, [("b", "i-22222222")])
示例#8
0
 def test_gets_instance_from_each_asg(self):
     autoscaling = mock.Mock()
     self.get_asg_instance_id.side_effect = lambda asg: asg["Instances"][0]
     self.get_all_asgs.return_value = iter([{
         "AutoScalingGroupName": "a",
         "Instances": ["i-11111111"]
     }, {
         "AutoScalingGroupName": "b",
         "Instances": ["i-22222222"]
     }, {
         "AutoScalingGroupName": "c",
         "Instances": ["i-33333333"]
     }])
     targets = chaos.get_targets(autoscaling)
     self.assertEqual(
         set(targets),
         set([("a", "i-11111111"), ("b", "i-22222222"),
              ("c", "i-33333333")]))
示例#9
0
 def test_returns_empty_list_if_no_auto_scaling_groups(self):
     autoscaling = mock.Mock()
     self.get_all_asgs.return_value = iter([])
     self.assertEqual(chaos.get_targets(autoscaling, 0), [])
示例#10
0
 def test_requests_all_auto_scaling_groups(self):
     autoscaling = mock.Mock()
     self.get_all_asgs.return_value = iter([])
     chaos.get_targets(autoscaling, 0)
     self.get_all_asgs.assert_called_once_with(autoscaling)
示例#11
0
 def test_returns_empty_list_if_no_auto_scaling_groups(self):
     autoscaling = mock.Mock()
     self.get_all_asgs.return_value = iter([])
     self.assertEqual(chaos.get_targets(autoscaling, 0), [])
示例#12
0
 def test_requests_all_auto_scaling_groups(self):
     autoscaling = mock.Mock()
     self.get_all_asgs.return_value = iter([])
     chaos.get_targets(autoscaling, 0)
     self.get_all_asgs.assert_called_once_with(autoscaling)
示例#13
0
 def test_returns_empty_list_if_no_auto_scaling_groups(self):
     self.describe.return_value = {"AutoScalingGroups": []}
     self.assertEqual(chaos.get_targets(self.autoscaling), [])
     self.describe.return_value = {}
     self.assertEqual(chaos.get_targets(self.autoscaling), [])