本文整理汇总了Python中disco_aws_automation.DiscoAWS.log_metrics方法的典型用法代码示例。如果您正苦于以下问题:Python DiscoAWS.log_metrics方法的具体用法?Python DiscoAWS.log_metrics怎么用?Python DiscoAWS.log_metrics使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类disco_aws_automation.DiscoAWS
的用法示例。
在下文中一共展示了DiscoAWS.log_metrics方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_provision_hc_with_chaos_using_config
# 需要导入模块: from disco_aws_automation import DiscoAWS [as 别名]
# 或者: from disco_aws_automation.DiscoAWS import log_metrics [as 别名]
def test_provision_hc_with_chaos_using_config(self, mock_config, **kwargs):
"""
Provision creates the proper launch configuration and autoscaling group with chaos from config
"""
config_dict = get_default_config_dict()
config_dict["mhcunittest"]["chaos"] = "True"
aws = DiscoAWS(config=get_mock_config(config_dict), environment_name=TEST_ENV_NAME)
mock_ami = self._get_image_mock(aws)
aws.log_metrics = MagicMock()
aws.update_elb = MagicMock(return_value=None)
with patch("disco_aws_automation.DiscoAWS.get_meta_network", return_value=_get_meta_network_mock()):
with patch("boto.ec2.connection.EC2Connection.get_all_snapshots", return_value=[]):
with patch("disco_aws_automation.DiscoAWS.create_scaling_schedule", return_value=None):
with patch("boto.ec2.autoscale.AutoScaleConnection.create_or_update_tags",
return_value=None):
metadata = aws.provision(ami=mock_ami, hostclass="mhcunittest",
owner="unittestuser",
min_size=1, desired_size=1, max_size=1)
self.assertEqual(metadata["hostclass"], "mhcunittest")
self.assertFalse(metadata["no_destroy"])
self.assertTrue(metadata["chaos"])
_lc = aws.autoscale.get_configs()[0]
self.assertRegexpMatches(_lc.name, r".*_mhcunittest_[0-9]*")
self.assertEqual(_lc.image_id, mock_ami.id)
self.assertTrue(aws.autoscale.has_group("mhcunittest"))
_ag = aws.autoscale.get_groups()[0]
self.assertEqual(_ag.name, "unittestenv_mhcunittest")
self.assertEqual(_ag.min_size, 1)
self.assertEqual(_ag.max_size, 1)
self.assertEqual(_ag.desired_capacity, 1)
示例2: test_provision_hostclass_sched_all_none
# 需要导入模块: from disco_aws_automation import DiscoAWS [as 别名]
# 或者: from disco_aws_automation.DiscoAWS import log_metrics [as 别名]
def test_provision_hostclass_sched_all_none(self, mock_config, **kwargs):
"""
Provision creates the proper autoscaling group sizes with scheduled sizes
"""
aws = DiscoAWS(config=mock_config, environment_name=TEST_ENV_NAME)
aws.log_metrics = MagicMock()
aws.update_elb = MagicMock(return_value=None)
with patch("disco_aws_automation.DiscoAWS.get_meta_network", return_value=_get_meta_network_mock()):
with patch("boto.ec2.connection.EC2Connection.get_all_snapshots", return_value=[]):
with patch("disco_aws_automation.DiscoAWS.create_scaling_schedule", return_value=None):
with patch("boto.ec2.autoscale.AutoScaleConnection.create_or_update_tags",
return_value=None):
aws.provision(ami=self._get_image_mock(aws),
hostclass="mhcunittest", owner="unittestuser",
min_size="", desired_size="", max_size="")
_ag0 = aws.autoscale.get_groups()[0]
self.assertEqual(_ag0.min_size, 0) # minimum of listed sizes
self.assertEqual(_ag0.desired_capacity, 0) # maximum of listed sizes
self.assertEqual(_ag0.max_size, 0) # maximum of listed sizes
with patch("disco_aws_automation.DiscoAWS.get_meta_network", return_value=_get_meta_network_mock()):
with patch("boto.ec2.connection.EC2Connection.get_all_snapshots", return_value=[]):
with patch("disco_aws_automation.DiscoAWS.create_scaling_schedule", return_value=None):
with patch("boto.ec2.autoscale.AutoScaleConnection.create_or_update_tags",
return_value=None):
aws.provision(ami=self._get_image_mock(aws),
hostclass="mhcunittest", owner="unittestuser",
min_size="3", desired_size="6", max_size="9")
_ag1 = aws.autoscale.get_groups()[0]
self.assertEqual(_ag1.min_size, 3) # minimum of listed sizes
self.assertEqual(_ag1.desired_capacity, 6) # maximum of listed sizes
self.assertEqual(_ag1.max_size, 9) # maximum of listed sizes
with patch("disco_aws_automation.DiscoAWS.get_meta_network", return_value=_get_meta_network_mock()):
with patch("boto.ec2.connection.EC2Connection.get_all_snapshots", return_value=[]):
with patch("disco_aws_automation.DiscoAWS.create_scaling_schedule", return_value=None):
with patch("boto.ec2.autoscale.AutoScaleConnection.create_or_update_tags",
return_value=None):
aws.provision(ami=self._get_image_mock(aws),
hostclass="mhcunittest", owner="unittestuser",
min_size="", desired_size="", max_size="")
_ag2 = aws.autoscale.get_groups()[0]
self.assertEqual(_ag2.min_size, 3) # minimum of listed sizes
self.assertEqual(_ag2.desired_capacity, 6) # maximum of listed sizes
self.assertEqual(_ag2.max_size, 9) # maximum of listed sizes