Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
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
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
tci-gateway-module
Grpc
Commits
fe4939f8
Commit
fe4939f8
authored
9 years ago
by
Craig Tiller
Browse files
Options
Downloads
Patches
Plain Diff
More robust port_server version checking
parent
4d1fc552
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tools/run_tests/port_server.py
+14
-5
14 additions, 5 deletions
tools/run_tests/port_server.py
tools/run_tests/run_tests.py
+15
-12
15 additions, 12 deletions
tools/run_tests/run_tests.py
with
29 additions
and
17 deletions
tools/run_tests/port_server.py
+
14
−
5
View file @
fe4939f8
...
@@ -38,6 +38,18 @@ import socket
...
@@ -38,6 +38,18 @@ import socket
import
sys
import
sys
import
time
import
time
# increment this number whenever making a change to ensure that
# the changes are picked up by running CI servers
# note that all changes must be backwards compatible
_MY_VERSION
=
2
if
len
(
sys
.
argv
)
==
2
and
sys
.
argv
[
1
]
==
'
dump_version
'
:
print
_MY_VERSION
sys
.
exit
(
0
)
argp
=
argparse
.
ArgumentParser
(
description
=
'
Server for httpcli_test
'
)
argp
=
argparse
.
ArgumentParser
(
description
=
'
Server for httpcli_test
'
)
argp
.
add_argument
(
'
-p
'
,
'
--port
'
,
default
=
12345
,
type
=
int
)
argp
.
add_argument
(
'
-p
'
,
'
--port
'
,
default
=
12345
,
type
=
int
)
args
=
argp
.
parse_args
()
args
=
argp
.
parse_args
()
...
@@ -47,9 +59,6 @@ print 'port server running on port %d' % args.port
...
@@ -47,9 +59,6 @@ print 'port server running on port %d' % args.port
pool
=
[]
pool
=
[]
in_use
=
{}
in_use
=
{}
with
open
(
__file__
)
as
f
:
_MY_VERSION
=
hashlib
.
sha1
(
f
.
read
()).
hexdigest
()
def
refill_pool
(
max_timeout
,
req
):
def
refill_pool
(
max_timeout
,
req
):
"""
Scan for ports not marked for being in use
"""
"""
Scan for ports not marked for being in use
"""
...
@@ -113,7 +122,7 @@ class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
...
@@ -113,7 +122,7 @@ class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
del
in_use
[
p
]
del
in_use
[
p
]
pool
.
append
(
p
)
pool
.
append
(
p
)
self
.
log_message
(
'
drop port %d
'
%
p
)
self
.
log_message
(
'
drop port %d
'
%
p
)
elif
self
.
path
==
'
/version
'
:
elif
self
.
path
==
'
/version
_number
'
:
# fetch a version string and the current process pid
# fetch a version string and the current process pid
self
.
send_response
(
200
)
self
.
send_response
(
200
)
self
.
send_header
(
'
Content-Type
'
,
'
text/plain
'
)
self
.
send_header
(
'
Content-Type
'
,
'
text/plain
'
)
...
@@ -128,7 +137,7 @@ class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
...
@@ -128,7 +137,7 @@ class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
self
.
end_headers
()
self
.
end_headers
()
now
=
time
.
time
()
now
=
time
.
time
()
self
.
wfile
.
write
(
yaml
.
dump
({
'
pool
'
:
pool
,
'
in_use
'
:
dict
((
k
,
now
-
v
)
for
k
,
v
in
in_use
.
iteritems
())}))
self
.
wfile
.
write
(
yaml
.
dump
({
'
pool
'
:
pool
,
'
in_use
'
:
dict
((
k
,
now
-
v
)
for
k
,
v
in
in_use
.
iteritems
())}))
elif
self
.
path
==
'
/quit
'
:
elif
self
.
path
==
'
/quit
quitquit
'
:
self
.
send_response
(
200
)
self
.
send_response
(
200
)
self
.
end_headers
()
self
.
end_headers
()
keep_running
=
False
keep_running
=
False
...
...
This diff is collapsed.
Click to expand it.
tools/run_tests/run_tests.py
+
15
−
12
View file @
fe4939f8
...
@@ -713,21 +713,24 @@ def _start_port_server(port_server_port):
...
@@ -713,21 +713,24 @@ def _start_port_server(port_server_port):
# if not running ==> start a new one
# if not running ==> start a new one
# otherwise, leave it up
# otherwise, leave it up
try
:
try
:
version
=
urllib2
.
urlopen
(
'
http://localhost:%d/version
'
%
port_server_port
,
version
=
int
(
urllib2
.
urlopen
(
timeout
=
1
).
read
()
'
http://localhost:%d/version_number
'
%
port_server_port
,
print
'
detected port server running
'
timeout
=
1
).
read
())
print
'
detected port server running version %d
'
%
version
running
=
True
running
=
True
except
Exception
:
except
Exception
as
e
:
print
'
failed to detect port server: %s
'
%
sys
.
exc_info
()[
0
]
print
'
failed to detect port server: %s
'
%
sys
.
exc_info
()[
0
]
print
e
.
strerror
running
=
False
running
=
False
if
running
:
if
running
:
with
open
(
'
tools/run_tests/port_server.py
'
)
as
f
:
current_version
=
int
(
subprocess
.
check_output
(
current_version
=
hashlib
.
sha1
(
f
.
read
()).
hexdigest
()
[
sys
.
executable
,
'
tools/run_tests/port_server.py
'
,
'
dump_version
'
]))
running
=
(
version
==
current_version
)
print
'
my port server is version %d
'
%
current_version
if
not
running
:
running
=
(
version
>=
current_version
)
print
'
port_server version mismatch: killing the old one
'
if
not
running
:
urllib2
.
urlopen
(
'
http://localhost:%d/quit
'
%
port_server_port
).
read
()
print
'
port_server version mismatch: killing the old one
'
time
.
sleep
(
1
)
urllib2
.
urlopen
(
'
http://localhost:%d/quitquitquit
'
%
port_server_port
).
read
()
time
.
sleep
(
1
)
if
not
running
:
if
not
running
:
print
'
starting port_server
'
print
'
starting port_server
'
port_log
=
open
(
'
portlog.txt
'
,
'
w
'
)
port_log
=
open
(
'
portlog.txt
'
,
'
w
'
)
...
@@ -773,7 +776,7 @@ def _build_and_run(
...
@@ -773,7 +776,7 @@ def _build_and_run(
# start antagonists
# start antagonists
antagonists
=
[
subprocess
.
Popen
([
'
tools/run_tests/antagonist.py
'
])
antagonists
=
[
subprocess
.
Popen
([
'
tools/run_tests/antagonist.py
'
])
for
_
in
range
(
0
,
args
.
antagonists
)]
for
_
in
range
(
0
,
args
.
antagonists
)]
port_server_port
=
9999
port_server_port
=
32767
_start_port_server
(
port_server_port
)
_start_port_server
(
port_server_port
)
try
:
try
:
infinite_runs
=
runs_per_test
==
0
infinite_runs
=
runs_per_test
==
0
...
...
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