Merge "Fix: CLI metric-create using project-id fails"
This commit is contained in:
commit
3fa5659855
@ -211,6 +211,34 @@ class ShellTestMonascaCommands(ShellBase):
|
||||
self.assertHeaders()
|
||||
self.assertEqual(data, self.requests_mock.last_request.json())
|
||||
|
||||
def test_good_metrics_create_subcommand_with_tenant_id(self):
|
||||
self._script_keystone_client()
|
||||
self.m.ReplayAll()
|
||||
|
||||
headers = {'location': 'http://no.where/v2.0/metrics'}
|
||||
self.requests_mock.post('http://192.168.1.5:8004/v1/f14b41234/metrics',
|
||||
status_code=204,
|
||||
headers=headers)
|
||||
|
||||
proj = 'd48e63e76a5c4e05ba26a1185f31d4aa'
|
||||
argstrings = [
|
||||
'metric-create metric1 123 --time 1395691090 --project-id ' + proj,
|
||||
]
|
||||
for argstr in argstrings:
|
||||
retvalue = self.shell(argstr)
|
||||
self.assertRegexpMatches(retvalue, "^Success")
|
||||
|
||||
data = {'timestamp': 1395691090,
|
||||
'name': 'metric1',
|
||||
'value': 123.0}
|
||||
|
||||
self.assertHeaders()
|
||||
self.assertEqual(data, self.requests_mock.last_request.json())
|
||||
|
||||
request_url = self.requests_mock.last_request.url
|
||||
query_arg = request_url[request_url.index('?') + 1:]
|
||||
self.assertEqual('tenant_id=' + proj, query_arg)
|
||||
|
||||
def test_bad_notifications_create_missing_args_subcommand(self):
|
||||
argstrings = [
|
||||
'notification-create email1 metric1@hp.com',
|
||||
|
@ -65,8 +65,7 @@ notification_types = ['EMAIL', 'WEBHOOK', 'PAGERDUTY']
|
||||
help='Metric timestamp in milliseconds. Default: current timestamp.')
|
||||
@utils.arg('--project-id', metavar='<CROSS_PROJECT_ID>',
|
||||
help='The Project ID to create metric on behalf of. '
|
||||
'Requires monitoring-delegate role in keystone.',
|
||||
action='append')
|
||||
'Requires monitoring-delegate role in keystone.')
|
||||
@utils.arg('value', metavar='<METRIC_VALUE>',
|
||||
type=float,
|
||||
help='Metric value.')
|
||||
|
Loading…
Reference in New Issue
Block a user