summaryrefslogtreecommitdiffstats
path: root/vstf/vstf/agent/unittest/env/test_bridge_plugin.py
blob: ac4eb26807a575674c5a8b23f22c5656ff82d16f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""
Created on 2015-10-12

@author: y00228926
"""
import unittest

from vstf.common.utils import check_call
from vstf.agent.unittest.env import model
from vstf.agent.env.vswitch_plugins import bridge_plugin
from vstf.agent.env.driver_plugins import manager


class Test(model.Test):
    def setUp(self):
        super(Test, self).setUp()
        self.plugin = bridge_plugin.BridgePlugin()
        self.dr_mgr = manager.DriverPluginManager()
        self.br_cfg = {
            "name": "br1",
            "uplinks": [
                {
                    "bdf": self.bdf_of_eth[0],
                },
                {
                    "bdf": self.bdf_of_eth[1],
                }
            ]
        }
        self.dr_mgr.clean()
        self.dr_mgr.load(['ixgbe'])

    def tearDown(self):
        super(Test, self).tearDown()

    def _check_br_exists(self, name):
        try:
            check_call('ifconfig %s' % name, shell=True)
        except Exception, e:
            return False
        return True

    def test_create_br(self):
        self.plugin.clean()
        self.plugin.create_br(self.br_cfg)
        self.assertTrue(self._check_br_exists(self.br_cfg['name']))
        self.plugin.clean()
        self.assertFalse(self._check_br_exists(self.br_cfg['name']))


if __name__ == "__main__":
    import logging

    logging.basicConfig(level=logging.INFO)
    LOG = logging.getLogger(__name__)
    unittest.main()