struct cache_test_t : public seastar_test_suite_t {
segment_manager::EphemeralSegmentManagerRef segment_manager;
- InterruptedCacheRef ref;
- InterruptedCache &cache;
+ Cache cache;
paddr_t current{0, 0};
journal_seq_t seq;
cache_test_t()
: segment_manager(segment_manager::create_test_ephemeral()),
- ref(std::make_unique<Cache>(*segment_manager)),
- cache(*ref) {}
+ cache(*segment_manager) {}
seastar::future<std::optional<paddr_t>> submit_transaction(
TransactionRef t) {
return cache.create_transaction();
}
+ template <typename T, typename... Args>
+ auto get_extent(Transaction &t, Args&&... args) {
+ return with_trans_intr(
+ t,
+ [this](auto &&... args) {
+ return cache.get_extent<T>(args...);
+ },
+ std::forward<Args>(args)...);
+ }
+
seastar::future<> set_up_fut() final {
return segment_manager->init(
).safe_then(
}
{
auto t = get_transaction();
- auto extent = cache.get_extent<TestBlockPhysical>(
+ auto extent = get_extent<TestBlockPhysical>(
*t,
addr,
TestBlockPhysical::SIZE).unsafe_get0();
{
// test that read with same transaction sees new block though
// uncommitted
- auto extent = cache.get_extent<TestBlockPhysical>(
+ auto extent = get_extent<TestBlockPhysical>(
*t,
reladdr,
TestBlockPhysical::SIZE).unsafe_get0();
{
// test that consecutive reads on the same extent get the same ref
auto t = get_transaction();
- auto extent = cache.get_extent<TestBlockPhysical>(
+ auto extent = get_extent<TestBlockPhysical>(
*t,
addr,
TestBlockPhysical::SIZE).unsafe_get0();
auto t2 = get_transaction();
- auto extent2 = cache.get_extent<TestBlockPhysical>(
+ auto extent2 = get_extent<TestBlockPhysical>(
*t2,
addr,
TestBlockPhysical::SIZE).unsafe_get0();
{
// read back test block
auto t = get_transaction();
- auto extent = cache.get_extent<TestBlockPhysical>(
+ auto extent = get_extent<TestBlockPhysical>(
*t,
addr,
TestBlockPhysical::SIZE).unsafe_get0();
// test that concurrent read with fresh transaction sees old
// block
auto t2 = get_transaction();
- auto extent = cache.get_extent<TestBlockPhysical>(
+ auto extent = get_extent<TestBlockPhysical>(
*t2,
addr,
TestBlockPhysical::SIZE).unsafe_get0();
}
{
// test that read with same transaction sees new block
- auto extent = cache.get_extent<TestBlockPhysical>(
+ auto extent = get_extent<TestBlockPhysical>(
*t,
addr,
TestBlockPhysical::SIZE).unsafe_get0();
{
// test that fresh transaction now sees newly dirty block
auto t = get_transaction();
- auto extent = cache.get_extent<TestBlockPhysical>(
+ auto extent = get_extent<TestBlockPhysical>(
*t,
addr,
TestBlockPhysical::SIZE).unsafe_get0();