~corey.bryant/ubuntu/trusty/neutron/lp1318721

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Corey Bryant
  • Date: 2014-10-06 09:15:06 UTC
  • mfrom: (28.1.4 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20141006091506-cesvev43moce4y74
Tags: 1:2014.1.3-0ubuntu1
[ Corey Bryant ]
* Resynchronize with stable/icehouse (4a0210e) (LP: #1377136):
  - [3a30d19] Deletes floating ip related connection states
  - [dd4b77f] Forbid regular users to reset admin-only attrs to default values
  - [dc2c893] Add delete operations for the ODL MechanismDriver
  - [b51e2c7] Add missing ml2 plugin to migration 1fcfc149aca4
  - [a17a500] Don't convert numeric protocol values to int
  - [3a85946] NSX: Optionally not enforce nat rule match length check
  - [645f984] Don't spawn metadata-proxy for non-isolated nets
  - [b464d89] Big Switch: Check for 'id' in port before lookup
  - [3116ffa] use TRUE in SQL for boolean var
  - [3520e66] call security_groups_member_updated in port_update
  - [50e1534] Don't allow user to set firewall rule with port and no protocol
  - [0061533] BSN: Add context to backend request for debugging
  - [6de6d61] Improve ODL ML2 Exception Handling
  - [2a4153d] Send network name and uuid to subnet create
  - [b5e3c9a] BSN: Allow concurrent reads to consistency DB
  - [b201432] Big Switch: Retry on 503 errors from backend
  - [f6c47ee] NSX: log request body to NSX as debug
  - [97d622a] Fix metadata agent's auth info caching
  - [255df45] NSX: Correct allowed_address_pair return value on create_port
  - [5bea041] Neutron should not use the neutronclient utils module for import_class
  - [d5314e2] Cisco N1kv plugin to send subtype on network profile creation
  - [f32d1ce] Pass object to policy when finding fields to strip
  - [8b5f6be] Call policy.init() once per API request
  - [9a6d811] Perform policy checks only once on list responses
  - [c48db90] Datacenter moid should not be tuple
  - [161d465] Allow unsharing a network used as gateway/floatingip
  - [9574a2f] Add support for router scheduling in Cisco N1kv Plugin
  - [6f54565] Fix func job hook script permission problems
  - [ea43103] Add hook scripts for the functional infra job
  - [8161cb7] Fixes Hyper-V agent issue on Hyper-V 2008 R2
  - [8e99cfd] Fixes Hyper-V issue due to ML2 RPC versioning
  - [69f9121] Ensure ip6tables are used only if ipv6 is enabled in kernel
  - [399b809] Remove explicit dependency on amqplib
  - [a872143] Clear entries in Cisco N1KV specific tables on rollback
  - [ad82fad] Verify ML2 type driver exists before calling del
  - [af2cc98] Big Switch: Only update hash header on success
  - [b1e5eec] Ignore variable column widths in ovsdb functional tests
  - [4a0210e] VMWare: don't notify on disassociate_floatingips()

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 
16
16
from oslo.config import cfg
17
17
 
 
18
from neutron import context
18
19
from neutron.extensions import portbindings
 
20
from neutron.extensions import securitygroup as ext_sg
 
21
from neutron.plugins.openvswitch import ovs_neutron_plugin
19
22
from neutron.tests.unit import _test_extension_portbindings as test_bindings
20
23
from neutron.tests.unit import test_db_plugin as test_plugin
21
24
from neutron.tests.unit import test_extension_allowedaddresspairs as test_pair
22
25
from neutron.tests.unit import test_security_groups_rpc as test_sg_rpc
23
26
 
 
27
import mock
 
28
 
24
29
 
25
30
class OpenvswitchPluginV2TestCase(test_plugin.NeutronDbPluginV2TestCase):
26
31
 
86
91
class TestOpenvswitchAllowedAddressPairs(OpenvswitchPluginV2TestCase,
87
92
                                         test_pair.TestAllowedAddressPairs):
88
93
    pass
 
94
 
 
95
 
 
96
class TestOpenvswitchUpdatePort(OpenvswitchPluginV2TestCase,
 
97
                                ovs_neutron_plugin.OVSNeutronPluginV2):
 
98
 
 
99
    def test_update_port_add_remove_security_group(self):
 
100
        get_port_func = (
 
101
            'neutron.db.db_base_plugin_v2.'
 
102
            'NeutronDbPluginV2.get_port'
 
103
        )
 
104
        with mock.patch(get_port_func) as mock_get_port:
 
105
            mock_get_port.return_value = {
 
106
                ext_sg.SECURITYGROUPS: ["sg1", "sg2"],
 
107
                "admin_state_up": True,
 
108
                "fixed_ips": "fake_ip",
 
109
                "network_id": "fake_id"}
 
110
 
 
111
            update_port_func = (
 
112
                'neutron.db.db_base_plugin_v2.'
 
113
                'NeutronDbPluginV2.update_port'
 
114
            )
 
115
            with mock.patch(update_port_func) as mock_update_port:
 
116
                mock_update_port.return_value = {
 
117
                    ext_sg.SECURITYGROUPS: ["sg2", "sg3"],
 
118
                    "admin_state_up": True,
 
119
                    "fixed_ips": "fake_ip",
 
120
                    "network_id": "fake_id"}
 
121
 
 
122
                fake_func = (
 
123
                    'neutron.plugins.openvswitch.'
 
124
                    'ovs_db_v2.get_network_binding'
 
125
                )
 
126
                with mock.patch(fake_func) as mock_func:
 
127
                    class MockBinding:
 
128
                        network_type = "fake"
 
129
                        segmentation_id = "fake"
 
130
                        physical_network = "fake"
 
131
 
 
132
                    mock_func.return_value = MockBinding()
 
133
 
 
134
                    ctx = context.Context('', 'somebody')
 
135
                    self.update_port(ctx, "id", {
 
136
                        "port": {
 
137
                            ext_sg.SECURITYGROUPS: [
 
138
                                "sg2", "sg3"]}})
 
139
 
 
140
                    sgmu = self.notifier.security_groups_member_updated
 
141
                    sgmu.assert_called_with(ctx, set(['sg1', 'sg3']))
 
142
 
 
143
    def setUp(self):
 
144
        super(TestOpenvswitchUpdatePort, self).setUp()
 
145
        self.update_security_group_on_port = mock.MagicMock(return_value=True)
 
146
        self._process_portbindings_create_and_update = mock.MagicMock(
 
147
            return_value=True)
 
148
        self._update_extra_dhcp_opts_on_port = mock.MagicMock(
 
149
            return_value=True)
 
150
        self.update_address_pairs_on_port = mock.MagicMock(
 
151
            return_value=True)
 
152
 
 
153
        class MockNotifier:
 
154
            def __init__(self):
 
155
                self.port_update = mock.MagicMock(return_value=True)
 
156
                self.security_groups_member_updated = mock.MagicMock(
 
157
                    return_value=True)
 
158
 
 
159
        self.notifier = MockNotifier()