-
Notifications
You must be signed in to change notification settings - Fork 17
Add timeout for starting tarantool server #302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ylobankov
merged 4 commits into
master
from
VitaliyaIoffe/gh-276-hangs-timeout-doesnt-work
Mar 15, 2022
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
0fd83f6
Use gevent sleep for switching context
VitaliyaIoffe 33d1adc
Add timeout for starting tarantool server
VitaliyaIoffe 1e01638
Kill processes of non-started tarantool servers
ylobankov 37bd48f
Add unit test checking no hanging procs present
ylobankov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env tarantool | ||
ligurio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
box.cfg { | ||
listen = os.getenv('LISTEN'), | ||
} | ||
|
||
require('console').listen(os.getenv('ADMIN')) | ||
ligurio marked this conversation as resolved.
Show resolved
Hide resolved
|
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
test_run = require('test_run').new() | ||
|
||
-- This test should hang: we are unable to bootstrap the replica, because it is | ||
-- unable to join the master because of lack of granting user permissions. | ||
test_run:cmd('create server replica with rpl_master=default, script="unittest/replica-7f4d4895ff58.lua"') | ||
test_run:cmd('start server replica') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env tarantool | ||
|
||
box.cfg { | ||
listen = os.getenv('LISTEN'), | ||
replication = os.getenv('MASTER'), | ||
} | ||
|
||
require('console').listen(os.getenv('ADMIN')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[default] | ||
core = tarantool | ||
description = unit tests | ||
script = box-cc0544b6afd1.lua | ||
use_unix_sockets = True | ||
use_unix_sockets_iproto = True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import os | ||
ligurio marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import subprocess | ||
import sys | ||
import unittest | ||
|
||
|
||
class TestTarantoolServer(unittest.TestCase): | ||
def test_tarantool_server_not_hanging(self): | ||
env = os.environ.copy() | ||
env['SERVER_START_TIMEOUT'] = '5' | ||
|
||
cmd = [sys.executable, 'test/test-run.py', 'unittest/hang.test.lua'] | ||
|
||
# File names intentionally have hashes to find exactly these processes | ||
# using 'ps' command. | ||
box_instance = 'box-cc0544b6afd1' | ||
replica_instance = 'replica-7f4d4895ff58' | ||
|
||
err_msg_1 = ('[Instance "%s"] Failed to start tarantool ' | ||
'instance "%s"' % (box_instance, replica_instance)) | ||
err_msg_2 = ('[Instance "%s"] Failed to start within %s seconds' | ||
% (replica_instance, env['SERVER_START_TIMEOUT'])) | ||
|
||
try: | ||
subprocess.check_output(cmd, env=env, universal_newlines=True) | ||
self.fail("Command `%s` did not return non-zero exit code" | ||
% ' '.join(cmd)) | ||
except subprocess.CalledProcessError as exc: | ||
err_obj = exc | ||
|
||
self.assertIn(err_msg_1, err_obj.output) | ||
self.assertIn(err_msg_2, err_obj.output) | ||
|
||
ps_lines = subprocess.check_output( | ||
['ps', '-o', 'command'], universal_newlines=True | ||
).splitlines() | ||
proc_lines = [line.strip() for line in ps_lines | ||
if 'tarantool %s.lua' % box_instance in line or | ||
'tarantool %s.lua' % replica_instance in line] | ||
|
||
self.assertFalse( | ||
proc_lines, 'There are some hanging tarantool processes!' | ||
) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.