]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test_volume_client: make test_object_versioned py3 compatible
authorRishabh Dave <ridave@redhat.com>
Fri, 21 Jun 2019 09:26:49 +0000 (14:56 +0530)
committerRishabh Dave <ridave@redhat.com>
Sat, 13 Jul 2019 05:40:58 +0000 (11:10 +0530)
Convert strings to bytes in the Python program embedded inside this
test. Also, in the process don't lose Python 2 compatibility.

Fixes: http://tracker.ceph.com/issues/39405
Signed-off-by: Rishabh Dave <ridave@redhat.com>
qa/tasks/cephfs/test_volume_client.py

index 31484dde4004551115a899b9ffdf7948dfe6a336..83de532645f2a3816803252bdfcd0fc187b4b233 100644 (file)
@@ -34,6 +34,7 @@ class TestVolumeClient(CephFSTestCase):
         return client.run_python("""
 from __future__ import print_function
 from ceph_volume_client import CephFSVolumeClient, VolumePath
+from sys import version_info as sys_version_info
 import logging
 log = logging.getLogger("ceph_volume_client")
 log.addHandler(logging.StreamHandler())
@@ -999,9 +1000,19 @@ vc.disconnect()
         with self.assertRaises(CommandFailedError):
             self._volume_client_python(vc_mount, dedent("""
                 data, version = vc.get_object_and_version("{pool_name}", "{obj_name}")
-                data += 'm1'
+
+                if sys_version_info.major < 3:
+                    data = data + 'm1'
+                elif sys_version_info.major > 3:
+                    data = str.encode(data.decode('utf-8') + 'm1')
+
                 vc.put_object("{pool_name}", "{obj_name}", data)
-                data += 'm2'
+
+                if sys_version_info.major < 3:
+                    data = data + 'm2'
+                elif sys_version_info.major > 3:
+                    data = str.encode(data.decode('utf-8') + 'm2')
+
                 vc.put_object_versioned("{pool_name}", "{obj_name}", data, version)
             """).format(pool_name=pool_name, obj_name=obj_name))