mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Update Rackspace cloud test file to be more accurate
This commit is contained in:
parent
650891c923
commit
e89564c775
@ -16,18 +16,16 @@ from salttesting.helpers import ensure_in_syspath, expensiveTest
|
|||||||
ensure_in_syspath('../../../')
|
ensure_in_syspath('../../../')
|
||||||
|
|
||||||
# Import Salt Libs
|
# Import Salt Libs
|
||||||
import integration # pylint: disable=import-error
|
import integration
|
||||||
from salt.config import cloud_providers_config
|
from salt.config import cloud_providers_config
|
||||||
|
from salt.ext.six.moves import range
|
||||||
|
|
||||||
# Import Third-Party Libs
|
# Import Third-Party Libs
|
||||||
# pylint: disable=import-error
|
|
||||||
from salt.ext.six.moves import range # pylint: disable=redefined-builtin
|
|
||||||
try:
|
try:
|
||||||
import libcloud # pylint: disable=unused-import
|
import libcloud # pylint: disable=unused-import
|
||||||
HAS_LIBCLOUD = True
|
HAS_LIBCLOUD = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
HAS_LIBCLOUD = False
|
HAS_LIBCLOUD = False
|
||||||
# pylint: enable=import-error
|
|
||||||
|
|
||||||
|
|
||||||
def __random_name(size=6):
|
def __random_name(size=6):
|
||||||
@ -41,6 +39,8 @@ def __random_name(size=6):
|
|||||||
|
|
||||||
# Create the cloud instance name to be used throughout the tests
|
# Create the cloud instance name to be used throughout the tests
|
||||||
INSTANCE_NAME = __random_name()
|
INSTANCE_NAME = __random_name()
|
||||||
|
PROVIDER_NAME = 'rackspace'
|
||||||
|
DRIVER_NAME = 'openstack'
|
||||||
|
|
||||||
|
|
||||||
@skipIf(HAS_LIBCLOUD is False, 'salt-cloud requires >= libcloud 0.13.2')
|
@skipIf(HAS_LIBCLOUD is False, 'salt-cloud requires >= libcloud 0.13.2')
|
||||||
@ -57,53 +57,55 @@ class RackspaceTest(integration.ShellCase):
|
|||||||
super(RackspaceTest, self).setUp()
|
super(RackspaceTest, self).setUp()
|
||||||
|
|
||||||
# check if appropriate cloud provider and profile files are present
|
# check if appropriate cloud provider and profile files are present
|
||||||
profile_str = 'rackspace-config:'
|
profile_str = 'rackspace-config'
|
||||||
provider = 'rackspace'
|
|
||||||
providers = self.run_cloud('--list-providers')
|
providers = self.run_cloud('--list-providers')
|
||||||
if profile_str not in providers:
|
if profile_str + ':' not in providers:
|
||||||
self.skipTest(
|
self.skipTest(
|
||||||
'Configuration file for {0} was not found. Check {0}.conf files '
|
'Configuration file for {0} was not found. Check {0}.conf files '
|
||||||
'in tests/integration/files/conf/cloud.*.d/ to run these tests.'
|
'in tests/integration/files/conf/cloud.*.d/ to run these tests.'
|
||||||
.format(provider)
|
.format(PROVIDER_NAME)
|
||||||
)
|
)
|
||||||
|
|
||||||
# check if api key, user, and tenant are present
|
# check if personal access token, ssh_key_file, and ssh_key_names are present
|
||||||
path = os.path.join(integration.FILES,
|
config = cloud_providers_config(
|
||||||
|
os.path.join(
|
||||||
|
integration.FILES,
|
||||||
'conf',
|
'conf',
|
||||||
'cloud.providers.d',
|
'cloud.providers.d',
|
||||||
provider + '.conf')
|
PROVIDER_NAME + '.conf'
|
||||||
config = cloud_providers_config(path)
|
)
|
||||||
user = config['rackspace-config']['openstack']['user']
|
)
|
||||||
tenant = config['rackspace-config']['openstack']['tenant']
|
|
||||||
api = config['rackspace-config']['openstack']['apikey']
|
user = config[profile_str][DRIVER_NAME]['user']
|
||||||
|
tenant = config[profile_str][DRIVER_NAME]['tenant']
|
||||||
|
api = config[profile_str][DRIVER_NAME]['apikey']
|
||||||
if api == '' or tenant == '' or user == '':
|
if api == '' or tenant == '' or user == '':
|
||||||
self.skipTest(
|
self.skipTest(
|
||||||
'A user, tenant, and an api key must be provided to run these '
|
'A user, tenant, and an api key must be provided to run these '
|
||||||
'tests. Check tests/integration/files/conf/cloud.providers.d/{0}.conf'
|
'tests. Check tests/integration/files/conf/cloud.providers.d/{0}.conf'
|
||||||
.format(provider)
|
.format(PROVIDER_NAME)
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_instance(self):
|
def test_instance(self):
|
||||||
'''
|
'''
|
||||||
Test creating an instance on rackspace with the openstack driver
|
Test creating an instance on rackspace with the openstack driver
|
||||||
'''
|
'''
|
||||||
|
# check if instance with salt installed returned
|
||||||
# create the instance
|
|
||||||
instance = self.run_cloud('-p rackspace-test {0}'.format(INSTANCE_NAME))
|
|
||||||
ret = ' {0}'.format(INSTANCE_NAME)
|
|
||||||
|
|
||||||
# check if instance with salt installed returned successfully
|
|
||||||
try:
|
try:
|
||||||
self.assertIn(ret, instance)
|
self.assertIn(
|
||||||
|
INSTANCE_NAME,
|
||||||
|
[i.strip() for i in self.run_cloud('-p rackspace-test {0}'.format(INSTANCE_NAME))]
|
||||||
|
)
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME))
|
self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME))
|
||||||
raise
|
raise
|
||||||
|
|
||||||
# delete the instance
|
# delete the instance
|
||||||
delete = self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME))
|
|
||||||
ret = ' True'
|
|
||||||
try:
|
try:
|
||||||
self.assertIn(ret, delete)
|
self.assertIn(
|
||||||
|
INSTANCE_NAME + ':',
|
||||||
|
[i.strip() for i in self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME))]
|
||||||
|
)
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user