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
dd885d64
Commit
dd885d64
authored
May 11, 2022
by
zhifan huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test add bigger net ping test && use miniupnp when build net
parent
6533148d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
13 deletions
+52
-13
re6st/tests/test_network/miniupnpd.conf
re6st/tests/test_network/miniupnpd.conf
+3
-0
re6st/tests/test_network/network_build.py
re6st/tests/test_network/network_build.py
+21
-9
re6st/tests/test_network/test_ping.py
re6st/tests/test_network/test_ping.py
+28
-4
No files found.
re6st/tests/test_network/miniupnpd.conf
0 → 100644
View file @
dd885d64
clean_ruleset_interval
=
600
allow
1024
-
65535
10
.
0
.
0
.
0
/
8
1024
-
65535
deny
0
-
65535
0
.
0
.
0
.
0
/
0
0
-
65535
re6st/tests/test_network/network_build.py
View file @
dd885d64
from
sys
import
prefix
import
sys
import
nemu
import
weakref
import
ipaddress
...
...
@@ -10,6 +10,13 @@ execfile(str(fix_file))
IPTABLES
=
'iptables'
class
Node
(
nemu
.
Node
):
def
__init__
(
self
):
super
(
Node
,
self
).
__init__
()
self
.
Popen
((
'sysctl'
,
'-q'
,
'net.ipv4.icmp_echo_ignore_broadcasts=0'
)).
wait
()
"""simple nemu.Node used for registry and nodes"""
def
_add_interface
(
self
,
iface
):
self
.
iface
=
iface
...
...
@@ -101,9 +108,9 @@ def network_demo():
nm
.
object
=
[
registry
,
internet
,
m0
,
m1
,
m2
,
m3
,
m4
,
m5
,
g1
,
switch0
,
switch1
]
nm
.
registrys
=
{
registry
:
[
m0
,
m1
,
m2
,
m3
,
m4
,
m5
]}
# for node in [registry, m0, m2
, m3, m4, m5]:
#
print "pid: {}".format(node.pid)
for
node
in
[
g1
,
m3
,
m4
,
m5
]:
print
"pid: {}"
.
format
(
node
.
pid
)
g0_if_0
,
_
=
g1
.
connect_network
(
internet
)
m0
.
connect_network
(
internet
)
...
...
@@ -140,10 +147,14 @@ def network_demo():
for
node
in
[
m1
,
m2
]:
node
.
add_route
(
nexthop
=
"10.1.9.1"
)
for
node
in
[
m3
,
m4
,
m5
]:
node
.
add_route
(
nexthop
=
"10.1.10.1"
)
g1
.
app
=
g1
.
Popen
(
'miniupnpd -d -f miniupnpd.conf -P miniupnpd.pid'
' -a %s -i %s'
%
(
g1
.
if_s
.
name
,
g0_if_0
.
name
),
shell
=
True
)
print
"---------------"
for
node
in
[
m0
,
m1
,
m2
,
m3
,
m4
,
m5
]:
app0
=
node
.
Popen
([
"ping"
,
"-c"
,
"1"
,
registry
.
ip
],
stdout
=
PIPE
)
...
...
@@ -162,10 +173,10 @@ def network_direct():
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
...
...
@@ -174,6 +185,7 @@ def network_direct():
ret
=
app0
.
wait
()
assert
ret
==
0
,
"network construct failed"
return
nm
if
__name__
==
"__main__"
:
network_direct
()
nm
=
network_demo
()
time
.
sleep
(
1000000
)
re6st/tests/test_network/test_ping.py
View file @
dd885d64
...
...
@@ -74,11 +74,35 @@ class TestPing(unittest.TestCase):
proc
=
proc
.
split
()[
1
]
subprocess
.
call
([
"kill"
,
"-15"
,
proc
])
def
test_sample
(
self
):
# def test_sample(self):
# """create a network demo, test the connectivity by ping
# wait the network stable then ping 3 times
# """
# nm = network_direct()
# net = nm.registrys
# nodes = []
# registrys = []
# for registry in net:
# reg = re6st_wrap.Re6stRegistry(registry, "2001:db8:42::", recreate=False)
# reg_node = re6st_wrap.Re6stNode(registry, reg, name=reg.name)
# registrys.append(registry)
# reg_node.run("--gateway", "--disable-proto", "none", "--ip", registry.ip)
# nodes.append(reg_node)
# for m in net[registry]:
# node = re6st_wrap.Re6stNode(m, reg)
# node.run("-i" + m.iface.name)
# nodes.append(node)
# wait_stable(nodes)
# for i in range(3):
# time.sleep(20)
# self.assertFalse(ping_test(nodes), "N.{} ping test failed".format(i))
def
test_demo
(
self
):
"""create a network demo, test the connectivity by ping
wait the network stable then ping 3 times
"""
nm
=
network_d
irect
()
nm
=
network_d
emo
()
net
=
nm
.
registrys
nodes
=
[]
registrys
=
[]
...
...
@@ -92,10 +116,10 @@ class TestPing(unittest.TestCase):
node
=
re6st_wrap
.
Re6stNode
(
m
,
reg
)
node
.
run
(
"-i"
+
m
.
iface
.
name
)
nodes
.
append
(
node
)
wait_stable
(
nodes
)
for
i
in
range
(
3
):
time
.
sleep
(
2
0
)
time
.
sleep
(
3
0
)
self
.
assertFalse
(
ping_test
(
nodes
),
"N.{} ping test failed"
.
format
(
i
))
...
...
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