blob: d6bc73745511e9fea4c20d259f92f6b186878087 [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
A R Karthick76a497a2017-04-12 10:59:39 -070026from CordTestUtils import log_test as log
27
Thangavelu K S7d5077f2016-12-09 22:33:15 +000028log.setLevel('INFO')
29
30class iperf_exchange(unittest.TestCase):
31
32 switch_script = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../setup', 'of-bridge.sh')
33 switch = 'br-int'
34 ctlr_ip = os.getenv('ONOS_CONTROLLER_IP', 'localhost')
35 ctlr_port = '6653'
36 IPERF_TIMEOUT = 360
37 app = 'org.onosproject.dhcp'
38
39 @classmethod
40 def setUpClass(cls):
41 #cls.stop_switch()
42 #cls.install_app()
43 cmd = "apt-get install iperf"
44 os.system(cmd)
45 time.sleep(40)
46
47 @classmethod
48 def tearDownClass(cls):pass
49 #cls.onos_ctrl.deactivate()
50
51 @classmethod
52 def install_app(cls):
53 OnosCtrl.uninstall_app(cls.igmp_app)
54 time.sleep(2)
55 OnosCtrl.install_app(cls.igmp_app_file)
56 time.sleep(3)
57
58 def cliEnter(self):
59 retries = 0
60 while retries < 3:
61 self.cli = OnosCliDriver(connect = True)
62 if self.cli.handle:
63 break
64 else:
65 retries += 1
66 time.sleep(2)
67
68 def cliExit(self):
69 self.cli.disconnect()
70
71 @classmethod
72 def iperf_tool_cmd_execution(cls,cmd = " "):
73 log.info('Test Controller by executing a iperf tool command on host = {}'.format(cmd))
74
75 try:
76# status = os.system(cmd)
77 status = subprocess.Popen(cmd, shell=True)
78 time.sleep(90)
79 pid = status.pid
80 log.info('Subprocess status = {}'.format(status))
81 log.info('Subprocess task id on host = {}'.format(pid))
82 status.terminate()
83 except Exception:
84 status.terminate()
85 main.log.exception( self.name + ": Uncaught exception!" )
86 main.cleanup()
87 main.exit()
88
89 @deferred(IPERF_TIMEOUT)
90 def test_tcp_using_iperf(self):
91 df = defer.Deferred()
92 def iperf_network_test(df):
93 cmd = 'iperf -c 172.17.0.2 -p 6653 -t 20 -P 1 -i 1'
94 log.info('Test Controller by executing a iperf tool command on host = {}'.format(cmd))
95 os.system(cmd)
96 self.onos_ctrl = OnosCtrl(self.app)
97 status, _ = self.onos_ctrl.activate()
98 assert_equal(status, True)
99 df.callback(0)
100 reactor.callLater(0, iperf_network_test, df)
101 return df
102
103 @deferred(IPERF_TIMEOUT)
104 def test_udp_using_iperf(self):
105 df = defer.Deferred()
106 def iperf_network_test(df):
107 cmd = 'iperf -c 172.17.0.2 -p 6653 -u -t 20 -P 1 -i 1'
108 log.info('Test Controller by executing a iperf tool command on host = {}'.format(cmd))
109 status = os.system(cmd)
110 self.onos_ctrl = OnosCtrl(self.app)
111 df.callback(0)
112 reactor.callLater(0, iperf_network_test, df)
113 return df
114
115 @deferred(IPERF_TIMEOUT)
116 def test_tcp_window_of_40k_using_iperf(self):
117 df = defer.Deferred()
118 def iperf_network_test(df):
119 cmd = 'iperf -c 172.17.0.2 -p 6653 -t 20 -P 1 -i 1 -w 40k'
120 log.info('Test Controller by executing a iperf tool command on host = {}'.format(cmd))
121 status = os.system(cmd)
122 df.callback(0)
123 reactor.callLater(0, iperf_network_test, df)
124 return df
125
126
127 @deferred(IPERF_TIMEOUT)
128 def test_tcp_window_of_120k_using_iperf(self):
129 df = defer.Deferred()
130 def iperf_network_test(df):
131 cmd = 'iperf -c 172.17.0.2 -p 6653 -t 20 -P 1 -i 1 -w 120k'
132 log.info('Test Controller by executing a iperf tool command on host = {}'.format(cmd))
133 status = os.system(cmd)
134 df.callback(0)
135 reactor.callLater(0, iperf_network_test, df)
136 return df
137
138
139 @deferred(IPERF_TIMEOUT)
140 def test_tcp_window_of_520k_using_iperf(self):
141 df = defer.Deferred()
142 def iperf_network_test(df):
143 cmd = 'iperf -c 172.17.0.2 -p 6653 -t 20 -P 1 -i 1 -w 520k'
144 log.info('Test Controller by executing a iperf tool command on host = {}'.format(cmd))
145 status = os.system(cmd)
146 df.callback(0)
147 reactor.callLater(0, iperf_network_test, df)
148 return df
149
150 @deferred(IPERF_TIMEOUT)
151 def test_multiple_tcp_sessions_using_iperf(self):
152 df = defer.Deferred()
153 def iperf_network_test(df):
154 cmd = 'iperf -c 172.17.0.2 -p 6653 -t 5 -P 2 -i 1'
155 self.iperf_tool_cmd_execution(cmd = cmd)
156 df.callback(0)
157 reactor.callLater(0, iperf_network_test, df)
158 return df
159
160 @deferred(IPERF_TIMEOUT)
161 def test_multiple_udp_sessions_using_iperf(self):
162 df = defer.Deferred()
163 def iperf_network_test(df):
164 cmd = 'iperf -c 172.17.0.2 -p 6653 -u -t 5 -P 2 -i 1'
165 log.info('Test Controller by executing a iperf tool command on host = {}'.format(cmd))
166 status = os.system(cmd)
167 df.callback(0)
168 reactor.callLater(0, iperf_network_test, df)
169 return df
170
171
172 @deferred(IPERF_TIMEOUT)
173 def test_tcp_mss_with_90Bytes_using_iperf(self):
174 df = defer.Deferred()
175 def iperf_network_test(df):
176 cmd = 'iperf -c 172.17.0.2 -p 6653 -t 20 -P 1 -i 1 -m -M 90'
177 log.info('Test Controller by executing a iperf tool command on host = {}'.format(cmd))
178 status = os.system(cmd)
179 df.callback(0)
180 reactor.callLater(0, iperf_network_test, df)
181 return df
182
183 @deferred(IPERF_TIMEOUT)
184 def test_tcp_mss_with_1490Bytes_using_iperf(self):
185 df = defer.Deferred()
186 def iperf_network_test(df):
187 cmd = 'iperf -c 172.17.0.2 -p 6653 -t 20 -P 1 -i 1 -m -M 1490'
188 log.info('Test Controller by executing a iperf tool command on host = {}'.format(cmd))
189 status = os.system(cmd)
190 df.callback(0)
191 reactor.callLater(0, iperf_network_test, df)
192 return df
193
194 @deferred(IPERF_TIMEOUT)
195 def test_tcp_mss_with_9000Bytes_for_max_throughput_using_iperf(self):
196 df = defer.Deferred()
197 def iperf_network_test(df):
198 cmd = 'iperf -c 172.17.0.2 -p 6653 -t 20 -P 1 -i 1 -m -M 9000'
199 log.info('Test Controller by executing a iperf tool command on host = {}'.format(cmd))
200 status = os.system(cmd)
201 df.callback(0)
202 reactor.callLater(0, iperf_network_test, df)
203 return df