From 877a0cd87167836e71b745a039127ecda10c04a8 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Sun, 19 Jul 2020 17:36:52 +0800 Subject: [PATCH] qa/tasks/mgr/dashboard: drop python2 support Signed-off-by: Kefu Chai --- qa/tasks/mgr/dashboard/helper.py | 10 +++------- qa/tasks/mgr/dashboard/test_cephfs.py | 5 ++--- qa/tasks/mgr/dashboard/test_crush_rule.py | 6 ++---- qa/tasks/mgr/dashboard/test_erasure_code_profile.py | 8 +++----- qa/tasks/mgr/dashboard/test_pool.py | 13 ++++++------- qa/tasks/mgr/dashboard/test_rgw.py | 3 ++- 6 files changed, 18 insertions(+), 27 deletions(-) diff --git a/qa/tasks/mgr/dashboard/helper.py b/qa/tasks/mgr/dashboard/helper.py index 44f919b11190e..db7c1b2e41ef3 100644 --- a/qa/tasks/mgr/dashboard/helper.py +++ b/qa/tasks/mgr/dashboard/helper.py @@ -8,7 +8,6 @@ from collections import namedtuple import time import requests -import six from teuthology.exceptions import CommandFailedError from tasks.mgr.mgr_test_case import MgrTestCase @@ -458,13 +457,10 @@ class DashboardTestCase(MgrTestCase): return obj return None - +# TODP: pass defaults=(False,) to namedtuple() if python3.7 class JLeaf(namedtuple('JLeaf', ['typ', 'none'])): def __new__(cls, typ, none=False): - if typ == str: - typ = six.string_types - return super(JLeaf, cls).__new__(cls, typ, none) - + return super().__new__(cls, typ, none) JList = namedtuple('JList', ['elem_typ']) @@ -553,7 +549,7 @@ def _validate_json(val, schema, path=[]): for key in unknown_keys ) return result - if schema in [str, int, float, bool, six.string_types]: + if schema in [str, int, float, bool]: return _validate_json(val, JLeaf(schema), path) assert False, str(path) diff --git a/qa/tasks/mgr/dashboard/test_cephfs.py b/qa/tasks/mgr/dashboard/test_cephfs.py index e6594450f7141..fafa0a0fcfc62 100644 --- a/qa/tasks/mgr/dashboard/test_cephfs.py +++ b/qa/tasks/mgr/dashboard/test_cephfs.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import -import six from contextlib import contextmanager from .helper import DashboardTestCase, JObj, JList, JLeaf @@ -154,11 +153,11 @@ class CephfsTest(DashboardTestCase): # Name self.assertToHave(data, 'name') - self.assertIsInstance(data['name'], six.string_types) + self.assertIsInstance(data['name'], str) # Standbys self.assertToHave(data, 'standbys') - self.assertIsInstance(data['standbys'], six.string_types) + self.assertIsInstance(data['standbys'], str) # MDS counters counters = data['mds_counters'] diff --git a/qa/tasks/mgr/dashboard/test_crush_rule.py b/qa/tasks/mgr/dashboard/test_crush_rule.py index a0bca63ff4a03..514f16a401315 100644 --- a/qa/tasks/mgr/dashboard/test_crush_rule.py +++ b/qa/tasks/mgr/dashboard/test_crush_rule.py @@ -2,8 +2,6 @@ from __future__ import absolute_import -import six - from .helper import DashboardTestCase, JObj, JList @@ -15,7 +13,7 @@ class CrushRuleTest(DashboardTestCase): 'max_size': int, 'min_size': int, 'rule_id': int, - 'rule_name': six.string_types, + 'rule_name': str, 'ruleset': int, 'steps': JList(JObj({}, allow_unknown=True)) }, allow_unknown=True) @@ -83,7 +81,7 @@ class CrushRuleTest(DashboardTestCase): self._get('/ui-api/crush_rule/info') self.assertStatus(200) self.assertSchemaBody(JObj({ - 'names': JList(six.string_types), + 'names': JList(str), 'nodes': JList(JObj({}, allow_unknown=True)) })) diff --git a/qa/tasks/mgr/dashboard/test_erasure_code_profile.py b/qa/tasks/mgr/dashboard/test_erasure_code_profile.py index 12e061777fc28..27fe884c8b0cc 100644 --- a/qa/tasks/mgr/dashboard/test_erasure_code_profile.py +++ b/qa/tasks/mgr/dashboard/test_erasure_code_profile.py @@ -2,8 +2,6 @@ from __future__ import absolute_import -import six - from .helper import DashboardTestCase, JObj, JList @@ -101,9 +99,9 @@ class ECPTest(DashboardTestCase): def test_ecp_info(self): self._get('/ui-api/erasure_code_profile/info') self.assertSchemaBody(JObj({ - 'names': JList(six.string_types), - 'plugins': JList(six.string_types), - 'directory': six.string_types, + 'names': JList(str), + 'plugins': JList(str), + 'directory': str, 'nodes': JList(JObj({}, allow_unknown=True)) })) diff --git a/qa/tasks/mgr/dashboard/test_pool.py b/qa/tasks/mgr/dashboard/test_pool.py index 2d34bc75ce136..35cab37975f49 100644 --- a/qa/tasks/mgr/dashboard/test_pool.py +++ b/qa/tasks/mgr/dashboard/test_pool.py @@ -2,7 +2,6 @@ from __future__ import absolute_import import logging -import six import time from contextlib import contextmanager @@ -405,16 +404,16 @@ class PoolTest(DashboardTestCase): def test_pool_info(self): self._get("/ui-api/pool/info") self.assertSchemaBody(JObj({ - 'pool_names': JList(six.string_types), - 'compression_algorithms': JList(six.string_types), - 'compression_modes': JList(six.string_types), + 'pool_names': JList(str), + 'compression_algorithms': JList(str), + 'compression_modes': JList(str), 'is_all_bluestore': bool, - 'bluestore_compression_algorithm': six.string_types, + 'bluestore_compression_algorithm': str, 'osd_count': int, 'crush_rules_replicated': JList(JObj({}, allow_unknown=True)), 'crush_rules_erasure': JList(JObj({}, allow_unknown=True)), - 'pg_autoscale_default_mode': six.string_types, - 'pg_autoscale_modes': JList(six.string_types), + 'pg_autoscale_default_mode': str, + 'pg_autoscale_modes': JList(str), 'erasure_code_profiles': JList(JObj({}, allow_unknown=True)), 'used_rules': JObj({}, allow_unknown=True), 'used_profiles': JObj({}, allow_unknown=True), diff --git a/qa/tasks/mgr/dashboard/test_rgw.py b/qa/tasks/mgr/dashboard/test_rgw.py index 9f5f782347e05..0957f553aba8c 100644 --- a/qa/tasks/mgr/dashboard/test_rgw.py +++ b/qa/tasks/mgr/dashboard/test_rgw.py @@ -5,10 +5,11 @@ import base64 import logging import time +from urllib import parse + from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives.twofactor.totp import TOTP from cryptography.hazmat.primitives.hashes import SHA1 -from six.moves.urllib import parse from .helper import DashboardTestCase, JObj, JList, JLeaf -- 2.39.5