~ubuntu-branches/ubuntu/vivid/neutron/vivid-updates

« back to all changes in this revision

Viewing changes to neutron/tests/unit/openvswitch/test_ovs_tunnel.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2015-03-30 11:17:19 UTC
  • mfrom: (1.1.21)
  • Revision ID: package-import@ubuntu.com-20150330111719-h0gx7233p4jkkgfh
Tags: 1:2015.1~b3-0ubuntu1
* New upstream milestone release:
  - d/control: Align version requirements with upstream.
  - d/control: Add new dependency on oslo-log.
  - d/p/*: Rebase.
  - d/control,d/neutron-plugin-hyperv*: Dropped, decomposed into
    separate project upstream.
  - d/control,d/neutron-plugin-openflow*: Dropped, decomposed into
    separate project upstream.
  - d/neutron-common.install: Add neutron-rootwrap-daemon and 
    neutron-keepalived-state-change binaries.
  - d/rules: Ignore neutron-hyperv-agent when installing; only for Windows.
  - d/neutron-plugin-cisco.install: Drop neutron-cisco-cfg-agent as
    decomposed into separate project upstream.
  - d/neutron-plugin-vmware.install: Drop neutron-check-nsx-config and
    neutron-nsx-manage as decomposed into separate project upstream.
  - d/control: Add dependency on python-neutron-fwaas to neutron-l3-agent.
* d/pydist-overrides: Add overrides for oslo packages.
* d/control: Fixup type in package description (LP: #1263539).
* d/p/fixup-driver-test-execution.patch: Cherry pick fix from upstream VCS
  to support unit test exection in out-of-tree vendor drivers.
* d/neutron-common.postinst: Allow general access to /etc/neutron but limit
  access to root/neutron to /etc/neutron/neutron.conf to support execution
  of unit tests in decomposed vendor drivers.
* d/control: Add dependency on python-neutron-fwaas to neutron-l3-agent
  package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import time
19
19
 
20
20
import mock
21
 
from oslo.config import cfg
 
21
from oslo_config import cfg
 
22
from oslo_log import log
22
23
 
23
24
from neutron.agent.linux import ip_lib
24
25
from neutron.agent.linux import ovs_lib
25
 
from neutron.openstack.common import log
26
26
from neutron.plugins.common import constants as p_const
27
27
from neutron.plugins.openvswitch.agent import ovs_neutron_agent
28
28
from neutron.plugins.openvswitch.common import constants
31
31
 
32
32
# Useful global dummy variables.
33
33
NET_UUID = '3faeebfe-5d37-11e1-a64b-000c29d5f0a7'
34
 
LS_ID = 42
 
34
LS_ID = 420
35
35
LV_ID = 42
36
36
LV_IDS = [42, 43]
37
37
VIF_ID = '404deaec-5d37-11e1-a64b-000c29d5f0a8'
99
99
        }
100
100
 
101
101
        self.mock_bridge = mock.patch.object(ovs_lib, 'OVSBridge').start()
102
 
        self.mock_bridge.side_effect = (lambda br_name, root_helper:
 
102
        self.mock_bridge.side_effect = (lambda br_name:
103
103
                                        self.ovs_bridges[br_name])
104
104
 
105
105
        self.mock_int_bridge = self.ovs_bridges[self.INT_BRIDGE]
139
139
 
140
140
    def _define_expected_calls(self):
141
141
        self.mock_bridge_expected = [
142
 
            mock.call(self.INT_BRIDGE, 'sudo'),
143
 
            mock.call(self.MAP_TUN_BRIDGE, 'sudo'),
144
 
            mock.call(self.TUN_BRIDGE, 'sudo'),
 
142
            mock.call(self.INT_BRIDGE),
 
143
            mock.call(self.MAP_TUN_BRIDGE),
 
144
            mock.call(self.TUN_BRIDGE),
145
145
        ]
146
146
 
147
147
        self.mock_int_bridge = self.ovs_bridges[self.INT_BRIDGE]
186
186
        ]
187
187
 
188
188
        self.mock_tun_bridge_expected = [
189
 
            mock.call.reset_bridge(),
 
189
            mock.call.reset_bridge(secure_mode=True),
190
190
            mock.call.add_patch_port('patch-int', 'patch-tun'),
191
191
        ]
192
192
        self.mock_int_bridge_expected += [
241
241
        self.device_exists_expected = []
242
242
 
243
243
        self.ipdevice_expected = []
244
 
        self.ipwrapper_expected = [mock.call('sudo')]
 
244
        self.ipwrapper_expected = [mock.call()]
245
245
 
246
246
        self.get_bridges_expected = [mock.call(), mock.call()]
247
247
 
254
254
        kwargs.setdefault('tun_br', self.TUN_BRIDGE)
255
255
        kwargs.setdefault('local_ip', '10.0.0.1')
256
256
        kwargs.setdefault('bridge_mappings', self.NET_MAPPING)
257
 
        kwargs.setdefault('root_helper', 'sudo')
258
257
        kwargs.setdefault('polling_interval', 2)
259
258
        kwargs.setdefault('tunnel_types', ['gre'])
260
259
        kwargs.setdefault('veth_mtu', self.VETH_MTU)
367
366
            mock.call.add_flow(priority=4, in_port=self.MAP_TUN_PHY_OFPORT,
368
367
                               dl_vlan=LV_ID, actions=action_string))
369
368
 
370
 
        action_string = 'mod_vlan_vid:%s,normal' % LS_ID
 
369
        action_string = 'mod_vlan_vid:%s,normal' % LV_ID
371
370
        self.mock_int_bridge_expected.append(
372
371
            mock.call.add_flow(priority=3, in_port=self.INT_OFPORT,
373
 
                               dl_vlan=LV_ID, actions=action_string))
 
372
                               dl_vlan=LS_ID, actions=action_string))
374
373
 
375
374
        a = self._build_agent()
376
375
        a.available_local_vlans = set([LV_ID])
424
423
                in_port=self.MAP_TUN_PHY_OFPORT, dl_vlan=LVM_VLAN.vlan))
425
424
        self.mock_int_bridge_expected.append(
426
425
            mock.call.delete_flows(
427
 
                dl_vlan=LV_ID, in_port=self.INT_OFPORT))
 
426
                dl_vlan=LS_ID, in_port=self.INT_OFPORT))
428
427
 
429
428
        a = self._build_agent()
430
429
        a.phys_brs['net1'] = self.mock_map_tun_bridge
515
514
        ]
516
515
 
517
516
        with contextlib.nested(
518
 
            mock.patch.object(log.ContextAdapter, 'exception'),
 
517
            mock.patch.object(log.KeywordArgumentAdapter, 'exception'),
519
518
            mock.patch.object(ovs_neutron_agent.OVSNeutronAgent,
520
519
                              'scan_ports'),
521
520
            mock.patch.object(ovs_neutron_agent.OVSNeutronAgent,
564
563
 
565
564
    def _define_expected_calls(self):
566
565
        self.mock_bridge_expected = [
567
 
            mock.call(self.INT_BRIDGE, 'sudo'),
568
 
            mock.call(self.MAP_TUN_BRIDGE, 'sudo'),
569
 
            mock.call(self.TUN_BRIDGE, 'sudo'),
 
566
            mock.call(self.INT_BRIDGE),
 
567
            mock.call(self.MAP_TUN_BRIDGE),
 
568
            mock.call(self.TUN_BRIDGE),
570
569
        ]
571
570
 
572
571
        self.mock_int_bridge_expected = [
602
601
        ]
603
602
 
604
603
        self.mock_tun_bridge_expected = [
605
 
            mock.call.reset_bridge(),
 
604
            mock.call.reset_bridge(secure_mode=True),
606
605
            mock.call.add_patch_port('patch-int', 'patch-tun'),
607
606
        ]
608
607
        self.mock_int_bridge_expected += [
657
656
        ]
658
657
 
659
658
        self.device_exists_expected = [
660
 
            mock.call('int-%s' % self.MAP_TUN_BRIDGE, 'sudo'),
 
659
            mock.call('int-%s' % self.MAP_TUN_BRIDGE),
661
660
        ]
662
661
 
663
662
        self.ipdevice_expected = [
664
 
            mock.call('int-%s' % self.MAP_TUN_BRIDGE, 'sudo'),
 
663
            mock.call('int-%s' % self.MAP_TUN_BRIDGE),
665
664
            mock.call().link.delete()
666
665
        ]
667
666
        self.ipwrapper_expected = [
668
 
            mock.call('sudo'),
 
667
            mock.call(),
669
668
            mock.call().add_veth('int-%s' % self.MAP_TUN_BRIDGE,
670
669
                                 'phy-%s' % self.MAP_TUN_BRIDGE)
671
670
        ]