]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind: Add test for creating pool by raw UTF-8
authorDavid Coles <dcoles@gaikai.com>
Tue, 20 Oct 2015 17:57:46 +0000 (10:57 -0700)
committerDavid Coles <dcoles@gaikai.com>
Fri, 13 Nov 2015 01:26:30 +0000 (17:26 -0800)
Some clients try providing non-ASCII pool names by sending raw encoded bytes.
This check ensures that we still support this behaviour for Python 2.

In Python 3, bytestrings will fail since strings are Unicode strings and thus
clients should use Unicode escapes instead.

Signed-off-by: David Coles <dcoles@gaikai.com>
src/test/pybind/test_rados.py

index 11457a7bc3bd01d7eae7cd41b0b624c0d205e015..ebc4e8fcdee652259c14c569006e2952be4295c6 100644 (file)
@@ -7,6 +7,10 @@ import time
 import threading
 import json
 import errno
+import sys
+
+# Are we running Python 2.x
+_python2 = sys.hexversion < 0x03000000
 
 def test_rados_init_error():
     assert_raises(Error, Rados, conffile='', rados_id='admin',
@@ -127,6 +131,16 @@ class TestRados(object):
         self.rados.create_pool('foo')
         self.rados.delete_pool('foo')
 
+    def test_create_utf8(self):
+        if _python2:
+            # Use encoded bytestring
+            poolname = b"\351\273\204"
+        else:
+            poolname = "\u9ec4"
+        self.rados.create_pool(poolname)
+        assert self.rados.pool_exists(u"\u9ec4")
+        self.rados.delete_pool(poolname)
+
     def test_create_auid(self):
         self.rados.create_pool('foo', 100)
         assert self.rados.pool_exists('foo')