Fixed integration test

This commit is contained in:
Maksim Kita 2021-04-26 23:35:56 +03:00
parent c93666e0de
commit 71bccfdea1
3 changed files with 29 additions and 9 deletions

View File

@ -192,6 +192,20 @@ void StorageDictionary::shutdown()
removeDictionaryConfigurationFromRepository();
}
void StorageDictionary::startup()
{
auto context = getContext();
bool lazy_load = context->getConfigRef().getBool("dictionaries_lazy_load", true);
if (!lazy_load)
{
auto & external_dictionaries_loader = context->getExternalDictionariesLoader();
/// reloadConfig() is called here to force loading the dictionary.
external_dictionaries_loader.reloadConfig(getStorageID().getInternalDictionaryName());
}
}
void StorageDictionary::removeDictionaryConfigurationFromRepository()
{
if (remove_repository_callback_executed)
@ -256,14 +270,6 @@ void registerStorageDictionary(StorageFactory & factory)
auto abstract_dictionary_configuration = getDictionaryConfigurationFromAST(args.query, local_context, dictionary_id.database_name);
auto result_storage = StorageDictionary::create(dictionary_id, abstract_dictionary_configuration, local_context);
bool lazy_load = local_context->getConfigRef().getBool("dictionaries_lazy_load", true);
if (!lazy_load)
{
/// load() is called here to force loading the dictionary, wait until the loading is finished,
/// and throw an exception if the loading is failed.
external_dictionaries_loader.load(result_storage->getStorageID().getInternalDictionaryName());
}
return result_storage;
}
else

View File

@ -38,7 +38,8 @@ public:
bool isDictionary() const override { return true; }
void drop() override;
void shutdown() override;
void shutdown() override;
void startup() override;
void renameInMemory(const StorageID & new_table_id) override;

View File

@ -61,6 +61,11 @@ def test_dependency_via_implicit_table(node):
check()
# Restart must not break anything.
node.restart_clickhouse()
check()
@pytest.mark.parametrize("node", nodes)
def test_dependency_via_explicit_table(node):
tbl_names = ["test.atbl", "test.ztbl", "atest.tbl", "ztest.tbl"]
@ -80,6 +85,10 @@ def test_dependency_via_explicit_table(node):
check()
# Restart must not break anything.
node.restart_clickhouse()
check()
@pytest.mark.parametrize("node", nodes)
def test_dependency_via_dictionary_database(node):
@ -96,3 +105,7 @@ def test_dependency_via_dictionary_database(node):
assert node.query("SELECT dictGet({}, 'y', toUInt64(5))".format(d_name)) == "6\n"
check()
# Restart must not break anything.
node.restart_clickhouse()
check()