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