1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

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

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
This commit is contained in:
Tim Rupp 2018-02-15 12:14:01 -08:00 committed by John R Barker
parent fed20b825f
commit 77fa41795e
10 changed files with 51 additions and 1 deletions

View file

@ -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(

View file

@ -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(

View file

@ -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(

View file

@ -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(

View file

@ -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

View file

@ -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

View file

@ -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(

View file

@ -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(

View file

@ -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

View file

@ -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(