From 0bf35b1cb18f7ecf52e4dff444a3aaa94eb347eb Mon Sep 17 00:00:00 2001 From: vgusev Date: Tue, 17 Mar 2015 17:27:16 +0300 Subject: [PATCH] [Ceilometer] Add context and scenario for resources - Added context ceilometer.py for creating samples and collecting resources in list - Added CeilometerResource.get_resources_on_tenant scenario Change-Id: I4cf6148cdd3fa685a2ae17eb16f1e205e1edb2bf --- rally-jobs/rally.yaml | 27 +++++++++++++++++++ .../ceilometer/get-tenant-resources.json | 23 ++++++++++++++++ .../ceilometer/get-tenant-resources.yaml | 16 +++++++++++ .../scenarios/ceilometer/list-samples.json | 8 ++++++ .../scenarios/ceilometer/list-samples.yaml | 7 +++++ tests/unit/fakes.py | 16 ++++++++++- 6 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 samples/tasks/scenarios/ceilometer/get-tenant-resources.json create mode 100644 samples/tasks/scenarios/ceilometer/get-tenant-resources.yaml diff --git a/rally-jobs/rally.yaml b/rally-jobs/rally.yaml index 6efcb798..fb226cde 100755 --- a/rally-jobs/rally.yaml +++ b/rally-jobs/rally.yaml @@ -296,6 +296,26 @@ failure_rate: max: 0 + CeilometerResource.get_tenant_resources: + - + runner: + type: "constant" + times: 10 + concurrency: 5 + context: + users: + tenants: 2 + users_per_tenant: 2 + ceilometer: + counter_name: "cpu_util" + counter_type: "gauge" + counter_volume: 1.0 + counter_unit: "instance" + resources_per_tenant: 3 + sla: + failure_rate: + max: 0 + CeilometerSamples.list_samples: - runner: @@ -306,6 +326,13 @@ users: tenants: 1 users_per_tenant: 1 + ceilometer: + counter_name: "cpu_util" + counter_type: "gauge" + counter_unit: "instance" + counter_volume: 1.0 + resources_per_tenant: 3 + samples_per_resource: 3 sla: failure_rate: max: 0 diff --git a/samples/tasks/scenarios/ceilometer/get-tenant-resources.json b/samples/tasks/scenarios/ceilometer/get-tenant-resources.json new file mode 100644 index 00000000..a1e7467a --- /dev/null +++ b/samples/tasks/scenarios/ceilometer/get-tenant-resources.json @@ -0,0 +1,23 @@ +{ + "CeilometerResource.get_tenant_resources": [ + { + "runner": { + "type": "constant", + "times": 10, + "concurrency": 5 + }, + "context": { + "users": { + "tenants": 2, + "users_per_tenant": 2 + }, + "ceilometer": { + "counter_name": "cpu_util", + "counter_type": "gauge", + "counter_unit": "instance", + "counter_volume": 1.0 + } + } + } + ] +} \ No newline at end of file diff --git a/samples/tasks/scenarios/ceilometer/get-tenant-resources.yaml b/samples/tasks/scenarios/ceilometer/get-tenant-resources.yaml new file mode 100644 index 00000000..a58d3c8f --- /dev/null +++ b/samples/tasks/scenarios/ceilometer/get-tenant-resources.yaml @@ -0,0 +1,16 @@ +--- + CeilometerResource.get_tenant_resources: + - + runner: + type: "constant" + times: 10 + concurrency: 5 + context: + users: + tenants: 2 + users_per_tenant: 2 + ceilometer: + counter_name: "cpu_util" + counter_type: "gauge" + counter_volume: 1.0 + counter_unit: "instance" \ No newline at end of file diff --git a/samples/tasks/scenarios/ceilometer/list-samples.json b/samples/tasks/scenarios/ceilometer/list-samples.json index 393c8d36..1b4b3973 100644 --- a/samples/tasks/scenarios/ceilometer/list-samples.json +++ b/samples/tasks/scenarios/ceilometer/list-samples.json @@ -10,6 +10,14 @@ "users": { "tenants": 2, "users_per_tenant": 2 + }, + "ceilometer": { + "counter_name": "cpu_util", + "counter_type": "gauge", + "counter_unit": "instance", + "counter_volume": 1.0, + "resources_per_tenant": 3, + "samples_per_resource": 3 } } } diff --git a/samples/tasks/scenarios/ceilometer/list-samples.yaml b/samples/tasks/scenarios/ceilometer/list-samples.yaml index 7c8e053c..6c4547b9 100644 --- a/samples/tasks/scenarios/ceilometer/list-samples.yaml +++ b/samples/tasks/scenarios/ceilometer/list-samples.yaml @@ -9,3 +9,10 @@ users: tenants: 2 users_per_tenant: 2 + ceilometer: + counter_name: "cpu_util" + counter_type: "gauge" + counter_unit: "instance" + counter_volume: 1.0 + resources_per_tenant: 3 + samples_per_resource: 3 diff --git a/tests/unit/fakes.py b/tests/unit/fakes.py index fbd8016a..23064760 100644 --- a/tests/unit/fakes.py +++ b/tests/unit/fakes.py @@ -219,6 +219,7 @@ class FakeAlarm(FakeResource): self.threshold = kwargs.get("threshold") self.state = kwargs.get("state", "fake-alarm-state") self.alarm_id = kwargs.get("alarm_id", "fake-alarm-id") + self.state = kwargs.get("state", "ok") self.optional_args = kwargs.get("optional_args", {}) @@ -229,7 +230,17 @@ class FakeSample(FakeResource): self.counter_type = kwargs.get("counter_type", "fake-counter-type") self.counter_unit = kwargs.get("counter_unit", "fake-counter-unit") self.counter_volume = kwargs.get("counter_volume", 100) - self.resource_id = kwargs.get("resource_id", "fake-resource-id") + + @property + def resource_id(self): + return "fake-resource-id" + + def to_dict(self): + return {"counter_name": self.counter_name, + "counter_type": self.counter_type, + "counter_unit": self.counter_unit, + "counter_volume": self.counter_volume, + "resource_id": self.resource_id} class FakeVolume(FakeResource): @@ -775,6 +786,9 @@ class FakeMeterManager(FakeManager): class FakeCeilometerResourceManager(FakeManager): + def get(self, resource_id): + return ["fake-resource-info"] + def list(self): return ["fake-resource"]