Skip to content

Commit ed8cea2

Browse files
authored
Merge pull request #298 from Enmk/dont_run_query_id_tests_on_non_Linux
Dont run query id tests on non linux
2 parents 4179250 + 2727d49 commit ed8cea2

File tree

6 files changed

+60
-7
lines changed

6 files changed

+60
-7
lines changed

.github/workflows/macos.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ jobs:
6565
working-directory: ${{github.workspace}}/build/ut
6666
env:
6767
# It is impossible to start CH server in docker on macOS due to github actions limitations,
68-
# so limit tests to ones that do no require server interaction.
69-
GTEST_FILTER_ONLY_LOCAL: "-Client/*"
70-
run: ./clickhouse-cpp-ut
68+
# so we use remote server to execute tests, some do not allow some features for anonymoust/free users:
69+
# - system.query_log used by 'Client/ClientCase.Query_ID'
70+
GTEST_FILTER: "-Client/ClientCase.Query_ID*"
71+
run: ./clickhouse-cpp-ut ${GTEST_FILTER}

.github/workflows/windows_mingw.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,12 @@ jobs:
8181
./go-tlsoffloader.exe -l localhost:9000 -b github.demo.trial.altinity.cloud:9440 &
8282
8383
- name: Test
84-
run: ./build/ut/clickhouse-cpp-ut.exe
84+
env:
85+
# It is impossible to start CH server in docker on Windows due to github actions limitations,
86+
# so we use remote server to execute tests, some do not allow some features for anonymoust/free users:
87+
# - system.query_log used by 'Client/ClientCase.Query_ID'
88+
GTEST_FILTER: "-Client/ClientCase.Query_ID*"
89+
run: ./build/ut/clickhouse-cpp-ut.exe ${GTEST_FILTER}
8590

8691
- name: Test (simple)
8792
run: ./build/tests/simple/simple-test.exe

.github/workflows/windows_msvc.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ on:
1010

1111
env:
1212
BUILD_TYPE: Release
13-
GTEST_FILTER: --gtest_filter=-"*"
1413
CLICKHOUSE_USER: clickhouse_cpp_cicd
1514
CLICKHOUSE_PASSWORD: clickhouse_cpp_cicd
1615
#
@@ -58,5 +57,10 @@ jobs:
5857
./go-tlsoffloader.exe -l localhost:9000 -b github.demo.trial.altinity.cloud:9440 &
5958
6059
- name: Test
60+
env:
61+
# It is impossible to start CH server in docker on Windows due to github actions limitations,
62+
# so we use remote server to execute tests, some do not allow some features for anonymoust/free users:
63+
# - system.query_log used by 'Client/ClientCase.Query_ID'
64+
GTEST_FILTER: "-Client/ClientCase.Query_ID*"
6165
working-directory: ${{github.workspace}}/build/ut
6266
run: Release\clickhouse-cpp-ut.exe "${{env.GTEST_FILTER}}"

clickhouse/query.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ using SelectCallback = std::function<void(const Block& block)>;
8080
using SelectCancelableCallback = std::function<bool(const Block& block)>;
8181
using SelectServerLogCallback = std::function<bool(const Block& block)>;
8282
using ProfileEventsCallback = std::function<bool(const Block& block)>;
83+
using ProfileCallbak = std::function<void(const Profile& profile)>;
8384

8485

8586
class Query : public QueryEvents {
@@ -159,6 +160,11 @@ class Query : public QueryEvents {
159160
return *this;
160161
}
161162

163+
inline Query& OnProfile(ProfileCallbak cb) {
164+
profile_callback_cb_ = std::move(cb);
165+
return *this;
166+
}
167+
162168
static const std::string default_query_id;
163169

164170
private:
@@ -183,7 +189,8 @@ class Query : public QueryEvents {
183189
}
184190

185191
void OnProfile(const Profile& profile) override {
186-
(void)profile;
192+
if (profile_callback_cb_)
193+
profile_callback_cb_(profile);
187194
}
188195

189196
void OnProgress(const Progress& progress) override {
@@ -218,6 +225,7 @@ class Query : public QueryEvents {
218225
SelectCancelableCallback select_cancelable_cb_;
219226
SelectServerLogCallback select_server_log_cb_;
220227
ProfileEventsCallback profile_events_callback_cb_;
228+
ProfileCallbak profile_callback_cb_;
221229
};
222230

223231
}

ut/client_ut.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <gtest/gtest.h>
88

9+
#include <optional>
910
#include <thread>
1011
#include <chrono>
1112

@@ -1116,6 +1117,37 @@ TEST_P(ClientCase, OnProfileEvents) {
11161117
}
11171118
}
11181119

1120+
TEST_P(ClientCase, OnProfile) {
1121+
Query query("SELECT * FROM system.numbers LIMIT 10;");
1122+
1123+
std::optional<Profile> profile;
1124+
query.OnProfile([&profile](const Profile & new_profile) {
1125+
profile = new_profile;
1126+
1127+
std::cout <<
1128+
"Profile:" <<
1129+
"\n\trows: " << new_profile.rows <<
1130+
"\n\tblocks: " << new_profile.blocks <<
1131+
"\n\tbytes: " << new_profile.bytes <<
1132+
"\n\trows_before_limit: " << new_profile.rows_before_limit <<
1133+
"\n\tapplied_limit: " << new_profile.applied_limit <<
1134+
"\n\tcalculated_rows_before_limit: " << new_profile.calculated_rows_before_limit <<
1135+
std::endl;
1136+
});
1137+
1138+
client_->Execute(query);
1139+
1140+
// Make sure that profile event came through
1141+
ASSERT_NE(profile, std::nullopt);
1142+
1143+
EXPECT_GE(profile->rows, 10u);
1144+
EXPECT_GE(profile->blocks, 1u);
1145+
EXPECT_GT(profile->bytes, 1u);
1146+
EXPECT_GE(profile->rows_before_limit, 10u);
1147+
EXPECT_EQ(profile->applied_limit, true);
1148+
EXPECT_EQ(profile->calculated_rows_before_limit, true);
1149+
}
1150+
11191151
TEST_P(ClientCase, SelectAggregateFunction) {
11201152
// Verifies that perofing SELECT value of type AggregateFunction(...) doesn't crash the client.
11211153
// For details: https://github.com/ClickHouse/clickhouse-cpp/issues/266

ut/utils.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <cinttypes>
2222
#include <iomanip>
2323
#include <sstream>
24+
#include <type_traits>
2425

2526

2627
namespace {
@@ -51,7 +52,9 @@ std::ostream& operator<<(std::ostream & ostr, const DateTimeValue & time) {
5152
template <typename ColumnType, typename AsType = decltype(std::declval<ColumnType>().At(0)) >
5253
bool doPrintValue(const ColumnRef & c, const size_t row, std::ostream & ostr) {
5354
if (const auto & casted_c = c->As<ColumnType>()) {
54-
if constexpr (is_container_v<std::decay_t<AsType>>) {
55+
if constexpr (is_container_v<std::decay_t<AsType>>
56+
&& !std::is_same_v<ColumnType, ColumnString>
57+
&& !std::is_same_v<ColumnType, ColumnFixedString>) {
5558
ostr << PrintContainer{static_cast<AsType>(casted_c->At(row))};
5659
} else {
5760
ostr << static_cast<AsType>(casted_c->At(row));

0 commit comments

Comments
 (0)