Skip to content

Commit

Permalink
Merge "Merge branch 'mad-hatter' into master"
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerrit Code Review committed Feb 5, 2021
2 parents 8b018a4 + 8dabbf0 commit 9160c2f
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 12 deletions.
47 changes: 42 additions & 5 deletions engines/ep/tests/module_tests/evp_store_single_threaded_test.cc
Expand Up @@ -183,7 +183,7 @@ void SingleThreadedKVBucketTest::runReadersUntilWarmedUp() {
* Finally, run warmup.
*/
void SingleThreadedKVBucketTest::resetEngineAndEnableWarmup(
std::string new_config) {
std::string new_config, bool force) {
shutdownAndPurgeTasks(engine.get());
std::string config = config_string;

Expand All @@ -202,7 +202,7 @@ void SingleThreadedKVBucketTest::resetEngineAndEnableWarmup(
config += new_config;
}

reinitialise(config);
reinitialise(config, force);
if (isPersistent()) {
static_cast<EPBucket*>(engine->getKVBucket())->initializeWarmupTask();
static_cast<EPBucket*>(engine->getKVBucket())->startWarmupTask();
Expand All @@ -213,8 +213,9 @@ void SingleThreadedKVBucketTest::resetEngineAndEnableWarmup(
* Destroy engine and replace it with a new engine that can be warmed up.
* Finally, run warmup.
*/
void SingleThreadedKVBucketTest::resetEngineAndWarmup(std::string new_config) {
resetEngineAndEnableWarmup(new_config);
void SingleThreadedKVBucketTest::resetEngineAndWarmup(std::string new_config,
bool force) {
resetEngineAndEnableWarmup(new_config, force);

// Now get the engine warmed up
runReadersUntilWarmedUp();
Expand Down Expand Up @@ -5387,6 +5388,42 @@ void STParamPersistentBucketTest::testAbortDoesNotIncrementOpsDelete(
EXPECT_EQ(0, vb.opsDelete);
}

TEST_P(STParamPersistentBucketTest, CleanShutdown) {
// @TODO Enable for magma in MB-43946
if (isMagma()) {
GTEST_SKIP();
}

setVBucketStateAndRunPersistTask(vbid, vbucket_state_active);
auto vb = engine->getKVBucket()->getVBucket(vbid);

auto initialUuid = vb->failovers->getLatestUUID();

vb.reset();
resetEngineAndWarmup();
vb = engine->getKVBucket()->getVBucket(vbid);

EXPECT_EQ(initialUuid, vb->failovers->getLatestUUID());
}

TEST_P(STParamPersistentBucketTest, UncleanShutdown) {
// @TODO Enable for magma in MB-43946
if (isMagma()) {
GTEST_SKIP();
}

setVBucketStateAndRunPersistTask(vbid, vbucket_state_active);
auto vb = engine->getKVBucket()->getVBucket(vbid);

auto initialUuid = vb->failovers->getLatestUUID();

vb.reset();
resetEngineAndWarmup("", true /* force shutdown*/);
vb = engine->getKVBucket()->getVBucket(vbid);

EXPECT_NE(initialUuid, vb->failovers->getLatestUUID());
}

void STParamPersistentBucketTest::testFailoverTableEntryPersistedAtWarmup(
std::function<void()> testFunction) {
// 1) Store something so we can expire it later
Expand All @@ -5404,7 +5441,7 @@ void STParamPersistentBucketTest::testFailoverTableEntryPersistedAtWarmup(
// 2) Restart as though we had an unclean shutdown (creating a new failover
// table entry) and run the warmup up to the point of completion.
vb.reset();
resetEngineAndEnableWarmup();
resetEngineAndEnableWarmup("", true /*unclean*/);

auto& readerQueue = *task_executor->getLpTaskQ()[READER_TASK_IDX];
auto* warmup = engine->getKVBucket()->getWarmup();
Expand Down
12 changes: 10 additions & 2 deletions engines/ep/tests/module_tests/evp_store_single_threaded_test.h
Expand Up @@ -228,14 +228,22 @@ class SingleThreadedKVBucketTest : public KVBucketTest {

/**
* Destroy engine and replace it with a new engine that can be warmed up.
*
* @param new_config The config to supply to engine creation
* @param unclean Should the restart be made to appear unclean
*/
void resetEngineAndEnableWarmup(std::string new_config = "");
void resetEngineAndEnableWarmup(std::string new_config = "",
bool unclean = false);

/**
* Destroy engine and replace it with a new engine that can be warmed up.
* Finally, run warmup.
*
* @param new_config The config to supply to engine creation
* @param unclean Should the restart be made to appear unclean
*/
void resetEngineAndWarmup(std::string new_config = "");
void resetEngineAndWarmup(std::string new_config = "",
bool unclean = false);

/*
* Fake callback emulating dcp_add_failover_log
Expand Down
7 changes: 4 additions & 3 deletions engines/ep/tests/module_tests/kv_bucket_test.cc
Expand Up @@ -128,14 +128,15 @@ void KVBucketTest::TearDown() {
}
}

void KVBucketTest::destroy() {
void KVBucketTest::destroy(bool force) {
destroy_mock_cookie(cookie);
engine->getDcpConnMap().manageConnections();
engine->destroyInner(force);
engine.reset();
}

void KVBucketTest::reinitialise(std::string config) {
destroy();
void KVBucketTest::reinitialise(std::string config, bool force) {
destroy(force);
initialise(config);
}

Expand Down
8 changes: 6 additions & 2 deletions engines/ep/tests/module_tests/kv_bucket_test.h
Expand Up @@ -180,8 +180,10 @@ class KVBucketTest : virtual public ::testing::Test {
/**
* Effectively shutdown/restart. This destroys the test engine/store/cookie
* and re-creates them.
*
* @param force Force the shutdown making it appear unclean
*/
void reinitialise(std::string config);
void reinitialise(std::string config, bool force = false);

/**
* Create a *_with_meta packet with the key/body
Expand Down Expand Up @@ -266,8 +268,10 @@ class KVBucketTest : virtual public ::testing::Test {

/**
* Destroy the test objects - e.g. engine/store/cookie
*
* @param force Force the shutdown making it appear unclean
*/
void destroy();
void destroy(bool force = false);

bool completeWarmup = true;

Expand Down

0 comments on commit 9160c2f

Please sign in to comment.