style + flaky test fix

This commit is contained in:
nikitamikhaylov 2020-11-17 17:36:04 +03:00
parent 4345f2987d
commit 9c6b896928
5 changed files with 29 additions and 20 deletions

View File

@ -10,6 +10,7 @@
#include <Common/randomSeed.h>
#include <Common/typeid_cast.h>
#include <Core/Defines.h>
#include <IO/WriteBufferFromOStream.h>
#include <ext/range.h>
#include <ext/size.h>
#include <Common/setThreadName.h>
@ -284,7 +285,7 @@ Overloaded(Ts...) -> Overloaded<Ts...>;
std::string CacheDictionary::AttributeValuesForKey::dump()
{
std::ostringstream os;
WriteBufferFromOwnString os;
for (auto & attr : values)
std::visit(Overloaded {
[&os](UInt8 arg) { os << "type: UInt8, value: " << std::to_string(arg) << "\n"; },
@ -309,7 +310,7 @@ std::string CacheDictionary::AttributeValuesForKey::dump()
std::string CacheDictionary::UpdateUnit::dumpFoundIds()
{
std::ostringstream os;
WriteBufferFromOwnString os;
for (auto it : found_ids)
{
os << "Key: " << std::to_string(it.first) << "\n";
@ -514,15 +515,16 @@ CacheDictionary::Attribute CacheDictionary::createAttributeWithTypeAndName(const
switch (type)
{
/* Macro argument should be enclosed in parentheses, but if do so we cannot initialize \
* NearestFieldType which takes TYPE as a template parameter. */
#define DISPATCH(TYPE)\
case AttributeUnderlyingType::ut##TYPE: {\
attr.null_value = TYPE(null_value.get<NearestFieldType<TYPE>>()); /* NOLINT(bugprone-macro-parentheses) */ \
attr.arrays = std::make_unique<ContainerType<TYPE>>(size); /* NOLINT(bugprone-macro-parentheses) */ \
bytes_allocated += size * sizeof(TYPE);\
break;}
case AttributeUnderlyingType::ut##TYPE:\
{\
attr.null_value = TYPE(null_value.get<NearestFieldType<TYPE>>()); /* NOLINT(bugprone-macro-parentheses) */ \
attr.arrays = std::make_unique<ContainerType<TYPE>>(size); /* NOLINT(bugprone-macro-parentheses) */ \
bytes_allocated += size * sizeof(TYPE);\
break;\
}
DISPATCH(UInt8)
DISPATCH(UInt16)
DISPATCH(UInt32)

View File

@ -257,7 +257,8 @@ private:
void createAttributes();
Attribute createAttributeWithTypeAndName(const AttributeUnderlyingType type, const String & name, const Field & null_value); /* NOLINT(readability-convert-member-functions-to-static) */
/* NOLINTNEXTLINE(readability-convert-member-functions-to-static) */
Attribute createAttributeWithTypeAndName(const AttributeUnderlyingType type, const String & name, const Field & null_value);
template <typename AttributeType, typename OutputType, typename DefaultGetter>
void getItemsNumberImpl(
@ -314,7 +315,6 @@ private:
/// to the expiration time. And it overflows pretty well.
cell.setExpiresAt(std::chrono::time_point<std::chrono::system_clock>::max() - 2 * std::chrono::seconds(extra_lifetime_seconds));
}
}
inline bool isExpired(time_point_t now, time_point_t deadline) const

View File

@ -1028,6 +1028,10 @@ class ClickHouseInstance:
["bash", "-c", 'grep "{}" /var/log/clickhouse-server/clickhouse-server.log || true'.format(substring)])
return len(result) > 0
def file_exists(self, path):
return self.exec_in_container(
["bash", "-c", "echo $(if [ -e '{}' ]; then echo 'yes'; else echo 'no'; fi)".format(path)]) == 'yes\n'
def copy_file_to_container(self, local_path, dest_path):
container_id = self.get_docker_handle().id
return self.cluster.copy_file_to_container(container_id, local_path, dest_path)

View File

@ -204,7 +204,10 @@ def test_reload_after_fail_by_timer(started_cluster):
# Creating the file source makes the dictionary able to load.
instance.copy_file_to_container(os.path.join(SCRIPT_DIR, "configs/dictionaries/file.txt"),
"/etc/clickhouse-server/config.d/no_file_2.txt")
time.sleep(6);
# Check that file appears in container and wait if needed.
while not instance.file_exists("/etc/clickhouse-server/config.d/no_file_2.txt"):
time.sleep(1)
assert("9\t10\n" == instance.exec_in_container("cat /etc/clickhouse-server/config.d/no_file_2.txt"))
query("SELECT dictGetInt32('no_file_2', 'a', toUInt64(9))") == "10\n"
assert get_status("no_file_2") == "LOADED"