mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #6 from Ch3LL/cloud_provider_files
Move provider config setup into Setup/Teardown class
This commit is contained in:
commit
326e9f23dd
1 changed files with 30 additions and 26 deletions
|
@ -14,6 +14,7 @@ from time import sleep
|
|||
from tests.support.case import ShellCase
|
||||
from tests.support.helpers import generate_random_name, expensiveTest
|
||||
from tests.support.paths import FILES
|
||||
from tests.support.runtests import RUNTIME_VARS
|
||||
|
||||
# Import Salt Libs
|
||||
from salt.config import cloud_config, cloud_providers_config
|
||||
|
@ -27,6 +28,7 @@ log = logging.getLogger(__name__)
|
|||
class CloudTest(ShellCase):
|
||||
PROVIDER = ''
|
||||
REQUIRED_PROVIDER_CONFIG_ITEMS = tuple()
|
||||
TMP_PROVIDER_DIR = os.path.join(RUNTIME_VARS.TMP_CONF_DIR, 'cloud.providers.d')
|
||||
__RE_RUN_DELAY = 15
|
||||
__RE_TRIES = 3
|
||||
|
||||
|
@ -177,15 +179,6 @@ class CloudTest(ShellCase):
|
|||
if not self.PROVIDER:
|
||||
self.fail('A PROVIDER must be defined for this test')
|
||||
|
||||
# clean up before setup
|
||||
self.tmp_cloud_provider = os.path.join(self.config_dir, 'cloud.providers.d')
|
||||
self.clean_cloud_dir(self.tmp_cloud_provider)
|
||||
|
||||
# add the provider config for only the cloud we are testing
|
||||
provider_file = self.PROVIDER + '.conf'
|
||||
shutil.copyfile(os.path.join(os.path.join(FILES, 'conf', 'cloud.providers.d'), provider_file),
|
||||
os.path.join(self.tmp_cloud_provider, provider_file))
|
||||
|
||||
# check if appropriate cloud provider and profile files are present
|
||||
if self.profile_str + ':' not in self.providers:
|
||||
self.skipTest(
|
||||
|
@ -212,21 +205,32 @@ class CloudTest(ShellCase):
|
|||
if the tearDown is where an instance is destroyed.
|
||||
'''
|
||||
# Make sure that the instance for sure gets deleted, but fail the test if it happens in the tearDown
|
||||
try:
|
||||
destroyed = False
|
||||
if self._instance_exists():
|
||||
for _ in range(3):
|
||||
sleep(30)
|
||||
success, result_str = self._destroy_instance()
|
||||
if success:
|
||||
self.fail('The instance "{}" was deleted during the tearDown, not the test.'.format(
|
||||
self.instance_name))
|
||||
if not self._instance_exists():
|
||||
destroyed = True
|
||||
break
|
||||
destroyed = False
|
||||
if self._instance_exists():
|
||||
for _ in range(3):
|
||||
sleep(30)
|
||||
success, result_str = self._destroy_instance()
|
||||
if success:
|
||||
self.fail('The instance "{}" was deleted during the tearDown, not the test.'.format(
|
||||
self.instance_name))
|
||||
if not self._instance_exists():
|
||||
destroyed = True
|
||||
break
|
||||
|
||||
if not destroyed:
|
||||
# Destroying instances in the tearDown is a contingency, not the way things should work by default.
|
||||
self.fail('The Instance "{}" was not deleted after multiple attempts'.format(self.instance_name))
|
||||
finally:
|
||||
self.clean_cloud_dir(self.tmp_cloud_provider)
|
||||
if not destroyed:
|
||||
# Destroying instances in the tearDown is a contingency, not the way things should work by default.
|
||||
self.fail('The Instance "{}" was not deleted after multiple attempts'.format(self.instance_name))
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
cls.clean_cloud_dir(cls, cls.TMP_PROVIDER_DIR)
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
# clean up before setup
|
||||
cls.clean_cloud_dir(cls, cls.TMP_PROVIDER_DIR)
|
||||
|
||||
# add the provider config for only the cloud we are testing
|
||||
provider_file = cls.PROVIDER + '.conf'
|
||||
shutil.copyfile(os.path.join(os.path.join(FILES, 'conf', 'cloud.providers.d'), provider_file),
|
||||
os.path.join(os.path.join(cls.TMP_PROVIDER_DIR, provider_file)))
|
||||
|
|
Loading…
Add table
Reference in a new issue