summaryrefslogtreecommitdiffstats
path: root/src/test/lazy-omap-stats/lazy_omap_stats_test.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/lazy-omap-stats/lazy_omap_stats_test.h')
-rw-r--r--src/test/lazy-omap-stats/lazy_omap_stats_test.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/test/lazy-omap-stats/lazy_omap_stats_test.h b/src/test/lazy-omap-stats/lazy_omap_stats_test.h
new file mode 100644
index 000000000..020c72c73
--- /dev/null
+++ b/src/test/lazy-omap-stats/lazy_omap_stats_test.h
@@ -0,0 +1,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