Merge pull request #12154 from ClickHouse/fix-test-under-thread-fuzzer

Fix test under thread fuzzer
This commit is contained in:
alexey-milovidov 2020-07-06 19:49:42 +03:00 committed by GitHub
commit fd266ffccd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 54 additions and 1 deletions

View File

@ -0,0 +1,50 @@
#include <Common/ThreadFuzzer.h>
#include <Functions/FunctionFactory.h>
#include <DataTypes/DataTypesNumber.h>
#include <Core/Field.h>
namespace DB
{
/** Returns whether Thread Fuzzer is effective.
* It can be used in tests to prevent too long runs.
*/
class FunctionHasThreadFuzzer : public IFunction
{
public:
static constexpr auto name = "hasThreadFuzzer";
static FunctionPtr create(const Context &)
{
return std::make_shared<FunctionHasThreadFuzzer>();
}
String getName() const override
{
return name;
}
size_t getNumberOfArguments() const override
{
return 0;
}
DataTypePtr getReturnTypeImpl(const DataTypes & /*arguments*/) const override
{
return std::make_shared<DataTypeUInt8>();
}
void executeImpl(Block & block, const ColumnNumbers &, size_t result, size_t input_rows_count) override
{
block.getByPosition(result).column = DataTypeUInt8().createColumnConst(input_rows_count, ThreadFuzzer::instance().isEffective());
}
};
void registerFunctionHasThreadFuzzer(FunctionFactory & factory)
{
factory.registerFunction<FunctionHasThreadFuzzer>();
}
}

View File

@ -58,6 +58,7 @@ void registerFunctionGetMacro(FunctionFactory &);
void registerFunctionGetScalar(FunctionFactory &);
void registerFunctionIsConstant(FunctionFactory &);
void registerFunctionGlobalVariable(FunctionFactory &);
void registerFunctionHasThreadFuzzer(FunctionFactory &);
void registerFunctionInitializeAggregation(FunctionFactory &);
#if USE_ICU
@ -117,6 +118,7 @@ void registerFunctionsMiscellaneous(FunctionFactory & factory)
registerFunctionGetScalar(factory);
registerFunctionIsConstant(factory);
registerFunctionGlobalVariable(factory);
registerFunctionHasThreadFuzzer(factory);
registerFunctionInitializeAggregation(factory);
#if USE_ICU

View File

@ -219,6 +219,7 @@ SRCS(
h3ToParent.cpp
h3ToString.cpp
hasColumnInTable.cpp
hasThreadFuzzer.cpp
hasTokenCaseInsensitive.cpp
hasToken.cpp
hostName.cpp

View File

@ -19,7 +19,7 @@ threads=10
count_multiplier=1
max_time_ms=1000
debug_or_sanitizer_build=`$CLICKHOUSE_CLIENT -q "WITH ((SELECT value FROM system.build_options WHERE name='BUILD_TYPE') AS build, (SELECT value FROM system.build_options WHERE name='CXX_FLAGS') as flags) SELECT build='Debug' OR flags LIKE '%fsanitize%'"`
debug_or_sanitizer_build=`$CLICKHOUSE_CLIENT -q "WITH ((SELECT value FROM system.build_options WHERE name='BUILD_TYPE') AS build, (SELECT value FROM system.build_options WHERE name='CXX_FLAGS') as flags) SELECT build='Debug' OR flags LIKE '%fsanitize%' OR hasThreadFuzzer()"`
if [[ debug_or_sanitizer_build -eq 1 ]]; then tables=100; count_multiplier=10; max_time_ms=1500; fi