-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add tests for Policy-Management and BGPVPN. #14
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
20c15d5
Add tests for Policy-Management and BGPVPN.
Goutham-Pratapa 4f92d29
Update test_policy_management.py
Goutham-Pratapa d356758
Add tests for Tag_Type and Service_objects.
5d68d02
Add tests for Tag_Type and Service_objects.
966a2f2
Merge branch 'master' of https://github.com/Goutham-Pratapa/tungsten-…
Goutham-Pratapa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
101 changes: 101 additions & 0 deletions
101
tungsten_tempest_plugin/tests/api/contrail/test_bgpvpn.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
"""Tempest Suite for Contrail BGP_VPN.""" | ||
# Copyright 2018 AT&T Intellectual Property. | ||
# All other 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 patrole_tempest_plugin import rbac_rule_validation | ||
from tempest import config | ||
from tempest.lib.common.utils import data_utils | ||
from tempest.lib import decorators | ||
|
||
from tungsten_tempest_plugin.tests.api.contrail import rbac_base | ||
|
||
CONF = config.CONF | ||
|
||
|
||
class BgpvpnTest(rbac_base.BaseContrailTest): | ||
"""Test suite for validating RBAC functionality of 'bgpvpn' API.""" | ||
|
||
@classmethod | ||
def skip_checks(cls): | ||
super(BgpvpnTest, cls).skip_checks() | ||
if float(CONF.sdn.contrail_version) < 4: | ||
msg = "bgpvpn requires Contrail >= 4" | ||
raise cls.skipException(msg) | ||
|
||
@classmethod | ||
def resource_setup(cls): | ||
"""Create Bgpvpn to use across the Suite.""" | ||
super(BgpvpnTest, cls).resource_setup() | ||
cls.bgpvpn_uuid = cls._create_bgpvpn() | ||
|
||
@classmethod | ||
def _create_bgpvpn(cls): | ||
"""Create Bgpvpn.""" | ||
bgpvpn_name = data_utils.rand_name('test-bgpvpn') | ||
bgpvpn_fq_name = ['default-domain', cls.tenant_name, bgpvpn_name] | ||
resp_body = cls.contrail_client.create_bgpvpn( | ||
parent_type='project', | ||
fq_name=bgpvpn_fq_name) | ||
bgpvpn_uuid = resp_body['bgpvpn']['uuid'] | ||
cls.addClassResourceCleanup( | ||
cls._try_delete_resource, | ||
cls.contrail_client.delete_bgpvpn, | ||
bgpvpn_uuid) | ||
return bgpvpn_uuid | ||
|
||
@rbac_rule_validation.action(service="Contrail", | ||
rules=["list_bgpvpns"]) | ||
@decorators.idempotent_id('65afb5d5-52cb-484c-9e8e-42509be7dd77') | ||
def test_list_bgpvpns(self): | ||
"""Test whether current role can list of bgpvpns.""" | ||
with self.rbac_utils.override_role(self): | ||
self.contrail_client.list_bgpvpns() | ||
|
||
@rbac_rule_validation.action(service="Contrail", | ||
rules=["create_bgpvpns"]) | ||
@decorators.idempotent_id('c3a7510c-c8d6-4736-9962-5c1aa032bf79') | ||
def test_create_bgpvpns(self): | ||
"""Test whether current role can create bgpvpn.""" | ||
with self.rbac_utils.override_role(self): | ||
self._create_bgpvpn() | ||
|
||
@rbac_rule_validation.action(service="Contrail", | ||
rules=["show_bgpvpn"]) | ||
@decorators.idempotent_id('2fd05ca2-97d8-477c-aead-a881a2ba5e7e') | ||
def test_show_bgpvpn(self): | ||
"""Test whether current role can get bgpvpn details.""" | ||
with self.rbac_utils.override_role(self): | ||
self.contrail_client.show_bgpvpn( | ||
self.bgpvpn_uuid) | ||
|
||
@rbac_rule_validation.action(service="Contrail", | ||
rules=["delete_bgpvpn"]) | ||
@decorators.idempotent_id('919aa2bb-1556-4dcf-bbef-0a31f9c6464b') | ||
def test_delete_bgpvpn(self): | ||
"""Test whether current role can delete bgpvpn details.""" | ||
new_bgpvpn_uuid = self._create_bgpvpn() | ||
with self.rbac_utils.override_role(self): | ||
self.contrail_client.delete_bgpvpn( | ||
new_bgpvpn_uuid) | ||
|
||
@rbac_rule_validation.action(service="Contrail", | ||
rules=["update_bgpvpn"]) | ||
@decorators.idempotent_id('ae734791-eaeb-4ca9-908a-59d0eac1a3c0') | ||
def test_update_bgpvpn(self): | ||
"""Test whether current role can update bgpvpn.""" | ||
with self.rbac_utils.override_role(self): | ||
self.contrail_client.update_bgpvpn( | ||
self.bgpvpn_uuid, | ||
display_name=data_utils.rand_name('test-bgpvpn')) |
121 changes: 121 additions & 0 deletions
121
tungsten_tempest_plugin/tests/api/contrail/test_policy_management.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
"""Tempest Suite for Policy Management of Contrail.""" | ||
# 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 patrole_tempest_plugin import rbac_rule_validation | ||
from tempest import config | ||
from tempest.lib.common.utils import data_utils | ||
from tempest.lib import decorators | ||
|
||
from tungsten_tempest_plugin.tests.api.contrail import rbac_base | ||
|
||
CONF = config.CONF | ||
|
||
|
||
class PolicyManagementTest(rbac_base.BaseContrailTest): | ||
"""Class to test the Policy Management of Contrail.""" | ||
|
||
@classmethod | ||
def skip_checks(cls): | ||
"""Skip the Suite if the Contrail version is less than five.""" | ||
super(PolicyManagementTest, cls).skip_checks() | ||
if float(CONF.sdn.contrail_version) < 5: | ||
msg = "policy_management requires Contrail >= 5" | ||
raise cls.skipException(msg) | ||
|
||
@classmethod | ||
def resource_setup(cls): | ||
"""Create Policy Management to use across the Suite.""" | ||
super(PolicyManagementTest, cls).resource_setup() | ||
cls.policy_management_uuid = cls._create_policy_management() | ||
|
||
@classmethod | ||
def _create_policy_management(cls): | ||
"""Create a Policy Management.""" | ||
fq_name = data_utils.rand_name('policy-management') | ||
post_body = { | ||
'parent_type': 'project', | ||
'fq_name': ["default-domain", cls.tenant_name, fq_name] | ||
} | ||
resp_body = cls.contrail_client.create_policy_management( | ||
**post_body) | ||
policy_management_uuid = resp_body['policy-management']['uuid'] | ||
cls.addClassResourceCleanup( | ||
cls._try_delete_resource, | ||
cls.contrail_client.delete_policy_management, | ||
policy_management_uuid) | ||
return policy_management_uuid | ||
|
||
@rbac_rule_validation.action(service="Contrail", | ||
rules=["create_policy_management"]) | ||
@decorators.idempotent_id('8fc56caa-fe8c-487f-8da6-579ae56dc831') | ||
def test_create_policy_management(self): | ||
"""Create policy_management. | ||
|
||
RBAC test for the Contrail create_policy_management policy | ||
""" | ||
with self.rbac_utils.override_role(self): | ||
self._create_policy_management() | ||
|
||
@rbac_rule_validation.action(service="Contrail", | ||
rules=["list_policy_management"]) | ||
@decorators.idempotent_id('5bfb007b-70d3-48f2-91ce-dc2ff471fe34') | ||
def test_list_policy_managements(self): | ||
"""List policy_managements. | ||
|
||
RBAC test for the Contrail list_policy_managements policy | ||
""" | ||
with self.rbac_utils.override_role(self): | ||
self.contrail_client.list_policy_managements() | ||
|
||
@rbac_rule_validation.action(service="Contrail", | ||
rules=["show_policy_management"]) | ||
@decorators.idempotent_id('a62737ec-dae9-4c26-8474-c4352c578607') | ||
def test_show_policy_management(self): | ||
"""Show policy_management. | ||
|
||
RBAC test for the Contrail show_policy_management policy | ||
""" | ||
with self.rbac_utils.override_role(self): | ||
self.contrail_client.\ | ||
show_policy_management(self.policy_management_uuid) | ||
|
||
@rbac_rule_validation.action(service="Contrail", | ||
rules=["delete_policy_management"]) | ||
@decorators.idempotent_id('1a3515ce-ce89-42e0-a4aa-a6c80eed4a7e') | ||
def test_delete_policy_management(self): | ||
"""Delete policy_management. | ||
|
||
RBAC test for the Contrail delete_policy_management policy | ||
""" | ||
obj_uuid = self._create_policy_management() | ||
with self.rbac_utils.override_role(self): | ||
self.contrail_client.\ | ||
delete_policy_management(obj_uuid) | ||
|
||
@rbac_rule_validation.action(service="Contrail", | ||
rules=["update_policy_management"]) | ||
@decorators.idempotent_id('833de029-cd09-4929-a40e-ddf521381474') | ||
def test_update_policy_management(self): | ||
"""Update policy_management. | ||
|
||
RBAC test for the Contrail update_policy_management policy | ||
""" | ||
put_body = { | ||
'display_name': data_utils.rand_name( | ||
'update_policy_management')} | ||
with self.rbac_utils.override_role(self): | ||
self.contrail_client.update_policy_management( | ||
self.policy_management_uuid, **put_body) |
116 changes: 116 additions & 0 deletions
116
tungsten_tempest_plugin/tests/api/contrail/test_service_object.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
"""Tempest Suite for Contrail Service Objects.""" | ||
# 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 patrole_tempest_plugin import rbac_rule_validation | ||
from tempest import config | ||
from tempest.lib.common.utils import data_utils | ||
from tempest.lib import decorators | ||
|
||
from tungsten_tempest_plugin.tests.api.contrail import rbac_base | ||
|
||
CONF = config.CONF | ||
|
||
|
||
class ServiceObjectContrailTest(rbac_base.BaseContrailTest): | ||
"""Class to test the Service objects of Contrail.""" | ||
|
||
@classmethod | ||
def skip_checks(cls): | ||
"""Skip the suite if the Contrail version is less than 4.1.""" | ||
super(ServiceObjectContrailTest, cls).skip_checks() | ||
if float(CONF.sdn.contrail_version) < 4.1: | ||
msg = "service_object requires Contrail >= 4.1" | ||
raise cls.skipException(msg) | ||
|
||
@classmethod | ||
def resource_setup(cls): | ||
"""Create Service object to use it across the suite.""" | ||
super(ServiceObjectContrailTest, cls).resource_setup() | ||
cls.service_object_uuid = cls._create_service_object() | ||
|
||
@classmethod | ||
def _create_service_object(cls): | ||
"""Create service object.""" | ||
display_name = data_utils.rand_name('service_object') | ||
post_body = {'display_name': display_name} | ||
post_body['fq_name'] = [display_name] | ||
resp_body = cls.contrail_client.create_service_object(**post_body) | ||
service_object_uuid = resp_body['service-object']['uuid'] | ||
cls.addClassResourceCleanup( | ||
cls._try_delete_resource, | ||
cls.contrail_client.delete_service_object, | ||
service_object_uuid) | ||
return service_object_uuid | ||
|
||
@rbac_rule_validation.action(service="Contrail", | ||
rules=["list_service_objects"]) | ||
@decorators.idempotent_id('05458fa1-ba09-4772-91aa-ca06243b5f5e') | ||
def test_list_service_objects(self): | ||
"""List service_objects. | ||
|
||
RBAC test for the Contrail list_service_objects policy | ||
""" | ||
with self.rbac_utils.override_role(self): | ||
self.contrail_client.list_service_objects() | ||
|
||
@rbac_rule_validation.action(service="Contrail", | ||
rules=["create_service_object"]) | ||
@decorators.idempotent_id('8be0e381-3abb-4256-858d-5930db4ceafb') | ||
def test_create_service_object(self): | ||
"""Create service_object. | ||
|
||
RBAC test for the Contrail create_service_object policy | ||
""" | ||
with self.rbac_utils.override_role(self): | ||
self._create_service_object() | ||
|
||
@rbac_rule_validation.action(service="Contrail", | ||
rules=["show_service_object"]) | ||
@decorators.idempotent_id('bb570ddd-c5fa-4691-899e-00a64568f736') | ||
def test_show_service_object(self): | ||
"""Show service_object. | ||
|
||
RBAC test for the Contrail show_service_object policy | ||
""" | ||
with self.rbac_utils.override_role(self): | ||
self.contrail_client.show_service_object(self.service_object_uuid) | ||
|
||
@rbac_rule_validation.action(service="Contrail", | ||
rules=["delete_service_object"]) | ||
@decorators.idempotent_id('15a4d6dc-f16b-11e8-8e54-080027758b73') | ||
def test_delete_service_object(self): | ||
"""Delete service_object. | ||
|
||
RBAC test for the Contrail delete_service_object policy | ||
""" | ||
obj_uuid = self._create_service_object() | ||
with self.rbac_utils.override_role(self): | ||
self.contrail_client.delete_service_object(obj_uuid) | ||
|
||
@rbac_rule_validation.action(service="Contrail", | ||
rules=["update_service_object"]) | ||
@decorators.idempotent_id('a6eaee65-9ead-4df5-9aa0-5329ee9a26f2') | ||
def test_update_service_object(self): | ||
"""Update service_object. | ||
|
||
RBAC test for the Contrail update_service_object policy | ||
""" | ||
put_body = { | ||
'display_name': data_utils.rand_name( | ||
'update_service_object')} | ||
with self.rbac_utils.override_role(self): | ||
self.contrail_client.update_service_object( | ||
self.service_object_uuid, **put_body) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
You use
@decorators.idempotent_id
here, but you importsfrom tempest.lib.decorators import idempotent_id
on L20.So there is not
decorators
module in the current scope.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.
Yea i have updated it thanks :)