This is an automated email from the ASF dual-hosted git repository.
isapego pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new 7cefb18ddb4 IGNITE-27213 Added windows version for fake_server test
suite. (#7478)
7cefb18ddb4 is described below
commit 7cefb18ddb4731922e95f0d90077cbe7faa88f74
Author: Ed Rakhmankulov <[email protected]>
AuthorDate: Thu Jan 29 18:59:10 2026 +0300
IGNITE-27213 Added windows version for fake_server test suite. (#7478)
---
modules/platforms/cpp/CMakeLists.txt | 5 +-
.../platforms/cpp/tests/fake_server/CMakeLists.txt | 2 +-
.../cpp/tests/fake_server/fake_server.cpp | 23 ++----
.../platforms/cpp/tests/fake_server/fake_server.h | 11 ++-
modules/platforms/cpp/tests/fake_server/main.cpp | 19 +++++
.../socket_adapter/posix/client_socket_adapter.h | 72 ++++++++++++++++++
.../socket_adapter/posix/server_socket_adapter.h | 88 ++++++++++++++++++++++
.../fake_server/socket_adapter/socket_adapter.h | 32 ++++++++
.../socket_adapter/win/client_socket_adapter.h | 72 ++++++++++++++++++
.../socket_adapter/win/server_socket_adapter.h | 87 +++++++++++++++++++++
.../cpp/tests/fake_server/tcp_client_channel.cpp | 29 +++----
.../cpp/tests/fake_server/tcp_client_channel.h | 18 +++--
12 files changed, 408 insertions(+), 50 deletions(-)
diff --git a/modules/platforms/cpp/CMakeLists.txt
b/modules/platforms/cpp/CMakeLists.txt
index de12bd97977..39b0e82d293 100644
--- a/modules/platforms/cpp/CMakeLists.txt
+++ b/modules/platforms/cpp/CMakeLists.txt
@@ -163,10 +163,7 @@ if (${ENABLE_TESTS})
if (${ENABLE_CLIENT})
add_subdirectory(tests/client-test)
-
- if (NOT MSVC) # TODO enable when IGNITE-27213 implemented
- add_subdirectory(tests/fake_server)
- endif ()
+ add_subdirectory(tests/fake_server)
endif()
if (${ENABLE_ODBC})
diff --git a/modules/platforms/cpp/tests/fake_server/CMakeLists.txt
b/modules/platforms/cpp/tests/fake_server/CMakeLists.txt
index b923dcd5a1e..ea4abb5be51 100644
--- a/modules/platforms/cpp/tests/fake_server/CMakeLists.txt
+++ b/modules/platforms/cpp/tests/fake_server/CMakeLists.txt
@@ -24,4 +24,4 @@ set(SOURCES
connection_test.cpp
)
-ignite_test(${TARGET} SOURCES ${SOURCES} LIBS ignite-test-common
ignite3-client msgpack-c)
\ No newline at end of file
+ignite_test(${TARGET} SOURCES ${SOURCES} LIBS ignite-test-common
ignite3-client msgpack-c ignite-protocol ignite-tuple)
\ No newline at end of file
diff --git a/modules/platforms/cpp/tests/fake_server/fake_server.cpp
b/modules/platforms/cpp/tests/fake_server/fake_server.cpp
index dce83621cd1..c341db6d0cf 100644
--- a/modules/platforms/cpp/tests/fake_server/fake_server.cpp
+++ b/modules/platforms/cpp/tests/fake_server/fake_server.cpp
@@ -1,5 +1,5 @@
/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
+ * Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
@@ -18,10 +18,9 @@
#include "fake_server.h"
#include "ignite/protocol/protocol_version.h"
-#include <cstring>
#include <ignite/common/ignite_error.h>
#include <ignite/protocol/utils.h>
-#include <iostream>
+
#include <queue>
void fake_server::start() {
@@ -47,31 +46,25 @@ void fake_server::start() {
}
void fake_server::start_socket() {
- m_srv_fd = socket(AF_INET, SOCK_STREAM, 6);
+ m_srv_sock.start();
- if (m_srv_fd < 0) {
+ if (!m_srv_sock.is_valid()) {
throw ignite_error("socket failed");
}
}
void fake_server::bind_address_port() const {
- sockaddr_in srv_addr{};
-
- srv_addr.sin_family = AF_INET;
- srv_addr.sin_addr.s_addr = INADDR_ANY;
- srv_addr.sin_port = htons(m_srv_port);
-
- int bind_res = bind(m_srv_fd, reinterpret_cast<sockaddr *>(&srv_addr),
sizeof(srv_addr));
+ int bind_res = m_srv_sock.bind(m_srv_port);
if (bind_res < 0) {
std::stringstream ss;
- ss << "bind failed" << strerror(errno);
+ ss << "bind failed: " << LAST_SOCKET_ERROR();
throw std::runtime_error(ss.str());
}
}
void fake_server::start_socket_listen() const {
- int listen_res = listen(m_srv_fd, 1);
+ int listen_res = m_srv_sock.listen();
if (listen_res < 0) {
throw std::runtime_error("listen failed");
@@ -81,7 +74,7 @@ void fake_server::start_socket_listen() const {
}
void fake_server::accept_client_connection() {
- m_client_channel = std::make_unique<tcp_client_channel>(m_srv_fd,
m_logger);
+ m_client_channel = std::make_unique<tcp_client_channel>(m_srv_sock,
m_logger);
m_client_channel->start();
}
diff --git a/modules/platforms/cpp/tests/fake_server/fake_server.h
b/modules/platforms/cpp/tests/fake_server/fake_server.h
index 3a748ac1076..22d25e26efa 100644
--- a/modules/platforms/cpp/tests/fake_server/fake_server.h
+++ b/modules/platforms/cpp/tests/fake_server/fake_server.h
@@ -27,7 +27,6 @@
#include <atomic>
#include <thread>
-#include <unistd.h>
using namespace ignite;
@@ -51,10 +50,9 @@ public:
if (m_started)
m_client_channel->stop();
- if (m_srv_fd > 0) {
- ::close(m_srv_fd);
+ if (m_srv_sock.is_valid()) {
+ m_srv_sock.close();
}
-
m_io_thread->join();
}
@@ -81,8 +79,9 @@ private:
void handle_requests();
- /** Server socket FD. */
- int m_srv_fd = -1;
+ /** Server socket. */
+ server_socket_adapter m_srv_sock;
+
/** Flag is up when server initialization was complete. */
std::atomic_bool m_started{false};
diff --git a/modules/platforms/cpp/tests/fake_server/main.cpp
b/modules/platforms/cpp/tests/fake_server/main.cpp
index 420cdb738de..4e4d531e3f7 100644
--- a/modules/platforms/cpp/tests/fake_server/main.cpp
+++ b/modules/platforms/cpp/tests/fake_server/main.cpp
@@ -22,6 +22,10 @@
#include <gtest/gtest.h>
+#ifdef _WIN32
+#include <winsock2.h>
+#endif
+
#include <chrono>
#include <csignal>
@@ -60,6 +64,17 @@ void set_process_abort_handler(std::function<void(int)>
handler) {
int main(int argc, char **argv) {
using namespace ignite;
+#ifdef _WIN32
+ static bool wsa_initialized = false;
+ if (!wsa_initialized) {
+ WSADATA wsaData;
+ if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) {
+ throw ignite_error("WSAStartup failed");
+ }
+ wsa_initialized = true;
+ }
+#endif
+
set_process_abort_handler([&](int signal) {
std::cout << "Caught signal " << signal << " during tests" <<
std::endl;
});
@@ -75,5 +90,9 @@ int main(int argc, char **argv) {
return 2;
}
+#ifdef _WIN32
+ WSACleanup();
+#endif
+
return 0;
}
diff --git
a/modules/platforms/cpp/tests/fake_server/socket_adapter/posix/client_socket_adapter.h
b/modules/platforms/cpp/tests/fake_server/socket_adapter/posix/client_socket_adapter.h
new file mode 100644
index 00000000000..4d44b8165b9
--- /dev/null
+++
b/modules/platforms/cpp/tests/fake_server/socket_adapter/posix/client_socket_adapter.h
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <sys/socket.h>
+#include <unistd.h>
+#include <vector>
+#include <cstddef>
+
+namespace ignite {
+class client_socket_adapter {
+public:
+ explicit client_socket_adapter(int m_fd)
+ : m_fd(m_fd) {}
+
+ ~client_socket_adapter() {
+ if (is_valid()) {
+ close();
+ }
+ }
+
+ client_socket_adapter() = default;
+
+ client_socket_adapter(const client_socket_adapter &other) = delete;
+
+ client_socket_adapter(client_socket_adapter &&other) noexcept
+ : m_fd(other.m_fd)
+ {
+ other.m_fd = -1;
+ }
+
+ client_socket_adapter &operator=(const client_socket_adapter &other) =
delete;
+
+ client_socket_adapter &operator=(client_socket_adapter &&other) noexcept {
+ m_fd = other.m_fd;
+ other.m_fd = -1;
+
+ return *this;
+ }
+
+ [[nodiscard]] bool is_valid() const { return m_fd >= 0; }
+
+ void send_message(const std::vector<std::byte> &msg) const { ::send(m_fd,
msg.data(), msg.size(), 0); }
+
+ [[nodiscard]] ssize_t receive_next_packet(std::byte *buf, size_t buf_size)
const {
+ return ::recv(m_fd, buf, buf_size, 0);
+ }
+
+ void close() {
+ ::close(m_fd);
+ m_fd = -1;
+ }
+
+private:
+ int m_fd = -1;
+};
+} // namespace ignite
\ No newline at end of file
diff --git
a/modules/platforms/cpp/tests/fake_server/socket_adapter/posix/server_socket_adapter.h
b/modules/platforms/cpp/tests/fake_server/socket_adapter/posix/server_socket_adapter.h
new file mode 100644
index 00000000000..d7d902651d7
--- /dev/null
+++
b/modules/platforms/cpp/tests/fake_server/socket_adapter/posix/server_socket_adapter.h
@@ -0,0 +1,88 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <unistd.h>
+
+namespace ignite {
+class server_socket_adapter {
+public:
+ explicit server_socket_adapter(int m_fd)
+ : m_fd(m_fd) {}
+
+ server_socket_adapter() = default;
+
+ server_socket_adapter(const server_socket_adapter &other) = delete;
+
+ server_socket_adapter(server_socket_adapter &&other) noexcept
+ : m_fd(other.m_fd)
+ {
+ other.m_fd = -1;
+ }
+
+ server_socket_adapter &operator=(const server_socket_adapter &other) =
delete;
+
+ server_socket_adapter &operator=(server_socket_adapter &&other) noexcept {
+ m_fd = other.m_fd;
+ other.m_fd = -1;
+
+ return *this;
+ }
+
+ void start() {
+ m_fd = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ }
+
+ [[nodiscard]] bool is_valid() const {
+ return m_fd >= 0;
+ }
+
+ [[nodiscard]] int accept() const {
+ sockaddr_in cl_addr{};
+
+ socklen_t addr_len = sizeof(cl_addr);
+
+ int cl_sock = ::accept(m_fd, reinterpret_cast<sockaddr *>(&cl_addr),
&addr_len);
+
+ return cl_sock;
+ }
+
+ [[nodiscard]] int bind(int port) const {
+ sockaddr_in srv_addr{};
+
+ srv_addr.sin_family = AF_INET;
+ srv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
+ srv_addr.sin_port = htons(port);
+
+ return ::bind(m_fd, reinterpret_cast<sockaddr*>(&srv_addr),
sizeof(srv_addr));
+ }
+
+ [[nodiscard]] int listen() const {
+ return ::listen(m_fd, 1);
+ }
+
+ void close() {
+ ::close(m_fd);
+ m_fd = -1;
+ }
+private:
+ int m_fd = -1;
+};
+}
\ No newline at end of file
diff --git
a/modules/platforms/cpp/tests/fake_server/socket_adapter/socket_adapter.h
b/modules/platforms/cpp/tests/fake_server/socket_adapter/socket_adapter.h
new file mode 100644
index 00000000000..fad23ca55f6
--- /dev/null
+++ b/modules/platforms/cpp/tests/fake_server/socket_adapter/socket_adapter.h
@@ -0,0 +1,32 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#ifdef _WIN32
+#include "win/server_socket_adapter.h"
+#include "win/client_socket_adapter.h"
+
+#define LAST_SOCKET_ERROR() WSAGetLastError()
+#else
+#include "posix/server_socket_adapter.h"
+#include "posix/client_socket_adapter.h"
+#include <cerrno>
+#include <cstring>
+
+#define LAST_SOCKET_ERROR() strerror(errno)
+#endif
\ No newline at end of file
diff --git
a/modules/platforms/cpp/tests/fake_server/socket_adapter/win/client_socket_adapter.h
b/modules/platforms/cpp/tests/fake_server/socket_adapter/win/client_socket_adapter.h
new file mode 100644
index 00000000000..0856c7b820b
--- /dev/null
+++
b/modules/platforms/cpp/tests/fake_server/socket_adapter/win/client_socket_adapter.h
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+#include <winsock2.h>
+#include <vector>
+#include <cstddef>
+
+namespace ignite {
+class client_socket_adapter {
+public:
+ explicit client_socket_adapter(int m_fd)
+ : m_fd(m_fd) {}
+
+ ~client_socket_adapter() {
+ if (is_valid()) {
+ close();
+ }
+ }
+
+ client_socket_adapter() = default;
+
+ client_socket_adapter(const client_socket_adapter &other) = delete;
+
+ client_socket_adapter(client_socket_adapter &&other) noexcept
+ : m_fd(other.m_fd)
+ {
+ other.m_fd = INVALID_SOCKET;
+ }
+
+ client_socket_adapter &operator=(const client_socket_adapter &other) =
delete;
+
+ client_socket_adapter &operator=(client_socket_adapter &&other) noexcept {
+ m_fd = other.m_fd;
+ other.m_fd = INVALID_SOCKET;
+
+ return *this;
+ }
+
+ [[nodiscard]] bool is_valid() const { return m_fd != INVALID_SOCKET; }
+
+ void send_message(const std::vector<std::byte> &msg) const {
+ ::send(m_fd, reinterpret_cast<const char *>(msg.data()), msg.size(),
0);
+ }
+
+ [[nodiscard]] int receive_next_packet(std::byte *buf, size_t buf_size)
const {
+ return ::recv(m_fd, reinterpret_cast<char *>(buf), buf_size, 0);
+ }
+
+ void close() {
+ ::closesocket(m_fd);
+ m_fd = INVALID_SOCKET;
+ }
+
+private:
+ SOCKET m_fd = INVALID_SOCKET;
+};
+} // namespace ignite
\ No newline at end of file
diff --git
a/modules/platforms/cpp/tests/fake_server/socket_adapter/win/server_socket_adapter.h
b/modules/platforms/cpp/tests/fake_server/socket_adapter/win/server_socket_adapter.h
new file mode 100644
index 00000000000..11a2b6c0f0d
--- /dev/null
+++
b/modules/platforms/cpp/tests/fake_server/socket_adapter/win/server_socket_adapter.h
@@ -0,0 +1,87 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <winsock2.h>
+#include <ws2tcpip.h>
+
+namespace ignite {
+class server_socket_adapter {
+public:
+ explicit server_socket_adapter(int m_fd)
+ : m_fd(m_fd) {}
+
+ server_socket_adapter() = default;
+
+ server_socket_adapter(const server_socket_adapter &other) = delete;
+
+ server_socket_adapter(server_socket_adapter &&other) noexcept
+ : m_fd(other.m_fd)
+ {
+ other.m_fd = INVALID_SOCKET;
+ }
+
+ server_socket_adapter &operator=(const server_socket_adapter &other) =
delete;
+
+ server_socket_adapter &operator=(server_socket_adapter &&other) noexcept {
+ m_fd = other.m_fd;
+ other.m_fd = INVALID_SOCKET;
+
+ return *this;
+ }
+
+ void start() {
+ m_fd = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ }
+
+ [[nodiscard]] bool is_valid() const {
+ return m_fd != INVALID_SOCKET;
+ }
+
+ [[nodiscard]] SOCKET accept() const {
+ sockaddr_in cl_addr{};
+
+ socklen_t addr_len = sizeof(cl_addr);
+
+ SOCKET cl_sock = ::accept(m_fd, reinterpret_cast<sockaddr
*>(&cl_addr), &addr_len);
+
+ return cl_sock;
+ }
+
+ [[nodiscard]] int bind(int port) const {
+ sockaddr_in srv_addr{};
+
+ srv_addr.sin_family = AF_INET;
+ srv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
+ srv_addr.sin_port = htons(port);
+
+ return ::bind(m_fd, reinterpret_cast<sockaddr*>(&srv_addr),
sizeof(srv_addr));
+ }
+
+ [[nodiscard]] int listen() const {
+ return ::listen(m_fd, 1);
+ }
+
+ void close() {
+ ::closesocket(m_fd);
+ m_fd = INVALID_SOCKET;
+ }
+private:
+ SOCKET m_fd = INVALID_SOCKET;
+};
+}
\ No newline at end of file
diff --git a/modules/platforms/cpp/tests/fake_server/tcp_client_channel.cpp
b/modules/platforms/cpp/tests/fake_server/tcp_client_channel.cpp
index 2dc63fe6138..6b0cb2a3af6 100644
--- a/modules/platforms/cpp/tests/fake_server/tcp_client_channel.cpp
+++ b/modules/platforms/cpp/tests/fake_server/tcp_client_channel.cpp
@@ -18,9 +18,6 @@
#include "tcp_client_channel.h"
#include <algorithm>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <unistd.h>
namespace ignite {
std::vector<std::byte> tcp_client_channel::read_next_n_bytes(size_t n) {
@@ -47,12 +44,12 @@ std::vector<std::byte>
tcp_client_channel::read_next_n_bytes(size_t n) {
return res;
}
-void tcp_client_channel::send_message(std::vector<std::byte> msg) {
- ::send(m_cl_fd, msg.data(), msg.size(), 0);
+void tcp_client_channel::send_message(const std::vector<std::byte>& msg) {
+ m_cl_sock.send_message(msg);
}
void tcp_client_channel::receive_next_packet() {
- int received = ::recv(m_cl_fd, m_buf, sizeof(m_buf), 0);
+ int64_t received = m_cl_sock.receive_next_packet(m_buf, sizeof(m_buf));
if (received == 0) {
m_logger->log_debug( "connection was closed");
@@ -63,7 +60,7 @@ void tcp_client_channel::receive_next_packet() {
if (received < 0 && !m_stopped) {
std::stringstream ss;
- ss << "connection was closed with error: " << strerror(errno);
+ ss << "connection was closed with error: " << LAST_SOCKET_ERROR();
throw ignite_error(ss.str());
}
@@ -72,17 +69,14 @@ void tcp_client_channel::receive_next_packet() {
}
void tcp_client_channel::start() {
- sockaddr_in cl_addr{};
+ m_logger->log_debug("waiting for client to connect");
- socklen_t addr_len = sizeof(cl_addr);
+ auto cl_fd = m_srv_sock.accept();
+ m_cl_sock = client_socket_adapter(cl_fd);
- m_logger->log_debug("waiting for client to connect srv_fd = " +
std::to_string(m_srv_fd));
-
- m_cl_fd = accept(m_srv_fd, reinterpret_cast<sockaddr *>(&cl_addr),
&addr_len);
-
- if (m_cl_fd < 0 && !m_stopped) {
+ if (!m_cl_sock.is_valid() && !m_stopped) {
std::stringstream ss;
- ss << "connection acceptance failed " << strerror(errno);
+ ss << "connection acceptance failed " << LAST_SOCKET_ERROR();
throw std::runtime_error(ss.str());
}
@@ -91,8 +85,9 @@ void tcp_client_channel::start() {
void tcp_client_channel::stop() {
m_stopped.store(true);
- if (m_cl_fd > 0) {
- ::close(m_cl_fd);
+
+ if (m_cl_sock.is_valid()) {
+ m_cl_sock.close();
}
}
}; // namespace ignite
\ No newline at end of file
diff --git a/modules/platforms/cpp/tests/fake_server/tcp_client_channel.h
b/modules/platforms/cpp/tests/fake_server/tcp_client_channel.h
index fd83dfc0305..0f4e10b2c54 100644
--- a/modules/platforms/cpp/tests/fake_server/tcp_client_channel.h
+++ b/modules/platforms/cpp/tests/fake_server/tcp_client_channel.h
@@ -18,12 +18,15 @@
#pragma once
#include "ignite/client/ignite_logger.h"
+#include "socket_adapter/socket_adapter.h"
#include <atomic>
#include <cstddef>
#include <ignite/common/ignite_error.h>
#include <ignite/protocol/utils.h>
+
+
namespace ignite {
/**
@@ -31,21 +34,22 @@ namespace ignite {
*/
class tcp_client_channel {
public:
- explicit tcp_client_channel(int srv_socket_fd,
std::shared_ptr<ignite_logger> logger)
- : m_srv_fd(srv_socket_fd)
+ explicit tcp_client_channel(const server_socket_adapter& srv_sock,
std::shared_ptr<ignite_logger> logger)
+ : m_srv_sock(srv_sock)
+ , m_buf{}
, m_logger(std::move(logger)) {}
void start();
void stop();
std::vector<std::byte> read_next_n_bytes(size_t n);
- void send_message(std::vector<std::byte> msg);
+ void send_message(const std::vector<std::byte>& msg);
private:
void receive_next_packet();
- /** Server FD. */
- int m_srv_fd;
- /** Client FD. */
- int m_cl_fd = -1;
+ /** Server socket. */
+ const server_socket_adapter& m_srv_sock;
+ /** Client socket. */
+ client_socket_adapter m_cl_sock;
/** Message buffer. */
std::byte m_buf[1024];
/** Pointer position. */