mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
undercased non-const variable and added print statements
This commit is contained in:
parent
c5e875db4a
commit
2acb2df6d3
14 changed files with 61 additions and 61 deletions
|
@ -70,7 +70,7 @@ class DigitalOceanTest(CloudTest):
|
|||
)
|
||||
|
||||
self.assertEqual(self._instance_exists(), False,
|
||||
'The instance "{}" exists before it was created by the test'.format(self.INSTANCE_NAME))
|
||||
'The instance "{}" exists before it was created by the test'.format(self.instance_name))
|
||||
|
||||
def test_list_images(self):
|
||||
'''
|
||||
|
@ -106,7 +106,7 @@ class DigitalOceanTest(CloudTest):
|
|||
'''
|
||||
Test key management
|
||||
'''
|
||||
do_key_name = self.INSTANCE_NAME + '-key'
|
||||
do_key_name = self.instance_name + '-key'
|
||||
|
||||
# generate key and fingerprint
|
||||
ssh_key = RSA.generate(4096)
|
||||
|
@ -152,8 +152,8 @@ class DigitalOceanTest(CloudTest):
|
|||
'''
|
||||
# check if instance with salt installed returned
|
||||
self.assertIn(
|
||||
self.INSTANCE_NAME,
|
||||
[i.strip() for i in self.run_cloud('-p digitalocean-test {0}'.format(self.INSTANCE_NAME), timeout=TIMEOUT)]
|
||||
self.instance_name,
|
||||
[i.strip() for i in self.run_cloud('-p digitalocean-test {0}'.format(self.instance_name), timeout=TIMEOUT)]
|
||||
)
|
||||
self.assertEqual(self._instance_exists(), True)
|
||||
self._destroy_instance()
|
||||
|
|
|
@ -65,7 +65,7 @@ class DimensionDataTest(CloudTest):
|
|||
)
|
||||
|
||||
self.assertEqual(self._instance_exists(), False,
|
||||
'The instance "{}" exists before it was created by the test'.format(self.INSTANCE_NAME))
|
||||
'The instance "{}" exists before it was created by the test'.format(self.instance_name))
|
||||
|
||||
def test_list_images(self):
|
||||
'''
|
||||
|
@ -103,8 +103,8 @@ class DimensionDataTest(CloudTest):
|
|||
'''
|
||||
# check if instance with salt installed returned
|
||||
self.assertIn(
|
||||
self.INSTANCE_NAME,
|
||||
[i.strip() for i in self.run_cloud('-p dimensiondata-test {0}'.format(self.INSTANCE_NAME), timeout=TIMEOUT)]
|
||||
self.instance_name,
|
||||
[i.strip() for i in self.run_cloud('-p dimensiondata-test {0}'.format(self.instance_name), timeout=TIMEOUT)]
|
||||
)
|
||||
|
||||
self._destroy_instance()
|
||||
|
|
|
@ -108,7 +108,7 @@ class EC2Test(CloudTest):
|
|||
)
|
||||
|
||||
self.assertEqual(self._instance_exists(), False,
|
||||
'The instance "{}" exists before it was created by the test'.format(self.INSTANCE_NAME))
|
||||
'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')
|
||||
|
@ -140,9 +140,9 @@ class EC2Test(CloudTest):
|
|||
cmd = ['-p', profile]
|
||||
if debug:
|
||||
cmd.extend(['-l', 'debug'])
|
||||
cmd.append(self.INSTANCE_NAME)
|
||||
cmd.append(self.instance_name)
|
||||
instance = self.run_cloud(' '.join(cmd), timeout=TIMEOUT)
|
||||
ret_str = '{0}:'.format(self.INSTANCE_NAME)
|
||||
ret_str = '{0}:'.format(self.instance_name)
|
||||
|
||||
# check if instance returned with salt installed
|
||||
self.assertIn(ret_str, instance)
|
||||
|
@ -155,7 +155,7 @@ class EC2Test(CloudTest):
|
|||
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 = self.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)
|
||||
|
@ -163,11 +163,11 @@ class EC2Test(CloudTest):
|
|||
# check if instance returned
|
||||
self.assertIn(ret_str, instance)
|
||||
|
||||
change_name = self.run_cloud('-a rename {0} newname={1} --assume-yes'.format(changed_name, self.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(self.INSTANCE_NAME), [self.INSTANCE_NAME])
|
||||
exp_results = [' {0}:'.format(self.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])
|
||||
|
|
|
@ -75,8 +75,8 @@ class GCETest(CloudTest):
|
|||
'''
|
||||
|
||||
# create the instance
|
||||
instance = self.run_cloud('-p gce-test {0}'.format(self.INSTANCE_NAME), timeout=TIMEOUT)
|
||||
ret_str = '{0}:'.format(self.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)
|
||||
|
@ -90,9 +90,9 @@ class GCETest(CloudTest):
|
|||
|
||||
# create the instance
|
||||
instance = self.run_cloud('-p gce-test-extra \
|
||||
{0}'.format(self.INSTANCE_NAME),
|
||||
{0}'.format(self.instance_name),
|
||||
timeout=TIMEOUT)
|
||||
ret_str = '{0}:'.format(self.INSTANCE_NAME)
|
||||
ret_str = '{0}:'.format(self.instance_name)
|
||||
|
||||
# check if instance returned with salt installed
|
||||
self.assertIn(ret_str, instance)
|
||||
|
|
|
@ -65,7 +65,7 @@ class GoGridTest(CloudTest):
|
|||
)
|
||||
|
||||
self.assertEqual(self._instance_exists(), False,
|
||||
'The instance "{}" exists before it was created by the test'.format(self.INSTANCE_NAME))
|
||||
'The instance "{}" exists before it was created by the test'.format(self.instance_name))
|
||||
|
||||
def test_instance(self):
|
||||
'''
|
||||
|
@ -73,8 +73,8 @@ class GoGridTest(CloudTest):
|
|||
'''
|
||||
# check if instance with salt installed returned
|
||||
self.assertIn(
|
||||
self.INSTANCE_NAME,
|
||||
[i.strip() for i in self.run_cloud('-p gogrid-test {0}'.format(self.INSTANCE_NAME), timeout=TIMEOUT)]
|
||||
self.instance_name,
|
||||
[i.strip() for i in self.run_cloud('-p gogrid-test {0}'.format(self.instance_name), timeout=TIMEOUT)]
|
||||
)
|
||||
self.assertEqual(self._instance_exists(), True)
|
||||
self._destroy_instance()
|
||||
|
|
|
@ -64,17 +64,17 @@ class JoyentTest(CloudTest):
|
|||
'tests/integration/files/conf/cloud.providers.d/{0}.conf'
|
||||
.format(PROVIDER_NAME)
|
||||
)
|
||||
|
||||
print('Joyent_test created instance: {}'.format(self.instance_name))
|
||||
self.assertEqual(self._instance_exists(), False,
|
||||
'The instance "{}" exists before it was created by the test'.format(self.INSTANCE_NAME))
|
||||
'The instance "{}" exists before it was created by the test'.format(self.instance_name))
|
||||
|
||||
def test_instance(self):
|
||||
'''
|
||||
Test creating and deleting instance on Joyent
|
||||
'''
|
||||
self.assertIn(
|
||||
self.INSTANCE_NAME,
|
||||
[i.strip() for i in self.run_cloud('-p joyent-test {0}'.format(self.INSTANCE_NAME), timeout=TIMEOUT)]
|
||||
self.instance_name,
|
||||
[i.strip() for i in self.run_cloud('-p joyent-test {0}'.format(self.instance_name), timeout=TIMEOUT)]
|
||||
)
|
||||
self.assertEqual(self._instance_exists(), True)
|
||||
self._destroy_instance()
|
||||
|
|
|
@ -63,7 +63,7 @@ class LinodeTest(CloudTest):
|
|||
)
|
||||
|
||||
self.assertEqual(self._instance_exists(), False,
|
||||
'The instance "{}" exists before it was created by the test'.format(self.INSTANCE_NAME))
|
||||
'The instance "{}" exists before it was created by the test'.format(self.instance_name))
|
||||
|
||||
def test_instance(self):
|
||||
'''
|
||||
|
@ -71,8 +71,8 @@ class LinodeTest(CloudTest):
|
|||
'''
|
||||
# check if instance with salt installed returned
|
||||
self.assertIn(
|
||||
self.INSTANCE_NAME,
|
||||
[i.strip() for i in self.run_cloud('-p linode-test {0}'.format(self.INSTANCE_NAME), timeout=TIMEOUT)]
|
||||
self.instance_name,
|
||||
[i.strip() for i in self.run_cloud('-p linode-test {0}'.format(self.instance_name), timeout=TIMEOUT)]
|
||||
)
|
||||
self.assertEqual(self._instance_exists(), True)
|
||||
self._destroy_instance()
|
||||
|
|
|
@ -111,7 +111,7 @@ class AzureTest(CloudTest):
|
|||
)
|
||||
|
||||
self.assertEqual(self._instance_exists(), False,
|
||||
'The instance "{}" exists before it was created by the test'.format(self.INSTANCE_NAME))
|
||||
'The instance "{}" exists before it was created by the test'.format(self.instance_name))
|
||||
|
||||
def test_instance(self):
|
||||
'''
|
||||
|
@ -119,11 +119,11 @@ class AzureTest(CloudTest):
|
|||
'''
|
||||
# check if instance with salt installed returned
|
||||
self.assertIn(
|
||||
self.INSTANCE_NAME,
|
||||
self.instance_name,
|
||||
[i.strip() for i in self.run_cloud(
|
||||
'-p {0} {1}'.format(
|
||||
PROFILE_NAME,
|
||||
self.INSTANCE_NAME
|
||||
self.instance_name
|
||||
), timeout=TIMEOUT
|
||||
)]
|
||||
)
|
||||
|
|
|
@ -221,7 +221,7 @@ class RackspaceTest(CloudTest):
|
|||
)
|
||||
|
||||
self.assertEqual(self._instance_exists(), False,
|
||||
'The instance "{}" exists before it was created by the test'.format(self.INSTANCE_NAME))
|
||||
'The instance "{}" exists before it was created by the test'.format(self.instance_name))
|
||||
|
||||
def test_instance(self):
|
||||
'''
|
||||
|
@ -229,8 +229,8 @@ class RackspaceTest(CloudTest):
|
|||
'''
|
||||
# check if instance with salt installed returned
|
||||
self.assertIn(
|
||||
self.INSTANCE_NAME,
|
||||
[i.strip() for i in self.run_cloud('-p rackspace-test {0}'.format(self.INSTANCE_NAME), timeout=TIMEOUT)]
|
||||
self.instance_name,
|
||||
[i.strip() for i in self.run_cloud('-p rackspace-test {0}'.format(self.instance_name), timeout=TIMEOUT)]
|
||||
)
|
||||
|
||||
self.assertEqual(self._instance_exists(), True)
|
||||
|
|
|
@ -77,7 +77,7 @@ class ProfitBricksTest(CloudTest):
|
|||
)
|
||||
|
||||
self.assertEqual(self._instance_exists(), False,
|
||||
'The instance "{}" exists before it was created by the test'.format(self.INSTANCE_NAME))
|
||||
'The instance "{}" exists before it was created by the test'.format(self.instance_name))
|
||||
|
||||
def test_list_images(self):
|
||||
'''
|
||||
|
@ -189,9 +189,9 @@ class ProfitBricksTest(CloudTest):
|
|||
'''
|
||||
# check if instance with salt installed returned
|
||||
self.assertIn(
|
||||
self.INSTANCE_NAME,
|
||||
self.instance_name,
|
||||
[i.strip() for i in self.run_cloud(
|
||||
'-p profitbricks-test {0}'.format(self.INSTANCE_NAME),
|
||||
'-p profitbricks-test {0}'.format(self.instance_name),
|
||||
timeout=TIMEOUT
|
||||
)]
|
||||
)
|
||||
|
|
|
@ -73,7 +73,7 @@ class VMWareTest(CloudTest):
|
|||
)
|
||||
|
||||
self.assertEqual(self._instance_exists(), False,
|
||||
'The instance "{}" exists before it was created by the test'.format(self.INSTANCE_NAME))
|
||||
'The instance "{}" exists before it was created by the test'.format(self.instance_name))
|
||||
|
||||
def test_instance(self):
|
||||
'''
|
||||
|
@ -90,9 +90,9 @@ class VMWareTest(CloudTest):
|
|||
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(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)
|
||||
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)
|
||||
|
@ -107,9 +107,9 @@ class VMWareTest(CloudTest):
|
|||
Tests creating snapshot and creating vm with --no-deploy
|
||||
'''
|
||||
# create the instance
|
||||
instance = self.run_cloud('-p vmware-test {0} --no-deploy'.format(self.INSTANCE_NAME),
|
||||
instance = self.run_cloud('-p vmware-test {0} --no-deploy'.format(self.instance_name),
|
||||
timeout=TIMEOUT)
|
||||
ret_str = '{0}:'.format(self.INSTANCE_NAME)
|
||||
ret_str = '{0}:'.format(self.instance_name)
|
||||
|
||||
# check if instance returned with salt installed
|
||||
self.assertIn(ret_str, instance)
|
||||
|
@ -117,7 +117,7 @@ class VMWareTest(CloudTest):
|
|||
|
||||
create_snapshot = self.run_cloud('-a create_snapshot {0} \
|
||||
snapshot_name=\'Test Cloud\' \
|
||||
memdump=True -y'.format(self.INSTANCE_NAME),
|
||||
memdump=True -y'.format(self.instance_name),
|
||||
timeout=TIMEOUT)
|
||||
s_ret_str = 'Snapshot created successfully'
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ class VultrTest(CloudTest):
|
|||
)
|
||||
|
||||
self.assertEqual(self._instance_exists(), False,
|
||||
'The instance "{}" exists before it was created by the test'.format(self.INSTANCE_NAME))
|
||||
'The instance "{}" exists before it was created by the test'.format(self.instance_name))
|
||||
|
||||
def test_list_images(self):
|
||||
'''
|
||||
|
@ -147,9 +147,9 @@ class VultrTest(CloudTest):
|
|||
Test creating an instance on Vultr
|
||||
'''
|
||||
# check if instance with salt installed returned
|
||||
create_vm = self.run_cloud('-p vultr-test {0}'.format(self.INSTANCE_NAME), timeout=TIMEOUT + 300)
|
||||
create_vm = self.run_cloud('-p vultr-test {0}'.format(self.instance_name), timeout=TIMEOUT + 300)
|
||||
self.assertIn(
|
||||
self.INSTANCE_NAME,
|
||||
self.instance_name,
|
||||
[i.strip() for i in create_vm]
|
||||
)
|
||||
self.assertNotIn('Failed to start', six.text_type(create_vm))
|
||||
|
|
|
@ -18,7 +18,7 @@ TIMEOUT = 500
|
|||
|
||||
class CloudTest(ShellCase):
|
||||
@property
|
||||
def INSTANCE_NAME(self):
|
||||
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()
|
||||
|
@ -27,33 +27,33 @@ class CloudTest(ShellCase):
|
|||
def _instance_exists(self):
|
||||
# salt-cloud -a show_instance myinstance
|
||||
query = self.run_cloud('--query')
|
||||
log.debug('INSTANCE EXISTS? {}: {}'.format(self.INSTANCE_NAME, query))
|
||||
return ' {0}:'.format(self.INSTANCE_NAME) in query
|
||||
log.debug('INSTANCE EXISTS? {}: {}'.format(self.instance_name, query))
|
||||
return ' {0}:'.format(self.instance_name) in query
|
||||
|
||||
def _destroy_instance(self):
|
||||
log.debug('Deleting instance "{}"'.format(self.INSTANCE_NAME))
|
||||
delete = self.run_cloud('-d {0} --assume-yes'.format(self.INSTANCE_NAME), timeout=TIMEOUT)
|
||||
print('Deleting instance "{}"'.format(self.instance_name))
|
||||
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)
|
||||
log.debug('Deletion status: {}'.format(delete_str))
|
||||
print('Deletion status: {}'.format(delete_str))
|
||||
|
||||
if any([x in delete_str for x in (
|
||||
'True',
|
||||
'was successfully deleted'
|
||||
)]):
|
||||
log.debug('Instance "{}" was successfully deleted'.format(self.INSTANCE_NAME))
|
||||
print('Instance "{}" was successfully deleted'.format(self.instance_name))
|
||||
elif any([x in delete_str for x in (
|
||||
'shutting-down',
|
||||
'.delete',
|
||||
)]):
|
||||
log.debug('Instance "{}" is cleaning up'.format(self.INSTANCE_NAME))
|
||||
print('Instance "{}" is cleaning up'.format(self.instance_name))
|
||||
sleep(60)
|
||||
else:
|
||||
log.error('Instance "{}" may not have been deleted properly'.format(self.INSTANCE_NAME))
|
||||
log.error('Instance "{}" may not have been deleted properly'.format(self.instance_name))
|
||||
|
||||
# By now it should all be over
|
||||
self.assertEqual(self._instance_exists(), False)
|
||||
log.debug('Instance "{}" no longer exists'.format(self.INSTANCE_NAME))
|
||||
print('Instance "{}" no longer exists'.format(self.instance_name))
|
||||
|
||||
def tearDown(self):
|
||||
'''
|
||||
|
|
|
@ -56,17 +56,17 @@ class CloudClientTestCase(CloudTest):
|
|||
# Create the VM using salt.cloud.CloudClient.create() instead of calling salt-cloud
|
||||
created = cloud_client.create(
|
||||
provider=self.provider_name,
|
||||
names=[self.INSTANCE_NAME],
|
||||
names=[self.instance_name],
|
||||
image=self.image_name,
|
||||
location='sfo1', size='512mb', vm_size='512mb'
|
||||
)
|
||||
|
||||
# Check that the VM was created correctly
|
||||
self.assertIn(self.INSTANCE_NAME, created)
|
||||
self.assertIn(self.instance_name, created)
|
||||
self.assertEqual(self._instance_exists(), True)
|
||||
|
||||
# Clean up after ourselves and delete the VM
|
||||
deleted = cloud_client.destroy(names=[self.INSTANCE_NAME])
|
||||
deleted = cloud_client.destroy(names=[self.instance_name])
|
||||
|
||||
# Check that the VM was deleted correctly
|
||||
self.assertIn(self.INSTANCE_NAME, deleted)
|
||||
self.assertIn(self.instance_name, deleted)
|
||||
|
|
Loading…
Add table
Reference in a new issue