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
78a1dac7
Commit
78a1dac7
authored
Apr 15, 2022
by
zhifan huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a 2 node test
parent
e1aa324b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
3 deletions
+29
-3
re6st/tests/test_network/network_build.py
re6st/tests/test_network/network_build.py
+28
-2
re6st/tests/test_network/test_ping.py
re6st/tests/test_network/test_ping.py
+1
-1
No files found.
re6st/tests/test_network/network_build.py
View file @
78a1dac7
from
sys
import
prefix
import
nemu
import
nemu
import
weakref
import
weakref
import
ipaddress
import
ipaddress
...
@@ -30,7 +31,7 @@ class Node(nemu.Node):
...
@@ -30,7 +31,7 @@ class Node(nemu.Node):
return
addr
return
addr
def
connect_network
(
self
,
internet
):
def
connect_network
(
self
,
internet
):
""" create a p2p interface with internet, and as
saing
ipaddress for
""" create a p2p interface with internet, and as
gin
ipaddress for
interface
interface
internet: Internet object
internet: Internet object
...
@@ -145,9 +146,34 @@ def network_demo():
...
@@ -145,9 +146,34 @@ def network_demo():
for
node
in
[
m0
,
m1
,
m2
,
m3
,
m4
,
m5
]:
for
node
in
[
m0
,
m1
,
m2
,
m3
,
m4
,
m5
]:
app0
=
m1
.
Popen
([
"ping"
,
"-c"
,
"1"
,
registry
.
ip
],
stdout
=
PIPE
)
app0
=
node
.
Popen
([
"ping"
,
"-c"
,
"1"
,
registry
.
ip
],
stdout
=
PIPE
)
ret
=
app0
.
wait
()
ret
=
app0
.
wait
()
assert
ret
==
0
,
"network construct failed"
assert
ret
==
0
,
"network construct failed"
return
nm
return
nm
def
network_direct
():
"""one server and one client connect direct"""
registry
=
Node
()
m0
=
Node
()
nm
=
NetManager
()
nm
.
registrys
=
{
registry
:
[
m0
]}
re_if_0
,
m_if_0
=
nemu
.
P2PInterface
.
create_pair
(
registry
,
m0
)
registry
.
_ip
=
u"10.1.2.1"
re_if_0
.
add_v4_address
(
u"10.1.2.1"
,
prefix_len
=
24
)
m_if_0
.
add_v4_address
(
u"10.1.2.2"
,
prefix_len
=
24
)
re_if_0
.
up
=
m_if_0
.
up
=
True
for
node
in
[
m0
]:
app0
=
node
.
Popen
([
"ping"
,
"-c"
,
"1"
,
"10.1.2.1"
],
stdout
=
PIPE
)
ret
=
app0
.
wait
()
assert
ret
==
0
,
"network construct failed"
return
nm
if
__name__
==
"__main__"
:
network_direct
()
re6st/tests/test_network/test_ping.py
View file @
78a1dac7
...
@@ -78,7 +78,7 @@ class TestPing(unittest.TestCase):
...
@@ -78,7 +78,7 @@ class TestPing(unittest.TestCase):
"""create a network demo, test the connectivity by ping
"""create a network demo, test the connectivity by ping
wait the network stable then ping 3 times
wait the network stable then ping 3 times
"""
"""
nm
=
network_d
emo
()
nm
=
network_d
irect
()
net
=
nm
.
registrys
net
=
nm
.
registrys
nodes
=
[]
nodes
=
[]
registrys
=
[]
registrys
=
[]
...
...
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