X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fceph%2Fsrc%2Ftest%2Fosd%2Ftest_ec_transaction.cc;fp=src%2Fceph%2Fsrc%2Ftest%2Fosd%2Ftest_ec_transaction.cc;h=0000000000000000000000000000000000000000;hb=7da45d65be36d36b880cc55c5036e96c24b53f00;hp=1ef2d5d832c136292988b46a67ecd785de3ded5c;hpb=691462d09d0987b47e112d6ee8740375df3c51b2;p=stor4nfv.git diff --git a/src/ceph/src/test/osd/test_ec_transaction.cc b/src/ceph/src/test/osd/test_ec_transaction.cc deleted file mode 100644 index 1ef2d5d..0000000 --- a/src/ceph/src/test/osd/test_ec_transaction.cc +++ /dev/null @@ -1,124 +0,0 @@ -// -*- 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) 2016 Red Hat - * - * 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 -#include "osd/PGTransaction.h" -#include "osd/ECTransaction.h" - -#include "test/unit.cc" - -struct mydpp : public DoutPrefixProvider { - string gen_prefix() const override { return "foo"; } - CephContext *get_cct() const override { return g_ceph_context; } - unsigned get_subsys() const override { return ceph_subsys_osd; } -} dpp; - -#define dout_context g_ceph_context - -TEST(ectransaction, two_writes_separated) -{ - hobject_t h; - PGTransactionUPtr t(new PGTransaction); - bufferlist a, b; - t->create(h); - a.append_zero(565760); - t->write(h, 0, a.length(), a, 0); - b.append_zero(2437120); - t->write(h, 669856, b.length(), b, 0); - - ECUtil::stripe_info_t sinfo(2, 8192); - auto plan = ECTransaction::get_write_plan( - sinfo, - std::move(t), - [&](const hobject_t &i) { - ECUtil::HashInfoRef ref(new ECUtil::HashInfo(1)); - return ref; - }, - &dpp); - generic_derr << "to_read " << plan.to_read << dendl; - generic_derr << "will_write " << plan.will_write << dendl; - - ASSERT_EQ(0u, plan.to_read.size()); - ASSERT_EQ(1u, plan.will_write.size()); -} - -TEST(ectransaction, two_writes_nearby) -{ - hobject_t h; - PGTransactionUPtr t(new PGTransaction); - bufferlist a, b; - t->create(h); - - // two nearby writes, both partly touching the same 8192-byte stripe - ECUtil::stripe_info_t sinfo(2, 8192); - a.append_zero(565760); - t->write(h, 0, a.length(), a, 0); - b.append_zero(2437120); - t->write(h, 569856, b.length(), b, 0); - - auto plan = ECTransaction::get_write_plan( - sinfo, - std::move(t), - [&](const hobject_t &i) { - ECUtil::HashInfoRef ref(new ECUtil::HashInfo(1)); - return ref; - }, - &dpp); - generic_derr << "to_read " << plan.to_read << dendl; - generic_derr << "will_write " << plan.will_write << dendl; - - ASSERT_EQ(0u, plan.to_read.size()); - ASSERT_EQ(1u, plan.will_write.size()); -} - -TEST(ectransaction, many_writes) -{ - hobject_t h; - PGTransactionUPtr t(new PGTransaction); - bufferlist a, b; - a.append_zero(512); - b.append_zero(4096); - t->create(h); - - ECUtil::stripe_info_t sinfo(2, 8192); - // write 2801664~512 - // write 2802176~512 - // write 2802688~512 - // write 2803200~512 - t->write(h, 2801664, a.length(), a, 0); - t->write(h, 2802176, a.length(), a, 0); - t->write(h, 2802688, a.length(), a, 0); - t->write(h, 2803200, a.length(), a, 0); - - // write 2805760~4096 - // write 2809856~4096 - // write 2813952~4096 - t->write(h, 2805760, b.length(), b, 0); - t->write(h, 2809856, b.length(), b, 0); - t->write(h, 2813952, b.length(), b, 0); - - auto plan = ECTransaction::get_write_plan( - sinfo, - std::move(t), - [&](const hobject_t &i) { - ECUtil::HashInfoRef ref(new ECUtil::HashInfo(1)); - return ref; - }, - &dpp); - generic_derr << "to_read " << plan.to_read << dendl; - generic_derr << "will_write " << plan.will_write << dendl; - - ASSERT_EQ(0u, plan.to_read.size()); - ASSERT_EQ(1u, plan.will_write.size()); -}