summaryrefslogtreecommitdiffstats
path: root/src/test/cls_fifo/test_cls_fifo.cc
blob: 484248c0c81ca3178df8ae4c5e234ab9c0f305ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
// -*- 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) 2019 Red Hat, Inc.
 *
 * This is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1, as published by the Free Software
 * Foundation.  See file COPYING.
 *
 */

#include <cerrno>
#include <iostream>
#include <string_view>

#include <boost/asio.hpp>
#include <boost/system/error_code.hpp>

#include <spawn/spawn.hpp>

#include "include/scope_guard.h"
#include "include/types.h"
#include "include/neorados/RADOS.hpp"

#include "cls/fifo/cls_fifo_ops.h"

#include "neorados/cls/fifo.h"

#include "test/neorados/common_tests.h"

#include "gtest/gtest.h"

namespace R = neorados;
namespace ba = boost::asio;
namespace bs = boost::system;
namespace cb = ceph::buffer;
namespace fifo = rados::cls::fifo;
namespace RCf = neorados::cls::fifo;
namespace s = spawn;

namespace {
void fifo_create(R::RADOS& r,
		 const R::IOContext& ioc,
		 const R::Object& oid,
		 std::string_view id,
		 s::yield_context y,
		 std::optional<fifo::objv> objv = std::nullopt,
		 std::optional<std::string_view> oid_prefix = std::nullopt,
		 bool exclusive = false,
		 std::uint64_t max_part_size = RCf::default_max_part_size,
		 std::uint64_t max_entry_size = RCf::default_max_entry_size)
{
  R::WriteOp op;
  RCf::create_meta(op, id, objv, oid_prefix, exclusive, max_part_size,
		   max_entry_size);
  r.execute(oid, ioc, std::move(op), y);
}
}

TEST(ClsFIFO, TestCreate) {
  ba::io_context c;
  auto fifo_id = "fifo"sv;
  R::Object oid(fifo_id);

  s::spawn(c, [&](s::yield_context y) {
		auto r = R::RADOS::Builder{}.build(c, y);
		auto pool = create_pool(r, get_temp_pool_name(), y);
		auto sg = make_scope_guard(
		  [&] {
		    r.delete_pool(pool, y);
		  });
		R::IOContext ioc(pool);
		bs::error_code ec;
		fifo_create(r, ioc, oid, ""s, y[ec]);
		EXPECT_EQ(bs::errc::invalid_argument, ec);
		fifo_create(r, ioc, oid, fifo_id, y[ec], std::nullopt,
			    std::nullopt, false, 0);
		EXPECT_EQ(bs::errc::invalid_argument, ec);
		fifo_create(r, ioc, oid, {}, y[ec],
			    std::nullopt, std::nullopt,
			    false, RCf::default_max_part_size, 0);
		EXPECT_EQ(bs::errc::invalid_argument, ec);
		fifo_create(r, ioc, oid, fifo_id, y);
		{
		  std::uint64_t size;
		  std::uint64_t size2;
		  {
		    R::ReadOp op;
		    op.stat(&size, nullptr);
		    r.execute(oid, ioc, std::move(op),
			      nullptr, y);
		    EXPECT_GT(size, 0);
		  }

		  {
		    R::ReadOp op;
		    op.stat(&size2, nullptr);
		    r.execute(oid, ioc, std::move(op), nullptr, y);
		  }
		  EXPECT_EQ(size2, size);
		}
		/* test idempotency */
		fifo_create(r, ioc, oid, fifo_id, y);
		fifo_create(r, ioc, oid, {}, y[ec], std::nullopt,
			    std::nullopt, false);
		EXPECT_EQ(bs::errc::invalid_argument, ec);
		fifo_create(r, ioc, oid, {}, y[ec], std::nullopt,
			    "myprefix"sv, false);
		EXPECT_EQ(bs::errc::invalid_argument, ec);
		fifo_create(r, ioc, oid, "foo"sv, y[ec],
			    std::nullopt, std::nullopt, false);
		EXPECT_EQ(bs::errc::file_exists, ec);
	      });
  c.run();
}

TEST(ClsFIFO, TestGetInfo) {
  ba::io_context c;
  auto fifo_id = "fifo"sv;
  R::Object oid(fifo_id);

  s::spawn(c, [&](s::yield_context y) {
		auto r = R::RADOS::Builder{}.build(c, y);
		auto pool = create_pool(r, get_temp_pool_name(), y);
		auto sg = make_scope_guard(
		  [&] {
		    r.delete_pool(pool, y);
		  });
		R::IOContext ioc(pool);
		/* first successful create */
		fifo_create(r, ioc, oid, fifo_id, y);

		fifo::info info;
		std::uint32_t part_header_size;
		std::uint32_t part_entry_overhead;
		{
		  R::ReadOp op;
		  RCf::get_meta(op, std::nullopt,
				nullptr, &info, &part_header_size,
				&part_entry_overhead);
		  r.execute(oid, ioc, std::move(op), nullptr, y);
		  EXPECT_GT(part_header_size, 0);
		  EXPECT_GT(part_entry_overhead, 0);
		  EXPECT_FALSE(info.version.instance.empty());
		}
		{
		  R::ReadOp op;
		  RCf::get_meta(op, info.version,
				nullptr, &info, &part_header_size,
				&part_entry_overhead);
		  r.execute(oid, ioc, std::move(op), nullptr, y);
		}
		{
		  R::ReadOp op;
		  fifo::objv objv;
		  objv.instance = "foo";
		  objv.ver = 12;
		  RCf::get_meta(op, objv,
				nullptr, &info, &part_header_size,
				&part_entry_overhead);
		  ASSERT_ANY_THROW(r.execute(oid, ioc, std::move(op),
					     nullptr, y));
		}
	      });
  c.run();
}

TEST(FIFO, TestOpenDefault) {
  ba::io_context c;
  auto fifo_id = "fifo"s;

  s::spawn(c, [&](s::yield_context y) {
		auto r = R::RADOS::Builder{}.build(c, y);
		auto pool = create_pool(r, get_temp_pool_name(), y);
		auto sg = make_scope_guard(
		  [&] {
		    r.delete_pool(pool, y);
		  });
		R::IOContext ioc(pool);
		auto fifo = RCf::FIFO::create(r, ioc, fifo_id, y);
		// force reading from backend
		fifo->read_meta(y);
		auto info = fifo->meta();
		EXPECT_EQ(info.id, fifo_id);
	      });
  c.run();
}

TEST(FIFO, TestOpenParams) {
  ba::io_context c;
  auto fifo_id = "fifo"sv;

  s::spawn(c, [&](s::yield_context y) {
		auto r = R::RADOS::Builder{}.build(c, y);
		auto pool = create_pool(r, get_temp_pool_name(), y);
		auto sg = make_scope_guard(
		  [&] {
		    r.delete_pool(pool, y);
		  });
		R::IOContext ioc(pool);

		const std::uint64_t max_part_size = 10 * 1024;
		const std::uint64_t max_entry_size = 128;
		auto oid_prefix = "foo.123."sv;
		fifo::objv objv;
		objv.instance = "fooz"s;
		objv.ver = 10;

		/* first successful create */
		auto f = RCf::FIFO::create(r, ioc, fifo_id, y, objv, oid_prefix,
					   false, max_part_size,
					   max_entry_size);


		/* force reading from backend */
		f->read_meta(y);
		auto info = f->meta();
		ASSERT_EQ(info.id, fifo_id);
		ASSERT_EQ(info.params.max_part_size, max_part_size);
		ASSERT_EQ(info.params.max_entry_size, max_entry_size);
		ASSERT_EQ(info.version, objv);
	      });
  c.run();
}

namespace {
template<class T>
std::pair<T, std::string> decode_entry(const RCf::list_entry& entry)
{
  T val;
  auto iter = entry.data.cbegin();
  decode(val, iter);
  return std::make_pair(std::move(val), entry.marker);
}
}



TEST(FIFO, TestPushListTrim) {
  ba::io_context c;
  auto fifo_id = "fifo"sv;

  s::spawn(c, [&](s::yield_context y) mutable {
		auto r = R::RADOS::Builder{}.build(c, y);
		auto pool = create_pool(r, get_temp_pool_name(), y);
		auto sg = make_scope_guard(
		  [&] {
		    r.delete_pool(pool, y);
		  });
		R::IOContext ioc(pool);
		auto f = RCf::FIFO::create(r, ioc, fifo_id, y);
		static constexpr auto max_entries = 10u;
		for (uint32_t i = 0; i < max_entries; ++i) {
		  cb::list bl;
		  encode(i, bl);
		  f->push(bl, y);
		}

		std::optional<std::string> marker;
		/* get entries one by one */

		for (auto i = 0u; i < max_entries; ++i) {
		  auto [result, more] = f->list(1, marker, y);

		  bool expected_more = (i != (max_entries - 1));
		  ASSERT_EQ(expected_more, more);
		  ASSERT_EQ(1, result.size());

		  std::uint32_t val;
		  std::tie(val, marker) =
		    decode_entry<std::uint32_t>(result.front());

		  ASSERT_EQ(i, val);
		}

		/* get all entries at once */
		std::string markers[max_entries];
		std::uint32_t min_entry = 0;
		{
		  auto [result, more] = f->list(max_entries * 10, std::nullopt,
						y);

		  ASSERT_FALSE(more);
		  ASSERT_EQ(max_entries, result.size());


		  for (auto i = 0u; i < max_entries; ++i) {
		    std::uint32_t val;

		    std::tie(val, markers[i]) =
		      decode_entry<std::uint32_t>(result[i]);
		    ASSERT_EQ(i, val);
		  }


		  /* trim one entry */
		  f->trim(markers[min_entry], false, y);
		  ++min_entry;
		}

		auto [result, more] = f->list(max_entries * 10,
					      std::nullopt, y);

		ASSERT_FALSE(more);
		ASSERT_EQ(max_entries - min_entry, result.size());

		for (auto i = min_entry; i < max_entries; ++i) {
		  std::uint32_t val;

		  std::tie(val, markers[i - min_entry]) =
		    decode_entry<std::uint32_t>(result[i - min_entry]);
		  ASSERT_EQ(i, val);
		}

	      });
  c.run();
}


TEST(FIFO, TestPushTooBig) {
  ba::io_context c;
  auto fifo_id = "fifo"sv;
  static constexpr auto max_part_size = 2048ull;
  static constexpr auto max_entry_size = 128ull;

  s::spawn(c, [&](s::yield_context y) {
		auto r = R::RADOS::Builder{}.build(c, y);
		auto pool = create_pool(r, get_temp_pool_name(), y);
		auto sg = make_scope_guard(
		  [&] {
		    r.delete_pool(pool, y);
		  });
		R::IOContext ioc(pool);

		auto f = RCf::FIFO::create(r, ioc, fifo_id, y, std::nullopt,
					   std::nullopt, false, max_part_size,
					   max_entry_size);

		char buf[max_entry_size + 1];
		memset(buf, 0, sizeof(buf));

		cb::list bl;
		bl.append(buf, sizeof(buf));

		bs::error_code ec;
		f->push(bl, y[ec]);
		EXPECT_EQ(RCf::errc::entry_too_large, ec);
	      });
  c.run();
}


TEST(FIFO, TestMultipleParts) {
  ba::io_context c;
  auto fifo_id = "fifo"sv;
  static constexpr auto max_part_size = 2048ull;
  static constexpr auto max_entry_size = 128ull;

  s::spawn(c, [&](s::yield_context y) mutable {
		auto r = R::RADOS::Builder{}.build(c, y);
		auto pool = create_pool(r, get_temp_pool_name(), y);
		auto sg = make_scope_guard(
		  [&] {
		    r.delete_pool(pool, y);
		  });
		R::IOContext ioc(pool);

		auto f = RCf::FIFO::create(r, ioc, fifo_id, y, std::nullopt,
					   std::nullopt, false, max_part_size,
					   max_entry_size);


		char buf[max_entry_size];
		memset(buf, 0, sizeof(buf));

		const auto [part_header_size, part_entry_overhead] =
		  f->get_part_layout_info();

		const auto entries_per_part =
		  (max_part_size - part_header_size) /
		  (max_entry_size + part_entry_overhead);

		const auto max_entries = entries_per_part * 4 + 1;

		/* push enough entries */
		for (auto i = 0u; i < max_entries; ++i) {
		  cb::list bl;

		  *(int *)buf = i;
		  bl.append(buf, sizeof(buf));

		  f->push(bl, y);
		}

		auto info = f->meta();

		ASSERT_EQ(info.id, fifo_id);
		/* head should have advanced */
		ASSERT_GT(info.head_part_num, 0);


		/* list all at once */
		auto [result, more] = f->list(max_entries, std::nullopt, y);
		EXPECT_EQ(false, more);

		ASSERT_EQ(max_entries, result.size());

		for (auto i = 0u; i < max_entries; ++i) {
		  auto& bl = result[i].data;
		  ASSERT_EQ(i, *(int *)bl.c_str());
		}

		std::optional<std::string> marker;
		/* get entries one by one */

		for (auto i = 0u; i < max_entries; ++i) {
		  auto [result, more] = f->list(1, marker, y);
		  ASSERT_EQ(result.size(), 1);
		  const bool expected_more = (i != (max_entries - 1));
		  ASSERT_EQ(expected_more, more);

		  std::uint32_t val;
		  std::tie(val, marker) =
		    decode_entry<std::uint32_t>(result.front());

		  auto& entry = result.front();
		  auto& bl = entry.data;
		  ASSERT_EQ(i, *(int *)bl.c_str());
		  marker = entry.marker;
		}

		/* trim one at a time */
		marker.reset();
		for (auto i = 0u; i < max_entries; ++i) {
		  /* read single entry */
		  {
		    auto [result, more] = f->list(1, marker, y);
		    ASSERT_EQ(result.size(), 1);
		    const bool expected_more = (i != (max_entries - 1));
		    ASSERT_EQ(expected_more, more);

		    marker = result.front().marker;

		    f->trim(*marker, false, y);
		  }

		  /* check tail */
		  info = f->meta();
		  ASSERT_EQ(info.tail_part_num, i / entries_per_part);

		  /* try to read all again, see how many entries left */
		  auto [result, more] = f->list(max_entries, marker, y);
		  ASSERT_EQ(max_entries - i - 1, result.size());
		  ASSERT_EQ(false, more);
		}

		/* tail now should point at head */
		info = f->meta();
		ASSERT_EQ(info.head_part_num, info.tail_part_num);

		/* check old tails are removed */
		for (auto i = 0; i < info.tail_part_num; ++i) {
		  bs::error_code ec;
		  f->get_part_info(i, y[ec]);
		  ASSERT_EQ(bs::errc::no_such_file_or_directory, ec);
		}
		/* check current tail exists */
		f->get_part_info(info.tail_part_num, y);
	      });
  c.run();
}


TEST(FIFO, TestTwoPushers) {
  ba::io_context c;
  auto fifo_id = "fifo"sv;
  static constexpr auto max_part_size = 2048ull;
  static constexpr auto max_entry_size = 128ull;

  s::spawn(c, [&](s::yield_context y) {
		auto r = R::RADOS::Builder{}.build(c, y);
		auto pool = create_pool(r, get_temp_pool_name(), y);
		auto sg = make_scope_guard(
		  [&] {
		    r.delete_pool(pool, y);
		  });
		R::IOContext ioc(pool);

		auto f = RCf::FIFO::create(r, ioc, fifo_id, y, std::nullopt,
					   std::nullopt, false, max_part_size,
					   max_entry_size);



		char buf[max_entry_size];
		memset(buf, 0, sizeof(buf));


		auto [part_header_size, part_entry_overhead] =
		  f->get_part_layout_info();

		const auto entries_per_part =
		  (max_part_size - part_header_size) /
		  (max_entry_size + part_entry_overhead);

		const auto max_entries = entries_per_part * 4 + 1;

		auto f2 = RCf::FIFO::open(r, ioc, fifo_id, y);

		std::vector fifos{&f, &f2};

		for (auto i = 0u; i < max_entries; ++i) {
		  cb::list bl;
		  *(int *)buf = i;
		  bl.append(buf, sizeof(buf));

		  auto& f = fifos[i % fifos.size()];

		  (*f)->push(bl, y);
		}

		/* list all by both */
		{
		  auto [result, more] = f2->list(max_entries, std::nullopt, y);

		  ASSERT_EQ(false, more);
		  ASSERT_EQ(max_entries, result.size());
		}
		auto [result, more] = f2->list(max_entries, std::nullopt, y);
		ASSERT_EQ(false, more);
		ASSERT_EQ(max_entries, result.size());

		for (auto i = 0u; i < max_entries; ++i) {
		  auto& bl = result[i].data;
		  ASSERT_EQ(i, *(int *)bl.c_str());
		}
	      });
  c.run();
}


TEST(FIFO, TestTwoPushersTrim) {
  ba::io_context c;
  auto fifo_id = "fifo"sv;
  static constexpr auto max_part_size = 2048ull;
  static constexpr auto max_entry_size = 128ull;

  s::spawn(c, [&](s::yield_context y) {
		auto r = R::RADOS::Builder{}.build(c, y);
		auto pool = create_pool(r, get_temp_pool_name(), y);
		auto sg = make_scope_guard(
		  [&] {
		    r.delete_pool(pool, y);
		  });
		R::IOContext ioc(pool);

		auto f1 = RCf::FIFO::create(r, ioc, fifo_id, y, std::nullopt,
					    std::nullopt, false, max_part_size,
					    max_entry_size);

		char buf[max_entry_size];
		memset(buf, 0, sizeof(buf));


		auto [part_header_size, part_entry_overhead] =
		  f1->get_part_layout_info();

		const auto entries_per_part =
		  (max_part_size - part_header_size) /
		  (max_entry_size + part_entry_overhead);

		const auto max_entries = entries_per_part * 4 + 1;

		auto f2 = RCf::FIFO::open(r, ioc, fifo_id, y);

		/* push one entry to f2 and the rest to f1 */

		for (auto i = 0u; i < max_entries; ++i) {
		  cb::list bl;

		  *(int *)buf = i;
		  bl.append(buf, sizeof(buf));

		  auto f = (i < 1 ? &f2 : &f1);
		  (*f)->push(bl, y);
		}

		/* trim half by fifo1 */
		auto num = max_entries / 2;

		std::string marker;
		{
		  auto [result, more] = f1->list(num, std::nullopt, y);

		  ASSERT_EQ(true, more);
		  ASSERT_EQ(num, result.size());

		  for (auto i = 0u; i < num; ++i) {
		    auto& bl = result[i].data;
		    ASSERT_EQ(i, *(int *)bl.c_str());
		  }

		  auto& entry = result[num - 1];
		  marker = entry.marker;

		  f1->trim(marker, false, y);

		  /* list what's left by fifo2 */

		}

		const auto left = max_entries - num;
		auto [result, more] = f2->list(left, marker, y);
		ASSERT_EQ(left, result.size());
		ASSERT_EQ(false, more);

		for (auto i = num; i < max_entries; ++i) {
		  auto& bl = result[i - num].data;
		  ASSERT_EQ(i, *(int *)bl.c_str());
		}
	      });
  c.run();
}

TEST(FIFO, TestPushBatch) {
  ba::io_context c;
  auto fifo_id = "fifo"sv;
  static constexpr auto max_part_size = 2048ull;
  static constexpr auto max_entry_size = 128ull;

  s::spawn(c, [&](s::yield_context y) {
		auto r = R::RADOS::Builder{}.build(c, y);
		auto pool = create_pool(r, get_temp_pool_name(), y);
		auto sg = make_scope_guard(
		  [&] {
		    r.delete_pool(pool, y);
		  });
		R::IOContext ioc(pool);

		auto f = RCf::FIFO::create(r, ioc, fifo_id, y, std::nullopt,
					   std::nullopt, false, max_part_size,
					   max_entry_size);


		char buf[max_entry_size];
		memset(buf, 0, sizeof(buf));

		auto [part_header_size, part_entry_overhead]
		  = f->get_part_layout_info();

		auto entries_per_part =
		  (max_part_size - part_header_size) /
		  (max_entry_size + part_entry_overhead);

		auto max_entries = entries_per_part * 4 + 1; /* enough entries to span multiple parts */

		std::vector<cb::list> bufs;

		for (auto i = 0u; i < max_entries; ++i) {
		  cb::list bl;

		  *(int *)buf = i;
		  bl.append(buf, sizeof(buf));

		  bufs.push_back(bl);
		}

		f->push(bufs, y);

		/* list all */

		auto [result, more] = f->list(max_entries, std::nullopt, y);
		ASSERT_EQ(false, more);
		ASSERT_EQ(max_entries, result.size());

		for (auto i = 0u; i < max_entries; ++i) {
		  auto& bl = result[i].data;
		  ASSERT_EQ(i, *(int *)bl.c_str());
		}

		auto& info = f->meta();
		ASSERT_EQ(info.head_part_num, 4);
	      });
  c.run();
}

TEST(FIFO, TestTrimExclusive) {
  ba::io_context c;
  auto fifo_id = "fifo"sv;

  s::spawn(c, [&](s::yield_context y) mutable {
		auto r = R::RADOS::Builder{}.build(c, y);
		auto pool = create_pool(r, get_temp_pool_name(), y);
		auto sg = make_scope_guard(
		  [&] {
		    r.delete_pool(pool, y);
		  });
		R::IOContext ioc(pool);
		auto f = RCf::FIFO::create(r, ioc, fifo_id, y);
		static constexpr auto max_entries = 10u;
		for (uint32_t i = 0; i < max_entries; ++i) {
		  cb::list bl;
		  encode(i, bl);
		  f->push(bl, y);
		}

		{
		  auto [result, more] = f->list(1, std::nullopt, y);
		  auto [val, marker] =
		    decode_entry<std::uint32_t>(result.front());
		  ASSERT_EQ(0, val);
		  f->trim(marker, true, y);
		}
		{
		  auto [result, more] = f->list(max_entries, std::nullopt, y);
		  auto [val, marker] = decode_entry<std::uint32_t>(result.front());
		  ASSERT_EQ(0, val);
		  f->trim(result[4].marker, true, y);
		}
		{
		  auto [result, more] = f->list(max_entries, std::nullopt, y);
		  auto [val, marker] =
		    decode_entry<std::uint32_t>(result.front());
		  ASSERT_EQ(4, val);
		  f->trim(result.back().marker, true, y);
		}
		{
		  auto [result, more] = f->list(max_entries, std::nullopt, y);
		  auto [val, marker] =
		    decode_entry<std::uint32_t>(result.front());
		  ASSERT_EQ(result.size(), 1);
		  ASSERT_EQ(max_entries - 1, val);
		}
	      });
  c.run();
}