def setUpClass(cls): cls.config = config.TempestConfig() cls.isolated_creds = [] if cls.config.compute.allow_tenant_isolation: creds = cls._get_isolated_creds() username, tenant_name, password = creds os = openstack.Manager(username=username, password=password, tenant_name=tenant_name) else: os = openstack.Manager() cls.os = os cls.volumes_client = os.volumes_client cls.servers_client = os.servers_client cls.image_ref = cls.config.compute.image_ref cls.flavor_ref = cls.config.compute.flavor_ref cls.build_interval = cls.config.volume.build_interval cls.build_timeout = cls.config.volume.build_timeout cls.volumes = {} skip_msg = ("%s skipped as Cinder endpoint is not available" % cls.__name__) try: cls.volumes_client.keystone_auth(cls.os.username, cls.os.password, cls.os.auth_url, cls.volumes_client.service, cls.os.tenant_name) except exceptions.EndpointNotFound: cls.clear_isolated_creds() raise nose.SkipTest(skip_msg)
def setUpClass(cls): cls.config = config.TempestConfig() cls.isolated_creds = [] if cls.config.compute.allow_tenant_isolation: creds = cls._get_isolated_creds() username, tenant_name, password = creds os = openstack.Manager(username=username, password=password, tenant_name=tenant_name, interface=cls._interface) else: os = openstack.Manager(interface=cls._interface) cls.os = os cls.servers_client = os.servers_client cls.flavors_client = os.flavors_client cls.images_client = os.images_client cls.extensions_client = os.extensions_client cls.floating_ips_client = os.floating_ips_client cls.keypairs_client = os.keypairs_client cls.security_groups_client = os.security_groups_client cls.console_outputs_client = os.console_outputs_client cls.quotas_client = os.quotas_client cls.limits_client = os.limits_client cls.volumes_extensions_client = os.volumes_extensions_client cls.volumes_client = os.volumes_client cls.build_interval = cls.config.compute.build_interval cls.build_timeout = cls.config.compute.build_timeout cls.ssh_user = cls.config.compute.ssh_user cls.image_ref = cls.config.compute.image_ref cls.image_ref_alt = cls.config.compute.image_ref_alt cls.flavor_ref = cls.config.compute.flavor_ref cls.flavor_ref_alt = cls.config.compute.flavor_ref_alt cls.servers = []
def setUpClass(cls): cls.os = openstack.Manager() cls.client = cls.os.servers_client cls.config = cls.os.config cls.image_ref = cls.config.env.image_ref cls.flavor_ref = cls.config.env.flavor_ref cls.ssh_timeout = cls.config.nova.ssh_timeout
def setUpClass(cls): cls.os = openstack.Manager() cls.client = cls.os.servers_client cls.config = cls.os.config cls.image_ref = cls.config.env.image_ref cls.flavor_ref = cls.config.env.flavor_ref cls.image_ref_alt = cls.config.env.image_ref_alt cls.flavor_ref_alt = cls.config.env.flavor_ref_alt cls.s1_name = rand_name('server') resp, server = cls.client.create_server(cls.s1_name, cls.image_ref, cls.flavor_ref) cls.client.wait_for_server_status(server['id'], 'ACTIVE') resp, cls.s1 = cls.client.get_server(server['id']) cls.s2_name = rand_name('server') resp, server = cls.client.create_server(cls.s2_name, cls.image_ref_alt, cls.flavor_ref) cls.client.wait_for_server_status(server['id'], 'ACTIVE') resp, cls.s2 = cls.client.get_server(server['id']) cls.s3_name = rand_name('server') resp, server = cls.client.create_server(cls.s3_name, cls.image_ref, cls.flavor_ref_alt) cls.client.wait_for_server_status(server['id'], 'ACTIVE') resp, cls.s3 = cls.client.get_server(server['id'])
def setUpClass(cls): cls.os = openstack.Manager() cls.client = cls.os.servers_client cls.config = cls.config = cls.os.config cls.image_ref = cls.config.env.image_ref cls.flavor_ref = cls.config.env.flavor_ref cls.user_client = cls.os.limits_client
def setUpClass(cls): cls.os = openstack.Manager() cls.client = cls.os.images_client cls.servers_client = cls.os.servers_client cls.config = cls.os.config cls.image_ref = cls.config.env.image_ref cls.flavor_ref = cls.config.env.flavor_ref cls.create_image_enabled = cls.config.env.create_image_enabled
def setUpClass(cls): cls.os = openstack.Manager() cls.client = cls.os.servers_client cls.config = cls.os.config cls.image_ref = cls.config.compute.image_ref cls.flavor_ref = cls.config.compute.flavor_ref cls.login_name = cls.config.compute.login_name cls.pswd = cls.config.compute.pswd
def setUpClass(cls): super(InstanceRunTest, cls).setUpClass() if not tempest.tests.boto.A_I_IMAGES_READY: raise nose.SkipTest("".join( ("EC2 ", cls.__name__, ": requires ami/aki/ari manifest"))) cls.os = openstack.Manager() cls.s3_client = cls.os.s3_client cls.ec2_client = cls.os.ec2api_client config = cls.os.config cls.zone = cls.ec2_client.get_good_zone() cls.materials_path = config.boto.s3_materials_path ami_manifest = config.boto.ami_manifest aki_manifest = config.boto.aki_manifest ari_manifest = config.boto.ari_manifest cls.instance_type = config.boto.instance_type cls.bucket_name = rand_name("s3bucket-") cls.keypair_name = rand_name("keypair-") cls.keypair = cls.ec2_client.create_key_pair(cls.keypair_name) cls.addResourceCleanUp(cls.ec2_client.delete_key_pair, cls.keypair_name) bucket = cls.s3_client.create_bucket(cls.bucket_name) cls.addResourceCleanUp(cls.destroy_bucket, cls.s3_client.connection_data, cls.bucket_name) s3_upload_dir(bucket, cls.materials_path) cls.images = { "ami": { "name": rand_name("ami-name-"), "location": cls.bucket_name + "/" + ami_manifest }, "aki": { "name": rand_name("aki-name-"), "location": cls.bucket_name + "/" + aki_manifest }, "ari": { "name": rand_name("ari-name-"), "location": cls.bucket_name + "/" + ari_manifest } } for image in cls.images.itervalues(): image["image_id"] = cls.ec2_client.register_image( name=image["name"], image_location=image["location"]) cls.addResourceCleanUp(cls.ec2_client.deregister_image, image["image_id"]) for image in cls.images.itervalues(): def _state(): retr = cls.ec2_client.get_image(image["image_id"]) return retr.state state = state_wait(_state, "available") if state != "available": for _image in cls.images.itervalues(): ec2_client.deregister_image(_image["image_id"]) raise RegisterImageException(image_id=image["image_id"])
def setUpClass(cls): cls.os = openstack.Manager() cls.object_client = cls.os.object_client cls.container_client = cls.os.container_client cls.account_client = cls.os.account_client cls.config = cls.os.config try: cls.account_client.list_account_containers() except exceptions.EndpointNotFound: enabled = False skip_msg = "No OpenStack Object Storage API endpoint" raise nose.SkipTest(skip_msg)
def setUpClass(cls): os = openstack.Manager() client = os.network_client config = os.config networks = [] enabled = True # Validate that there is even an endpoint configured # for networks, and mark the attr for skipping if not try: client.list_networks() except exceptions.EndpointNotFound: enabled = False skip_msg = "No OpenStack Network API endpoint" raise nose.SkipTest(skip_msg)
def setUpClass(cls): super(ServerDetailsNegativeTest, cls).setUpClass() cls.client = cls.servers_client cls.servers = [] if compute.MULTI_USER: if cls.config.compute.allow_tenant_isolation: creds = cls._get_isolated_creds() username, tenant_name, password = creds cls.alt_manager = openstack.Manager(username=username, password=password, tenant_name=tenant_name) else: # Use the alt_XXX credentials in the config file cls.alt_manager = openstack.AltManager() cls.alt_client = cls.alt_manager.servers_client
def setUpClass(cls): cls.os = openstack.Manager() cls.client = cls.os.servers_client cls.config = cls.os.config cls.image_ref = cls.config.env.image_ref cls.flavor_ref = cls.config.env.flavor_ref #Create a server to be used for all read only tests name = rand_name('server') resp, server = cls.client.create_server(name, cls.image_ref, cls.flavor_ref, meta={}) cls.server_id = server['id'] #Wait for the server to become active cls.client.wait_for_server_status(cls.server_id, 'ACTIVE')
def setup_package(): LOG.debug("Entering tempest.tests.compute.setup_package") global MULTI_USER, DISK_CONFIG_ENABLED, FLAVOR_EXTRA_DATA_ENABLED os = openstack.Manager() images_client = os.images_client flavors_client = os.flavors_client extensions_client = os.extensions_client DISK_CONFIG_ENABLED = extensions_client.is_enabled('DiskConfig') FLAVOR_EXTRA_DATA_ENABLED = extensions_client.is_enabled('FlavorExtraData') # Validate reference data exists # If not, we raise the exception here and prevent # going forward... try: image_ref = CONFIG.compute.image_ref image_ref_alt = CONFIG.compute.image_ref_alt images_client.get_image(image_ref) images_client.get_image(image_ref_alt) flavor_ref = CONFIG.compute.flavor_ref flavor_ref_alt = CONFIG.compute.flavor_ref_alt flavors_client.get_flavor_details(flavor_ref) flavors_client.get_flavor_details(flavor_ref_alt) except Exception as e: msg = "Failed basic configuration: %s" % e raise nose.SkipTest(msg) # Determine if there are two regular users that can be # used in testing. If the test cases are allowed to create # users (config.compute.allow_tenant_isolation is true, # then we allow multi-user. if CONFIG.compute.allow_tenant_isolation: MULTI_USER = True else: user1 = CONFIG.compute.username user2 = CONFIG.compute.alt_username if user2 and user1 != user2: user2_password = CONFIG.compute.alt_password user2_tenant_name = CONFIG.compute.alt_tenant_name if not user2_password or user2_tenant_name: msg = ("Alternate user specified but not alternate " "tenant or password") % e raise nose.SkipTest(msg) MULTI_USER = True
def __init__(self, username=None, password=None, tenant_name=None): self.username = username or 'admin' self.password = password or 'crowbar' self.tenant_name = tenant_name or 'admin' self.os = openstack.Manager(self.username, self.password, self.tenant_name) self.servers_client = self.os.servers_client self.images_client = self.os.images_client self.flavors_client = self.os.flavors_client self.volumes_client = self.os.volumes_client self.config = self.os.config self.flavor_ref = self.config.compute.flavor_ref self.auth_url = self.config.identity.auth_url self.token = self._get_user_token()
def setUpClass(cls): raise nose.SkipTest("Until Bug 1046870 is fixed") super(ImagesTestXML, cls).setUpClass() cls.client = cls.images_client cls.servers_client = cls.servers_client cls.image_ids = [] if compute.MULTI_USER: if cls.config.compute.allow_tenant_isolation: creds = cls._get_isolated_creds() username, tenant_name, password = creds cls.alt_manager = openstack.Manager(username=username, password=password, tenant_name=tenant_name) else: # Use the alt_XXX credentials in the config file cls.alt_manager = openstack.AltManager() cls.alt_client = cls.alt_manager.images_client
def setUpClass(cls): cls.os = openstack.Manager() cls.client = cls.os.images_client cls.servers_client = cls.os.servers_client cls.config = cls.os.config cls.image_ref = cls.config.env.image_ref cls.flavor_ref = cls.config.env.flavor_ref name = rand_name('server') resp, cls.server1 = cls.servers_client.create_server(name, cls.image_ref, cls.flavor_ref) cls.servers_client.wait_for_server_status(cls.server1['id'], 'ACTIVE') name = rand_name('server') resp, cls.server2 = cls.servers_client.create_server(name, cls.image_ref, cls.flavor_ref) cls.servers_client.wait_for_server_status(cls.server2['id'], 'ACTIVE') #Create images to be used in the filter tests image1_name = rand_name('image') resp, body = cls.client.create_image(cls.server1['id'], image1_name) cls.image1_id = _parse_image_id(resp['location']) cls.client.wait_for_image_resp_code(cls.image1_id, 200) cls.client.wait_for_image_status(cls.image1_id, 'ACTIVE') resp, cls.image1 = cls.client.get_image(cls.image1_id) image2_name = rand_name('image') resp, body = cls.client.create_image(cls.server1['id'], image2_name) cls.image2_id = _parse_image_id(resp['location']) cls.client.wait_for_image_resp_code(cls.image2_id, 200) cls.client.wait_for_image_status(cls.image2_id, 'ACTIVE') resp, cls.image2 = cls.client.get_image(cls.image2_id) image3_name = rand_name('image') resp, body = cls.client.create_image(cls.server2['id'], image3_name) cls.image3_id = _parse_image_id(resp['location']) cls.client.wait_for_image_resp_code(cls.image3_id, 200) cls.client.wait_for_image_status(cls.image3_id, 'ACTIVE') resp, cls.image3 = cls.client.get_image(cls.image3_id)
def setUpClass(cls): super(S3ImagesTest, cls).setUpClass() if not tempest.tests.boto.A_I_IMAGES_READY: raise nose.SkipTest("".join( ("EC2 ", cls.__name__, ": requires ami/aki/ari manifest"))) cls.os = openstack.Manager() cls.s3_client = cls.os.s3_client cls.images_client = cls.os.ec2api_client config = cls.os.config cls.materials_path = config.boto.s3_materials_path cls.ami_manifest = config.boto.ami_manifest cls.aki_manifest = config.boto.aki_manifest cls.ari_manifest = config.boto.ari_manifest cls.ami_path = cls.materials_path + os.sep + cls.ami_manifest cls.aki_path = cls.materials_path + os.sep + cls.aki_manifest cls.ari_path = cls.materials_path + os.sep + cls.ari_manifest cls.bucket_name = rand_name("bucket-") bucket = cls.s3_client.create_bucket(cls.bucket_name) cls.addResourceCleanUp(cls.destroy_bucket, cls.s3_client.connection_data, cls.bucket_name) s3_upload_dir(bucket, cls.materials_path)
def setUpClass(cls): cls.os = openstack.Manager() cls.servers_client = cls.os.servers_client cls.client = cls.os.images_client cls.config = cls.os.config cls.image_ref = cls.config.env.image_ref cls.flavor_ref = cls.config.env.flavor_ref cls.ssh_timeout = cls.config.nova.ssh_timeout name = rand_name('server') resp, server = cls.servers_client.create_server( name, cls.image_ref, cls.flavor_ref) cls.server_id = server['id'] #Wait for the server to become active cls.servers_client.wait_for_server_status(cls.server_id, 'ACTIVE') # Snapshot the server once to save time name = rand_name('image') resp, _ = cls.client.create_image(cls.server_id, name, {}) cls.image_id = resp['location'].rsplit('/', 1)[1] cls.client.wait_for_image_resp_code(cls.image_id, 200) cls.client.wait_for_image_status(cls.image_id, 'ACTIVE')
# you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Stress test that associates/disasssociates floating ips""" # local imports from stress.test_floating_ips import TestChangeFloatingIp from stress.basher import BasherAction from stress.driver import * from tempest import openstack choice_spec = [ BasherAction(TestChangeFloatingIp(), 100) ] nova = openstack.Manager() bash_openstack(nova, choice_spec, duration=datetime.timedelta(seconds=300), test_name="floating_ips", initial_floating_ips=8, initial_vms=8)
def setUpClass(cls): super(EC2VolumesTest, cls).setUpClass() cls.os = openstack.Manager() cls.client = cls.os.ec2api_client cls.zone = cls.client.get_good_zone()
def setUpClass(cls): cls.os = openstack.Manager() cls.client = cls.os.extensions_client cls.config = cls.os.config
def setUpClass(cls): super(EC2KeysTest, cls).setUpClass() cls.os = openstack.Manager() cls.client = cls.os.ec2api_client
def setUpClass(cls): cls.os = openstack.Manager() cls.client = cls.os.flavors_client cls.config = cls.os.config cls.flavor_id = cls.config.compute.flavor_ref
def setUpClass(cls): super(S3BucketsTest, cls).setUpClass() cls.os = openstack.Manager() cls.client = cls.os.s3_client cls.config = cls.os.config
def setUpClass(cls): if not compute.MULTI_USER: msg = "Need >1 user" raise nose.SkipTest(msg) super(AuthorizationTest, cls).setUpClass() cls.client = cls.os.servers_client cls.images_client = cls.os.images_client cls.keypairs_client = cls.os.keypairs_client cls.security_client = cls.os.security_groups_client cls.console_outputs_client = cls.os.console_outputs_client if cls.config.compute.allow_tenant_isolation: creds = cls._get_isolated_creds() username, tenant_name, password = creds cls.alt_manager = openstack.Manager(username=username, password=password, tenant_name=tenant_name) else: # Use the alt_XXX credentials in the config file cls.alt_manager = openstack.AltManager() cls.alt_client = cls.alt_manager.servers_client cls.alt_images_client = cls.alt_manager.images_client cls.alt_keypairs_client = cls.alt_manager.keypairs_client cls.alt_security_client = cls.alt_manager.security_groups_client cls.alt_console_outputs_client = cls.alt_manager.console_outputs_client cls.alt_security_client._set_auth() name = rand_name('server') resp, server = cls.client.create_server(name, cls.image_ref, cls.flavor_ref) cls.client.wait_for_server_status(server['id'], 'ACTIVE') resp, cls.server = cls.client.get_server(server['id']) name = rand_name('image') resp, body = cls.client.create_image(server['id'], name) image_id = parse_image_id(resp['location']) cls.images_client.wait_for_image_resp_code(image_id, 200) cls.images_client.wait_for_image_status(image_id, 'ACTIVE') resp, cls.image = cls.images_client.get_image(image_id) cls.keypairname = rand_name('keypair') resp, keypair = \ cls.keypairs_client.create_keypair(cls.keypairname) name = rand_name('security') description = rand_name('description') resp, cls.security_group = \ cls.security_client.create_security_group(name, description) parent_group_id = cls.security_group['id'] ip_protocol = 'tcp' from_port = 22 to_port = 22 resp, cls.rule =\ cls.security_client.create_security_group_rule(\ parent_group_id, ip_protocol, from_port, to_port)
return parser if __name__ == '__main__': args = get_argparser().parse_args() process = subprocess.Popen([ 'nosetests', '-q', '-w', args.w_dir, " ".join(args.tests), '--with-xunit', '--xunit-file=/dev/stdout' ], stdout=subprocess.PIPE, stderr=subprocess.PIPE) out, err = process.communicate() print out logging.basicConfig() logging.disable('ERROR') os = openstack.Manager() client = os.floating_ips_client resp, data = client.list_floating_ips() #TODO:agordeev #take care of response statuses for ip in data: if ip['instance_id']: client.disassociate_floating_ip_from_server( ip['ip'], ip['instance_id']) client.delete_floating_ip(ip['id']) client = os.volumes_client resp, data = client.list_volumes() for vol in data: if vol['status'] in ('error', 'available'): client.delete_volume(vol['id']) try:
def setUpClass(cls): super(EC2SecurityGroupTest, cls).setUpClass() cls.os = openstack.Manager() cls.client = cls.os.ec2api_client
def setUpClass(cls): super(ListServersNegativeTest, cls).setUpClass() cls.client = cls.servers_client cls.servers = [] if compute.MULTI_USER: if cls.config.compute.allow_tenant_isolation: creds = cls._get_isolated_creds() username, tenant_name, password = creds cls.alt_manager = openstack.Manager(username=username, password=password, tenant_name=tenant_name) else: # Use the alt_XXX credentials in the config file cls.alt_manager = openstack.AltManager() cls.alt_client = cls.alt_manager.servers_client # Under circumstances when there is not a tenant/user # created for the test case, the test case checks # to see if there are existing servers for the # either the normal user/tenant or the alt user/tenant # and if so, the whole test is skipped. We do this # because we assume a baseline of no servers at the # start of the test instead of destroying any existing # servers. resp, body = cls.client.list_servers() servers = body['servers'] num_servers = len(servers) if num_servers > 0: username = cls.os.username tenant_name = cls.os.tenant_name msg = ("User/tenant %(username)s/%(tenant_name)s already have " "existing server instances. Skipping test.") % locals() raise nose.SkipTest(msg) resp, body = cls.alt_client.list_servers() servers = body['servers'] num_servers = len(servers) if num_servers > 0: username = cls.alt_manager.username tenant_name = cls.alt_manager.tenant_name msg = ("Alt User/tenant %(username)s/%(tenant_name)s already have " "existing server instances. Skipping test.") % locals() raise nose.SkipTest(msg) # The following servers are created for use # by the test methods in this class. These # servers are cleaned up automatically in the # tearDownClass method of the super-class. cls.existing_fixtures = [] cls.deleted_fixtures = [] for x in xrange(2): srv = cls.create_server() cls.existing_fixtures.append(srv) srv = cls.create_server() cls.client.delete_server(srv['id']) # We ignore errors on termination because the server may # be put into ERROR status on a quick spawn, then delete, # as the compute node expects the instance local status # to be spawning, not deleted. See LP Bug#1061167 cls.client.wait_for_server_termination(srv['id'], ignore_error=True) cls.deleted_fixtures.append(srv)