Skip to content

Commit

Permalink
Fix CPP tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
AMashenkov committed Jan 20, 2025
1 parent 6ba66c7 commit 8bb2115
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@

using namespace ignite;

#define TEST_TABLE_NAME "column_order_test"
// TODO https://issues.apache.org/jira/browse/IGNITE-24261 check lowercased name
#define TEST_TABLE_NAME "COLUMN_ORDER_TEST"

/**
* Test suite.
Expand Down
8 changes: 5 additions & 3 deletions modules/platforms/cpp/tests/client-test/ignite_runner_suite.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ using namespace std::string_view_literals;
*/
class ignite_runner_suite : public virtual ::testing::Test {
public:
static constexpr std::string_view TABLE_1 = "tbl1"sv;
static constexpr std::string_view TABLE_NAME_ALL_COLUMNS = "tbl_all_columns"sv;
static constexpr std::string_view TABLE_NAME_ALL_COLUMNS_SQL = "tbl_all_columns_sql"sv;
// TODO https://issues.apache.org/jira/browse/IGNITE-24261 revert changing named to uppercase
static constexpr std::string_view TABLE_1 = "TBL1"sv;
static constexpr std::string_view TABLE_NAME_ALL_COLUMNS = "TBL_ALL_COLUMNS"sv;
static constexpr std::string_view TABLE_NAME_ALL_COLUMNS_SQL = "TBL_ALL_COLUMNS_SQL"sv;


inline static const std::string PLATFORM_TEST_NODE_RUNNER =
"org.apache.ignite.internal.runner.app.PlatformTestNodeRunner";
Expand Down
19 changes: 11 additions & 8 deletions modules/platforms/cpp/tests/client-test/tables_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@

using namespace ignite;

// TODO https://issues.apache.org/jira/browse/IGNITE-24261 check lowercased name
#define TEST_TABLE_NAME "TBL1"

/**
* Test suite.
*/
Expand All @@ -43,9 +46,9 @@ TEST_F(tables_test, tables_get_table) {
auto tableUnknown = tables.get_table("some_unknown");
EXPECT_FALSE(tableUnknown.has_value());

auto table = tables.get_table("tbl1");
auto table = tables.get_table(TEST_TABLE_NAME);
ASSERT_TRUE(table.has_value());
EXPECT_EQ(table->get_name(), "tbl1");
EXPECT_EQ(table->get_name(), TEST_TABLE_NAME);
}

TEST_F(tables_test, tables_get_table_async_promises) {
Expand All @@ -66,11 +69,11 @@ TEST_F(tables_test, tables_get_table_async_promises) {
EXPECT_FALSE(tableUnknown.has_value());

tablePromise = std::make_shared<std::promise<std::optional<table>>>();
tables.get_table_async("tbl1", result_promise_setter(tablePromise));
tables.get_table_async(TEST_TABLE_NAME, result_promise_setter(tablePromise));

auto table = tablePromise->get_future().get();
ASSERT_TRUE(table.has_value());
EXPECT_EQ(table->get_name(), "tbl1");
EXPECT_EQ(table->get_name(), TEST_TABLE_NAME);
}

TEST_F(tables_test, tables_get_table_async_callbacks) {
Expand Down Expand Up @@ -104,7 +107,7 @@ TEST_F(tables_test, tables_get_table_async_callbacks) {
operation1->set_value();
});

tables.get_table_async("tbl1", [&](auto tableRes) {
tables.get_table_async(TEST_TABLE_NAME, [&](auto tableRes) {
if (!check_and_set_operation_error(*operation2, tableRes))
return;

Expand All @@ -113,7 +116,7 @@ TEST_F(tables_test, tables_get_table_async_callbacks) {
operation2->set_exception(std::make_exception_ptr(ignite_error("Table should not be null")));
return;
}
if (table->get_name() != "tbl1") {
if (table->get_name() != TEST_TABLE_NAME) {
operation2->set_exception(
std::make_exception_ptr(ignite_error("Table has unexpected name: " + table->get_name())));
return;
Expand All @@ -140,7 +143,7 @@ TEST_F(tables_test, tables_get_tables) {
auto tables = tablesApi.get_tables();
ASSERT_GT(tables.size(), 0);

auto it = std::find_if(tables.begin(), tables.end(), [](auto &table) { return table.get_name() == "TBL1"; });
auto it = std::find_if(tables.begin(), tables.end(), [](auto &table) { return table.get_name() == TEST_TABLE_NAME; });

ASSERT_NE(it, tables.end());
}
Expand All @@ -159,7 +162,7 @@ TEST_F(tables_test, tables_get_tables_async_promises) {
auto tables = tablesPromise->get_future().get();
ASSERT_GT(tables.size(), 0);

auto it = std::find_if(tables.begin(), tables.end(), [](auto &table) { return table.get_name() == "TBL1"; });
auto it = std::find_if(tables.begin(), tables.end(), [](auto &table) { return table.get_name() == TEST_TABLE_NAME; });

ASSERT_NE(it, tables.end());
}
39 changes: 21 additions & 18 deletions modules/platforms/cpp/tests/client-test/transactions_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@

using namespace ignite;

// TODO https://issues.apache.org/jira/browse/IGNITE-24261 check lowercased name
#define TEST_TABLE_NAME "TBL1"

/**
* Test suite.
*/
Expand Down Expand Up @@ -68,7 +71,7 @@ TEST_F(transactions_test, empty_transaction_commit) {
}

TEST_F(transactions_test, commit_updates_data) {
auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view();
auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view();

auto tx = m_client.get_transactions().begin();

Expand All @@ -86,7 +89,7 @@ TEST_F(transactions_test, commit_updates_data) {
}

TEST_F(transactions_test, rollback_does_not_update_data) {
auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view();
auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view();

auto tx = m_client.get_transactions().begin();

Expand All @@ -102,7 +105,7 @@ TEST_F(transactions_test, rollback_does_not_update_data) {

// TODO https://issues.apache.org/jira/browse/IGNITE-22057
TEST_F(transactions_test, DISABLED_destruction_does_not_update_data) {
auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view();
auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view();

{
auto tx = m_client.get_transactions().begin();
Expand All @@ -117,7 +120,7 @@ TEST_F(transactions_test, DISABLED_destruction_does_not_update_data) {
}

TEST_F(transactions_test, non_committed_data_visible_for_tx) {
auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view();
auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view();

auto tx = m_client.get_transactions().begin();

Expand All @@ -133,7 +136,7 @@ TEST_F(transactions_test, non_committed_data_visible_for_tx) {
}

TEST_F(transactions_test, sql_commit) {
auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view();
auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view();

auto tx = m_client.get_transactions().begin();

Expand All @@ -151,7 +154,7 @@ TEST_F(transactions_test, sql_commit) {
}

TEST_F(transactions_test, sql_rollback) {
auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view();
auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view();

auto tx = m_client.get_transactions().begin();

Expand Down Expand Up @@ -194,7 +197,7 @@ TEST_F(transactions_test, rollback_after_rollback_works) {
}

TEST_F(transactions_test, record_view_upsert_all) {
auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view();
auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view();

auto tx = m_client.get_transactions().begin();

Expand All @@ -217,7 +220,7 @@ TEST_F(transactions_test, record_view_upsert_all) {
}

TEST_F(transactions_test, record_view_get_and_upsert) {
auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view();
auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view();

auto tx = m_client.get_transactions().begin();

Expand All @@ -241,7 +244,7 @@ TEST_F(transactions_test, record_view_get_and_upsert) {
}

TEST_F(transactions_test, record_view_insert) {
auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view();
auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view();

auto tx = m_client.get_transactions().begin();

Expand All @@ -263,7 +266,7 @@ TEST_F(transactions_test, record_view_insert) {
}

TEST_F(transactions_test, record_view_insert_all) {
auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view();
auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view();

auto tx = m_client.get_transactions().begin();

Expand All @@ -286,7 +289,7 @@ TEST_F(transactions_test, record_view_insert_all) {
}

TEST_F(transactions_test, record_view_replace) {
auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view();
auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view();

auto tx = m_client.get_transactions().begin();

Expand All @@ -305,7 +308,7 @@ TEST_F(transactions_test, record_view_replace) {
}

TEST_F(transactions_test, record_view_replace_exact) {
auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view();
auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view();

auto tx = m_client.get_transactions().begin();

Expand All @@ -324,7 +327,7 @@ TEST_F(transactions_test, record_view_replace_exact) {
}

TEST_F(transactions_test, record_view_get_and_replace) {
auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view();
auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view();

auto tx = m_client.get_transactions().begin();

Expand All @@ -346,7 +349,7 @@ TEST_F(transactions_test, record_view_get_and_replace) {
}

TEST_F(transactions_test, record_view_remove) {
auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view();
auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view();

auto value0 = get_tuple(42, "Lorem ipsum");
record_view.insert(nullptr, value0);
Expand All @@ -362,7 +365,7 @@ TEST_F(transactions_test, record_view_remove) {
}

TEST_F(transactions_test, record_view_remove_exact) {
auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view();
auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view();

auto value0 = get_tuple(42, "Lorem ipsum");
record_view.insert(nullptr, value0);
Expand All @@ -378,7 +381,7 @@ TEST_F(transactions_test, record_view_remove_exact) {
}

TEST_F(transactions_test, record_view_get_and_remove) {
auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view();
auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view();

auto value0 = get_tuple(42, "Lorem ipsum");
record_view.insert(nullptr, value0);
Expand All @@ -402,7 +405,7 @@ TEST_F(transactions_test, record_view_get_and_remove) {
}

TEST_F(transactions_test, record_view_remove_all) {
auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view();
auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view();

auto value0 = get_tuple(42, "Lorem ipsum");
record_view.insert(nullptr, value0);
Expand All @@ -418,7 +421,7 @@ TEST_F(transactions_test, record_view_remove_all) {
}

TEST_F(transactions_test, record_view_remove_all_exact) {
auto record_view = m_client.get_tables().get_table("tbl1")->get_record_binary_view();
auto record_view = m_client.get_tables().get_table(TABLE_1)->get_record_binary_view();

auto value0 = get_tuple(42, "Lorem ipsum");
record_view.insert(nullptr, value0);
Expand Down
7 changes: 4 additions & 3 deletions modules/platforms/cpp/tests/odbc-test/odbc_suite.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ namespace ignite {
*/
class odbc_suite : public virtual ::testing::Test, public odbc_connection {
public:
static inline const std::string TABLE_1 = "tbl1";
static inline const std::string TABLE_NAME_ALL_COLUMNS = "tbl_all_columns";
static inline const std::string TABLE_NAME_ALL_COLUMNS_SQL = "tbl_all_columns_sql";
// TODO https://issues.apache.org/jira/browse/IGNITE-24261 revert changing named to uppercase
static inline const std::string TABLE_1 = "TBL1";
static inline const std::string TABLE_NAME_ALL_COLUMNS = "TBL_ALL_COLUMNS";
static inline const std::string TABLE_NAME_ALL_COLUMNS_SQL = "TBL_ALL_COLUMNS_SQL";

static constexpr const char *KEY_COLUMN = "key";
static constexpr const char *VAL_COLUMN = "val";
Expand Down

0 comments on commit 8bb2115

Please sign in to comment.