Skip to content

Commit abed8bd

Browse files
committed
Skipping some tests against older server
1 parent 4d34bae commit abed8bd

File tree

4 files changed

+41
-28
lines changed

4 files changed

+41
-28
lines changed

ut/Column_ut.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,21 @@ TYPED_TEST(GenericColumnTest, RoundTrip) {
279279

280280
clickhouse::Client client(LocalHostEndpoint);
281281

282+
if constexpr (std::is_same_v<typename TestFixture::ColumnType, ColumnDate32>) {
283+
// Date32 first appeared in v21.9.2.17-stable
284+
const auto server_info = client.GetServerInfo();
285+
if (versionNumber(server_info) < versionNumber(21, 9)) {
286+
GTEST_SKIP() << "Date32 is availble since v21.9.2.17-stable and can't be tested against server: " << server_info;
287+
}
288+
}
289+
290+
if constexpr (std::is_same_v<typename TestFixture::ColumnType, ColumnInt128>) {
291+
const auto server_info = client.GetServerInfo();
292+
if (versionNumber(server_info) < versionNumber(21, 7)) {
293+
GTEST_SKIP() << "ColumnInt128 is availble since v21.7.2.7-stable and can't be tested against server: " << server_info;
294+
}
295+
}
296+
282297
auto result_typed = RoundtripColumnValues(client, column)->template AsStrict<typename TestFixture::ColumnType>();
283298
EXPECT_TRUE(CompareRecursive(*column, *result_typed));
284299
}

ut/client_ut.cpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,11 @@
77

88
#include <gtest/gtest.h>
99

10-
#include <cmath>
1110
#include <thread>
1211
#include <chrono>
1312

1413
using namespace clickhouse;
1514

16-
namespace {
17-
18-
uint64_t versionNumber(
19-
uint64_t version_major,
20-
uint64_t version_minor,
21-
uint64_t version_patch = 0,
22-
uint64_t revision = 0) {
23-
24-
// in this case version_major can be up to 1000
25-
static auto revision_decimal_places = 8;
26-
static auto patch_decimal_places = 4;
27-
static auto minor_decimal_places = 4;
28-
29-
auto const result = version_major * static_cast<uint64_t>(std::pow(10, minor_decimal_places + patch_decimal_places + revision_decimal_places))
30-
+ version_minor * static_cast<uint64_t>(std::pow(10, patch_decimal_places + revision_decimal_places))
31-
+ version_patch * static_cast<uint64_t>(std::pow(10, revision_decimal_places))
32-
+ revision;
33-
34-
return result;
35-
}
36-
37-
uint64_t versionNumber(const ServerInfo & server_info) {
38-
return versionNumber(server_info.version_major, server_info.version_minor, server_info.version_patch, server_info.revision);
39-
}
40-
41-
}
42-
4315
// Use value-parameterized tests to run same tests with different client
4416
// options.
4517
class ClientCase : public testing::TestWithParam<ClientOptions> {

ut/utils.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,7 @@ std::ostream & operator<<(std::ostream & ostr, const ServerInfo & server_info) {
267267
}
268268

269269
}
270+
271+
uint64_t versionNumber(const ServerInfo & server_info) {
272+
return versionNumber(server_info.version_major, server_info.version_minor, server_info.version_patch, server_info.revision);
273+
}

ut/utils.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <system_error>
1212
#include <type_traits>
1313
#include <vector>
14+
#include <cmath>
1415

1516
#include <time.h>
1617

@@ -135,3 +136,24 @@ std::ostream& operator<<(std::ostream & ostr, const PrintContainer<T>& print_con
135136

136137
return ostr << "]";
137138
}
139+
140+
inline uint64_t versionNumber(
141+
uint64_t version_major,
142+
uint64_t version_minor,
143+
uint64_t version_patch = 0,
144+
uint64_t revision = 0) {
145+
146+
// in this case version_major can be up to 1000
147+
static auto revision_decimal_places = 8;
148+
static auto patch_decimal_places = 4;
149+
static auto minor_decimal_places = 4;
150+
151+
auto const result = version_major * static_cast<uint64_t>(std::pow(10, minor_decimal_places + patch_decimal_places + revision_decimal_places))
152+
+ version_minor * static_cast<uint64_t>(std::pow(10, patch_decimal_places + revision_decimal_places))
153+
+ version_patch * static_cast<uint64_t>(std::pow(10, revision_decimal_places))
154+
+ revision;
155+
156+
return result;
157+
}
158+
159+
uint64_t versionNumber(const clickhouse::ServerInfo & server_info);

0 commit comments

Comments
 (0)