Merge "Also run v2 functional tests with registry"

This commit is contained in:
Jenkins 2014-07-22 01:14:22 +00:00 committed by Gerrit Code Review
commit 81e4a01818
4 changed files with 115 additions and 2 deletions

View File

@ -320,6 +320,8 @@ class ApiServer(Server):
default_sql_connection = 'sqlite:////%s/tests.sqlite' % self.test_dir
self.sql_connection = os.environ.get('GLANCE_TEST_SQL_CONNECTION',
default_sql_connection)
self.data_api = kwargs.get("data_api",
"glance.db.sqlalchemy.api")
self.user_storage_quota = '0'
self.lock_path = self.test_dir
@ -369,6 +371,7 @@ image_cache_driver = %(image_cache_driver)s
policy_file = %(policy_file)s
policy_default_rule = %(policy_default_rule)s
db_auto_create = False
data_api = %(data_api)s
sql_connection = %(sql_connection)s
show_image_direct_url = %(show_image_direct_url)s
show_multiple_locations = %(show_multiple_locations)s
@ -499,6 +502,9 @@ pipeline = unauthenticated-context registryapp
[pipeline:glance-registry-fakeauth]
pipeline = fakeauth context registryapp
[pipeline:glance-registry-trusted-auth]
pipeline = context registryapp
[app:registryapp]
paste.app_factory = glance.registry.api:API.factory

View File

@ -0,0 +1,52 @@
# Copyright 2014 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.
from glance.db.registry.api import * # noqa
from glance.common.rpc import RPCClient
from glance.registry.client.v2 import api
from glance.registry.client.v2 import client
def patched_bulk_request(self, commands):
# We add some auth headers which are typically
# added by keystone. This is required when testing
# without keystone, otherwise the tests fail.
# We use the 'trusted-auth' deployment flavour
# for testing so that these headers are interpreted
# as expected (ie the same way as if keystone was
# present)
body = self._serializer.to_json(commands)
headers = {"X-Identity-Status": "Confirmed", 'X-Roles': 'member'}
if self.context.user is not None:
headers['X-User-Id'] = self.context.user
if self.context.tenant is not None:
headers['X-Tenant-Id'] = self.context.tenant
response = super(RPCClient, self).do_request('POST',
self.base_path,
body,
headers=headers)
return self._deserializer.from_json(response.read())
def client_wrapper(func):
def call(context):
reg_client = func(context)
reg_client.context = context
return reg_client
return call
client.RegistryClient.bulk_request = patched_bulk_request
api.get_registry_client = client_wrapper(api.get_registry_client)

View File

@ -38,7 +38,7 @@ class TestImages(functional.FunctionalTest):
super(TestImages, self).setUp()
self.cleanup()
self.api_server.deployment_flavor = 'noauth'
self.start_servers(**self.__dict__.copy())
self.api_server.data_api = 'glance.db.sqlalchemy.api'
def _url(self, path):
return 'http://127.0.0.1:%d%s' % (self.api_port, path)
@ -56,6 +56,7 @@ class TestImages(functional.FunctionalTest):
def test_image_lifecycle(self):
# Image list should be empty
self.start_servers(**self.__dict__.copy())
path = self._url('/v2/images')
response = requests.get(path, headers=self._headers())
self.assertEqual(200, response.status_code)
@ -520,6 +521,7 @@ class TestImages(functional.FunctionalTest):
self.stop_servers()
def test_permissions(self):
self.start_servers(**self.__dict__.copy())
# Create an image that belongs to TENANT1
path = self._url('/v2/images')
headers = self._headers({'Content-Type': 'application/json'})
@ -1463,6 +1465,7 @@ class TestImages(functional.FunctionalTest):
self.stop_servers()
def test_tag_lifecycle(self):
self.start_servers(**self.__dict__.copy())
# Create an image with a tag - duplicate should be ignored
path = self._url('/v2/images')
headers = self._headers({'Content-Type': 'application/json'})
@ -1642,6 +1645,7 @@ class TestImages(functional.FunctionalTest):
def test_images_container(self):
# Image list should be empty and no next link should be present
self.start_servers(**self.__dict__.copy())
path = self._url('/v2/images')
response = requests.get(path, headers=self._headers())
self.assertEqual(200, response.status_code)
@ -1822,6 +1826,7 @@ class TestImages(functional.FunctionalTest):
self.stop_servers()
def test_update_locations(self):
self.start_servers(**self.__dict__.copy())
# Create an image
path = self._url('/v2/images')
headers = self._headers({'content-type': 'application/json'})
@ -1859,6 +1864,14 @@ class TestImages(functional.FunctionalTest):
self.assertEqual(image['size'], 6)
class TestImagesWithRegistry(TestImages):
def setUp(self):
super(TestImagesWithRegistry, self).setUp()
self.api_server.data_api = (
'glance.tests.functional.v2.registry_data_api')
self.registry_server.deployment_flavor = 'trusted-auth'
class TestImageDirectURLVisibility(functional.FunctionalTest):
def setUp(self):
@ -2060,6 +2073,14 @@ class TestImageDirectURLVisibility(functional.FunctionalTest):
self.stop_servers()
class TestImageDirectURLVisibilityWithRegistry(TestImageDirectURLVisibility):
def setUp(self):
super(TestImageDirectURLVisibilityWithRegistry, self).setUp()
self.api_server.data_api = (
'glance.tests.functional.v2.registry_data_api')
self.registry_server.deployment_flavor = 'trusted-auth'
class TestImageLocationSelectionStrategy(functional.FunctionalTest):
def setUp(self):
@ -2214,6 +2235,15 @@ class TestImageLocationSelectionStrategy(functional.FunctionalTest):
self.stop_servers()
class TestImageLocationSelectionStrategyWithRegistry(
TestImageLocationSelectionStrategy):
def setUp(self):
super(TestImageLocationSelectionStrategyWithRegistry, self).setUp()
self.api_server.data_api = (
'glance.tests.functional.v2.registry_data_api')
self.registry_server.deployment_flavor = 'trusted-auth'
class TestImageMembers(functional.FunctionalTest):
def setUp(self):
@ -2515,12 +2545,21 @@ class TestImageMembers(functional.FunctionalTest):
self.stop_servers()
class TestImageMembersWithRegistry(TestImageMembers):
def setUp(self):
super(TestImageMembersWithRegistry, self).setUp()
self.api_server.data_api = (
'glance.tests.functional.v2.registry_data_api')
self.registry_server.deployment_flavor = 'trusted-auth'
class TestQuotas(functional.FunctionalTest):
def setUp(self):
super(TestQuotas, self).setUp()
self.cleanup()
self.api_server.deployment_flavor = 'noauth'
self.registry_server.deployment_flavor = 'trusted-auth'
self.user_storage_quota = 100
self.start_servers(**self.__dict__.copy())
@ -2589,3 +2628,11 @@ class TestQuotas(functional.FunctionalTest):
yield 'x' * (self.user_storage_quota + 1)
self._upload_image_test(data_gen(), 413)
class TestQuotasWithRegistry(TestQuotas):
def setUp(self):
super(TestQuotasWithRegistry, self).setUp()
self.api_server.data_api = (
'glance.tests.functional.v2.registry_data_api')
self.registry_server.deployment_flavor = 'trusted-auth'

View File

@ -37,7 +37,6 @@ class TestTasks(functional.FunctionalTest):
self.cleanup()
self.file_path = self._stash_file()
self.api_server.deployment_flavor = 'noauth'
self.start_servers(**self.__dict__.copy())
def _url(self, path):
return 'http://127.0.0.1:%d%s' % (self.api_port, path)
@ -64,6 +63,7 @@ class TestTasks(functional.FunctionalTest):
return 'file://%s' % file_path
def test_task_lifecycle(self):
self.start_servers(**self.__dict__.copy())
# Task list should be empty
path = self._url('/v2/tasks')
response = requests.get(path, headers=self._headers())
@ -138,3 +138,11 @@ class TestTasks(functional.FunctionalTest):
self.assertEqual('GET', response.headers.get('Allow'))
self.stop_servers()
class TestTasksWithRegistry(TestTasks):
def setUp(self):
super(TestTasksWithRegistry, self).setUp()
self.api_server.data_api = (
'glance.tests.functional.v2.registry_data_api')
self.registry_server.deployment_flavor = 'trusted-auth'