Merge "Migrate volume API tests to resource_* fixtures"
diff --git a/tempest/api/compute/security_groups/test_security_group_rules.py b/tempest/api/compute/security_groups/test_security_group_rules.py
index b28124c..901c377 100644
--- a/tempest/api/compute/security_groups/test_security_group_rules.py
+++ b/tempest/api/compute/security_groups/test_security_group_rules.py
@@ -28,6 +28,13 @@
cls.client = cls.security_groups_client
cls.neutron_available = CONF.service_available.neutron
+ @classmethod
+ def setUpClass(self):
+ super(SecurityGroupRulesTestJSON, self).setUpClass()
+ self.ip_protocol = 'tcp'
+ self.from_port = 22
+ self.to_port = 22
+
@test.attr(type='smoke')
@test.services('network')
def test_security_group_rules_create(self):
@@ -37,14 +44,11 @@
resp, security_group = self.create_security_group()
securitygroup_id = security_group['id']
# Adding rules to the created Security Group
- ip_protocol = 'tcp'
- from_port = 22
- to_port = 22
resp, rule = \
self.client.create_security_group_rule(securitygroup_id,
- ip_protocol,
- from_port,
- to_port)
+ self.ip_protocol,
+ self.from_port,
+ self.to_port)
self.addCleanup(self.client.delete_security_group_rule, rule['id'])
self.assertEqual(200, resp.status)
@@ -65,16 +69,13 @@
secgroup2 = security_group['id']
# Adding rules to the created Security Group with optional arguments
parent_group_id = secgroup1
- ip_protocol = 'tcp'
- from_port = 22
- to_port = 22
cidr = '10.2.3.124/24'
group_id = secgroup2
resp, rule = \
self.client.create_security_group_rule(parent_group_id,
- ip_protocol,
- from_port,
- to_port,
+ self.ip_protocol,
+ self.from_port,
+ self.to_port,
cidr=cidr,
group_id=group_id)
self.assertEqual(200, resp.status)
@@ -89,13 +90,11 @@
securitygroup_id = security_group['id']
# Add a first rule to the created Security Group
- ip_protocol1 = 'tcp'
- from_port1 = 22
- to_port1 = 22
resp, rule = \
self.client.create_security_group_rule(securitygroup_id,
- ip_protocol1,
- from_port1, to_port1)
+ self.ip_protocol,
+ self.from_port,
+ self.to_port)
rule1_id = rule['id']
# Add a second rule to the created Security Group
@@ -127,14 +126,11 @@
resp, security_group = self.create_security_group()
sg2_id = security_group['id']
# Adding rules to the Group1
- ip_protocol = 'tcp'
- from_port = 22
- to_port = 22
resp, rule = \
self.client.create_security_group_rule(sg1_id,
- ip_protocol,
- from_port,
- to_port,
+ self.ip_protocol,
+ self.from_port,
+ self.to_port,
group_id=sg2_id)
self.assertEqual(200, resp.status)
diff --git a/tempest/api/compute/servers/test_list_server_filters.py b/tempest/api/compute/servers/test_list_server_filters.py
index 6032976..98fe387 100644
--- a/tempest/api/compute/servers/test_list_server_filters.py
+++ b/tempest/api/compute/servers/test_list_server_filters.py
@@ -233,6 +233,30 @@
self.assertNotIn(self.s3_name, map(lambda x: x['name'], servers))
@test.attr(type='gate')
+ def test_list_servers_filtered_by_name_regex(self):
+ # list of regex that should match s1, s2 and s3
+ regexes = ['^.*\-instance\-[0-9]+$', '^.*\-instance\-.*$']
+ for regex in regexes:
+ params = {'name': regex}
+ resp, body = self.client.list_servers(params)
+ servers = body['servers']
+
+ self.assertIn(self.s1_name, map(lambda x: x['name'], servers))
+ self.assertIn(self.s2_name, map(lambda x: x['name'], servers))
+ self.assertIn(self.s3_name, map(lambda x: x['name'], servers))
+
+ # Let's take random part of name and try to search it
+ part_name = self.s1_name[-10:]
+
+ params = {'name': part_name}
+ resp, body = self.client.list_servers(params)
+ servers = body['servers']
+
+ self.assertIn(self.s1_name, map(lambda x: x['name'], servers))
+ self.assertNotIn(self.s2_name, map(lambda x: x['name'], servers))
+ self.assertNotIn(self.s3_name, map(lambda x: x['name'], servers))
+
+ @test.attr(type='gate')
def test_list_servers_filtered_by_ip(self):
# Filter servers by ip
# Here should be listed 1 server
diff --git a/tempest/api/compute/servers/test_server_actions.py b/tempest/api/compute/servers/test_server_actions.py
index 071bbfb..3aacf2a 100644
--- a/tempest/api/compute/servers/test_server_actions.py
+++ b/tempest/api/compute/servers/test_server_actions.py
@@ -75,9 +75,7 @@
new_password)
linux_client.validate_authentication()
- @test.attr(type='smoke')
- def test_reboot_server_hard(self):
- # The server should be power cycled
+ def _test_reboot_server(self, reboot_type):
if self.run_ssh:
# Get the time the server was last rebooted,
resp, server = self.client.get_server(self.server_id)
@@ -85,7 +83,7 @@
self.password)
boot_time = linux_client.get_boot_time()
- resp, body = self.client.reboot(self.server_id, 'HARD')
+ resp, body = self.client.reboot(self.server_id, reboot_type)
self.assertEqual(202, resp.status)
self.client.wait_for_server_status(self.server_id, 'ACTIVE')
@@ -97,28 +95,16 @@
self.assertTrue(new_boot_time > boot_time,
'%s > %s' % (new_boot_time, boot_time))
+ @test.attr(type='smoke')
+ def test_reboot_server_hard(self):
+ # The server should be power cycled
+ self._test_reboot_server('HARD')
+
@test.skip_because(bug="1014647")
@test.attr(type='smoke')
def test_reboot_server_soft(self):
# The server should be signaled to reboot gracefully
- if self.run_ssh:
- # Get the time the server was last rebooted,
- resp, server = self.client.get_server(self.server_id)
- linux_client = remote_client.RemoteClient(server, self.ssh_user,
- self.password)
- boot_time = linux_client.get_boot_time()
-
- resp, body = self.client.reboot(self.server_id, 'SOFT')
- self.assertEqual(202, resp.status)
- self.client.wait_for_server_status(self.server_id, 'ACTIVE')
-
- if self.run_ssh:
- # Log in and verify the boot time has changed
- linux_client = remote_client.RemoteClient(server, self.ssh_user,
- self.password)
- new_boot_time = linux_client.get_boot_time()
- self.assertTrue(new_boot_time > boot_time,
- '%s > %s' % (new_boot_time, boot_time))
+ self._test_reboot_server('SOFT')
@test.attr(type='smoke')
def test_rebuild_server(self):
diff --git a/tempest/api/network/common.py b/tempest/api/network/common.py
deleted file mode 100644
index 5ac8b5a..0000000
--- a/tempest/api/network/common.py
+++ /dev/null
@@ -1,157 +0,0 @@
-# Copyright 2013 Hewlett-Packard Development Company, L.P.
-# All Rights Reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); 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.
-
-import abc
-
-import six
-
-
-class AttributeDict(dict):
-
- """
- Provide attribute access (dict.key) to dictionary values.
- """
-
- def __getattr__(self, name):
- """Allow attribute access for all keys in the dict."""
- if name in self:
- return self[name]
- return super(AttributeDict, self).__getattribute__(name)
-
-
-@six.add_metaclass(abc.ABCMeta)
-class DeletableResource(AttributeDict):
-
- """
- Support deletion of neutron resources (networks, subnets) via a
- delete() method, as is supported by keystone and nova resources.
- """
-
- def __init__(self, *args, **kwargs):
- self.client = kwargs.pop('client', None)
- super(DeletableResource, self).__init__(*args, **kwargs)
-
- def __str__(self):
- return '<%s id="%s" name="%s">' % (self.__class__.__name__,
- self.id, self.name)
-
- @abc.abstractmethod
- def delete(self):
- return
-
- def __hash__(self):
- return id(self)
-
-
-class DeletableNetwork(DeletableResource):
-
- def delete(self):
- self.client.delete_network(self.id)
-
-
-class DeletableSubnet(DeletableResource):
-
- def __init__(self, *args, **kwargs):
- super(DeletableSubnet, self).__init__(*args, **kwargs)
- self._router_ids = set()
-
- def update(self, *args, **kwargs):
- body = dict(subnet=dict(*args, **kwargs))
- result = self.client.update_subnet(subnet=self.id, body=body)
- super(DeletableSubnet, self).update(**result['subnet'])
-
- def add_to_router(self, router_id):
- self._router_ids.add(router_id)
- body = dict(subnet_id=self.id)
- self.client.add_interface_router(router_id, body=body)
-
- def delete(self):
- for router_id in self._router_ids.copy():
- body = dict(subnet_id=self.id)
- self.client.remove_interface_router(router_id, body=body)
- self._router_ids.remove(router_id)
- self.client.delete_subnet(self.id)
-
-
-class DeletableRouter(DeletableResource):
-
- def add_gateway(self, network_id):
- body = dict(network_id=network_id)
- self.client.add_gateway_router(self.id, body=body)
-
- def delete(self):
- self.client.remove_gateway_router(self.id)
- self.client.delete_router(self.id)
-
-
-class DeletableFloatingIp(DeletableResource):
-
- def update(self, *args, **kwargs):
- result = self.client.update_floatingip(floatingip=self.id,
- body=dict(
- floatingip=dict(*args,
- **kwargs)
- ))
- super(DeletableFloatingIp, self).update(**result['floatingip'])
-
- def __repr__(self):
- return '<%s addr="%s">' % (self.__class__.__name__,
- self.floating_ip_address)
-
- def __str__(self):
- return '<"FloatingIP" addr="%s" id="%s">' % (self.floating_ip_address,
- self.id)
-
- def delete(self):
- self.client.delete_floatingip(self.id)
-
-
-class DeletablePort(DeletableResource):
-
- def delete(self):
- self.client.delete_port(self.id)
-
-
-class DeletableSecurityGroup(DeletableResource):
-
- def delete(self):
- self.client.delete_security_group(self.id)
-
-
-class DeletableSecurityGroupRule(DeletableResource):
-
- def __repr__(self):
- return '<%s id="%s">' % (self.__class__.__name__, self.id)
-
- def delete(self):
- self.client.delete_security_group_rule(self.id)
-
-
-class DeletablePool(DeletableResource):
-
- def delete(self):
- self.client.delete_pool(self.id)
-
-
-class DeletableMember(DeletableResource):
-
- def delete(self):
- self.client.delete_member(self.id)
-
-
-class DeletableVip(DeletableResource):
-
- def delete(self):
- self.client.delete_vip(self.id)
diff --git a/tempest/api/orchestration/stacks/test_update.py b/tempest/api/orchestration/stacks/test_update.py
deleted file mode 100644
index 98761ac..0000000
--- a/tempest/api/orchestration/stacks/test_update.py
+++ /dev/null
@@ -1,82 +0,0 @@
-# Licensed under the Apache License, Version 2.0 (the "License"); 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.
-
-import logging
-
-from tempest.api.orchestration import base
-from tempest.common.utils import data_utils
-from tempest import test
-
-
-LOG = logging.getLogger(__name__)
-
-
-class UpdateStackTestJSON(base.BaseOrchestrationTest):
- _interface = 'json'
-
- template = '''
-heat_template_version: 2013-05-23
-resources:
- random1:
- type: OS::Heat::RandomString
-'''
- update_template = '''
-heat_template_version: 2013-05-23
-resources:
- random1:
- type: OS::Heat::RandomString
- random2:
- type: OS::Heat::RandomString
-'''
-
- def update_stack(self, stack_identifier, template):
- stack_name = stack_identifier.split('/')[0]
- self.client.update_stack(
- stack_identifier=stack_identifier,
- name=stack_name,
- template=template)
- self.client.wait_for_stack_status(stack_identifier, 'UPDATE_COMPLETE')
-
- @test.attr(type='gate')
- def test_stack_update_nochange(self):
- stack_name = data_utils.rand_name('heat')
- stack_identifier = self.create_stack(stack_name, self.template)
- self.client.wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE')
- expected_resources = {'random1': 'OS::Heat::RandomString'}
- self.assertEqual(expected_resources,
- self.list_resources(stack_identifier))
-
- # Update with no changes, resources should be unchanged
- self.update_stack(stack_identifier, self.template)
- self.assertEqual(expected_resources,
- self.list_resources(stack_identifier))
-
- @test.attr(type='gate')
- def test_stack_update_add_remove(self):
- stack_name = data_utils.rand_name('heat')
- stack_identifier = self.create_stack(stack_name, self.template)
- self.client.wait_for_stack_status(stack_identifier, 'CREATE_COMPLETE')
- initial_resources = {'random1': 'OS::Heat::RandomString'}
- self.assertEqual(initial_resources,
- self.list_resources(stack_identifier))
-
- # Add one resource via a stack update
- self.update_stack(stack_identifier, self.update_template)
- updated_resources = {'random1': 'OS::Heat::RandomString',
- 'random2': 'OS::Heat::RandomString'}
- self.assertEqual(updated_resources,
- self.list_resources(stack_identifier))
-
- # Then remove it by updating with the original template
- self.update_stack(stack_identifier, self.template)
- self.assertEqual(initial_resources,
- self.list_resources(stack_identifier))
diff --git a/tempest/auth.py b/tempest/auth.py
index c84ad6b..b1ead29 100644
--- a/tempest/auth.py
+++ b/tempest/auth.py
@@ -40,11 +40,9 @@
Provide authentication
"""
- def __init__(self, credentials, client_type='tempest',
- interface=None):
+ def __init__(self, credentials, interface=None):
"""
:param credentials: credentials for authentication
- :param client_type: 'tempest' or 'official'
:param interface: 'json' or 'xml'. Applicable for tempest client only
"""
credentials = self._convert_credentials(credentials)
@@ -52,9 +50,8 @@
self.credentials = credentials
else:
raise TypeError("Invalid credentials")
- self.client_type = client_type
self.interface = interface
- if self.client_type == 'tempest' and self.interface is None:
+ if self.interface is None:
self.interface = 'json'
self.cache = None
self.alt_auth_data = None
@@ -68,11 +65,10 @@
return credentials
def __str__(self):
- return "Creds :{creds}, client type: {client_type}, interface: " \
- "{interface}, cached auth data: {cache}".format(
- creds=self.credentials, client_type=self.client_type,
- interface=self.interface, cache=self.cache
- )
+ return "Creds :{creds}, interface: {interface}, " \
+ "cached auth data: {cache}".format(
+ creds=self.credentials, interface=self.interface,
+ cache=self.cache)
@abc.abstractmethod
def _decorate_request(self, filters, method, url, headers=None, body=None,
@@ -208,9 +204,8 @@
token_expiry_threshold = datetime.timedelta(seconds=60)
- def __init__(self, credentials, client_type='tempest', interface=None):
- super(KeystoneAuthProvider, self).__init__(credentials, client_type,
- interface)
+ def __init__(self, credentials, interface=None):
+ super(KeystoneAuthProvider, self).__init__(credentials, interface)
self.auth_client = self._auth_client()
def _decorate_request(self, filters, method, url, headers=None, body=None,
@@ -244,15 +239,12 @@
def _get_auth(self):
# Bypasses the cache
- if self.client_type == 'tempest':
- auth_func = getattr(self.auth_client, 'get_token')
- auth_params = self._auth_params()
+ auth_func = getattr(self.auth_client, 'get_token')
+ auth_params = self._auth_params()
- # returns token, auth_data
- token, auth_data = auth_func(**auth_params)
- return token, auth_data
- else:
- raise NotImplementedError
+ # returns token, auth_data
+ token, auth_data = auth_func(**auth_params)
+ return token, auth_data
def get_token(self):
return self.auth_data[0]
@@ -263,23 +255,17 @@
EXPIRY_DATE_FORMAT = '%Y-%m-%dT%H:%M:%SZ'
def _auth_client(self):
- if self.client_type == 'tempest':
- if self.interface == 'json':
- return json_id.TokenClientJSON()
- else:
- return xml_id.TokenClientXML()
+ if self.interface == 'json':
+ return json_id.TokenClientJSON()
else:
- raise NotImplementedError
+ return xml_id.TokenClientXML()
def _auth_params(self):
- if self.client_type == 'tempest':
- return dict(
- user=self.credentials.username,
- password=self.credentials.password,
- tenant=self.credentials.tenant_name,
- auth_data=True)
- else:
- raise NotImplementedError
+ return dict(
+ user=self.credentials.username,
+ password=self.credentials.password,
+ tenant=self.credentials.tenant_name,
+ auth_data=True)
def _fill_credentials(self, auth_data_body):
tenant = auth_data_body['token']['tenant']
@@ -350,24 +336,18 @@
EXPIRY_DATE_FORMAT = '%Y-%m-%dT%H:%M:%S.%fZ'
def _auth_client(self):
- if self.client_type == 'tempest':
- if self.interface == 'json':
- return json_v3id.V3TokenClientJSON()
- else:
- return xml_v3id.V3TokenClientXML()
+ if self.interface == 'json':
+ return json_v3id.V3TokenClientJSON()
else:
- raise NotImplementedError
+ return xml_v3id.V3TokenClientXML()
def _auth_params(self):
- if self.client_type == 'tempest':
- return dict(
- user=self.credentials.username,
- password=self.credentials.password,
- tenant=self.credentials.tenant_name,
- domain=self.credentials.user_domain_name,
- auth_data=True)
- else:
- raise NotImplementedError
+ return dict(
+ user=self.credentials.username,
+ password=self.credentials.password,
+ tenant=self.credentials.tenant_name,
+ domain=self.credentials.user_domain_name,
+ auth_data=True)
def _fill_credentials(self, auth_data_body):
# project or domain, depending on the scope
diff --git a/tempest/cli/simple_read_only/compute/test_nova_manage.py b/tempest/cli/simple_read_only/compute/test_nova_manage.py
index c27b12e..a4c7aa1 100644
--- a/tempest/cli/simple_read_only/compute/test_nova_manage.py
+++ b/tempest/cli/simple_read_only/compute/test_nova_manage.py
@@ -65,20 +65,17 @@
self.nova_manage('', '--version', merge_stderr=True))
def test_debug_flag(self):
- self.assertNotEqual("", self.nova_manage('flavor list',
+ self.assertNotEqual("", self.nova_manage('service list',
'--debug'))
def test_verbose_flag(self):
- self.assertNotEqual("", self.nova_manage('flavor list',
+ self.assertNotEqual("", self.nova_manage('service list',
'--verbose'))
# test actions
def test_version(self):
self.assertNotEqual("", self.nova_manage('version'))
- def test_flavor_list(self):
- self.assertNotEqual("", self.nova_manage('flavor list'))
-
def test_db_sync(self):
# make sure command doesn't error out
self.nova_manage('db sync')
diff --git a/tempest/clients.py b/tempest/clients.py
index 89cffba..2d07852 100644
--- a/tempest/clients.py
+++ b/tempest/clients.py
@@ -13,9 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.
-import keystoneclient.exceptions
-import keystoneclient.v2_0.client
-
from tempest import auth
from tempest.common import rest_client
from tempest import config
@@ -228,7 +225,6 @@
def __init__(self, credentials=None, interface='json', service=None):
# Set interface and client type first
self.interface = interface
- self.client_type = 'tempest'
# super cares for credentials validation
super(Manager, self).__init__(credentials=credentials)
@@ -488,290 +484,3 @@
credentials=auth.get_default_credentials('compute_admin'),
interface=interface,
service=service)
-
-
-class OfficialClientManager(manager.Manager):
- """
- Manager that provides access to the official python clients for
- calling various OpenStack APIs.
- """
-
- NOVACLIENT_VERSION = '2'
- CINDERCLIENT_VERSION = '1'
- HEATCLIENT_VERSION = '1'
- IRONICCLIENT_VERSION = '1'
- SAHARACLIENT_VERSION = '1.1'
- CEILOMETERCLIENT_VERSION = '2'
-
- def __init__(self, credentials):
- # FIXME(andreaf) Auth provider for client_type 'official' is
- # not implemented yet, setting to 'tempest' for now.
- self.client_type = 'tempest'
- self.interface = None
- # super cares for credentials validation
- super(OfficialClientManager, self).__init__(credentials=credentials)
- self.baremetal_client = self._get_baremetal_client()
- self.compute_client = self._get_compute_client(credentials)
- self.identity_client = self._get_identity_client(credentials)
- self.image_client = self._get_image_client()
- self.network_client = self._get_network_client()
- self.volume_client = self._get_volume_client(credentials)
- self.object_storage_client = self._get_object_storage_client(
- credentials)
- self.orchestration_client = self._get_orchestration_client(
- credentials)
- self.data_processing_client = self._get_data_processing_client(
- credentials)
- self.ceilometer_client = self._get_ceilometer_client(
- credentials)
-
- def _get_roles(self):
- admin_credentials = auth.get_default_credentials('identity_admin')
- keystone_admin = self._get_identity_client(admin_credentials)
-
- username = self.credentials.username
- tenant_name = self.credentials.tenant_name
- user_id = keystone_admin.users.find(name=username).id
- tenant_id = keystone_admin.tenants.find(name=tenant_name).id
-
- roles = keystone_admin.roles.roles_for_user(
- user=user_id, tenant=tenant_id)
-
- return [r.name for r in roles]
-
- def _get_compute_client(self, credentials):
- # Novaclient will not execute operations for anyone but the
- # identified user, so a new client needs to be created for
- # each user that operations need to be performed for.
- if not CONF.service_available.nova:
- return None
- import novaclient.client
-
- auth_url = CONF.identity.uri
- dscv = CONF.identity.disable_ssl_certificate_validation
- region = CONF.identity.region
-
- client_args = (credentials.username, credentials.password,
- credentials.tenant_name, auth_url)
-
- # Create our default Nova client to use in testing
- service_type = CONF.compute.catalog_type
- endpoint_type = CONF.compute.endpoint_type
- return novaclient.client.Client(self.NOVACLIENT_VERSION,
- *client_args,
- service_type=service_type,
- endpoint_type=endpoint_type,
- region_name=region,
- no_cache=True,
- insecure=dscv,
- http_log_debug=True)
-
- def _get_image_client(self):
- if not CONF.service_available.glance:
- return None
- import glanceclient
- token = self.identity_client.auth_token
- region = CONF.identity.region
- endpoint_type = CONF.image.endpoint_type
- endpoint = self.identity_client.service_catalog.url_for(
- attr='region', filter_value=region,
- service_type=CONF.image.catalog_type, endpoint_type=endpoint_type)
- dscv = CONF.identity.disable_ssl_certificate_validation
- return glanceclient.Client('1', endpoint=endpoint, token=token,
- insecure=dscv)
-
- def _get_volume_client(self, credentials):
- if not CONF.service_available.cinder:
- return None
- import cinderclient.client
- auth_url = CONF.identity.uri
- region = CONF.identity.region
- endpoint_type = CONF.volume.endpoint_type
- dscv = CONF.identity.disable_ssl_certificate_validation
- return cinderclient.client.Client(self.CINDERCLIENT_VERSION,
- credentials.username,
- credentials.password,
- credentials.tenant_name,
- auth_url,
- region_name=region,
- endpoint_type=endpoint_type,
- insecure=dscv,
- http_log_debug=True)
-
- def _get_object_storage_client(self, credentials):
- if not CONF.service_available.swift:
- return None
- import swiftclient
- auth_url = CONF.identity.uri
- # add current tenant to swift operator role group.
- admin_credentials = auth.get_default_credentials('identity_admin')
- keystone_admin = self._get_identity_client(admin_credentials)
-
- # enable test user to operate swift by adding operator role to him.
- roles = keystone_admin.roles.list()
- operator_role = CONF.object_storage.operator_role
- member_role = [role for role in roles if role.name == operator_role][0]
- # NOTE(maurosr): This is surrounded in the try-except block cause
- # neutron tests doesn't have tenant isolation.
- try:
- keystone_admin.roles.add_user_role(self.identity_client.user_id,
- member_role.id,
- self.identity_client.tenant_id)
- except keystoneclient.exceptions.Conflict:
- pass
-
- endpoint_type = CONF.object_storage.endpoint_type
- os_options = {'endpoint_type': endpoint_type}
- return swiftclient.Connection(auth_url, credentials.username,
- credentials.password,
- tenant_name=credentials.tenant_name,
- auth_version='2',
- os_options=os_options)
-
- def _get_orchestration_client(self, credentials):
- if not CONF.service_available.heat:
- return None
- import heatclient.client
-
- keystone = self._get_identity_client(credentials)
- region = CONF.identity.region
- endpoint_type = CONF.orchestration.endpoint_type
- token = keystone.auth_token
- service_type = CONF.orchestration.catalog_type
- try:
- endpoint = keystone.service_catalog.url_for(
- attr='region',
- filter_value=region,
- service_type=service_type,
- endpoint_type=endpoint_type)
- except keystoneclient.exceptions.EndpointNotFound:
- return None
- else:
- return heatclient.client.Client(self.HEATCLIENT_VERSION,
- endpoint,
- token=token,
- username=credentials.username,
- password=credentials.password)
-
- def _get_identity_client(self, credentials):
- # This identity client is not intended to check the security
- # of the identity service, so use admin credentials by default.
-
- auth_url = CONF.identity.uri
- dscv = CONF.identity.disable_ssl_certificate_validation
-
- return keystoneclient.v2_0.client.Client(
- username=credentials.username,
- password=credentials.password,
- tenant_name=credentials.tenant_name,
- auth_url=auth_url,
- insecure=dscv)
-
- def _get_baremetal_client(self):
- # ironic client is currently intended to by used by admin users
- if not CONF.service_available.ironic:
- return None
- import ironicclient.client
- roles = self._get_roles()
- if CONF.identity.admin_role not in roles:
- return None
-
- auth_url = CONF.identity.uri
- api_version = self.IRONICCLIENT_VERSION
- insecure = CONF.identity.disable_ssl_certificate_validation
- service_type = CONF.baremetal.catalog_type
- endpoint_type = CONF.baremetal.endpoint_type
- creds = {
- 'os_username': self.credentials.username,
- 'os_password': self.credentials.password,
- 'os_tenant_name': self.credentials.tenant_name
- }
-
- try:
- return ironicclient.client.get_client(
- api_version=api_version,
- os_auth_url=auth_url,
- insecure=insecure,
- os_service_type=service_type,
- os_endpoint_type=endpoint_type,
- **creds)
- except keystoneclient.exceptions.EndpointNotFound:
- return None
-
- def _get_network_client(self):
- # The intended configuration is for the network client to have
- # admin privileges and indicate for whom resources are being
- # created via a 'tenant_id' parameter. This will often be
- # preferable to authenticating as a specific user because
- # working with certain resources (public routers and networks)
- # often requires admin privileges anyway.
- if not CONF.service_available.neutron:
- return None
- import neutronclient.v2_0.client
-
- credentials = auth.get_default_credentials('identity_admin')
-
- auth_url = CONF.identity.uri
- dscv = CONF.identity.disable_ssl_certificate_validation
- endpoint_type = CONF.network.endpoint_type
-
- return neutronclient.v2_0.client.Client(
- username=credentials.username,
- password=credentials.password,
- tenant_name=credentials.tenant_name,
- endpoint_type=endpoint_type,
- auth_url=auth_url,
- insecure=dscv)
-
- def _get_data_processing_client(self, credentials):
- if not CONF.service_available.sahara:
- # Sahara isn't available
- return None
-
- import saharaclient.client
-
- endpoint_type = CONF.data_processing.endpoint_type
- catalog_type = CONF.data_processing.catalog_type
- auth_url = CONF.identity.uri
-
- client = saharaclient.client.Client(
- self.SAHARACLIENT_VERSION,
- credentials.username,
- credentials.password,
- project_name=credentials.tenant_name,
- endpoint_type=endpoint_type,
- service_type=catalog_type,
- auth_url=auth_url)
-
- return client
-
- def _get_ceilometer_client(self, credentials):
- if not CONF.service_available.ceilometer:
- return None
-
- import ceilometerclient.client
-
- keystone = self._get_identity_client(credentials)
- region = CONF.identity.region
-
- endpoint_type = CONF.telemetry.endpoint_type
- service_type = CONF.telemetry.catalog_type
- auth_url = CONF.identity.uri
-
- try:
- keystone.service_catalog.url_for(
- attr='region',
- filter_value=region,
- service_type=service_type,
- endpoint_type=endpoint_type)
- except keystoneclient.exceptions.EndpointNotFound:
- return None
- else:
- return ceilometerclient.client.get_client(
- self.CEILOMETERCLIENT_VERSION,
- os_username=credentials.username,
- os_password=credentials.password,
- os_tenant_name=credentials.tenant_name,
- os_auth_url=auth_url,
- os_service_type=service_type,
- os_endpoint_type=endpoint_type)
diff --git a/tempest/cmd/javelin.py b/tempest/cmd/javelin.py
index 27e388d..3c41dd9 100755
--- a/tempest/cmd/javelin.py
+++ b/tempest/cmd/javelin.py
@@ -184,7 +184,9 @@
def destroy_users(users):
admin = keystone_admin()
for user in users:
- user_id = admin.identity.get_user_by_name(user['name'])['id']
+ tenant_id = admin.identity.get_tenant_by_name(user['tenant'])['id']
+ user_id = admin.identity.get_user_by_username(tenant_id,
+ user['name'])['id']
r, body = admin.identity.delete_user(user_id)
diff --git a/tempest/config.py b/tempest/config.py
index cea9dec..174a895 100644
--- a/tempest/config.py
+++ b/tempest/config.py
@@ -1141,8 +1141,10 @@
# to remove an issue with the config file up to date checker.
if parse_conf:
config_files.append(path)
-
- cfg.CONF([], project='tempest', default_config_files=config_files)
+ if os.path.isfile(path):
+ cfg.CONF([], project='tempest', default_config_files=config_files)
+ else:
+ cfg.CONF([], project='tempest')
logging.setup('tempest')
LOG = logging.getLogger('tempest')
LOG.info("Using tempest config file %s" % path)
diff --git a/tempest/hacking/checks.py b/tempest/hacking/checks.py
index abc60cb..55cc89b 100644
--- a/tempest/hacking/checks.py
+++ b/tempest/hacking/checks.py
@@ -106,20 +106,6 @@
"T107: service tag should not be in path")
-def no_official_client_manager_in_api_tests(physical_line, filename):
- """Check that the OfficialClientManager isn't used in the api tests
-
- The api tests should not use the official clients.
-
- T108: Can not use OfficialClientManager in the API tests
- """
- if 'tempest/api' in filename:
- if 'OfficialClientManager' in physical_line:
- return (physical_line.find('OfficialClientManager'),
- 'T108: OfficialClientManager can not be used in the api '
- 'tests')
-
-
def no_mutable_default_args(logical_line):
"""Check that mutable object isn't used as default argument
@@ -136,5 +122,4 @@
register(no_setupclass_for_unit_tests)
register(no_vi_headers)
register(service_tags_not_in_module_path)
- register(no_official_client_manager_in_api_tests)
register(no_mutable_default_args)
diff --git a/tempest/manager.py b/tempest/manager.py
index 75aee96..538b619 100644
--- a/tempest/manager.py
+++ b/tempest/manager.py
@@ -63,6 +63,5 @@
'Credentials must be specified')
auth_provider_class = self.get_auth_provider_class(credentials)
return auth_provider_class(
- client_type=getattr(self, 'client_type', None),
interface=getattr(self, 'interface', None),
credentials=credentials)
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 559f3d5..b3b4fbf 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -21,7 +21,6 @@
import netaddr
import six
-from tempest.api.network import common as net_common
from tempest import auth
from tempest import clients
from tempest.common import debug
@@ -47,15 +46,7 @@
class ScenarioTest(tempest.test.BaseTestCase):
- """Replaces the OfficialClientTest base class.
-
- Uses tempest own clients as opposed to OfficialClients.
-
- Common differences:
- - replace resource.attribute with resource['attribute']
- - replace resouce.delete with delete_callable(resource['id'])
- - replace local waiters with common / rest_client waiters
- """
+ """Base class for scenario tests. Uses tempest own clients. """
@classmethod
def setUpClass(cls):
@@ -598,7 +589,7 @@
def _get_network_by_name(self, network_name):
net = self._list_networks(name=network_name)
- return net_common.AttributeDict(net[0])
+ return net_resources.AttributeDict(net[0])
def _create_floating_ip(self, thing, external_network_id, port_id=None,
client=None):
diff --git a/tempest/scenario/orchestration/test_server_cfn_init.py b/tempest/scenario/orchestration/test_server_cfn_init.py
index 0ab4311..abda1f8 100644
--- a/tempest/scenario/orchestration/test_server_cfn_init.py
+++ b/tempest/scenario/orchestration/test_server_cfn_init.py
@@ -24,6 +24,7 @@
class CfnInitScenarioTest(manager.OrchestrationScenarioTest):
+ @test.skip_because(bug="1374175")
def setUp(self):
super(CfnInitScenarioTest, self).setUp()
if not CONF.orchestration.image_ref:
diff --git a/tempest/scenario/test_load_balancer_basic.py b/tempest/scenario/test_load_balancer_basic.py
index 6ab870e..21680c2 100644
--- a/tempest/scenario/test_load_balancer_basic.py
+++ b/tempest/scenario/test_load_balancer_basic.py
@@ -18,11 +18,11 @@
import time
import urllib2
-from tempest.api.network import common as net_common
from tempest.common import commands
from tempest import config
from tempest import exceptions
from tempest.scenario import manager
+from tempest.services.network import resources as net_resources
from tempest import test
config = config.CONF
@@ -38,9 +38,8 @@
2. SSH to the instance and start two servers
3. Create a load balancer with two members and with ROUND_ROBIN algorithm
associate the VIP with a floating ip
- 4. Send 10 requests to the floating ip and check that they are shared
- between the two servers and that both of them get equal portions
- of the requests
+ 4. Send NUM requests to the floating ip and check that they are shared
+ between the two servers.
"""
@classmethod
@@ -67,6 +66,7 @@
cls.server_ips = {}
cls.port1 = 80
cls.port2 = 88
+ cls.num = 50
def setUp(self):
super(TestLoadBalancerBasic, self).setUp()
@@ -89,7 +89,7 @@
if tenant_net:
tenant_subnet = self._list_subnets(tenant_id=self.tenant_id)[0]
- self.subnet = net_common.DeletableSubnet(
+ self.subnet = net_resources.DeletableSubnet(
client=self.network_client,
**tenant_subnet)
self.network = tenant_net
@@ -101,7 +101,7 @@
# should instead pull a subnet id from config, which is set by
# devstack/admin/etc.
subnet = self._list_subnets(network_id=self.network['id'])[0]
- self.subnet = net_common.AttributeDict(subnet)
+ self.subnet = net_resources.AttributeDict(subnet)
def _create_security_group_for_test(self):
self.security_group = self._create_security_group(
@@ -287,26 +287,21 @@
def _check_load_balancing(self):
"""
- 1. Send 10 requests on the floating ip associated with the VIP
- 2. Check that the requests are shared between
- the two servers and that both of them get equal portions
- of the requests
+ 1. Send NUM requests on the floating ip associated with the VIP
+ 2. Check that the requests are shared between the two servers
"""
self._check_connection(self.vip_ip)
- self._send_requests(self.vip_ip, set(["server1", "server2"]))
+ self._send_requests(self.vip_ip, ["server1", "server2"])
- def _send_requests(self, vip_ip, expected, num_req=10):
- count = 0
- while count < num_req:
- resp = []
- for i in range(len(self.members)):
- resp.append(
- urllib2.urlopen(
- "http://{0}/".format(vip_ip)).read())
- count += 1
- self.assertEqual(expected,
- set(resp))
+ def _send_requests(self, vip_ip, servers):
+ counters = dict.fromkeys(servers, 0)
+ for i in range(self.num):
+ server = urllib2.urlopen("http://{0}/".format(vip_ip)).read()
+ counters[server] += 1
+ # Assert that each member of the pool gets balanced at least once
+ for member, counter in counters.iteritems():
+ self.assertGreater(counter, 0, 'Member %s never balanced' % member)
@test.services('compute', 'network')
def test_load_balancer_basic(self):
diff --git a/tempest/scenario/test_server_basic_ops.py b/tempest/scenario/test_server_basic_ops.py
index b38b1a3..eb636f7 100644
--- a/tempest/scenario/test_server_basic_ops.py
+++ b/tempest/scenario/test_server_basic_ops.py
@@ -35,8 +35,7 @@
* Create a security group to control network access in instance
* Add simple permissive rules to the security group
* Launch an instance
- * Pause/unpause the instance
- * Suspend/resume the instance
+ * Perform ssh to instance
* Terminate the instance
"""
diff --git a/tempest/tests/test_hacking.py b/tempest/tests/test_hacking.py
index 9c13013..37ad18e 100644
--- a/tempest/tests/test_hacking.py
+++ b/tempest/tests/test_hacking.py
@@ -100,14 +100,6 @@
self.assertFalse(checks.service_tags_not_in_module_path(
"@test.services('compute')", './tempest/api/image/fake_test.py'))
- def test_no_official_client_manager_in_api_tests(self):
- self.assertTrue(checks.no_official_client_manager_in_api_tests(
- "cls.official_client = clients.OfficialClientManager(credentials)",
- "tempest/api/compute/base.py"))
- self.assertFalse(checks.no_official_client_manager_in_api_tests(
- "cls.official_client = clients.OfficialClientManager(credentials)",
- "tempest/scenario/fake_test.py"))
-
def test_no_mutable_default_args(self):
self.assertEqual(1, len(list(checks.no_mutable_default_args(
" def function1(para={}):"))))
diff --git a/tempest/thirdparty/boto/test_ec2_instance_run.py b/tempest/thirdparty/boto/test_ec2_instance_run.py
index ee904c7..c0d3f7a 100644
--- a/tempest/thirdparty/boto/test_ec2_instance_run.py
+++ b/tempest/thirdparty/boto/test_ec2_instance_run.py
@@ -200,29 +200,6 @@
instance.terminate()
self.assertInstanceStateWait(instance, '_GONE')
- def test_run_reboot_terminate_instance(self):
- # EC2 run, await till it reaches to running state, then reboot,
- # and wait untill its state is running, and then terminate
- image_ami = self.ec2_client.get_image(self.images["ami"]
- ["image_id"])
- reservation = image_ami.run(kernel_id=self.images["aki"]["image_id"],
- ramdisk_id=self.images["ari"]["image_id"],
- instance_type=self.instance_type)
-
- self.assertEqual(1, len(reservation.instances))
-
- instance = reservation.instances[0]
- if instance.state != "running":
- self.assertInstanceStateWait(instance, "running")
-
- instance.reboot()
- if instance.state != "running":
- self.assertInstanceStateWait(instance, "running")
- LOG.debug("Instance rebooted - state: %s", instance.state)
-
- instance.terminate()
- self.assertInstanceStateWait(instance, '_GONE')
-
def test_compute_with_volumes(self):
# EC2 1. integration test (not strict)
image_ami = self.ec2_client.get_image(self.images["ami"]["image_id"])