Skip to content

Commit a64c6e0

Browse files
test: wait until server is ready
Current `wait_until_started` method wait till `box.info.status` is "running" and start sending requests. Such approach is wrong: status "running" [1] does not guarantees that instance is available for writing (like creating new users) [2]. It results in flaky test results (for example, see 4 restarts in [3]). This patch fixes the issue. After this patch, it is guaranteed that after `wait_until_ready` call instance had finished to run its initialization script, including box.cfg, and available for writing data if it is expected to be able to. Windows instances use a separate lock mechanism, so this patch is not related to Windows instances. 1. https://github.com/tarantool/tarantool/blob/983a7ec215d46b6d02935d1baa8bbe07fc371795/src/box/box.cc#L5425-L5426 2. https://github.com/tarantool/tarantool/blob/983a7ec215d46b6d02935d1baa8bbe07fc371795/src/box/box.cc#L5454 3. https://github.com/tarantool/tarantool/actions/runs/5759802620
1 parent 21f77a6 commit a64c6e0

File tree

3 files changed

+12
-13
lines changed

3 files changed

+12
-13
lines changed

test/suites/box.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ box.cfg{
1919
pid_file = "box.pid",
2020
auth_type = (auth_type:len() > 0) and auth_type or nil,
2121
}
22+
23+
rawset(_G, 'ready', true)

test/suites/crud_server.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,5 @@ if crud_imported == false or vshard_imported == false then
9191
else
9292
configure_crud_instance(primary_listen, crud, vshard)
9393
end
94+
95+
rawset(_G, 'ready', true)

test/suites/lib/tarantool_server.py

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -302,27 +302,22 @@ def prepare_args(self):
302302

303303
return shlex.split(self.binary if not self.script else self.script_dst)
304304

305-
def wait_until_started(self):
305+
def wait_until_ready(self):
306306
"""
307-
Wait until server is started.
307+
Wait until server is configured and ready to work.
308308
309309
Server consists of two parts:
310310
1) wait until server is listening on sockets
311-
2) wait until server tells us his status
311+
2) wait until server finishes executing its script
312312
"""
313313

314314
while True:
315315
try:
316316
temp = TarantoolAdmin('0.0.0.0', self.args['admin'])
317-
while True:
318-
ans = temp('box.info.status')[0]
319-
if ans in ('running', 'hot_standby', 'orphan') or ans.startswith('replica'):
320-
temp.disconnect()
321-
return True
322-
if ans in ('loading',):
323-
continue
324-
325-
raise ValueError(f"Strange output for `box.info.status`: {ans}")
317+
ans = temp('ready')[0]
318+
temp.disconnect()
319+
if isinstance(ans, bool) and ans:
320+
return True
326321
except socket.error as exc:
327322
if exc.errno == errno.ECONNREFUSED:
328323
time.sleep(0.1)
@@ -352,7 +347,7 @@ def start(self):
352347
cwd=self.vardir,
353348
stdout=self.log_des,
354349
stderr=self.log_des)
355-
self.wait_until_started()
350+
self.wait_until_ready()
356351

357352
def stop(self):
358353
"""

0 commit comments

Comments
 (0)