Reduces the unit test time of select bigip modules (#36256) (#36260)

The modules in this patch include waits that need to happen to ensure
something is correctly configured on a BIG-IP. These waits were
raised as an issue in a recent ansible-testing meeting.

This patch eliminates the waits by mocking time.sleep
(cherry picked from commit 77fa41795e)
pull/36283/head
John R Barker 7 years ago committed by GitHub
parent 3d81f94349
commit 784932875f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -89,6 +89,11 @@ class TestManager(unittest.TestCase):
def setUp(self): def setUp(self):
self.spec = ArgumentSpec() self.spec = ArgumentSpec()
self.policy = os.path.join(fixture_path, 'fake_policy.xml') self.policy = os.path.join(fixture_path, 'fake_policy.xml')
self.patcher1 = patch('time.sleep')
self.patcher1.start()
def tearDown(self):
self.patcher1.stop()
def test_activate_import_from_file(self, *args): def test_activate_import_from_file(self, *args):
set_module_args(dict( set_module_args(dict(

@ -71,6 +71,11 @@ class TestManager(unittest.TestCase):
def setUp(self): def setUp(self):
self.spec = ArgumentSpec() self.spec = ArgumentSpec()
self.patcher1 = patch('time.sleep')
self.patcher1.start()
def tearDown(self):
self.patcher1.stop()
def test_run_single_command(self, *args): def test_run_single_command(self, *args):
set_module_args(dict( set_module_args(dict(

@ -91,6 +91,11 @@ class TestManager(unittest.TestCase):
def setUp(self): def setUp(self):
self.spec = ArgumentSpec() self.spec = ArgumentSpec()
self.patcher1 = patch('time.sleep')
self.patcher1.start()
def tearDown(self):
self.patcher1.stop()
def test_update_agent_status_traps(self, *args): def test_update_agent_status_traps(self, *args):
set_module_args(dict( set_module_args(dict(

@ -83,6 +83,11 @@ class TestModuleManager(unittest.TestCase):
def setUp(self): def setUp(self):
self.spec = ArgumentSpec() self.spec = ArgumentSpec()
self.patcher1 = patch('time.sleep')
self.patcher1.start()
def tearDown(self):
self.patcher1.stop()
def test_update(self, *args): def test_update(self, *args):
set_module_args( set_module_args(

@ -73,6 +73,11 @@ class TestManager(unittest.TestCase):
def setUp(self): def setUp(self):
self.spec = ArgumentSpec() self.spec = ArgumentSpec()
self.patcher1 = patch('time.sleep')
self.patcher1.start()
def tearDown(self):
self.patcher1.stop()
def test_create_iapp_template(self, *args): def test_create_iapp_template(self, *args):
# Configure the arguments that would be sent to the Ansible module # Configure the arguments that would be sent to the Ansible module

@ -75,6 +75,11 @@ class TestManager(unittest.TestCase):
def setUp(self): def setUp(self):
self.spec = ArgumentSpec() self.spec = ArgumentSpec()
self.patcher1 = patch('time.sleep')
self.patcher1.start()
def tearDown(self):
self.patcher1.stop()
def test_provision_one_module_default_level(self, *args): def test_provision_one_module_default_level(self, *args):
# Configure the arguments that would be sent to the Ansible module # Configure the arguments that would be sent to the Ansible module

@ -112,6 +112,11 @@ class TestV1Manager(unittest.TestCase):
def setUp(self): def setUp(self):
self.spec = ArgumentSpec() self.spec = ArgumentSpec()
self.patcher1 = patch('time.sleep')
self.patcher1.start()
def tearDown(self):
self.patcher1.stop()
def test_ucs_default_present(self, *args): def test_ucs_default_present(self, *args):
set_module_args(dict( set_module_args(dict(

@ -149,6 +149,11 @@ class TestParameters(unittest.TestCase):
class TestManager(unittest.TestCase): class TestManager(unittest.TestCase):
def setUp(self): def setUp(self):
self.spec = ArgumentSpec() self.spec = ArgumentSpec()
self.patcher1 = patch('time.sleep')
self.patcher1.start()
def tearDown(self):
self.patcher1.stop()
def test_create_vlan(self, *args): def test_create_vlan(self, *args):
set_module_args(dict( set_module_args(dict(

@ -93,6 +93,11 @@ class TestParameters(unittest.TestCase):
class TestManager(unittest.TestCase): class TestManager(unittest.TestCase):
def setUp(self): def setUp(self):
self.spec = ArgumentSpec() self.spec = ArgumentSpec()
self.patcher1 = patch('time.sleep')
self.patcher1.start()
def tearDown(self):
self.patcher1.stop()
def test_wait_already_available(self, *args): def test_wait_already_available(self, *args):
set_module_args(dict( set_module_args(dict(
@ -115,4 +120,4 @@ class TestManager(unittest.TestCase):
results = mm.exec_module() results = mm.exec_module()
assert results['changed'] is False assert results['changed'] is False
assert results['elapsed'] == 1 assert results['elapsed'] == 0

@ -88,6 +88,11 @@ class TestManager(unittest.TestCase):
def setUp(self): def setUp(self):
self.spec = ArgumentSpec() self.spec = ArgumentSpec()
self.patcher1 = patch('time.sleep')
self.patcher1.start()
def tearDown(self):
self.patcher1.stop()
def test_create(self, *args): def test_create(self, *args):
set_module_args(dict( set_module_args(dict(

Loading…
Cancel
Save