fb0ffdfc43b4ffca6b9a7c9a942214f24987450d
[openstack-build/neutron-build.git] / neutron / tests / unit / plugins / ml2 / drivers / test_type_geneve.py
1 # Copyright (c) 2015 OpenStack Foundation
2 # All Rights Reserved.
3 #
4 #    Licensed under the Apache License, Version 2.0 (the "License"); you may
5 #    not use this file except in compliance with the License. You may obtain
6 #    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, WITHOUT
12 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 #    License for the specific language governing permissions and limitations
14 #    under the License.
15
16 from neutron.plugins.common import constants as p_const
17 from neutron.plugins.ml2.drivers import type_geneve
18 from neutron.tests.unit.plugins.ml2.drivers import base_type_tunnel
19 from neutron.tests.unit.plugins.ml2 import test_rpc
20 from neutron.tests.unit import testlib_api
21
22
23 TUNNEL_IP_ONE = "10.10.10.77"
24 TUNNEL_IP_TWO = "10.10.10.78"
25 HOST_ONE = 'fake_host_one1'
26 HOST_TWO = 'fake_host_two2'
27
28
29 class GeneveTypeTest(base_type_tunnel.TunnelTypeTestMixin,
30                      testlib_api.SqlTestCase):
31     DRIVER_CLASS = type_geneve.GeneveTypeDriver
32     TYPE = p_const.TYPE_GENEVE
33
34     def test_get_endpoints(self):
35         self.driver.add_endpoint(TUNNEL_IP_ONE, HOST_ONE)
36         self.driver.add_endpoint(TUNNEL_IP_TWO, HOST_TWO)
37
38         endpoints = self.driver.get_endpoints()
39         for endpoint in endpoints:
40             if endpoint['ip_address'] == TUNNEL_IP_ONE:
41                 self.assertEqual(HOST_ONE, endpoint['host'])
42             elif endpoint['ip_address'] == TUNNEL_IP_TWO:
43                 self.assertEqual(HOST_TWO, endpoint['host'])
44
45
46 class GeneveTypeMultiRangeTest(base_type_tunnel.TunnelTypeMultiRangeTestMixin,
47                                testlib_api.SqlTestCase):
48     DRIVER_CLASS = type_geneve.GeneveTypeDriver
49
50
51 class GeneveTypeRpcCallbackTest(base_type_tunnel.TunnelRpcCallbackTestMixin,
52                                 test_rpc.RpcCallbacksTestCase,
53                                 testlib_api.SqlTestCase):
54     DRIVER_CLASS = type_geneve.GeneveTypeDriver
55     TYPE = p_const.TYPE_GENEVE