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
2
Issues
2
List
Boards
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
nexedi
re6stnet
Commits
9410d0f5
Commit
9410d0f5
authored
May 16, 2024
by
Tom Niget
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more resource cleanups to remove ResourceWarnings
parent
69c4e60a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
40 additions
and
23 deletions
+40
-23
re6st/cli/node.py
re6st/cli/node.py
+6
-6
re6st/tests/test_end2end/test_registry_client.py
re6st/tests/test_end2end/test_registry_client.py
+1
-0
re6st/tests/test_network/network_build.py
re6st/tests/test_network/network_build.py
+5
-5
re6st/tests/test_network/re6st_wrap.py
re6st/tests/test_network/re6st_wrap.py
+2
-0
re6st/tests/test_network/test_net.py
re6st/tests/test_network/test_net.py
+23
-9
re6st/tests/tools.py
re6st/tests/tools.py
+3
-3
No files found.
re6st/cli/node.py
View file @
9410d0f5
...
...
@@ -266,12 +266,12 @@ def main():
def
call
(
cmd
):
logging
.
debug
(
'%r'
,
cmd
)
p
=
subprocess
.
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
stdout
,
stderr
=
p
.
communicate
()
if
p
.
returncode
:
raise
EnvironmentError
(
"%r failed with error %u
\
n
%s"
%
(
' '
.
join
(
cmd
),
p
.
returncode
,
stderr
))
with
subprocess
.
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
as
p
:
stdout
,
stderr
=
p
.
communicate
()
if
p
.
returncode
:
raise
EnvironmentError
(
"%r failed with error %u
\
n
%s"
%
(
' '
.
join
(
cmd
),
p
.
returncode
,
stderr
))
return
stdout
def
ip4
(
object
,
*
args
):
args
=
[
'ip'
,
'-4'
,
object
,
'add'
]
+
list
(
args
)
...
...
re6st/tests/test_end2end/test_registry_client.py
View file @
9410d0f5
...
...
@@ -42,6 +42,7 @@ class TestRegistryClientInteract(unittest.TestCase):
def
tearDown
(
self
):
self
.
server
.
proc
.
terminate
()
self
.
server
.
proc
.
__exit__
()
def
test_1_main
(
self
):
""" a client interact a server, no re6stnet node test basic function"""
...
...
re6st/tests/test_network/network_build.py
View file @
9410d0f5
...
...
@@ -62,11 +62,11 @@ class NetManager:
"""
for
reg
,
nodes
in
self
.
registries
.
items
():
for
node
in
nodes
:
app0
=
node
.
Popen
([
"ping"
,
"-c"
,
"1"
,
reg
.
ip
],
stdout
=
PIPE
)
ret
=
app0
.
wait
()
if
ret
:
raise
ConnectableError
(
"network construct failed {} to {}"
.
format
(
node
.
ip
,
reg
.
ip
))
with
node
.
Popen
([
"ping"
,
"-c"
,
"1"
,
reg
.
ip
],
stdout
=
PIPE
)
as
app0
:
ret
=
app0
.
wait
()
if
ret
:
raise
ConnectableError
(
"network construct failed {} to {}"
.
format
(
node
.
ip
,
reg
.
ip
))
logging
.
debug
(
"each node can ping to their registry"
)
...
...
re6st/tests/test_network/re6st_wrap.py
View file @
9410d0f5
...
...
@@ -136,6 +136,7 @@ class Re6stRegistry:
try
:
logging
.
debug
(
"teminate process %s"
,
self
.
proc
.
pid
)
self
.
proc
.
destroy
()
self
.
proc
.
__exit__
()
except
:
pass
...
...
@@ -262,6 +263,7 @@ class Re6stNode:
"""stop running re6stnet process"""
logging
.
debug
(
"%s teminate process %s"
,
self
.
name
,
self
.
proc
.
pid
)
self
.
proc
.
destroy
()
self
.
proc
.
__exit__
()
def
__del__
(
self
):
"""teminate process and rm temp dir"""
...
...
re6st/tests/test_network/test_net.py
View file @
9410d0f5
...
...
@@ -31,6 +31,14 @@ def deploy_re6st(nm, recreate=False):
nodes
.
append
(
node
)
return
nodes
,
registries
def
clean_re6st
(
nodes
,
registries
):
for
node
in
nodes
:
node
.
node
.
destroy
()
node
.
stop
()
for
reg
in
registries
:
reg
.
__del__
()
def
wait_stable
(
nodes
,
timeout
=
240
):
"""try use ping6 from each node to the other until ping success to all the
other nodes
...
...
@@ -94,12 +102,14 @@ class TestNet(unittest.TestCase):
"""create a network in a net segment, test the connectivity by ping
"""
nm
=
network_build
.
net_route
()
nodes
,
_
=
deploy_re6st
(
nm
)
nodes
,
registries
=
deploy_re6st
(
nm
)
wait_stable
(
nodes
,
4
0
)
wait_stable
(
nodes
,
1
0
)
time
.
sleep
(
10
)
self
.
assertTrue
(
wait_stable
(
nodes
,
30
),
" ping test failed"
)
self
.
assertTrue
(
wait_stable
(
nodes
,
10
),
" ping test failed"
)
clean_re6st
(
nodes
,
registries
)
@
unittest
.
skip
(
"usually failed due to UPnP problem"
)
def
test_reboot_one_machine
(
self
):
...
...
@@ -107,9 +117,9 @@ class TestNet(unittest.TestCase):
then test if network recover, this test seems always failed
"""
nm
=
network_build
.
net_demo
()
nodes
,
_
=
deploy_re6st
(
nm
)
nodes
,
registries
=
deploy_re6st
(
nm
)
wait_stable
(
nodes
,
10
0
)
wait_stable
(
nodes
,
10
)
# stop on machine randomly
index
=
int
(
random
.
random
()
*
7
)
+
1
...
...
@@ -119,16 +129,18 @@ class TestNet(unittest.TestCase):
machine
.
run
(
"-i"
+
machine
.
node
.
iface
.
name
)
logging
.
info
(
"restart %s"
,
machine
.
name
)
self
.
assertTrue
(
wait_stable
(
nodes
,
400
),
"network can't recover"
)
self
.
assertTrue
(
wait_stable
(
nodes
,
10
),
"network can't recover"
)
clean_re6st
(
nodes
,
registries
)
def
test_reboot_one_machine_router
(
self
):
"""create a network router, wait the net stable, reboot on machine,
then test if network recover,
"""
nm
=
network_build
.
net_route
()
nodes
,
_
=
deploy_re6st
(
nm
)
nodes
,
registries
=
deploy_re6st
(
nm
)
wait_stable
(
nodes
,
4
0
)
wait_stable
(
nodes
,
1
0
)
# stop on machine randomly
index
=
int
(
random
.
random
()
*
2
)
+
1
...
...
@@ -138,7 +150,9 @@ class TestNet(unittest.TestCase):
machine
.
run
(
"-i"
+
machine
.
node
.
iface
.
name
)
logging
.
info
(
"restart %s"
,
machine
.
name
)
self
.
assertTrue
(
wait_stable
(
nodes
,
100
),
"network can't recover"
)
self
.
assertTrue
(
wait_stable
(
nodes
,
10
),
"network can't recover"
)
clean_re6st
(
nodes
,
registries
)
...
...
re6st/tests/tools.py
View file @
9410d0f5
...
...
@@ -103,7 +103,7 @@ def decrypt(pkey, incontent):
with
open
(
"node.key"
,
'w'
)
as
f
:
f
.
write
(
pkey
.
decode
())
args
=
"openssl rsautl -decrypt -inkey node.key"
.
split
()
p
=
subprocess
.
Popen
(
args
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
outcontent
,
err
=
p
.
communicate
(
incontent
)
with
subprocess
.
Popen
(
args
,
stdin
=
subprocess
.
PIPE
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
as
p
:
outcontent
,
err
=
p
.
communicate
(
incontent
)
return
outcontent
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