Skip to content

Commit

Permalink
test: fix flaky ClientTest test
Browse files Browse the repository at this point in the history
In brew, new stable version of Tarantool is 3.0.0. It has a new feature:
case-sensitive names in SQL. So let's make ClientTest version-independent
and call SQL columns in upper case.

Along the way, let's print response sql metadata in ClientTest - it will
make it easy to find a problem if the test fails.
  • Loading branch information
drewdzzz committed Jan 24, 2024
1 parent bc37f33 commit b04171e
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions test/ClientTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,19 @@ printResponse(Response<BUFFER> &response, Data data = std::vector<UserTuple>())
" code=" << err.errcode << std::endl;
return;
}
if (response.body.metadata != std::nullopt) {
std::cout << "RESPONSE SQL METADATA:" << std::endl;
for (const auto &column : response.body.metadata->column_maps) {
std::cout << "column=" << column.field_name <<
" type=" << column.field_type <<
" collation=" << column.collation <<
" is_nullable=" << column.is_nullable <<
" is_autoincrement" << column.is_autoincrement;
if (column.span.has_value())
std::cout << " span=" << column.span.value();
std::cout << std::endl;
}
}
if (response.body.data != std::nullopt) {
if (!response.body.data->decode(data)) {
std::cerr << "FAILED TO DECODE DATA" << std::endl;
Expand Down Expand Up @@ -750,8 +763,8 @@ single_conn_sql(Connector<BUFFER, NetProvider> &client)
fail_unless(rc == 0);

TEST_CASE("CREATE TABLE");
std::string stmt_str = "CREATE TABLE IF NOT EXISTS tsql (column1 UNSIGNED PRIMARY KEY, "
"column2 VARCHAR(50), column3 DOUBLE);";
std::string stmt_str = "CREATE TABLE IF NOT EXISTS tsql (COLUMN1 UNSIGNED PRIMARY KEY, "
"COLUMN2 VARCHAR(50), COLUMN3 DOUBLE);";
auto stmt = StmtProcessor::process(client, conn, stmt_str);
rid_t create_table = conn.execute(stmt, std::make_tuple());

Expand Down Expand Up @@ -848,8 +861,8 @@ single_conn_sql(Connector<BUFFER, NetProvider> &client)

TEST_CASE("CREATE TABLE with autoincrement and collation");
stmt_str = "CREATE TABLE IF NOT EXISTS tsql "
"(column1 UNSIGNED PRIMARY KEY AUTOINCREMENT, "
"column2 STRING COLLATE \"unicode\", column3 DOUBLE);";
"(COLUMN1 UNSIGNED PRIMARY KEY AUTOINCREMENT, "
"COLUMN2 STRING COLLATE \"unicode\", COLUMN3 DOUBLE);";
stmt = StmtProcessor::process(client, conn, stmt_str);
create_table = conn.execute(stmt, std::make_tuple());
client.wait(conn, create_table, WAIT_TIMEOUT);
Expand Down

0 comments on commit b04171e

Please sign in to comment.