add_ceph_unittest(unittest_rgw_putobj)
target_link_libraries(unittest_rgw_putobj ${rgw_libs} ${UNITTEST_LIBS})
-add_executable(ceph_test_rgw_throttle
- test_rgw_throttle.cc
- $<TARGET_OBJECTS:unit-main>)
-target_link_libraries(ceph_test_rgw_throttle ${rgw_libs}
- librados global ${UNITTEST_LIBS})
-install(TARGETS ceph_test_rgw_throttle DESTINATION ${CMAKE_INSTALL_BINDIR})
+add_executable(unittest_rgw_throttle test_rgw_throttle.cc)
+add_ceph_unittest(unittest_rgw_throttle)
+target_link_libraries(unittest_rgw_throttle ${rgw_libs} ${UNITTEST_LIBS})
add_executable(unittest_rgw_iam_policy test_rgw_iam_policy.cc)
add_ceph_unittest(unittest_rgw_iam_policy)
#include <spawn/spawn.hpp>
#include <gtest/gtest.h>
-struct RadosEnv : public ::testing::Environment {
- public:
- static constexpr auto poolname = "ceph_test_rgw_throttle";
-
- static std::optional<RGWSI_RADOS> rados;
-
- void SetUp() override {
- rados.emplace(g_ceph_context);
- const NoDoutPrefix no_dpp(g_ceph_context, 1);
- ASSERT_EQ(0, rados->start(null_yield, &no_dpp));
- int r = rados->pool({poolname}).create(&no_dpp);
- if (r == -EEXIST)
- r = 0;
- ASSERT_EQ(0, r);
- }
- void TearDown() override {
- ASSERT_EQ(0, rados->get_rados_handle()->pool_delete(poolname));
- rados->shutdown();
- rados.reset();
- }
-};
-std::optional<RGWSI_RADOS> RadosEnv::rados;
-
-auto *const rados_env = ::testing::AddGlobalTestEnvironment(new RadosEnv);
-
-// test fixture for global setup/teardown
-class RadosFixture : public ::testing::Test {
- protected:
- RGWSI_RADOS::Obj make_obj(const std::string& oid) {
- auto obj = RadosEnv::rados->obj({{RadosEnv::poolname}, oid});
- const NoDoutPrefix no_dpp(g_ceph_context, 1);
- ceph_assert_always(0 == obj.open(&no_dpp));
- return obj;
- }
-};
-
-using Aio_Throttle = RadosFixture;
+static rgw_raw_obj make_obj(const std::string& oid)
+{
+ return {{"testpool"}, oid};
+}
namespace rgw {
};
}
-TEST_F(Aio_Throttle, NoThrottleUpToMax)
+TEST(Aio_Throttle, NoThrottleUpToMax)
{
BlockingAioThrottle throttle(4);
auto obj = make_obj(__PRETTY_FUNCTION__);
}
}
-TEST_F(Aio_Throttle, CostOverWindow)
+TEST(Aio_Throttle, CostOverWindow)
{
BlockingAioThrottle throttle(4);
auto obj = make_obj(__PRETTY_FUNCTION__);
EXPECT_EQ(-EDEADLK, c.front().result);
}
-TEST_F(Aio_Throttle, ThrottleOverMax)
+TEST(Aio_Throttle, ThrottleOverMax)
{
constexpr uint64_t window = 4;
BlockingAioThrottle throttle(window);
EXPECT_EQ(window, max_outstanding);
}
-TEST_F(Aio_Throttle, YieldCostOverWindow)
+TEST(Aio_Throttle, YieldCostOverWindow)
{
auto obj = make_obj(__PRETTY_FUNCTION__);
context.run();
}
-TEST_F(Aio_Throttle, YieldingThrottleOverMax)
+TEST(Aio_Throttle, YieldingThrottleOverMax)
{
constexpr uint64_t window = 4;