コード例 #1
0
    virtual void
    SetUp()
    {
        throttle_usecs = 1000;
        SCOCacheTestSetup::SetUp();

        mp_path_ = pathPfx_ / "mp1";
        mp_size_ = 1 << 29; // 512 MiB

        fs::create_directories(mp_path_);

        MountPointConfigs mpcfgs;

        mpcfgs.push_back(MountPointConfig(mp_path_,
                                          mp_size_));

        boost::property_tree::ptree pt;
        pt.put("version", 1);

        PARAMETER_TYPE(scocache_mount_points)(mpcfgs).persist(pt);

        PARAMETER_TYPE(datastore_throttle_usecs)(throttle_usecs).persist(pt);
        PARAMETER_TYPE(trigger_gap)(yt::DimensionedValue(1)).persist(pt);
        PARAMETER_TYPE(backoff_gap)(yt::DimensionedValue(1)).persist(pt);

        scoCache_.reset(new SCOCache(pt));

        scoCache_->addNamespace(nspace_,
                                0,
                                std::numeric_limits<uint64_t>::max());

    }
コード例 #2
0
TEST_F(SCOCacheConstructorTest, invalidMountPoint)
{
    MountPointConfigs mpCfgs;

    EXPECT_FALSE(fs::exists(pathPfx_ / "lost+found"));
    EXPECT_FALSE(fs::exists(pathPfx_ / "tooSmall"));
    EXPECT_FALSE(fs::exists(pathPfx_ / "one"));
    EXPECT_FALSE(fs::exists(pathPfx_ / "two"));

    mpCfgs.push_back(MountPointConfig(pathPfx_ / "lost+found", 1 << 30));
    mpCfgs.push_back(MountPointConfig(pathPfx_ / "tooSmall", 0));

    fs::path one(pathPfx_ / "one");
    fs::path two(pathPfx_ / "two");

    fs::create_directories(one);
    fs::create_directories(two);

    mpCfgs.push_back(MountPointConfig(one, 1ULL << 20));
    mpCfgs.push_back(MountPointConfig(two,
                                      std::numeric_limits<uint64_t>::max()));

    std::unique_ptr<SCOCache> scoCache;

    boost::property_tree::ptree pt;

    PARAMETER_TYPE(datastore_throttle_usecs)(throttling).persist(pt);
    PARAMETER_TYPE(trigger_gap)(yt::DimensionedValue(5ULL << 30)).persist(pt);
    PARAMETER_TYPE(backoff_gap)(yt::DimensionedValue(10ULL << 30)).persist(pt);
    pt.put("version", 1);
    PARAMETER_TYPE(scocache_mount_points)(mpCfgs).persist(pt);


    ASSERT_NO_THROW(scoCache.reset(new SCOCache(pt)));

    // EXPECT_TRUE(fs::exists(pathPfx_ / "one"));
    // EXPECT_TRUE(fs::exists(pathPfx_ / "two"));
    // EXPECT_FALSE(fs::exists(pathPfx_ / "tooSmall"));
    // EXPECT_FALSE(fs::exists(pathPfx_ / "lost+found"));

    SCOCacheMountPointList& l = getMountPointList(*scoCache);
    EXPECT_EQ(2U, l.size());

    BOOST_FOREACH(SCOCacheMountPointPtr mp, l)
    {
        EXPECT_TRUE(one == mp->getPath() ||
                    two == mp->getPath()) << mp->getPath();
    }