Bridge between container framework networking and storage models to OpenStack networking and storage abstractions.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_vlan.py 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  2. # not use this file except in compliance with the License. You may obtain
  3. # a copy of the License at
  4. #
  5. # http://www.apache.org/licenses/LICENSE-2.0
  6. #
  7. # Unless required by applicable law or agreed to in writing, software
  8. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  9. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  10. # License for the specific language governing permissions and limitations
  11. # under the License.
  12. import mock
  13. from oslo_utils import uuidutils
  14. from kuryr.lib.binding.drivers import vlan
  15. from kuryr.lib import constants
  16. from kuryr.lib import utils
  17. from kuryr.tests.unit import base
  18. mock_create = mock.MagicMock()
  19. mock_interface = mock.MagicMock()
  20. class TestVlanDriver(base.TestCase):
  21. """Unit tests for nested vlan driver"""
  22. @mock.patch('kuryr.lib.binding.drivers.utils._configure_container_iface')
  23. @mock.patch('pyroute2.ipdb.interface.InterfacesDict.__getattribute__',
  24. return_value=mock_create)
  25. @mock.patch('pyroute2.ipdb.interface.InterfacesDict.__getitem__',
  26. return_value=mock_interface)
  27. def test_port_bind(self, mock_getitem, mock_getattribute,
  28. mock_configure_container_iface):
  29. fake_segmentation_id = 100
  30. fake_docker_endpoint_id = utils.get_hash()
  31. fake_docker_network_id = utils.get_hash()
  32. fake_port_id = uuidutils.generate_uuid()
  33. fake_neutron_v4_subnet_id = uuidutils.generate_uuid()
  34. fake_neutron_v6_subnet_id = uuidutils.generate_uuid()
  35. fake_vif_details = {"port_filter": True, "ovs_hybrid_plug": False}
  36. fake_vif_type = "ovs"
  37. fake_port = self._get_fake_port(
  38. fake_docker_endpoint_id, fake_docker_network_id,
  39. fake_port_id, constants.PORT_STATUS_ACTIVE,
  40. fake_neutron_v4_subnet_id, fake_neutron_v6_subnet_id,
  41. vif_details=fake_vif_details, vif_type=fake_vif_type)
  42. fake_subnets = self._get_fake_subnets(
  43. fake_docker_endpoint_id, fake_docker_network_id,
  44. fake_neutron_v4_subnet_id, fake_neutron_v6_subnet_id)
  45. vlan.port_bind(fake_docker_endpoint_id,
  46. fake_port['port'],
  47. fake_subnets['subnets'],
  48. fake_segmentation_id)
  49. mock_configure_container_iface.assert_called_once()