From fd821f2d42e5e99b15f55a62308f67bc6de23729 Mon Sep 17 00:00:00 2001 From: Adrian Moreno Date: Mon, 11 Dec 2017 15:44:17 +0100 Subject: [PATCH] Test dashboard endpoint --- ecsclient/common/monitoring/dashboard.py | 9 +- ecsclient/schemas.py | 195 +++++++++++++++++++++++ tests/functional/__init__.py | 3 +- tests/functional/test_dashboard.py | 19 +++ 4 files changed, 217 insertions(+), 9 deletions(-) create mode 100644 tests/functional/test_dashboard.py diff --git a/ecsclient/common/monitoring/dashboard.py b/ecsclient/common/monitoring/dashboard.py index 5511fb2..ad91a5e 100644 --- a/ecsclient/common/monitoring/dashboard.py +++ b/ecsclient/common/monitoring/dashboard.py @@ -1,12 +1,5 @@ -# Standard lib imports import logging -# Third party imports -# None - -# Project level imports -# None - log = logging.getLogger(__name__) @@ -48,7 +41,7 @@ def get_local_zone_replication_groups(self): Too large to output here """ - log.info("Getting vpools in local VDC") + log.info("Getting local VDC replication groups details") return self.conn.get(url='dashboard/zones/localzone/replicationgroups') def get_local_zone_rglinks_failed(self): diff --git a/ecsclient/schemas.py b/ecsclient/schemas.py index 08fd914..b0cb356 100644 --- a/ecsclient/schemas.py +++ b/ecsclient/schemas.py @@ -857,3 +857,198 @@ "totalProvisioned_gb" ] } + +DASHBOARD_REPLICATION_GROUP_TRAFFIC = { + "type": "object", + "properties": { + "Bandwidth": {"type": "string"}, + "t": {"type": "string"}, + }, + "required": [ + "Bandwidth", + "t" + ] +} + +DASHBOARD_REPLICATION_GROUP_TRAFFIC_SUMMARY = { + "type": "object", + "properties": { + "Max": { + "type": "array", + "minItems": 0, + "items": DASHBOARD_REPLICATION_GROUP_TRAFFIC + }, + "Min": { + "type": "array", + "minItems": 0, + "items": DASHBOARD_REPLICATION_GROUP_TRAFFIC + }, + "Avg": {"type": "string"}, + }, + "required": [ + "Max", + "Min", + "Avg" + ] +} + +DASHBOARD_REPLICATION_GROUP = { + "type": "object", + "properties": { + "chunksRepoPendingReplicationTotalSize": {"type": "string"}, + "chunksJournalPendingReplicationTotalSize": {"type": "string"}, + "chunksPendingXorTotalSize": {"type": "string"}, + "name": {"type": "string"}, + "id": {"type": "string"}, + "numZones": {"type": "string"}, + "apiChange": {"type": "string"}, + "replicationIngressTrafficSummary": DASHBOARD_REPLICATION_GROUP_TRAFFIC_SUMMARY, + "replicationEgressTrafficSummary": DASHBOARD_REPLICATION_GROUP_TRAFFIC_SUMMARY, + "replicationIngressTraffic": { + "type": "array", + "minItems": 0, + "items": DASHBOARD_REPLICATION_GROUP_TRAFFIC + }, + "replicationEgressTraffic": { + "type": "array", + "minItems": 0, + "items": DASHBOARD_REPLICATION_GROUP_TRAFFIC + }, + "_links": { + "type": "object", + "properties": { + "self": { + "type": "object", + "properties": { + "href": {"type": "string"}, + }, + "required": [ + "href", + ] + }, + "rglinks": { + "type": "object", + "properties": { + "href": {"type": "string"}, + }, + "required": [ + "href", + ] + }, + "datatables": { + "type": "object", + "properties": { + "href": {"type": "string"}, + }, + "required": [ + "href", + ] + } + }, + "required": [ + "self", + "rglinks", + "datatables", + ] + }, + }, + "required": [ + "chunksRepoPendingReplicationTotalSize", + "chunksJournalPendingReplicationTotalSize", + "chunksPendingXorTotalSize", + "name", + "id", + "numZones", + "apiChange", + "replicationIngressTrafficSummary", + "replicationEgressTrafficSummary", + "replicationIngressTraffic", + "replicationEgressTraffic", + "_links" + ] +} + +DASHBOARD_REPLICATION_GROUPS = { + "type": "object", + "properties": { + "title": {"type": "string"}, + "_links": { + "type": "object", + "properties": { + "self": { + "type": "object", + "properties": { + "href": {"type": "string"}, + }, + "required": [ + "href", + ] + } + }, + "required": [ + "self", + ] + }, + "_embedded": { + "type": "object", + "properties": { + "_instances": { + "type": "array", + "minItems": 1, + "items": DASHBOARD_REPLICATION_GROUP + } + }, + "required": [ + "_instances", + ] + }, + + }, + "required": [ + "title", + "_links", + "_embedded" + ] +} + +DASHBOARD_NODES = { + "type": "object", + "properties": { + "title": {"type": "string"}, + "_links": { + "type": "object", + "properties": { + "self": { + "type": "object", + "properties": { + "href": {"type": "string"}, + }, + "required": [ + "href", + ] + } + }, + "required": [ + "self", + ] + }, + "_embedded": { + "type": "object", + "properties": { + "_instances": { + "type": "array", + "minItems": 1, + } + }, + "required": [ + "_instances", + ] + }, + + }, + "required": [ + "title", + "_links", + "_embedded" + ] +} diff --git a/tests/functional/__init__.py b/tests/functional/__init__.py index 2882734..8aa7e77 100644 --- a/tests/functional/__init__.py +++ b/tests/functional/__init__.py @@ -38,7 +38,8 @@ def _get_client(self): username=self.username, password=self.password, ecs_endpoint=self.ecs_endpoint, - token_endpoint=self.token_endpoint) + token_endpoint=self.token_endpoint, + request_timeout=60.0) def setUp(self): super(BaseTestCase, self).setUp() diff --git a/tests/functional/test_dashboard.py b/tests/functional/test_dashboard.py new file mode 100644 index 0000000..335a69c --- /dev/null +++ b/tests/functional/test_dashboard.py @@ -0,0 +1,19 @@ +from ecsclient import schemas +from tests import functional + + +class TestDashboard(functional.BaseTestCase): + + def __test_get_local_zone_replication_groups(self): + response = self.client.dashboard.get_local_zone_replication_groups() + self.assertValidSchema(response, schemas.DASHBOARD_REPLICATION_GROUPS) + + def __test_get_local_zone_nodes(self): + response = self.client.dashboard.get_local_zone_nodes() + # TODO: complete the schema to validate the full response + self.assertValidSchema(response, schemas.DASHBOARD_NODES) + + def test_get_node_disks(self): + response = self.client.dashboard.get_node_disks() + print(response) + # self.assertValidSchema(response, schemas.DASHBOARD_NODES)