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