diff options
author | Tor Egge <Tor.Egge@online.no> | 2023-02-02 16:30:41 +0100 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2023-02-02 16:30:41 +0100 |
commit | 55f7bba90d6fbf89e4b2b17ca06ece3440b0d9fa (patch) | |
tree | e210a6dd4735422875995b120ba80d5aab58b36c /searchcore/src/tests/proton | |
parent | 733ea50fe289aa28f364399f3fd097cd7011f7a4 (diff) |
Add helper member function to fixture classes.
Diffstat (limited to 'searchcore/src/tests/proton')
-rw-r--r-- | searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp | 106 |
1 files changed, 60 insertions, 46 deletions
diff --git a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp index c8603110560..1cdc4e8b985 100644 --- a/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp +++ b/searchcore/src/tests/proton/documentdb/configurer/configurer_test.cpp @@ -163,6 +163,15 @@ struct Fixture Fixture(); ~Fixture(); void initViewSet(ViewSet &views); + void reconfigure(const DocumentDBConfig& new_config_snapshot, + const DocumentDBConfig& old_config_snapshot, + const ReconfigParams& reconfig_params, + IDocumentDBReferenceResolver& resolver); + IReprocessingInitializer::UP reconfigure(const DocumentDBConfig& new_config_snapshot, + const DocumentDBConfig& old_config_snapshot, + AttributeCollectionSpec&& attr_spec, + const ReconfigParams& reconfig_params, + IDocumentDBReferenceResolver& resolver); }; Fixture::Fixture() @@ -228,6 +237,26 @@ Fixture::initViewSet(ViewSet &views) SearchableFeedView::Context(indexWriter))); } +void +Fixture::reconfigure(const DocumentDBConfig& new_config_snapshot, + const DocumentDBConfig& old_config_snapshot, + const ReconfigParams& reconfig_params, + IDocumentDBReferenceResolver& resolver) +{ + auto prepared_reconfig = _configurer->prepare_reconfig(new_config_snapshot, old_config_snapshot, reconfig_params); + _configurer->reconfigure(new_config_snapshot, old_config_snapshot, reconfig_params, resolver, *prepared_reconfig); +} + +IReprocessingInitializer::UP +Fixture::reconfigure(const DocumentDBConfig& new_config_snapshot, + const DocumentDBConfig& old_config_snapshot, + AttributeCollectionSpec&& attr_spec, + const ReconfigParams& reconfig_params, + IDocumentDBReferenceResolver& resolver) +{ + auto prepared_reconfig = _configurer->prepare_reconfig(new_config_snapshot, old_config_snapshot, reconfig_params); + return _configurer->reconfigure(new_config_snapshot, old_config_snapshot, std::move(attr_spec), reconfig_params, resolver, *prepared_reconfig); +} using MySummaryAdapter = test::MockSummaryAdapter; @@ -293,8 +322,23 @@ struct FastAccessFixture ~FastAccessFixture() { _service.shutdown(); } + + IReprocessingInitializer::UP + reconfigure(const DocumentDBConfig& new_config_snapshot, + const DocumentDBConfig& old_config_snapshot, + AttributeCollectionSpec&& attr_spec); }; +IReprocessingInitializer::UP +FastAccessFixture::reconfigure(const DocumentDBConfig& new_config_snapshot, + const DocumentDBConfig& old_config_snapshot, + AttributeCollectionSpec&& attr_spec) +{ + ReconfigParams reconfig_params{CCR()}; + auto prepared_reconfig = _configurer.prepare_reconfig(new_config_snapshot, old_config_snapshot, reconfig_params); + return _configurer.reconfigure(new_config_snapshot, old_config_snapshot, std::move(attr_spec), *prepared_reconfig); +} + DocumentDBConfig::SP createConfig() { @@ -457,13 +501,9 @@ TEST_F("require that we can reconfigure attribute manager", Fixture) ViewPtrs o = f._views.getViewPtrs(); ReconfigParams params(CCR().setAttributesChanged(true).setSchemaChanged(true)); // Use new config snapshot == old config snapshot (only relevant for reprocessing) - auto old_config_snapshot = createConfig(); - auto new_config_snapshot = createConfig(); - auto prepared_reconfig = f._configurer->prepare_reconfig(*new_config_snapshot, *old_config_snapshot, params); - f._configurer->reconfigure(*new_config_snapshot, *old_config_snapshot, - AttributeCollectionSpec(AttributeCollectionSpec::AttributeList(), 1, 0), - params, f._resolver, *prepared_reconfig); - prepared_reconfig.reset(); + f.reconfigure(*createConfig(), *createConfig(), + AttributeCollectionSpec(AttributeCollectionSpec::AttributeList(), 1, 0), + params, f._resolver); ViewPtrs n = f._views.getViewPtrs(); { // verify search view @@ -499,13 +539,9 @@ checkAttributeWriterChangeOnRepoChange(Fixture &f, bool docTypeRepoChanged) auto oldAttributeWriter = getAttributeWriter(f); ReconfigParams params(CCR().setDocumentTypeRepoChanged(docTypeRepoChanged)); // Use new config snapshot == old config snapshot (only relevant for reprocessing) - auto old_config_snapshot = createConfig(); - auto new_config_snapshot = createConfig(); - auto prepared_reconfig = f._configurer->prepare_reconfig(*new_config_snapshot, *old_config_snapshot, params); - f._configurer->reconfigure(*new_config_snapshot, *old_config_snapshot, - AttributeCollectionSpec(AttributeCollectionSpec::AttributeList(), 1, 0), - params, f._resolver, *prepared_reconfig); - prepared_reconfig.reset(); + f.reconfigure(*createConfig(), *createConfig(), + AttributeCollectionSpec(AttributeCollectionSpec::AttributeList(), 1, 0), + params, f._resolver); auto newAttributeWriter = getAttributeWriter(f); if (docTypeRepoChanged) { EXPECT_NOT_EQUAL(oldAttributeWriter, newAttributeWriter); @@ -522,15 +558,11 @@ TEST_F("require that we get new attribute writer if document type repo changes", TEST_F("require that reconfigure returns reprocessing initializer when changing attributes", Fixture) { - auto old_config_snapshot = createConfig(); - auto new_config_snapshot = createConfig(); ReconfigParams params(CCR().setAttributesChanged(true).setSchemaChanged(true)); - auto prepared_reconfig = f._configurer->prepare_reconfig(*new_config_snapshot, *old_config_snapshot, params); IReprocessingInitializer::UP init = - f._configurer->reconfigure(*new_config_snapshot, *old_config_snapshot, - AttributeCollectionSpec(AttributeCollectionSpec::AttributeList(), 1, 0), - params, f._resolver, *prepared_reconfig); - prepared_reconfig.reset(); + f.reconfigure(*createConfig(), *createConfig(), + AttributeCollectionSpec(AttributeCollectionSpec::AttributeList(), 1, 0), + params, f._resolver); EXPECT_TRUE(init.get() != nullptr); EXPECT_TRUE((dynamic_cast<AttributeReprocessingInitializer *>(init.get())) != nullptr); @@ -540,13 +572,9 @@ TEST_F("require that reconfigure returns reprocessing initializer when changing TEST_F("require that we can reconfigure attribute writer", FastAccessFixture) { FastAccessFeedView::SP o = f._view._feedView.get(); - auto old_config_snapshot = createConfig(); - auto new_config_snapshot = createConfig(); ReconfigParams reconfig_params{CCR()}; - auto prepared_reconfig = f._configurer.prepare_reconfig(*new_config_snapshot, *old_config_snapshot, reconfig_params); - f._configurer.reconfigure(*createConfig(), *createConfig(), - AttributeCollectionSpec(AttributeCollectionSpec::AttributeList(), 1, 0), *prepared_reconfig); - prepared_reconfig.reset(); + f.reconfigure(*createConfig(), *createConfig(), + AttributeCollectionSpec(AttributeCollectionSpec::AttributeList(), 1, 0)); FastAccessFeedView::SP n = f._view._feedView.get(); FastAccessFeedViewComparer cmp(o, n); @@ -558,13 +586,8 @@ TEST_F("require that we can reconfigure attribute writer", FastAccessFixture) TEST_F("require that reconfigure returns reprocessing initializer", FastAccessFixture) { - auto old_config_snapshot = createConfig(); - auto new_config_snapshot = createConfig(); - ReconfigParams reconfig_params{CCR()}; - auto prepared_reconfig = f._configurer.prepare_reconfig(*new_config_snapshot, *old_config_snapshot, reconfig_params); - IReprocessingInitializer::UP init = f._configurer.reconfigure(*new_config_snapshot, *old_config_snapshot, - AttributeCollectionSpec(AttributeCollectionSpec::AttributeList(), 1, 0), *prepared_reconfig); - prepared_reconfig.reset(); + IReprocessingInitializer::UP init = f.reconfigure(*createConfig(), *createConfig(), + AttributeCollectionSpec(AttributeCollectionSpec::AttributeList(), 1, 0)); EXPECT_TRUE(init.get() != nullptr); EXPECT_TRUE((dynamic_cast<AttributeReprocessingInitializer *>(init.get())) != nullptr); @@ -576,11 +599,7 @@ TEST_F("require that we can reconfigure summary manager", Fixture) ViewPtrs o = f._views.getViewPtrs(); ReconfigParams params(CCR().setSummaryChanged(true)); // Use new config snapshot == old config snapshot (only relevant for reprocessing) - auto old_config_snapshot = createConfig(); - auto new_config_snapshot = createConfig(); - auto prepared_reconfig = f._configurer->prepare_reconfig(*new_config_snapshot, *old_config_snapshot, params); - f._configurer->reconfigure(*new_config_snapshot, *old_config_snapshot, params, f._resolver, *prepared_reconfig); - prepared_reconfig.reset(); + f.reconfigure(*createConfig(), *createConfig(), params, f._resolver); ViewPtrs n = f._views.getViewPtrs(); { // verify search view @@ -599,13 +618,8 @@ TEST_F("require that we can reconfigure matchers", Fixture) { ViewPtrs o = f._views.getViewPtrs(); // Use new config snapshot == old config snapshot (only relevant for reprocessing) - auto old_config_snapshot = createConfig(o.fv->getSchema()); - auto new_config_snapshot = createConfig(o.fv->getSchema()); - ReconfigParams reconfig_params(CCR().setRankProfilesChanged(true)); - auto prepared_reconfig = f._configurer->prepare_reconfig(*new_config_snapshot, *old_config_snapshot, reconfig_params); - f._configurer->reconfigure(*new_config_snapshot, *old_config_snapshot, - reconfig_params, f._resolver, *prepared_reconfig); - prepared_reconfig.reset(); + f.reconfigure(*createConfig(o.fv->getSchema()), *createConfig(o.fv->getSchema()), + ReconfigParams(CCR().setRankProfilesChanged(true)), f._resolver); ViewPtrs n = f._views.getViewPtrs(); { // verify search view |