Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / test / librados / cls.cc
1 #include "include/rados/librados.h"
2 #include "include/rados/librados.hpp"
3 #include "test/librados/test.h"
4
5 #include "gtest/gtest.h"
6 #include <errno.h>
7 #include <map>
8 #include <sstream>
9 #include <string>
10
11 using namespace librados;
12 using std::map;
13 using std::ostringstream;
14 using std::string;
15
16 TEST(LibRadosCls, DNE) {
17   Rados cluster;
18   std::string pool_name = get_temp_pool_name();
19   ASSERT_EQ("", create_one_pool_pp(pool_name, cluster));
20   IoCtx ioctx;
21   cluster.ioctx_create(pool_name.c_str(), ioctx);
22
23   // create an object
24   string oid = "foo";
25   bufferlist bl;
26   ASSERT_EQ(0, ioctx.write(oid, bl, bl.length(), 0));
27
28   // call a bogus class
29   ASSERT_EQ(-EOPNOTSUPP, ioctx.exec(oid, "doesnotexistasdfasdf", "method", bl, bl));
30
31   // call a bogus method on existent class
32   ASSERT_EQ(-EOPNOTSUPP, ioctx.exec(oid, "lock", "doesnotexistasdfasdfasdf", bl, bl));
33
34   ioctx.close();
35   ASSERT_EQ(0, destroy_one_pool_pp(pool_name, cluster));
36 }