Update ranger-tempest-plugin to python 3.6
Small changes to ensure ranger-tempest-plugin is ready for the end of python 2.7 support. Change-Id: Ib1dd506ccf5bbd419ced9c3e81dabfb0cde08719
This commit is contained in:
parent
a14ad5d3eb
commit
e687324086
37
Dockerfile
37
Dockerfile
@ -1,20 +1,20 @@
|
||||
FROM ubuntu:16.04
|
||||
FROM ubuntu:18.04
|
||||
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
ENV container docker
|
||||
ENV LC_ALL C.UTF-8
|
||||
ENV LANG C.UTF-8
|
||||
|
||||
RUN apt -qq update && \
|
||||
RUN apt update && \
|
||||
apt -y install git \
|
||||
netcat \
|
||||
netbase \
|
||||
openssh-server \
|
||||
python-minimal \
|
||||
python-setuptools \
|
||||
python-pip \
|
||||
python-dev \
|
||||
python-dateutil \
|
||||
python3-minimal \
|
||||
python3-setuptools \
|
||||
python3-pip \
|
||||
python3-dev \
|
||||
python3-dateutil \
|
||||
ca-certificates \
|
||||
openstack-pkg-tools \
|
||||
apache2 \
|
||||
@ -32,10 +32,10 @@ RUN apt -qq update && \
|
||||
/usr/share/doc \
|
||||
/usr/share/doc-base
|
||||
|
||||
RUN pip install -U setuptools && \
|
||||
pip install wheel && \
|
||||
pip install --upgrade six && \
|
||||
pip install pbr==2.0.0
|
||||
RUN ln -s /usr/bin/python3 /usr/bin/python && \
|
||||
pip3 install -U setuptools && \
|
||||
pip3 install wheel && \
|
||||
pip3 install pbr==2.0.0
|
||||
|
||||
|
||||
##########################################################################
|
||||
@ -62,8 +62,8 @@ WORKDIR /
|
||||
RUN git clone https://git.openstack.org/openstack/tempest
|
||||
|
||||
### now run 'pip install -r requirements'
|
||||
RUN pip install -r /tempest/requirements.txt && \
|
||||
pip install -r /tempest/test-requirements.txt
|
||||
RUN pip3 install -r /tempest/requirements.txt && \
|
||||
pip3 install -r /tempest/test-requirements.txt
|
||||
|
||||
### create required tempest directories - and remove .stestr folder
|
||||
RUN mkdir -p /tempest/logs \
|
||||
@ -86,14 +86,15 @@ COPY tempest_setup/tempest.conf /tempest/etc
|
||||
### RUN tempest tests on test_regions
|
||||
##########################################################################
|
||||
### create egg-info for tempest
|
||||
RUN python /tempest/setup.py develop
|
||||
RUN cd /tempest && \
|
||||
python setup.py develop
|
||||
|
||||
#ENTRYPOINT ostestr run ranger_tempest_plugin.tests.api.test_regions \
|
||||
#ENTRYPOINT stestr run ranger_tempest_plugin.tests.api.test_regions \
|
||||
# && /bin/bash
|
||||
#ENTRYPOINT ostestr run ranger_tempest_plugin.tests.api.test_flavors/ \
|
||||
#ENTRYPOINT stestr run ranger_tempest_plugin.tests.api.test_flavors/ \
|
||||
# && /bin/bash
|
||||
#ENTRYPOINT ostestr run ranger_tempest_plugin.tests.api.test_customers/ \
|
||||
#ENTRYPOINT stestr run ranger_tempest_plugin.tests.api.test_customers/ \
|
||||
# && /bin/bash
|
||||
#ENTRYPOINT ostestr run ranger_tempest_plugin.tests.api.test_images/ \
|
||||
#ENTRYPOINT stestr run ranger_tempest_plugin.tests.api.test_images/ \
|
||||
# && /bin/bash
|
||||
|
||||
|
@ -103,7 +103,7 @@ class CmsClient(base_client.RangerClientBase):
|
||||
def list_customers(self, filter=None):
|
||||
uri = '%s/%s/orm/customers' % (self.cms_url, self.version)
|
||||
if filter is not None:
|
||||
uri += '?' + urllib.urlencode(filter)
|
||||
uri += '?' + urllib.parse.urlencode(filter)
|
||||
return self.get_request(uri, schema.list_customer)
|
||||
|
||||
# DELETE
|
||||
|
@ -45,7 +45,7 @@ class GrpClient(base_client.RangerClientBase):
|
||||
def list_groups(self, filter=None):
|
||||
uri = '%s/%s/orm/groups' % (self.cms_url, self.version)
|
||||
if filter is not None:
|
||||
uri += '?' + urllib.urlencode(filter)
|
||||
uri += '?' + urllib.parse.urlencode(filter)
|
||||
return self.get_request(uri, schema.list_groups)
|
||||
|
||||
def add_groups_region(self, group_id, *args):
|
||||
|
@ -113,7 +113,7 @@ class RmsClient(base_client.RangerClientBase):
|
||||
def list_regions(self, filter=None):
|
||||
uri = '%s/%s/orm/regions' % (self.rms_url, self.version)
|
||||
if filter is not None:
|
||||
uri += '?' + urllib.urlencode(filter)
|
||||
uri += '?' + urllib.parse.urlencode(filter)
|
||||
return self.get_request(uri, schema.list_region)
|
||||
|
||||
def delete_region(self, region_id):
|
||||
|
@ -16,7 +16,6 @@
|
||||
from oslo_log import log as logging
|
||||
from ranger_tempest_plugin import clients
|
||||
|
||||
import six
|
||||
from tempest import config
|
||||
from tempest import test
|
||||
|
||||
@ -45,8 +44,8 @@ class BaseOrmTest(test.BaseTestCase):
|
||||
skip_msg = ("%s skipped as ranger is not available" % cls.__name__)
|
||||
raise cls.skipException(skip_msg)
|
||||
|
||||
def assertExpected(self, expected, actual, excluded_keys):
|
||||
for key, value in six.iteritems(expected):
|
||||
def assert_expected(self, expected, actual, excluded_keys):
|
||||
for key, value in list(expected.items()):
|
||||
if key not in excluded_keys:
|
||||
self.assertIn(key, actual)
|
||||
self.assertEqual(value, actual[key], key)
|
||||
|
@ -134,7 +134,7 @@ class CmsBaseOrmTest(base.BaseOrmTest):
|
||||
return [region]
|
||||
|
||||
@classmethod
|
||||
def _create_cust_validate_creation_on_dcp_and_lcp(self, **kwargs):
|
||||
def _create_cust_validate_creation_on_dcp_and_lcp(cls, **kwargs):
|
||||
"""Creates a customer record
|
||||
|
||||
kwargs contains field data needed for customer POST body:
|
||||
@ -149,20 +149,19 @@ class CmsBaseOrmTest(base.BaseOrmTest):
|
||||
- visibility
|
||||
- tenants
|
||||
"""
|
||||
_, body = self.client.create_customer(**kwargs)
|
||||
_, body = cls.client.create_customer(**kwargs)
|
||||
customer_id = body["customer"]["id"]
|
||||
_, customer = self.client.get_customer(customer_id)
|
||||
_, customer = cls.client.get_customer(customer_id)
|
||||
if customer["name"] == kwargs["name"]:
|
||||
if customer["regions"] == []:
|
||||
customer_status = "no regions"
|
||||
else:
|
||||
customer_status = "Success"
|
||||
|
||||
self._wait_for_status(customer_id, customer_status)
|
||||
return customer_id
|
||||
else:
|
||||
message = "customer %s not created successfully" % kwargs["name"]
|
||||
exceptions.TempestException(message)
|
||||
cls._wait_for_status(customer_id, customer_status)
|
||||
return customer_id
|
||||
|
||||
@classmethod
|
||||
def _wait_for_status(cls, customer_id, status):
|
||||
@ -208,10 +207,7 @@ class CmsBaseOrmTest(base.BaseOrmTest):
|
||||
if (quota["compute"][0][param] ==
|
||||
str(body["quota_set"][param])):
|
||||
actual_quota_count += 1
|
||||
if expected_quota_count == actual_quota_count:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return bool(expected_quota_count == actual_quota_count)
|
||||
|
||||
@classmethod
|
||||
def _validate_users_on_cust_on_dcp_and_lcp(cls, post_body, cust_id):
|
||||
@ -238,10 +234,7 @@ class CmsBaseOrmTest(base.BaseOrmTest):
|
||||
for user in region_users_req:
|
||||
if (user in users_lcp) and (user in region_users_dcp):
|
||||
actual_users_count += 1
|
||||
if expected_users_count == actual_users_count:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return bool(expected_users_count == actual_users_count)
|
||||
|
||||
@classmethod
|
||||
def _del_cust_validate_deletion_on_dcp_and_lcp(cls, customer_id):
|
||||
|
@ -118,11 +118,11 @@ class FmsBaseOrmTest(base.BaseOrmTest):
|
||||
(flavor_id, status))
|
||||
raise exceptions.TempestException(message)
|
||||
if int(time.time()) - start >= cls.build_timeout:
|
||||
message =\
|
||||
'flavor %s failed to reach %s status within'
|
||||
' the required time (%s s) and is in'
|
||||
'%s status.' % (flavor_id, status,
|
||||
cls.build_timeout, flavor_status)
|
||||
message = ('flavor %s failed to reach %s status within'
|
||||
' the required time (%s s) and is in'
|
||||
' %s status.') % (flavor_id, status,
|
||||
cls.build_timeout,
|
||||
flavor_status)
|
||||
raise exceptions.TimeoutException(message)
|
||||
|
||||
@classmethod
|
||||
@ -151,15 +151,9 @@ class FmsBaseOrmTest(base.BaseOrmTest):
|
||||
if spec in actual_specs:
|
||||
if expected_specs[spec] == actual_specs[spec]:
|
||||
actual_specs_count += 1
|
||||
if expected_specs_count == actual_specs_count:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
if _validate_extra_specs(flavor_orm) and\
|
||||
_validate_extra_specs(flavor_lcp):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return bool(expected_specs_count == actual_specs_count)
|
||||
return bool(_validate_extra_specs(flavor_orm) and
|
||||
_validate_extra_specs(flavor_lcp))
|
||||
|
||||
@classmethod
|
||||
def _del_flv_and_validate_deletion_on_dcp_and_lcp(cls, flavor_id):
|
||||
@ -206,9 +200,8 @@ class FmsBaseOrmTest(base.BaseOrmTest):
|
||||
flavor_status = flavor_ids[0]["status"]
|
||||
if flavor_status == 'Error':
|
||||
message = \
|
||||
'Flavor %s failed to get deleted'
|
||||
'and is in error status' % \
|
||||
flavor_id
|
||||
('Flavor %s failed to get deleted'
|
||||
'and is in error status') % flavor_id
|
||||
raise exceptions.TempestException(message)
|
||||
if int(time.time()) - start >= cls.build_timeout:
|
||||
message = (
|
||||
@ -242,20 +235,17 @@ class FmsBaseOrmTest(base.BaseOrmTest):
|
||||
def _get_expected_flavor_name(cls, post_body):
|
||||
name = post_body["series"] + "." + "c" + \
|
||||
post_body["vcpus"] + "r" + \
|
||||
str(int(post_body["ram"]) / 1024) \
|
||||
str(int(post_body["ram"]) // 1024) \
|
||||
+ "d" + post_body["disk"] + "s" + \
|
||||
str(int(post_body["swap"]) / 1024) \
|
||||
+ "e" + str(int(post_body["ephemeral"]) / 1024)
|
||||
str(int(post_body["swap"]) // 1024) \
|
||||
+ "e" + str(int(post_body["ephemeral"]) // 1024)
|
||||
return name
|
||||
|
||||
@classmethod
|
||||
def _validate_flv_geometry_on_lcp(cls, flavor_id, post_body):
|
||||
flv = cls.flavors_client.show_flavor(flavor_id)["flavor"]
|
||||
if flv["vcpus"] == int(post_body["vcpus"]) and \
|
||||
flv["ram"] == post_body["ram"] and \
|
||||
flv["swap"] == int(post_body["swap"]) and \
|
||||
flv["disk"] == int(post_body["disk"]) and \
|
||||
flv["ephemeral"] == post_body["ephemeral"]:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return bool(flv["vcpus"] == int(post_body["vcpus"]) and
|
||||
flv["ram"] == post_body["ram"] and
|
||||
flv["swap"] == int(post_body["swap"]) and
|
||||
flv["disk"] == int(post_body["disk"]) and
|
||||
flv["ephemeral"] == post_body["ephemeral"])
|
||||
|
@ -198,9 +198,8 @@ class ImsBaseOrmTest(base.BaseOrmTest):
|
||||
image_status = image_ids[0]["status"]
|
||||
if image_status == 'Error':
|
||||
message = \
|
||||
'Image %s failed to get deleted '
|
||||
'and is in error status' % \
|
||||
image_id
|
||||
('Image %s failed to get deleted '
|
||||
'and is in error status') % image_id
|
||||
raise exceptions.TempestException(message)
|
||||
if int(time.time()) - start >= cls.build_timeout:
|
||||
message = ('Image %s failed to get deleted within '
|
||||
|
@ -327,7 +327,7 @@ class TestTempestCms(cms_base.CmsBaseOrmTest):
|
||||
customer)
|
||||
self._wait_for_status(self.setup_customer_id, 'Success')
|
||||
_, body = self.client.get_customer(self.setup_customer_id)
|
||||
self.assertExpected(customer, body, ['name', 'regions'])
|
||||
self.assert_expected(customer, body, ['name', 'regions'])
|
||||
for region in customer['regions']:
|
||||
self.assertIn(region['name'], [x['name'] for x in body['regions']])
|
||||
|
||||
|
@ -112,10 +112,10 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
|
||||
_, body = self.client.update_extra_specs(flavor_id, self.custom_es)
|
||||
self._wait_for_flavor_status_on_dcp(flavor_id, 'Success')
|
||||
|
||||
_, es = self.client.get_extra_specs(flavor_id)
|
||||
_, extra_specs = self.client.get_extra_specs(flavor_id)
|
||||
es_expected = self.custom_es.get("os_extra_specs")
|
||||
es_expected.update(self.dflt_ex_specs)
|
||||
self.assertDictEqual(es_expected, es.get("os_extra_specs"))
|
||||
self.assertDictEqual(es_expected, extra_specs.get("os_extra_specs"))
|
||||
|
||||
@classmethod
|
||||
def resource_cleanup(cls):
|
||||
@ -191,7 +191,7 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
|
||||
self._exec_tags_function(self.flavor_id, add_tag_body, 'add', None)
|
||||
_, tag_body = self.client.get_tags(self.flavor_id)
|
||||
|
||||
subset = {k: v for k, v in tag_body.get("tags").items()
|
||||
subset = {k: v for k, v in list(tag_body.get("tags").items())
|
||||
if k in add_tag_body.get("tags")}
|
||||
|
||||
self.assertDictEqual(add_tag_body.get("tags"), subset)
|
||||
@ -266,11 +266,11 @@ class TestTempestFms(fms_base.FmsBaseOrmTest):
|
||||
# add custom extra specs
|
||||
add_es_body = {"os_extra_specs": {"a": "apple", "b": "banana"}}
|
||||
self._exec_ex_spec_function(self.flavor_id, add_es_body, 'add', None)
|
||||
_, es = self.client.get_extra_specs(self.flavor_id)
|
||||
_, extra_specs = self.client.get_extra_specs(self.flavor_id)
|
||||
|
||||
# assert extra specs add results match expected
|
||||
es_expected.update(add_es_body["os_extra_specs"])
|
||||
self.assertDictEqual(es_expected, es.get("os_extra_specs"))
|
||||
self.assertDictEqual(es_expected, extra_specs.get("os_extra_specs"))
|
||||
|
||||
@decorators.idempotent_id('043948fd-125b-4d96-bf40-42464066a7e1')
|
||||
def test_update_flvr_extra_specs(self):
|
||||
|
@ -68,10 +68,10 @@ class TestTempestRegionGroup(base.BaseOrmTest):
|
||||
|
||||
@decorators.idempotent_id('0d377eb2-754d-49c1-9a4f-c7019dfe80ca')
|
||||
def test_update_group(self):
|
||||
id = self.group_ids[-1]
|
||||
group = orm_data_utils.rand_region_group(self.setup_ids, id)
|
||||
_, body = self.client.update_region_group(id, **group)
|
||||
self.assertExpected(group, body['group'], ['regions'])
|
||||
_id = self.group_ids[-1]
|
||||
group = orm_data_utils.rand_region_group(self.setup_ids, _id)
|
||||
_, body = self.client.update_region_group(_id, **group)
|
||||
self.assert_expected(group, body['group'], ['regions'])
|
||||
|
||||
@decorators.idempotent_id('b946c6c4-d601-42b9-befd-ba40992a3c53')
|
||||
def test_list_groups(self):
|
||||
@ -82,6 +82,6 @@ class TestTempestRegionGroup(base.BaseOrmTest):
|
||||
|
||||
@decorators.idempotent_id('9a37d966-4416-4ff3-8f3b-6847810662d7')
|
||||
def test_get_group(self):
|
||||
id = self.group_1['group']['id']
|
||||
_, body = self.client.get_region_group(id)
|
||||
self.assertExpected(self.group_1['group'], body, ['links'])
|
||||
_id = self.group_1['group']['id']
|
||||
_, body = self.client.get_region_group(_id)
|
||||
self.assert_expected(self.group_1['group'], body, ['links'])
|
||||
|
@ -114,7 +114,7 @@ class TestTempestRegion(rms_base.RmsBaseOrmTest):
|
||||
|
||||
@decorators.idempotent_id('f2b2361d-ce71-43a8-9f01-acb529835880')
|
||||
def test_list_region_with_metadata(self):
|
||||
filter = {'metadata': self.region_1['metadata'].keys()[0]}
|
||||
filter = {'metadata': list(self.region_1['metadata'].keys())[0]}
|
||||
self._list_regions_with_filter(filter, 'metadata')
|
||||
|
||||
@decorators.idempotent_id('4533b31a-115d-466d-bf75-8ac24338c1a5')
|
||||
@ -140,19 +140,19 @@ class TestTempestRegion(rms_base.RmsBaseOrmTest):
|
||||
@decorators.idempotent_id('358f3cbc-4ae5-4b43-be36-6df55eae8fd9')
|
||||
def test_get_region(self):
|
||||
_, body = self.client.get_region(self.region_1['id'])
|
||||
self.assertExpected(self.region_1, body, [])
|
||||
self.assert_expected(self.region_1, body, [])
|
||||
|
||||
@decorators.idempotent_id('cefb952f-7777-4878-87d2-d78ac345f0d2')
|
||||
def test_get_region_metadata(self):
|
||||
_, body = self.client.get_region_metadata(self.region_1['id'])
|
||||
self.assertExpected(self.region_1['metadata'], body['metadata'], [])
|
||||
self.assert_expected(self.region_1['metadata'], body['metadata'], [])
|
||||
|
||||
@decorators.idempotent_id('b2c3baf5-22af-4bf9-bcad-b6a1a74e82d9')
|
||||
def test_update_region(self):
|
||||
id = self.setup_ids[-1]
|
||||
region = orm_data_utils.rand_region(id)
|
||||
_, body = self.client.update_region(id, **region)
|
||||
self.assertExpected(region, body, [])
|
||||
_id = self.setup_ids[-1]
|
||||
region = orm_data_utils.rand_region(_id)
|
||||
_, body = self.client.update_region(_id, **region)
|
||||
self.assert_expected(region, body, [])
|
||||
|
||||
@decorators.idempotent_id('0d5644d8-92bc-497c-8fc5-b57417d86e6d')
|
||||
def test_update_region_status(self):
|
||||
@ -160,7 +160,7 @@ class TestTempestRegion(rms_base.RmsBaseOrmTest):
|
||||
status['status'] = orm_data_utils.rand_region_status(
|
||||
[self.region_1['status']])
|
||||
_, body = self.client.update_region_status(self.region_1['id'], status)
|
||||
self.assertExpected(status, body, ['links'])
|
||||
self.assert_expected(status, body, ['links'])
|
||||
|
||||
@decorators.idempotent_id('5c1a2624-6abe-49e7-82c8-30e8df1377d0')
|
||||
def test_update_region_metadata(self):
|
||||
@ -168,7 +168,7 @@ class TestTempestRegion(rms_base.RmsBaseOrmTest):
|
||||
metadata['metadata'] = orm_data_utils.rand_region_metadata()
|
||||
_, body = self.client.update_region_metadata(self.region_1['id'],
|
||||
metadata)
|
||||
self.assertExpected(metadata, body, [])
|
||||
self.assert_expected(metadata, body, [])
|
||||
|
||||
def _list_regions_with_filter(self, filter, key):
|
||||
_, body = self.client.list_regions(filter)
|
||||
|
@ -17,7 +17,7 @@ classifier =
|
||||
Natural Language :: English
|
||||
Topic :: Software Development :: Quality Assurance
|
||||
Topic :: Software Development :: Testing
|
||||
Programming Language :: Python
|
||||
Programming Language :: Python :: 3.6
|
||||
keywords =
|
||||
Plugin
|
||||
Tempest
|
||||
|
Loading…
x
Reference in New Issue
Block a user