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

hulk pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/incubator-kvrocks.git


The following commit(s) were added to refs/heads/unstable by this push:
     new 5dc7867  Fix starting server should wait for ready in tcl tests (#761)
5dc7867 is described below

commit 5dc7867bb0f9ca078dda2bd3874c994fe0c03bf5
Author: hulk <[email protected]>
AuthorDate: Sat Jul 30 12:47:14 2022 +0800

    Fix starting server should wait for ready in tcl tests (#761)
---
 src/main.cc                        |  5 ++---
 tests/tcl/tests/support/server.tcl | 12 ++++++------
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/main.cc b/src/main.cc
index cabd0c8..6b5d6f1 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -306,7 +306,6 @@ int main(int argc, char* argv[]) {
   signal(SIGTERM, signal_handler);
   setupSigSegvAction();
 
-  std::cout << "Version: " << VERSION << " @" << GIT_COMMIT << std::endl;
   auto opts = parseCommandLineOptions(argc, argv);
   if (opts.show_usage) usage(argv[0]);
 
@@ -320,11 +319,12 @@ int main(int argc, char* argv[]) {
     exit(1);
   }
   initGoogleLog(&config);
+  LOG(INFO)<< "Version: " << VERSION << " @" << GIT_COMMIT << std::endl;
   // Tricky: We don't expect that different instances running on the same port,
   // but the server use REUSE_PORT to support the multi listeners. So we 
connect
   // the listen port to check if the port has already listened or not.
   if (Util::IsPortInUse(config.port)) {
-    std::cout << "Failed to start the server, the specified port["
+    LOG(ERROR)<< "Could not create server TCP since the specified port["
               << config.port << "] is already in use" << std::endl;
     exit(1);
   }
@@ -336,7 +336,6 @@ int main(int argc, char* argv[]) {
     exit(1);
   }
 
-  LOG(INFO) << "Version: " << VERSION << " @" << GIT_COMMIT;
   Engine::Storage storage(&config);
   s = storage.Open();
   if (!s.IsOK()) {
diff --git a/tests/tcl/tests/support/server.tcl 
b/tests/tcl/tests/support/server.tcl
index 72141b2..c4bb718 100644
--- a/tests/tcl/tests/support/server.tcl
+++ b/tests/tcl/tests/support/server.tcl
@@ -255,13 +255,10 @@ proc spawn_server {config_file stdout stderr} {
 
 # Wait for actual startup, return 1 if port is busy, 0 otherwise
 proc wait_server_started {config_file stdout pid} {
-    set checkperiod 100; # Milliseconds
+    set checkperiod 1000; # Milliseconds
     set maxiter [expr {120*1000/$checkperiod}] ; # Wait up to 2 minutes.
     set port_busy 0
     while 1 {
-        if {[regexp -- " PID: $pid" [exec cat $stdout]]} {
-            break
-        }
         after $checkperiod
         incr maxiter -1
         if {$maxiter == 0} {
@@ -274,10 +271,13 @@ proc wait_server_started {config_file stdout pid} {
 
         # Check if the port is actually busy and the server failed
         # for this reason.
-        if {[regexp {Could not create server TCP} [exec cat $stdout]]} {
+        if {[regexp -- "Could not create server TCP" [exec cat $stdout]]} {
             set port_busy 1
             break
         }
+        if {[count_log_message [dict get $config_file "dir"] "Ready to 
accept"] > 0} {
+            break
+        }
     }
     return $port_busy
 }
@@ -442,7 +442,7 @@ proc start_server {options {code undefined}} {
 
         # check that the server actually started
         set port_busy 0
-        # set port_busy [wait_server_started $config_file $stdout $pid]
+        set port_busy [wait_server_started $config $stdout $pid]
 
         # Sometimes we have to try a different port, even if we checked
         # for availability. Other test clients may grab the port before we

Reply via email to