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
b905dddf
Commit
b905dddf
authored
10 years ago
by
Bob Lantz
Browse files
Options
Downloads
Patches
Plain Diff
Reorganize and pass pylint
parent
11a9c469
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_switchdpidassignment.py
+37
-41
37 additions, 41 deletions
mininet/test/test_switchdpidassignment.py
with
37 additions
and
41 deletions
mininet/test/test_switchdpidassignment.py
100644 → 100755
+
37
−
41
View file @
b905dddf
...
...
@@ -5,8 +5,6 @@
import
unittest
import
sys
from
functools
import
partial
import
re
from
mininet.net
import
Mininet
from
mininet.node
import
Host
,
Controller
...
...
@@ -16,13 +14,16 @@
from
mininet.util
import
quietRun
from
mininet.clean
import
cleanup
class
testSwitchDpidAssignmentCommon
(
object
):
"""
Verify Switch dpid assignment.
"""
switchClass
=
None
# overridden in subclasses
class
TestSwitchDpidAssignmentOVS
(
unittest
.
TestCase
):
"
Verify Switch dpid assignment.
"
switchClass
=
OVSSwitch
# overridden in subclasses
def
tearDown
(
self
):
"
Clean up if necessary
"
# satisfy pylint
assert
self
if
sys
.
exc_info
!=
(
None
,
None
,
None
):
cleanup
()
...
...
@@ -33,12 +34,19 @@ def testDefaultDpid ( self ):
self
.
switchClass
,
Host
,
Controller
).
addSwitch
(
'
s1
'
)
self
.
assertEqual
(
switch
.
defaultDpid
(),
switch
.
dpid
)
def
dpidFrom
(
self
,
num
):
"
Compute default dpid from number
"
fmt
=
(
'
%0
'
+
str
(
self
.
switchClass
.
dpidLen
)
+
'
x
'
)
return
fmt
%
num
def
testActualDpidAssignment
(
self
):
"""
Verify that Switch dpid is the actual dpid assigned if dpid is
passed in switch creation.
"""
dpid
=
self
.
dpidFrom
(
0xABCD
)
switch
=
Mininet
(
Topo
(),
self
.
switchClass
,
Host
,
Controller
).
addSwitch
(
'
A
'
,
dpid
=
'
000000000000ABCD
'
)
self
.
assertEqual
(
switch
.
dpid
,
'
000000000000ABCD
'
)
Host
,
Controller
).
addSwitch
(
'
s1
'
,
dpid
=
dpid
)
self
.
assertEqual
(
switch
.
dpid
,
dpid
)
def
testDefaultDpidAssignmentFailure
(
self
):
"""
Verify that Default dpid assignment raises an Exception if the
...
...
@@ -58,49 +66,37 @@ def testDefaultDpidLen( self ):
in switch name.
"""
switch
=
Mininet
(
Topo
(),
self
.
switchClass
,
Host
,
Controller
).
addSwitch
(
'
s123
'
)
dpid
=
hex
(
int
(
re
.
findall
(
r
'
\d+
'
,
switch
.
name
)
[
0
])
)
[
2
:
]
try
:
if
issubclass
(
UserSwitch
,
self
.
switchClass
):
# Dpid lenght of UserSwitch = 12
self
.
assertEqual
(
switch
.
dpid
,
'
0
'
*
(
12
-
len
(
dpid
))
+
str
(
dpid
)
)
else
:
self
.
assertEqual
(
switch
.
dpid
,
'
0
'
*
(
16
-
len
(
dpid
))
+
str
(
dpid
)
)
except
TypeError
:
# Switch is OVS User Switch
self
.
assertEqual
(
switch
.
dpid
,
'
0
'
*
(
16
-
len
(
dpid
))
+
str
(
dpid
)
)
class
testSwitchOVSKernel
(
testSwitchDpidAssignmentCommon
,
unittest
.
TestCase
):
"""
Test dpid assignnment of OVS Kernel Switch.
"""
switchClass
=
OVSSwitch
class
testSwitchOVSUser
(
testSwitchDpidAssignmentCommon
,
unittest
.
TestCase
):
"""
Test dpid assignnment of OVS User Switch.
"""
switchClass
=
partial
(
OVSSwitch
,
datapath
=
'
user
'
)
self
.
assertEqual
(
switch
.
dpid
,
self
.
dpidFrom
(
123
)
)
class
OVSUser
(
OVSSwitch
):
"
OVS User Switch convenience class
"
def
__init__
(
self
,
*
args
,
**
kwargs
):
kwargs
.
update
(
datapath
=
'
user
'
)
OVSSwitch
.
__init__
(
self
,
*
args
,
**
kwargs
)
class
testSwitchOVSUser
(
TestSwitchDpidAssignmentOVS
):
"
Test dpid assignnment of OVS User Switch.
"
switchClass
=
OVSUser
@unittest.skipUnless
(
quietRun
(
'
which ovs-openflowd
'
),
'
OVS Legacy Kernel switch is not installed
'
)
class
testSwitchOVSLegacyKernel
(
testSwitchDpidAssignmentCommon
,
unittest
.
TestCase
):
"""
Test dpid assignnment of OVS Legacy Kernel Switch.
"""
class
testSwitchOVSLegacyKernel
(
TestSwitchDpidAssignmentOVS
):
"
Test dpid assignnment of OVS Legacy Kernel Switch.
"
switchClass
=
OVSLegacyKernelSwitch
@unittest.skipUnless
(
quietRun
(
'
which ivs-ctl
'
),
'
IVS switch is not installed
'
)
class
testSwitchIVS
(
testSwitchDpidAssignmentCommon
,
unittest
.
TestCase
):
""
"
Test dpid assignment of IVS switch.
"
""
@unittest.skipUnless
(
quietRun
(
'
which ivs-ctl
'
),
'
IVS switch is not installed
'
)
class
testSwitchIVS
(
TestSwitchDpidAssignmentOVS
):
"
Test dpid assignment of IVS switch.
"
switchClass
=
IVSSwitch
@unittest.skipUnless
(
quietRun
(
'
which ofprotocol
'
),
'
Reference user switch is not installed
'
)
class
testSwitchUserspace
(
testSwitchDpidAssignmentCommon
,
unittest
.
TestCase
):
""
"
Test dpid assignment of Userspace switch.
"
""
@unittest.skipUnless
(
quietRun
(
'
which ofprotocol
'
),
'
Reference user switch is not installed
'
)
class
testSwitchUserspace
(
TestSwitchDpidAssignmentOVS
):
"
Test dpid assignment of Userspace switch.
"
switchClass
=
UserSwitch
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