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
b2fcab82
Commit
b2fcab82
authored
10 years ago
by
Bob Lantz
Browse files
Options
Downloads
Patches
Plain Diff
Add cleanup and fix pylint errors
parent
1471da95
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mininet/test/test_hifi.py
+18
-7
18 additions, 7 deletions
mininet/test/test_hifi.py
with
18 additions
and
7 deletions
mininet/test/test_hifi.py
+
18
−
7
View file @
b2fcab82
...
...
@@ -4,6 +4,7 @@
Test creation and pings for topologies with link and/or CPU options.
"""
import
unittest
import
sys
from
functools
import
partial
from
mininet.net
import
Mininet
...
...
@@ -13,6 +14,7 @@
from
mininet.topo
import
Topo
from
mininet.log
import
setLogLevel
from
mininet.util
import
quietRun
from
mininet.clean
import
cleanup
# Number of hosts for each test
N
=
2
...
...
@@ -40,6 +42,11 @@ class testOptionsTopoCommon( object ):
switchClass
=
None
# overridden in subclasses
def
tearDown
(
self
):
"
Clean up if necessary
"
if
sys
.
exc_info
!=
(
None
,
None
,
None
):
cleanup
()
def
runOptionsTopoTest
(
self
,
n
,
msg
,
hopts
=
None
,
lopts
=
None
):
"
Generic topology-with-options test runner.
"
mn
=
Mininet
(
topo
=
SingleSwitchOptionsTopo
(
n
=
n
,
hopts
=
hopts
,
...
...
@@ -96,7 +103,8 @@ def testCPULimits( self ):
results
=
mn
.
runCpuLimitTest
(
cpu
=
CPU_FRACTION
)
mn
.
stop
()
hostUsage
=
'
\n
'
.
join
(
'
h%s: %s
'
%
(
n
+
1
,
results
[
(
n
-
1
)
*
5
:
(
n
*
5
)
-
1
]
)
(
n
+
1
,
results
[
(
n
-
1
)
*
5
:
(
n
*
5
)
-
1
]
)
for
n
in
range
(
N
)
)
hoptsStr
=
'
,
'
.
join
(
'
%s: %s
'
%
(
opt
,
value
)
for
opt
,
value
in
hopts
.
items
()
)
...
...
@@ -106,7 +114,8 @@ def testCPULimits( self ):
'
hopts = %s
\n
'
'
host = CPULimitedHost
\n
'
'
Switch = %s
\n
'
%
(
CPU_FRACTION
*
100
,
hostUsage
,
N
,
hoptsStr
,
self
.
switchClass
)
)
%
(
CPU_FRACTION
*
100
,
hostUsage
,
N
,
hoptsStr
,
self
.
switchClass
)
)
for
pct
in
results
:
#divide cpu by 100 to convert from percentage to fraction
self
.
assertWithinTolerance
(
pct
/
100
,
CPU_FRACTION
,
...
...
@@ -115,7 +124,8 @@ def testCPULimits( self ):
def
testLinkBandwidth
(
self
):
"
Verify that link bandwidths are accurate within a bound.
"
if
self
.
switchClass
is
UserSwitch
:
self
.
skipTest
(
'
UserSwitch has very poor performance, so skip for now
'
)
self
.
skipTest
(
'
UserSwitch has very poor performance -
'
'
skipping for now
'
)
BW
=
5
# Mbps
BW_TOLERANCE
=
0.8
# BW fraction below which test should fail
# Verify ability to create limited-link topo first;
...
...
@@ -124,7 +134,7 @@ def testLinkBandwidth( self ):
mn
=
Mininet
(
SingleSwitchOptionsTopo
(
n
=
N
,
lopts
=
lopts
),
link
=
TCLink
,
switch
=
self
.
switchClass
,
waitConnected
=
True
)
bw_strs
=
mn
.
run
(
mn
.
iperf
,
f
orma
t
=
'
m
'
)
bw_strs
=
mn
.
run
(
mn
.
iperf
,
f
m
t
=
'
m
'
)
loptsStr
=
'
,
'
.
join
(
'
%s: %s
'
%
(
opt
,
value
)
for
opt
,
value
in
lopts
.
items
()
)
msg
=
(
'
\n
Testing link bandwidth limited to %d Mbps per link
\n
'
...
...
@@ -160,12 +170,12 @@ def testLinkDelay( self ):
mn
.
stop
()
test_outputs
=
ping_delays
[
0
]
# Ignore unused variables below
# pylint: disable
-msg
=W0612
# pylint: disable=W0612
node
,
dest
,
ping_outputs
=
test_outputs
sent
,
received
,
rttmin
,
rttavg
,
rttmax
,
rttdev
=
ping_outputs
pingFailMsg
=
'
sent %s pings, only received %s
'
%
(
sent
,
received
)
self
.
assertEqual
(
sent
,
received
,
msg
=
pingFailMsg
)
# pylint: enable
-msg
=W0612
# pylint: enable=W0612
loptsStr
=
'
,
'
.
join
(
'
%s: %s
'
%
(
opt
,
value
)
for
opt
,
value
in
lopts
.
items
()
)
msg
=
(
'
\n
Testing Link Delay of %s ms
\n
'
...
...
@@ -212,7 +222,8 @@ def testLinkLoss( self ):
'
lopts = %s
\n
'
'
host = default
\n
'
'
switch = %s
\n
'
%
(
LOSS_PERCENT
,
dropped_total
,
N
,
loptsStr
,
self
.
switchClass
)
)
%
(
LOSS_PERCENT
,
dropped_total
,
N
,
loptsStr
,
self
.
switchClass
)
)
self
.
assertGreater
(
dropped_total
,
0
,
msg
)
...
...
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