mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
put cloudtest base in separate file so that only one change needs to be made
This commit is contained in:
parent
8e723357ad
commit
459b16d413
10 changed files with 112 additions and 200 deletions
51
tests/integration/cloud/cloud_test_helpers.py
Normal file
51
tests/integration/cloud/cloud_test_helpers.py
Normal file
|
@ -0,0 +1,51 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
Tests for the Openstack Cloud Provider
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
from time import sleep
|
||||
import logging
|
||||
|
||||
# Import Salt libs
|
||||
from salt.ext.six.moves import range
|
||||
|
||||
# Import Salt Testing libs
|
||||
from tests.support.case import ShellCase
|
||||
from tests.support.helpers import generate_random_name
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
TIMEOUT = 500
|
||||
|
||||
|
||||
class CloudTest(ShellCase):
|
||||
@property
|
||||
def INSTANCE_NAME(self):
|
||||
if not hasattr(self, '_instance_name'):
|
||||
# Create the cloud instance name to be used throughout the tests
|
||||
self._instance_name = generate_random_name('cloud-test-').lower()
|
||||
return self._instance_name
|
||||
|
||||
def _instance_exists(self):
|
||||
# salt-cloud -a show_instance myinstance
|
||||
return ' {0}:'.format(self.INSTANCE_NAME) in self.run_cloud('--query')
|
||||
|
||||
def tearDown(self):
|
||||
'''
|
||||
Clean up after tests, share this between all the cloud tests
|
||||
'''
|
||||
for _ in range(4):
|
||||
if self._instance_exists():
|
||||
delete = self.run_cloud('-d {0} --assume-yes'.format(self.INSTANCE_NAME), timeout=TIMEOUT)
|
||||
# example response: ['gce-config:', '----------', ' gce:', '----------', 'cloud-test-dq4e6c:', 'True', '']
|
||||
delete_str = ''.join(delete)
|
||||
self.assertIn(self.INSTANCE_NAME, delete_str)
|
||||
|
||||
if 'shutting-down' in ''.join(delete):
|
||||
log.debug('Instance "{}" was deleted properly'.format(self.INSTANCE_NAME))
|
||||
break
|
||||
else:
|
||||
log.warning('Instance "{}" was not deleted'.format(self.INSTANCE_NAME))
|
||||
sleep(10)
|
||||
self.assertEqual(self._instance_exists(), False)
|
|
@ -15,17 +15,16 @@ import salt.utils.files
|
|||
import salt.utils.yaml
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.case import ShellCase
|
||||
from tests.support.paths import FILES
|
||||
from tests.support.helpers import expensiveTest, generate_random_name
|
||||
from tests.support.helpers import expensiveTest
|
||||
from tests.support.unit import skipIf
|
||||
from tests.support import win_installer
|
||||
|
||||
# Create the cloud instance name to be used throughout the tests
|
||||
INSTANCE_NAME = generate_random_name('cloud-test-').lower()
|
||||
from tests.integration.cloud.cloud_test_helpers import TIMEOUT, CloudTest
|
||||
|
||||
PROVIDER_NAME = 'ec2'
|
||||
HAS_WINRM = salt.utils.cloud.HAS_WINRM and salt.utils.cloud.HAS_SMB
|
||||
TIMEOUT = 1200
|
||||
|
||||
|
||||
def _fetch_installer():
|
||||
|
@ -49,7 +48,7 @@ def _fetch_installer():
|
|||
INSTALLER = _fetch_installer()
|
||||
|
||||
|
||||
class EC2Test(ShellCase):
|
||||
class EC2Test(CloudTest):
|
||||
'''
|
||||
Integration tests for the EC2 cloud provider in Salt-Cloud
|
||||
'''
|
||||
|
@ -108,10 +107,7 @@ class EC2Test(ShellCase):
|
|||
)
|
||||
|
||||
self.assertEqual(self._instance_exists(), False,
|
||||
'The instance "{}" exists before it was created by the test'.format(INSTANCE_NAME))
|
||||
|
||||
def _instance_exists(self):
|
||||
return ' {0}:'.format(INSTANCE_NAME) in self.run_cloud('--query')
|
||||
'The instance "{}" exists before it was created by the test'.format(self.INSTANCE_NAME))
|
||||
|
||||
def override_profile_config(self, name, data):
|
||||
conf_path = os.path.join(self.config_dir, 'cloud.profiles.d', 'ec2.conf')
|
||||
|
@ -143,9 +139,9 @@ class EC2Test(ShellCase):
|
|||
cmd = '-p {0}'.format(profile)
|
||||
if debug:
|
||||
cmd += ' -l debug'
|
||||
cmd += ' {0}'.format(INSTANCE_NAME)
|
||||
cmd += ' {0}'.format(self.INSTANCE_NAME)
|
||||
instance = self.run_cloud(cmd, timeout=TIMEOUT)
|
||||
ret_str = '{0}:'.format(INSTANCE_NAME)
|
||||
ret_str = '{0}:'.format(self.INSTANCE_NAME)
|
||||
|
||||
# check if instance returned with salt installed
|
||||
self.assertIn(ret_str, instance)
|
||||
|
@ -156,7 +152,7 @@ class EC2Test(ShellCase):
|
|||
Tests creating and renaming an instance on EC2 (classic)
|
||||
'''
|
||||
# Start with a name that is different from usual so that it will get deleted normally after the test
|
||||
changed_name = INSTANCE_NAME + '-changed'
|
||||
changed_name = self.INSTANCE_NAME + '-changed'
|
||||
# create the instance
|
||||
instance = self.run_cloud('-p ec2-test {0} --no-deploy'.format(changed_name), timeout=TIMEOUT)
|
||||
ret_str = '{0}:'.format(changed_name)
|
||||
|
@ -164,11 +160,11 @@ class EC2Test(ShellCase):
|
|||
# check if instance returned
|
||||
self.assertIn(ret_str, instance)
|
||||
|
||||
change_name = self.run_cloud('-a rename {0} newname={1} --assume-yes'.format(changed_name, INSTANCE_NAME),
|
||||
change_name = self.run_cloud('-a rename {0} newname={1} --assume-yes'.format(changed_name, self.INSTANCE_NAME),
|
||||
timeout=TIMEOUT)
|
||||
|
||||
check_rename = self.run_cloud('-a show_instance {0} --assume-yes'.format(INSTANCE_NAME), [INSTANCE_NAME])
|
||||
exp_results = [' {0}:'.format(INSTANCE_NAME), ' size:',
|
||||
check_rename = self.run_cloud('-a show_instance {0} --assume-yes'.format(self.INSTANCE_NAME), [self.INSTANCE_NAME])
|
||||
exp_results = [' {0}:'.format(self.INSTANCE_NAME), ' size:',
|
||||
' architecture:']
|
||||
for result in exp_results:
|
||||
self.assertIn(result, check_rename[0])
|
||||
|
@ -249,15 +245,3 @@ class EC2Test(ShellCase):
|
|||
|
||||
)
|
||||
self._test_instance('ec2-win2016-test', debug=True)
|
||||
|
||||
def tearDown(self):
|
||||
'''
|
||||
Clean up after tests
|
||||
'''
|
||||
delete = self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=TIMEOUT)
|
||||
# example response: ['gce-config:', '----------', ' gce:', '----------', 'cloud-test-dq4e6c:', 'True', '']
|
||||
delete_str = ''.join(delete)
|
||||
|
||||
# check if deletion was `performed appropriately
|
||||
self.assertIn(INSTANCE_NAME, delete_str)
|
||||
self.assertIn('True', delete_str)
|
||||
|
|
|
@ -12,15 +12,12 @@ import os
|
|||
from salt.config import cloud_providers_config
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.case import ShellCase
|
||||
from tests.integration.cloud.cloud_test_helpers import TIMEOUT, CloudTest
|
||||
from tests.support.paths import FILES
|
||||
from tests.support.helpers import expensiveTest, generate_random_name
|
||||
|
||||
INSTANCE_NAME = generate_random_name('cloud-test-').lower()
|
||||
TIMEOUT = 500
|
||||
from tests.support.helpers import expensiveTest
|
||||
|
||||
|
||||
class GCETest(ShellCase):
|
||||
class GCETest(CloudTest):
|
||||
'''
|
||||
Integration tests for the GCE cloud provider in Salt-Cloud
|
||||
'''
|
||||
|
@ -72,21 +69,14 @@ class GCETest(ShellCase):
|
|||
.format(provider)
|
||||
)
|
||||
|
||||
self.assertEqual(self._instance_exists(), False,
|
||||
'The instance "{}" exists before it was created by the test'.format(INSTANCE_NAME))
|
||||
|
||||
def _instance_exists(self):
|
||||
# salt-cloud -a show_instance myinstance
|
||||
return ' {0}:'.format(INSTANCE_NAME) in self.run_cloud('--query')
|
||||
|
||||
def test_instance(self):
|
||||
'''
|
||||
Tests creating and deleting an instance on GCE
|
||||
'''
|
||||
|
||||
# create the instance
|
||||
instance = self.run_cloud('-p gce-test {0}'.format(INSTANCE_NAME), timeout=TIMEOUT)
|
||||
ret_str = '{0}:'.format(INSTANCE_NAME)
|
||||
instance = self.run_cloud('-p gce-test {0}'.format(self.INSTANCE_NAME), timeout=TIMEOUT)
|
||||
ret_str = '{0}:'.format(self.INSTANCE_NAME)
|
||||
|
||||
# check if instance returned with salt installed
|
||||
self.assertIn(ret_str, instance)
|
||||
|
@ -99,23 +89,10 @@ class GCETest(ShellCase):
|
|||
|
||||
# create the instance
|
||||
instance = self.run_cloud('-p gce-test-extra \
|
||||
{0}'.format(INSTANCE_NAME),
|
||||
{0}'.format(self.INSTANCE_NAME),
|
||||
timeout=TIMEOUT)
|
||||
ret_str = '{0}:'.format(INSTANCE_NAME)
|
||||
ret_str = '{0}:'.format(self.INSTANCE_NAME)
|
||||
|
||||
# check if instance returned with salt installed
|
||||
self.assertIn(ret_str, instance)
|
||||
self.assertEqual(self._instance_exists(), True)
|
||||
|
||||
def tearDown(self):
|
||||
'''
|
||||
Clean up after tests
|
||||
'''
|
||||
# delete the instance
|
||||
delete = self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=TIMEOUT)
|
||||
# example response: ['gce-config:', '----------', ' gce:', '----------', 'cloud-test-dq4e6c:', 'True', '']
|
||||
delete_str = ''.join(delete)
|
||||
|
||||
# check if deletion was performed appropriately
|
||||
self.assertIn(INSTANCE_NAME, delete_str)
|
||||
self.assertIn('True', delete_str)
|
||||
|
|
|
@ -8,22 +8,21 @@ from __future__ import absolute_import, print_function, unicode_literals
|
|||
import os
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.case import ShellCase
|
||||
from tests.support.paths import FILES
|
||||
from tests.support.helpers import expensiveTest, generate_random_name
|
||||
from tests.support.helpers import expensiveTest
|
||||
from tests.support.unit import skipIf
|
||||
|
||||
# Import Salt Libs
|
||||
from salt.config import cloud_providers_config
|
||||
|
||||
# Create the cloud instance name to be used throughout the tests
|
||||
INSTANCE_NAME = generate_random_name('cloud-test-').lower()
|
||||
from tests.integration.cloud.cloud_test_helpers import TIMEOUT, CloudTest
|
||||
|
||||
PROVIDER_NAME = 'gogrid'
|
||||
TIMEOUT = 500
|
||||
|
||||
|
||||
@skipIf(True, 'waiting on bug report fixes from #13365')
|
||||
class GoGridTest(ShellCase):
|
||||
class GoGridTest(CloudTest):
|
||||
'''
|
||||
Integration tests for the GoGrid cloud provider in Salt-Cloud
|
||||
'''
|
||||
|
@ -68,29 +67,13 @@ class GoGridTest(ShellCase):
|
|||
self.assertEqual(self._instance_exists(), False,
|
||||
'The instance "{}" exists before it was created by the test'.format(INSTANCE_NAME))
|
||||
|
||||
def _instance_exists(self):
|
||||
return ' {0}:'.format(INSTANCE_NAME) in self.run_cloud('--query')
|
||||
|
||||
def test_instance(self):
|
||||
'''
|
||||
Test creating an instance on GoGrid
|
||||
'''
|
||||
# check if instance with salt installed returned
|
||||
self.assertIn(
|
||||
INSTANCE_NAME,
|
||||
[i.strip() for i in self.run_cloud('-p gogrid-test {0}'.format(INSTANCE_NAME), timeout=500)]
|
||||
self.INSTANCE_NAME,
|
||||
[i.strip() for i in self.run_cloud('-p gogrid-test {0}'.format(self.INSTANCE_NAME), timeout=500)]
|
||||
)
|
||||
self.assertEqual(self._instance_exists(), True)
|
||||
|
||||
def tearDown(self):
|
||||
'''
|
||||
Clean up after tests
|
||||
'''
|
||||
# delete the instance
|
||||
delete = self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=TIMEOUT)
|
||||
# example response: ['gce-config:', '----------', ' gce:', '----------', 'cloud-test-dq4e6c:', 'True', '']
|
||||
delete_str = ''.join(delete)
|
||||
|
||||
# check if deletion was performed appropriately
|
||||
self.assertIn(INSTANCE_NAME, delete_str)
|
||||
self.assertIn('True', delete_str)
|
||||
|
|
|
@ -8,20 +8,19 @@ from __future__ import absolute_import, print_function, unicode_literals
|
|||
import os
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.case import ShellCase
|
||||
from tests.support.paths import FILES
|
||||
from tests.support.helpers import expensiveTest, generate_random_name
|
||||
from tests.support.helpers import expensiveTest
|
||||
|
||||
# Import Salt Libs
|
||||
from salt.config import cloud_providers_config
|
||||
|
||||
# Create the cloud instance name to be used throughout the tests
|
||||
INSTANCE_NAME = generate_random_name('cloud-test-').lower()
|
||||
from tests.integration.cloud.cloud_test_helpers import TIMEOUT, CloudTest
|
||||
|
||||
PROVIDER_NAME = 'joyent'
|
||||
TIMEOUT = 500
|
||||
|
||||
|
||||
class JoyentTest(ShellCase):
|
||||
class JoyentTest(CloudTest):
|
||||
'''
|
||||
Integration tests for the Joyent cloud provider in Salt-Cloud
|
||||
'''
|
||||
|
@ -69,27 +68,12 @@ class JoyentTest(ShellCase):
|
|||
self.assertEqual(self._instance_exists(), False,
|
||||
'The instance "{}" exists before it was created by the test'.format(INSTANCE_NAME))
|
||||
|
||||
def _instance_exists(self):
|
||||
return ' {0}:'.format(INSTANCE_NAME) in self.run_cloud('--query')
|
||||
|
||||
def test_instance(self):
|
||||
'''
|
||||
Test creating and deleting instance on Joyent
|
||||
'''
|
||||
self.assertIn(
|
||||
INSTANCE_NAME,
|
||||
[i.strip() for i in self.run_cloud('-p joyent-test {0}'.format(INSTANCE_NAME), timeout=500)]
|
||||
self.INSTANCE_NAME,
|
||||
[i.strip() for i in self.run_cloud('-p joyent-test {0}'.format(self.INSTANCE_NAME), timeout=500)]
|
||||
)
|
||||
self.assertEqual(self._instance_exists(), True)
|
||||
|
||||
def tearDown(self):
|
||||
'''
|
||||
Clean up after tests
|
||||
'''
|
||||
delete = self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=TIMEOUT)
|
||||
# example response: ['gce-config:', '----------', ' gce:', '----------', 'cloud-test-dq4e6c:', 'True', '']
|
||||
delete_str = ''.join(delete)
|
||||
|
||||
# check if deletion was performed appropriately
|
||||
self.assertIn(INSTANCE_NAME, delete_str)
|
||||
self.assertIn('True', delete_str)
|
||||
|
|
|
@ -8,20 +8,19 @@ from __future__ import absolute_import, print_function, unicode_literals
|
|||
import os
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.case import ShellCase
|
||||
from tests.support.paths import FILES
|
||||
from tests.support.helpers import expensiveTest, generate_random_name
|
||||
from tests.support.helpers import expensiveTest
|
||||
|
||||
# Import Salt Libs
|
||||
from salt.config import cloud_providers_config
|
||||
|
||||
# Create the cloud instance name to be used throughout the tests
|
||||
INSTANCE_NAME = generate_random_name('cloud-test-').lower()
|
||||
from tests.integration.cloud.cloud_test_helpers import TIMEOUT, CloudTest
|
||||
|
||||
PROVIDER_NAME = 'linode'
|
||||
TIMEOUT = 500
|
||||
|
||||
|
||||
class LinodeTest(ShellCase):
|
||||
class LinodeTest(CloudTest):
|
||||
'''
|
||||
Integration tests for the Linode cloud provider in Salt-Cloud
|
||||
'''
|
||||
|
@ -64,10 +63,7 @@ class LinodeTest(ShellCase):
|
|||
)
|
||||
|
||||
self.assertEqual(self._instance_exists(), False,
|
||||
'The instance "{}" exists before it was created by the test'.format(INSTANCE_NAME))
|
||||
|
||||
def _instance_exists(self):
|
||||
return ' {0}:'.format(INSTANCE_NAME) in self.run_cloud('--query')
|
||||
'The instance "{}" exists before it was created by the test'.format(self.INSTANCE_NAME))
|
||||
|
||||
def test_instance(self):
|
||||
'''
|
||||
|
@ -75,19 +71,7 @@ class LinodeTest(ShellCase):
|
|||
'''
|
||||
# check if instance with salt installed returned
|
||||
self.assertIn(
|
||||
INSTANCE_NAME,
|
||||
[i.strip() for i in self.run_cloud('-p linode-test {0}'.format(INSTANCE_NAME), timeout=500)]
|
||||
self.INSTANCE_NAME,
|
||||
[i.strip() for i in self.run_cloud('-p linode-test {0}'.format(self.INSTANCE_NAME), timeout=500)]
|
||||
)
|
||||
self.assertEqual(self._instance_exists(), True)
|
||||
|
||||
def tearDown(self):
|
||||
'''
|
||||
Clean up after tests
|
||||
'''
|
||||
delete = self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=TIMEOUT)
|
||||
# example response: ['gce-config:', '----------', ' gce:', '----------', 'cloud-test-dq4e6c:', 'True', '']
|
||||
delete_str = ''.join(delete)
|
||||
|
||||
# check if deletion was performed appropriately
|
||||
self.assertIn(INSTANCE_NAME, delete_str)
|
||||
self.assertIn('True', delete_str)
|
||||
|
|
|
@ -9,14 +9,15 @@ import logging
|
|||
import os
|
||||
|
||||
# Import Salt Testing libs
|
||||
from tests.support.case import ModuleCase, ShellCase
|
||||
from tests.support.case import ModuleCase
|
||||
from tests.support.paths import FILES
|
||||
from tests.support.unit import skipIf
|
||||
from tests.support.helpers import destructiveTest, expensiveTest, generate_random_name
|
||||
from tests.support.helpers import destructiveTest, expensiveTest
|
||||
from tests.support.mixins import SaltReturnAssertsMixin
|
||||
|
||||
# Import Salt Libs
|
||||
from salt.config import cloud_providers_config
|
||||
from tests.integration.cloud.cloud_test_helpers import TIMEOUT, CloudTest
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
@ -38,10 +39,8 @@ except ImportError:
|
|||
HAS_SHADE = False
|
||||
|
||||
# Create the cloud instance name to be used throughout the tests
|
||||
INSTANCE_NAME = generate_random_name('cloud-test-').lower()
|
||||
PROVIDER_NAME = 'openstack'
|
||||
DRIVER_NAME = 'openstack'
|
||||
TIMEOUT = 500
|
||||
|
||||
|
||||
@skipIf(
|
||||
|
@ -179,7 +178,7 @@ class OpenstackTest(ModuleCase, SaltReturnAssertsMixin):
|
|||
|
||||
|
||||
@skipIf(not HAS_SHADE, 'openstack driver requires `shade`')
|
||||
class RackspaceTest(ShellCase):
|
||||
class RackspaceTest(CloudTest):
|
||||
'''
|
||||
Integration tests for the Rackspace cloud provider using the Openstack driver
|
||||
'''
|
||||
|
@ -222,10 +221,7 @@ class RackspaceTest(ShellCase):
|
|||
)
|
||||
|
||||
self.assertEqual(self._instance_exists(), False,
|
||||
'The instance "{}" exists before it was created by the test'.format(INSTANCE_NAME))
|
||||
|
||||
def _instance_exists(self):
|
||||
return ' {0}:'.format(INSTANCE_NAME) in self.run_cloud('--query')
|
||||
'The instance "{}" exists before it was created by the test'.format(self.INSTANCE_NAME))
|
||||
|
||||
def test_instance(self):
|
||||
'''
|
||||
|
@ -233,19 +229,6 @@ class RackspaceTest(ShellCase):
|
|||
'''
|
||||
# check if instance with salt installed returned
|
||||
self.assertIn(
|
||||
INSTANCE_NAME,
|
||||
[i.strip() for i in self.run_cloud('-p rackspace-test {0}'.format(INSTANCE_NAME), timeout=500)]
|
||||
self.INSTANCE_NAME,
|
||||
[i.strip() for i in self.run_cloud('-p rackspace-test {0}'.format(self.INSTANCE_NAME), timeout=500)]
|
||||
)
|
||||
|
||||
def tearDown(self):
|
||||
'''
|
||||
Clean up after tests
|
||||
'''
|
||||
# delete the instance
|
||||
delete = self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=TIMEOUT)
|
||||
# example response: ['gce-config:', '----------', ' gce:', '----------', 'cloud-test-dq4e6c:', 'True', '']
|
||||
delete_str = ''.join(delete)
|
||||
|
||||
# check if deletion was performed appropriately
|
||||
self.assertIn(INSTANCE_NAME, delete_str)
|
||||
self.assertIn('True', delete_str)
|
||||
|
|
|
@ -8,15 +8,16 @@ from __future__ import absolute_import, print_function, unicode_literals
|
|||
import os
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.case import ShellCase
|
||||
from tests.support.paths import FILES
|
||||
from tests.support.unit import skipIf
|
||||
from tests.support.helpers import expensiveTest, generate_random_name
|
||||
from tests.support.helpers import expensiveTest
|
||||
|
||||
# Import Salt Libs
|
||||
from salt.config import cloud_providers_config
|
||||
|
||||
# Import Third-Party Libs
|
||||
from tests.integration.cloud.cloud_test_helpers import TIMEOUT, CloudTest
|
||||
|
||||
try:
|
||||
# pylint: disable=unused-import
|
||||
from profitbricks.client import ProfitBricksService
|
||||
|
@ -26,14 +27,12 @@ except ImportError:
|
|||
HAS_PROFITBRICKS = False
|
||||
|
||||
# Create the cloud instance name to be used throughout the tests
|
||||
INSTANCE_NAME = generate_random_name('cloud-test-').lower()
|
||||
PROVIDER_NAME = 'profitbricks'
|
||||
DRIVER_NAME = 'profitbricks'
|
||||
TIMEOUT = 500
|
||||
|
||||
|
||||
@skipIf(HAS_PROFITBRICKS is False, 'salt-cloud requires >= profitbricks 4.1.0')
|
||||
class ProfitBricksTest(ShellCase):
|
||||
class ProfitBricksTest(CloudTest):
|
||||
'''
|
||||
Integration tests for the ProfitBricks cloud provider
|
||||
'''
|
||||
|
@ -80,9 +79,6 @@ class ProfitBricksTest(ShellCase):
|
|||
self.assertEqual(self._instance_exists(), False,
|
||||
'The instance "{}" exists before it was created by the test'.format(INSTANCE_NAME))
|
||||
|
||||
def _instance_exists(self):
|
||||
return ' {0}:'.format(INSTANCE_NAME) in self.run_cloud('--query')
|
||||
|
||||
def test_list_images(self):
|
||||
'''
|
||||
Tests the return of running the --list-images command for ProfitBricks
|
||||
|
@ -193,22 +189,9 @@ class ProfitBricksTest(ShellCase):
|
|||
'''
|
||||
# check if instance with salt installed returned
|
||||
self.assertIn(
|
||||
INSTANCE_NAME,
|
||||
self.INSTANCE_NAME,
|
||||
[i.strip() for i in self.run_cloud(
|
||||
'-p profitbricks-test {0}'.format(INSTANCE_NAME),
|
||||
'-p profitbricks-test {0}'.format(self.INSTANCE_NAME),
|
||||
timeout=TIMEOUT
|
||||
)]
|
||||
)
|
||||
|
||||
def tearDown(self):
|
||||
'''
|
||||
Clean up after tests
|
||||
'''
|
||||
if self._instance_exists():
|
||||
delete = self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=TIMEOUT)
|
||||
# example response: ['gce-config:', '----------', ' gce:', '----------', 'cloud-test-dq4e6c:', 'True', '']
|
||||
delete_str = ''.join(delete)
|
||||
|
||||
# check if deletion was performed appropriately
|
||||
self.assertIn(INSTANCE_NAME, delete_str)
|
||||
self.assertIn('True', delete_str)
|
||||
|
|
|
@ -12,17 +12,16 @@ from salt.config import cloud_providers_config, cloud_config
|
|||
from salt.ext import six
|
||||
|
||||
# Import Salt Testing LIbs
|
||||
from tests.support.case import ShellCase
|
||||
from tests.support.paths import FILES
|
||||
from tests.support.helpers import expensiveTest, generate_random_name
|
||||
from tests.support.helpers import expensiveTest
|
||||
|
||||
# Create the cloud instance name to be used throughout the tests
|
||||
INSTANCE_NAME = generate_random_name('cloud-test-').lower()
|
||||
from tests.integration.cloud.cloud_test_helpers import TIMEOUT, CloudTest
|
||||
|
||||
PROVIDER_NAME = 'vmware'
|
||||
TIMEOUT = 500
|
||||
|
||||
|
||||
class VMWareTest(ShellCase):
|
||||
class VMWareTest(CloudTest):
|
||||
'''
|
||||
Integration tests for the vmware cloud provider in Salt-Cloud
|
||||
'''
|
||||
|
@ -76,9 +75,6 @@ class VMWareTest(ShellCase):
|
|||
self.assertEqual(self._instance_exists(), False,
|
||||
'The instance "{}" exists before it was created by the test'.format(INSTANCE_NAME))
|
||||
|
||||
def _instance_exists(self):
|
||||
return ' {0}:'.format(INSTANCE_NAME) in self.run_cloud('--query')
|
||||
|
||||
def test_instance(self):
|
||||
'''
|
||||
Tests creating and deleting an instance on vmware and installing salt
|
||||
|
@ -94,9 +90,9 @@ class VMWareTest(ShellCase):
|
|||
profile_config = cloud_config(profile)
|
||||
disk_datastore = profile_config['vmware-test']['devices']['disk']['Hard disk 2']['datastore']
|
||||
|
||||
instance = self.run_cloud('-p vmware-test {0}'.format(INSTANCE_NAME), timeout=TIMEOUT)
|
||||
ret_str = '{0}:'.format(INSTANCE_NAME)
|
||||
disk_datastore_str = ' [{0}] {1}/Hard disk 2-flat.vmdk'.format(disk_datastore, INSTANCE_NAME)
|
||||
instance = self.run_cloud('-p vmware-test {0}'.format(self.INSTANCE_NAME), timeout=TIMEOUT)
|
||||
ret_str = '{0}:'.format(self.INSTANCE_NAME)
|
||||
disk_datastore_str = ' [{0}] {1}/Hard disk 2-flat.vmdk'.format(disk_datastore, self.INSTANCE_NAME)
|
||||
|
||||
# check if instance returned with salt installed
|
||||
self.assertIn(ret_str, instance)
|
||||
|
@ -109,9 +105,9 @@ class VMWareTest(ShellCase):
|
|||
Tests creating snapshot and creating vm with --no-deploy
|
||||
'''
|
||||
# create the instance
|
||||
instance = self.run_cloud('-p vmware-test {0} --no-deploy'.format(INSTANCE_NAME),
|
||||
instance = self.run_cloud('-p vmware-test {0} --no-deploy'.format(self.INSTANCE_NAME),
|
||||
timeout=TIMEOUT)
|
||||
ret_str = '{0}:'.format(INSTANCE_NAME)
|
||||
ret_str = '{0}:'.format(self.INSTANCE_NAME)
|
||||
|
||||
# check if instance returned with salt installed
|
||||
self.assertIn(ret_str, instance)
|
||||
|
@ -119,19 +115,8 @@ class VMWareTest(ShellCase):
|
|||
|
||||
create_snapshot = self.run_cloud('-a create_snapshot {0} \
|
||||
snapshot_name=\'Test Cloud\' \
|
||||
memdump=True -y'.format(INSTANCE_NAME),
|
||||
memdump=True -y'.format(self.INSTANCE_NAME),
|
||||
timeout=TIMEOUT)
|
||||
s_ret_str = 'Snapshot created successfully'
|
||||
|
||||
self.assertIn(s_ret_str, six.text_type(create_snapshot))
|
||||
|
||||
def tearDown(self):
|
||||
'''
|
||||
Clean up after tests
|
||||
'''
|
||||
# delete the instance
|
||||
delete = self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME), timeout=TIMEOUT)
|
||||
ret_str = '{0}:\', \' True'.format(INSTANCE_NAME)
|
||||
|
||||
# check if deletion was performed appropriately
|
||||
self.assertIn(ret_str, six.text_type(delete))
|
||||
|
|
|
@ -75,9 +75,7 @@ class CloudClientTestCase(ShellCase):
|
|||
provider=self.provider_name,
|
||||
names=[INSTANCE_NAME],
|
||||
image=self.image_name,
|
||||
location='sfo1',
|
||||
size='512mb',
|
||||
vm_size='512mb'
|
||||
location='sfo1', size='512mb', vm_size='512mb'
|
||||
)
|
||||
|
||||
# Check that the VM was created correctly
|
||||
|
|
Loading…
Add table
Reference in a new issue