You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "Erixonich (via GitHub)" <gi...@apache.org> on 2026/01/26 18:43:41 UTC

[PR] Added windows version for fake_server test suite. [ignite-3]

Erixonich opened a new pull request, #7478:
URL: https://github.com/apache/ignite-3/pull/7478

   Thank you for submitting the pull request.
   
   To streamline the review process of the patch and ensure better code quality
   we ask both an author and a reviewer to verify the following:
   
   ### The Review Checklist
   - [ ] **Formal criteria:** TC status, codestyle, mandatory documentation. Also make sure to complete the following:  
   \- There is a single JIRA ticket related to the pull request.  
   \- The web-link to the pull request is attached to the JIRA ticket.  
   \- The JIRA ticket has the Patch Available state.  
   \- The description of the JIRA ticket explains WHAT was made, WHY and HOW.  
   \- The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
   - [ ] **Design:** new code conforms with the design principles of the components it is added to.
   - [ ] **Patch quality:** patch cannot be split into smaller pieces, its size must be reasonable.
   - [ ] **Code quality:** code is clean and readable, necessary developer documentation is added if needed.
   - [ ] **Tests code quality:** test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.
   
   ### Notes
   - [Apache Ignite Coding Guidelines](https://cwiki.apache.org/confluence/display/IGNITE/Java+Code+Style+Guide)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27213 Added windows version for fake_server test suite. [ignite-3]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #7478:
URL: https://github.com/apache/ignite-3/pull/7478#discussion_r2736195349


##########
modules/platforms/cpp/tests/fake_server/socket_adapter/posix/server_socket_adapter.h:
##########
@@ -0,0 +1,75 @@
+/*
+* 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) = default;
+
+    server_socket_adapter &operator=(const server_socket_adapter &other) = default;
+

Review Comment:
   `server_socket_adapter` is an owning wrapper around a socket handle but is copyable (default copy constructor and copy assignment) without any shared-ownership semantics, which makes double-closing or use-after-close of the underlying socket very easy by mistake. To make ownership clear and safer, consider deleting the copy constructor/assignment and adding move semantics, or otherwise ensuring only a single owner is responsible for closing the socket.
   ```suggestion
       server_socket_adapter(const server_socket_adapter &other) = delete;
   
       server_socket_adapter &operator=(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=(server_socket_adapter &&other) noexcept {
           if (this != &other) {
               if (is_valid()) {
                   ::close(m_fd);
               }
   
               m_fd = other.m_fd;
               other.m_fd = -1;
           }
   
           return *this;
       }
   ```



##########
modules/platforms/cpp/tests/fake_server/socket_adapter/win/client_socket_adapter.h:
##########
@@ -0,0 +1,53 @@
+/*
+ * 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(SOCKET m_fd)
+        : m_fd(m_fd) {}
+
+    client_socket_adapter() = default;
+
+    client_socket_adapter(const client_socket_adapter &other) = default;
+
+    client_socket_adapter &operator=(const client_socket_adapter &other) = default;
+

Review Comment:
   `client_socket_adapter` (Windows) is an owning wrapper for a `SOCKET` but is copyable with a `close()` method that unconditionally calls `closesocket` on the stored handle. This can lead to multiple copies managing the same `SOCKET` and potentially double-closing it; please consider deleting the copy constructor/assignment and using move-only semantics for clearer, safer ownership.
   ```suggestion
       client_socket_adapter(const client_socket_adapter &other) = delete;
   
       client_socket_adapter &operator=(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=(client_socket_adapter &&other) noexcept {
           if (this != &other) {
               m_fd = other.m_fd;
               other.m_fd = INVALID_SOCKET;
           }
           return *this;
       }
   ```



##########
modules/platforms/cpp/tests/fake_server/socket_adapter/win/server_socket_adapter.h:
##########
@@ -0,0 +1,74 @@
+/*
+* 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(SOCKET m_fd)
+        : m_fd(m_fd) {}
+
+    server_socket_adapter() = default;
+
+    server_socket_adapter(const server_socket_adapter &other) = default;
+
+    server_socket_adapter &operator=(const server_socket_adapter &other) = default;
+

Review Comment:
   `server_socket_adapter` on Windows is an owning wrapper around `SOCKET` but remains copyable (default copy constructor and assignment) even though each instance calls `closesocket` in `close()`. This can easily lead to double-closing the same `SOCKET` or using a socket after it was closed via another copy; please make the type move-only or otherwise enforce single ownership of the handle.
   ```suggestion
       server_socket_adapter(const server_socket_adapter &other) = delete;
   
       server_socket_adapter &operator=(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=(server_socket_adapter &&other) noexcept {
           if (this != &other) {
               if (is_valid()) {
                   ::closesocket(m_fd);
               }
               m_fd = other.m_fd;
               other.m_fd = INVALID_SOCKET;
           }
           return *this;
       }
   ```



##########
modules/platforms/cpp/tests/fake_server/socket_adapter/win/client_socket_adapter.h:
##########
@@ -0,0 +1,53 @@
+/*
+ * 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(SOCKET m_fd)
+        : m_fd(m_fd) {}
+
+    client_socket_adapter() = default;
+
+    client_socket_adapter(const client_socket_adapter &other) = default;
+
+    client_socket_adapter &operator=(const client_socket_adapter &other) = default;
+
+    bool is_valid() const { return m_fd != INVALID_SOCKET; }
+
+    void send_message(const std::vector<std::byte> &msg) {
+        ::send(m_fd, reinterpret_cast<const char *>(msg.data()), msg.size(), 0);
+    }
+
+    int receive_next_packet(std::byte *buf, size_t buf_size) {
+        return ::recv(m_fd, reinterpret_cast<char *>(buf), buf_size, 0);

Review Comment:
   On Windows, `receive_next_packet` takes a `size_t buf_size` but passes it directly to `::recv`, whose length parameter is an `int`. This implicit narrowing can overflow for large buffers and is harder to reason about; it would be safer to validate that `buf_size` fits into an `int` and cast explicitly, or to use an `int` parameter type that matches the underlying API.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27213 Added windows version for fake_server test suite. [ignite-3]

Posted by "Erixonich (via GitHub)" <gi...@apache.org>.
Erixonich commented on code in PR #7478:
URL: https://github.com/apache/ignite-3/pull/7478#discussion_r2736150829


##########
modules/platforms/cpp/tests/fake_server/tcp_client_channel.h:
##########
@@ -24,28 +24,41 @@
 #include <ignite/common/ignite_error.h>
 #include <ignite/protocol/utils.h>
 
+#ifdef _WIN32
+#include "socket_adapter/win/server_socket_adapter.h"
+#include "socket_adapter/win/client_socket_adapter.h"
+
+#define LAST_SOCKET_ERROR() WSAGetLastError()
+#else
+#include "socket_adapter/posix/server_socket_adapter.h"
+#include "socket_adapter/posix/client_socket_adapter.h"

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27213 Added windows version for fake_server test suite. [ignite-3]

Posted by "Erixonich (via GitHub)" <gi...@apache.org>.
Erixonich commented on code in PR #7478:
URL: https://github.com/apache/ignite-3/pull/7478#discussion_r2737373115


##########
modules/platforms/cpp/tests/fake_server/socket_adapter/win/client_socket_adapter.h:
##########
@@ -0,0 +1,53 @@
+/*
+ * 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(SOCKET m_fd)
+        : m_fd(m_fd) {}
+
+    client_socket_adapter() = default;
+
+    client_socket_adapter(const client_socket_adapter &other) = default;
+
+    client_socket_adapter &operator=(const client_socket_adapter &other) = default;
+

Review Comment:
   fixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27213 Added windows version for fake_server test suite. [ignite-3]

Posted by "isapego (via GitHub)" <gi...@apache.org>.
isapego commented on code in PR #7478:
URL: https://github.com/apache/ignite-3/pull/7478#discussion_r2741191855


##########
modules/platforms/cpp/tests/fake_server/tcp_client_channel.h:
##########
@@ -24,28 +24,44 @@
 #include <ignite/common/ignite_error.h>
 #include <ignite/protocol/utils.h>
 
+#ifdef _WIN32
+#include "socket_adapter/win/server_socket_adapter.h"
+#include "socket_adapter/win/client_socket_adapter.h"
+
+#define LAST_SOCKET_ERROR() WSAGetLastError()
+#else
+#include "socket_adapter/posix/server_socket_adapter.h"
+#include "socket_adapter/posix/client_socket_adapter.h"

Review Comment:
   Let's maybe move the whole thing to `socket_adapter.h`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27213 Added windows version for fake_server test suite. [ignite-3]

Posted by "Erixonich (via GitHub)" <gi...@apache.org>.
Erixonich commented on code in PR #7478:
URL: https://github.com/apache/ignite-3/pull/7478#discussion_r2736131223


##########
modules/platforms/cpp/tests/fake_server/tcp_client_channel.cpp:
##########
@@ -18,9 +18,10 @@
 #include "tcp_client_channel.h"
 
 #include <algorithm>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <unistd.h>
+
+#ifndef _WIN32
+
+#endif

Review Comment:
   removed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27213 Added windows version for fake_server test suite. [ignite-3]

Posted by "Erixonich (via GitHub)" <gi...@apache.org>.
Erixonich commented on code in PR #7478:
URL: https://github.com/apache/ignite-3/pull/7478#discussion_r2737371858


##########
modules/platforms/cpp/tests/fake_server/socket_adapter/posix/server_socket_adapter.h:
##########
@@ -0,0 +1,75 @@
+/*
+* 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) = default;
+
+    server_socket_adapter &operator=(const server_socket_adapter &other) = default;
+

Review Comment:
   fixed



##########
modules/platforms/cpp/tests/fake_server/socket_adapter/win/server_socket_adapter.h:
##########
@@ -0,0 +1,74 @@
+/*
+* 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(SOCKET m_fd)
+        : m_fd(m_fd) {}
+
+    server_socket_adapter() = default;
+
+    server_socket_adapter(const server_socket_adapter &other) = default;
+
+    server_socket_adapter &operator=(const server_socket_adapter &other) = default;
+

Review Comment:
   fixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27213 Added windows version for fake_server test suite. [ignite-3]

Posted by "Erixonich (via GitHub)" <gi...@apache.org>.
Erixonich commented on code in PR #7478:
URL: https://github.com/apache/ignite-3/pull/7478#discussion_r2736129092


##########
modules/platforms/cpp/tests/fake_server/fake_server.h:
##########
@@ -43,19 +42,33 @@ class fake_server {
         : m_srv_port(srv_port)
         , m_logger(std::move(logger))
         , m_op_type_handler(op_type_handler)
-    {}
+    {
+#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

Review Comment:
   done



##########
modules/platforms/cpp/tests/fake_server/fake_server.h:
##########
@@ -43,19 +42,33 @@ class fake_server {
         : m_srv_port(srv_port)
         , m_logger(std::move(logger))
         , m_op_type_handler(op_type_handler)
-    {}
+    {
+#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
+    }
 
     ~fake_server() {
         m_stopped.store(true);
 
         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();
+
+#ifdef _WIN32
+        WSACleanup();
+#endif

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Added windows version for fake_server test suite. [ignite-3]

Posted by "isapego (via GitHub)" <gi...@apache.org>.
isapego commented on code in PR #7478:
URL: https://github.com/apache/ignite-3/pull/7478#discussion_r2735574955


##########
modules/platforms/cpp/tests/fake_server/fake_server.h:
##########
@@ -43,19 +42,33 @@ class fake_server {
         : m_srv_port(srv_port)
         , m_logger(std::move(logger))
         , m_op_type_handler(op_type_handler)
-    {}
+    {
+#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
+    }
 
     ~fake_server() {
         m_stopped.store(true);
 
         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();
+
+#ifdef _WIN32
+        WSACleanup();
+#endif

Review Comment:
   Let's move this to main as well :)



##########
modules/platforms/cpp/tests/fake_server/tcp_client_channel.cpp:
##########
@@ -18,9 +18,10 @@
 #include "tcp_client_channel.h"
 
 #include <algorithm>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <unistd.h>
+
+#ifndef _WIN32
+
+#endif

Review Comment:
   ?



##########
modules/platforms/cpp/tests/fake_server/fake_server.h:
##########
@@ -43,19 +42,33 @@ class fake_server {
         : m_srv_port(srv_port)
         , m_logger(std::move(logger))
         , m_op_type_handler(op_type_handler)
-    {}
+    {
+#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

Review Comment:
   Let's move to main.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27213 Added windows version for fake_server test suite. [ignite-3]

Posted by "Erixonich (via GitHub)" <gi...@apache.org>.
Erixonich commented on code in PR #7478:
URL: https://github.com/apache/ignite-3/pull/7478#discussion_r2736143136


##########
modules/platforms/cpp/tests/fake_server/socket_adapter/win/client_socket_adapter.h:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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>
+
+namespace ignite {
+class client_socket_adapter {
+public:
+    explicit client_socket_adapter(SOCKET m_fd)
+        : m_fd(m_fd) {}
+
+    client_socket_adapter() = default;
+
+    client_socket_adapter(const client_socket_adapter &other) = default;
+
+    client_socket_adapter &operator=(const client_socket_adapter &other) = default;
+
+    bool is_valid() const { return m_fd != INVALID_SOCKET; }
+
+    void send_message(const std::vector<std::byte> &msg) {
+        ::send(m_fd, reinterpret_cast<const char *>(msg.data()), msg.size(), 0);
+    }
+
+    int recieve_next_packet(std::byte *buf, size_t buf_size) {
+        return ::recv(m_fd, reinterpret_cast<char *>(buf), buf_size, 0);

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Added windows version for fake_server test suite. [ignite-3]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #7478:
URL: https://github.com/apache/ignite-3/pull/7478#discussion_r2735590928


##########
modules/platforms/cpp/tests/fake_server/socket_adapter/win/client_socket_adapter.h:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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>
+
+namespace ignite {
+class client_socket_adapter {
+public:
+    explicit client_socket_adapter(SOCKET m_fd)
+        : m_fd(m_fd) {}
+
+    client_socket_adapter() = default;
+
+    client_socket_adapter(const client_socket_adapter &other) = default;
+
+    client_socket_adapter &operator=(const client_socket_adapter &other) = default;
+
+    bool is_valid() const { return m_fd != INVALID_SOCKET; }
+
+    void send_message(const std::vector<std::byte> &msg) {
+        ::send(m_fd, reinterpret_cast<const char *>(msg.data()), msg.size(), 0);
+    }
+
+    int recieve_next_packet(std::byte *buf, size_t buf_size) {
+        return ::recv(m_fd, reinterpret_cast<char *>(buf), buf_size, 0);

Review Comment:
   The Windows `client_socket_adapter` header uses `std::vector<std::byte>` and `size_t` but only includes `<winsock2.h>`, without `<vector>` or `<cstddef>`. To keep headers self‑contained and avoid relying on indirect standard library includes, please add the appropriate standard headers here as well.



##########
modules/platforms/cpp/tests/fake_server/socket_adapter/posix/server_socket_adapter.h:
##########
@@ -0,0 +1,73 @@
+/*
+* 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 <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) = default;
+
+    server_socket_adapter &operator=(const server_socket_adapter &other) = default;
+
+    void start() {
+        m_fd = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+    }
+
+    bool is_valid() const {
+        return m_fd >= 0;
+    }
+
+    int accept() {
+        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;
+    }
+
+    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));
+    }
+
+    int listen() const {
+        return ::listen(m_fd, 1);

Review Comment:
   `server_socket_adapter::start()` and other methods use POSIX socket APIs (`::socket`, `::accept`, `::bind`, `::listen`), but this header only includes `<netinet/in.h>` and `<unistd.h>`; it does not include `<sys/socket.h>`, which is where these functions are actually declared on POSIX. Please add `<sys/socket.h>` here so that the adapter header provides the correct declarations without depending on previous includes in the translation unit.



##########
modules/platforms/cpp/tests/fake_server/tcp_client_channel.cpp:
##########
@@ -18,9 +18,10 @@
 #include "tcp_client_channel.h"
 
 #include <algorithm>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <unistd.h>
+
+#ifndef _WIN32
+
+#endif
 

Review Comment:
   The empty `#ifndef _WIN32` / `#endif` block here has no effect and looks like a leftover from earlier POSIX‑specific includes; keeping unused preprocessor conditionals around makes the file harder to read and can confuse future edits. Please either remove these lines or move any platform‑specific includes or code that still needs to be guarded back inside this conditional.
   ```suggestion
   
   ```



##########
modules/platforms/cpp/tests/fake_server/socket_adapter/win/client_socket_adapter.h:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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>
+
+namespace ignite {
+class client_socket_adapter {
+public:
+    explicit client_socket_adapter(SOCKET m_fd)
+        : m_fd(m_fd) {}
+
+    client_socket_adapter() = default;
+
+    client_socket_adapter(const client_socket_adapter &other) = default;
+
+    client_socket_adapter &operator=(const client_socket_adapter &other) = default;
+
+    bool is_valid() const { return m_fd != INVALID_SOCKET; }
+
+    void send_message(const std::vector<std::byte> &msg) {
+        ::send(m_fd, reinterpret_cast<const char *>(msg.data()), msg.size(), 0);
+    }
+
+    int recieve_next_packet(std::byte *buf, size_t buf_size) {
+        return ::recv(m_fd, reinterpret_cast<char *>(buf), buf_size, 0);
+    }
+

Review Comment:
   The method name `recieve_next_packet` is misspelled ("recieve" instead of "receive"), and this typo is now part of the public API used by `tcp_client_channel`. To keep the test code and adapters readable and avoid propagating the typo, consider renaming the method to `receive_next_packet` (providing a temporary compatibility alias if needed).
   ```suggestion
       int receive_next_packet(std::byte *buf, size_t buf_size) {
           return ::recv(m_fd, reinterpret_cast<char *>(buf), buf_size, 0);
       }
   
       // Temporary compatibility alias for the misspelled method name.
       // Prefer using receive_next_packet in new code.
       int recieve_next_packet(std::byte *buf, size_t buf_size) {
           return receive_next_packet(buf, buf_size);
       }
   ```



##########
modules/platforms/cpp/tests/fake_server/socket_adapter/posix/client_socket_adapter.h:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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>
+
+namespace ignite {
+class client_socket_adapter {
+public:
+    explicit client_socket_adapter(int m_fd)
+        : m_fd(m_fd) {}
+
+    client_socket_adapter() = default;
+
+    client_socket_adapter(const client_socket_adapter &other) = default;
+
+    client_socket_adapter &operator=(const client_socket_adapter &other) = default;
+
+    bool is_valid() const { return m_fd >= 0; }
+
+    void send_message(const std::vector<std::byte> &msg) { ::send(m_fd, msg.data(), msg.size(), 0); }
+
+    int recieve_next_packet(std::byte *buf, size_t buf_size) { return ::recv(m_fd, buf, buf_size, 0); }
+
+    void close() {

Review Comment:
   Both the POSIX and Windows `client_socket_adapter` headers use `std::vector<std::byte>` and `size_t` in method signatures, but neither of them includes `<vector>` or `<cstddef>`. This makes these headers non self‑contained and can lead to build failures or brittle dependencies on indirect includes; please add the necessary standard headers explicitly so that each adapter header can be included on its own.



##########
modules/platforms/cpp/tests/fake_server/fake_server.h:
##########
@@ -43,19 +42,33 @@ class fake_server {
         : m_srv_port(srv_port)
         , m_logger(std::move(logger))
         , m_op_type_handler(op_type_handler)
-    {}
+    {
+#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

Review Comment:
   On Windows the Winsock initialization/cleanup logic here is unbalanced: `WSAStartup` is guarded by a `static bool wsa_initialized` flag, but `WSACleanup()` in the destructor is called unconditionally for every `fake_server` instance. This means that after the first instance is destroyed Winsock will be cleaned up, and subsequent `fake_server` instances will never re‑initialize it (because `wsa_initialized` stays `true`), leading to undefined behavior or failures when using sockets. Consider either (a) using a reference count or a separate process‑wide initializer that pairs `WSAStartup` and `WSACleanup`, or (b) delegating to the existing `ignite::network::detail::init_wsa()` helper so that test code does not own Winsock lifecycle at all.



##########
modules/platforms/cpp/tests/fake_server/socket_adapter/posix/client_socket_adapter.h:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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>
+
+namespace ignite {
+class client_socket_adapter {
+public:
+    explicit client_socket_adapter(int m_fd)
+        : m_fd(m_fd) {}
+
+    client_socket_adapter() = default;
+
+    client_socket_adapter(const client_socket_adapter &other) = default;
+
+    client_socket_adapter &operator=(const client_socket_adapter &other) = default;
+
+    bool is_valid() const { return m_fd >= 0; }
+
+    void send_message(const std::vector<std::byte> &msg) { ::send(m_fd, msg.data(), msg.size(), 0); }
+
+    int recieve_next_packet(std::byte *buf, size_t buf_size) { return ::recv(m_fd, buf, buf_size, 0); }

Review Comment:
   The method name `recieve_next_packet` is misspelled ("recieve" instead of "receive"), and this typo is now part of the adapter interface used by `tcp_client_channel`. To keep the code consistent and readable, please rename this to `receive_next_packet` (and adjust call sites accordingly).
   ```suggestion
       int receive_next_packet(std::byte *buf, size_t buf_size) { return ::recv(m_fd, buf, buf_size, 0); }
   ```



##########
modules/platforms/cpp/tests/fake_server/tcp_client_channel.h:
##########
@@ -24,28 +24,41 @@
 #include <ignite/common/ignite_error.h>
 #include <ignite/protocol/utils.h>
 
+#ifdef _WIN32
+#include "socket_adapter/win/server_socket_adapter.h"
+#include "socket_adapter/win/client_socket_adapter.h"
+
+#define LAST_SOCKET_ERROR() WSAGetLastError()
+#else
+#include "socket_adapter/posix/server_socket_adapter.h"
+#include "socket_adapter/posix/client_socket_adapter.h"

Review Comment:
   The helper macro `LAST_SOCKET_ERROR()` expands to `strerror(errno)` on POSIX, but this header does not include `<cerrno>` or `<cstring>`, nor do the directly included headers, so `errno`/`strerror` will be undeclared on some compilers and configurations. To make this header self‑contained and avoid relying on transitive system includes, please add the appropriate standard headers (for example `<cerrno>` and `<cstring>`) in the non‑Windows branch.
   ```suggestion
   #include "socket_adapter/posix/client_socket_adapter.h"
   #include <cerrno>
   #include <cstring>
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27213 Added windows version for fake_server test suite. [ignite-3]

Posted by "Erixonich (via GitHub)" <gi...@apache.org>.
Erixonich commented on code in PR #7478:
URL: https://github.com/apache/ignite-3/pull/7478#discussion_r2736154535


##########
modules/platforms/cpp/tests/fake_server/socket_adapter/win/client_socket_adapter.h:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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>
+
+namespace ignite {
+class client_socket_adapter {
+public:
+    explicit client_socket_adapter(SOCKET m_fd)
+        : m_fd(m_fd) {}
+
+    client_socket_adapter() = default;
+
+    client_socket_adapter(const client_socket_adapter &other) = default;
+
+    client_socket_adapter &operator=(const client_socket_adapter &other) = default;
+
+    bool is_valid() const { return m_fd != INVALID_SOCKET; }
+
+    void send_message(const std::vector<std::byte> &msg) {
+        ::send(m_fd, reinterpret_cast<const char *>(msg.data()), msg.size(), 0);
+    }
+
+    int recieve_next_packet(std::byte *buf, size_t buf_size) {
+        return ::recv(m_fd, reinterpret_cast<char *>(buf), buf_size, 0);
+    }
+

Review Comment:
   fixed



##########
modules/platforms/cpp/tests/fake_server/socket_adapter/posix/client_socket_adapter.h:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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>
+
+namespace ignite {
+class client_socket_adapter {
+public:
+    explicit client_socket_adapter(int m_fd)
+        : m_fd(m_fd) {}
+
+    client_socket_adapter() = default;
+
+    client_socket_adapter(const client_socket_adapter &other) = default;
+
+    client_socket_adapter &operator=(const client_socket_adapter &other) = default;
+
+    bool is_valid() const { return m_fd >= 0; }
+
+    void send_message(const std::vector<std::byte> &msg) { ::send(m_fd, msg.data(), msg.size(), 0); }
+
+    int recieve_next_packet(std::byte *buf, size_t buf_size) { return ::recv(m_fd, buf, buf_size, 0); }

Review Comment:
   fixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27213 Added windows version for fake_server test suite. [ignite-3]

Posted by "Erixonich (via GitHub)" <gi...@apache.org>.
Erixonich commented on code in PR #7478:
URL: https://github.com/apache/ignite-3/pull/7478#discussion_r2736145968


##########
modules/platforms/cpp/tests/fake_server/socket_adapter/posix/server_socket_adapter.h:
##########
@@ -0,0 +1,73 @@
+/*
+* 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 <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) = default;
+
+    server_socket_adapter &operator=(const server_socket_adapter &other) = default;
+
+    void start() {
+        m_fd = ::socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+    }
+
+    bool is_valid() const {
+        return m_fd >= 0;
+    }
+
+    int accept() {
+        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;
+    }
+
+    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));
+    }
+
+    int listen() const {
+        return ::listen(m_fd, 1);

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27213 Added windows version for fake_server test suite. [ignite-3]

Posted by "Erixonich (via GitHub)" <gi...@apache.org>.
Erixonich commented on code in PR #7478:
URL: https://github.com/apache/ignite-3/pull/7478#discussion_r2736113479


##########
modules/platforms/cpp/tests/fake_server/fake_server.h:
##########
@@ -43,19 +42,33 @@ class fake_server {
         : m_srv_port(srv_port)
         , m_logger(std::move(logger))
         , m_op_type_handler(op_type_handler)
-    {}
+    {
+#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

Review Comment:
   sure



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27213 Added windows version for fake_server test suite. [ignite-3]

Posted by "Erixonich (via GitHub)" <gi...@apache.org>.
Erixonich commented on code in PR #7478:
URL: https://github.com/apache/ignite-3/pull/7478#discussion_r2736114951


##########
modules/platforms/cpp/tests/fake_server/tcp_client_channel.cpp:
##########
@@ -18,9 +18,10 @@
 #include "tcp_client_channel.h"
 
 #include <algorithm>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <unistd.h>
+
+#ifndef _WIN32
+
+#endif

Review Comment:
   left from refactoring.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27213 Added windows version for fake_server test suite. [ignite-3]

Posted by "Erixonich (via GitHub)" <gi...@apache.org>.
Erixonich commented on code in PR #7478:
URL: https://github.com/apache/ignite-3/pull/7478#discussion_r2736142132


##########
modules/platforms/cpp/tests/fake_server/socket_adapter/posix/client_socket_adapter.h:
##########
@@ -0,0 +1,48 @@
+/*
+ * 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>
+
+namespace ignite {
+class client_socket_adapter {
+public:
+    explicit client_socket_adapter(int m_fd)
+        : m_fd(m_fd) {}
+
+    client_socket_adapter() = default;
+
+    client_socket_adapter(const client_socket_adapter &other) = default;
+
+    client_socket_adapter &operator=(const client_socket_adapter &other) = default;
+
+    bool is_valid() const { return m_fd >= 0; }
+
+    void send_message(const std::vector<std::byte> &msg) { ::send(m_fd, msg.data(), msg.size(), 0); }
+
+    int recieve_next_packet(std::byte *buf, size_t buf_size) { return ::recv(m_fd, buf, buf_size, 0); }
+
+    void close() {

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27213 Added windows version for fake_server test suite. [ignite-3]

Posted by "Erixonich (via GitHub)" <gi...@apache.org>.
Erixonich commented on code in PR #7478:
URL: https://github.com/apache/ignite-3/pull/7478#discussion_r2736147250


##########
modules/platforms/cpp/tests/fake_server/fake_server.h:
##########
@@ -43,19 +42,33 @@ class fake_server {
         : m_srv_port(srv_port)
         , m_logger(std::move(logger))
         , m_op_type_handler(op_type_handler)
-    {}
+    {
+#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

Review Comment:
   done



##########
modules/platforms/cpp/tests/fake_server/tcp_client_channel.cpp:
##########
@@ -18,9 +18,10 @@
 #include "tcp_client_channel.h"
 
 #include <algorithm>
-#include <netinet/in.h>
-#include <sys/socket.h>
-#include <unistd.h>
+
+#ifndef _WIN32
+
+#endif
 

Review Comment:
   removed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27213 Added windows version for fake_server test suite. [ignite-3]

Posted by "isapego (via GitHub)" <gi...@apache.org>.
isapego merged PR #7478:
URL: https://github.com/apache/ignite-3/pull/7478


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27213 Added windows version for fake_server test suite. [ignite-3]

Posted by "Erixonich (via GitHub)" <gi...@apache.org>.
Erixonich commented on code in PR #7478:
URL: https://github.com/apache/ignite-3/pull/7478#discussion_r2737376504


##########
modules/platforms/cpp/tests/fake_server/socket_adapter/win/client_socket_adapter.h:
##########
@@ -0,0 +1,53 @@
+/*
+ * 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(SOCKET m_fd)
+        : m_fd(m_fd) {}
+
+    client_socket_adapter() = default;
+
+    client_socket_adapter(const client_socket_adapter &other) = default;
+
+    client_socket_adapter &operator=(const client_socket_adapter &other) = default;
+
+    bool is_valid() const { return m_fd != INVALID_SOCKET; }
+
+    void send_message(const std::vector<std::byte> &msg) {
+        ::send(m_fd, reinterpret_cast<const char *>(msg.data()), msg.size(), 0);
+    }
+
+    int receive_next_packet(std::byte *buf, size_t buf_size) {
+        return ::recv(m_fd, reinterpret_cast<char *>(buf), buf_size, 0);

Review Comment:
   fixed



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org