Skip to content

Commit 5800488

Browse files
committed
Skipping test if server is too old for SimpleAggregateFunction
1 parent b77b33a commit 5800488

File tree

3 files changed

+41
-10
lines changed

3 files changed

+41
-10
lines changed

clickhouse/client.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,6 @@ struct ClientInfo {
5555
uint32_t client_revision = 0;
5656
};
5757

58-
struct ServerInfo {
59-
std::string name;
60-
std::string timezone;
61-
std::string display_name;
62-
uint64_t version_major;
63-
uint64_t version_minor;
64-
uint64_t version_patch;
65-
uint64_t revision;
66-
};
67-
6858
std::ostream& operator<<(std::ostream& os, const ClientOptions& opt) {
6959
os << "Client(" << opt.user << '@' << opt.host << ":" << opt.port
7060
<< " ping_before_query:" << opt.ping_before_query
@@ -91,6 +81,8 @@ class Client::Impl {
9181

9282
void ResetConnection();
9383

84+
const ServerInfo& GetServerInfo() const;
85+
9486
private:
9587
bool Handshake();
9688

@@ -297,6 +289,10 @@ void Client::Impl::ResetConnection() {
297289
}
298290
}
299291

292+
const ServerInfo& Client::Impl::GetServerInfo() const {
293+
return server_info_;
294+
}
295+
300296
bool Client::Impl::Handshake() {
301297
if (!SendHello()) {
302298
return false;
@@ -789,4 +785,8 @@ void Client::ResetConnection() {
789785
impl_->ResetConnection();
790786
}
791787

788+
const ServerInfo& Client::GetServerInfo() const {
789+
return impl_->GetServerInfo();
790+
}
791+
792792
}

clickhouse/client.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@
2323

2424
namespace clickhouse {
2525

26+
struct ServerInfo {
27+
std::string name;
28+
std::string timezone;
29+
std::string display_name;
30+
uint64_t version_major;
31+
uint64_t version_minor;
32+
uint64_t version_patch;
33+
uint64_t revision;
34+
};
35+
2636
/// Methods of block compression.
2737
enum class CompressionMethod {
2838
None = -1,
@@ -106,6 +116,8 @@ class Client {
106116
/// Reset connection with initial params.
107117
void ResetConnection();
108118

119+
const ServerInfo& GetServerInfo() const;
120+
109121
private:
110122
ClientOptions options_;
111123

ut/client_ut.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@
33

44
using namespace clickhouse;
55

6+
namespace clickhouse
7+
{
8+
std::ostream & operator<<(std::ostream & ostr, const ServerInfo & server_info)
9+
{
10+
return ostr << server_info.name << "/" << server_info.display_name
11+
<< " ver "
12+
<< server_info.version_major << "."
13+
<< server_info.version_minor << "."
14+
<< server_info.version_patch
15+
<< " (" << server_info.revision << ")";
16+
}
17+
}
18+
619
// Use value-parameterized tests to run same tests with different client
720
// options.
821
class ClientCase : public testing::TestWithParam<ClientOptions> {
@@ -285,6 +298,12 @@ TEST_P(ClientCase, Numbers) {
285298
}
286299

287300
TEST_P(ClientCase, SimpleAggregateFunction) {
301+
const auto & server_info = client_->GetServerInfo();
302+
if (server_info.version_major <= 19 && server_info.version_minor < 9) {
303+
std::cout << "Test is skipped since server '" << server_info << "' does not support SimpleAggregateFunction" << std::endl;
304+
return;
305+
}
306+
288307
client_->Execute("DROP TABLE IF EXISTS test_clickhouse_cpp.SimpleAggregateFunction");
289308
client_->Execute(
290309
"CREATE TABLE IF NOT EXISTS test_clickhouse_cpp.SimpleAggregateFunction (saf SimpleAggregateFunction(sum, UInt64))"

0 commit comments

Comments
 (0)