From 7d461b19ed0d8da3a2038454f66d4b6d22d1e4a1 Mon Sep 17 00:00:00 2001 From: Aswad Rangnekar Date: Thu, 29 May 2014 11:40:47 +0530 Subject: [PATCH] Minor fixes in Ceilometer benchmark scenarios 1. Renames ceilometer.py to alarms.py as it contains scenarios for alarms only. 2. Complete a TODO to use self._generate_random_name Change-Id: I536e0ebd20f8dc56e31a75f117994c3abe4c9f2d Closes-Bug: #1323629 --- doc/samples/tasks/ceilometer/create-alarm.json | 2 +- doc/samples/tasks/ceilometer/create-alarm.yaml | 2 +- .../tasks/ceilometer/create-and-delete-alarm.json | 2 +- .../tasks/ceilometer/create-and-delete-alarm.yaml | 2 +- .../tasks/ceilometer/create-and-list-alarm.json | 2 +- .../tasks/ceilometer/create-and-list-alarm.yaml | 2 +- .../tasks/ceilometer/create-and-update-alarm.json | 2 +- .../tasks/ceilometer/create-and-update-alarm.yaml | 2 +- doc/samples/tasks/ceilometer/list-alarms.json | 2 +- doc/samples/tasks/ceilometer/list-alarms.yaml | 2 +- rally-scenarios/rally.yaml | 10 +++++----- .../ceilometer/{ceilometer.py => alarms.py} | 2 +- rally/benchmark/scenarios/ceilometer/utils.py | 10 +++------- .../{test_ceilometer.py => test_alarms.py} | 14 +++++++------- 14 files changed, 26 insertions(+), 30 deletions(-) rename rally/benchmark/scenarios/ceilometer/{ceilometer.py => alarms.py} (98%) rename tests/benchmark/scenarios/ceilometer/{test_ceilometer.py => test_alarms.py} (90%) diff --git a/doc/samples/tasks/ceilometer/create-alarm.json b/doc/samples/tasks/ceilometer/create-alarm.json index 2aa260eb17..839fabf8d9 100644 --- a/doc/samples/tasks/ceilometer/create-alarm.json +++ b/doc/samples/tasks/ceilometer/create-alarm.json @@ -1,5 +1,5 @@ { - "CeilometerBasic.create_alarm": [ + "CeilometerAlarms.create_alarm": [ { "args": { "meter_name": "ram_util", diff --git a/doc/samples/tasks/ceilometer/create-alarm.yaml b/doc/samples/tasks/ceilometer/create-alarm.yaml index 9500f01629..5954227751 100644 --- a/doc/samples/tasks/ceilometer/create-alarm.yaml +++ b/doc/samples/tasks/ceilometer/create-alarm.yaml @@ -1,5 +1,5 @@ --- - CeilometerBasic.create_alarm: + CeilometerAlarms.create_alarm: - args: meter_name: "ram_util" diff --git a/doc/samples/tasks/ceilometer/create-and-delete-alarm.json b/doc/samples/tasks/ceilometer/create-and-delete-alarm.json index 256d144100..366ac24cba 100644 --- a/doc/samples/tasks/ceilometer/create-and-delete-alarm.json +++ b/doc/samples/tasks/ceilometer/create-and-delete-alarm.json @@ -1,5 +1,5 @@ { - "CeilometerBasic.create_and_delete_alarm": [ + "CeilometerAlarms.create_and_delete_alarm": [ { "args": { "meter_name": "ram_util", diff --git a/doc/samples/tasks/ceilometer/create-and-delete-alarm.yaml b/doc/samples/tasks/ceilometer/create-and-delete-alarm.yaml index 8ad134ff4a..6577f64861 100644 --- a/doc/samples/tasks/ceilometer/create-and-delete-alarm.yaml +++ b/doc/samples/tasks/ceilometer/create-and-delete-alarm.yaml @@ -1,5 +1,5 @@ --- - CeilometerBasic.create_and_delete_alarm: + CeilometerAlarms.create_and_delete_alarm: - args: meter_name: "ram_util" diff --git a/doc/samples/tasks/ceilometer/create-and-list-alarm.json b/doc/samples/tasks/ceilometer/create-and-list-alarm.json index afe1fea042..5bf1e278cf 100644 --- a/doc/samples/tasks/ceilometer/create-and-list-alarm.json +++ b/doc/samples/tasks/ceilometer/create-and-list-alarm.json @@ -1,5 +1,5 @@ { - "CeilometerBasic.create_and_list_alarm": [ + "CeilometerAlarms.create_and_list_alarm": [ { "args": { "meter_name": "ram_util", diff --git a/doc/samples/tasks/ceilometer/create-and-list-alarm.yaml b/doc/samples/tasks/ceilometer/create-and-list-alarm.yaml index 46956ffeff..2101cff338 100644 --- a/doc/samples/tasks/ceilometer/create-and-list-alarm.yaml +++ b/doc/samples/tasks/ceilometer/create-and-list-alarm.yaml @@ -1,5 +1,5 @@ --- - CeilometerBasic.create_and_list_alarm: + CeilometerAlarms.create_and_list_alarm: - args: meter_name: "ram_util" diff --git a/doc/samples/tasks/ceilometer/create-and-update-alarm.json b/doc/samples/tasks/ceilometer/create-and-update-alarm.json index 811f5167c6..481f27a3e2 100644 --- a/doc/samples/tasks/ceilometer/create-and-update-alarm.json +++ b/doc/samples/tasks/ceilometer/create-and-update-alarm.json @@ -1,5 +1,5 @@ { - "CeilometerBasic.create_and_update_alarm": [ + "CeilometerAlarms.create_and_update_alarm": [ { "args": { "meter_name": "ram_util", diff --git a/doc/samples/tasks/ceilometer/create-and-update-alarm.yaml b/doc/samples/tasks/ceilometer/create-and-update-alarm.yaml index 8c0353126f..27e0c1ecce 100644 --- a/doc/samples/tasks/ceilometer/create-and-update-alarm.yaml +++ b/doc/samples/tasks/ceilometer/create-and-update-alarm.yaml @@ -1,5 +1,5 @@ --- - CeilometerBasic.create_and_update_alarm: + CeilometerAlarms.create_and_update_alarm: - args: meter_name: "ram_util" diff --git a/doc/samples/tasks/ceilometer/list-alarms.json b/doc/samples/tasks/ceilometer/list-alarms.json index 0f1457715d..1f6e37902d 100644 --- a/doc/samples/tasks/ceilometer/list-alarms.json +++ b/doc/samples/tasks/ceilometer/list-alarms.json @@ -1,5 +1,5 @@ { - "CeilometerBasic.list_alarms": [ + "CeilometerAlarms.list_alarms": [ { "runner":{ "type": "constant", diff --git a/doc/samples/tasks/ceilometer/list-alarms.yaml b/doc/samples/tasks/ceilometer/list-alarms.yaml index 20d2861b73..39db2ca1a9 100644 --- a/doc/samples/tasks/ceilometer/list-alarms.yaml +++ b/doc/samples/tasks/ceilometer/list-alarms.yaml @@ -1,5 +1,5 @@ --- - CeilometerBasic.list_alarms: + CeilometerAlarms.list_alarms: - runner: type: "constant" diff --git a/rally-scenarios/rally.yaml b/rally-scenarios/rally.yaml index 242142bd5b..390f8ac3ef 100644 --- a/rally-scenarios/rally.yaml +++ b/rally-scenarios/rally.yaml @@ -17,7 +17,7 @@ times: 10 concurrency: 10 - CeilometerBasic.create_alarm: + CeilometerAlarms.create_alarm: - args: meter_name: "ram_util" @@ -32,7 +32,7 @@ times: 10 concurrency: 10 - CeilometerBasic.create_and_delete_alarm: + CeilometerAlarms.create_and_delete_alarm: - args: meter_name: "ram_util" @@ -47,7 +47,7 @@ times: 10 concurrency: 10 - CeilometerBasic.create_and_list_alarm: + CeilometerAlarms.create_and_list_alarm: - args: meter_name: "ram_util" @@ -62,7 +62,7 @@ times: 10 concurrency: 10 - CeilometerBasic.create_and_update_alarm: + CeilometerAlarms.create_and_update_alarm: - args: meter_name: "ram_util" @@ -77,7 +77,7 @@ times: 10 concurrency: 10 - CeilometerBasic.list_alarms: + CeilometerAlarms.list_alarms: - runner: type: "constant" diff --git a/rally/benchmark/scenarios/ceilometer/ceilometer.py b/rally/benchmark/scenarios/ceilometer/alarms.py similarity index 98% rename from rally/benchmark/scenarios/ceilometer/ceilometer.py rename to rally/benchmark/scenarios/ceilometer/alarms.py index b2c3974916..b19ee56dbd 100644 --- a/rally/benchmark/scenarios/ceilometer/ceilometer.py +++ b/rally/benchmark/scenarios/ceilometer/alarms.py @@ -16,7 +16,7 @@ from rally.benchmark.scenarios import base from rally.benchmark.scenarios.ceilometer import utils as ceilometerutils -class CeilometerBasic(ceilometerutils.CeilometerScenario): +class CeilometerAlarms(ceilometerutils.CeilometerScenario): @base.scenario(context={"cleanup": ["ceilometer"]}) def create_alarm(self, meter_name, threshold, **kwargs): """Test creating an alarm. diff --git a/rally/benchmark/scenarios/ceilometer/utils.py b/rally/benchmark/scenarios/ceilometer/utils.py index c17560d0d2..49ec724304 100644 --- a/rally/benchmark/scenarios/ceilometer/utils.py +++ b/rally/benchmark/scenarios/ceilometer/utils.py @@ -12,8 +12,6 @@ # License for the specific language governing permissions and limitations # under the License. -import uuid - from rally.benchmark.scenarios import base from rally.benchmark.scenarios import utils as scenario_utils @@ -27,11 +25,9 @@ class CeilometerScenario(base.Scenario): :param kwargs: optional parameters to create alarm :returns: alarm dictionary used to create an alarm """ - # TODO(Aswad): Reuse _generate_random_name from base.Scenario instead - # of generating alarm_uuid. Ref: bp/benchmark-scenarios-for-neutron. - alarm_uuid = str(uuid.uuid4()) - alarm = {"alarm_id": alarm_uuid, - "name": "TestAlarm-%s" % alarm_uuid, + alarm_id = self._generate_random_name() + alarm = {"alarm_id": alarm_id, + "name": "TestAlarm-%s" % alarm_id, "description": "Test Alarm"} alarm.update(kwargs) diff --git a/tests/benchmark/scenarios/ceilometer/test_ceilometer.py b/tests/benchmark/scenarios/ceilometer/test_alarms.py similarity index 90% rename from tests/benchmark/scenarios/ceilometer/test_ceilometer.py rename to tests/benchmark/scenarios/ceilometer/test_alarms.py index a91d470cf2..335c947197 100644 --- a/tests/benchmark/scenarios/ceilometer/test_ceilometer.py +++ b/tests/benchmark/scenarios/ceilometer/test_alarms.py @@ -14,13 +14,13 @@ import mock -from rally.benchmark.scenarios.ceilometer import ceilometer +from rally.benchmark.scenarios.ceilometer import alarms from tests import test -class CeilometerBasicTestCase(test.TestCase): +class CeilometerAlarmsTestCase(test.TestCase): def test_create_alarm(self): - scenario = ceilometer.CeilometerBasic() + scenario = alarms.CeilometerAlarms() scenario._create_alarm = mock.MagicMock() scenario.create_alarm("fake_meter_name", @@ -31,7 +31,7 @@ class CeilometerBasicTestCase(test.TestCase): {'fakearg': 'f'}) def test_list_alarm(self): - scenario = ceilometer.CeilometerBasic() + scenario = alarms.CeilometerAlarms() scenario._list_alarms = mock.MagicMock() scenario.list_alarms() @@ -39,7 +39,7 @@ class CeilometerBasicTestCase(test.TestCase): def test_create_and_list_alarm(self): fake_alarm = mock.MagicMock() - scenario = ceilometer.CeilometerBasic() + scenario = alarms.CeilometerAlarms() scenario._create_alarm = mock.MagicMock(return_value=fake_alarm) scenario._list_alarms = mock.MagicMock() @@ -54,7 +54,7 @@ class CeilometerBasicTestCase(test.TestCase): def test_create_and_update_alarm(self): fake_alram_dict_diff = {'description': 'Changed Test Description'} fake_alarm = mock.MagicMock() - scenario = ceilometer.CeilometerBasic() + scenario = alarms.CeilometerAlarms() scenario._create_alarm = mock.MagicMock(return_value=fake_alarm) scenario._update_alarm = mock.MagicMock() @@ -69,7 +69,7 @@ class CeilometerBasicTestCase(test.TestCase): def test_create_and_delete_alarm(self): fake_alarm = mock.MagicMock() - scenario = ceilometer.CeilometerBasic() + scenario = alarms.CeilometerAlarms() scenario._create_alarm = mock.MagicMock(return_value=fake_alarm) scenario._delete_alarm = mock.MagicMock()