Skip to content
This repository has been archived by the owner on Nov 1, 2018. It is now read-only.

Shipyard GET API Tests #3

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions airship_tempest_plugin/hacking/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def no_rbac_rule_validation_decorator(physical_line, filename):
"""
global have_rbac_decorator

if ("airship_tempest_plugin/tests/api/rbac" in filename or
if ("airship_tempest_plugin/tests/api/shipyard/rbac" in filename or
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it shouldn't be just for shipyard as more rbac tests for other services could be added later

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is added to bypass the naming convention validation for function tests; Naming convention validation would be applicable for all rbac tests only.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, but maybe use regex so it is not hardcoded to only shipyard.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this still needs to be updated. nothing here should be hardcoded to shipyard

"airship_tempest_plugin/tests/scenario" in filename):

if RULE_VALIDATION_DECORATOR.match(physical_line):
Expand All @@ -163,7 +163,7 @@ def no_rbac_suffix_in_test_filename(filename):
"""Check that RBAC filenames end with "_rbac" suffix.
P101
"""
if "airship_tempest_plugin/tests/api" in filename:
if "airship_tempest_plugin/tests/api/shipyard/rbac" in filename:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it shouldn't be just for shipyard as more rbac tests for other services could be added later

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is added to bypass the naming convention validation for the function tests; Naming convention validation would be applicable for all rbac tests only.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, but maybe use regex so it is not hardcoded to only shipyard.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this still needs to be updated. nothing here should be hardcoded to shipyard


if filename.endswith('rbac_base.py'):
return
Expand All @@ -176,7 +176,7 @@ def no_rbac_test_suffix_in_test_class_name(physical_line, filename):
"""Check that RBAC class names end with "RbacTest"
P102
"""
if "airship_tempest_plugin/tests/api/rbac/" in filename:
if "airship_tempest_plugin/tests/api/shipyard/rbac" in filename:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it shouldn't be just for shipyard as more rbac tests for other services could be added later

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is added to bypass the naming convention validation for function tests; Naming convention validation would be applicable for all rbac tests only.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, but maybe use regex so it is not hardcoded to only shipyard.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this still needs to be updated. nothing here should be hardcoded to shipyard


if filename.endswith('rbac_base.py'):
return
Expand All @@ -190,7 +190,7 @@ def no_client_alias_in_test_cases(logical_line, filename):
"""Check that test cases don't use "self.client" to define a client.
P103
"""
if "airship_tempest_plugin/tests/api" in filename:
if "airship_tempest_plugin/tests/api/" in filename:
if "self.client" in logical_line or "cls.client" in logical_line:
return 0, "Do not use 'self.client' as a service client alias"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

from tempest.lib.common import rest_client


# NOTE(rb560u): The following will need to be rewritten in the future if
# functional testing is desired:
# - 'def create_action`
Expand All @@ -37,7 +38,10 @@ def list_actions(self):
resp, body = self.get('actions')
self.expected_success(200, resp.status)
body = json.loads(body)
return rest_client.ResponseBody(resp, body)
if isinstance(body, list):
return rest_client.ResponseBodyList(resp, body)
else:
return rest_client.ResponseBody(resp, body)

def create_action(self, action=None):
url = 'actions'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"""

from oslo_serialization import jsonutils as json

from tempest.lib.common import rest_client


Expand All @@ -30,7 +29,10 @@ def list_workflows(self):
resp, body = self.get('workflows')
self.expected_success(200, resp.status)
body = json.loads(body)
return rest_client.ResponseBody(resp, body)
if isinstance(body, list):
return rest_client.ResponseBodyList(resp, body)
else:
return rest_client.ResponseBody(resp, body)

def get_workflow(self, workflow_id=None):
resp, body = self.get('workflows/%s' % workflow_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
"""

from oslo_serialization import jsonutils as json

from tempest.lib.common import rest_client


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the extra line needed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra line is removed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see it as removed. Perhaps I am not seeing the latest updates made?

# NOTE(rb560u): The following will need to be rewritten in the future if
# functional testing is desired:
# - 'def create_configdocs`
Expand All @@ -37,7 +37,10 @@ def get_configdocs_status(self):
resp, body = self.get('configdocs')
self.expected_success(200, resp.status)
body = json.loads(body)
return rest_client.ResponseBody(resp, body)
if isinstance(body, list):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this needing when doing a get on a specific artifact/resource?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is returning a List only; therefore used "ResponseBodyList".

return rest_client.ResponseBodyList(resp, body)
else:
return rest_client.ResponseBody(resp, body)

def create_configdocs(self, collection_id=None):
url = "configdocs/%s" % collection_id
Expand All @@ -52,17 +55,43 @@ def get_configdocs(self, collection_id=None):
resp, body = self.get('configdocs/%s' % collection_id)
self.expected_success(200, resp.status)
body = json.loads(body)
return rest_client.ResponseBody(resp, body)
if isinstance(body, list):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this needing when doing a get on a specific artifact/resource?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is returning a List only; therefore used "ResponseBodyList".

return rest_client.ResponseBodyList(resp, body)
else:
return rest_client.ResponseBody(resp, body)

def get_configdocs_version(self, collection_id=None, version_arg=None):
resp, body = self.get('configdocs/%s?version=%s' %
(collection_id, version_arg))
self.expected_success(200, resp.status)
return rest_client.ResponseBodyData(resp, body)

def get_renderedconfigdocs(self):
resp, body = self.get('renderedconfigdocs')
self.expected_success(200, resp.status)
body = json.loads(body)
return rest_client.ResponseBody(resp, body)
if isinstance(body, list):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this needing when doing a get on a specific artifact/resource?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is returning a List only; therefore used "ResponseBodyList".

return rest_client.ResponseBodyList(resp, body)
else:
return rest_client.ResponseBody(resp, body)

def get_renderedconfigdocs_version(self, version_arg=None):
resp, body = self.get('renderedconfigdocs?version=%s' % version_arg)
self.expected_success(200, resp.status)
return rest_client.ResponseBodyData(resp, body)

def commit_configdocs(self, force=False, dryrun=False):
post_body = json.dumps({"force": force, "dryrun": dryrun})
resp, body = self.post("commitconfigdocs", post_body)
self.expected_success(200, resp.status)
body = json.loads(body)
return rest_client.ResponseBody(resp, body)

def get_configdocs_compare_two(self, version_arg=None):
resp, body = self.get('configdocs?%s' % version_arg)
self.expected_success(200, resp.status)
body = json.loads(body)
if isinstance(body, list):
return rest_client.ResponseBodyList(resp, body)
else:
return rest_client.ResponseBody(resp, body)
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
http://airship-shipyard.readthedocs.io/en/latest/API.html#airflow-monitoring-api
"""

from oslo_serialization import jsonutils as json

from tempest.lib.common import rest_client


Expand All @@ -30,5 +28,4 @@ def get_action_step_logs(self, action_id=None, step_id=None):
resp, body = \
self.get('actions/%s/steps/%s/logs' % (action_id, step_id))
self.expected_success(200, resp.status)
body = json.loads(body)
return rest_client.ResponseBody(resp, body)
return rest_client.ResponseBodyData(resp, body)
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"""

from oslo_serialization import jsonutils as json

from tempest.lib.common import rest_client
from tempest.lib import decorators


class SiteStatusesClient(rest_client.RestClient):
Expand All @@ -32,3 +32,8 @@ def get_site_statuses(self):
self.expected_success(200, resp.status)
body = json.loads(body)
return rest_client.ResponseBody(resp, body)

def get_site_statuses_arg(self, args=None):
resp, body = self.get('site_statuses?filters=%s' % args)
self.expected_success(200, resp.status)
return rest_client.ResponseBodyData(resp, body)
5 changes: 2 additions & 3 deletions airship_tempest_plugin/tests/api/shipyard/test_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,14 @@
#

from airship_tempest_plugin.tests.api.shipyard import base

from tempest.lib import decorators


class ActionsTest(base.BaseShipyardTest):

def _get_action_id(self):
resp = self.shipyard_actions_client.list_actions()
self.assertTrue(len(resp[1]) > 0,
'No actions available, nothing to test')
# get the response body
return resp[1]['id']

def _get_action_step_id(self):
Expand All @@ -48,10 +45,12 @@ def test_get_action(self):
"""Get actions, Successful with response status 200"""
resp = self.shipyard_actions_client.get_action(action_id)
self.assertEqual(resp.response['status'], '200')
self.assertEqual(resp.values()[0][0]['action_id'], action_id)

@decorators.idempotent_id('a8bc9e6b-bfa3-4635-a1ec-0b9ddc9cb03f')
def test_get_action_step(self):
"""Get actions step, Successful with response status 200"""
action_id, step_id = self._get_action_step_id()
resp = self.shipyard_actions_client.get_action_step(action_id, step_id)
self.assertEqual(resp.response['status'], '200')
self.assertEqual(resp['task_id'], step_id)
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2018 AT&T Corp
# All Rights Reserved.
#
# 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 airship_tempest_plugin.tests.api.shipyard import base
from tempest.lib import decorators


class AirflowMonitoringTest(base.BaseShipyardTest):
def _get_workflows_id(self):
resp = self.shipyard_airflow_monitoring_client.list_workflows()
self.assertTrue(len(resp[0]) > 0,
'No configdocs available, nothing to test')
return resp[0]['workflow_id']

@decorators.idempotent_id('5a41bb54-c010-4d09-9d68-eece565e66f3')
def test_get_workflows_list(self):
"""List of workflows, Successful with response status 200"""
response = self.shipyard_airflow_monitoring_client.list_workflows()
self.assertEqual(response.response['status'], '200')

@decorators.idempotent_id('7e4fb56b-6637-48bf-808d-c166ee5f804f')
def test_get_workflow(self):
"""A particular workflow detail, Successful with response status 200"""
workflow_id = self._get_workflows_id()
response = self.shipyard_airflow_monitoring_client. \
get_workflow(workflow_id)
self.assertEqual(response.response['status'], '200')
self.assertEqual(response['workflow_id'], workflow_id)
Loading