Add ability to create, fill and drop tables in perftest

This commit is contained in:
alesapin 2019-02-01 18:10:13 +03:00
parent 1a69ccfa8f
commit 7fb2556a23
7 changed files with 61 additions and 21 deletions

View File

@ -128,6 +128,32 @@ UInt64 PerformanceTest::calculateMaxExecTime() const
return result; return result;
} }
void PerformanceTest::prepare() const
{
for (const auto & query : test_info.create_queries)
{
LOG_INFO(log, "Executing create query '" << query << "'");
connection.sendQuery(query);
}
for (const auto & query : test_info.fill_queries)
{
LOG_INFO(log, "Executing fill query '" << query << "'");
connection.sendQuery(query);
}
}
void PerformanceTest::finish() const
{
for (const auto & query : test_info.drop_queries)
{
LOG_INFO(log, "Executing drop query '" << query << "'");
connection.sendQuery(query);
}
}
std::vector<TestStats> PerformanceTest::execute() std::vector<TestStats> PerformanceTest::execute()
{ {
std::vector<TestStats> statistics_by_run; std::vector<TestStats> statistics_by_run;

View File

@ -25,12 +25,15 @@ public:
Context & context_); Context & context_);
bool checkPreconditions() const; bool checkPreconditions() const;
void prepare() const;
std::vector<TestStats> execute(); std::vector<TestStats> execute();
void finish() const;
const PerformanceTestInfo & getTestInfo() const const PerformanceTestInfo & getTestInfo() const
{ {
return test_info; return test_info;
} }
bool checkSIGINT() const bool checkSIGINT() const
{ {
return got_SIGINT; return got_SIGINT;

View File

@ -90,6 +90,7 @@ PerformanceTestInfo::PerformanceTestInfo(
getExecutionType(config); getExecutionType(config);
getStopConditions(config); getStopConditions(config);
getMetrics(config); getMetrics(config);
extractAuxiliaryQueries(config);
} }
void PerformanceTestInfo::applySettings(XMLConfigurationPtr config) void PerformanceTestInfo::applySettings(XMLConfigurationPtr config)
@ -269,4 +270,16 @@ void PerformanceTestInfo::getMetrics(XMLConfigurationPtr config)
checkMetricsInput(metrics, exec_type); checkMetricsInput(metrics, exec_type);
} }
void PerformanceTestInfo::extractAuxiliaryQueries(XMLConfigurationPtr config)
{
if (config->has("create_query"))
create_queries = getMultipleValuesFromConfig(*config, "", "create_query");
if (config->has("fill_query"))
fill_queries = getMultipleValuesFromConfig(*config, "", "fill_query");
if (config->has("drop_query"))
drop_queries = getMultipleValuesFromConfig(*config, "", "drop_query");
}
} }

View File

@ -43,6 +43,10 @@ public:
std::string profiles_file; std::string profiles_file;
std::vector<TestStopConditions> stop_conditions_by_run; std::vector<TestStopConditions> stop_conditions_by_run;
Strings create_queries;
Strings fill_queries;
Strings drop_queries;
private: private:
void applySettings(XMLConfigurationPtr config); void applySettings(XMLConfigurationPtr config);
void extractQueries(XMLConfigurationPtr config); void extractQueries(XMLConfigurationPtr config);
@ -50,6 +54,7 @@ private:
void getExecutionType(XMLConfigurationPtr config); void getExecutionType(XMLConfigurationPtr config);
void getStopConditions(XMLConfigurationPtr config); void getStopConditions(XMLConfigurationPtr config);
void getMetrics(XMLConfigurationPtr config); void getMetrics(XMLConfigurationPtr config);
void extractAuxiliaryQueries(XMLConfigurationPtr config);
}; };
} }

View File

@ -202,11 +202,18 @@ private:
current.checkPreconditions(); current.checkPreconditions();
LOG_INFO(log, "Preconditions for test '" << info.test_name << "' are fullfilled"); LOG_INFO(log, "Preconditions for test '" << info.test_name << "' are fullfilled");
LOG_INFO(log, "Preparing for run, have " << info.create_queries.size()
<< " create queries and " << info.fill_queries.size() << " fill queries");
current.prepare();
LOG_INFO(log, "Prepared");
LOG_INFO(log, "Running test '" << info.test_name << "'"); LOG_INFO(log, "Running test '" << info.test_name << "'");
auto result = current.execute(); auto result = current.execute();
LOG_INFO(log, "Test '" << info.test_name << "' finished"); LOG_INFO(log, "Test '" << info.test_name << "' finished");
LOG_INFO(log, "Running post run queries");
current.finish();
LOG_INFO(log, "Postqueries finished");
if (lite_output) if (lite_output)
return {report_builder->buildCompactReport(info, result), current.checkSIGINT()}; return {report_builder->buildCompactReport(info, result), current.checkSIGINT()};
else else

View File

@ -2,9 +2,10 @@
<name>trim_whitespaces</name> <name>trim_whitespaces</name>
<type>loop</type> <type>loop</type>
<preconditions> <create_query>CREATE TABLE IF NOT EXISTS whitespaces(value String) ENGINE = MergeTree() PARTITION BY tuple() ORDER BY tuple()</create_query>
<table_exists>whitespaces</table_exists> <fill_query> INSERT INTO whitespaces SELECT value FROM (SELECT arrayStringConcat(groupArray(' ')) AS spaces, concat(spaces, toString(any(number)), spaces) AS value FROM numbers(100000000) GROUP BY pow(number, intHash32(number) % 4) % 12345678)</fill_query>
</preconditions> <fill_query> INSERT INTO whitespaces SELECT value FROM (SELECT arrayStringConcat(groupArray(' ')) AS spaces, concat(spaces, toString(any(number)), spaces) AS value FROM numbers(100000000) GROUP BY pow(number, intHash32(number) % 4) % 12345678)</fill_query>
<fill_query> INSERT INTO whitespaces SELECT value FROM (SELECT arrayStringConcat(groupArray(' ')) AS spaces, concat(spaces, toString(any(number)), spaces) AS value FROM numbers(100000000) GROUP BY pow(number, intHash32(number) % 4) % 12345678)</fill_query>
<stop_conditions> <stop_conditions>
<all_of> <all_of>
@ -32,4 +33,6 @@
</substitutions> </substitutions>
<query>SELECT count() FROM whitespaces WHERE NOT ignore({func})</query> <query>SELECT count() FROM whitespaces WHERE NOT ignore({func})</query>
<drop_query>DROP TABLE IF EXISTS whitespaces</drop_query>
</test> </test>

View File

@ -1,17 +0,0 @@
CREATE TABLE whitespaces
(
value String
)
ENGINE = MergeTree()
PARTITION BY tuple()
ORDER BY tuple()
INSERT INTO whitespaces SELECT value
FROM
(
SELECT
arrayStringConcat(groupArray(' ')) AS spaces,
concat(spaces, toString(any(number)), spaces) AS value
FROM numbers(100000000)
GROUP BY pow(number, intHash32(number) % 4) % 12345678
) -- repeat something like this multiple times and/or just copy whitespaces table into itself