Merge "Move SOA refresh interval into unit tests"
This commit is contained in:
commit
3e95c7c723
|
@ -13,10 +13,11 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import copy
|
||||
import functools
|
||||
import os
|
||||
import inspect
|
||||
import os
|
||||
import time
|
||||
|
||||
from testtools import testcase
|
||||
|
|
|
@ -17,8 +17,10 @@
|
|||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
import random
|
||||
import shutil
|
||||
import tempfile
|
||||
from contextlib import contextmanager
|
||||
|
||||
import fixtures
|
||||
from oslo_log import log as logging
|
||||
|
@ -32,6 +34,8 @@ from designate import rpc
|
|||
from designate.network_api import fake as fake_network_api
|
||||
from designate.sqlalchemy import utils as sqlalchemy_utils
|
||||
|
||||
"""Test fixtures
|
||||
"""
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -160,3 +164,13 @@ class ZoneManagerTaskFixture(fixtures.Fixture):
|
|||
super(ZoneManagerTaskFixture, self).setUp()
|
||||
self.task = self._task_cls()
|
||||
self.task.on_partition_change(range(0, 4095), None, None)
|
||||
|
||||
|
||||
@contextmanager
|
||||
def random_seed(seed):
|
||||
"""Context manager to set random.seed() temporarily
|
||||
"""
|
||||
state = random.getstate()
|
||||
random.seed(seed)
|
||||
yield
|
||||
random.setstate(state)
|
||||
|
|
|
@ -517,11 +517,6 @@ class CentralServiceTest(CentralTestCase):
|
|||
with testtools.ExpectedException(exceptions.OverQuota):
|
||||
self.create_zone()
|
||||
|
||||
def test_create_zone_with_refresh_time_dispersion(self):
|
||||
random.seed(42)
|
||||
zone = self.create_zone()
|
||||
self.assertEqual(3563, zone['refresh'])
|
||||
|
||||
def test_create_subzone(self):
|
||||
# Create the Parent Zone using fixture 0
|
||||
parent_zone = self.create_zone(fixture=0)
|
||||
|
|
|
@ -28,6 +28,7 @@ import testtools
|
|||
|
||||
from designate import exceptions
|
||||
from designate.central.service import Service
|
||||
from designate.tests.fixtures import random_seed
|
||||
import designate.central.service
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -516,9 +517,9 @@ class CentralServiceTestCase(CentralBasic):
|
|||
assert parent_zone
|
||||
|
||||
|
||||
class CentralzoneTestCase(CentralBasic):
|
||||
class CentralZoneTestCase(CentralBasic):
|
||||
def setUp(self):
|
||||
super(CentralzoneTestCase, self).setUp()
|
||||
super(CentralZoneTestCase, self).setUp()
|
||||
|
||||
def storage_find_tld(c, d):
|
||||
if d['name'] not in ('org',):
|
||||
|
@ -1838,6 +1839,11 @@ class CentralzoneTestCase(CentralBasic):
|
|||
self.assertEqual(1, invalid[0].managed_tenant_id)
|
||||
self.assertEqual(data['k'], ({'address': 1}, None))
|
||||
|
||||
def test__generate_soa_refresh_interval(self):
|
||||
with random_seed(42):
|
||||
refresh_time = self.service._generate_soa_refresh_interval()
|
||||
self.assertEqual(3563, refresh_time)
|
||||
|
||||
|
||||
class IsSubzoneTestCase(CentralBasic):
|
||||
def setUp(self):
|
||||
|
|
Loading…
Reference in New Issue