Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
re6stnet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
zhifan huang
re6stnet
Commits
bdf77571
Commit
bdf77571
authored
May 11, 2022
by
zhifan huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix add server start test
parent
042ec0b1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
0 deletions
+29
-0
re6st/tests/test_network/re6st_wrap.py
re6st/tests/test_network/re6st_wrap.py
+29
-0
No files found.
re6st/tests/test_network/re6st_wrap.py
View file @
bdf77571
...
...
@@ -9,6 +9,7 @@ import time
import
re
from
subprocess
import
PIPE
,
call
from
pathlib2
import
Path
import
logging
import
re6st.tests.tools
as
tools
...
...
@@ -34,6 +35,15 @@ def ip_to_serial(ip6):
return
int
(
ip6
,
16
)
def
wait_ps
(
p
,
timeout
=
1
,
sec
=
0.1
):
"""implement timeout of wait"""
now
=
time
.
time
()
while
time
.
time
()
-
timeout
<
now
:
if
p
.
poll
()
is
not
None
:
return
time
.
sleep
(
sec
)
raise
Exception
(
"{}, not terminate"
.
format
(
p
.
pid
))
class
Re6stRegistry
(
object
):
"""class run a re6st-registry service on a namespace"""
registry_seq
=
-
1
...
...
@@ -67,6 +77,25 @@ class Re6stRegistry(object):
self
.
run
()
# wait the servcice started
p
=
self
.
node
.
Popen
([
'python'
,
'-c'
,
"""if 1:
import socket, time
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
while True:
try:
s.connect(('localhost', 80))
break
except socket.error:
time.sleep(.1)
"""
])
try
:
wait_ps
(
p
,
5
)
except
Exception
as
e
:
logging
.
error
(
"{}: {}"
,
self
.
name
,
e
)
raise
e
logging
.
info
(
"re6st service started"
)
@
classmethod
def
generate_name
(
cls
):
cls
.
registry_seq
+=
1
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment