From e6918187568dbd01842d8d1d2c808ce16a894239 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 21 Apr 2024 13:54:28 +0200 Subject: Adding upstream version 18.2.2. Signed-off-by: Daniel Baumann --- src/test/rgw/bench_rgw_ratelimit_gc.cc | 52 ++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/test/rgw/bench_rgw_ratelimit_gc.cc (limited to 'src/test/rgw/bench_rgw_ratelimit_gc.cc') diff --git a/src/test/rgw/bench_rgw_ratelimit_gc.cc b/src/test/rgw/bench_rgw_ratelimit_gc.cc new file mode 100644 index 000000000..ae422e1da --- /dev/null +++ b/src/test/rgw/bench_rgw_ratelimit_gc.cc @@ -0,0 +1,52 @@ +#include "rgw_ratelimit.h" +#include "rgw_common.h" +#include "random" +#include +#include +#include +#include +int main(int argc, char **argv) +{ + int num_qos_classes = 1; + try + { + using namespace boost::program_options; + options_description desc{"Options"}; + desc.add_options() + ("help,h", "Help screen") + ("num_qos_classes", value()->default_value(1), "how many qos tenants"); + variables_map vm; + store(parse_command_line(argc, argv, desc), vm); + if (vm.count("help")) { + std::cout << desc << std::endl; + return EXIT_SUCCESS; + } + num_qos_classes = vm["num_qos_classes"].as(); + } + catch (const boost::program_options::error &ex) + { + std::cerr << ex.what() << std::endl; + return EXIT_FAILURE; + } + RGWRateLimitInfo info; + info.enabled = true; + info.max_read_bytes = 0; + info.max_write_bytes = 0; + info.max_read_ops = 0; + info.max_write_ops = 0; + std::unique_ptr cct = std::make_unique(CEPH_ENTITY_TYPE_ANY); + if (!g_ceph_context) + { + g_ceph_context = cct.get(); + } + std::shared_ptr ratelimit(new ActiveRateLimiter(g_ceph_context)); + ratelimit->start(); + auto dout = DoutPrefix(g_ceph_context, ceph_subsys_rgw, "rate limiter: "); + for(int i = 0; i < num_qos_classes; i++) + { + std::string tenant = "uuser" + std::to_string(i); + auto time = ceph::coarse_real_clock::now(); + ratelimit->get_active()->should_rate_limit("PUT", tenant, time, &info); + } + +} -- cgit v1.2.3