Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ jobs:
env:
# It is impossible to start CH server in docker on macOS due to github actions limitations,
# so we use remote server to execute tests, some do not allow some features for anonymoust/free users:
# - system.query_log used by 'Client/ClientCase.Query_ID'
GTEST_FILTER: "-Client/ClientCase.Query_ID*:Client/ClientCase.TracingContext/*"
# - system.query_log used by 'Client/ClientCase.Query_ID' and 'Client/ClientCase.ClientName'
# - system.opentelemetry_span_log is used by 'Client/ClientCase.TracingContext'
GTEST_FILTER: "-Client/ClientCase.Query_ID*:Client/ClientCase.TracingContext/*:Client/ClientCase.ClientName/*"
run: ./clickhouse-cpp-ut ${GTEST_FILTER}
5 changes: 3 additions & 2 deletions .github/workflows/windows_mingw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ jobs:
env:
# It is impossible to start CH server in docker on Windows due to github actions limitations,
# so we use remote server to execute tests, some do not allow some features for anonymoust/free users:
# - system.query_log used by 'Client/ClientCase.Query_ID'
GTEST_FILTER: "-Client/ClientCase.Query_ID*:Client/ClientCase.TracingContext/*"
# - system.query_log used by 'Client/ClientCase.Query_ID' and 'Client/ClientCase.ClientName'
# - system.opentelemetry_span_log is used by 'Client/ClientCase.TracingContext'
GTEST_FILTER: "-Client/ClientCase.Query_ID*:Client/ClientCase.TracingContext/*:Client/ClientCase.ClientName/*"
run: ./build/ut/clickhouse-cpp-ut.exe ${GTEST_FILTER}

- name: Test (simple)
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/windows_msvc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ jobs:
env:
# It is impossible to start CH server in docker on Windows due to github actions limitations,
# so we use remote server to execute tests, some do not allow some features for anonymoust/free users:
# - system.query_log used by 'Client/ClientCase.Query_ID'
GTEST_FILTER: "-Client/ClientCase.Query_ID*:Client/ClientCase.TracingContext/*"
# - system.query_log used by 'Client/ClientCase.Query_ID' and 'Client/ClientCase.ClientName'
# - system.opentelemetry_span_log is used by 'Client/ClientCase.TracingContext'
GTEST_FILTER: "-Client/ClientCase.Query_ID*:Client/ClientCase.TracingContext/*:Client/ClientCase.ClientName/*"
working-directory: ${{github.workspace}}/build/ut
run: Release\clickhouse-cpp-ut.exe "${{env.GTEST_FILTER}}"
6 changes: 3 additions & 3 deletions clickhouse/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "base/sslsocket.h"
#endif

#define DBMS_NAME "ClickHouse"
#define CLIENT_NAME "clickhouse-cpp"

#define DBMS_MIN_REVISION_WITH_TEMPORARY_TABLES 50264
#define DBMS_MIN_REVISION_WITH_TOTAL_ROWS_IN_PROGRESS 51554
Expand Down Expand Up @@ -813,7 +813,7 @@ void Client::Impl::SendQuery(const Query& query, bool finalize) {
ClientInfo info;

info.query_kind = 1;
info.client_name = "ClickHouse client";
info.client_name = CLIENT_NAME;
info.client_version_major = CLICKHOUSE_CPP_VERSION_MAJOR;
info.client_version_minor = CLICKHOUSE_CPP_VERSION_MINOR;
info.client_version_patch = CLICKHOUSE_CPP_VERSION_PATCH;
Expand Down Expand Up @@ -978,7 +978,7 @@ void Client::Impl::InitializeStreams(std::unique_ptr<SocketBase>&& socket) {

bool Client::Impl::SendHello() {
WireFormat::WriteUInt64(*output_, ClientCodes::Hello);
WireFormat::WriteString(*output_, std::string(DBMS_NAME) + " client");
WireFormat::WriteString(*output_, std::string(CLIENT_NAME));
WireFormat::WriteUInt64(*output_, CLICKHOUSE_CPP_VERSION_MAJOR);
WireFormat::WriteUInt64(*output_, CLICKHOUSE_CPP_VERSION_MINOR);
WireFormat::WriteUInt64(*output_, DMBS_PROTOCOL_REVISION);
Expand Down
27 changes: 27 additions & 0 deletions ut/client_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1553,3 +1553,30 @@ TEST_P(ClientCase, QueryParameters) {

client_->Execute("DROP TEMPORARY TABLE " + table_name);
}

TEST_P(ClientCase, ClientName) {
const auto server_info = client_->GetServerInfo();

std::srand(std::time(nullptr) + reinterpret_cast<int64_t>(&server_info));
const auto * test_info = ::testing::UnitTest::GetInstance()->current_test_info();
const std::string query_id = std::to_string(std::rand()) + "-" + test_info->test_suite_name() + "/" + test_info->name();

SCOPED_TRACE(query_id);

client_->Select("SELECT 1", query_id, [](const Block&) { /* make sure the data is delivered in full */ });

FlushLogs();

std::string query_log_query
= "SELECT CAST(client_name, 'String') FROM system.query_log WHERE query_id = '" + query_id + "'";

size_t total_rows = 0;
client_->Select(query_log_query, [&total_rows](const Block& block) {
const auto row_count = block.GetRowCount();
total_rows += row_count;
for (size_t i = 0; i < row_count; ++i) {
ASSERT_EQ(block[0]->AsStrict<ColumnString>()->At(i), "clickhouse-cpp");
}
});
ASSERT_GT(total_rows, 0UL) << "Query with query_id " << query_id << " is not found";
}
Loading