You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by al...@apache.org on 2022/04/26 16:50:53 UTC

[kudu] branch master updated: [unit test] KUDU-3361 Fix SocketTest.TestRecvReset

This is an automated email from the ASF dual-hosted git repository.

alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git


The following commit(s) were added to refs/heads/master by this push:
     new d216e417f [unit test] KUDU-3361 Fix SocketTest.TestRecvReset
d216e417f is described below

commit d216e417f7fa7daef59ec7eb2c15aadfd4e1c563
Author: shenxingwuying <sh...@gmail.com>
AuthorDate: Wed Apr 20 17:57:43 2022 +0800

    [unit test] KUDU-3361 Fix SocketTest.TestRecvReset
    
    The case SocketTest.TestRecvReset is not steady, and can cause
    jenkins -1, and need rerun it. And I found using a fixed timeout
    parameter is not good enough.
    
    eg: Set timeout 1ms coredump happened.
    Check failure stack trace: ***
    Aborted at 1650445865 (unix time) try "date -d @1650445865" if you are
    using GNU date ***
    PC: @     0x7fd63d0092e7 __GI_raise
    SIGABRT (@0x198309) received by PID 1671945 (TID 0x7fd640cb7980) from
    PID 1671945; stack trace: ***
        @   0x7fd63e8881d1 google::(anonymous namespace)::FailureSignalHandler()
        @     0x7fd63d390140 (unknown)
        @     0x7fd63d0092e7 __GI_raise
        @     0x7fd63d00a6c8 __GI_abort
        @     0x7fd63e878419 google::logging_fail()
        @     0x7fd63e87be9d google::LogMessage::Fail()
        @     0x7fd63e87daae google::LogMessage::SendToLog()
        @     0x7fd63e87ba20 google::LogMessage::Flush()
        @     0x7fd63e87e399 google::LogMessageFatal::~LogMessageFatal()
        @           0x21ff23 kudu::SocketTest::ConnectToListeningServer()
        @           0x21cc4a kudu::SocketTest::DoTestServerDisconnects()
        @           0x21b29c kudu::SocketTest_TestRecvReset_Test::TestBody()
        @     0x7fd63e219f2e testing::internal::HandleExceptionsInMethodIfSupported<>()
        @     0x7fd63e20fa2b testing::Test::Run()
        @     0x7fd63e20fb95 testing::TestInfo::Run()
        @     0x7fd63e20fc85 testing::TestSuite::Run()
        @     0x7fd63e210144 testing::internal::UnitTestImpl::RunAllTests()
        @     0x7fd63e21a46e testing::internal::HandleExceptionsInMethodIfSupported<>()
        @     0x7fd63e210340 testing::UnitTest::Run()
        @     0x7fd640e933c1 RUN_ALL_TESTS()
        @     0x7fd640e92316 main
        @     0x7fd63cff5ac5 __libc_start_main
        @           0x219029 (unknown)
        Aborted (core dumped)
    
    eg: Set timeout 50ms test failed.
    Value of: s.message().ToString()
        Expected: contains regular expression "recv error from
        127.0.0.1:[0-9]+: Resource temporarily unavailable"
        Actual: "recv error from unknown peer: Transport endpoint is not
        connected" (of type std::string)
        WARNING: Logging before InitGoogleLogging() is written to STDERR
    
    Change-Id: Ie85f36532510db53c8ac167f9d20689da0c76d33
    Reviewed-on: http://gerrit.cloudera.org:8080/18431
    Tested-by: Kudu Jenkins
    Reviewed-by: Alexey Serbin <al...@apache.org>
---
 src/kudu/util/net/socket-test.cc | 19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/src/kudu/util/net/socket-test.cc b/src/kudu/util/net/socket-test.cc
index dacae8512..e67f956fa 100644
--- a/src/kudu/util/net/socket-test.cc
+++ b/src/kudu/util/net/socket-test.cc
@@ -21,6 +21,7 @@
 
 #include <cstddef>
 #include <cstdint>
+#include <functional>
 #include <memory>
 #include <string>
 #include <thread>
@@ -28,13 +29,16 @@
 #include <glog/logging.h>
 #include <gtest/gtest.h>
 
+#include "kudu/gutil/ref_counted.h"
 #include "kudu/gutil/strings/substitute.h"
 #include "kudu/gutil/strings/util.h"
+#include "kudu/util/countdown_latch.h"
 #include "kudu/util/monotime.h"
 #include "kudu/util/net/sockaddr.h"
 #include "kudu/util/scoped_cleanup.h"
 #include "kudu/util/slice.h"
 #include "kudu/util/status.h"
+#include "kudu/util/thread.h"
 #include "kudu/util/test_macros.h"
 #include "kudu/util/test_util.h"
 
@@ -122,19 +126,26 @@ class SocketTest : public KuduTest {
 
   void DoTestServerDisconnects(bool accept, const std::string &message) {
     NO_FATALS(BindAndListen("0.0.0.0:0"));
-    std::thread t([&]{
+
+    CountDownLatch latch(1);
+    scoped_refptr<kudu::Thread> t;
+    Status status = kudu::Thread::Create("pool", "worker", ([&]{
       if (accept) {
         Sockaddr new_addr;
         Socket sock;
         CHECK_OK(listener_.Accept(&sock, &new_addr, 0));
         CHECK_OK(sock.Close());
       } else {
-        SleepFor(MonoDelta::FromMilliseconds(200));
+        while (!latch.WaitFor(MonoDelta::FromMilliseconds(10))) {}
         CHECK_OK(listener_.Close());
       }
-    });
+    }), &t);
+    ASSERT_OK(status);
     SCOPED_CLEANUP({
-      t.join();
+      latch.CountDown();
+      if (t) {
+        t->Join();
+      }
     });
 
     Socket client = ConnectToListeningServer();