Fix static driver equality check

A recent refactor of the config objects (which simplified the
repetitive __eq__ methods) missed updating the static driver.  This
could lead to infinite recursion (as the static driver explicitly
called super().__eq__ which itself called __eq__).

This updates the driver to use the new framework, and it also adds
a check to a unit test which exercises it.

Change-Id: I0f443cde147e46d73112025cd2f819159a8b4f86
This commit is contained in:
James E. Blair 2021-06-21 15:24:07 -07:00
parent 80a044e138
commit 36a7df3677
2 changed files with 4 additions and 7 deletions

View File

@ -22,6 +22,8 @@ from nodepool.config import as_list
class StaticPool(ConfigPool):
ignore_equality = ['provider']
def __init__(self):
self.name = None
self.nodes = []
@ -31,13 +33,6 @@ class StaticPool(ConfigPool):
# Initialize base class attributes
super().__init__()
def __eq__(self, other):
if isinstance(other, StaticPool):
return (super().__eq__(other) and
other.name == self.name and
other.nodes == self.nodes)
return False
def __repr__(self):
return "<StaticPool %s>" % self.name

View File

@ -38,6 +38,8 @@ class TestDriverStatic(tests.DBTestCase):
configfile = self.setup_config('static.yaml')
config = nodepool_config.loadConfig(configfile)
self.assertIn('static-provider', config.providers)
config2 = nodepool_config.loadConfig(configfile)
self.assertEqual(config, config2)
def test_static_basic(self):
'''