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
f01d94c7
Commit
f01d94c7
authored
May 12, 2022
by
zhifan huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: set default route for node use UPnP
parent
73b32880
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
9 deletions
+14
-9
re6st/tests/test_network/my_net.py
re6st/tests/test_network/my_net.py
+9
-7
re6st/tests/test_network/test_net.py
re6st/tests/test_network/test_net.py
+5
-2
No files found.
re6st/tests/test_network/my_net.py
View file @
f01d94c7
...
@@ -50,7 +50,7 @@ class Device(object):
...
@@ -50,7 +50,7 @@ class Device(object):
def
add_ip4
(
self
,
address
,
prefix
):
def
add_ip4
(
self
,
address
,
prefix
):
ip
=
"{}/{}"
.
format
(
address
,
prefix
)
ip
=
"{}/{}"
.
format
(
address
,
prefix
)
self
.
ips
.
append
(
address
)
self
.
ips
.
append
(
address
)
self
.
net
.
run
([
'ip'
,
'addr'
,
'add'
,
ip
,
'dev'
,
self
.
name
])
self
.
net
.
run
([
'ip'
,
'addr'
,
'add'
,
ip
,
'dev'
,
self
.
name
,
"brd"
,
"+"
])
class
Netns
(
object
):
class
Netns
(
object
):
...
@@ -65,6 +65,7 @@ class Netns(object):
...
@@ -65,6 +65,7 @@ class Netns(object):
self
.
run
([
'sysctl'
,
'-w'
,
'net.ipv4.ip_forward=1'
],
stdout
=
PIPE
)
self
.
run
([
'sysctl'
,
'-w'
,
'net.ipv4.ip_forward=1'
],
stdout
=
PIPE
)
self
.
run
([
'sysctl'
,
'-w'
,
'net.ipv6.conf.default.forwarding=1'
],
self
.
run
([
'sysctl'
,
'-w'
,
'net.ipv6.conf.default.forwarding=1'
],
stdout
=
PIPE
)
stdout
=
PIPE
)
self
.
run
([
'sysctl'
,
'-q'
,
'net.ipv4.icmp_echo_ignore_broadcasts=0'
])
def
Popen
(
self
,
cmd
,
**
kw
):
def
Popen
(
self
,
cmd
,
**
kw
):
""" wrapper for subprocess.Popen"""
""" wrapper for subprocess.Popen"""
...
@@ -285,7 +286,8 @@ def net_demo():
...
@@ -285,7 +286,8 @@ def net_demo():
dev
.
add_ip4
(
str
(
ip
),
24
)
dev
.
add_ip4
(
str
(
ip
),
24
)
ip
+=
1
ip
+=
1
for
node
in
[
node1
,
node2
]:
for
node
in
[
node1
,
node2
]:
node
.
add_route
(
"10.0.0.0/8"
,
'via'
,
"10.1.1.1"
)
# fix, upnp will use 239.255.255.250, use default instead 10.0.0.0
node
.
add_route
(
"default"
,
'via'
,
"10.1.1.1"
)
gateway1
.
run
([
IPTABLES
,
'-t'
,
'nat'
,
'-A'
,
'POSTROUTING'
,
'-o'
,
veth_g1_1
.
name
,
'-j'
,
'MASQUERADE'
])
gateway1
.
run
([
IPTABLES
,
'-t'
,
'nat'
,
'-A'
,
'POSTROUTING'
,
'-o'
,
veth_g1_1
.
name
,
'-j'
,
'MASQUERADE'
])
gateway1
.
run
([
IPTABLES
,
'-t'
,
'nat'
,
'-N'
,
'MINIUPNPD'
])
gateway1
.
run
([
IPTABLES
,
'-t'
,
'nat'
,
'-N'
,
'MINIUPNPD'
])
...
@@ -315,18 +317,18 @@ def net_demo():
...
@@ -315,18 +317,18 @@ def net_demo():
# internet.add_route("10.1.0.0/16", 'via', "10.1.0.2")
# internet.add_route("10.1.0.0/16", 'via', "10.1.0.2")
internet
.
add_route
(
"10.2.0.0/16"
,
'via'
,
"10.2.0.2"
)
internet
.
add_route
(
"10.2.0.0/16"
,
'via'
,
"10.2.0.2"
)
# print gateway1.devices[-1].name, veth_g1_1.name
gateway1
.
proc
=
gateway1
.
Popen
([
'miniupnpd'
,
'-d'
,
'-f'
,
'miniupnpd.conf'
,
'-P'
,
'miniupnpd.pid'
,
gateway1
.
proc
=
gateway1
.
Popen
([
'miniupnpd'
,
'-d'
,
'-f'
,
'miniupnpd.conf'
,
'-P'
,
'miniupnpd.pid'
,
'-a'
,
gateway1
.
devices
[
-
1
].
name
,
'-i'
,
gateway1
.
devices
[
-
1
]
.
name
],
'-a'
,
gateway1
.
devices
[
-
1
].
name
,
'-i'
,
veth_g1_1
.
name
],
stdout
=
PIPE
,
stderr
=
PIPE
)
stderr
=
PIPE
)
nm
.
object
+=
[
internet
,
gateway1
,
gateway2
,
router1
,
router2
,
router3
]
nm
.
object
+=
[
internet
,
gateway1
,
gateway2
,
router1
,
router2
,
router3
]
nm
.
registrys
[
registry
]
=
[
node1
,
node2
,
node3
,
node4
,
node5
,
node6
,
node7
,
node8
]
nm
.
registrys
[
registry
]
=
[
node1
,
node2
,
node3
,
node4
,
node5
,
node6
,
node7
,
node8
]
connectible_test
(
nm
)
connectible_test
(
nm
)
return
nm
return
nm
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
net_demo
()
a
=
net_demo
()
time
.
sleep
(
1000000
)
print
(
"good bye!"
)
print
(
"good bye!"
)
re6st/tests/test_network/test_net.py
View file @
f01d94c7
...
@@ -28,7 +28,10 @@ def deploy_re6st(nm, recreate=False):
...
@@ -28,7 +28,10 @@ def deploy_re6st(nm, recreate=False):
nodes
.
append
(
reg_node
)
nodes
.
append
(
reg_node
)
for
m
in
net
[
registry
]:
for
m
in
net
[
registry
]:
node
=
re6st_wrap
.
Re6stNode
(
m
,
reg
)
node
=
re6st_wrap
.
Re6stNode
(
m
,
reg
)
node
.
run
(
"-i"
+
m
.
out
.
name
)
if
node
.
name
in
[
"node_1"
]:
node
.
run
(
"-I"
+
m
.
out
.
name
)
else
:
node
.
run
(
"-i"
,
m
.
out
.
name
)
nodes
.
append
(
node
)
nodes
.
append
(
node
)
return
nodes
,
registrys
return
nodes
,
registrys
...
@@ -167,7 +170,7 @@ class TestNet(unittest.TestCase):
...
@@ -167,7 +170,7 @@ class TestNet(unittest.TestCase):
time
.
sleep
(
5
)
time
.
sleep
(
5
)
machine
.
run
(
"-i"
+
machine
.
node
.
out
.
name
)
machine
.
run
(
"-i"
+
machine
.
node
.
out
.
name
)
self
.
assertTrue
(
wait_stable
(
nodes
,
1
0
0
),
"network can't recover"
)
self
.
assertTrue
(
wait_stable
(
nodes
,
1
2
0
),
"network can't recover"
)
@
unittest
.
skip
(
"re6st dont use hmac now"
)
@
unittest
.
skip
(
"re6st dont use hmac now"
)
def
test_hmac
(
self
):
def
test_hmac
(
self
):
...
...
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