This is an automated email from the ASF dual-hosted git repository. isapego pushed a commit to branch ignite-17607 in repository https://gitbox.apache.org/repos/asf/ignite-3.git
commit bd294cb7706df8600852b296fa46b75fe993baff Author: Igor Sapego <[email protected]> AuthorDate: Wed Mar 15 01:18:31 2023 +0300 IGNITE-17607 Add negative tests --- .../cpp/tests/client-test/compute_test.cpp | 33 ++++++++++++++++++++++ .../cpp/tests/client-test/ignite_runner_suite.h | 2 ++ 2 files changed, 35 insertions(+) diff --git a/modules/platforms/cpp/tests/client-test/compute_test.cpp b/modules/platforms/cpp/tests/client-test/compute_test.cpp index c35feba204..e6e2324970 100644 --- a/modules/platforms/cpp/tests/client-test/compute_test.cpp +++ b/modules/platforms/cpp/tests/client-test/compute_test.cpp @@ -139,6 +139,39 @@ TEST_F(compute_test, execute_with_args) { EXPECT_EQ(result.value().get<std::string>(), "5.3_00000000-0000-0000-0000-000000000000_42_null"); } +TEST_F(compute_test, job_error_propagates_to_client) { + auto cluster_nodes = m_client.get_cluster_nodes(); + + EXPECT_THROW( + { + try { + m_client.get_compute().execute(cluster_nodes, ERROR_JOB, {"unused"}); + } catch (const ignite_error &e) { + EXPECT_THAT(e.what_str(), testing::HasSubstr("Custom job error")); + EXPECT_THAT(e.what_str(), testing::HasSubstr( + "org.apache.ignite.internal.runner.app.client.ItThinClientComputeTest$CustomException")); + EXPECT_THAT(e.what_str(), testing::HasSubstr("IGN-TBL-3")); + throw; + } + }, + ignite_error); +} + +TEST_F(compute_test, unknown_node_throws) { + auto unknown_node = cluster_node("some", "random", {"127.0.0.1", 1234}); + + EXPECT_THROW( + { + try { + m_client.get_compute().execute({unknown_node}, ECHO_JOB, {"unused"}); + } catch (const ignite_error &e) { + EXPECT_THAT(e.what_str(), testing::HasSubstr("Specified node is not present in the cluster: random")); + throw; + } + }, + ignite_error); +} + diff --git a/modules/platforms/cpp/tests/client-test/ignite_runner_suite.h b/modules/platforms/cpp/tests/client-test/ignite_runner_suite.h index e45c04c56a..288a0f2bae 100644 --- a/modules/platforms/cpp/tests/client-test/ignite_runner_suite.h +++ b/modules/platforms/cpp/tests/client-test/ignite_runner_suite.h @@ -51,6 +51,8 @@ public: inline static const std::string NODE_NAME_JOB = IT_THIN_CLIENT_COMPUTE_TEST + "$NodeNameJob"; inline static const std::string CONCAT_JOB = IT_THIN_CLIENT_COMPUTE_TEST + "$ConcatJob"; + inline static const std::string ERROR_JOB = IT_THIN_CLIENT_COMPUTE_TEST + "$IgniteExceptionJob"; + inline static const std::string ECHO_JOB = IT_THIN_CLIENT_COMPUTE_TEST + "$EchoJob"; static constexpr const char *KEY_COLUMN = "key"; static constexpr const char *VAL_COLUMN = "val";
