diff options
author | Cédric Ollivier <cedric.ollivier@orange.com> | 2018-06-14 21:20:59 +0200 |
---|---|---|
committer | Cédric Ollivier <cedric.ollivier@orange.com> | 2018-06-14 21:46:14 +0200 |
commit | 7f2d7515e068c2ba072d4f3b4cf0997e06ae8460 (patch) | |
tree | a067dcdd08c3e11a1e820ccb0f9fdef866e70e69 | |
parent | 09d6e6feef33fa47bca440a096894b851b1ebca5 (diff) |
Support py3 in uncovered packages
It has to be noted that cloudify_rest_client doesn't support py3 then
next unit tests vs cloudify-based testcases would be excluded.
Change-Id: I0b0e64929d1238665c778ce51fd6abd5ccf06b6c
Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
-rw-r--r-- | functest/api/resources/v1/testcases.py | 4 | ||||
-rw-r--r-- | functest/api/server.py | 5 | ||||
-rw-r--r-- | functest/opnfv_tests/vnf/epc/juju_epc.py | 17 | ||||
-rw-r--r-- | functest/opnfv_tests/vnf/ims/cloudify_ims.py | 10 | ||||
-rw-r--r-- | functest/opnfv_tests/vnf/ims/cloudify_ims_perf.py | 2 | ||||
-rw-r--r-- | functest/opnfv_tests/vnf/ims/ixia/utils/IxChassisUtils.py | 14 | ||||
-rw-r--r-- | functest/opnfv_tests/vnf/ims/ixia/utils/IxLoadUtils.py | 6 | ||||
-rw-r--r-- | functest/opnfv_tests/vnf/ims/ixia/utils/IxRestUtils.py | 7 | ||||
-rw-r--r-- | functest/opnfv_tests/vnf/router/cloudify_vrouter.py | 5 | ||||
-rw-r--r-- | tox.ini | 5 |
10 files changed, 42 insertions, 33 deletions
diff --git a/functest/api/resources/v1/testcases.py b/functest/api/resources/v1/testcases.py index 43340625b..65c055c40 100644 --- a/functest/api/resources/v1/testcases.py +++ b/functest/api/resources/v1/testcases.py @@ -11,7 +11,6 @@ Resources to handle testcase related requests """ -import ConfigParser import logging import os import re @@ -21,6 +20,7 @@ import uuid from flask import jsonify from flasgger.utils import swag_from import pkg_resources +from six.moves import configparser from functest.api.base import ApiResource from functest.api.common import api_utils, thread @@ -144,7 +144,7 @@ class V1Testcase(ApiResource): def _update_logging_ini(self, task_id): # pylint: disable=no-self-use """ Update the log file for each task""" - rconfig = ConfigParser.RawConfigParser() + rconfig = configparser.RawConfigParser() rconfig.read( pkg_resources.resource_filename('xtesting', 'ci/logging.ini')) log_path = os.path.join(getattr(config.CONF, 'dir_results'), diff --git a/functest/api/server.py b/functest/api/server.py index 2a6b228ff..b27929a3e 100644 --- a/functest/api/server.py +++ b/functest/api/server.py @@ -15,12 +15,12 @@ Used to launch Functest RestApi import inspect import logging import socket -from urlparse import urljoin import pkg_resources from flask import Flask from flask_restful import Api from flasgger import Swagger +import six from functest.api.base import ApiResource from functest.api.common import api_utils @@ -57,7 +57,8 @@ def get_resource(resource_name): def get_endpoint(url): """ Obtain the endpoint of url """ address = socket.gethostbyname(socket.gethostname()) - return urljoin('http://{}:5000'.format(address), url) + return six.moves.urllib.parse.urljoin( + 'http://{}:5000'.format(address), url) def api_add_resource(): diff --git a/functest/opnfv_tests/vnf/epc/juju_epc.py b/functest/opnfv_tests/vnf/epc/juju_epc.py index 224d71114..54eeeac8a 100644 --- a/functest/opnfv_tests/vnf/epc/juju_epc.py +++ b/functest/opnfv_tests/vnf/epc/juju_epc.py @@ -18,15 +18,10 @@ import subprocess import sys import uuid from copy import deepcopy -from urlparse import urljoin import pkg_resources import yaml -from functest.core import vnf -from functest.opnfv_tests.openstack.snaps import snaps_utils -from functest.utils import config -from functest.utils import env - +import six from snaps.config.flavor import FlavorConfig from snaps.config.image import ImageConfig from snaps.config.network import NetworkConfig, SubnetConfig @@ -43,6 +38,11 @@ from snaps.openstack.create_user import OpenStackUser from snaps.openstack.utils import keystone_utils from snaps.openstack.utils import nova_utils +from functest.core import vnf +from functest.opnfv_tests.openstack.snaps import snaps_utils +from functest.utils import config +from functest.utils import env + __author__ = "Amarendra Meher <amarendra@rebaca.com>" __author__ = "Soumaya K Nayek <soumaya.nayek@rebaca.com>" @@ -227,7 +227,8 @@ class JujuEpc(vnf.VnfOnBoarding): # it enforces a versioned public identity endpoint as juju simply # adds /auth/tokens wich fails vs an unversioned endpoint. if not self.public_auth_url.endswith(('v3', 'v3/', 'v2.0', 'v2.0/')): - self.public_auth_url = urljoin(self.public_auth_url, 'v3') + self.public_auth_url = six.moves.urllib.parse.urljoin( + self.public_auth_url, 'v3') self._register_cloud() if self.snaps_creds.identity_api_version == 3: self._register_credentials_v3() @@ -286,7 +287,7 @@ class JujuEpc(vnf.VnfOnBoarding): self.__logger.info("Upload some OS images if it doesn't exist") images = get_config("tenant_images", self.config_file) self.__logger.info("Images needed for vEPC: %s", images) - for image_name, image_file in images.iteritems(): + for image_name, image_file in six.iteritems(images): self.__logger.info("image: %s, file: %s", image_name, image_file) if image_file and image_name: image_creator = OpenStackImage(self.snaps_creds, ImageConfig( diff --git a/functest/opnfv_tests/vnf/ims/cloudify_ims.py b/functest/opnfv_tests/vnf/ims/cloudify_ims.py index bc4242235..71aaa3008 100644 --- a/functest/opnfv_tests/vnf/ims/cloudify_ims.py +++ b/functest/opnfv_tests/vnf/ims/cloudify_ims.py @@ -19,8 +19,7 @@ import uuid from cloudify_rest_client import CloudifyClient from cloudify_rest_client.executions import Execution from scp import SCPClient -import yaml - +import six from snaps.config.flavor import FlavorConfig from snaps.config.image import ImageConfig from snaps.config.keypair import KeypairConfig @@ -40,9 +39,10 @@ from snaps.openstack.create_security_group import OpenStackSecurityGroup from snaps.openstack.create_user import OpenStackUser from snaps.openstack.utils import keystone_utils from xtesting.energy import energy +import yaml from functest.opnfv_tests.openstack.snaps import snaps_utils -import functest.opnfv_tests.vnf.ims.clearwater_ims_base as clearwater_ims_base +from functest.opnfv_tests.vnf.ims import clearwater_ims_base from functest.utils import config from functest.utils import env @@ -165,7 +165,7 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase): # needs some images self.__logger.info("Upload some OS images if it doesn't exist") - for image_name, image_file in self.images.iteritems(): + for image_name, image_file in six.iteritems(self.images): self.__logger.info("image: %s, file: %s", image_name, image_file) if image_file and image_name: image_creator = OpenStackImage( @@ -274,7 +274,7 @@ class CloudifyIms(clearwater_ims_base.ClearwaterOnBoardingBase): raise Exception("Cloudify Manager isn't up and running") self.__logger.info("Put OpenStack creds in manager") secrets_list = cfy_client.secrets.list() - for k, val in cfy_creds.iteritems(): + for k, val in six.iteritems(cfy_creds): if not any(d.get('key', None) == k for d in secrets_list): cfy_client.secrets.create(k, val) else: diff --git a/functest/opnfv_tests/vnf/ims/cloudify_ims_perf.py b/functest/opnfv_tests/vnf/ims/cloudify_ims_perf.py index 37148c918..376138bb9 100644 --- a/functest/opnfv_tests/vnf/ims/cloudify_ims_perf.py +++ b/functest/opnfv_tests/vnf/ims/cloudify_ims_perf.py @@ -358,7 +358,7 @@ class CloudifyImsPerf(cloudify_ims.CloudifyIms): i = 0 for rdata in result: i = i + 1 - print rdata.address + print(rdata.address) iplistims += str(rdata.address) if i != len(result): iplistims += ';' diff --git a/functest/opnfv_tests/vnf/ims/ixia/utils/IxChassisUtils.py b/functest/opnfv_tests/vnf/ims/ixia/utils/IxChassisUtils.py index 973e0264d..301a0c7bc 100644 --- a/functest/opnfv_tests/vnf/ims/ixia/utils/IxChassisUtils.py +++ b/functest/opnfv_tests/vnf/ims/ixia/utils/IxChassisUtils.py @@ -55,7 +55,7 @@ class ChassisRestAPI: headers=urlHeadersJson) logger.debug(response) logger.debug(content) - except Exception, e: + except Exception as e: raise Exception('Got an error code: ', e) return content @@ -74,7 +74,7 @@ class ChassisRestAPI: (response, content) = h.request(loginUrl, 'POST', body=payload, headers=urlHeadersJson) - except Exception, e: + except Exception as e: raise Exception('Got an error code: ', e) return content @@ -95,7 +95,7 @@ class ChassisRestAPI: (response, content) = h.request(url, 'POST', json.dumps(payload), headers=urlHeadersJson) - except Exception, e: + except Exception as e: raise Exception('Got an error code: ', e) return content @@ -111,9 +111,9 @@ class ChassisRestAPI: (response, content) = h.request(url, 'PATCH', json.dumps(payload), urlHeadersJson) - except Exception, e: + except Exception as e: - # print (response, content) + # print((response, content)) raise Exception('Got an error code: ', e) return content @@ -127,7 +127,7 @@ class ChassisRestAPI: disable_ssl_certificate_validation=True) (response, content) = h.request(url, 'DELETE', '', urlHeadersJson) logger.debug('DELETE: ' + url) - except Exception, e: + except Exception as e: raise Exception('Got an error code: ', e) if response.status not in okStates: raise TestFailedError(json.loads(content)['error']) @@ -142,7 +142,7 @@ class ChassisRestAPI: disable_ssl_certificate_validation=True) logger.debug('GET: ' + url) (response, content) = h.request(url, 'GET', '', urlHeadersJson) - except Exception, e: + except Exception as e: raise Exception('Got an error code: ', e) if response.status not in okStates: raise TestFailedError(json.loads(content)['error']) diff --git a/functest/opnfv_tests/vnf/ims/ixia/utils/IxLoadUtils.py b/functest/opnfv_tests/vnf/ims/ixia/utils/IxLoadUtils.py index bc71a38cf..93da2018c 100644 --- a/functest/opnfv_tests/vnf/ims/ixia/utils/IxLoadUtils.py +++ b/functest/opnfv_tests/vnf/ims/ixia/utils/IxLoadUtils.py @@ -70,7 +70,7 @@ def waitForActionToFinish(connection, replyObj, actionUrl): if actionStatusObj.status == kActionStatusError: errorMsg += actionStatusObj.error - print errorMsg + print(errorMsg) sys.exit(1) else: @@ -172,13 +172,13 @@ def uploadFile(connection, url, fileName, uploadPath, overwrite=True): with open(fileName, 'rb') as f: resp = requests.post(url, data=f, params=params, headers=headers) - except requests.exceptions.ConnectionError, e: + except requests.exceptions.ConnectionError as e: raise Exception('Upload file failed. Received connection error. \ One common cause for this error is the size of the \ file to be uploaded.The web server sets a limit of 1GB\ for the uploaded file size. \ Received the following error: %s' % str(e)) - except IOError, e: + except IOError as e: raise Exception('Upload file failed. Received IO error: %s' % str(e)) except Exception: diff --git a/functest/opnfv_tests/vnf/ims/ixia/utils/IxRestUtils.py b/functest/opnfv_tests/vnf/ims/ixia/utils/IxRestUtils.py index 41c23dc53..9148dd20a 100644 --- a/functest/opnfv_tests/vnf/ims/ixia/utils/IxRestUtils.py +++ b/functest/opnfv_tests/vnf/ims/ixia/utils/IxRestUtils.py @@ -7,10 +7,13 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 -from urlparse import urljoin import requests +import six +from six.moves.urllib.parse import urljoin + + def getConnection(server, port): """ Gets a Connection instance, that will be used to @@ -180,7 +183,7 @@ class WebObject(object): """ self.jsonOptions = {} - for (key, value) in entries.iteritems(): + for (key, value) in six.iteritems(entries): webObj = _WebObject(value) self.jsonOptions[key] = webObj self.__dict__[key] = webObj diff --git a/functest/opnfv_tests/vnf/router/cloudify_vrouter.py b/functest/opnfv_tests/vnf/router/cloudify_vrouter.py index 194549022..c5c72e05c 100644 --- a/functest/opnfv_tests/vnf/router/cloudify_vrouter.py +++ b/functest/opnfv_tests/vnf/router/cloudify_vrouter.py @@ -50,6 +50,9 @@ import snaps.openstack.utils.glance_utils as glance_utils from snaps.openstack.utils import keystone_utils +import six + + __author__ = "Shuya Nakama <shuya.nakama@okinawaopenlabs.org>" @@ -180,7 +183,7 @@ class CloudifyVrouter(vrouter_base.VrouterOnBoardingBase): self.created_object.append(keypair_creator) self.__logger.info("Upload some OS images if it doesn't exist") - for image_name, image_file in self.images.iteritems(): + for image_name, image_file in six.iteritems(self.images): self.__logger.info("image: %s, file: %s", image_name, image_file) if image_file and image_name: image_creator = OpenStackImage( @@ -100,9 +100,10 @@ commands = dirs = functest/tests/unit/ci functest/tests/unit/cli + functest/tests/unit/core functest/tests/unit/odl - functest/tests/unit/openstack/rally - functest/tests/unit/openstack/tempest + functest/tests/unit/openstack + functest/tests/unit/vnf/epc functest/tests/unit/utils commands = nosetests {[testenv:py35]dirs} |