-
Notifications
You must be signed in to change notification settings - Fork 3
Shipyard GET API Tests #3
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
"airship_tempest_plugin/tests/scenario" in filename): | ||
|
||
if RULE_VALIDATION_DECORATOR.match(physical_line): | ||
|
@@ -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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
@@ -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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
@@ -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: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, Will be modified accordingly. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 "self.client" in logical_line or "cls.client" in logical_line: | ||
return 0, "Do not use 'self.client' as a service client alias" | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,10 +30,16 @@ 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) | ||
self.expected_success(200, resp.status) | ||
body = json.loads(body) | ||
return rest_client.ResponseBody(resp, body) | ||
if isinstance(body, list): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Modified accordingly as it's returning a specific workflow |
||
return rest_client.ResponseBodyList(resp, body) | ||
else: | ||
return rest_client.ResponseBody(resp, body) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
|
||
from tempest.lib.common import rest_client | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is the extra line needed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extra line is removed. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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` | ||
|
@@ -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): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this needing when doing a get on a specific artifact/resource? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
@@ -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): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this needing when doing a get on a specific artifact/resource? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this needing when doing a get on a specific artifact/resource? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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}) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# 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') |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
# 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. | ||
# | ||
|
||
import logging | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not used There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Used "logging.getLogger()" instead of "print()" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not seeing your updates... |
||
|
||
from airship_tempest_plugin.tests.api.shipyard import base | ||
|
||
from tempest import config | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not used There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not used There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed |
||
LOG = logging.getLogger(__name__) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not used There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed |
||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: DocumentStagingTests |
||
class DocumentStagingTest(base.BaseShipyardTest): | ||
def _get_collection_id(self): | ||
resp = self.shipyard_document_staging_client.get_configdocs_status() | ||
self.assertTrue(len(resp[0]) > 0, | ||
'No configdocs available, nothing to test') | ||
return resp[0]['collection_name'] | ||
|
||
@decorators.idempotent_id('db351ee5-a608-4492-b705-6e6c654a60e7') | ||
def test_get_collection_list(self): | ||
"""Config docs status, Successful with response status 200""" | ||
response = self.shipyard_document_staging_client.\ | ||
get_configdocs_status() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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') | ||
|
||
@decorators.idempotent_id('743ab304-be35-4e45-ad47-e124dce3b9dc') | ||
def test_get_collection(self): | ||
"""Get Config docs, Successful with response status 200 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated accordingly |
||
In case document does not found, return 404 Not Found | ||
""" | ||
collection_id = self._get_collection_id() | ||
try: | ||
response = self.shipyard_document_staging_client.\ | ||
get_configdocs(collection_id) | ||
self.assertEqual(response.response['status'], '200') | ||
except exceptions.NotFound: | ||
print("The Shipyard buffer does not contain this collection") | ||
pass | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't use print ... Under what scenario does: There was a problem hiding this comment. Choose a reason for hiding this commentThe 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". |
||
|
||
@decorators.idempotent_id('bd138747-582e-4c2e-9f26-09c3fccad96f') | ||
def test_get_collection_version_buffer(self): | ||
"""Get Config docs of buffer version, | ||
Successful with response status 200 | ||
In case document does not found, return 404 Not Found | ||
""" | ||
collection_id = self._get_collection_id() | ||
try: | ||
response = self.shipyard_document_staging_client.\ | ||
get_configdocs_version(collection_id, "buffer") | ||
self.assertEqual(response.response['status'], '200') | ||
except exceptions.NotFound: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment as above regarding the NotFound exception There was a problem hiding this comment. Choose a reason for hiding this commentThe 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". |
||
print("The Shipyard buffer does not contain this collection") | ||
pass | ||
|
||
@decorators.idempotent_id('d42c691a-07a2-41cc-91a6-9d02be8f2649') | ||
def test_get_collection_version_committed(self): | ||
"""Get Config docs of committed version, | ||
Successful with response status 200 | ||
""" | ||
collection_id = self._get_collection_id() | ||
response = self.shipyard_document_staging_client.\ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
get_configdocs_version(collection_id, "committed") | ||
self.assertEqual(response.response['status'], '200') | ||
|
||
@decorators.idempotent_id('2940492a-47b0-4218-859a-b9cb556f480b') | ||
def test_get_collection_version_successful_site_action(self): | ||
"""Get Config docs of successful_site_action version, | ||
Successful with response status 200 | ||
""" | ||
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') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
|
||
@decorators.idempotent_id('f6b86b85-5797-4664-95a9-0b6d242b50b7') | ||
def test_get_collection_version_last_site_action(self): | ||
"""Get Config docs of last_site_action, | ||
Successful with response status 200 | ||
""" | ||
collection_id = self._get_collection_id() | ||
response = self.shipyard_document_staging_client.\ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
get_configdocs_version(collection_id, "last_site_action") | ||
self.assertEqual(response.response['status'], '200') | ||
|
||
@decorators.idempotent_id('2db31479-8d1f-4d95-a3a0-31b1bf726f39') | ||
def test_get_renderedconfigdocs(self): | ||
"""Get RenderedConfig docs, Successful with response status 200 | ||
In case document does not found, return 404 Not Found | ||
""" | ||
try: | ||
response = self.shipyard_document_staging_client.\ | ||
get_renderedconfigdocs() | ||
self.assertEqual(response.response['status'], '200') | ||
except exceptions.NotFound: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
print("buffer version does not exist") | ||
pass | ||
|
||
@decorators.idempotent_id('ffd9d1d9-9846-4493-9f9e-e35f12ce56da') | ||
def test_get_renderedconfigdocs_version_buffer(self): | ||
"""Get RenderedConfig docs of buffer version, | ||
Successful with response status 200 | ||
In case document does not found, return 404 Not Found | ||
""" | ||
try: | ||
response = self.shipyard_document_staging_client.\ | ||
get_renderedconfigdocs_version("buffer") | ||
self.assertEqual(response.response['status'], '200') | ||
except exceptions.NotFound: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment as above There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
print("buffer version does not exist") | ||
pass | ||
|
||
@decorators.idempotent_id('353e9955-7f12-4561-a3c2-c9819f259775') | ||
def test_get_renderedconfigdocs_version_committed(self): | ||
"""Get RenderedConfig docs of committed version, | ||
Successful with response status 200 | ||
""" | ||
response = self.shipyard_document_staging_client.\ | ||
get_renderedconfigdocs_version("committed") | ||
self.assertEqual(response.response['status'], '200') | ||
|
||
@decorators.idempotent_id('3daac942-baec-4078-a632-71b66dca1e91') | ||
def test_get_renderedconfigdocs_version_successful_site_action(self): | ||
"""Get RenderedConfig docs of successful_site_action version, | ||
Successful with response status 200 | ||
In case document does not found, return 404 Not Found | ||
""" | ||
try: | ||
response = self.shipyard_document_staging_client.\ | ||
get_renderedconfigdocs_version("successful_site_action") | ||
self.assertEqual(response.response['status'], '200') | ||
except exceptions.NotFound: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comments as above There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
print("This revision does not exist") | ||
pass | ||
|
||
@decorators.idempotent_id('9af56232-eacf-4baa-85e9-cbb93772974d') | ||
def test_get_renderedconfigdocs_version_last_site_action(self): | ||
"""Get RenderedConfig docs of last_site_action, | ||
Successful with response status 200 | ||
""" | ||
response = self.shipyard_document_staging_client.\ | ||
get_renderedconfigdocs_version("last_site_action") | ||
self.assertEqual(response.response['status'], '200') |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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