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
Xiaowu Zhang
re6stnet
Commits
c51929b5
Commit
c51929b5
authored
Jul 12, 2022
by
zhifan huang
Committed by
Xiaowu Zhang
Aug 29, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: move connect test function, and typo
parent
d288e269
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
22 deletions
+18
-22
re6st/tests/test_network/network_build.py
re6st/tests/test_network/network_build.py
+18
-22
No files found.
re6st/tests/test_network/network_build.py
View file @
c51929b5
...
@@ -8,7 +8,8 @@ from pathlib2 import Path
...
@@ -8,7 +8,8 @@ from pathlib2 import Path
DEMO_PATH
=
Path
(
__file__
).
resolve
().
parent
.
parent
.
parent
.
parent
/
"demo"
DEMO_PATH
=
Path
(
__file__
).
resolve
().
parent
.
parent
.
parent
.
parent
/
"demo"
fix_file
=
DEMO_PATH
/
"fixnemu.py"
fix_file
=
DEMO_PATH
/
"fixnemu.py"
execfile
(
str
(
fix_file
))
# execfile(str(fix_file)) Removed in python3
exec
(
open
(
str
(
fix_file
)).
read
())
IPTABLES
=
'iptables-nft'
IPTABLES
=
'iptables-nft'
class
Node
(
nemu
.
Node
):
class
Node
(
nemu
.
Node
):
...
@@ -50,27 +51,22 @@ class NetManager(object):
...
@@ -50,27 +51,22 @@ class NetManager(object):
def
__init__
(
self
):
def
__init__
(
self
):
self
.
object
=
[]
self
.
object
=
[]
self
.
registries
=
{}
self
.
registries
=
{}
def
connectable_test
(
self
):
"""test each node can ping to their registry
Raise:
AssertionError
"""
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
ConnectionError
(
"network construct failed {} to {}"
.
format
(
node
.
ip
,
reg
.
ip
))
logging
.
debug
(
"each node can ping to their registry"
)
def
connectible_test
(
nm
):
"""test each node can ping to their registry
Args:
nm: NetManger
Raise:
AssertionError
"""
for
reg
in
nm
.
registries
:
for
node
in
nm
.
registries
[
reg
]:
app0
=
node
.
Popen
([
"ping"
,
"-c"
,
"1"
,
reg
.
ip
],
stdout
=
PIPE
)
ret
=
app0
.
wait
()
if
ret
:
raise
ConnectionError
(
"network construct failed {} to {}"
.
format
(
node
.
ip
,
reg
.
ip
))
logging
.
debug
(
"each node can ping to their registry"
)
def
net_route
():
def
net_route
():
"""build a network connect by a route(bridge)
"""build a network connect by a route(bridge)
...
@@ -93,7 +89,7 @@ def net_route():
...
@@ -93,7 +89,7 @@ def net_route():
nm
.
object
.
append
(
switch1
)
nm
.
object
.
append
(
switch1
)
nm
.
registries
[
registry
]
=
[
machine1
,
machine2
]
nm
.
registries
[
registry
]
=
[
machine1
,
machine2
]
connectible_test
(
nm
)
nm
.
connectable_test
(
)
return
nm
return
nm
def
net_demo
():
def
net_demo
():
...
@@ -177,7 +173,7 @@ def net_demo():
...
@@ -177,7 +173,7 @@ def net_demo():
stdout
=
PIPE
,
stderr
=
PIPE
)
stdout
=
PIPE
,
stderr
=
PIPE
)
switch1
.
up
=
switch2
.
up
=
switch3
.
up
=
True
switch1
.
up
=
switch2
.
up
=
switch3
.
up
=
True
connectible_test
(
nm
)
nm
.
connectable_test
(
)
return
nm
return
nm
def
network_direct
():
def
network_direct
():
...
...
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