本文整理汇总了Python中cli_test.CLITest类的典型用法代码示例。如果您正苦于以下问题:Python CLITest类的具体用法?Python CLITest怎么用?Python CLITest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CLITest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_create_curl
def test_create_curl(self):
runner = CLIRunner(self.cli)
metric = 'FOO'
curl = runner.get_output(['-n', metric,
'-z'])
CLITest.check_curl(self, self.cli, curl)
示例2: test_create_metric
def test_create_metric(self):
runner_create = CLIRunner(MetricCreate())
metric_name = 'METRIC' + CLITest.random_string(6)
display_name = 'Display Name ' + CLITest.random_string(20)
display_name_short = 'Short Display Name' + CLITest.random_string(5)
description = CLITest.random_string(30)
aggregate = 'avg'
unit = 'number'
resolution = 60000
disabled = False
create = runner_create.get_output(['-n', metric_name,
'-d', display_name,
'-s', display_name_short,
'-i', description,
'-g', aggregate,
'-r', str(resolution),
'-u', unit,
'-x', str(disabled).lower()])
metric_create = json.loads(create)
metric = metric_create['result']
self.assertEqual(metric_name, metric['name'])
self.assertEqual(display_name, metric['displayName'])
self.assertEqual(display_name_short, metric['displayNameShort'])
self.assertFalse(metric['isDisabled'])
self.assertEqual(unit, metric['unit'])
self.assertEqual(aggregate.upper(), metric['defaultAggregate'])
self.assertEqual(resolution, int(metric['defaultResolutionMS']))
self.assertEqual(description, metric['description'])
runner_delete = CLIRunner(MetricDelete())
delete = runner_delete.get_output(['-n', metric_name])
示例3: test_create_curl
def test_create_curl(self):
runner = CLIRunner(self.cli)
alarm_id = 1024
curl = runner.get_output(['-i', str(alarm_id),
'-z'])
CLITest.check_curl(self, self.cli, curl)
示例4: test_create_curl
def test_create_curl(self):
runner = CLIRunner(self.cli)
filter_name = 'My-Filter'
curl = runner.get_output(['-n', filter_name,
'-z'])
CLITest.check_curl(self, self.cli, curl)
示例5: test_create_curl
def test_create_curl(self):
runner = CLIRunner(self.cli)
enabled = True
custom = True
curl = runner.get_output(['-b', str(enabled).lower(),
'-c', str(custom).lower(),
'-z'])
CLITest.check_curl(self, self.cli, curl)
示例6: test_update_alarm
def test_update_alarm(self):
alarm_name = 'my-alarm-' + CLITest.random_string(6)
metric_name = 'CPU'
note = CLITest.random_string(50)
aggregate = 'max'
op = 'gt'
value = 0.75
trigger_interval = 900000
is_disabled = True
runner_create = CLIRunner(AlarmCreate())
create = runner_create.get_output(['-n', alarm_name,
'-m', metric_name,
'-d', note,
'-g', aggregate,
'-o', op,
'-v', str(value),
'-r', str(trigger_interval),
'-x', str(is_disabled).lower()])
alarm_create = json.loads(create)
note = CLITest.random_string(50)
aggregate = 'max'
op = 'gt'
value = 0.75
trigger_interval = 300000
is_disabled = False
runner_update = CLIRunner(AlarmUpdate())
update = runner_update.get_output(['-i', str(int(alarm_create['id'])),
'-n', alarm_name,
'-m', metric_name,
'-d', note,
'-g', aggregate,
'-o', op,
'-v', str(value),
'-r', str(trigger_interval),
'-x', str(is_disabled).lower()])
alarm = json.loads(update)
self.assertEqual(trigger_interval, alarm['triggerInterval'])
self.assertEqual(1, alarm['familyId'])
self.assertFalse(is_disabled, alarm['isDisabled'])
self.assertEqual(metric_name, alarm['metric'])
self.assertEqual(alarm_name, alarm['name'])
self.assertEqual(aggregate, alarm['triggerPredicate']['agg'])
self.assertEqual(op, alarm['triggerPredicate']['op'])
self.assertEqual(value, alarm['triggerPredicate']['val'])
self.assertEqual(3, int(alarm['typeId']))
self.assertEqual(note, alarm['note'])
runner_delete = CLIRunner(AlarmDelete())
delete = runner_delete.get_output(['-i', str(alarm['id'])])
示例7: test_create_curl
def test_create_curl(self):
runner = CLIRunner(self.cli)
metric = 'CPU'
measurement = 0.5
timestamp = 1452643455
curl = runner.get_output(['-n', metric,
'-m', str(measurement),
'-s', 'source1',
'-d', str(timestamp),
'-z'])
CLITest.check_curl(self, self.cli, curl)
示例8: test_api_call
def test_api_call(self):
api = API()
name = 'ALARM_DELETE_API_TEST' + CLITest.random_string(6)
metric = 'CPU'
trigger_interval = 60000
aggregate = 'sum'
operation = 'gt'
threshold = '0.80'
note = CLITest.random_string(20)
alarm = api.alarm_create(name=name,
metric=metric,
trigger_interval=trigger_interval,
aggregate=aggregate,
operation=operation,
threshold=threshold,
note=note)
self.api.alarm_delete(id=alarm.id)
示例9: test_delete_alarm
def test_delete_alarm(self):
name = 'ALARM_DELETE_TEST' + CLITest.random_string(6)
metric = 'CPU'
trigger_interval = 60000
aggregate = 'sum'
operation = 'gt'
threshold = '0.80'
note = CLITest.random_string(20)
runner_create = CLIRunner(AlarmCreate())
create = runner_create.get_output(['-n', name,
'-m', metric,
'-g', aggregate,
'-o', operation,
'-v', str(threshold),
'-r', str(trigger_interval),
'-d', note])
alarm = json.loads(create)
runner_delete = CLIRunner(AlarmDelete())
delete = runner_delete.get_output(['-i', str(alarm['id'])])
示例10: test_create_curl
def test_create_curl(self):
runner = CLIRunner(self.cli)
alarm_id = 1024
alarm_name = 'my-curl'
metric_name = 'CPU'
aggregate = 'min'
operation = 'lt'
value = 0.5
trigger_interval = 300000
enabled = False
curl = runner.get_output(['-i', str(alarm_id),
'-n', alarm_name,
'-m', metric_name,
'-g', aggregate,
'-o', operation,
'-v', str(value),
'-r', str(trigger_interval),
'-x', str(enabled).lower(),
'-z'])
CLITest.check_curl(self, self.cli, curl)
示例11: test_api_call
def test_api_call(self):
aggregate = 'sum'
trigger_interval = 60
is_disabled = True
metric_name = 'CPU'
note = 'This is a note'
alarm_name = 'ALARM_CREATE_TEST' + CLITest.random_string(4)
operation = 'gt'
per_host_modify = True
threshold = '0.80'
alarm_create = self.api.alarm_create(aggregate=aggregate,
trigger_interval=trigger_interval,
is_disabled=is_disabled,
metric_name=metric_name,
name=alarm_name,
note=note,
operation=operation,
per_host_modify=per_host_modify,
threshold=threshold)
aggregate = 'avg'
trigger_interval = 3600000
is_disabled = False
metric_name = 'CPU'
note = 'This is a updated note'
operation = 'lt'
per_host_modify = True
threshold = '0.50'
alarm_update = self.api.alarm_update(id=alarm_create.id,
aggregate=aggregate,
trigger_interval=trigger_interval,
is_disabled=is_disabled,
metric_name=metric_name,
name=alarm_name,
note=note,
operation=operation,
per_host_modify=per_host_modify,
threshold=threshold)
self.assertEqual(aggregate, alarm_update.aggregate)
self.assertEqual(trigger_interval, alarm_update.trigger_interval)
self.assertEqual(is_disabled, alarm_update.is_disabled)
self.assertEqual(metric_name, alarm_update.metric_name)
self.assertEqual(alarm_name, alarm_update.name)
self.assertEqual(note, alarm_update.note)
self.assertEqual(operation, alarm_update.operation)
self.assertEqual(per_host_modify, alarm_update.per_host_modify)
self.assertEqual(threshold, alarm_update.threshold)
self.api.alarm_delete(id=alarm_create.id)
示例12: test_search_alarm
def test_search_alarm(self):
alarm_name = 'alarm_test' + CLITest.random_string(6)
metric_name = 'CPU'
aggregate = 'max'
op = 'gt'
value = 0.50
trigger_interval = 300000
note = CLITest.random_string(20)
enabled = True
runner_create = CLIRunner(AlarmCreate())
create = runner_create.get_output(['-n', alarm_name,
'-m', metric_name,
'-g', aggregate,
'-o', op,
'-v', str(value),
'-r', str(trigger_interval),
'-d', note,
'-x', str(enabled).lower()])
runner_search = CLIRunner(AlarmSearch())
search = runner_search.get_output(['-n', alarm_name])
result_search = json.loads(search)
alarm = result_search['result'][0]
self.assertEqual(trigger_interval, alarm['interval'])
self.assertItemsEqual([], alarm['actions'])
self.assertEqual(1, int(alarm['familyId']))
self.assertFalse(False, alarm['isDisabled'])
self.assertEqual(metric_name, alarm['metric'])
self.assertEqual(alarm_name, alarm['name'])
self.assertTrue(alarm['perHostNotify'])
self.assertEqual(aggregate, alarm['triggerPredicate']['agg'])
self.assertEqual(op, alarm['triggerPredicate']['op'])
self.assertEqual(value, alarm['triggerPredicate']['val'])
self.assertEqual(3, int(alarm['typeId']))
runner_delete = CLIRunner(AlarmDelete())
delete = runner_delete.get_output(['-i', str(alarm['id'])])
示例13: test_create_curl
def test_create_curl(self):
runner = CLIRunner(self.cli)
runner_create = CLIRunner(MetricCreate())
metric_name = 'METRIC'
display_name = 'Display Name'
display_name_short = 'Short Display Name'
description = 'My Description'
aggregate = 'avg'
unit = 'number'
resolution = 60000
disabled = False
curl = runner_create.get_output(['-n', metric_name,
'-d', display_name,
'-s', display_name_short,
'-i', description,
'-g', aggregate,
'-r', str(resolution),
'-u', unit,
'-x', str(disabled).lower(),
'-z'])
CLITest.check_curl(self, self.cli, curl)
示例14: test_delete_metric
def test_delete_metric(self):
runner_create = CLIRunner(MetricCreate())
metric_name = 'METRIC' + CLITest.random_string(6)
display_name = 'Display Name ' + CLITest.random_string(20)
display_name_short = 'Short Display Name' + CLITest.random_string(5)
description = CLITest.random_string(30)
aggregate = 'avg'
unit = 'number'
resolution = 60000
disabled = False
create = runner_create.get_output(['-n', metric_name,
'-d', display_name,
'-s', display_name_short,
'-i', description,
'-g', aggregate,
'-r', str(resolution),
'-u', unit,
'-x', str(disabled).lower()])
metric_create = json.loads(create)
metric = metric_create['result']
runner_delete = CLIRunner(MetricDelete())
delete = runner_delete.get_output(['-n', metric_name])
示例15: test_create_filter
def test_create_filter(self):
runner_create = CLIRunner(HostgroupCreate())
filter_name = 'Filter' + CLITest.random_string(6)
sources = 'foo,bar,red,green'
create = runner_create.get_output(['-n', filter_name,
'-s', sources])
filter_create = json.loads(create)
filter = filter_create['result']
self.assertEqual(filter_name, filter['name'])
self.assertItemsEqual(split(sources, ','), filter['hostnames'])
filter_id = filter['id']
runner_delete = CLIRunner(HostgroupDelete())
delete = runner_delete.get_output(['-i', str(filter_id)])
delete_result = json.loads(delete)
self.assertTrue(delete_result['result']['success'])