Skip to content

Commit

Permalink
test: update snap flushing/evicting test script
Browse files Browse the repository at this point in the history
Signed-off-by: Mingxin Liu <mingxin@xsky.com>
  • Loading branch information
LiumxNL committed Jun 14, 2016
1 parent 0e89d3f commit dd4d80f
Showing 1 changed file with 18 additions and 144 deletions.
162 changes: 18 additions & 144 deletions src/test/librados/tier.cc
Expand Up @@ -1059,22 +1059,8 @@ TEST_F(LibRadosTwoPoolsPP, EvictSnap) {
ASSERT_EQ('h', bl[0]);
}

// evict bar head (fail)
// evict bar from head
ioctx.snap_set_read(librados::SNAP_HEAD);
{
ObjectReadOperation op;
op.cache_evict();
librados::AioCompletion *completion = cluster.aio_create_completion();
ASSERT_EQ(0, ioctx.aio_operate(
"bar", completion, &op,
librados::OPERATION_IGNORE_CACHE, NULL));
completion->wait_for_safe();
ASSERT_EQ(-EBUSY, completion->get_return_value());
completion->release();
}

// evict bar snap
ioctx.snap_set_read(my_snaps[0]);
{
ObjectReadOperation op;
op.cache_evict();
Expand All @@ -1086,8 +1072,8 @@ TEST_F(LibRadosTwoPoolsPP, EvictSnap) {
ASSERT_EQ(0, completion->get_return_value());
completion->release();
}
// ...and then head
ioctx.snap_set_read(librados::SNAP_HEAD);

// head has evicted
{
bufferlist bl;
ObjectReadOperation op;
Expand All @@ -1097,18 +1083,21 @@ TEST_F(LibRadosTwoPoolsPP, EvictSnap) {
"bar", completion, &op,
librados::OPERATION_IGNORE_CACHE, NULL));
completion->wait_for_safe();
ASSERT_EQ(0, completion->get_return_value());
ASSERT_EQ(-ENOENT, completion->get_return_value());
completion->release();
}
// clone has evicted
ioctx.snap_set_read(my_snaps[0]);
{
bufferlist bl;
ObjectReadOperation op;
op.cache_evict();
op.read(1, 0, &bl, NULL);
librados::AioCompletion *completion = cluster.aio_create_completion();
ASSERT_EQ(0, ioctx.aio_operate(
"bar", completion, &op,
librados::OPERATION_IGNORE_CACHE, NULL));
completion->wait_for_safe();
ASSERT_EQ(0, completion->get_return_value());
ASSERT_EQ(-ENOENT, completion->get_return_value());
completion->release();
}

Expand Down Expand Up @@ -1603,58 +1592,6 @@ TEST_F(LibRadosTwoPoolsPP, FlushSnap) {
ASSERT_TRUE(it == ioctx.nobjects_end());
}

// flush on head (should fail)
ioctx.snap_set_read(librados::SNAP_HEAD);
{
ObjectReadOperation op;
op.cache_flush();
librados::AioCompletion *completion = cluster.aio_create_completion();
ASSERT_EQ(0, ioctx.aio_operate(
"foo", completion, &op,
librados::OPERATION_IGNORE_CACHE, NULL));
completion->wait_for_safe();
ASSERT_EQ(-EBUSY, completion->get_return_value());
completion->release();
}
// flush on recent snap (should fail)
ioctx.snap_set_read(my_snaps[0]);
{
ObjectReadOperation op;
op.cache_flush();
librados::AioCompletion *completion = cluster.aio_create_completion();
ASSERT_EQ(0, ioctx.aio_operate(
"foo", completion, &op,
librados::OPERATION_IGNORE_CACHE, NULL));
completion->wait_for_safe();
ASSERT_EQ(-EBUSY, completion->get_return_value());
completion->release();
}
// flush on oldest snap
ioctx.snap_set_read(my_snaps[1]);
{
ObjectReadOperation op;
op.cache_flush();
librados::AioCompletion *completion = cluster.aio_create_completion();
ASSERT_EQ(0, ioctx.aio_operate(
"foo", completion, &op,
librados::OPERATION_IGNORE_CACHE, NULL));
completion->wait_for_safe();
ASSERT_EQ(0, completion->get_return_value());
completion->release();
}
// flush on next oldest snap
ioctx.snap_set_read(my_snaps[0]);
{
ObjectReadOperation op;
op.cache_flush();
librados::AioCompletion *completion = cluster.aio_create_completion();
ASSERT_EQ(0, ioctx.aio_operate(
"foo", completion, &op,
librados::OPERATION_IGNORE_CACHE, NULL));
completion->wait_for_safe();
ASSERT_EQ(0, completion->get_return_value());
completion->release();
}
// flush on head
ioctx.snap_set_read(librados::SNAP_HEAD);
{
Expand Down Expand Up @@ -3591,22 +3528,8 @@ TEST_F(LibRadosTwoPoolsECPP, EvictSnap) {
ASSERT_EQ('h', bl[0]);
}

// evict bar head (fail)
// evict bar from head
ioctx.snap_set_read(librados::SNAP_HEAD);
{
ObjectReadOperation op;
op.cache_evict();
librados::AioCompletion *completion = cluster.aio_create_completion();
ASSERT_EQ(0, ioctx.aio_operate(
"bar", completion, &op,
librados::OPERATION_IGNORE_CACHE, NULL));
completion->wait_for_safe();
ASSERT_EQ(-EBUSY, completion->get_return_value());
completion->release();
}

// evict bar snap
ioctx.snap_set_read(my_snaps[0]);
{
ObjectReadOperation op;
op.cache_evict();
Expand All @@ -3618,8 +3541,8 @@ TEST_F(LibRadosTwoPoolsECPP, EvictSnap) {
ASSERT_EQ(0, completion->get_return_value());
completion->release();
}
// ...and then head
ioctx.snap_set_read(librados::SNAP_HEAD);

// head has evicted
{
bufferlist bl;
ObjectReadOperation op;
Expand All @@ -3629,18 +3552,21 @@ TEST_F(LibRadosTwoPoolsECPP, EvictSnap) {
"bar", completion, &op,
librados::OPERATION_IGNORE_CACHE, NULL));
completion->wait_for_safe();
ASSERT_EQ(0, completion->get_return_value());
ASSERT_EQ(-ENOENT, completion->get_return_value());
completion->release();
}
// head has evicted
ioctx.snap_set_read(my_snaps[0]);
{
bufferlist bl;
ObjectReadOperation op;
op.cache_evict();
op.read(1, 0, &bl, NULL);
librados::AioCompletion *completion = cluster.aio_create_completion();
ASSERT_EQ(0, ioctx.aio_operate(
"bar", completion, &op,
librados::OPERATION_IGNORE_CACHE, NULL));
completion->wait_for_safe();
ASSERT_EQ(0, completion->get_return_value());
ASSERT_EQ(-ENOENT, completion->get_return_value());
completion->release();
}

Expand Down Expand Up @@ -4196,58 +4122,6 @@ TEST_F(LibRadosTwoPoolsECPP, FlushSnap) {
ASSERT_TRUE(it == ioctx.nobjects_end());
}

// flush on head (should fail)
ioctx.snap_set_read(librados::SNAP_HEAD);
{
ObjectReadOperation op;
op.cache_flush();
librados::AioCompletion *completion = cluster.aio_create_completion();
ASSERT_EQ(0, ioctx.aio_operate(
"foo", completion, &op,
librados::OPERATION_IGNORE_CACHE, NULL));
completion->wait_for_safe();
ASSERT_EQ(-EBUSY, completion->get_return_value());
completion->release();
}
// flush on recent snap (should fail)
ioctx.snap_set_read(my_snaps[0]);
{
ObjectReadOperation op;
op.cache_flush();
librados::AioCompletion *completion = cluster.aio_create_completion();
ASSERT_EQ(0, ioctx.aio_operate(
"foo", completion, &op,
librados::OPERATION_IGNORE_CACHE, NULL));
completion->wait_for_safe();
ASSERT_EQ(-EBUSY, completion->get_return_value());
completion->release();
}
// flush on oldest snap
ioctx.snap_set_read(my_snaps[1]);
{
ObjectReadOperation op;
op.cache_flush();
librados::AioCompletion *completion = cluster.aio_create_completion();
ASSERT_EQ(0, ioctx.aio_operate(
"foo", completion, &op,
librados::OPERATION_IGNORE_CACHE, NULL));
completion->wait_for_safe();
ASSERT_EQ(0, completion->get_return_value());
completion->release();
}
// flush on next oldest snap
ioctx.snap_set_read(my_snaps[0]);
{
ObjectReadOperation op;
op.cache_flush();
librados::AioCompletion *completion = cluster.aio_create_completion();
ASSERT_EQ(0, ioctx.aio_operate(
"foo", completion, &op,
librados::OPERATION_IGNORE_CACHE, NULL));
completion->wait_for_safe();
ASSERT_EQ(0, completion->get_return_value());
completion->release();
}
// flush on head
ioctx.snap_set_read(librados::SNAP_HEAD);
{
Expand Down

0 comments on commit dd4d80f

Please sign in to comment.