Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / test / librados / test.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4  * Ceph - scalable distributed file system
5  *
6  * Copyright (C) 2011 New Dream Network
7  *
8  * This is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License version 2.1, as published by the Free Software
11  * Foundation.  See file COPYING.
12  *
13  */
14
15 #ifndef CEPH_TEST_RADOS_API_TEST_H
16 #define CEPH_TEST_RADOS_API_TEST_H
17
18 #include "include/rados/librados.h"
19 #include "include/rados/librados.hpp"
20
21 #include <map>
22 #include <string>
23 #include <unistd.h>
24
25 std::string get_temp_pool_name(const std::string &prefix = "test-rados-api-");
26
27 std::string create_one_pool(const std::string &pool_name, rados_t *cluster,
28     uint32_t pg_num=0);
29 std::string create_one_ec_pool(const std::string &pool_name, rados_t *cluster);
30 std::string create_one_pool_pp(const std::string &pool_name,
31                             librados::Rados &cluster);
32 std::string create_one_pool_pp(const std::string &pool_name,
33                                librados::Rados &cluster,
34                                const std::map<std::string, std::string> &config);
35 std::string create_one_ec_pool_pp(const std::string &pool_name,
36                             librados::Rados &cluster);
37 std::string connect_cluster(rados_t *cluster);
38 std::string connect_cluster_pp(librados::Rados &cluster);
39 std::string connect_cluster_pp(librados::Rados &cluster,
40                                const std::map<std::string, std::string> &config);
41 int destroy_one_pool(const std::string &pool_name, rados_t *cluster);
42 int destroy_one_ec_pool(const std::string &pool_name, rados_t *cluster);
43 int destroy_one_pool_pp(const std::string &pool_name, librados::Rados &cluster);
44 int destroy_one_ec_pool_pp(const std::string &pool_name, librados::Rados &cluster);
45 void assert_eq_sparse(bufferlist& expected,
46                       const std::map<uint64_t, uint64_t>& extents,
47                       bufferlist& actual);
48
49 class TestAlarm
50 {
51 public:
52   TestAlarm() {
53     alarm(1200);
54   }
55   ~TestAlarm() {
56     alarm(0);
57   }
58 };
59
60 #endif