blob: c7ddd1feb55631036c80b2bd352b43d1d48d2a41 [file] [log] [blame]
Matteo Scandolo48d3d2d2017-08-08 13:05:27 -07001
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
A R Karthickedab01c2016-09-08 14:05:44 -070017#
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#
32import unittest
33import time
34import os
35from nose.tools import *
36from nose.twistedtools import reactor, deferred
37from twisted.internet import defer
38from OnosCtrl import OnosCtrl
A R Karthick76a497a2017-04-12 10:59:39 -070039from CordTestUtils import log_test as log
40
A R Karthickedab01c2016-09-08 14:05:44 -070041log.setLevel('INFO')
42
43class cbench_exchange(unittest.TestCase):
44
45 igmp_app_file = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../apps',
46 'ciena-cordigmp-cbench-1.0-SNAPSHOT.oar')
47 igmp_app_file_default = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../apps',
48 'ciena-cordigmp-2.0-SNAPSHOT.oar')
49 igmp_app = 'org.ciena.cordigmp'
50 switch_script = os.path.join(os.path.dirname(os.path.realpath(__file__)), '../setup', 'of-bridge.sh')
51 switch = 'br-int'
52 ctlr_ip = os.getenv('ONOS_CONTROLLER_IP', 'localhost')
53 ctlr_port = '6653'
54 cbench = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'cbench')
55 cbench_igmp_options = '-g -D 3000 -w 10 -c {} -p {}'.format(ctlr_ip, ctlr_port)
56 CBENCH_TIMEOUT = 60
57
58 @classmethod
59 def setUpClass(cls):
60 cls.stop_switch()
61 cls.install_app()
62
63 @classmethod
64 def tearDownClass(cls):
65 cls.install_app_default()
66 cls.start_switch()
67
68 @classmethod
69 def install_app(cls):
70 OnosCtrl.uninstall_app(cls.igmp_app)
71 time.sleep(2)
72 OnosCtrl.install_app(cls.igmp_app_file)
73 time.sleep(3)
74
75 @classmethod
76 def install_app_default(cls):
77 OnosCtrl.uninstall_app(cls.igmp_app)
78 time.sleep(2)
79 OnosCtrl.install_app(cls.igmp_app_file_default)
80
81 @classmethod
82 def stop_switch(cls):
83 cmd = 'service openvswitch-switch stop'
84 log.info('Stopping switch before running cbench fakeswitch tests')
85 os.system(cmd)
86 time.sleep(1)
87
88 @classmethod
89 def start_switch(cls):
90 cmd = '{} {}'.format(cls.switch_script, cls.switch)
91 log.info('Starting back switch with command: \"%s\"', cmd)
92 os.system(cmd)
93 time.sleep(3)
A R Karthick76a497a2017-04-12 10:59:39 -070094
A R Karthickedab01c2016-09-08 14:05:44 -070095 @deferred(CBENCH_TIMEOUT)
96 def test_cbench_igmp(self):
97 df = defer.Deferred()
98 def cbench_igmp_join_leave_loop(df):
99 cmd = '{} {} -l 20 -s 1 -m 1000'.format(self.cbench, self.cbench_igmp_options)
100 os.system(cmd)
101 df.callback(0)
102 reactor.callLater(0, cbench_igmp_join_leave_loop, df)
103 return df