remove gnocchi specific tests
This commit is contained in:
@@ -1,70 +0,0 @@
|
|||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
from gnocchiclient.tests.functional import base
|
|
||||||
|
|
||||||
|
|
||||||
class ArchivePolicyClientTest(base.ClientTestBase):
|
|
||||||
def test_archive_policy_scenario(self):
|
|
||||||
# CREATE
|
|
||||||
result = self.gnocchi(
|
|
||||||
u'archive-policy', params=u"create low"
|
|
||||||
u" --back-window 0"
|
|
||||||
u" -d granularity:1s,points:86400")
|
|
||||||
policy = self.details_multiple(result)[0]
|
|
||||||
self.assertEqual('low', policy["name"])
|
|
||||||
|
|
||||||
# CREATE FAIL
|
|
||||||
result = self.gnocchi(
|
|
||||||
u'archive-policy', params=u"create low"
|
|
||||||
u" --back-window 0"
|
|
||||||
u" -d granularity:1s,points:86400",
|
|
||||||
fail_ok=True, merge_stderr=True)
|
|
||||||
self.assertFirstLineStartsWith(
|
|
||||||
result.split('\n'),
|
|
||||||
"Archive policy low already exists (HTTP 409)")
|
|
||||||
|
|
||||||
# GET
|
|
||||||
result = self.gnocchi(
|
|
||||||
'archive-policy', params="show low")
|
|
||||||
policy = self.details_multiple(result)[0]
|
|
||||||
self.assertEqual("low", policy["name"])
|
|
||||||
|
|
||||||
# LIST
|
|
||||||
result = self.gnocchi(
|
|
||||||
'archive-policy', params="list")
|
|
||||||
policies = self.parser.listing(result)
|
|
||||||
policy_from_list = [p for p in policies
|
|
||||||
if p['name'] == 'low'][0]
|
|
||||||
for field in ["back_window", "definition", "aggregation_methods"]:
|
|
||||||
self.assertEqual(policy[field], policy_from_list[field])
|
|
||||||
|
|
||||||
# DELETE
|
|
||||||
result = self.gnocchi('archive-policy',
|
|
||||||
params="delete low")
|
|
||||||
self.assertEqual("", result)
|
|
||||||
|
|
||||||
# GET FAIL
|
|
||||||
result = self.gnocchi('archive-policy',
|
|
||||||
params="show low",
|
|
||||||
fail_ok=True, merge_stderr=True)
|
|
||||||
self.assertFirstLineStartsWith(
|
|
||||||
result.split('\n'),
|
|
||||||
"Archive policy low does not exist (HTTP 404)")
|
|
||||||
|
|
||||||
# DELETE FAIL
|
|
||||||
result = self.gnocchi('archive-policy',
|
|
||||||
params="delete low",
|
|
||||||
fail_ok=True, merge_stderr=True)
|
|
||||||
self.assertFirstLineStartsWith(
|
|
||||||
result.split('\n'),
|
|
||||||
"Archive policy low does not exist (HTTP 404)")
|
|
@@ -1,75 +0,0 @@
|
|||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
import uuid
|
|
||||||
|
|
||||||
from gnocchiclient.tests.functional import base
|
|
||||||
|
|
||||||
|
|
||||||
class ArchivePolicyRuleClientTest(base.ClientTestBase):
|
|
||||||
def test_archive_policy_rule_scenario(self):
|
|
||||||
apname = str(uuid.uuid4())
|
|
||||||
# Create an archive policy
|
|
||||||
self.gnocchi(
|
|
||||||
u'archive-policy', params=u"create %s"
|
|
||||||
u" -d granularity:1s,points:86400" % apname)
|
|
||||||
|
|
||||||
# CREATE
|
|
||||||
result = self.gnocchi(
|
|
||||||
u'archive-policy-rule', params=u"create test"
|
|
||||||
u" --archive-policy %s"
|
|
||||||
u" --metric-pattern 'disk.io.*'" % apname)
|
|
||||||
policy_rule = self.details_multiple(result)[0]
|
|
||||||
self.assertEqual('test', policy_rule["name"])
|
|
||||||
|
|
||||||
# CREATE FAIL
|
|
||||||
result = self.gnocchi(
|
|
||||||
u'archive-policy-rule', params=u"create test"
|
|
||||||
u" --archive-policy high"
|
|
||||||
u" --metric-pattern 'disk.io.*'",
|
|
||||||
fail_ok=True, merge_stderr=True)
|
|
||||||
self.assertFirstLineStartsWith(
|
|
||||||
result.split('\n'),
|
|
||||||
"Archive policy rule test already exists (HTTP 409)")
|
|
||||||
# GET
|
|
||||||
result = self.gnocchi(
|
|
||||||
'archive-policy-rule', params="show test")
|
|
||||||
policy_rule = self.details_multiple(result)[0]
|
|
||||||
self.assertEqual("test", policy_rule["name"])
|
|
||||||
|
|
||||||
# LIST
|
|
||||||
result = self.gnocchi('archive-policy-rule', params="list")
|
|
||||||
rules = self.parser.listing(result)
|
|
||||||
rule_from_list = [p for p in rules
|
|
||||||
if p['name'] == 'test'][0]
|
|
||||||
for field in ["metric_pattern", "archive_policy_name"]:
|
|
||||||
self.assertEqual(policy_rule[field], rule_from_list[field])
|
|
||||||
|
|
||||||
# DELETE
|
|
||||||
result = self.gnocchi('archive-policy-rule',
|
|
||||||
params="delete test")
|
|
||||||
self.assertEqual("", result)
|
|
||||||
|
|
||||||
# GET FAIL
|
|
||||||
result = self.gnocchi('archive-policy-rule',
|
|
||||||
params="show test",
|
|
||||||
fail_ok=True, merge_stderr=True)
|
|
||||||
self.assertFirstLineStartsWith(
|
|
||||||
result.split('\n'),
|
|
||||||
"Archive policy rule test does not exist (HTTP 404)")
|
|
||||||
|
|
||||||
# DELETE FAIL
|
|
||||||
result = self.gnocchi('archive-policy-rule',
|
|
||||||
params="delete test",
|
|
||||||
fail_ok=True, merge_stderr=True)
|
|
||||||
self.assertFirstLineStartsWith(
|
|
||||||
result.split('\n'),
|
|
||||||
"Archive policy rule test does not exist (HTTP 404)")
|
|
@@ -1,101 +0,0 @@
|
|||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
import uuid
|
|
||||||
|
|
||||||
from gnocchiclient.tests.functional import base
|
|
||||||
|
|
||||||
|
|
||||||
class BenchmarkMetricTest(base.ClientTestBase):
|
|
||||||
def test_benchmark_metric_create_wrong_workers(self):
|
|
||||||
result = self.gnocchi(
|
|
||||||
u'benchmark', params=u"metric create -n 0",
|
|
||||||
fail_ok=True, merge_stderr=True)
|
|
||||||
self.assertIn("0 must be greater than 0", result)
|
|
||||||
|
|
||||||
def test_benchmark_metric_create(self):
|
|
||||||
apname = str(uuid.uuid4())
|
|
||||||
# PREPARE AN ACHIVE POLICY
|
|
||||||
self.gnocchi("archive-policy", params="create %s "
|
|
||||||
"--back-window 0 -d granularity:1s,points:86400" % apname)
|
|
||||||
|
|
||||||
result = self.gnocchi(
|
|
||||||
u'benchmark', params=u"metric create -n 10 -a %s" % apname)
|
|
||||||
result = self.details_multiple(result)[0]
|
|
||||||
self.assertEqual(10, int(result['create executed']))
|
|
||||||
self.assertLessEqual(int(result['create failures']), 10)
|
|
||||||
self.assertLessEqual(int(result['delete executed']),
|
|
||||||
int(result['create executed']))
|
|
||||||
|
|
||||||
result = self.gnocchi(
|
|
||||||
u'benchmark', params=u"metric create -k -n 10 -a %s" % apname)
|
|
||||||
result = self.details_multiple(result)[0]
|
|
||||||
self.assertEqual(10, int(result['create executed']))
|
|
||||||
self.assertLessEqual(int(result['create failures']), 10)
|
|
||||||
self.assertNotIn('delete executed', result)
|
|
||||||
|
|
||||||
def test_benchmark_metric_get(self):
|
|
||||||
apname = str(uuid.uuid4())
|
|
||||||
# PREPARE AN ACHIVE POLICY
|
|
||||||
self.gnocchi("archive-policy", params="create %s "
|
|
||||||
"--back-window 0 -d granularity:1s,points:86400" % apname)
|
|
||||||
|
|
||||||
result = self.gnocchi(
|
|
||||||
u'metric', params=u"create -a %s" % apname)
|
|
||||||
metric = self.details_multiple(result)[0]
|
|
||||||
|
|
||||||
result = self.gnocchi(
|
|
||||||
u'benchmark', params=u"metric show -n 10 %s" % metric['id'])
|
|
||||||
result = self.details_multiple(result)[0]
|
|
||||||
self.assertEqual(10, int(result['show executed']))
|
|
||||||
self.assertLessEqual(int(result['show failures']), 10)
|
|
||||||
|
|
||||||
def test_benchmark_measures_add(self):
|
|
||||||
apname = str(uuid.uuid4())
|
|
||||||
# PREPARE AN ACHIVE POLICY
|
|
||||||
self.gnocchi("archive-policy", params="create %s "
|
|
||||||
"--back-window 0 -d granularity:1s,points:86400" % apname)
|
|
||||||
|
|
||||||
result = self.gnocchi(
|
|
||||||
u'metric', params=u"create -a %s" % apname)
|
|
||||||
metric = self.details_multiple(result)[0]
|
|
||||||
|
|
||||||
result = self.gnocchi(
|
|
||||||
u'benchmark', params=u"measures add -n 10 -b 4 %s" % metric['id'])
|
|
||||||
result = self.details_multiple(result)[0]
|
|
||||||
self.assertEqual(2, int(result['push executed']))
|
|
||||||
self.assertLessEqual(int(result['push failures']), 2)
|
|
||||||
|
|
||||||
result = self.gnocchi(
|
|
||||||
u'benchmark',
|
|
||||||
params=u"measures add -s 2010-01-01 -n 10 -b 4 %s"
|
|
||||||
% metric['id'])
|
|
||||||
result = self.details_multiple(result)[0]
|
|
||||||
self.assertEqual(2, int(result['push executed']))
|
|
||||||
self.assertLessEqual(int(result['push failures']), 2)
|
|
||||||
|
|
||||||
def test_benchmark_measures_show(self):
|
|
||||||
apname = str(uuid.uuid4())
|
|
||||||
# PREPARE AN ACHIVE POLICY
|
|
||||||
self.gnocchi("archive-policy", params="create %s "
|
|
||||||
"--back-window 0 -d granularity:1s,points:86400" % apname)
|
|
||||||
|
|
||||||
result = self.gnocchi(
|
|
||||||
u'metric', params=u"create -a %s" % apname)
|
|
||||||
metric = self.details_multiple(result)[0]
|
|
||||||
|
|
||||||
result = self.gnocchi(
|
|
||||||
u'benchmark',
|
|
||||||
params=u"measures show -n 2 %s"
|
|
||||||
% metric['id'])
|
|
||||||
result = self.details_multiple(result)[0]
|
|
||||||
self.assertEqual(2, int(result['show executed']))
|
|
||||||
self.assertLessEqual(int(result['show failures']), 2)
|
|
@@ -1,274 +0,0 @@
|
|||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
import uuid
|
|
||||||
|
|
||||||
from gnocchiclient.tests.functional import base
|
|
||||||
|
|
||||||
|
|
||||||
class MetricClientTest(base.ClientTestBase):
|
|
||||||
def test_delete_several_metrics(self):
|
|
||||||
apname = str(uuid.uuid4())
|
|
||||||
# PREPARE AN ACHIVE POLICY
|
|
||||||
self.gnocchi("archive-policy", params="create %s "
|
|
||||||
"--back-window 0 -d granularity:1s,points:86400" % apname)
|
|
||||||
# Create 2 metrics
|
|
||||||
result = self.gnocchi(
|
|
||||||
u'metric', params=u"create"
|
|
||||||
u" --archive-policy-name %s" % apname)
|
|
||||||
metric1 = self.details_multiple(result)[0]
|
|
||||||
|
|
||||||
result = self.gnocchi(
|
|
||||||
u'metric', params=u"create"
|
|
||||||
u" --archive-policy-name %s" % apname)
|
|
||||||
metric2 = self.details_multiple(result)[0]
|
|
||||||
|
|
||||||
# DELETE
|
|
||||||
result = self.gnocchi('metric', params="delete %s %s"
|
|
||||||
% (metric1["id"], metric2["id"]))
|
|
||||||
self.assertEqual("", result)
|
|
||||||
|
|
||||||
# GET FAIL
|
|
||||||
result = self.gnocchi('metric', params="show %s" % metric1["id"],
|
|
||||||
fail_ok=True, merge_stderr=True)
|
|
||||||
self.assertFirstLineStartsWith(result.split('\n'),
|
|
||||||
"Metric %s does not exist (HTTP 404)" %
|
|
||||||
metric1["id"])
|
|
||||||
result = self.gnocchi('metric', params="show %s" % metric2["id"],
|
|
||||||
fail_ok=True, merge_stderr=True)
|
|
||||||
self.assertFirstLineStartsWith(result.split('\n'),
|
|
||||||
"Metric %s does not exist (HTTP 404)" %
|
|
||||||
metric2["id"])
|
|
||||||
|
|
||||||
def test_metric_scenario(self):
|
|
||||||
# PREPARE AN ACHIVE POLICY
|
|
||||||
self.gnocchi("archive-policy", params="create metric-test "
|
|
||||||
"--back-window 0 -d granularity:1s,points:86400")
|
|
||||||
|
|
||||||
# CREATE WITH NAME
|
|
||||||
result = self.gnocchi(
|
|
||||||
u'metric', params=u"create"
|
|
||||||
u" --archive-policy-name metric-test some-name")
|
|
||||||
metric = self.details_multiple(result)[0]
|
|
||||||
self.assertIsNotNone(metric["id"])
|
|
||||||
self.assertEqual(self.clients.project_id,
|
|
||||||
metric["created_by_project_id"])
|
|
||||||
self.assertEqual(self.clients.user_id, metric["created_by_user_id"])
|
|
||||||
self.assertEqual('some-name', metric["name"])
|
|
||||||
self.assertEqual('None', metric["resource"])
|
|
||||||
self.assertIn("metric-test", metric["archive_policy/name"])
|
|
||||||
|
|
||||||
# CREATE WITHOUT NAME
|
|
||||||
result = self.gnocchi(
|
|
||||||
u'metric', params=u"create"
|
|
||||||
u" --archive-policy-name metric-test")
|
|
||||||
metric = self.details_multiple(result)[0]
|
|
||||||
self.assertIsNotNone(metric["id"])
|
|
||||||
self.assertEqual(self.clients.project_id,
|
|
||||||
metric["created_by_project_id"])
|
|
||||||
self.assertEqual(self.clients.user_id, metric["created_by_user_id"])
|
|
||||||
self.assertEqual('None', metric["name"])
|
|
||||||
self.assertEqual('None', metric["resource"])
|
|
||||||
self.assertIn("metric-test", metric["archive_policy/name"])
|
|
||||||
|
|
||||||
# GET
|
|
||||||
result = self.gnocchi('metric', params="show %s" % metric["id"])
|
|
||||||
metric_get = self.details_multiple(result)[0]
|
|
||||||
self.assertEqual(metric, metric_get)
|
|
||||||
|
|
||||||
# MEASURES ADD
|
|
||||||
result = self.gnocchi('measures',
|
|
||||||
params=("add %s "
|
|
||||||
"-m '2015-03-06T14:33:57@43.11' "
|
|
||||||
"--measure '2015-03-06T14:34:12@12' "
|
|
||||||
) % metric["id"])
|
|
||||||
self.assertEqual("", result)
|
|
||||||
|
|
||||||
# MEASURES GET
|
|
||||||
result = self.retry_gnocchi(
|
|
||||||
5, 'measures', params=("show %s "
|
|
||||||
"--aggregation mean "
|
|
||||||
"--start 2015-03-06T14:32:00 "
|
|
||||||
"--stop 2015-03-06T14:36:00"
|
|
||||||
) % metric["id"])
|
|
||||||
measures = self.parser.listing(result)
|
|
||||||
self.assertEqual([{'granularity': '1.0',
|
|
||||||
'timestamp': '2015-03-06T14:33:57+00:00',
|
|
||||||
'value': '43.11'},
|
|
||||||
{'granularity': '1.0',
|
|
||||||
'timestamp': '2015-03-06T14:34:12+00:00',
|
|
||||||
'value': '12.0'}], measures)
|
|
||||||
|
|
||||||
# MEASURES AGGREGATION
|
|
||||||
result = self.gnocchi(
|
|
||||||
'measures', params=("aggregation "
|
|
||||||
"--metric %s "
|
|
||||||
"--aggregation mean "
|
|
||||||
"--start 2015-03-06T14:32:00 "
|
|
||||||
"--stop 2015-03-06T14:36:00"
|
|
||||||
) % metric["id"])
|
|
||||||
measures = self.parser.listing(result)
|
|
||||||
self.assertEqual([{'granularity': '1.0',
|
|
||||||
'timestamp': '2015-03-06T14:33:57+00:00',
|
|
||||||
'value': '43.11'},
|
|
||||||
{'granularity': '1.0',
|
|
||||||
'timestamp': '2015-03-06T14:34:12+00:00',
|
|
||||||
'value': '12.0'}], measures)
|
|
||||||
|
|
||||||
# LIST
|
|
||||||
result = self.gnocchi('metric', params="list")
|
|
||||||
metrics = self.parser.listing(result)
|
|
||||||
metric_from_list = [p for p in metrics
|
|
||||||
if p['id'] == metric['id']][0]
|
|
||||||
for field in ["id", "archive_policy/name", "name"]:
|
|
||||||
# FIXME(sileht): add "resource_id" or "resource"
|
|
||||||
# when LP#1497171 is fixed
|
|
||||||
self.assertEqual(metric[field], metric_from_list[field], field)
|
|
||||||
|
|
||||||
# DELETE
|
|
||||||
result = self.gnocchi('metric', params="delete %s" % metric["id"])
|
|
||||||
self.assertEqual("", result)
|
|
||||||
|
|
||||||
# GET FAIL
|
|
||||||
result = self.gnocchi('metric', params="show %s" % metric["id"],
|
|
||||||
fail_ok=True, merge_stderr=True)
|
|
||||||
self.assertFirstLineStartsWith(
|
|
||||||
result.split('\n'),
|
|
||||||
"Metric %s does not exist (HTTP 404)" % metric["id"])
|
|
||||||
|
|
||||||
# DELETE FAIL
|
|
||||||
result = self.gnocchi('metric', params="delete %s" % metric["id"],
|
|
||||||
fail_ok=True, merge_stderr=True)
|
|
||||||
self.assertFirstLineStartsWith(
|
|
||||||
result.split('\n'),
|
|
||||||
"Metric %s does not exist (HTTP 404)" % metric["id"])
|
|
||||||
|
|
||||||
def test_metric_by_name_scenario(self):
|
|
||||||
# PREPARE REQUIREMENT
|
|
||||||
self.gnocchi("archive-policy", params="create metric-test2 "
|
|
||||||
"--back-window 0 -d granularity:1s,points:86400")
|
|
||||||
self.gnocchi("resource", params="create metric-res")
|
|
||||||
|
|
||||||
# CREATE
|
|
||||||
result = self.gnocchi(
|
|
||||||
u'metric', params=u"create"
|
|
||||||
u" --archive-policy-name metric-test2 -r metric-res metric-name")
|
|
||||||
metric = self.details_multiple(result)[0]
|
|
||||||
self.assertIsNotNone(metric["id"])
|
|
||||||
self.assertEqual(self.clients.project_id,
|
|
||||||
metric["created_by_project_id"])
|
|
||||||
self.assertEqual(self.clients.user_id, metric["created_by_user_id"])
|
|
||||||
self.assertEqual('metric-name', metric["name"])
|
|
||||||
self.assertNotEqual('None', metric["resource"])
|
|
||||||
self.assertIn("metric-test", metric["archive_policy/name"])
|
|
||||||
|
|
||||||
# CREATE FAIL
|
|
||||||
result = self.gnocchi(
|
|
||||||
u'metric', params=u"create"
|
|
||||||
u" --archive-policy-name metric-test2 -r metric-res metric-name",
|
|
||||||
fail_ok=True, merge_stderr=True)
|
|
||||||
self.assertFirstLineStartsWith(
|
|
||||||
result.split('\n'),
|
|
||||||
"Named metric metric-name already exists (HTTP 409)")
|
|
||||||
|
|
||||||
# GET
|
|
||||||
result = self.gnocchi('metric',
|
|
||||||
params="show -r metric-res metric-name")
|
|
||||||
metric_get = self.details_multiple(result)[0]
|
|
||||||
self.assertEqual(metric, metric_get)
|
|
||||||
|
|
||||||
# MEASURES ADD
|
|
||||||
result = self.gnocchi('measures',
|
|
||||||
params=("add metric-name -r metric-res "
|
|
||||||
"-m '2015-03-06T14:33:57@43.11' "
|
|
||||||
"--measure '2015-03-06T14:34:12@12'"))
|
|
||||||
self.assertEqual("", result)
|
|
||||||
|
|
||||||
# MEASURES GET
|
|
||||||
result = self.retry_gnocchi(
|
|
||||||
5, 'measures', params=("show metric-name -r metric-res "
|
|
||||||
"--aggregation mean "
|
|
||||||
"--start 2015-03-06T14:32:00 "
|
|
||||||
"--stop 2015-03-06T14:36:00"))
|
|
||||||
|
|
||||||
measures = self.parser.listing(result)
|
|
||||||
self.assertEqual([{'granularity': '1.0',
|
|
||||||
'timestamp': '2015-03-06T14:33:57+00:00',
|
|
||||||
'value': '43.11'},
|
|
||||||
{'granularity': '1.0',
|
|
||||||
'timestamp': '2015-03-06T14:34:12+00:00',
|
|
||||||
'value': '12.0'}], measures)
|
|
||||||
|
|
||||||
# MEASURES AGGREGATION
|
|
||||||
result = self.gnocchi(
|
|
||||||
'measures', params=("--debug aggregation "
|
|
||||||
"--query \"id='metric-res'\" "
|
|
||||||
"--resource-type \"generic\" "
|
|
||||||
"-m metric-name "
|
|
||||||
"--aggregation mean "
|
|
||||||
"--needed-overlap 0 "
|
|
||||||
"--start 2015-03-06T14:32:00 "
|
|
||||||
"--stop 2015-03-06T14:36:00"))
|
|
||||||
measures = self.parser.listing(result)
|
|
||||||
self.assertEqual([{'granularity': '1.0',
|
|
||||||
'timestamp': '2015-03-06T14:33:57+00:00',
|
|
||||||
'value': '43.11'},
|
|
||||||
{'granularity': '1.0',
|
|
||||||
'timestamp': '2015-03-06T14:34:12+00:00',
|
|
||||||
'value': '12.0'}], measures)
|
|
||||||
|
|
||||||
# LIST
|
|
||||||
result = self.gnocchi('metric', params="list")
|
|
||||||
metrics = self.parser.listing(result)
|
|
||||||
metric_from_list = [p for p in metrics
|
|
||||||
if p['archive_policy/name'] == 'metric-test2'][0]
|
|
||||||
for field in ["archive_policy/name", "name"]:
|
|
||||||
# FIXME(sileht): add "resource_id" or "resource"
|
|
||||||
# when LP#1497171 is fixed
|
|
||||||
self.assertEqual(metric[field], metric_from_list[field])
|
|
||||||
|
|
||||||
# DELETE
|
|
||||||
result = self.gnocchi('metric',
|
|
||||||
params="delete -r metric-res metric-name")
|
|
||||||
self.assertEqual("", result)
|
|
||||||
|
|
||||||
# GET FAIL
|
|
||||||
result = self.gnocchi('metric',
|
|
||||||
params="show -r metric-res metric-name",
|
|
||||||
fail_ok=True, merge_stderr=True)
|
|
||||||
self.assertFirstLineStartsWith(
|
|
||||||
result.split('\n'),
|
|
||||||
"Metric metric-name does not exist (HTTP 404)")
|
|
||||||
|
|
||||||
# DELETE FAIL
|
|
||||||
result = self.gnocchi('metric',
|
|
||||||
params="delete -r metric-res metric-name",
|
|
||||||
fail_ok=True, merge_stderr=True)
|
|
||||||
self.assertFirstLineStartsWith(
|
|
||||||
result.split('\n'),
|
|
||||||
"Metric metric-name does not exist (HTTP 404)")
|
|
||||||
|
|
||||||
# GET RESOURCE ID
|
|
||||||
result = self.gnocchi(
|
|
||||||
'resource', params="show -t generic metric-res")
|
|
||||||
resource_id = self.details_multiple(result)[0]["id"]
|
|
||||||
|
|
||||||
# DELETE RESOURCE
|
|
||||||
result = self.gnocchi('resource', params="delete metric-res")
|
|
||||||
self.assertEqual("", result)
|
|
||||||
|
|
||||||
# GET FAIL WITH RESOURCE ERROR
|
|
||||||
result = self.gnocchi('metric',
|
|
||||||
params="show metric-name -r metric-res",
|
|
||||||
fail_ok=True, merge_stderr=True)
|
|
||||||
self.assertFirstLineStartsWith(
|
|
||||||
result.split('\n'),
|
|
||||||
"Resource %s does not exist (HTTP 404)" % resource_id)
|
|
@@ -1,158 +0,0 @@
|
|||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
import uuid
|
|
||||||
|
|
||||||
from gnocchiclient.tests.functional import base
|
|
||||||
|
|
||||||
|
|
||||||
class ResourceClientTest(base.ClientTestBase):
|
|
||||||
RESOURCE_ID = str(uuid.uuid4())
|
|
||||||
RESOURCE_ID2 = str(uuid.uuid4())
|
|
||||||
PROJECT_ID = str(uuid.uuid4())
|
|
||||||
|
|
||||||
def test_help(self):
|
|
||||||
self.gnocchi("help", params="resource list")
|
|
||||||
self.gnocchi("help", params="resource history")
|
|
||||||
self.gnocchi("help", params="resource search")
|
|
||||||
|
|
||||||
def test_resource_scenario(self):
|
|
||||||
apname = str(uuid.uuid4())
|
|
||||||
# Create an archive policy
|
|
||||||
self.gnocchi(
|
|
||||||
u'archive-policy', params=u"create %s"
|
|
||||||
u" -d granularity:1s,points:86400" % apname)
|
|
||||||
|
|
||||||
# CREATE
|
|
||||||
result = self.gnocchi(
|
|
||||||
u'resource', params=u"create %s --type generic" %
|
|
||||||
self.RESOURCE_ID)
|
|
||||||
resource = self.details_multiple(result)
|
|
||||||
resource = self.details_multiple(result)[0]
|
|
||||||
self.assertEqual(self.RESOURCE_ID, resource["id"])
|
|
||||||
self.assertEqual('None', resource["project_id"])
|
|
||||||
self.assertNotEqual('None', resource["started_at"])
|
|
||||||
|
|
||||||
# CREATE FAIL
|
|
||||||
result = self.gnocchi('resource',
|
|
||||||
params="create generic -a id:%s" %
|
|
||||||
self.RESOURCE_ID,
|
|
||||||
fail_ok=True, merge_stderr=True)
|
|
||||||
self.assertFirstLineStartsWith(
|
|
||||||
result.split('\n'),
|
|
||||||
"Resource %s already exists (HTTP 409)" % self.RESOURCE_ID)
|
|
||||||
|
|
||||||
# UPDATE
|
|
||||||
result = self.gnocchi(
|
|
||||||
'resource', params=("update -t generic %s -a project_id:%s "
|
|
||||||
"-n temperature:%s" %
|
|
||||||
(self.RESOURCE_ID, self.PROJECT_ID, apname)))
|
|
||||||
resource_updated = self.details_multiple(result)[0]
|
|
||||||
self.assertEqual(self.RESOURCE_ID, resource_updated["id"])
|
|
||||||
self.assertEqual(self.PROJECT_ID, resource_updated["project_id"])
|
|
||||||
self.assertEqual(resource["started_at"],
|
|
||||||
resource_updated["started_at"])
|
|
||||||
self.assertIn("temperature", resource_updated["metrics"])
|
|
||||||
|
|
||||||
# GET
|
|
||||||
result = self.gnocchi(
|
|
||||||
'resource', params="show -t generic %s" % self.RESOURCE_ID)
|
|
||||||
resource_got = self.details_multiple(result)[0]
|
|
||||||
self.assertEqual(self.RESOURCE_ID, resource_got["id"])
|
|
||||||
self.assertEqual(self.PROJECT_ID, resource_got["project_id"])
|
|
||||||
self.assertEqual(resource["started_at"], resource_got["started_at"])
|
|
||||||
self.assertIn("temperature", resource_updated["metrics"])
|
|
||||||
|
|
||||||
# HISTORY
|
|
||||||
result = self.gnocchi(
|
|
||||||
'resource', params="history --type generic %s" % self.RESOURCE_ID)
|
|
||||||
resource_history = self.parser.listing(result)
|
|
||||||
self.assertEqual(2, len(resource_history))
|
|
||||||
self.assertEqual(self.RESOURCE_ID, resource_history[0]["id"])
|
|
||||||
self.assertEqual(self.RESOURCE_ID, resource_history[1]["id"])
|
|
||||||
self.assertEqual("None", resource_history[0]["project_id"])
|
|
||||||
self.assertEqual(self.PROJECT_ID, resource_history[1]["project_id"])
|
|
||||||
|
|
||||||
# LIST
|
|
||||||
result = self.gnocchi('resource', params="list -t generic")
|
|
||||||
self.assertIn(self.RESOURCE_ID,
|
|
||||||
[r['id'] for r in self.parser.listing(result)])
|
|
||||||
resource_list = [r for r in self.parser.listing(result)
|
|
||||||
if r['id'] == self.RESOURCE_ID][0]
|
|
||||||
self.assertEqual(self.RESOURCE_ID, resource_list["id"])
|
|
||||||
self.assertEqual(self.PROJECT_ID, resource_list["project_id"])
|
|
||||||
self.assertEqual(resource["started_at"], resource_list["started_at"])
|
|
||||||
|
|
||||||
# Search
|
|
||||||
result = self.gnocchi('resource',
|
|
||||||
params=("search --type generic "
|
|
||||||
"--query 'project_id=%s'"
|
|
||||||
) % self.PROJECT_ID)
|
|
||||||
resource_list = self.parser.listing(result)[0]
|
|
||||||
self.assertEqual(self.RESOURCE_ID, resource_list["id"])
|
|
||||||
self.assertEqual(self.PROJECT_ID, resource_list["project_id"])
|
|
||||||
self.assertEqual(resource["started_at"], resource_list["started_at"])
|
|
||||||
|
|
||||||
# CREATE 2
|
|
||||||
result = self.gnocchi(
|
|
||||||
'resource', params=("create %s -t generic "
|
|
||||||
"-a project_id:%s"
|
|
||||||
) % (self.RESOURCE_ID2, self.PROJECT_ID))
|
|
||||||
resource2 = self.details_multiple(result)[0]
|
|
||||||
self.assertEqual(self.RESOURCE_ID2, resource2["id"])
|
|
||||||
self.assertEqual(self.PROJECT_ID, resource2["project_id"])
|
|
||||||
self.assertNotEqual('None', resource2["started_at"])
|
|
||||||
|
|
||||||
# Search + limit + short
|
|
||||||
result = self.gnocchi('resource',
|
|
||||||
params=("search "
|
|
||||||
"-t generic "
|
|
||||||
"--query 'project_id=%s' "
|
|
||||||
"--sort started_at:asc "
|
|
||||||
"--marker %s "
|
|
||||||
"--limit 1"
|
|
||||||
) % (self.PROJECT_ID, self.RESOURCE_ID))
|
|
||||||
resource_limit = self.parser.listing(result)[0]
|
|
||||||
self.assertEqual(self.RESOURCE_ID2, resource_limit["id"])
|
|
||||||
self.assertEqual(self.PROJECT_ID, resource_limit["project_id"])
|
|
||||||
self.assertEqual(resource2["started_at"], resource_limit["started_at"])
|
|
||||||
|
|
||||||
# DELETE
|
|
||||||
result = self.gnocchi('resource',
|
|
||||||
params="delete %s" % self.RESOURCE_ID)
|
|
||||||
self.assertEqual("", result)
|
|
||||||
result = self.gnocchi('resource',
|
|
||||||
params="delete %s" % self.RESOURCE_ID2)
|
|
||||||
self.assertEqual("", result)
|
|
||||||
|
|
||||||
# GET FAIL
|
|
||||||
result = self.gnocchi('resource',
|
|
||||||
params="show --type generic %s" %
|
|
||||||
self.RESOURCE_ID,
|
|
||||||
fail_ok=True, merge_stderr=True)
|
|
||||||
self.assertFirstLineStartsWith(
|
|
||||||
result.split('\n'),
|
|
||||||
"Resource %s does not exist (HTTP 404)" % self.RESOURCE_ID)
|
|
||||||
|
|
||||||
# DELETE FAIL
|
|
||||||
result = self.gnocchi('resource',
|
|
||||||
params="delete %s" % self.RESOURCE_ID,
|
|
||||||
fail_ok=True, merge_stderr=True)
|
|
||||||
self.assertFirstLineStartsWith(
|
|
||||||
result.split('\n'),
|
|
||||||
"Resource %s does not exist (HTTP 404)" % self.RESOURCE_ID)
|
|
||||||
|
|
||||||
# LIST EMPTY
|
|
||||||
result = self.gnocchi('resource', params="list -t generic")
|
|
||||||
resource_ids = [r['id'] for r in self.parser.listing(result)]
|
|
||||||
self.assertNotIn(self.RESOURCE_ID, resource_ids)
|
|
||||||
self.assertNotIn(self.RESOURCE_ID2, resource_ids)
|
|
@@ -1,20 +0,0 @@
|
|||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
from gnocchiclient.tests.functional import base
|
|
||||||
|
|
||||||
|
|
||||||
class MetricClientTest(base.ClientTestBase):
|
|
||||||
def test_status_scenario(self):
|
|
||||||
result = self.gnocchi("status")
|
|
||||||
status = self.details_multiple(result)[0]
|
|
||||||
self.assertEqual(2, len(status))
|
|
Reference in New Issue
Block a user