Reduce unittest time by changing the default max_attempt

Change-Id: I692405450b3c2faf78d82daf6e51238ee1409ee4
This commit is contained in:
Adit Sarfaty 2019-07-24 14:16:15 +03:00
parent 10c7a84fc6
commit 1d0a68abaa
2 changed files with 7 additions and 3 deletions

View File

@ -216,7 +216,8 @@ class NsxClientTestCase(NsxLibTestCase):
http_timeout=None,
http_read_timeout=None,
conn_idle_timeout=None,
nsx_api_managers=None):
nsx_api_managers=None,
max_attempts=None):
nsxlib_config = config.NsxLibConfig(
username=username or NSX_USER,
@ -229,6 +230,7 @@ class NsxClientTestCase(NsxLibTestCase):
http_timeout=http_timeout or NSX_HTTP_TIMEOUT,
http_read_timeout=http_read_timeout or NSX_HTTP_READ_TIMEOUT,
conn_idle_timeout=conn_idle_timeout or NSX_CONN_IDLE_TIME,
max_attempts=max_attempts or NSX_MAX_ATTEMPTS,
http_provider=NsxClientTestCase.MockHTTPProvider(
session_response=session_response),
nsx_api_managers=nsx_api_managers or [NSX_MANAGER],

View File

@ -308,7 +308,9 @@ class ClusteredAPITestCase(nsxlib_testcase.NsxClientTestCase):
def test_cluster_select_endpoint(self):
conf_managers = ['8.9.10.11', '9.10.11.12', '10.11.12.13']
api = self.mock_nsx_clustered_api(nsx_api_managers=conf_managers)
max_attempts = 3
api = self.mock_nsx_clustered_api(nsx_api_managers=conf_managers,
max_attempts=max_attempts)
api._validate = mock.Mock()
eps = list(api._endpoints.values())
@ -336,7 +338,7 @@ class ClusteredAPITestCase(nsxlib_testcase.NsxClientTestCase):
# simulate the case where 1 endpoint finally goes up
self.validate_count = 0
self.max_validate = 9
self.max_validate = max_attempts - 1
def _mock_validate(ep):
if self.validate_count >= self.max_validate: