summaryrefslogtreecommitdiffstats
path: root/src/test/lazy-omap-stats/lazy_omap_stats_test.h
blob: 020c72c7358adbfef2fee886917905cc2c9c0892 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
 * Ceph - scalable distributed file system
 *
 * Copyright (C) 2019 Red Hat
 *
 * This is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1, as published by the Free Software
 * Foundation.  See file COPYING.
 *
 */

#ifndef CEPH_LAZY_OMAP_STATS_TEST_H
#define CEPH_LAZY_OMAP_STATS_TEST_H

#include <map>
#include <regex>
#include <string>

#include "include/compat.h"
#include "include/rados/librados.hpp"

struct index_t {
  unsigned byte_index = 0;
  unsigned key_index = 0;
};

class LazyOmapStatsTest
{
  librados::IoCtx io_ctx;
  librados::Rados rados;
  std::map<std::string, librados::bufferlist> payload;

  struct lazy_omap_test_t {
    unsigned payload_size = 0;
    unsigned replica_count = 3;
    unsigned keys = 2000;
    unsigned how_many = 50;
    std::string pool_name = "lazy_omap_test_pool";
    unsigned total_bytes = 0;
    unsigned total_keys = 0;
  } conf;

  LazyOmapStatsTest(LazyOmapStatsTest&) = delete;
  void operator=(LazyOmapStatsTest) = delete;
  void init(const int argc, const char** argv);
  void shutdown();
  void write_omap(const std::string& object_name);
  const std::string get_name() const;
  void create_payload();
  void write_many(const unsigned how_many);
  void scrub() const;
  const int find_matches(std::string& output, std::regex& reg) const;
  void check_one();
  const int find_index(std::string& haystack, std::regex& needle,
                       std::string label) const;
  const unsigned tally_column(const unsigned omap_bytes_index,
                          const std::string& table, bool header) const;
  void check_column(const int index, const std::string& table,
                    const std::string& type, bool header = true) const;
  index_t get_indexes(std::regex& reg, std::string& output) const;
  const std::string get_pool_id(std::string& pool);
  void check_pg_dump();
  void check_pg_dump_summary();
  void check_pg_dump_pgs();
  void check_pg_dump_pools();
  void check_pg_ls();
  const std::string get_output(
      const std::string command = R"({"prefix": "pg dump"})",
      const bool silent = false);
  void wait_for_active_clean();

 public:
  LazyOmapStatsTest() = default;
  const int run(const int argc, const char** argv);
};

#endif // CEPH_LAZY_OMAP_STATS_TEST_H