From: John Spray Date: Wed, 17 Feb 2016 14:29:07 +0000 (+0000) Subject: java: update libcephfs tests to learn pool name X-Git-Tag: v10.1.0~144^2~13 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c3a8a09e4d109c8a259df6fa87332e1732436d6e;p=ceph.git java: update libcephfs tests to learn pool name Don't assume the data/metadata pools are called "data" and "metadata". Signed-off-by: John Spray --- diff --git a/src/java/test/com/ceph/fs/CephMountTest.java b/src/java/test/com/ceph/fs/CephMountTest.java index c952c0c9422c..fcc54d8c58e1 100644 --- a/src/java/test/com/ceph/fs/CephMountTest.java +++ b/src/java/test/com/ceph/fs/CephMountTest.java @@ -72,6 +72,18 @@ public class CephMountTest { return path; } + /* + * Helper to learn the data pool name, by reading it + * from the '/' dir inode. + */ + public String getRootPoolName() throws Exception + { + int fd = mount.open("/", CephMount.O_DIRECTORY, 0600); + String pool = mount.get_file_pool_name(fd); + mount.close(fd); + return pool; + } + /* * Helper function to create a file with the given path and size. The file * is filled with size bytes and the file descriptor is returned. @@ -936,17 +948,11 @@ public class CephMountTest { assertTrue(mount.get_stripe_unit_granularity() > 0); } - /* - * pool info. below we use "data" and "metadata" pool names which we assume - * to exist (they are the default pools created for file data / metadata in - * CephFS). - */ - @Test public void test_get_pool_id() throws Exception { - /* returns valid pool ids */ - assertTrue(mount.get_pool_id("data") >= 0); - assertTrue(mount.get_pool_id("metadata") >= 0); + String data_pool_name = getRootPoolName(); + /* returns valid pool id */ + assertTrue(mount.get_pool_id(data_pool_name) >= 0); /* test non-existent pool name */ try { @@ -964,20 +970,22 @@ public class CephMountTest { } catch (CephPoolException e) {} /* test valid pool id */ - int poolid = mount.get_pool_id("data"); + String data_pool_name = getRootPoolName(); + int poolid = mount.get_pool_id(data_pool_name); assertTrue(poolid >= 0); assertTrue(mount.get_pool_replication(poolid) > 0); } @Test public void test_get_file_pool_name() throws Exception { + String data_pool_name = getRootPoolName(); String path = makePath(); int fd = createFile(path, 1); String pool = mount.get_file_pool_name(fd); mount.close(fd); assertTrue(pool != null); - /* assumes using default data pool "data" */ - assertTrue(pool.compareTo("data") == 0); + /* assumes using default data pool */ + assertTrue(pool.compareTo(data_pool_name) == 0); mount.unlink(path); }