]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
java: update libcephfs tests to learn pool name
authorJohn Spray <john.spray@redhat.com>
Wed, 17 Feb 2016 14:29:07 +0000 (14:29 +0000)
committerJohn Spray <john.spray@redhat.com>
Thu, 10 Mar 2016 11:18:28 +0000 (11:18 +0000)
Don't assume the data/metadata pools are called
"data" and "metadata".

Signed-off-by: John Spray <john.spray@redhat.com>
src/java/test/com/ceph/fs/CephMountTest.java

index c952c0c9422cb3c3b47b481c8e60798a570a7f12..fcc54d8c58e1c9ffc9895262aaaf6eee652e7595 100644 (file)
@@ -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);
   }