Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tarantool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
tarantool
Commits
b029a92a
Commit
b029a92a
authored
13 years ago
by
Konstantin Shulgin
Browse files
Options
Downloads
Patches
Plain Diff
feature 'master-valgrind':
* process handle routines in test enviroment was updated.
parent
52632364
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/lib/server.py
+44
-43
44 additions, 43 deletions
test/lib/server.py
with
44 additions
and
43 deletions
test/lib/server.py
+
44
−
43
View file @
b029a92a
...
...
@@ -11,19 +11,6 @@ import daemon
import
glob
import
ConfigParser
def
wait_until_connected
(
port
):
"""
Wait until the server is started and accepting connections
"""
is_connected
=
False
while
not
is_connected
:
try
:
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
sock
.
connect
((
"
localhost
"
,
port
))
is_connected
=
True
sock
.
close
()
except
socket
.
error
as
e
:
time
.
sleep
(
0.001
)
def
check_port
(
port
):
"""
Check if the port we
'
re connecting to is available
"""
...
...
@@ -196,20 +183,18 @@ class Server(object):
args
=
prepare_gdb
(
args
)
elif
self
.
valgrind
:
args
=
prepare_valgrind
(
args
,
self
.
valgrind_log
,
os
.
path
.
abspath
(
os
.
path
.
join
(
self
.
vardir
,
self
.
default_suppression_name
)))
os
.
path
.
abspath
(
os
.
path
.
join
(
self
.
vardir
,
self
.
default_suppression_name
)))
if
self
.
start_and_exit
:
self
.
_start_and_exit
(
args
)
else
:
self
.
process
=
pexpect
.
spawn
(
args
[
0
],
args
[
1
:],
cwd
=
self
.
vardir
)
return
# wait until the server is connectedk
wait_until_connected
(
self
.
port
)
self
.
process
=
pexpect
.
spawn
(
args
[
0
],
args
[
1
:],
cwd
=
self
.
vardir
)
# wait until the server is connected
self
.
wait_until_started
()
# Set is_started flag, to nicely support cleanup during an exception.
self
.
is_started
=
True
with
open
(
self
.
pidfile
)
as
f
:
self
.
pid
=
int
(
f
.
read
())
def
stop
(
self
,
silent
=
True
):
"""
Stop server instance. Do nothing if the server is not started,
...
...
@@ -225,20 +210,18 @@ class Server(object):
if
self
.
process
==
None
:
self
.
kill_old_server
()
else
:
self
.
kill_server
()
if
self
.
gdb
:
self
.
process
.
expect
(
pexpect
.
EOF
,
timeout
=
1
<<
30
)
else
:
self
.
process
.
expect
(
pexpect
.
EOF
)
return
# kill process
self
.
process
.
kill
(
signal
.
SIGTERM
)
self
.
process
.
wait
()
# clean-up processs flags
self
.
is_started
=
False
self
.
p
id
=
None
self
.
p
rocess
=
None
def
deploy
(
self
,
config
=
None
,
binary
=
None
,
vardir
=
None
,
mem
=
None
,
start_and_exit
=
None
,
gdb
=
None
,
valgrind
=
None
,
valgrind_sup
=
None
,
silent
=
True
,
need_init
=
True
):
silent
=
True
,
need_init
=
True
):
if
config
!=
None
:
self
.
config
=
config
if
binary
!=
None
:
self
.
binary
=
binary
if
vardir
!=
None
:
self
.
vardir
=
vardir
...
...
@@ -267,23 +250,12 @@ class Server(object):
stderr
=
subprocess
.
STDOUT
).
stdout
.
read
()
print
output
def
kill_server
(
self
):
"""
Kill a server which was started correctly
"""
try
:
os
.
kill
(
self
.
pid
,
signal
.
SIGTERM
)
except
OSError
as
e
:
print
e
pass
def
kill_old_server
(
self
,
silent
=
True
):
"""
Kill old server instance if it exists.
"""
if
os
.
access
(
self
.
pidfile
,
os
.
F_OK
)
==
False
:
pid
=
self
.
read_pidfile
()
if
pid
==
-
1
:
return
# Nothing to do
pid
=
0
with
open
(
self
.
pidfile
)
as
f
:
pid
=
int
(
f
.
read
())
if
not
silent
:
print
"
Found old server, pid {0}, killing...
"
.
format
(
pid
)
...
...
@@ -294,3 +266,32 @@ class Server(object):
except
OSError
:
pass
def
read_pidfile
(
self
):
if
os
.
access
(
self
.
pidfile
,
os
.
F_OK
)
==
False
:
# file is inaccessible (not exist or permission denied)
return
-
1
pid
=
-
1
try
:
with
open
(
self
.
pidfile
)
as
f
:
pid
=
int
(
f
.
read
())
except
:
pass
return
pid
def
wait_until_started
(
self
):
"""
Wait until the server is started and accepting connections
"""
while
(
self
.
read_pidfile
()
!=
self
.
process
.
pid
):
time
.
sleep
(
0.001
)
is_connected
=
False
while
not
is_connected
:
try
:
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
sock
.
connect
((
"
localhost
"
,
self
.
port
))
is_connected
=
True
sock
.
close
()
except
socket
.
error
as
e
:
time
.
sleep
(
0.001
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment