Enable python3 unit tests as part of zuul

The existing py27 unit tests were not all passing in py36,
however now they are and so the zuul check and gate for py36
have been added.

Change-Id: Ie293ec69a04e6fd657f960aa9a135c428138b4b4
Story: 2004515
Task: 39768
Signed-off-by: albailey <Al.Bailey@windriver.com>
This commit is contained in:
albailey 2020-05-13 14:00:12 -05:00
parent 46eb4e8e0e
commit d46516c46d
5 changed files with 56 additions and 12 deletions

View File

@ -9,12 +9,14 @@
- openstack-tox-linters - openstack-tox-linters
- stx-distcloud-tox-pep8 - stx-distcloud-tox-pep8
- stx-distcloud-tox-py27 - stx-distcloud-tox-py27
- stx-distcloud-tox-py36
- stx-distcloud-tox-pylint - stx-distcloud-tox-pylint
gate: gate:
jobs: jobs:
- openstack-tox-linters - openstack-tox-linters
- stx-distcloud-tox-pep8 - stx-distcloud-tox-pep8
- stx-distcloud-tox-py27 - stx-distcloud-tox-py27
- stx-distcloud-tox-py36
- stx-distcloud-tox-pylint - stx-distcloud-tox-pylint
post: post:
jobs: jobs:
@ -33,6 +35,19 @@
tox_envlist: py27 tox_envlist: py27
tox_extra_args: -c distributedcloud/tox.ini tox_extra_args: -c distributedcloud/tox.ini
- job:
name: stx-distcloud-tox-py36
parent: tox
description: Run py36 for distcloud
required-projects:
- starlingx/fault
- starlingx/nfv
- starlingx/update
- starlingx/config
vars:
tox_envlist: py36
tox_extra_args: -c distributedcloud/tox.ini
- job: - job:
name: stx-distcloud-tox-pylint name: stx-distcloud-tox-pylint
parent: tox parent: tox

View File

@ -45,7 +45,8 @@ class TestSubcloudDeploy(testroot.DCManagerApiTest):
fields = list() fields = list()
for opt in consts.DEPLOY_COMMON_FILE_OPTIONS: for opt in consts.DEPLOY_COMMON_FILE_OPTIONS:
fake_name = opt + "_fake" fake_name = opt + "_fake"
fields.append((opt, fake_name, "fake content")) fake_content = "fake content".encode('utf-8')
fields.append((opt, fake_name, fake_content))
mock_upload_files.return_value = True mock_upload_files.return_value = True
response = self.app.post(FAKE_URL, response = self.app.post(FAKE_URL,
headers=FAKE_HEADERS, headers=FAKE_HEADERS,
@ -59,7 +60,8 @@ class TestSubcloudDeploy(testroot.DCManagerApiTest):
fields = list() fields = list()
for opt in opts: for opt in opts:
fake_name = opt + "_fake" fake_name = opt + "_fake"
fields.append((opt, fake_name, "fake content")) fake_content = "fake content".encode('utf-8')
fields.append((opt, fake_name, fake_content))
mock_upload_files.return_value = True mock_upload_files.return_value = True
response = self.app.post(FAKE_URL, response = self.app.post(FAKE_URL,
headers=FAKE_HEADERS, headers=FAKE_HEADERS,
@ -72,7 +74,8 @@ class TestSubcloudDeploy(testroot.DCManagerApiTest):
def test_post_subcloud_deploy_missing_file_name(self, mock_upload_files): def test_post_subcloud_deploy_missing_file_name(self, mock_upload_files):
fields = list() fields = list()
for opt in consts.DEPLOY_COMMON_FILE_OPTIONS: for opt in consts.DEPLOY_COMMON_FILE_OPTIONS:
fields.append((opt, "", "fake content")) fake_content = "fake content".encode('utf-8')
fields.append((opt, "", fake_content))
mock_upload_files.return_value = True mock_upload_files.return_value = True
response = self.app.post(FAKE_URL, response = self.app.post(FAKE_URL,
headers=FAKE_HEADERS, headers=FAKE_HEADERS,

View File

@ -131,7 +131,8 @@ class TestSubclouds(testroot.DCManagerApiTest):
fields = list() fields = list()
for f in subclouds.SUBCLOUD_ADD_MANDATORY_FILE: for f in subclouds.SUBCLOUD_ADD_MANDATORY_FILE:
fake_name = f + "_fake" fake_name = f + "_fake"
fields.append((f, fake_name, "fake content")) fake_content = "fake content".encode('utf-8')
fields.append((f, fake_name, fake_content))
data = copy.copy(FAKE_SUBCLOUD_DATA) data = copy.copy(FAKE_SUBCLOUD_DATA)
data.update(FAKE_BOOTSTRAP_VALUE) data.update(FAKE_BOOTSTRAP_VALUE)
mock_get_request_data.return_value = data mock_get_request_data.return_value = data
@ -174,10 +175,12 @@ class TestSubclouds(testroot.DCManagerApiTest):
fields = list() fields = list()
for f in subclouds.SUBCLOUD_ADD_GET_FILE_CONTENTS: for f in subclouds.SUBCLOUD_ADD_GET_FILE_CONTENTS:
fake_name = f + "_fake" fake_name = f + "_fake"
fields.append((f, fake_name, "fake content")) fake_content = "fake content".encode('utf-8')
fields.append((f, fake_name, fake_content))
params = copy.copy(FAKE_BOOTSTRAP_VALUE) params = copy.copy(FAKE_BOOTSTRAP_VALUE)
params.update({'bmc_password': params.update(
base64.b64encode('bmc_password'.encode("utf-8"))}) {'bmc_password':
base64.b64encode('bmc_password'.encode("utf-8")).decode('utf-8')})
data.update(params) data.update(params)
mock_get_request_data.return_value = data mock_get_request_data.return_value = data
mock_upload_deploy_config_file.return_value = True mock_upload_deploy_config_file.return_value = True

View File

@ -163,9 +163,6 @@ class TestSubcloudManager(base.DCManagerTestCase):
self.assertEqual('localhost', sm.host) self.assertEqual('localhost', sm.host)
self.assertEqual(self.ctx, sm.context) self.assertEqual(self.ctx, sm.context)
def exception_dcorch_rpc(self):
raise FakeException
@mock.patch.object(subcloud_manager.SubcloudManager, @mock.patch.object(subcloud_manager.SubcloudManager,
'_create_intermediate_ca_cert') '_create_intermediate_ca_cert')
@mock.patch.object(subcloud_manager.SubcloudManager, @mock.patch.object(subcloud_manager.SubcloudManager,
@ -194,6 +191,10 @@ class TestSubcloudManager(base.DCManagerTestCase):
controllers = FAKE_CONTROLLERS controllers = FAKE_CONTROLLERS
services = FAKE_SERVICES services = FAKE_SERVICES
# dcmanager add_subcloud queries the data from the db
fake_subcloud = Subcloud(values, False)
mock_db_api.subcloud_get_by_name.return_value = fake_subcloud
mock_sysinv_client().get_controller_hosts.return_value = controllers mock_sysinv_client().get_controller_hosts.return_value = controllers
mock_keystone_client().services_list = services mock_keystone_client().services_list = services
mock_keyring.get_password.return_value = "testpassword" mock_keyring.get_password.return_value = "testpassword"
@ -221,8 +222,11 @@ class TestSubcloudManager(base.DCManagerTestCase):
controllers = FAKE_CONTROLLERS controllers = FAKE_CONTROLLERS
services = FAKE_SERVICES services = FAKE_SERVICES
self.fake_dcorch_api.add_subcloud.\ # dcmanager add_subcloud queries the data from the db
side_effect = self.exception_dcorch_rpc fake_subcloud = Subcloud(values, False)
mock_db_api.subcloud_get_by_name.return_value = fake_subcloud
self.fake_dcorch_api.add_subcloud.side_effect = FakeException('boom')
mock_sysinv_client().get_controller_hosts.return_value = controllers mock_sysinv_client().get_controller_hosts.return_value = controllers
mock_keystone_client().services_list = services mock_keystone_client().services_list = services

View File

@ -55,6 +55,25 @@ commands =
find {toxinidir} -not -path '{toxinidir}/.tox/*' -name '*.py[c|o]' -delete find {toxinidir} -not -path '{toxinidir}/.tox/*' -name '*.py[c|o]' -delete
python setup.py testr --slowest --testr-args='{posargs}' python setup.py testr --slowest --testr-args='{posargs}'
[testenv:py36]
basepython = python3.6
deps = -r{toxinidir}/test-requirements.txt
-r{toxinidir}/requirements.txt
keyring
-e{[dc]nfv_client_src_dir}
-e{[dc]sysinv_src_dir}
-e{[dc]tsconfig_src_dir}
-e{[dc]fmclient_src_dir}
-e{[dc]fm_api_src_dir}
-e{[dc]cgtsclient_src_dir}
setenv =
CURRENT_CFG_FILE={toxinidir}/.current.cfg
SINGLE_REPO=True
OSLO_LOCK_PATH={toxinidir}
commands =
find {toxinidir} -not -path '{toxinidir}/.tox/*' -name '*.py[c|o]' -delete
python setup.py testr --slowest --testr-args='{posargs}'
[testenv:debug-py27] [testenv:debug-py27]
basepython = python2.7 basepython = python2.7
commands = oslo_debug_helper {posargs} commands = oslo_debug_helper {posargs}