예제 #1
0
 virtual void TearDown()
 {
     if(vol_ != nullptr)
     {
         destroyVolume(vol_,
                       DeleteLocalData::T,
                       RemoveVolumeCompletely::T);
     }
     VolManagerTestSetup::TearDown();
 }
TEST_P(SnapshotRestoreTest, TestFailOver)
{
    auto foc_ctx(start_one_foc());
    auto ns_ptr = make_random_namespace();
    SharedVolumePtr v = newVolume(VolumeId("volume1"),
                          ns_ptr->ns(),
                          VolumeSize((1 << 18) * 512),
                          SCOMultiplier(1));

    v->setFailOverCacheConfig(foc_ctx->config(GetParam().foc_mode()));

    VolumeConfig cfg = v->get_config();
    v->createSnapshot(SnapshotName("snap0"));

    for(int i = 0; i < 5; ++i)
    {
        writeToVolume(*v,
                      0,
                      4096,
                      "a");
    }


    waitForThisBackendWrite(*v);
    v->restoreSnapshot(SnapshotName("snap0"));

    for(int i = 0; i < 7; ++i)
    {
        writeToVolume(*v,
                      8,
                      4096,
                      "d");
    }

    flushFailOverCache(*v);
    destroyVolume(v,
                  DeleteLocalData::T,
                  RemoveVolumeCompletely::F);

    SharedVolumePtr v1 = 0;
    v1 = getVolume(VolumeId("volume1"));
    ASSERT_FALSE(v1);
    restartVolume(cfg);
    v1 = getVolume(VolumeId("volume1"));

    ASSERT_TRUE(v1 != nullptr);
    checkVolume(*v1,0,4096, "\0");
    checkVolume(*v1,8,4096, "d");
    checkCurrentBackendSize(*v1);
}
TEST_P(PrefetchThreadTest, test_one)
{
    auto ns_ptr = make_random_namespace();

    const backend::Namespace& ns = ns_ptr->ns();

    Volume* v = newVolume("v1",
			  ns);

    const size_t numwrites = 20;
    for(size_t i = 0; i < numwrites; ++i)
    {
        writeToVolume(v,
                      0,
                      4096,
                      "Superflous");
    }

    syncToBackend(v);

    destroyVolume(v,
                  DeleteLocalData::T,
                  RemoveVolumeCompletely::F);
}
예제 #4
0
    void
    test_after_tlog(bool failover)
    {
        const auto wrns(make_random_namespace());

        SharedVolumePtr v = make_volume(*wrns);

        const std::string pattern1("Hairdresser On Fire");

        {
            SCOPED_BLOCK_BACKEND(*v);

            writeToVolume(*v,
                          v->getClusterMultiplier() * CachePage::capacity(),
                          v->getClusterSize(),
                          pattern1);
        }

        v->scheduleBackendSync();
        waitForThisBackendWrite(*v);

        const std::string pattern2("Such A Little Thing Makes Such A Big Difference");

        writeToVolume(*v,
                      2 * v->getClusterMultiplier() * CachePage::capacity(),
                      v->getClusterSize(),
                      pattern2);

        const auto ncfgs(node_configs());

        if (failover)
        {
            mds_manager_->stop_one(ncfgs[0]);

            checkVolume(*v,
                        0,
                        v->getClusterSize(),
                        "");
        }
        else
        {
            const std::vector<MDSNodeConfig> ncfgs2{ ncfgs[1],
                                                     ncfgs[0] };

            v->updateMetaDataBackendConfig(MDSMetaDataBackendConfig(ncfgs2,
                                                                    ApplyRelocationsToSlaves::T));
        }

        check_config(*v,
                     ncfgs,
                     true);

        checkVolume(*v,
                    v->getClusterMultiplier() * CachePage::capacity(),
                    v->getClusterSize(),
                    pattern1);

        checkVolume(*v,
                    2 * v->getClusterMultiplier() * CachePage::capacity(),
                    v->getClusterSize(),
                    pattern2);

        destroyVolume(v,
                      DeleteLocalData::F,
                      RemoveVolumeCompletely::F);

        v = localRestart(wrns->ns());

        check_config(*v,
                     ncfgs,
                     true);

        checkVolume(*v,
                    v->getClusterMultiplier() * CachePage::capacity(),
                    v->getClusterSize(),
                    pattern1);

        checkVolume(*v,
                    2 * v->getClusterMultiplier() * CachePage::capacity(),
                    v->getClusterSize(),
                    pattern2);
    }
예제 #5
0
    void
    test_before_tlog(bool failover)
    {
        const auto wrns(make_random_namespace());

        SharedVolumePtr v = make_volume(*wrns);

        const auto ncfgs(node_configs());
        const std::string pattern("King Leer");

        {
            SCOPED_BLOCK_BACKEND(*v);

            writeToVolume(*v,
                          v->getClusterMultiplier() * CachePage::capacity(),
                          v->getClusterSize(),
                          pattern);

            if (failover)
            {
                mds_manager_->stop_one(ncfgs[0]);

                checkVolume(*v,
                            0,
                            v->getClusterSize(),
                            "");
            }
            else
            {
                const std::vector<MDSNodeConfig> ncfgs2{ ncfgs[1],
                                                         ncfgs[0] };

                v->updateMetaDataBackendConfig(MDSMetaDataBackendConfig(ncfgs2,
                                                                        ApplyRelocationsToSlaves::T));
            }

            check_config(*v,
                         ncfgs,
                         true);

            checkVolume(*v,
                        v->getClusterMultiplier() * CachePage::capacity(),
                        v->getClusterSize(),
                        pattern);
        }

        destroyVolume(v,
                      DeleteLocalData::F,
                      RemoveVolumeCompletely::F);

        v = localRestart(wrns->ns());

        check_config(*v,
                     ncfgs,
                     true);

        checkVolume(*v,
                    v->getClusterMultiplier() * CachePage::capacity(),
                    v->getClusterSize(),
                    pattern);
    }
TEST_P(PrefetchThreadTest, test_two)
{
    // backend::Namespace n1;
    auto ns_ptr = make_random_namespace();

    const backend::Namespace& n1 = ns_ptr->ns();

    Volume* v = newVolume("v1",
                          n1);
    // Y42 put in VolManagerTestSetup
    const VolumeConfig cfg = v->get_config();
    const uint64_t scoSize = cfg.getSCOSize();


    const size_t numwrites = 20;
    for(size_t i = 0; i < numwrites; ++i)
    {
        writeToVolume(v,
                      0,
                      scoSize,
                      "Superflous");
    }

    syncToBackend(v);

    SCONameList list;

    VolManager::get()->getSCOCache()->getSCONameList(n1,
                                        list,
                                        true);

    ASSERT_EQ(numwrites, list.size());

    for(SCONameList::const_iterator it = list.begin();
        it != list.end();
        ++it)
    {
        VolManager::get()->getSCOCache()->removeSCO(n1,
                                       *it,
                                       false);
    }

    {
        SCONameList list;
        VolManager::get()->getSCOCache()->getSCONameList(n1,
                                                         list,
                                                         true);
        ASSERT_TRUE(list.empty());
    }
    //fill the cache with 1 SCO
    SCONameList::const_iterator it = list.begin();
    v->getPrefetchData().addSCO(*it, 1);
    ++it;

    //make sure cachedXValMin_ is set
    VolManager::get()->getSCOCache()->cleanup();

    //make sure next SCO's with low sap are also prefetched as cache is not full
    float sap = 0.01;
    for( ; it != list.end(); ++it)
    {
        v->getPrefetchData().addSCO(*it, sap);
        sap *= 0.9;
    }

    SCONameList list2;
    size_t counter = 0;

    while(list2.size() != numwrites and counter < 60)
    {
        boost::this_thread::sleep(boost::posix_time::seconds(1));
        list2.clear();
        ++counter;
        VolManager::get()->getSCOCache()->getSCONameList(n1,
                                                         list2,
                                                         true);
    }

    ASSERT_EQ(numwrites, list2.size());
    destroyVolume(v,
                  DeleteLocalData::T,
                  RemoveVolumeCompletely::F);
}