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
2fc5e46f
Commit
2fc5e46f
authored
11 years ago
by
moijes12
Browse files
Options
Downloads
Patches
Plain Diff
Update test_switchdpidassignment.py
parent
09b06509
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
+46
-13
46 additions, 13 deletions
mininet/test/test_switchdpidassignment.py
with
46 additions
and
13 deletions
mininet/test/test_switchdpidassignment.py
+
46
−
13
View file @
2fc5e46f
...
...
@@ -4,37 +4,40 @@
Regression tests for switch dpid assignment.
"""
import
unittest
from
functools
import
partial
import
re
from
mininet.net
import
Mininet
from
mininet.node
import
Switch
from
mininet.node
import
Host
,
Controller
from
mininet.node
import
UserSwitch
,
OVSSwitch
,
OVSLegacyKernelSwitch
,
IVSSwitch
from
mininet.topo
import
Topo
from
mininet.log
import
setLogLevel
from
mininet.util
import
quietRun
class
testSwitchDpidAssignment
(
unittest
.
TestCase
):
class
testSwitchDpidAssignmentCommon
(
object
):
"""
Verify Switch dpid assignment.
"""
switchClass
=
None
# overridden in subclasses
def
testDefaultDpid
(
self
):
"""
Verify that the default dpid is assigned using a valid provided
canonical switchname if no dpid is passed in switch creation.
"""
mn
=
Mininet
(
Topo
()
)
switch
=
mn
.
addSwitch
(
'
s1
'
)
switch
=
Mininet
(
Topo
(),
self
.
switchClass
,
Host
,
Controller
).
addSwitch
(
'
s1
'
)
self
.
assertEqual
(
switch
.
defaultDpid
(),
switch
.
dpid
)
def
testActualDpidAssignment
(
self
):
"""
Verify that Switch dpid is the actual dpid assigned if dpid is
passed in switch creation.
"""
mn
=
Mininet
(
Topo
()
)
switch
=
mn
.
addSwitch
(
'
A
'
,
dpid
=
'
000000000000ABCD
'
)
switch
=
Mininet
(
Topo
(),
self
.
switchClass
,
Host
,
Controller
).
addSwitch
(
'
A
'
,
dpid
=
'
000000000000ABCD
'
)
self
.
assertEqual
(
switch
.
dpid
,
'
000000000000ABCD
'
)
def
testDefaultDpidAssignmentFailure
(
self
):
"""
Verify that Default dpid assignment raises an Exception if the
name of the switch does not contin a digit. Also verify the
exception message.
"""
mn
=
Mininet
(
Topo
()
)
with
self
.
assertRaises
(
Exception
)
as
raises_cm
:
switch
=
mn
.
addSwitch
(
'
A
'
)
switch
=
Mininet
(
Topo
(),
self
.
switchClass
,
Host
,
Controller
)
.
addSwitch
(
'
A
'
)
self
.
assertEqual
(
raises_cm
.
exception
.
message
,
'
Unable to derive
'
'
default datapath ID - please either specify a dpid
'
'
or use a canonical switch name such as s23.
'
)
...
...
@@ -44,11 +47,41 @@ def testDefaultDpidLen( self ):
16 - len(hex of first string of contiguous digits passed in switch
name) 0
'
s followed by hex of first string of contiguous digits passed
in switch name.
"""
mn
=
Mininet
(
Topo
()
)
switch
=
mn
.
addSwitch
(
'
s123
'
)
dpid
=
int
(
re
.
findall
(
r
'
\d+
'
,
switch
.
name
)
[
0
])
dpid
=
hex
(
dpid
)
[
2
:
]
self
.
assertEqual
(
switch
.
dpid
,
'
0
'
*
(
16
-
len
(
dpid
))
+
str
(
dpid
)
)
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
'
)
@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.
"""
switchClass
=
OVSLegacyKernelSwitch
@unittest.skipUnless
(
quietRun
(
'
which ivs-ctl
'
),
'
IVS switch is not installed
'
)
class
testSwitchIVS
(
testSwitchDpidAssignmentCommon
,
unittest
.
TestCase
):
"""
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.
"""
switchClass
=
UserSwitch
if
__name__
==
'
__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