From dce14c6722319bf447fef40fdfba8a71afc0c6cc Mon Sep 17 00:00:00 2001 From: Samarah Date: Fri, 5 Jan 2024 14:47:29 +0000 Subject: [PATCH] test/redis: Remove temporary boost.redis test program Signed-off-by: Samarah --- src/test/rgw/CMakeLists.txt | 18 ---- src/test/rgw/test_boost_redis.cc | 163 ------------------------------- 2 files changed, 181 deletions(-) delete mode 100644 src/test/rgw/test_boost_redis.cc diff --git a/src/test/rgw/CMakeLists.txt b/src/test/rgw/CMakeLists.txt index 8e19e75be59a2..64dfb28c8bfcd 100644 --- a/src/test/rgw/CMakeLists.txt +++ b/src/test/rgw/CMakeLists.txt @@ -71,24 +71,6 @@ target_link_libraries(ceph_test_rgw_redis_driver PRIVATE ) target_link_libraries(ceph_test_rgw_redis_driver PRIVATE spawn) install(TARGETS ceph_test_rgw_redis_driver DESTINATION ${CMAKE_INSTALL_BINDIR}) - -# remove later -Sam -add_executable(test_boost_redis - test_boost_redis.cc - ) -target_include_directories(test_boost_redis - PUBLIC "${CMAKE_SOURCE_DIR}/src/dmclock/support/src" - SYSTEM PRIVATE "${CMAKE_SOURCE_DIR}/src/rgw/driver/d4n") -target_link_libraries(test_boost_redis PRIVATE - rgw_common - librados - ceph-common - ${rgw_libs} - ${UNITTEST_LIBS} - ${EXTRALIBS} - ) - target_link_libraries(test_boost_redis PRIVATE spawn) -install(TARGETS test_boost_redis DESTINATION ${CMAKE_INSTALL_BINDIR}) endif() #unittest_rgw_bencode diff --git a/src/test/rgw/test_boost_redis.cc b/src/test/rgw/test_boost_redis.cc deleted file mode 100644 index 8ec5f01acf51c..0000000000000 --- a/src/test/rgw/test_boost_redis.cc +++ /dev/null @@ -1,163 +0,0 @@ -#include -#include - -#include -#include -#include - -namespace net = boost::asio; -using boost::redis::config; -using boost::redis::connection; -using boost::redis::request; -using boost::redis::response; - -class ConnectionFixture: public ::testing::Test { - protected: - virtual void SetUp() { - conn = new connection{io}; - - /* Run context */ - using Executor = net::io_context::executor_type; - using Work = net::executor_work_guard; - work = new std::optional(io.get_executor()); - worker = new std::thread([&] { io.run(); }); - - config cfg; - cfg.addr.host = "127.0.0.1"; - cfg.addr.port = "6379"; - - conn->async_run(cfg, {}, net::detached); - } - - virtual void TearDown() { - io.stop(); - - delete conn; - delete work; - delete worker; - } - - net::io_context io; - connection* conn; - - using Executor = net::io_context::executor_type; - using Work = net::executor_work_guard; - std::optional* work; - std::thread* worker; -}; - -TEST_F(ConnectionFixture, Ping) { - ASSERT_NE(conn, nullptr); - - request req; - req.push("PING", "Hello world"); - - response resp; - - conn->async_exec(req, resp, [&](auto ec, auto) { - ASSERT_EQ((bool)ec, 0); - EXPECT_EQ(std::get<0>(resp).value(), "Hello world"); - - conn->cancel(); - }); - - *work = std::nullopt; - worker->join(); -} - -TEST_F(ConnectionFixture, HMSet) { - request req; - response resp; - - req.push("HMSET", "key", "data", "value"); - - conn->async_exec(req, resp, [&](auto ec, auto) { - ASSERT_EQ((bool)ec, 0); - EXPECT_EQ(std::get<0>(resp).value(), "OK"); - - conn->cancel(); - }); - - *work = std::nullopt; - worker->join(); -} - -TEST_F(ConnectionFixture, HGETALL) { - request req; - response > resp; - - req.push("HMSET", "key", "data", "value"); - req.push("HGETALL", "key"); - - conn->async_exec(req, resp, [&](auto ec, auto) { - ASSERT_EQ((bool)ec, 0); - EXPECT_EQ(std::get<0>(resp).value(), "OK"); - EXPECT_EQ(std::get<1>(resp).value().size(), 1); - - conn->cancel(); - }); - - *work = std::nullopt; - worker->join(); -} - -TEST_F(ConnectionFixture, HMGET) { - request req; - response > resp; - - req.push("HMSET", "key", "data", "value"); - req.push("HMGET", "key", "data"); - - conn->async_exec(req, resp, [&](auto ec, auto) { - ASSERT_EQ((bool)ec, 0); - EXPECT_EQ(std::get<0>(resp).value(), "OK"); - EXPECT_EQ(std::get<1>(resp).value()[0], "value"); - - conn->cancel(); - }); - - *work = std::nullopt; - worker->join(); -} - -TEST_F(ConnectionFixture, HSET) { - request req; - response resp; - - req.push_range("HSET", "key", std::map{{"field", "value"}}); - - conn->async_exec(req, resp, [&](auto ec, auto) { - ASSERT_EQ((bool)ec, 0); - EXPECT_EQ(std::get<0>(resp).value(), 1); - - conn->cancel(); - }); - - *work = std::nullopt; - worker->join(); -} - -TEST_F(ConnectionFixture, FLUSHALL) { - request req; - response resp; - - req.push("HMSET", "key", "data", "value"); - req.push("FLUSHALL"); - - conn->async_exec(req, resp, [&](auto ec, auto) { - ASSERT_EQ((bool)ec, 0); - EXPECT_EQ(std::get<0>(resp).value(), "OK"); - - conn->cancel(); - }); - - *work = std::nullopt; - worker->join(); -} - -int main(int argc, char *argv[]) { - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} -- 2.39.5