|
1 | 1 | #include <clickhouse/client.h>
|
| 2 | + |
2 | 3 | #include "readonly_client_test.h"
|
3 | 4 | #include "connection_failed_client_test.h"
|
4 | 5 | #include "utils.h"
|
| 6 | + |
5 | 7 | #include <gtest/gtest.h>
|
6 | 8 |
|
7 | 9 | #include <cmath>
|
| 10 | +#include <thread> |
| 11 | +#include <chrono> |
8 | 12 |
|
9 | 13 | using namespace clickhouse;
|
10 | 14 |
|
@@ -882,7 +886,19 @@ TEST_P(ClientCase, Query_ID) {
|
882 | 886 | client_->SelectCancelable("SELECT 'b', count(*) FROM " + table_name, query_id, [](const Block &) { return true; });
|
883 | 887 | client_->Execute(Query("TRUNCATE TABLE " + table_name, query_id));
|
884 | 888 |
|
885 |
| - client_->Execute("SYSTEM FLUSH LOGS"); |
| 889 | + try { |
| 890 | + client_->Execute("SYSTEM FLUSH LOGS"); |
| 891 | + } catch (const std::exception & e) { |
| 892 | + // DB::Exception: clickhouse_cpp_cicd: Not enough privileges. To execute this query it's necessary to have grant SYSTEM FLUSH LOGS ON |
| 893 | + if (std::string(e.what()).find("To execute this query it's necessary to have grant SYSTEM FLUSH LOGS ON") != std::string::npos) { |
| 894 | + // Insufficient privileges, the only safe way is to wait long enough for system |
| 895 | + // to flush the logs automaticaly. Usualy it takes 7.5 seconds, so just in case, |
| 896 | + // wait 3 times that to ensure that all previously executed queries are in the logs now. |
| 897 | + const auto wait_duration = std::chrono::seconds(23); |
| 898 | + std::cerr << "Got error while flushing logs, now we wait " << wait_duration << "..." << std::endl; |
| 899 | + std::this_thread::sleep_for(wait_duration); |
| 900 | + } |
| 901 | + } |
886 | 902 |
|
887 | 903 | size_t total_count = 0;
|
888 | 904 | client_->Select("SELECT type, query_kind, query_id, query "
|
|
0 commit comments