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

Conversation

rupamatt
Copy link

@rupamatt rupamatt commented Oct 5, 2018

Shipyard GET API Tests - F30

@@ -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

@@ -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

@@ -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

@@ -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/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.

this is regardless of rbac. this should be enforced for all classes that instantiate a service client

Copy link
Author

Choose a reason for hiding this comment

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

Ok, Will be modified accordingly.

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


def get_workflow(self, workflow_id=None):
resp, body = self.get('workflows/%s' % workflow_id)
self.expected_success(200, resp.status)
body = json.loads(body)
return rest_client.ResponseBody(resp, body)
if isinstance(body, list):
Copy link
Contributor

@rickbartra91 rickbartra91 Oct 9, 2018

Choose a reason for hiding this comment

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

as this is a single GET - meaning it gets a specific workflow- would it ever return a list?

Copy link
Author

Choose a reason for hiding this comment

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

Modified accordingly as it's returning a specific workflow

@@ -22,6 +22,7 @@

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?

@@ -37,7 +38,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".

@@ -52,13 +56,30 @@ 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".


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".

# under the License.
#

import logging
Copy link
Contributor

Choose a reason for hiding this comment

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

not used

Copy link
Author

Choose a reason for hiding this comment

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

Used "logging.getLogger()" instead of "print()"

Copy link
Contributor

Choose a reason for hiding this comment

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

I am not seeing your updates...

from tempest.lib import exceptions

CONF = config.CONF
LOG = logging.getLogger(__name__)
Copy link
Contributor

Choose a reason for hiding this comment

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

not used

Copy link
Author

Choose a reason for hiding this comment

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

Removed


from airship_tempest_plugin.tests.api.shipyard import base

from tempest import config
Copy link
Contributor

Choose a reason for hiding this comment

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

not used

Copy link
Author

Choose a reason for hiding this comment

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

Removed

from tempest.lib import decorators
from tempest.lib import exceptions

CONF = config.CONF
Copy link
Contributor

Choose a reason for hiding this comment

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

not used

Copy link
Author

Choose a reason for hiding this comment

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

Removed

CONF = config.CONF
LOG = logging.getLogger(__name__)


Copy link
Contributor

Choose a reason for hiding this comment

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

nit: DocumentStagingTests


@decorators.idempotent_id('743ab304-be35-4e45-ad47-e124dce3b9dc')
def test_get_collection(self):
"""Get Config docs, Successful with response status 200
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe update docstring so it is clear that it is getting a specific collection

Copy link
Author

Choose a reason for hiding this comment

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

Updated accordingly

def test_get_collection_list(self):
"""Config docs status, Successful with response status 200"""
response = self.shipyard_document_staging_client.\
get_configdocs_status()
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we should reconsider the name of this API method: " get_configdocs_status()" ... there may be a reason why it contains "status" but I forgot why at the moment. Just something to consider

Copy link
Author

Choose a reason for hiding this comment

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

"get_configdocs_status()" is a function in "document_staging_client.py" which is resulting a list of all configuration docs and this function has been called from "test_document_staging_rbac.py" also; therefore not modified the name.

self.assertEqual(response.response['status'], '200')
except exceptions.NotFound:
print("The Shipyard buffer does not contain this collection")
pass
Copy link
Contributor

@rickbartra91 rickbartra91 Oct 9, 2018

Choose a reason for hiding this comment

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

don't use print ...
I think the NotFound exception should be raised...

Under what scenario does:
collection_id = self._get_collection_id()
not return a valid collection_id ?

Copy link
Author

@rupamatt rupamatt Oct 19, 2018

Choose a reason for hiding this comment

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

Removed print and used Log instead.

Collection_id is returning a valid one but as per Shipyard API document, it will return "404 NotFound exception" if the Shipyard buffer does not contain this particular collection and considered this scenario as Pass , used "except exceptions.NotFound".

response = self.shipyard_document_staging_client.\
get_configdocs_version(collection_id, "buffer")
self.assertEqual(response.response['status'], '200')
except exceptions.NotFound:
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment as above regarding the NotFound exception

Copy link
Author

Choose a reason for hiding this comment

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

As per Shipyard API document, it will return "404 NotFound exception" if the Shipyard buffer does not contain this particular collection and considered this scenario as Pass , used "except exceptions.NotFound".

Successful with response status 200
"""
collection_id = self._get_collection_id()
response = self.shipyard_document_staging_client.\
Copy link
Contributor

Choose a reason for hiding this comment

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

just curious why you selectively use the try/except logic when collection_id is being passed as an argument

collection_id = self._get_collection_id()
response = self.shipyard_document_staging_client.\
get_configdocs_version(collection_id, "successful_site_action")
self.assertEqual(response.response['status'], '200')
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment as above; "just curious why you selectively use the try/except logic when collection_id is being passed as an argument"

Copy link
Author

@rupamatt rupamatt Oct 19, 2018

Choose a reason for hiding this comment

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

In this scenario, "404 NotFound exception" is not returned; therefore "NotFound exception is not used.
As per Shipyard API document, wherever "404 NotFound Exception" may be returned in case of unavailability of the intended result(resource like collection, buffer etc), try/exception is used for those scenarios only.

Successful with response status 200
"""
collection_id = self._get_collection_id()
response = self.shipyard_document_staging_client.\
Copy link
Contributor

Choose a reason for hiding this comment

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

same as above

response = self.shipyard_document_staging_client.\
get_renderedconfigdocs()
self.assertEqual(response.response['status'], '200')
except exceptions.NotFound:
Copy link
Contributor

@rickbartra91 rickbartra91 Oct 9, 2018

Choose a reason for hiding this comment

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

why are the exceptions being silenced? If the resource doesn't exists, then a setup or teardown should be present. Tempest tests shouldn't rely on resources already existing.

Copy link
Author

Choose a reason for hiding this comment

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

As per Shipyard API documentation, for some of the API call, there might "404 NotFound" exception be raised, therefore try/exception block has been used. As of now, there are only test cases related to GET API call, once POST API call test cases will be added, setup and teardown will definitely be introduced.

response = self.shipyard_document_staging_client.\
get_renderedconfigdocs_version("buffer")
self.assertEqual(response.response['status'], '200')
except exceptions.NotFound:
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment as above

Copy link
Author

Choose a reason for hiding this comment

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

As per Shipyard API documentation, for some of the API call, there might "404 NotFound" exception be raised, therefore try/exception block has been used. As of now, there are only test cases related to GET API call, once POST API call test cases will be added, setup and teardown will definitely be introduced.

response = self.shipyard_document_staging_client.\
get_renderedconfigdocs_version("successful_site_action")
self.assertEqual(response.response['status'], '200')
except exceptions.NotFound:
Copy link
Contributor

Choose a reason for hiding this comment

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

same comments as above

Copy link
Author

Choose a reason for hiding this comment

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

As per Shipyard API documentation, for some of the API call, there might "404 NotFound" exception be raised, therefore try/exception block has been used. As of now, there are only test cases related to GET API call, once POST API call test cases will be added, setup and teardown will definitely be introduced.

Copy link
Contributor

@rickbartra91 rickbartra91 left a comment

Choose a reason for hiding this comment

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

Please provide more detailed commit message. Which APIs are being tested? What is the meaning of F30?

I would like to see your team more involved in the code reviews. Until I see this happen, I will not continue to review as I don't have the capacity to do so. We need more participation in review. As mentioned, I shouldn't be the only gate keeper to getting code merged. Please make sure your team has proper access to review and leave comments.

Please also understand that in the future these tests need to be built out more and do assertions on the response body and not just checking response codes.

I also do not believe the NotFound exceptions should be silenced.

@rickbartra91
Copy link
Contributor

Please update tests to do assertions beyond asserting the HTTP response code.

@pradeepsreenivas pradeepsreenivas changed the title Shipyard GET API Tests - F30 Shipyard GET API Tests Oct 26, 2018
@rickbartra91
Copy link
Contributor

I am not seeing the updates you made. Please squash your commits into a single commit as right now it is 4 different commits. Perhaps after squashing, I will be able to see the changes you made without having to make a new PR?

Also, I still do not see code review from your team.... This needs to change.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants