diff options
author | Matan Breizman <mbreizma@redhat.com> | 2024-01-15 15:47:00 +0100 |
---|---|---|
committer | Matan Breizman <mbreizma@redhat.com> | 2024-01-17 12:05:46 +0100 |
commit | 73b5e8c15dacc763489fd307c93ae45cd2c67aa6 (patch) | |
tree | 1e4b5266b47ff23c11c046663f3c41931fb0ddd0 | |
parent | test/neorados/aio_cxx: Seperate NeoRadosECTest from NeoRadosTest (diff) | |
download | ceph-73b5e8c15dacc763489fd307c93ae45cd2c67aa6.tar.xz ceph-73b5e8c15dacc763489fd307c93ae45cd2c67aa6.zip |
test/neorados/list: Seperate NeoRadosECTest from NeoRadosTest
otherwise SKIP_IF_CRIMSON won't work in this case
Signed-off-by: Matan Breizman <mbreizma@redhat.com>
-rwxr-xr-x | qa/workunits/rados/test.sh | 10 | ||||
-rw-r--r-- | src/test/neorados/CMakeLists.txt | 16 | ||||
-rw-r--r-- | src/test/neorados/ec_list.cc | 148 | ||||
-rw-r--r-- | src/test/neorados/list.cc | 94 |
4 files changed, 170 insertions, 98 deletions
diff --git a/qa/workunits/rados/test.sh b/qa/workunits/rados/test.sh index e64fc488a2d..c6bcca1f0af 100755 --- a/qa/workunits/rados/test.sh +++ b/qa/workunits/rados/test.sh @@ -53,7 +53,7 @@ do done for f in \ - cls cmd handler_error io ec_io list misc pool read_operations snapshots \ + cls cmd handler_error io ec_io list ec_list misc pool read_operations snapshots \ watch_notify write_operations do if [ $parallel -eq 1 ]; then @@ -64,9 +64,11 @@ do echo "test $f on pid $pid" pids[$f]=$pid else - if [ $crimson -eq 1 ] && [ $f = "ec_io" ]; then - echo "Skipping EC with Crimson" - continue + if [ $crimson -eq 1 ]; then + if [ $f = "ec_io" ] || [ $f = "ec_list" ]; then + echo "Skipping EC with Crimson" + continue + fi fi ceph_test_neorados_$f fi diff --git a/src/test/neorados/CMakeLists.txt b/src/test/neorados/CMakeLists.txt index 62937f5c077..968ef609cdc 100644 --- a/src/test/neorados/CMakeLists.txt +++ b/src/test/neorados/CMakeLists.txt @@ -154,6 +154,22 @@ install(TARGETS ceph_test_neorados_list DESTINATION ${CMAKE_INSTALL_BINDIR}) +add_executable(ceph_test_neorados_ec_list + ec_list.cc + ) +target_link_libraries(ceph_test_neorados_ec_list + libneorados + ${BLKID_LIBRARIES} + ${CMAKE_DL_LIBS} + ${CRYPTO_LIBS} + ${EXTRALIBS} + neoradostest-support + ${UNITTEST_LIBS} + ) +install(TARGETS + ceph_test_neorados_ec_list + DESTINATION ${CMAKE_INSTALL_BINDIR}) + add_executable(ceph_test_neorados_misc misc.cc ) diff --git a/src/test/neorados/ec_list.cc b/src/test/neorados/ec_list.cc new file mode 100644 index 00000000000..5a4b76179db --- /dev/null +++ b/src/test/neorados/ec_list.cc @@ -0,0 +1,148 @@ +// -*- 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) 2023 IBM + * + * See file COPYING for license information. + * + */ + +#include <coroutine> +#include <cstdint> +#include <tuple> +#include <utility> +#include <vector> + +#include <boost/asio/awaitable.hpp> +#include <boost/asio/use_awaitable.hpp> + +#include <boost/container/flat_set.hpp> + +#include <fmt/format.h> + +#include "include/neorados/RADOS.hpp" + +#include "test/neorados/common_tests.h" + +#include "gtest/gtest.h" + +namespace asio = boost::asio; +namespace container = boost::container; + +using namespace std::literals; + +using neorados::Cursor; +using neorados::IOContext; +using neorados::WriteOp; + +using Entries = std::vector<neorados::Entry>; +using REntries = container::flat_set<neorados::Entry>; + +asio::awaitable<void> populate(neorados::RADOS& rados, const IOContext& pool, + const REntries& entries) { + for (const auto& entry : entries) { + co_await ::create_obj(rados, entry.oid, pool, asio::use_awaitable); + } + co_return; +}; + +void compare(const REntries& ref, const Entries& res) { + EXPECT_EQ(ref.size(), res.size()); + for (const auto& e : res) { + EXPECT_TRUE(ref.contains(e)); + } + return; +}; + +CORO_TEST_F(NeoradosECList, ListObjects, NeoRadosECTest) { + static constexpr auto oid = "foo"; + co_await execute(oid, WriteOp{}.create(true)); + auto [entries, cursor] = co_await + rados().enumerate_objects(pool(), Cursor::begin(), Cursor::end(), 1'000, {}, + asio::use_awaitable); + + EXPECT_EQ(1, entries.size()); + EXPECT_EQ(oid, entries.front().oid); + co_return; +} + +CORO_TEST_F(NeoradosECList, ListObjectsNS, NeoRadosECTest) { + auto pdef = pool(); + IOContext p1{pool().get_pool(), "ns1"}; + IOContext p2{pool().get_pool(), "ns2"}; + IOContext pall{pool().get_pool(), neorados::all_nspaces}; + + neorados::Entry meow{.oid="foo1"s}; + REntries def{ + {.oid = "foo1"s}, + {.oid = "foo2"s}, + {.oid = "foo3"s} + }; + REntries ns1{ + {.nspace = "ns1"s, .oid = "foo1"s}, + {.nspace = "ns1"s, .oid = "foo4"s}, + {.nspace = "ns1"s, .oid = "foo5"s}, + {.nspace = "ns1"s, .oid = "foo6"s}, + {.nspace = "ns1"s, .oid = "foo7"s} + }; + REntries ns2{ + {.nspace = "ns2"s, .oid = "foo6"s}, + {.nspace = "ns2"s, .oid = "foo7"s} + }; + REntries all{def}; + all.insert(ns1.begin(), ns1.end()); + all.insert(ns2.begin(), ns2.end()); + + co_await populate(rados(), pdef, def); + co_await populate(rados(), p1, ns1); + co_await populate(rados(), p2, ns2); + + auto [resdef, cdef] = co_await + rados().enumerate_objects(pdef, Cursor::begin(), Cursor::end(), 1'000, {}, + asio::use_awaitable); + auto [res1, c1] = co_await + rados().enumerate_objects(p1, Cursor::begin(), Cursor::end(), 1'000, {}, + asio::use_awaitable); + auto [res2, c2] = co_await + rados().enumerate_objects(p2, Cursor::begin(), Cursor::end(), 1'000, {}, + asio::use_awaitable); + auto [resall, call] = co_await + rados().enumerate_objects(pall, Cursor::begin(), Cursor::end(), 1'000, {}, + asio::use_awaitable); + + compare(def, resdef); + compare(ns1, res1); + compare(ns2, res2); + compare(all, resall); + + co_return; +} + +CORO_TEST_F(NeoradosECList, ListObjectsMany, NeoRadosECTest) { + REntries ref; + for (auto i = 0u; i < 512; ++i) { + ref.insert({.oid = fmt::format("{:0>3}", i)}); + } + co_await populate(rados(), pool(), ref); + REntries res; + { + Cursor c; + Entries e; + static constexpr auto per = 10; + e.reserve(per); + while (c != Cursor::end()) { + std::tie(e, c) = co_await + rados().enumerate_objects(pool(), c, Cursor::end(), per, {}, + asio::use_awaitable); + for (auto&& n : e) { + res.insert(std::move(n)); + } + e.clear(); + } + } + EXPECT_EQ(ref, res); + + co_return; +} diff --git a/src/test/neorados/list.cc b/src/test/neorados/list.cc index 56cc042a2b8..bcfafc2c4e9 100644 --- a/src/test/neorados/list.cc +++ b/src/test/neorados/list.cc @@ -151,97 +151,3 @@ CORO_TEST_F(NeoradosList, ListObjectsMany, NeoRadosTest) { // Sadly I don't think there's a good way to templatize testcases over // fixture. - -CORO_TEST_F(NeoradosECList, ListObjects, NeoRadosECTest) { - SKIP_IF_CRIMSON(); - static constexpr auto oid = "foo"; - co_await execute(oid, WriteOp{}.create(true)); - auto [entries, cursor] = co_await - rados().enumerate_objects(pool(), Cursor::begin(), Cursor::end(), 1'000, {}, - asio::use_awaitable); - - EXPECT_EQ(1, entries.size()); - EXPECT_EQ(oid, entries.front().oid); - co_return; -} - -CORO_TEST_F(NeoradosECList, ListObjectsNS, NeoRadosECTest) { - SKIP_IF_CRIMSON(); - auto pdef = pool(); - IOContext p1{pool().get_pool(), "ns1"}; - IOContext p2{pool().get_pool(), "ns2"}; - IOContext pall{pool().get_pool(), neorados::all_nspaces}; - - neorados::Entry meow{.oid="foo1"s}; - REntries def{ - {.oid = "foo1"s}, - {.oid = "foo2"s}, - {.oid = "foo3"s} - }; - REntries ns1{ - {.nspace = "ns1"s, .oid = "foo1"s}, - {.nspace = "ns1"s, .oid = "foo4"s}, - {.nspace = "ns1"s, .oid = "foo5"s}, - {.nspace = "ns1"s, .oid = "foo6"s}, - {.nspace = "ns1"s, .oid = "foo7"s} - }; - REntries ns2{ - {.nspace = "ns2"s, .oid = "foo6"s}, - {.nspace = "ns2"s, .oid = "foo7"s} - }; - REntries all{def}; - all.insert(ns1.begin(), ns1.end()); - all.insert(ns2.begin(), ns2.end()); - - co_await populate(rados(), pdef, def); - co_await populate(rados(), p1, ns1); - co_await populate(rados(), p2, ns2); - - auto [resdef, cdef] = co_await - rados().enumerate_objects(pdef, Cursor::begin(), Cursor::end(), 1'000, {}, - asio::use_awaitable); - auto [res1, c1] = co_await - rados().enumerate_objects(p1, Cursor::begin(), Cursor::end(), 1'000, {}, - asio::use_awaitable); - auto [res2, c2] = co_await - rados().enumerate_objects(p2, Cursor::begin(), Cursor::end(), 1'000, {}, - asio::use_awaitable); - auto [resall, call] = co_await - rados().enumerate_objects(pall, Cursor::begin(), Cursor::end(), 1'000, {}, - asio::use_awaitable); - - compare(def, resdef); - compare(ns1, res1); - compare(ns2, res2); - compare(all, resall); - - co_return; -} - -CORO_TEST_F(NeoradosECList, ListObjectsMany, NeoRadosECTest) { - SKIP_IF_CRIMSON(); - REntries ref; - for (auto i = 0u; i < 512; ++i) { - ref.insert({.oid = fmt::format("{:0>3}", i)}); - } - co_await populate(rados(), pool(), ref); - REntries res; - { - Cursor c; - Entries e; - static constexpr auto per = 10; - e.reserve(per); - while (c != Cursor::end()) { - std::tie(e, c) = co_await - rados().enumerate_objects(pool(), c, Cursor::end(), per, {}, - asio::use_awaitable); - for (auto&& n : e) { - res.insert(std::move(n)); - } - e.clear(); - } - } - EXPECT_EQ(ref, res); - - co_return; -} |