backport lib caps and test patches to fix stable gate

accommodate new oslo.config Ib8fe3f0e6f37f2ca5c0785e73b2c770b71fac9e6
commit 4637aeb2d3

fix oslo.db 4.15.0 breakage I69f8ff9f702064e8fc5bf4018ebc6f3b2a8ea1a8
commit f5794af695
also
commit b2d64d26ac
commit c062916a81

Fix expected content-type and move CORS tests to gabbi I0f23481d5f75694da23d05c9ef88005a0f2c27d7
commit 5a6d3935bc)

cap gnocchiclient
Change-Id: Ib2960423cc3b72e1b21a9d9da9b87cdede1ab44c
commit 7bf0e3540a
This commit is contained in:
gord chung 2017-02-01 09:26:58 -05:00 committed by gordon chung
parent eab6af3049
commit 4ed3fd11a2
9 changed files with 48 additions and 12 deletions

View File

@ -121,7 +121,7 @@ function install_gnocchiclient {
git_clone_by_name python-gnocchiclient
setup_dev_lib python-gnocchiclient
else
pip_install gnocchiclient
pip_install 'gnocchiclient<3.0'
fi
}

View File

@ -23,6 +23,8 @@ from unittest import case
import warnings
from gabbi import fixture
from oslo_config import cfg
from oslo_middleware import cors
import sqlalchemy_utils
from gnocchi import indexer
@ -80,6 +82,13 @@ class ConfigFixture(fixture.GabbiFixture):
os.path.abspath('etc/gnocchi/api-paste.ini'),
'api')
# NOTE(sileht): This is not concurrency safe, but only this tests file
# deal with cors, so we are fine. set_override don't work because cors
# group doesn't yet exists, and we the CORS middleware is created it
# register the option and directly copy value of all configurations
# options making impossible to override them properly...
cfg.set_defaults(cors.CORS_OPTS, allowed_origin="http://foobar.com")
self.conf = conf
self.tmp_dir = data_tmp_dir

View File

@ -7,7 +7,7 @@ tests:
desc: Root URL must return information about API versions
GET: /
response_headers:
content-type: application/json; charset=UTF-8
content-type: /^application\/json/
response_json_paths:
$.versions.[0].id: "v1.0"
$.versions.[0].status: "CURRENT"
@ -24,7 +24,7 @@ tests:
points: 20
status: 201
response_headers:
content-type: /application\/json/
content-type: /^application\/json/
location: $SCHEME://$NETLOC/v1/archive_policy/test1
response_json_paths:
$.name: test1
@ -91,7 +91,7 @@ tests:
desc: Resources index page should return list of type associated with a URL
GET: /v1/resource/
response_headers:
content-type: application/json; charset=UTF-8
content-type: /^application\/json/
status: 200
response_json_paths:
$.generic: $SCHEME://$NETLOC/v1/resource/generic

View File

@ -0,0 +1,21 @@
fixtures:
- ConfigFixture
tests:
- name: get CORS headers for non-allowed
OPTIONS: /v1/status
request_headers:
Origin: http://notallowed.com
Access-Control-Request-Method: GET
response_forbidden_headers:
- Access-Control-Allow-Origin
- Access-Control-Allow-Methods
- name: get CORS headers for allowed
OPTIONS: /v1/status
request_headers:
Origin: http://foobar.com
Access-Control-Request-Method: GET
response_headers:
Access-Control-Allow-Origin: http://foobar.com
Access-Control-Allow-Methods: GET

View File

@ -35,7 +35,7 @@ tests:
status: 201
response_headers:
location: $SCHEME://$NETLOC/v1/resource/generic/f93450f2-d8a5-4d67-9985-02511241e7d1
content-type: application/json; charset=UTF-8
content-type: /^application\/json/
response_json_paths:
$.created_by_project_id: f3d41b770cc14f0bb94a1d5be9c0e3ea
$.created_by_user_id: 0fbb231484614b1a80131fc22f6afc9c

View File

@ -131,7 +131,7 @@ tests:
status: 201
response_headers:
location: $SCHEME://$NETLOC/v1/resource/generic/f93450f2-d8a5-4d67-9985-02511241e7d1
content-type: application/json; charset=UTF-8
content-type: /^application\/json/
response_json_paths:
$.created_by_project_id: f3d41b770cc14f0bb94a1d5be9c0e3ea
$.created_by_user_id: 0fbb231484614b1a80131fc22f6afc9c

View File

@ -16,6 +16,7 @@ import abc
import fixtures
import mock
import oslo_db.exception
from oslo_db.sqlalchemy import test_migrations
import six
import sqlalchemy as sa
@ -50,10 +51,14 @@ class ModelsMigrationsSync(
self.index = indexer.get_driver(self.conf)
self.index.connect()
self.index.upgrade(nocreate=True, create_legacy_resource_types=True)
self.addCleanup(self._drop_database)
def tearDown(self):
sqlalchemy_utils.drop_database(self.conf.indexer.url)
super(ModelsMigrationsSync, self).tearDown()
def _drop_database(self):
try:
sqlalchemy_utils.drop_database(self.conf.indexer.url)
except oslo_db.exception.DBNonExistentDatabase:
# NOTE(sileht): oslo db >= 4.15.0 cleanup this for us
pass
@staticmethod
def get_metadata():

View File

@ -35,7 +35,7 @@ class TestStatsd(tests_base.TestCase):
super(TestStatsd, self).setUp()
self.conf.set_override("resource_id",
uuid.uuid4(), "statsd")
str(uuid.uuid4()), "statsd")
self.conf.set_override("user_id",
self.STATSD_USER_ID, "statsd")
self.conf.set_override("project_id",

View File

@ -25,13 +25,13 @@ keystone =
keystonemiddleware>=4.0.0
mysql =
pymysql
oslo.db>=4.8.0
oslo.db>=4.8.0,!=4.13.1,!=4.13.2,!=4.15.0
sqlalchemy
sqlalchemy-utils
alembic>=0.7.6,!=0.8.1
postgresql =
psycopg2
oslo.db>=4.8.0
oslo.db>=4.8.0,!=4.13.1,!=4.13.2,!=4.15.0
sqlalchemy
sqlalchemy-utils
alembic>=0.7.6,!=0.8.1
@ -70,6 +70,7 @@ test =
os-testr
testrepository
testscenarios
testresources>=0.2.4 # Apache-2.0/BSD
testtools>=0.9.38
WebTest>=2.0.16
doc8