neutron/neutron/tests/unit/agent/l3/test_fip_rule_priority_allocator.py
Adolfo Duarte de81ab8385 Preserve DVR FIP rule priority over Agent restarts
IP rule priorities assigned to DVR floating IPs need
to be preserved over L3 agent restarts. Reuse
the ItemAllocator class decomposed from Link Local IP
address allocation.  Also move commn unit tests to
ItemAllocator class.

Closes-Bug: #1414779
Change-Id: I6a75aa8ad612ee80b391f0a27a8a7e29519c3f8d
Co-Authored-By: Rajeev Grover <rajeev.grover@hp.com>
Co-Authored-By: Ryan Moats <rmoats@us.ibm.com>
2015-08-12 15:52:19 -05:00

62 lines
2.3 KiB
Python

# Copyright 2014 Hewlett-Packard Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from neutron.agent.l3 import fip_rule_priority_allocator as frpa
from neutron.tests import base
class TestFipPriority(base.BaseTestCase):
def setUp(self):
super(TestFipPriority, self).setUp()
def test__init__(self):
test_pr = frpa.FipPriority(10)
self.assertEqual(10, test_pr.index)
def test__repr__(self):
test_pr = frpa.FipPriority(20)
self.assertEqual("20", str(test_pr))
def test__eq__(self):
left_pr = frpa.FipPriority(10)
right_pr = frpa.FipPriority(10)
other_pr = frpa.FipPriority(20)
self.assertEqual(left_pr, right_pr)
self.assertNotEqual(left_pr, other_pr)
self.assertNotEqual(right_pr, other_pr)
def test__hash__(self):
left_pr = frpa.FipPriority(10)
right_pr = frpa.FipPriority(10)
other_pr = frpa.FipPriority(20)
self.assertEqual(hash(left_pr), hash(right_pr))
self.assertNotEqual(hash(left_pr), hash(other_pr))
self.assertNotEqual(hash(other_pr), hash(right_pr))
class TestFipRulePriorityAllocator(base.BaseTestCase):
def setUp(self):
super(TestFipRulePriorityAllocator, self).setUp()
self.priority_rule_start = 100
self.priority_rule_end = 200
self.data_store_path = '/data_store_path_test'
def test__init__(self):
_frpa = frpa.FipRulePriorityAllocator(self.data_store_path,
self.priority_rule_start,
self.priority_rule_end)
self.assertEqual(self.data_store_path, _frpa.state_file)
self.assertEqual(frpa.FipPriority, _frpa.ItemClass)
self.assertEqual(100, len(_frpa.pool))