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
fba3fd81
Commit
fba3fd81
authored
11 years ago
by
Brian O'Connor
Browse files
Options
Downloads
Patches
Plain Diff
cleaned up and commented test_controllers.py
parent
e875c0de
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
examples/test/test_controllers.py
+8
-15
8 additions, 15 deletions
examples/test/test_controllers.py
with
8 additions
and
15 deletions
examples/test/test_controllers.py
+
8
−
15
View file @
fba3fd81
#!/usr/bin/env python
"""
TEST
"""
"""
Tests for controllers.py and controllers2.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.examples.simpleperf import SingleSwitchTopo
class
testControllers
(
unittest
.
TestCase
):
"
Test ping with single switch topology (common code).
"
prompt
=
'
mininet>
'
def
connectedTest
(
self
,
name
,
cmap
):
"
Verify that switches are connected to the controller specified by cmap
"
p
=
pexpect
.
spawn
(
'
python -m %s
'
%
name
)
p
.
expect
(
self
.
prompt
)
# but first a simple ping test
p
.
sendline
(
'
pingall
'
)
p
.
expect
(
'
(\d+)% dropped
'
)
percent
=
int
(
p
.
match
.
group
(
1
)
)
if
p
.
match
else
-
1
self
.
assertEqual
(
percent
,
0
)
# or this
self
.
assertEqual
(
percent
,
0
)
p
.
expect
(
self
.
prompt
)
# verify connected controller
for
switch
in
cmap
:
p
.
sendline
(
'
sh ovs-vsctl get-controller %s
'
%
switch
)
p
.
expect
(
'
tcp:([\d.:]+)
'
)
actual
=
p
.
match
.
group
(
1
)
expected
=
cmap
[
switch
]
self
.
assertEqual
(
actual
,
expected
)
self
.
assertEqual
(
actual
,
expected
)
p
.
expect
(
self
.
prompt
)
p
.
sendline
(
'
exit
'
)
p
.
wait
()
#TODO remove this
self
.
assertEqual
(
percent
,
0
)
def
testControllers
(
self
):
c0
=
'
127.0.0.1:6633
'
...
...
@@ -49,7 +44,5 @@ def testControllers2( self ):
cmap
=
{
'
s1
'
:
c0
,
'
s2
'
:
c1
}
self
.
connectedTest
(
'
mininet.examples.controllers2
'
,
cmap
)
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