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.
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 {
} 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);
}