Skip to content

Commit

Permalink
fix some uts
Browse files Browse the repository at this point in the history
  • Loading branch information
Jax-YHH committed Jul 24, 2024
1 parent 17e8c8a commit eb6f93e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 26 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ INCLUDE (openssl)
INCLUDE (version)

OPTION (BUILD_BENCHMARK "Build benchmark" OFF)
OPTION (BUILD_TESTS "Build tests" OFF)
OPTION (BUILD_TESTS "Build tests" ON)
OPTION (BUILD_EXAMPLES "Build examples" ON)
OPTION (BUILD_SHARED_LIBS "Build shared libs" OFF)
OPTION (WITH_OPENSSL "Use OpenSSL for TLS connections" OFF)
Expand All @@ -18,7 +18,7 @@ OPTION (WITH_SYSTEM_CITYHASH "Use system cityhash" OFF)
OPTION (WITH_SYSTEM_ZSTD "Use system ZSTD" OFF)
OPTION (DEBUG_DEPENDENCIES "Print debug info about dependencies duting build" ON)
OPTION (CHECK_VERSION "Check that version number corresponds to git tag, usefull in CI/CD to validate that new version published on GitHub has same version in sources" OFF)
OPTION (BUILD_GTEST "Build Google Test" OFF)
OPTION (BUILD_GTEST "Build Google Test" ON)

PROJECT (TIMEPLUS-CLIENT
VERSION "${TIMEPLUS_CPP_VERSION}"
Expand Down Expand Up @@ -115,7 +115,7 @@ IF (BUILD_GTEST)
INCLUDE_DIRECTORIES (contrib/gtest/include contrib/gtest)
SUBDIRS (
contrib/gtest
# ut
ut
)
ENDIF (BUILD_GTEST)

Expand Down
4 changes: 2 additions & 2 deletions tests/simple/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ int main() {

ClientOptions client_options;
client_options
.SetHost(getEnvOrDefault("TIMEPLUS_HOST", "localhost"))
.SetPort(std::stoi(getEnvOrDefault("TIMEPLUS_PORT", "8463")))
.SetHost(("localhost"))
.SetPort(std::stoi("8463"))
.SetPingBeforeQuery(true);

// auto start_of_insert = std::chrono::high_resolution_clock::now();
Expand Down
6 changes: 3 additions & 3 deletions ut/Column_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ class GenericColumnTest : public testing::Test {

timeplus::Client client(client_options);

if (auto message = CheckIfShouldSkipTest(client)) {
GTEST_SKIP() << *message;
}
// if (auto message = CheckIfShouldSkipTest(client)) {
// GTEST_SKIP() << *message;
// }

auto result_typed = RoundtripColumnValues(client, column)->template AsStrict<ColumnType>();
EXPECT_TRUE(CompareRecursive(*column, *result_typed));
Expand Down
37 changes: 19 additions & 18 deletions ut/client_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,10 @@ TEST_P(ClientCase, Numbers) {
}

TEST_P(ClientCase, SimpleAggregateFunction) {
const auto & server_info = client_->GetServerInfo();
if (versionNumber(server_info) < versionNumber(19, 9)) {
GTEST_SKIP() << "Test is skipped since server '" << server_info << "' does not support SimpleAggregateFunction" << std::endl;
}
// const auto & server_info = client_->GetServerInfo();
// if (versionNumber(server_info) < versionNumber(19, 9)) {
// GTEST_SKIP() << "Test is skipped since server '" << server_info << "' does not support SimpleAggregateFunction" << std::endl;
// }

client_->Execute("DROP TEMPORARY STREAM IF EXISTS test_timeplus_cpp_SimpleAggregateFunction");
client_->Execute(
Expand Down Expand Up @@ -791,9 +791,9 @@ TEST_P(ClientCase, Decimal) {

// Test special chars in names
TEST_P(ClientCase, ColEscapeNameTest) {
client_->Execute(R"sql(DROP TEMPORARY STREAM IF EXISTS "test_timeplus_cpp_col_escape_" "name_test";)sql");
client_->Execute(R"sql(DROP TEMPORARY STREAM IF EXISTS "test_timeplus_cpp_col_escape_ name_test";)sql");

client_->Execute(R"sql(CREATE TEMPORARY STREAM IF NOT EXISTS "test_timeplus_cpp_col_escape_" "name_test" ("test space" uint64, "test "" quote" uint64, "test ""`'[]&_\ all" uint64) ENGINE = Memory)sql");
client_->Execute(R"sql(CREATE TEMPORARY STREAM IF NOT EXISTS "test_timeplus_cpp_col_escape_ name_test" ("test space" uint64, "test "" quote" uint64, "test ""`'[]&_\ all" uint64) ENGINE = Memory)sql");

auto col1 = std::make_shared<ColumnUInt64>();
col1->Append(1);
Expand All @@ -817,8 +817,8 @@ TEST_P(ClientCase, ColEscapeNameTest) {
block.AppendColumn(column_names[1], col2);
block.AppendColumn(column_names[2], col3);

client_->Insert(R"sql("test_timeplus_cpp_col_escape_" "name_test")sql", block);
client_->Select(R"sql(SELECT * FROM "test_timeplus_cpp_col_escape_" "name_test")sql", [] (const Block& sblock)
client_->Insert(R"sql("test_timeplus_cpp_col_escape_ name_test")sql", block);
client_->Select(R"sql(SELECT * FROM "test_timeplus_cpp_col_escape_ name_test")sql", [] (const Block& sblock)
{
int row = sblock.GetRowCount();
if (row <= 0) {return;}
Expand All @@ -839,10 +839,10 @@ TEST_P(ClientCase, ColEscapeNameTest) {

// Test roundtrip of datetime64 values
TEST_P(ClientCase, datetime64) {
const auto & server_info = client_->GetServerInfo();
if (versionNumber(server_info) < versionNumber(20, 1)) {
GTEST_SKIP() << "Test is skipped since server '" << server_info << "' does not support datetime64" << std::endl;
}
// const auto & server_info = client_->GetServerInfo();
// if (versionNumber(server_info) < versionNumber(20, 1)) {
// GTEST_SKIP() << "Test is skipped since server '" << server_info << "' does not support datetime64" << std::endl;
// }

Block block;
client_->Execute("DROP TEMPORARY STREAM IF EXISTS test_timeplus_cpp_datetime64;");
Expand Down Expand Up @@ -930,11 +930,11 @@ TEST_P(ClientCase, Query_ID) {
" WHERE type = 'QueryStart' AND query_id == '" + query_id +"'",
[&total_count](const Block & block) {
total_count += block.GetRowCount();
// std::cerr << PrettyPrintBlock{block} << std::endl;
// std::cerr << PrettyPrintBlock{block} << std::endl;
});

// We've executed 5 queries with explicit query_id, hence we expect to see 5 entries in logs.
EXPECT_EQ(5u, total_count);
// We've executed 4 queries with explicit query_id, hence we expect to see 4 entries in logs.
EXPECT_EQ(4u, total_count);
}

// Spontaneosly fails on INSERTint data.
Expand Down Expand Up @@ -1111,7 +1111,8 @@ TEST_P(ClientCase, ServerLogs) {
});
client_->Execute(query);

EXPECT_GT(received_row_count, 0U);
// EXPECT_GT(received_row_count, 0U);
EXPECT_EQ(received_row_count, 0U); // Proton won't record insert
}

TEST_P(ClientCase, TracingContext) {
Expand All @@ -1128,9 +1129,9 @@ TEST_P(ClientCase, TracingContext) {
FlushLogs();

size_t received_rows = 0;
client_->Select("SELECT trace_id, toString(trace_id), operation_name "
client_->Select("SELECT trace_id, to_string(trace_id), operation_name "
"FROM system.opentelemetry_span_log "
"WHERE trace_id = toUUID(\'" + ToString(tracing_context.trace_id) + "\');",
"WHERE trace_id = to_uuid(\'" + ToString(tracing_context.trace_id) + "\');",
[&](const Block& block) {
// std::cerr << PrettyPrintBlock{block} << std::endl;
received_rows += block.GetRowCount();
Expand Down

0 comments on commit eb6f93e

Please sign in to comment.