mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #26915 from rallytime/joyent-tests
Update Joyent Cloud Tests
This commit is contained in:
commit
eddb532713
1 changed files with 25 additions and 24 deletions
|
@ -29,6 +29,7 @@ def __random_name(size=6):
|
|||
|
||||
# Create the cloud instance name to be used throughout the tests
|
||||
INSTANCE_NAME = __random_name()
|
||||
PROVIDER_NAME = 'joyent'
|
||||
|
||||
|
||||
class JoyentTest(integration.ShellCase):
|
||||
|
@ -44,57 +45,57 @@ class JoyentTest(integration.ShellCase):
|
|||
super(JoyentTest, self).setUp()
|
||||
|
||||
# check if appropriate cloud provider and profile files are present
|
||||
profile_str = 'joyent-config:'
|
||||
provider = 'joyent'
|
||||
profile_str = 'joyent-config'
|
||||
providers = self.run_cloud('--list-providers')
|
||||
if profile_str not in providers:
|
||||
if profile_str + ':' not in providers:
|
||||
self.skipTest(
|
||||
'Configuration file for {0} was not found. Check {0}.conf files '
|
||||
'in tests/integration/files/conf/cloud.*.d/ to run these tests.'
|
||||
.format(provider)
|
||||
.format(PROVIDER_NAME)
|
||||
)
|
||||
|
||||
# check if user, password, private_key, and keyname are present
|
||||
path = os.path.join(integration.FILES,
|
||||
'conf',
|
||||
'cloud.providers.d',
|
||||
provider + '.conf')
|
||||
config = cloud_providers_config(path)
|
||||
config = cloud_providers_config(
|
||||
os.path.join(
|
||||
integration.FILES,
|
||||
'conf',
|
||||
'cloud.providers.d',
|
||||
PROVIDER_NAME + '.conf'
|
||||
)
|
||||
)
|
||||
|
||||
user = config['joyent-config'][provider]['user']
|
||||
password = config['joyent-config'][provider]['password']
|
||||
private_key = config['joyent-config'][provider]['private_key']
|
||||
keyname = config['joyent-config'][provider]['keyname']
|
||||
user = config[profile_str][PROVIDER_NAME]['user']
|
||||
password = config[profile_str][PROVIDER_NAME]['password']
|
||||
private_key = config[profile_str][PROVIDER_NAME]['private_key']
|
||||
keyname = config[profile_str][PROVIDER_NAME]['keyname']
|
||||
|
||||
if user == '' or password == '' or private_key == '' or keyname == '':
|
||||
self.skipTest(
|
||||
'A user name, password, private_key file path, and a key name '
|
||||
'must be provided to run these tests. Check '
|
||||
'tests/integration/files/conf/cloud.providers.d/{0}.conf'
|
||||
.format(provider)
|
||||
.format(PROVIDER_NAME)
|
||||
)
|
||||
|
||||
def test_instance(self):
|
||||
'''
|
||||
Test creating and deleting instance on Joyent
|
||||
'''
|
||||
|
||||
# create the instance
|
||||
instance = self.run_cloud('-p joyent-test {0}'.format(INSTANCE_NAME))
|
||||
ret_str = ' {0}'.format(INSTANCE_NAME)
|
||||
|
||||
# check if instance with salt installed returned
|
||||
try:
|
||||
self.assertIn(ret_str, instance)
|
||||
self.assertIn(
|
||||
INSTANCE_NAME,
|
||||
[i.strip() for i in self.run_cloud('-p joyent-test {0}'.format(INSTANCE_NAME))]
|
||||
)
|
||||
except AssertionError:
|
||||
self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME))
|
||||
raise
|
||||
|
||||
# delete the instance
|
||||
delete = self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME))
|
||||
ret_str = ' True'
|
||||
try:
|
||||
self.assertIn(ret_str, delete)
|
||||
self.assertIn(
|
||||
INSTANCE_NAME + ':',
|
||||
[i.strip() for i in self.run_cloud('-d {0} --assume-yes'.format(INSTANCE_NAME))]
|
||||
)
|
||||
except AssertionError:
|
||||
raise
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue