]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
qa/tasks/mgr/dashboard: drop python2 support
authorKefu Chai <kchai@redhat.com>
Sun, 19 Jul 2020 09:36:52 +0000 (17:36 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 22 Jul 2020 03:55:49 +0000 (11:55 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
qa/tasks/mgr/dashboard/helper.py
qa/tasks/mgr/dashboard/test_cephfs.py
qa/tasks/mgr/dashboard/test_crush_rule.py
qa/tasks/mgr/dashboard/test_erasure_code_profile.py
qa/tasks/mgr/dashboard/test_pool.py
qa/tasks/mgr/dashboard/test_rgw.py

index 44f919b11190eb17b559ed60a7ba7f83108fca54..db7c1b2e41ef32b26a1204150ce54a6c6a4283f6 100644 (file)
@@ -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)
index e6594450f714177b6833de5b502f35db43ec09fc..fafa0a0fcfc62a41be9f93f8861e4d845ea2d3ea 100644 (file)
@@ -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']
index a0bca63ff4a038be1cadff5fcd52c54745e6b2ba..514f16a401315a3f687340def5230ff907e18538 100644 (file)
@@ -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))
         }))
 
index 12e061777fc28170e2a946058257ec6282e0f05c..27fe884c8b0cc12e5e3953064d8a4f673bc06cd0 100644 (file)
@@ -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))
         }))
 
index 2d34bc75ce136686dd37e40bd48a540b4361b3e7..35cab37975f491309476744d2f53b3f8c6dd0854 100644 (file)
@@ -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),
index 9f5f782347e054859da6d6d73b23bbd7b0d1ae35..0957f553aba8cc814ec8a6135f73502b5e2243c2 100644 (file)
@@ -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