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)
This commit is contained in:
John R Barker 2018-02-15 20:28:45 +00:00 committed by GitHub
parent 3d81f94349
commit 784932875f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 51 additions and 1 deletions

View file

@ -89,6 +89,11 @@ class TestManager(unittest.TestCase):
def setUp(self):
self.spec = ArgumentSpec()
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):
set_module_args(dict(

View file

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

View file

@ -91,6 +91,11 @@ class TestManager(unittest.TestCase):
def setUp(self):
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):
set_module_args(dict(

View file

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

View file

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

View file

@ -75,6 +75,11 @@ class TestManager(unittest.TestCase):
def setUp(self):
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):
# Configure the arguments that would be sent to the Ansible module

View file

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

View file

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

View file

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

View file

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