blob: a90f048f52edb72d7ed1a0394e308b4a8a0b8ce8 [file] [log] [blame]
Thangavelu K S7d5077f2016-12-09 22:33:15 +00001#
2# Copyright 2016-present Ciena Corporation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16import unittest
17import time
18import os
19import subprocess
20from nose.tools import *
21from onosclidriver import OnosCliDriver
22from CordContainer import *
23from nose.twistedtools import reactor, deferred
24from twisted.internet import defer
25from OnosCtrl import OnosCtrl
26from scapy.all import *
27log.setLevel('INFO')
28
29class iperf_exchange(unittest.TestCase):
30
31 switch_script = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../setup', 'of-bridge.sh')
32 switch = 'br-int'
33 ctlr_ip = os.getenv('ONOS_CONTROLLER_IP', 'localhost')
34 ctlr_port = '6653'
35 IPERF_TIMEOUT = 360
36 app = 'org.onosproject.dhcp'
37
38 @classmethod
39 def setUpClass(cls):
40 #cls.stop_switch()
41 #cls.install_app()
42 cmd = "apt-get install iperf"
43 os.system(cmd)
44 time.sleep(40)
45
46 @classmethod
47 def tearDownClass(cls):pass
48 #cls.onos_ctrl.deactivate()
49
50 @classmethod
51 def install_app(cls):
52 OnosCtrl.uninstall_app(cls.igmp_app)
53 time.sleep(2)
54 OnosCtrl.install_app(cls.igmp_app_file)
55 time.sleep(3)
56
57 def cliEnter(self):
58 retries = 0
59 while retries < 3:
60 self.cli = OnosCliDriver(connect = True)
61 if self.cli.handle:
62 break
63 else:
64 retries += 1
65 time.sleep(2)
66
67 def cliExit(self):
68 self.cli.disconnect()
69
70 @classmethod
71 def iperf_tool_cmd_execution(cls,cmd = " "):
72 log.info('Test Controller by executing a iperf tool command on host = {}'.format(cmd))
73
74 try:
75# status = os.system(cmd)
76 status = subprocess.Popen(cmd, shell=True)
77 time.sleep(90)
78 pid = status.pid
79 log.info('Subprocess status = {}'.format(status))
80 log.info('Subprocess task id on host = {}'.format(pid))
81 status.terminate()
82 except Exception:
83 status.terminate()
84 main.log.exception( self.name + ": Uncaught exception!" )
85 main.cleanup()
86 main.exit()
87
88 @deferred(IPERF_TIMEOUT)
89 def test_tcp_using_iperf(self):
90 df = defer.Deferred()
91 def iperf_network_test(df):
92 cmd = 'iperf -c 172.17.0.2 -p 6653 -t 20 -P 1 -i 1'
93 log.info('Test Controller by executing a iperf tool command on host = {}'.format(cmd))
94 os.system(cmd)
95 self.onos_ctrl = OnosCtrl(self.app)
96 status, _ = self.onos_ctrl.activate()
97 assert_equal(status, True)
98 df.callback(0)
99 reactor.callLater(0, iperf_network_test, df)
100 return df
101
102 @deferred(IPERF_TIMEOUT)
103 def test_udp_using_iperf(self):
104 df = defer.Deferred()
105 def iperf_network_test(df):
106 cmd = 'iperf -c 172.17.0.2 -p 6653 -u -t 20 -P 1 -i 1'
107 log.info('Test Controller by executing a iperf tool command on host = {}'.format(cmd))
108 status = os.system(cmd)
109 self.onos_ctrl = OnosCtrl(self.app)
110 df.callback(0)
111 reactor.callLater(0, iperf_network_test, df)
112 return df
113
114 @deferred(IPERF_TIMEOUT)
115 def test_tcp_window_of_40k_using_iperf(self):
116 df = defer.Deferred()
117 def iperf_network_test(df):
118 cmd = 'iperf -c 172.17.0.2 -p 6653 -t 20 -P 1 -i 1 -w 40k'
119 log.info('Test Controller by executing a iperf tool command on host = {}'.format(cmd))
120 status = os.system(cmd)
121 df.callback(0)
122 reactor.callLater(0, iperf_network_test, df)
123 return df
124
125
126 @deferred(IPERF_TIMEOUT)
127 def test_tcp_window_of_120k_using_iperf(self):
128 df = defer.Deferred()
129 def iperf_network_test(df):
130 cmd = 'iperf -c 172.17.0.2 -p 6653 -t 20 -P 1 -i 1 -w 120k'
131 log.info('Test Controller by executing a iperf tool command on host = {}'.format(cmd))
132 status = os.system(cmd)
133 df.callback(0)
134 reactor.callLater(0, iperf_network_test, df)
135 return df
136
137
138 @deferred(IPERF_TIMEOUT)
139 def test_tcp_window_of_520k_using_iperf(self):
140 df = defer.Deferred()
141 def iperf_network_test(df):
142 cmd = 'iperf -c 172.17.0.2 -p 6653 -t 20 -P 1 -i 1 -w 520k'
143 log.info('Test Controller by executing a iperf tool command on host = {}'.format(cmd))
144 status = os.system(cmd)
145 df.callback(0)
146 reactor.callLater(0, iperf_network_test, df)
147 return df
148
149 @deferred(IPERF_TIMEOUT)
150 def test_multiple_tcp_sessions_using_iperf(self):
151 df = defer.Deferred()
152 def iperf_network_test(df):
153 cmd = 'iperf -c 172.17.0.2 -p 6653 -t 5 -P 2 -i 1'
154 self.iperf_tool_cmd_execution(cmd = cmd)
155 df.callback(0)
156 reactor.callLater(0, iperf_network_test, df)
157 return df
158
159 @deferred(IPERF_TIMEOUT)
160 def test_multiple_udp_sessions_using_iperf(self):
161 df = defer.Deferred()
162 def iperf_network_test(df):
163 cmd = 'iperf -c 172.17.0.2 -p 6653 -u -t 5 -P 2 -i 1'
164 log.info('Test Controller by executing a iperf tool command on host = {}'.format(cmd))
165 status = os.system(cmd)
166 df.callback(0)
167 reactor.callLater(0, iperf_network_test, df)
168 return df
169
170
171 @deferred(IPERF_TIMEOUT)
172 def test_tcp_mss_with_90Bytes_using_iperf(self):
173 df = defer.Deferred()
174 def iperf_network_test(df):
175 cmd = 'iperf -c 172.17.0.2 -p 6653 -t 20 -P 1 -i 1 -m -M 90'
176 log.info('Test Controller by executing a iperf tool command on host = {}'.format(cmd))
177 status = os.system(cmd)
178 df.callback(0)
179 reactor.callLater(0, iperf_network_test, df)
180 return df
181
182 @deferred(IPERF_TIMEOUT)
183 def test_tcp_mss_with_1490Bytes_using_iperf(self):
184 df = defer.Deferred()
185 def iperf_network_test(df):
186 cmd = 'iperf -c 172.17.0.2 -p 6653 -t 20 -P 1 -i 1 -m -M 1490'
187 log.info('Test Controller by executing a iperf tool command on host = {}'.format(cmd))
188 status = os.system(cmd)
189 df.callback(0)
190 reactor.callLater(0, iperf_network_test, df)
191 return df
192
193 @deferred(IPERF_TIMEOUT)
194 def test_tcp_mss_with_9000Bytes_for_max_throughput_using_iperf(self):
195 df = defer.Deferred()
196 def iperf_network_test(df):
197 cmd = 'iperf -c 172.17.0.2 -p 6653 -t 20 -P 1 -i 1 -m -M 9000'
198 log.info('Test Controller by executing a iperf tool command on host = {}'.format(cmd))
199 status = os.system(cmd)
200 df.callback(0)
201 reactor.callLater(0, iperf_network_test, df)
202 return df
203