Merge "Reworked scenario tests to use their own non-default security groups"

This commit is contained in:
Jenkins 2014-06-17 21:29:53 +00:00 committed by Gerrit Code Review
commit 1bca50c070
6 changed files with 42 additions and 41 deletions

View File

@ -289,6 +289,23 @@ class OfficialClientTest(tempest.test.BaseTestCase):
rules.append(sg_rule)
return rules
def _create_security_group_nova(self, client=None,
namestart='secgroup-smoke-'):
if client is None:
client = self.compute_client
# Create security group
sg_name = data_utils.rand_name(namestart)
sg_desc = sg_name + " description"
secgroup = client.security_groups.create(sg_name, sg_desc)
self.assertEqual(secgroup.name, sg_name)
self.assertEqual(secgroup.description, sg_desc)
self.set_resource(sg_name, secgroup)
# Add rules to the security group
self._create_loginable_secgroup_rule_nova(client, secgroup.id)
return secgroup
def create_server(self, client=None, name=None, image=None, flavor=None,
wait=True, create_kwargs={}):
if client is None:
@ -922,24 +939,6 @@ class NetworkScenarioTest(OfficialClientTest):
CONF.compute.ping_timeout,
1)
def _create_security_group_nova(self, client=None,
namestart='secgroup-smoke-',
tenant_id=None):
if client is None:
client = self.compute_client
# Create security group
sg_name = data_utils.rand_name(namestart)
sg_desc = sg_name + " description"
secgroup = client.security_groups.create(sg_name, sg_desc)
self.assertEqual(secgroup.name, sg_name)
self.assertEqual(secgroup.description, sg_desc)
self.set_resource(sg_name, secgroup)
# Add rules to the security group
self._create_loginable_secgroup_rule_nova(client, secgroup.id)
return secgroup
def _create_security_group_neutron(self, tenant_id, client=None,
namestart='secgroup-smoke-'):
if client is None:

View File

@ -112,6 +112,11 @@ class TestMinimumBasicScenario(manager.OfficialClientTest):
volume = self.volume_client.volumes.get(self.volume.id)
self.assertEqual('available', volume.status)
def create_and_add_security_group(self):
secgroup = self._create_security_group_nova()
self.server.add_security_group(secgroup.name)
self.addCleanup(self.server.remove_security_group, secgroup.name)
@test.services('compute', 'volume', 'image', 'network')
def test_minimum_basic_scenario(self):
self.glance_image_create()
@ -128,7 +133,7 @@ class TestMinimumBasicScenario(manager.OfficialClientTest):
self.nova_floating_ip_create()
self.nova_floating_ip_add()
self._create_loginable_secgroup_rule_nova()
self.create_and_add_security_group()
self.ssh_to_server()
self.nova_reboot()
self.ssh_to_server()

View File

@ -13,7 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from tempest.common.utils import data_utils
from tempest import config
from tempest.openstack.common import log as logging
from tempest.scenario import manager
@ -68,22 +67,12 @@ class TestServerBasicOps(manager.OfficialClientTest):
def add_keypair(self):
self.keypair = self.create_keypair()
def create_security_group(self):
sg_name = data_utils.rand_name('secgroup-smoke')
sg_desc = sg_name + " description"
self.secgroup = self.compute_client.security_groups.create(sg_name,
sg_desc)
self.assertEqual(self.secgroup.name, sg_name)
self.assertEqual(self.secgroup.description, sg_desc)
self.set_resource('secgroup', self.secgroup)
# Add rules to the security group
self._create_loginable_secgroup_rule_nova(secgroup_id=self.secgroup.id)
def boot_instance(self):
# Create server with image and flavor from input scenario
security_groups = [self.security_group.name]
create_kwargs = {
'key_name': self.keypair.id
'key_name': self.keypair.id,
'security_groups': security_groups
}
instance = self.create_server(image=self.image_ref,
flavor=self.flavor_ref,
@ -117,7 +106,7 @@ class TestServerBasicOps(manager.OfficialClientTest):
@test.services('compute', 'network')
def test_server_basicops(self):
self.add_keypair()
self.create_security_group()
self.security_group = self._create_security_group_nova()
self.boot_instance()
self.verify_ssh()
self.terminate_instance()

View File

@ -35,8 +35,10 @@ class TestSnapshotPattern(manager.OfficialClientTest):
"""
def _boot_image(self, image_id):
security_groups = [self.security_group.name]
create_kwargs = {
'key_name': self.keypair.name
'key_name': self.keypair.name,
'security_groups': security_groups
}
return self.create_server(image=image_id, create_kwargs=create_kwargs)
@ -72,7 +74,7 @@ class TestSnapshotPattern(manager.OfficialClientTest):
def test_snapshot_pattern(self):
# prepare for booting a instance
self._add_keypair()
self._create_loginable_secgroup_rule_nova()
self.security_group = self._create_security_group_nova()
# boot a instance and create a timestamp file in it
server = self._boot_image(CONF.compute.image_ref)

View File

@ -62,8 +62,10 @@ class TestStampPattern(manager.OfficialClientTest):
volume_snapshot.id, status)
def _boot_image(self, image_id):
security_groups = [self.security_group.name]
create_kwargs = {
'key_name': self.keypair.name
'key_name': self.keypair.name,
'security_groups': security_groups
}
return self.create_server(image=image_id, create_kwargs=create_kwargs)
@ -152,7 +154,7 @@ class TestStampPattern(manager.OfficialClientTest):
def test_stamp_pattern(self):
# prepare for booting a instance
self._add_keypair()
self._create_loginable_secgroup_rule_nova()
self.security_group = self._create_security_group_nova()
# boot an instance and create a timestamp file in it
volume = self._create_volume()

View File

@ -55,9 +55,11 @@ class TestVolumeBootPattern(manager.OfficialClientTest):
bd_map = {
'vda': vol_id + ':::0'
}
security_groups = [self.security_group.name]
create_kwargs = {
'block_device_mapping': bd_map,
'key_name': keypair.name
'key_name': keypair.name,
'security_groups': security_groups
}
return self.create_server(image='', create_kwargs=create_kwargs)
@ -135,7 +137,7 @@ class TestVolumeBootPattern(manager.OfficialClientTest):
@test.services('compute', 'volume', 'image')
def test_volume_boot_pattern(self):
keypair = self.create_keypair()
self._create_loginable_secgroup_rule_nova()
self.security_group = self._create_security_group_nova()
# create an instance from volume
volume_origin = self._create_volume_from_image()
@ -182,8 +184,10 @@ class TestVolumeBootPatternV2(TestVolumeBootPattern):
bdms = [{'uuid': vol_id, 'source_type': 'volume',
'destination_type': 'volume', 'boot_index': 0,
'delete_on_termination': False}]
security_groups = [self.security_group.name]
create_kwargs = {
'block_device_mapping_v2': bdms,
'key_name': keypair.name
'key_name': keypair.name,
'security_groups': security_groups
}
return self.create_server(image='', create_kwargs=create_kwargs)