~ubuntu-branches/debian/jessie/ceph/jessie

« back to all changes in this revision

Viewing changes to .pc/firefly-post-release.patch/src/test/librados/pool.cc

  • Committer: Package Import Robot
  • Author(s): Dmitry Smirnov
  • Date: 2014-07-18 02:33:39 UTC
  • mfrom: (1.2.17)
  • Revision ID: package-import@ubuntu.com-20140718023339-03jdyr6dxl2hx00y
Tags: 0.80.4-1
* New upstream release [July 2014].
* New patches:
  + rbdmap1-mount.patch
  + rbdmap2-hooks.patch
  + rbdmap3-lazyumount.patch
  + bug-8821.patch
* radosgw: removed unused lintian overrides.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include "include/rados/librados.h"
2
 
#include "test/librados/test.h"
3
 
 
4
 
#include "gtest/gtest.h"
5
 
#include <errno.h>
6
 
#include <vector>
7
 
 
8
 
#define POOL_LIST_BUF_SZ 32768
9
 
 
10
 
TEST(LibRadosPools, PoolList) {
11
 
  std::vector<char> pool_list_buf(POOL_LIST_BUF_SZ, '\0');
12
 
  char *buf = &pool_list_buf[0];
13
 
  rados_t cluster;
14
 
  std::string pool_name = get_temp_pool_name();
15
 
  ASSERT_EQ("", create_one_pool(pool_name, &cluster));
16
 
  ASSERT_LT(rados_pool_list(cluster, buf, POOL_LIST_BUF_SZ), POOL_LIST_BUF_SZ);
17
 
 
18
 
  bool found_pool = false;
19
 
  while (buf[0] != '\0') {
20
 
    if ((found_pool == false) && (strcmp(buf, pool_name.c_str()) == 0)) {
21
 
      found_pool = true;
22
 
    }
23
 
    buf += strlen(buf) + 1;
24
 
  }
25
 
  ASSERT_EQ(found_pool, true);
26
 
  ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
27
 
}
28
 
 
29
 
int64_t rados_pool_lookup(rados_t cluster, const char *pool_name);
30
 
 
31
 
TEST(LibRadosPools, PoolLookup) {
32
 
  rados_t cluster;
33
 
  std::string pool_name = get_temp_pool_name();
34
 
  ASSERT_EQ("", create_one_pool(pool_name, &cluster));
35
 
  ASSERT_LT(0, rados_pool_lookup(cluster, pool_name.c_str()));
36
 
  ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
37
 
}
38
 
 
39
 
TEST(LibRadosPools, PoolLookup2) {
40
 
  rados_t cluster;
41
 
  std::string pool_name = get_temp_pool_name();
42
 
  ASSERT_EQ("", create_one_pool(pool_name, &cluster));
43
 
  int64_t pool_id = rados_pool_lookup(cluster, pool_name.c_str());
44
 
  ASSERT_GT(pool_id, 0);
45
 
  rados_ioctx_t ioctx;
46
 
  ASSERT_EQ(0, rados_ioctx_create(cluster, pool_name.c_str(), &ioctx));
47
 
  int64_t pool_id2 = rados_ioctx_get_id(ioctx);
48
 
  ASSERT_EQ(pool_id, pool_id2);
49
 
  rados_ioctx_destroy(ioctx);
50
 
  ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
51
 
}
52
 
 
53
 
TEST(LibRadosPools, PoolDelete) {
54
 
  rados_t cluster;
55
 
  std::string pool_name = get_temp_pool_name();
56
 
  ASSERT_EQ("", create_one_pool(pool_name, &cluster));
57
 
  ASSERT_EQ(0, rados_pool_delete(cluster, pool_name.c_str()));
58
 
  ASSERT_GT(0, rados_pool_lookup(cluster, pool_name.c_str()));
59
 
  ASSERT_EQ(0, rados_pool_create(cluster, pool_name.c_str()));
60
 
  ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
61
 
}
62
 
 
63
 
TEST(LibRadosPools, PoolCreateDelete) {
64
 
  rados_t cluster;
65
 
  std::string pool_name = get_temp_pool_name();
66
 
  ASSERT_EQ("", create_one_pool(pool_name, &cluster));
67
 
 
68
 
  std::string n = pool_name + "abc123";
69
 
  ASSERT_EQ(0, rados_pool_create(cluster, n.c_str()));
70
 
  ASSERT_EQ(-EEXIST, rados_pool_create(cluster, n.c_str()));
71
 
  ASSERT_EQ(0, rados_pool_delete(cluster, n.c_str()));
72
 
  ASSERT_EQ(-ENOENT, rados_pool_delete(cluster, n.c_str()));
73
 
 
74
 
  ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
75
 
}
76
 
 
77
 
TEST(LibRadosPools, PoolCreateWithCrushRule) {
78
 
  rados_t cluster;
79
 
  std::string pool_name = get_temp_pool_name();
80
 
  ASSERT_EQ("", create_one_pool(pool_name, &cluster));
81
 
 
82
 
  std::string pool2_name = get_temp_pool_name();
83
 
  ASSERT_EQ(0, rados_pool_create_with_crush_rule(cluster,
84
 
                            pool2_name.c_str(), 0));
85
 
  ASSERT_EQ(0, rados_pool_delete(cluster, pool2_name.c_str()));
86
 
 
87
 
  std::string pool3_name = get_temp_pool_name();
88
 
  ASSERT_EQ(0, rados_pool_create_with_all(cluster, pool3_name.c_str(),
89
 
                                          456ull, 0));
90
 
  rados_ioctx_t ioctx;
91
 
  ASSERT_EQ(0, rados_ioctx_create(cluster, pool3_name.c_str(), &ioctx));
92
 
  uint64_t auid;
93
 
  ASSERT_EQ(0, rados_ioctx_pool_get_auid(ioctx, &auid));
94
 
  ASSERT_EQ(456ull, auid);
95
 
  ASSERT_EQ(0, rados_pool_delete(cluster, pool3_name.c_str()));
96
 
  rados_ioctx_destroy(ioctx);
97
 
  ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
98
 
}