Base infrastructure for QoS API tests
This introduces the basic methods in the tempest client, that allow the
testing of the QoS plugin. This also contains 2 (very) simple tests
which test creation and deletion of both policies and bandwidth rules,
as well as list/show for both resources. While creation is done
explicitly, deletion is done implicitly (all resources are deleted after
the test, during tearDown)
Minor fixes to the QoS plugin are included as well.
Change-Id: I0f34ed8464857859bcd519e301a49b0b067593b0
diff --git a/neutron/tests/tempest/services/network/json/network_client.py b/neutron/tests/tempest/services/network/json/network_client.py
index 4958bc5..bbee873 100644
--- a/neutron/tests/tempest/services/network/json/network_client.py
+++ b/neutron/tests/tempest/services/network/json/network_client.py
@@ -65,7 +65,9 @@
'metering_label_rules': 'metering',
'firewall_rules': 'fw',
'firewall_policies': 'fw',
- 'firewalls': 'fw'
+ 'firewalls': 'fw',
+ 'policies': 'qos',
+ 'bandwidth_limit_rules': 'qos',
}
service_prefix = service_resource_prefix_map.get(
plural_name)
@@ -90,7 +92,8 @@
'ikepolicy': 'ikepolicies',
'ipsec_site_connection': 'ipsec-site-connections',
'quotas': 'quotas',
- 'firewall_policy': 'firewall_policies'
+ 'firewall_policy': 'firewall_policies',
+ 'qos_policy': 'policies'
}
return resource_plural_map.get(resource_name, resource_name + 's')
@@ -620,3 +623,72 @@
self.expected_success(200, resp.status)
body = json.loads(body)
return service_client.ResponseBody(resp, body)
+
+ def list_qos_policies(self):
+ uri = '%s/qos/policies' % self.uri_prefix
+ resp, body = self.get(uri)
+ self.expected_success(200, resp.status)
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
+
+ def create_qos_policy(self, name, description, shared):
+ uri = '%s/qos/policies' % self.uri_prefix
+ post_data = self.serialize(
+ {'policy': {
+ 'name': name,
+ 'description': description,
+ 'shared': shared
+ }})
+ resp, body = self.post(uri, post_data)
+ body = self.deserialize_single(body)
+ self.expected_success(201, resp.status)
+ return service_client.ResponseBody(resp, body)
+
+ def get_qos_policy(self, policy_id):
+ uri = '%s/qos/policies/%s' % (self.uri_prefix, policy_id)
+ resp, body = self.get(uri)
+ self.expected_success(200, resp.status)
+ return service_client.ResponseBody(resp, body)
+
+ def create_bandwidth_limit_rule(self, policy_id, max_kbps, max_burst_kbps):
+ uri = '%s/qos/policies/%s/bandwidth_limit_rules' % (
+ self.uri_prefix, policy_id)
+ #TODO(QoS): 'bandwidth_limit' should not be a magic string.
+ post_data = self.serialize(
+ {'bandwidth_limit_rule': {
+ 'max_kbps': max_kbps,
+ 'max_burst_kbps': max_burst_kbps,
+ 'type': 'bandwidth_limit'}})
+ resp, body = self.post(uri, post_data)
+ self.expected_success(201, resp.status)
+ body = json.loads(body)
+ return service_client.ResponseBody(resp, body)
+
+ def list_bandwidth_limit_rules(self, policy_id):
+ uri = '%s/qos/policies/%s/bandwidth_limit_rules' % (
+ self.uri_prefix, policy_id)
+ resp, body = self.get(uri)
+ body = self.deserialize_single(body)
+ self.expected_success(200, resp.status)
+ return service_client.ResponseBody(resp, body)
+
+ def show_bandwidth_limit_rule(self, policy_id, rule_id):
+ uri = '%s/qos/policies/%s/bandwidth_limit_rules/%s' % (
+ self.uri_prefix, policy_id, rule_id)
+ resp, body = self.get(uri)
+ body = self.deserialize_single(body)
+ self.expected_success(200, resp.status)
+ return service_client.ResponseBody(resp, body)
+
+ def update_bandwidth_limit_rule(self, policy_id, rule_id,
+ max_kbps, max_burst_kbps):
+ uri = '%s/qos/policies/%s/bandwidth_limit_rules/%s' % (
+ self.uri_prefix, policy_id, rule_id)
+ post_data = {
+ 'bandwidth_limit_rule': {
+ 'max_kbps': max_kbps,
+ 'max_burst_kbps': max_burst_kbps,
+ 'type': 'bandwidth_limit'}}
+ resp, body = self.put(uri, json.dumps(post_data))
+ self.expected_success(200, resp.status)
+ return service_client.ResponseBody(resp, body)