You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kvrocks.apache.org by ti...@apache.org on 2022/06/25 05:01:10 UTC

[incubator-kvrocks] 01/01: Revert "fix: replication tests should wait for server restarted (#660)"

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

tison pushed a commit to branch revert-660-fix-replication-test
in repository https://gitbox.apache.org/repos/asf/incubator-kvrocks.git

commit 53d5f10532e389fecc81677413e62cddfc38690e
Author: tison <wa...@gmail.com>
AuthorDate: Sat Jun 25 13:01:05 2022 +0800

    Revert "fix: replication tests should wait for server restarted (#660)"
    
    This reverts commit ad6dbba1aac666897857fb23239d31ec53dc3e1a.
---
 src/server.cc                      |  2 --
 tests/tcl/tests/support/server.tcl | 41 +++++++++++++++++++-------------------
 tests/tcl/tests/support/util.tcl   | 10 +++-------
 3 files changed, 24 insertions(+), 29 deletions(-)

diff --git a/src/server.cc b/src/server.cc
index f372046..c45617e 100644
--- a/src/server.cc
+++ b/src/server.cc
@@ -167,8 +167,6 @@ Status Server::Start() {
     }
   });
 
-  LOG(INFO) << "Ready to accept connections";
-
   return Status::OK();
 }
 
diff --git a/tests/tcl/tests/support/server.tcl b/tests/tcl/tests/support/server.tcl
index 72141b2..7504eb5 100644
--- a/tests/tcl/tests/support/server.tcl
+++ b/tests/tcl/tests/support/server.tcl
@@ -134,7 +134,7 @@ proc ping_server {host port} {
     set retval 0
     if {[catch {
         if {$::tls} {
-            set fd [::tls::socket $host $port]
+            set fd [::tls::socket $host $port] 
         } else {
             set fd [socket $host $port]
         }
@@ -498,7 +498,6 @@ proc start_server {options {code undefined}} {
     dict set srv "port" $port
     dict set srv "stdout" $stdout
     dict set srv "stderr" $stderr
-    dict set srv "dir" [dict get $config "dir"]
     dict set srv "unixsocket" $unixsocket
 
     # if a block of code is supplied, we wait for the server to become
@@ -509,13 +508,13 @@ proc start_server {options {code undefined}} {
             error_and_quit $config_file $line
         }
 
-        while 1 {
-           # check that the server actually started and is ready for connections
-           if {[count_log_message [dict get $srv "dir"] "Ready to accept"] > 0} {
-               break
-           }
-           after 10
-        }
+        #while 1 {
+        #    # check that the server actually started and is ready for connections
+        #    if {[count_message_lines $stdout "Ready to accept"] > 0} {
+        #        break
+        #    }
+        #    after 10
+        #}
 
         # append the server to the stack
         lappend ::servers $srv
@@ -597,7 +596,7 @@ proc restart_server {level wait_ready rotate_logs} {
         file rename $stdout $stdout.$ts.$pid
         file rename $stderr $stderr.$ts.$pid
     }
-    set prev_ready_count [count_log_message [dict get $srv "dir"] "Ready to accept"]
+    set prev_ready_count [count_message_lines $stdout "Ready to accept"]
 
     # if we're inside a test, write the test name to the server log file
     if {[info exists ::cur_test]} {
@@ -618,15 +617,17 @@ proc restart_server {level wait_ready rotate_logs} {
     # re-set $srv in the servers list
     lset ::servers end+$level $srv
 
-    if {$wait_ready} {
-        while 1 {
-            # check that the server actually started and is ready for connections
-            if {[count_log_message [dict get $srv "dir"] "Ready to accept"] > $prev_ready_count} {
-                break
-            }
-            after 10
-        }
-    }
-
+    # if {$wait_ready} {
+    #     while 1 {
+    #         # check that the server actually started and is ready for connections
+    #         if {[count_message_lines $stdout "Ready to accept"] > $prev_ready_count} {
+    #             break
+    #         }
+    #         after 10
+    #     }
+    # }
+
+    # Just sleep 1s to make sure that kvrocks started
+    after 1000
     reconnect $level
 }
diff --git a/tests/tcl/tests/support/util.tcl b/tests/tcl/tests/support/util.tcl
index 9dc6204..fecccf4 100644
--- a/tests/tcl/tests/support/util.tcl
+++ b/tests/tcl/tests/support/util.tcl
@@ -148,13 +148,9 @@ proc count_message_lines {file pattern} {
 }
 
 # returns the number of times a line with that pattern appears in the log
-proc count_log_message {dir pattern} {
-    set files [glob [format "%s/%s" $dir "kvrocks.*.INFO.*"]]
-    set res 0
-    foreach file $files {
-        incr res [count_message_lines $file $pattern]
-    }
-    return $res
+proc count_log_message {srv_idx pattern} {
+    set stdout [srv $srv_idx stdout]
+    return [count_message_lines $stdout $pattern]
 }
 
 # verify pattern exists in server's sdtout after a certain line number