Updated with 'stable/rocky' branch.

* Updated current repo with 'stable/rocky' branch.
    * Removed 'mox' library dependency on 'heat' testcases, as 'heat' in
      'stable/rocky' branch removed mox.
    * Using 'mock.patch' instead of 'mox.StubOutWithMock()'.
    * Updated 'test-requirements.txt' w.r.t. 'stable/rocky' release.
    * Updated zuul jobs w.r.t 'stable/rocky' release.

Change-Id: I9b4c20b95d011e886a848785c3939b60ace6a688
This commit is contained in:
Shyam Singh 2020-06-04 00:40:13 +05:30
parent 9d80d08095
commit 93232e3f6f
5 changed files with 1017 additions and 524 deletions

View File

@ -3,19 +3,37 @@
templates:
- openstack-python-jobs
- publish-to-pypi
# REVISIT: In the jobs below, the required-projects clause is needed on
# the master branch to select the correct version of the requirements
# repository. Otherwise, the master version will be used. It can be
# eliminated on the stable branches, and on the master branch once this
# repository's master branch is based on the neutron repository's master
# branch.
check:
jobs:
- openstack-tox-pep8:
nodeset: ubuntu-xenial
required-projects:
- name: openstack/requirements
override-checkout: stable/rocky
- openstack-tox-py27:
nodeset: ubuntu-xenial
required-projects:
- name: openstack/requirements
override-checkout: stable/rocky
- openstack-tox-py35:
nodeset: ubuntu-xenial
required-projects:
- name: openstack/requirements
override-checkout: stable/rocky
gate:
jobs:
- openstack-tox-pep8:
nodeset: ubuntu-xenial
required-projects:
- name: openstack/requirements
override-checkout: stable/rocky
- openstack-tox-py27:
nodeset: ubuntu-xenial
required-projects:
- name: openstack/requirements
override-checkout: stable/rocky
- openstack-tox-py35:
nodeset: ubuntu-xenial
required-projects:
- name: openstack/requirements
override-checkout: stable/rocky

File diff suppressed because it is too large Load Diff

View File

@ -11,6 +11,7 @@
# under the License.
import copy
import mock
import six
from gbpautomation.heat.engine.resources import servicechain
@ -89,14 +90,29 @@ class ServiceChainNodeTest(HeatTestCase):
def setUp(self):
super(ServiceChainNodeTest, self).setUp()
self.m.StubOutWithMock(gbpclient.Client, 'create_servicechain_node')
self.m.StubOutWithMock(gbpclient.Client, 'delete_servicechain_node')
self.m.StubOutWithMock(gbpclient.Client, 'show_servicechain_node')
self.m.StubOutWithMock(gbpclient.Client, 'update_servicechain_node')
self.mock_create = mock.patch(
'gbpclient.v2_0.client.Client.create_servicechain_node')
self.mock_delete = mock.patch(
'gbpclient.v2_0.client.Client.delete_servicechain_node')
self.mock_show = mock.patch(
'gbpclient.v2_0.client.Client.show_servicechain_node')
self.mock_update = mock.patch(
'gbpclient.v2_0.client.Client.update_servicechain_node')
self.mock_create.start()
self.mock_delete.start()
self.mock_show.start()
self.mock_update.start()
self.stub_keystoneclient()
def tearDown(self):
self.mock_create.stop()
self.mock_delete.stop()
self.mock_show.stop()
self.mock_update.stop()
super(ServiceChainNodeTest, self).tearDown()
def create_servicechain_node(self):
gbpclient.Client.create_servicechain_node({
call_dict = {
'servicechain_node': {
"name": "test-sc-node",
"description": "test service chain node resource",
@ -104,7 +120,15 @@ class ServiceChainNodeTest(HeatTestCase):
"shared": True,
"config": "{'name': 'sc_node_config'}"
}
}).AndReturn({'servicechain_node': {'id': '5678'}})
}
tdict = {'servicechain_node': {'id': '5678'}}
gbpclient.Client.create_servicechain_node.return_value = tdict
ret_val = gbpclient.Client.create_servicechain_node(call_dict)
expected = mock.call(call_dict)
_mocked_create = self.mock_create.get_original()[0]
_mocked_create.assert_has_calls([expected])
self.assertEqual(tdict, ret_val)
snippet = template_format.parse(servicechain_node_template)
self.stack = utils.parse_stack(snippet)
@ -115,13 +139,11 @@ class ServiceChainNodeTest(HeatTestCase):
def test_create(self):
rsrc = self.create_servicechain_node()
self.m.ReplayAll()
scheduler.TaskRunner(rsrc.create)()
self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)
self.m.VerifyAll()
def test_create_failed(self):
gbpclient.Client.create_servicechain_node({
call_dict = {
'servicechain_node': {
"name": "test-sc-node",
"description": "test service chain node resource",
@ -129,8 +151,9 @@ class ServiceChainNodeTest(HeatTestCase):
"shared": True,
"config": "{'name': 'sc_node_config'}"
}
}).AndRaise(servicechain.NeutronClientException())
self.m.ReplayAll()
}
exc = servicechain.NeutronClientException()
gbpclient.Client.create_servicechain_node.side_effect = exc
snippet = template_format.parse(servicechain_node_template)
self.stack = utils.parse_stack(snippet)
@ -146,37 +169,42 @@ class ServiceChainNodeTest(HeatTestCase):
'An unknown exception occurred.',
six.text_type(error))
self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
self.m.VerifyAll()
expected = mock.call(call_dict)
_mocked_create = self.mock_create.get_original()[0]
_mocked_create.assert_has_calls([expected])
def test_delete(self):
gbpclient.Client.delete_servicechain_node('5678')
gbpclient.Client.show_servicechain_node('5678').AndRaise(
servicechain.NeutronClientException(status_code=404))
exc = servicechain.NeutronClientException(status_code=404)
gbpclient.Client.show_servicechain_node.side_effect = exc
rsrc = self.create_servicechain_node()
self.m.ReplayAll()
scheduler.TaskRunner(rsrc.create)()
scheduler.TaskRunner(rsrc.delete)()
self.assertEqual((rsrc.DELETE, rsrc.COMPLETE), rsrc.state)
self.m.VerifyAll()
expected = mock.call('5678')
_mocked_show = self.mock_show.get_original()[0]
_mocked_show.assert_has_calls([expected])
def test_delete_already_gone(self):
gbpclient.Client.delete_servicechain_node('5678').AndRaise(
servicechain.NeutronClientException(status_code=404))
exc = servicechain.NeutronClientException(status_code=404)
gbpclient.Client.delete_servicechain_node.side_effect = exc
rsrc = self.create_servicechain_node()
self.m.ReplayAll()
scheduler.TaskRunner(rsrc.create)()
scheduler.TaskRunner(rsrc.delete)()
self.assertEqual((rsrc.DELETE, rsrc.COMPLETE), rsrc.state)
self.m.VerifyAll()
expected = mock.call('5678')
_mocked_delete = self.mock_delete.get_original()[0]
_mocked_delete.assert_has_calls([expected])
def test_delete_failed(self):
gbpclient.Client.delete_servicechain_node('5678').AndRaise(
servicechain.NeutronClientException(status_code=400))
exc = servicechain.NeutronClientException(status_code=400)
gbpclient.Client.delete_servicechain_node.side_effect = exc
rsrc = self.create_servicechain_node()
self.m.ReplayAll()
scheduler.TaskRunner(rsrc.create)()
error = self.assertRaises(exception.ResourceFailure,
scheduler.TaskRunner(rsrc.delete))
@ -185,41 +213,67 @@ class ServiceChainNodeTest(HeatTestCase):
'An unknown exception occurred.',
six.text_type(error))
self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
self.m.VerifyAll()
expected = mock.call('5678')
_mocked_delete = self.mock_delete.get_original()[0]
_mocked_delete.assert_has_calls([expected])
def test_update(self):
rsrc = self.create_servicechain_node()
gbpclient.Client.update_servicechain_node(
'5678', {'servicechain_node': {'name': 'node_update'}})
self.m.ReplayAll()
call_dict = {'servicechain_node': {'name': 'node_update'}}
scheduler.TaskRunner(rsrc.create)()
update_template = copy.deepcopy(rsrc.t)
update_template._properties['name'] = 'node_update'
scheduler.TaskRunner(rsrc.update, update_template)()
self.m.VerifyAll()
expected = mock.call('5678', call_dict)
_mocked_update = self.mock_update.get_original()[0]
_mocked_update.assert_has_calls([expected])
class ServiceChainSpecTest(HeatTestCase):
def setUp(self):
super(ServiceChainSpecTest, self).setUp()
self.m.StubOutWithMock(gbpclient.Client, 'create_servicechain_spec')
self.m.StubOutWithMock(gbpclient.Client, 'delete_servicechain_spec')
self.m.StubOutWithMock(gbpclient.Client, 'show_servicechain_spec')
self.m.StubOutWithMock(gbpclient.Client, 'update_servicechain_spec')
self.mock_create = mock.patch(
'gbpclient.v2_0.client.Client.create_servicechain_spec')
self.mock_delete = mock.patch(
'gbpclient.v2_0.client.Client.delete_servicechain_spec')
self.mock_show = mock.patch(
'gbpclient.v2_0.client.Client.show_servicechain_spec')
self.mock_update = mock.patch(
'gbpclient.v2_0.client.Client.update_servicechain_spec')
self.mock_create.start()
self.mock_delete.start()
self.mock_show.start()
self.mock_update.start()
self.stub_keystoneclient()
def tearDown(self):
self.mock_create.stop()
self.mock_delete.stop()
self.mock_show.stop()
self.mock_update.stop()
super(ServiceChainSpecTest, self).tearDown()
def create_servicechain_spec(self):
gbpclient.Client.create_servicechain_spec({
call_dict = {
"servicechain_spec": {
"name": "test-sc-spec",
"description": "test service chain spec resource",
"shared": True,
"nodes": ["1234", "7890"]
}
}).AndReturn({'servicechain_spec': {'id': '5678'}})
}
tdict = {'servicechain_spec': {'id': '5678'}}
gbpclient.Client.create_servicechain_spec.return_value = tdict
ret_val = gbpclient.Client.create_servicechain_spec(call_dict)
expected = mock.call(call_dict)
_mocked_create = self.mock_create.get_original()[0]
_mocked_create.assert_has_calls([expected])
self.assertEqual(tdict, ret_val)
snippet = template_format.parse(servicechain_spec_template)
self.stack = utils.parse_stack(snippet)
@ -230,21 +284,20 @@ class ServiceChainSpecTest(HeatTestCase):
def test_create(self):
rsrc = self.create_servicechain_spec()
self.m.ReplayAll()
scheduler.TaskRunner(rsrc.create)()
self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)
self.m.VerifyAll()
def test_create_failed(self):
gbpclient.Client.create_servicechain_spec({
call_dict = {
'servicechain_spec': {
"name": "test-sc-spec",
"description": "test service chain spec resource",
"shared": True,
"nodes": ["1234", "7890"]
}
}).AndRaise(servicechain.NeutronClientException())
self.m.ReplayAll()
}
exc = servicechain.NeutronClientException()
gbpclient.Client.create_servicechain_spec.side_effect = exc
snippet = template_format.parse(servicechain_spec_template)
self.stack = utils.parse_stack(snippet)
@ -260,37 +313,42 @@ class ServiceChainSpecTest(HeatTestCase):
'An unknown exception occurred.',
six.text_type(error))
self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
self.m.VerifyAll()
expected = mock.call(call_dict)
_mocked_create = self.mock_create.get_original()[0]
_mocked_create.assert_has_calls([expected])
def test_delete(self):
gbpclient.Client.delete_servicechain_spec('5678')
gbpclient.Client.show_servicechain_spec('5678').AndRaise(
servicechain.NeutronClientException(status_code=404))
exc = servicechain.NeutronClientException(status_code=404)
gbpclient.Client.show_servicechain_spec.side_effect = exc
rsrc = self.create_servicechain_spec()
self.m.ReplayAll()
scheduler.TaskRunner(rsrc.create)()
scheduler.TaskRunner(rsrc.delete)()
self.assertEqual((rsrc.DELETE, rsrc.COMPLETE), rsrc.state)
self.m.VerifyAll()
expected = mock.call('5678')
_mocked_show = self.mock_show.get_original()[0]
_mocked_show.assert_has_calls([expected])
def test_delete_already_gone(self):
gbpclient.Client.delete_servicechain_spec('5678').AndRaise(
servicechain.NeutronClientException(status_code=404))
exc = servicechain.NeutronClientException(status_code=404)
gbpclient.Client.delete_servicechain_spec.side_effect = exc
rsrc = self.create_servicechain_spec()
self.m.ReplayAll()
scheduler.TaskRunner(rsrc.create)()
scheduler.TaskRunner(rsrc.delete)()
self.assertEqual((rsrc.DELETE, rsrc.COMPLETE), rsrc.state)
self.m.VerifyAll()
expected = mock.call('5678')
_mocked_delete = self.mock_delete.get_original()[0]
_mocked_delete.assert_has_calls([expected])
def test_delete_failed(self):
gbpclient.Client.delete_servicechain_spec('5678').AndRaise(
servicechain.NeutronClientException(status_code=400))
exc = servicechain.NeutronClientException(status_code=400)
gbpclient.Client.delete_servicechain_spec.side_effect = exc
rsrc = self.create_servicechain_spec()
self.m.ReplayAll()
scheduler.TaskRunner(rsrc.create)()
error = self.assertRaises(exception.ResourceFailure,
scheduler.TaskRunner(rsrc.delete))
@ -299,34 +357,52 @@ class ServiceChainSpecTest(HeatTestCase):
'An unknown exception occurred.',
six.text_type(error))
self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
self.m.VerifyAll()
expected = mock.call('5678')
_mocked_delete = self.mock_delete.get_original()[0]
_mocked_delete.assert_has_calls([expected])
def test_update(self):
rsrc = self.create_servicechain_spec()
gbpclient.Client.update_servicechain_spec(
'5678', {'servicechain_spec': {'name': 'spec_update'}})
self.m.ReplayAll()
call_dict = {'servicechain_spec': {'name': 'spec_update'}}
scheduler.TaskRunner(rsrc.create)()
update_template = copy.deepcopy(rsrc.t)
update_template._properties['name'] = 'spec_update'
scheduler.TaskRunner(rsrc.update, update_template)()
self.m.VerifyAll()
expected = mock.call('5678', call_dict)
_mocked_update = self.mock_update.get_original()[0]
_mocked_update.assert_has_calls([expected])
class ServiceProfileTest(HeatTestCase):
def setUp(self):
super(ServiceProfileTest, self).setUp()
self.m.StubOutWithMock(gbpclient.Client, 'create_service_profile')
self.m.StubOutWithMock(gbpclient.Client, 'delete_service_profile')
self.m.StubOutWithMock(gbpclient.Client, 'show_service_profile')
self.m.StubOutWithMock(gbpclient.Client, 'update_service_profile')
self.mock_create = mock.patch(
'gbpclient.v2_0.client.Client.create_service_profile')
self.mock_delete = mock.patch(
'gbpclient.v2_0.client.Client.delete_service_profile')
self.mock_show = mock.patch(
'gbpclient.v2_0.client.Client.show_service_profile')
self.mock_update = mock.patch(
'gbpclient.v2_0.client.Client.update_service_profile')
self.mock_create.start()
self.mock_delete.start()
self.mock_show.start()
self.mock_update.start()
self.stub_keystoneclient()
def tearDown(self):
self.mock_create.stop()
self.mock_delete.stop()
self.mock_show.stop()
self.mock_update.stop()
super(ServiceProfileTest, self).tearDown()
def create_service_profile(self):
gbpclient.Client.create_service_profile({
call_dict = {
'service_profile': {
"name": "test-svc-profile",
"description": "test service profile resource",
@ -336,7 +412,15 @@ class ServiceProfileTest(HeatTestCase):
"service_flavor": "test flavor",
"shared": True
}
}).AndReturn({'service_profile': {'id': '5678'}})
}
tdict = {'service_profile': {'id': '5678'}}
gbpclient.Client.create_service_profile.return_value = tdict
ret_val = gbpclient.Client.create_service_profile(call_dict)
expected = mock.call(call_dict)
_mocked_create = self.mock_create.get_original()[0]
_mocked_create.assert_has_calls([expected])
self.assertEqual(tdict, ret_val)
snippet = template_format.parse(service_profile_template)
self.stack = utils.parse_stack(snippet)
@ -346,13 +430,11 @@ class ServiceProfileTest(HeatTestCase):
def test_create(self):
rsrc = self.create_service_profile()
self.m.ReplayAll()
scheduler.TaskRunner(rsrc.create)()
self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)
self.m.VerifyAll()
def test_create_failed(self):
gbpclient.Client.create_service_profile({
call_dict = {
'service_profile': {
"name": "test-svc-profile",
"description": "test service profile resource",
@ -362,8 +444,9 @@ class ServiceProfileTest(HeatTestCase):
"service_flavor": "test flavor",
"shared": True
}
}).AndRaise(servicechain.NeutronClientException())
self.m.ReplayAll()
}
exc = servicechain.NeutronClientException()
gbpclient.Client.create_service_profile.side_effect = exc
snippet = template_format.parse(service_profile_template)
self.stack = utils.parse_stack(snippet)
@ -379,37 +462,42 @@ class ServiceProfileTest(HeatTestCase):
'An unknown exception occurred.',
six.text_type(error))
self.assertEqual((rsrc.CREATE, rsrc.FAILED), rsrc.state)
self.m.VerifyAll()
expected = mock.call(call_dict)
_mocked_create = self.mock_create.get_original()[0]
_mocked_create.assert_has_calls([expected])
def test_delete(self):
gbpclient.Client.delete_service_profile('5678')
gbpclient.Client.show_service_profile('5678').AndRaise(
servicechain.NeutronClientException(status_code=404))
exc = servicechain.NeutronClientException(status_code=404)
gbpclient.Client.show_service_profile.side_effect = exc
rsrc = self.create_service_profile()
self.m.ReplayAll()
scheduler.TaskRunner(rsrc.create)()
scheduler.TaskRunner(rsrc.delete)()
self.assertEqual((rsrc.DELETE, rsrc.COMPLETE), rsrc.state)
self.m.VerifyAll()
expected = mock.call('5678')
_mocked_show = self.mock_show.get_original()[0]
_mocked_show.assert_has_calls([expected])
def test_delete_already_gone(self):
gbpclient.Client.delete_service_profile('5678').AndRaise(
servicechain.NeutronClientException(status_code=404))
exc = servicechain.NeutronClientException(status_code=404)
gbpclient.Client.delete_service_profile.side_effect = exc
rsrc = self.create_service_profile()
self.m.ReplayAll()
scheduler.TaskRunner(rsrc.create)()
scheduler.TaskRunner(rsrc.delete)()
self.assertEqual((rsrc.DELETE, rsrc.COMPLETE), rsrc.state)
self.m.VerifyAll()
expected = mock.call('5678')
_mocked_delete = self.mock_delete.get_original()[0]
_mocked_delete.assert_has_calls([expected])
def test_delete_failed(self):
gbpclient.Client.delete_service_profile('5678').AndRaise(
servicechain.NeutronClientException(status_code=400))
exc = servicechain.NeutronClientException(status_code=400)
gbpclient.Client.delete_service_profile.side_effect = exc
rsrc = self.create_service_profile()
self.m.ReplayAll()
scheduler.TaskRunner(rsrc.create)()
error = self.assertRaises(exception.ResourceFailure,
scheduler.TaskRunner(rsrc.delete))
@ -418,17 +506,20 @@ class ServiceProfileTest(HeatTestCase):
'An unknown exception occurred.',
six.text_type(error))
self.assertEqual((rsrc.DELETE, rsrc.FAILED), rsrc.state)
self.m.VerifyAll()
expected = mock.call('5678')
_mocked_delete = self.mock_delete.get_original()[0]
_mocked_delete.assert_has_calls([expected])
def test_update(self):
rsrc = self.create_service_profile()
gbpclient.Client.update_service_profile(
'5678', {'service_profile': {'name': 'profile_update'}})
self.m.ReplayAll()
call_dict = {'service_profile': {'name': 'profile_update'}}
scheduler.TaskRunner(rsrc.create)()
update_template = copy.deepcopy(rsrc.t)
update_template._properties['name'] = 'profile_update'
scheduler.TaskRunner(rsrc.update, update_template)()
self.m.VerifyAll()
expected = mock.call('5678', call_dict)
_mocked_update = self.mock_update.get_original()[0]
_mocked_update.assert_has_calls([expected])

View File

@ -2,16 +2,15 @@
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
-e git+https://opendev.org/openstack/heat.git@stable/queens#egg=heat
-e git+https://opendev.org/openstack/heat.git@stable/rocky#egg=heat
-e git+https://opendev.org/x/python-group-based-policy-client.git@master#egg=gbpclient
# Hacking already pins down pep8, pyflakes and flake8
hacking<0.11,>=0.10.0
bandit>=1.1.0 # Apache-2.0
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
bandit<1.6.0,>=1.1.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD
kombu!=4.0.2,>=4.0.0 # BSD
mock>=2.0 # BSD
mox3>=0.20.0 # Apache-2.0
PyMySQL>=0.7.6 # MIT License
openstackdocstheme>=1.18.1 # Apache-2.0
os-api-ref>=1.4.0 # Apache-2.0

10
tox.ini
View File

@ -1,6 +1,6 @@
[tox]
envlist = py27,pep8
minversion = 1.6
envlist = py27,py35, pep8
minversion = 2.3.2
skipsdist = True
[testenv]
@ -10,8 +10,10 @@ setenv = VIRTUAL_ENV={envdir}
PYTHONHASHSEED=0
usedevelop = True
install_command = pip install {opts} {packages}
deps = -r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
deps =
-c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/rocky}
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
commands =
python setup.py testr --slowest --testr-args='^(?!functionaltests) {posargs}'