Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mininet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Olaf Bergmann
mininet
Commits
b9b1f2e7
Commit
b9b1f2e7
authored
11 years ago
by
Brian O'Connor
Browse files
Options
Downloads
Patches
Plain Diff
cleaned up and commented test_nat.py; added check for connectivity before running test
parent
cdd5210b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/test/test_multitest.py
+1
-1
1 addition, 1 deletion
examples/test/test_multitest.py
examples/test/test_nat.py
+9
-21
9 additions, 21 deletions
examples/test/test_nat.py
with
10 additions
and
22 deletions
examples/test/test_multitest.py
+
1
−
1
View file @
b9b1f2e7
...
...
@@ -15,7 +15,7 @@ def testMultiTest( self ):
"
Verify pingall (0% dropped) and hX-eth0 interface for each host (ifconfig)
"
p
=
pexpect
.
spawn
(
'
python -m mininet.examples.multitest
'
)
p
.
expect
(
'
(\d+)% dropped
'
)
dropped
=
int
(
p
.
match
.
group
(
1
)
)
dropped
=
int
(
p
.
match
.
group
(
1
)
)
self
.
assertEqual
(
dropped
,
0
)
ifCount
=
0
while
True
:
...
...
This diff is collapsed.
Click to expand it.
examples/test/test_nat.py
+
9
−
21
View file @
b9b1f2e7
#!/usr/bin/env python
"""
TEST
"""
"""
Test for nat.py
"""
import
unittest
import
pexpect
#from time import sleep
from
mininet.log
import
setLogLevel
#from mininet.net import Mininet
#from mininet.node import CPULimitedHost
#from mininet.link import TCLink
from
mininet.util
import
quietRun
#from mininet.examples.simpleperf import SingleSwitchTopo
destIP
=
'
8.8.8.8
'
# Google DNS
class
testNAT
(
unittest
.
TestCase
):
"
Test ping with single switch topology (common code).
"
prompt
=
'
mininet>
'
# skip if 8.8.8.8 unreachable
@unittest.skipIf
(
'
0 received
'
in
quietRun
(
'
ping -c 1 %s
'
%
destIP
),
'
Destination IP is not reachable
'
)
def
testNAT
(
self
):
"
Attempt to ping an IP on the Internet and verify 0% packet loss
"
p
=
pexpect
.
spawn
(
'
python -m mininet.examples.nat
'
)
p
.
expect
(
self
.
prompt
)
p
.
sendline
(
'
h1 ping -c 1
8.8.8.8
'
)
p
.
sendline
(
'
h1 ping -c 1
%s
'
%
destIP
)
p
.
expect
(
'
(\d+)% packet loss
'
)
percent
=
int
(
p
.
match
.
group
(
1
)
)
if
p
.
match
else
-
1
p
.
expect
(
self
.
prompt
)
p
.
sendline
(
'
exit
'
)
p
.
wait
()
self
.
assertEqual
(
percent
,
0
)
'''
def testTopo( self ):
topo = SingleSwitchTopo(n=4)
net = Mininet(topo=topo,
host=CPULimitedHost, link=TCLink)
net.start()
h1, h4 = net.get(
'
h1
'
,
'
h4
'
)
h1.cmd(
'
ping -c 1 %s
'
% h4.IP() )
net.stop()
'''
if
__name__
==
'
__main__
'
:
setLogLevel
(
'
warning
'
)
unittest
.
main
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment