diff options
author | Tor Egge <Tor.Egge@yahoo-inc.com> | 2017-03-17 14:26:36 +0000 |
---|---|---|
committer | Tor Egge <Tor.Egge@yahoo-inc.com> | 2017-03-17 14:26:36 +0000 |
commit | 3c7c0aadfc30d6348ffa61e4da66a742f415e0db (patch) | |
tree | e14fa019c12b11e3646ca2357cb039252cf9b72b /searchcore/src/tests/proton/index/indexmanager_test.cpp | |
parent | 467bc3bfff814aa6dd5756b0cf44d444b15ae47f (diff) |
Trim down schema in existing disk indexes when setting new schema, to
eliminate removed fields and fields with mismatching data type or collection
type.
Diffstat (limited to 'searchcore/src/tests/proton/index/indexmanager_test.cpp')
-rw-r--r-- | searchcore/src/tests/proton/index/indexmanager_test.cpp | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/searchcore/src/tests/proton/index/indexmanager_test.cpp b/searchcore/src/tests/proton/index/indexmanager_test.cpp index b1081eb3338..9d8f4d8b7f6 100644 --- a/searchcore/src/tests/proton/index/indexmanager_test.cpp +++ b/searchcore/src/tests/proton/index/indexmanager_test.cpp @@ -690,22 +690,36 @@ TEST_F("requireThatFailedFusionIsRetried", Fixture) { EXPECT_EQUAL(2u, spec.flush_ids[1]); } -TEST_F("require that wipeHistory updates schema on disk", Fixture) { - Schema empty_schema; - f.addDocument(docid); - f.flushIndexManager(); - f.runAsMaster([&]() { f._index_manager->setSchema(empty_schema, 1000); }); - f.addDocument(docid); - f.flushIndexManager(); +namespace { +void expectSchemaIndexFields(uint32_t expIndexFields) { Schema s; s.loadFromFile("test_data/index.flush.1/schema.txt"); - EXPECT_EQUAL(1u, s.getNumIndexFields()); + EXPECT_EQUAL(expIndexFields, s.getNumIndexFields()); +} - f.runAsMaster([&]() { f._index_manager->wipeHistory(f._serial_num); }); +} - s.loadFromFile("test_data/index.flush.1/schema.txt"); - EXPECT_EQUAL(0u, s.getNumIndexFields()); +TEST_F("require that setSchema updates schema on disk, wiping removed fields", Fixture) +{ + Schema empty_schema; + f.addDocument(docid); + f.flushIndexManager(); + TEST_DO(expectSchemaIndexFields(1)); + f.runAsMaster([&]() { f._index_manager->setSchema(empty_schema, ++f._serial_num); }); + TEST_DO(expectSchemaIndexFields(0)); +} + +TEST_F("require that wipeHistory updates schema on disk", Fixture) +{ + Schema empty_schema; + f.addDocument(docid); + f.flushIndexManager(); + TEST_DO(expectSchemaIndexFields(1)); + f.runAsMaster([&]() { f._index_manager->setSchema(empty_schema, f._serial_num); }); + TEST_DO(expectSchemaIndexFields(1)); + f.runAsMaster([&]() { f._index_manager->wipeHistory(++f._serial_num); }); + TEST_DO(expectSchemaIndexFields(0)); } TEST_F("require that indexes manager stats can be generated", Fixture) |