This is an automated email from the ASF dual-hosted git repository. isapego pushed a commit to branch ignite-17424 in repository https://gitbox.apache.org/repos/asf/ignite-3.git
commit 4dfb667079331cb2a0b1d00cbb875251708f88b1 Author: Igor Sapego <isap...@apache.org> AuthorDate: Thu Sep 8 00:39:32 2022 +0400 IGNITE-17424 Tests run --- modules/platforms/cpp/client-test/CMakeLists.txt | 2 +- .../cpp/client-test/src/ignite_client_test.cpp | 41 ++++++++++++++++++++-- modules/platforms/cpp/client/CMakeLists.txt | 4 +++ .../cpp/client/include/ignite/ignite_client.h | 12 +++---- modules/platforms/cpp/client/src/ignite_client.cpp | 8 ++--- .../src/ignite_client.cpp => common/Export.h} | 35 ++++++------------ 6 files changed, 62 insertions(+), 40 deletions(-) diff --git a/modules/platforms/cpp/client-test/CMakeLists.txt b/modules/platforms/cpp/client-test/CMakeLists.txt index aae4c83c7e..d78aa2faa1 100644 --- a/modules/platforms/cpp/client-test/CMakeLists.txt +++ b/modules/platforms/cpp/client-test/CMakeLists.txt @@ -32,7 +32,7 @@ set(SOURCES add_executable(${TARGET} ${SOURCES}) -target_link_libraries(${TARGET} ignite-test-common ${GTEST_LIBRARY}) +target_link_libraries(${TARGET} ignite-test-common ignite-client ${GTEST_LIBRARY}) set(TEST_TARGET IgniteClientTest) add_test(NAME ${TEST_TARGET} COMMAND ${TARGET}) diff --git a/modules/platforms/cpp/client-test/src/ignite_client_test.cpp b/modules/platforms/cpp/client-test/src/ignite_client_test.cpp index 7fc40ed724..9982a62698 100644 --- a/modules/platforms/cpp/client-test/src/ignite_client_test.cpp +++ b/modules/platforms/cpp/client-test/src/ignite_client_test.cpp @@ -20,12 +20,17 @@ #include <gtest/gtest.h> +#include "ignite/ignite_client_configuration.h" +#include "ignite/ignite_client.h" + #include "ignite_node.h" +using namespace ignite; + class ClientTest : public ::testing::Test { protected: ClientTest() = default; - ~ClientTest() = default; + ~ClientTest() override = default; void SetUp() override { @@ -40,13 +45,45 @@ protected: } }; +class TestLogger : public IgniteLogger +{ +public: + void logError(std::string_view message) override + { + std::cout << "ERROR: " << message << std::endl; + } + + void logWarning(std::string_view message) override + { + std::cout << "WARNING: " << message << std::endl; + } + + void logInfo(std::string_view message) override + { + std::cout << "INFO: " << message << std::endl; + } + + void logDebug(std::string_view message) override + { + std::cout << "DEBUG: " << message << std::endl; + } +}; + TEST_F(ClientTest, TestTest) { - ignite::IgniteNode node; + IgniteNode node; node.start(); + // TODO: Implement node startup await std::this_thread::sleep_for(std::chrono::seconds(20)); + IgniteClientConfiguration cfg{"127.0.0.1:10942"}; + cfg.setLogger(std::make_shared<TestLogger>()); + + std::cout << "Connecting..." << std::endl; + + auto client = IgniteClient::startAsync(cfg).get(); + node.stop(); } \ No newline at end of file diff --git a/modules/platforms/cpp/client/CMakeLists.txt b/modules/platforms/cpp/client/CMakeLists.txt index f4d5af46b9..fe28b791ae 100644 --- a/modules/platforms/cpp/client/CMakeLists.txt +++ b/modules/platforms/cpp/client/CMakeLists.txt @@ -36,6 +36,10 @@ if (WIN32) set_target_properties(${TARGET} PROPERTIES OUTPUT_NAME "ignite-client") endif() +if (WIN32) + add_definitions(-DIGNITE_EXPORTS) +endif() + target_link_libraries(${TARGET} ignite-common ignite-network ignite-protocol) target_include_directories(${TARGET} INTERFACE include) diff --git a/modules/platforms/cpp/client/include/ignite/ignite_client.h b/modules/platforms/cpp/client/include/ignite/ignite_client.h index 4a8b45d30e..fab15c17dd 100644 --- a/modules/platforms/cpp/client/include/ignite/ignite_client.h +++ b/modules/platforms/cpp/client/include/ignite/ignite_client.h @@ -20,16 +20,12 @@ #include <future> #include <memory> +#include "common/export.h" #include <ignite/ignite_client_configuration.h> namespace ignite { -namespace impl -{ -class IgniteClientImpl; -} - /** * Ignite client. */ @@ -65,7 +61,7 @@ public: * @param configuration Client configuration. * @return Future with either Ignite client or exception. */ - static std::future<IgniteClient> startAsync(IgniteClientConfiguration configuration); + IGNITE_API static std::future<IgniteClient> startAsync(IgniteClientConfiguration configuration); private: /** @@ -73,10 +69,10 @@ private: * * @param impl Implementation */ - explicit IgniteClient(std::unique_ptr<impl::IgniteClientImpl> impl); + explicit IgniteClient(std::shared_ptr<void> impl); /** Implementation. */ - std::unique_ptr<impl::IgniteClientImpl> m_impl; + std::shared_ptr<void> m_impl; }; } // namespace ignite \ No newline at end of file diff --git a/modules/platforms/cpp/client/src/ignite_client.cpp b/modules/platforms/cpp/client/src/ignite_client.cpp index ddb8975344..234b8776d6 100644 --- a/modules/platforms/cpp/client/src/ignite_client.cpp +++ b/modules/platforms/cpp/client/src/ignite_client.cpp @@ -22,12 +22,10 @@ namespace ignite { - std::future<IgniteClient> IgniteClient::startAsync(IgniteClientConfiguration configuration) { - return std::async(std::launch::async, [cfg = std::move(configuration)]() { - - auto impl = std::make_unique<impl::IgniteClientImpl>(cfg); + return std::async(std::launch::async, [cfg = std::move(configuration)] () mutable { + auto impl = std::make_shared<impl::IgniteClientImpl>(std::move(cfg)); impl->start(); @@ -35,7 +33,7 @@ std::future<IgniteClient> IgniteClient::startAsync(IgniteClientConfiguration con }); } -IgniteClient::IgniteClient(std::unique_ptr<impl::IgniteClientImpl> impl) : +IgniteClient::IgniteClient(std::shared_ptr<void> impl) : m_impl(std::move(impl)) { } } // namespace ignite diff --git a/modules/platforms/cpp/client/src/ignite_client.cpp b/modules/platforms/cpp/common/Export.h similarity index 59% copy from modules/platforms/cpp/client/src/ignite_client.cpp copy to modules/platforms/cpp/common/Export.h index ddb8975344..f619affdbf 100644 --- a/modules/platforms/cpp/client/src/ignite_client.cpp +++ b/modules/platforms/cpp/common/Export.h @@ -15,27 +15,14 @@ * limitations under the License. */ -#include "ignite/ignite_client.h" - -#include "ignite_client_impl.h" - -namespace ignite -{ - - -std::future<IgniteClient> IgniteClient::startAsync(IgniteClientConfiguration configuration) -{ - return std::async(std::launch::async, [cfg = std::move(configuration)]() { - - auto impl = std::make_unique<impl::IgniteClientImpl>(cfg); - - impl->start(); - - return IgniteClient(std::move(impl)); - }); -} - -IgniteClient::IgniteClient(std::unique_ptr<impl::IgniteClientImpl> impl) : - m_impl(std::move(impl)) { } - -} // namespace ignite +#pragma once + +#ifdef _WIN32 +# ifdef IGNITE_EXPORTS +# define IGNITE_API __declspec(dllexport) +# else +# define IGNITE_API __declspec(dllimport) +# endif +#elif +# define IGNITE_API +#endif