| 1 | #pragma once |
| 2 | #include "StopConditionsSet.h" |
| 3 | #include <Poco/Util/XMLConfiguration.h> |
| 4 | |
| 5 | namespace DB |
| 6 | { |
| 7 | /// Stop conditions for a test run. The running test will be terminated in either of two conditions: |
| 8 | /// 1. All conditions marked 'all_of' are fulfilled |
| 9 | /// or |
| 10 | /// 2. Any condition marked 'any_of' is fulfilled |
| 11 | |
| 12 | using ConfigurationPtr = Poco::AutoPtr<Poco::Util::AbstractConfiguration>; |
| 13 | |
| 14 | class TestStopConditions |
| 15 | { |
| 16 | public: |
| 17 | void loadFromConfig(ConfigurationPtr & stop_conditions_config); |
| 18 | inline bool empty() const |
| 19 | { |
| 20 | return !conditions_all_of.initialized_count && !conditions_any_of.initialized_count; |
| 21 | } |
| 22 | |
| 23 | #define DEFINE_REPORT_FUNC(FUNC_NAME, CONDITION) \ |
| 24 | void FUNC_NAME(UInt64 value) \ |
| 25 | { \ |
| 26 | conditions_all_of.report(value, conditions_all_of.CONDITION); \ |
| 27 | conditions_any_of.report(value, conditions_any_of.CONDITION); \ |
| 28 | } |
| 29 | |
| 30 | DEFINE_REPORT_FUNC(reportTotalTime, total_time_ms) |
| 31 | DEFINE_REPORT_FUNC(reportRowsRead, rows_read) |
| 32 | DEFINE_REPORT_FUNC(reportBytesReadUncompressed, bytes_read_uncompressed) |
| 33 | DEFINE_REPORT_FUNC(reportIterations, iterations) |
| 34 | DEFINE_REPORT_FUNC(reportMinTimeNotChangingFor, min_time_not_changing_for_ms) |
| 35 | DEFINE_REPORT_FUNC(reportMaxSpeedNotChangingFor, max_speed_not_changing_for_ms) |
| 36 | DEFINE_REPORT_FUNC(reportAverageSpeedNotChangingFor, average_speed_not_changing_for_ms) |
| 37 | |
| 38 | #undef REPORT |
| 39 | |
| 40 | bool areFulfilled() const; |
| 41 | |
| 42 | void reset() |
| 43 | { |
| 44 | conditions_all_of.reset(); |
| 45 | conditions_any_of.reset(); |
| 46 | } |
| 47 | |
| 48 | /// Return max exec time for these conditions |
| 49 | /// Return zero if max time cannot be determined |
| 50 | UInt64 getMaxExecTime() const; |
| 51 | |
| 52 | private: |
| 53 | StopConditionsSet conditions_all_of; |
| 54 | StopConditionsSet conditions_any_of; |
| 55 | }; |
| 56 | |
| 57 | } |
| 58 | |