Skip to content

Commit

Permalink
tests: fix flacky test_running_base_functionality
Browse files Browse the repository at this point in the history
The integration test `test_running_cluster::test_running_base_functionality`
fails sometimes with an failed assertion of the same PID after restart.

After the patch waiting for instances stop was added to make sure that
cluster is down before it will start again and will check for PID.

Closes #972
  • Loading branch information
themilchenko authored and oleg-jukovec committed Oct 28, 2024
1 parent a2c0629 commit 00d9650
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
9 changes: 8 additions & 1 deletion test/integration/running/test_running_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import yaml

from utils import (control_socket, extract_status, get_tarantool_version,
run_command_and_get_output, run_path, wait_file)
run_command_and_get_output, run_path, wait_file,
wait_pid_disappear)

tarantool_major_version, tarantool_minor_version = get_tarantool_version()

Expand Down Expand Up @@ -99,6 +100,12 @@ def test_running_base_functionality(tt_cmd, tmpdir_with_cfg):
)
start_output = instance_process.stdout.read()

# Need to wait for all instances to stop before start.
for inst in instances:
# Wait when PID that was fetched on start disappears.
wait_pid_disappear(os.path.join(run_dir, inst, 'tarantool.pid'),
pidByInstanceName.get(inst))

for inst in instances:
assert f"Starting an instance [{app_name}:{inst}]" in start_output

Expand Down
14 changes: 14 additions & 0 deletions test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,3 +573,17 @@ def wait_for_lines_in_output(stdout, expected_lines: list):
break

return output


@retry(Exception, tries=40, delay=0.5)
def wait_pid_disappear(file, target_pid):
found = True
while found:
if not os.path.exists(file):
found = False
break
with open(file, "r") as f:
if target_pid not in f.readline():
found = False
break
assert not found

0 comments on commit 00d9650

Please sign in to comment.