Run functional tests under tox
This patch allows to run functional tests under tox, however, they are disabled by default. In order to run tests with tox, it is necessary to enable them by modifying the functional-tests.conf and setting run_tests to True. This patch also merged both test files in a single one (test-requirements.txt) blueprint refactor-system-tests Change-Id: Iba440b12653cf9ee1454022830107a06b8a7bea9
This commit is contained in:
parent
5a12dbf5fc
commit
80157e6a4a
@ -1,2 +0,0 @@
|
|||||||
requests
|
|
||||||
ddt
|
|
@ -14,6 +14,8 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from marconi import tests as testing
|
from marconi import tests as testing
|
||||||
|
from marconi.tests.functional import config
|
||||||
|
from marconi.tests.functional import helpers
|
||||||
# NOTE(flaper87): This is necessary to register,
|
# NOTE(flaper87): This is necessary to register,
|
||||||
# wsgi configs and won't be permanent. It'll be
|
# wsgi configs and won't be permanent. It'll be
|
||||||
# refactored as part of the work for this blueprint
|
# refactored as part of the work for this blueprint
|
||||||
@ -22,6 +24,25 @@ from marconi.transport import wsgi # noqa
|
|||||||
|
|
||||||
class FunctionalTestBase(testing.TestBase):
|
class FunctionalTestBase(testing.TestBase):
|
||||||
|
|
||||||
|
def setUp(self):
|
||||||
|
super(FunctionalTestBase, self).setUp()
|
||||||
|
|
||||||
|
# NOTE(flaper87): Config can't be a class
|
||||||
|
# attribute because it may be necessary to
|
||||||
|
# modify it at runtime which will affect
|
||||||
|
# other instances running instances.
|
||||||
|
self.cfg = config.load_config()
|
||||||
|
|
||||||
|
if not self.cfg.run_tests:
|
||||||
|
self.skipTest("Functional tests disabled")
|
||||||
|
|
||||||
|
self.mconf = self.load_conf(self.cfg.marconi.config).conf
|
||||||
|
self.limits = self.mconf['limits:transport']
|
||||||
|
|
||||||
|
self.header = helpers.create_marconi_headers(self.cfg)
|
||||||
|
self.headers_response_with_body = set(['location',
|
||||||
|
'content-type'])
|
||||||
|
|
||||||
def assertIsSubset(self, required_values, actual_values):
|
def assertIsSubset(self, required_values, actual_values):
|
||||||
"""Checks if a list is subset of another.
|
"""Checks if a list is subset of another.
|
||||||
|
|
||||||
|
@ -17,6 +17,9 @@ import os
|
|||||||
|
|
||||||
from oslo.config import cfg
|
from oslo.config import cfg
|
||||||
|
|
||||||
|
_DEFAULT = [
|
||||||
|
cfg.BoolOpt("run_tests", default=False),
|
||||||
|
]
|
||||||
|
|
||||||
_AUTH_OPTIONS = [
|
_AUTH_OPTIONS = [
|
||||||
cfg.BoolOpt("auth_on", default=False),
|
cfg.BoolOpt("auth_on", default=False),
|
||||||
@ -42,6 +45,7 @@ _HEADERS_OPTIONS = [
|
|||||||
|
|
||||||
def load_config():
|
def load_config():
|
||||||
conf = cfg.ConfigOpts()
|
conf = cfg.ConfigOpts()
|
||||||
|
conf.register_opts(_DEFAULT)
|
||||||
conf.register_opts(_AUTH_OPTIONS, group="auth")
|
conf.register_opts(_AUTH_OPTIONS, group="auth")
|
||||||
conf.register_opts(_MARCONI_OPTIONS, group="marconi")
|
conf.register_opts(_MARCONI_OPTIONS, group="marconi")
|
||||||
conf.register_opts(_HEADERS_OPTIONS, group="headers")
|
conf.register_opts(_HEADERS_OPTIONS, group="headers")
|
||||||
|
@ -12,8 +12,7 @@
|
|||||||
# implied.
|
# implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
from marconi.tests.functional.util import config
|
from marconi.tests.functional import http
|
||||||
from marconi.tests.functional.util import http
|
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import random
|
import random
|
||||||
@ -21,9 +20,6 @@ import string
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
|
||||||
CFG = config.Config()
|
|
||||||
|
|
||||||
|
|
||||||
def get_keystone_token(conf):
|
def get_keystone_token(conf):
|
||||||
"""Gets Keystone Auth token."""
|
"""Gets Keystone Auth token."""
|
||||||
req_json = {
|
req_json = {
|
||||||
|
@ -44,7 +44,6 @@ marconi.common.cache.backends =
|
|||||||
[nosetests]
|
[nosetests]
|
||||||
where=tests
|
where=tests
|
||||||
verbosity=2
|
verbosity=2
|
||||||
exclude=functional/*
|
|
||||||
|
|
||||||
with-doctest = true
|
with-doctest = true
|
||||||
|
|
||||||
|
@ -10,6 +10,9 @@ python-subunit
|
|||||||
testrepository
|
testrepository
|
||||||
testtools
|
testtools
|
||||||
|
|
||||||
|
# Functional Tests
|
||||||
|
requests
|
||||||
|
|
||||||
# Test runner
|
# Test runner
|
||||||
nose
|
nose
|
||||||
nose-exclude
|
nose-exclude
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
[DEFAULT]
|
||||||
|
# run_tests = False
|
||||||
|
|
||||||
[auth]
|
[auth]
|
||||||
# auth_on = False
|
# auth_on = False
|
||||||
# url = https://127.0.0.1:5000/v2.0/tokens
|
# url = https://127.0.0.1:5000/v2.0/tokens
|
||||||
|
@ -6,15 +6,37 @@ words, the API calls attempt to simulate an actual user. Unlike unit tests,
|
|||||||
the functional tests do not use mockendpoints.
|
the functional tests do not use mockendpoints.
|
||||||
|
|
||||||
|
|
||||||
Running the Functional Tests
|
Running functional tests (With Tox)
|
||||||
------------------------
|
-----------------------------------
|
||||||
|
|
||||||
|
#. Setup a Marconi server. Refer to the Marconi `README`_ on
|
||||||
|
how to run Marconi locally, or simply use an existing server.
|
||||||
|
|
||||||
|
#. Change `$MARCONI_TESTS_CONFIGS_DIR/functional-tests.conf` and
|
||||||
|
set `run_tests` to True.
|
||||||
|
|
||||||
|
#. Run tests. ::
|
||||||
|
|
||||||
|
$ tox
|
||||||
|
|
||||||
|
#. Filter tests. ::
|
||||||
|
|
||||||
|
$ tox -- --tests tests.functional.test_messages
|
||||||
|
|
||||||
|
#. Run tests for specific environments. ::
|
||||||
|
|
||||||
|
$ tox -epy27,pep8
|
||||||
|
|
||||||
|
Running the Functional Tests (Without Tox)
|
||||||
|
------------------------------------------
|
||||||
|
|
||||||
#. Setup a Marconi server. Refer to the Marconi `README`_ on
|
#. Setup a Marconi server. Refer to the Marconi `README`_ on
|
||||||
how to run Marconi locally, or simply use an existing server.
|
how to run Marconi locally, or simply use an existing server.
|
||||||
|
|
||||||
#. Install functional tests dependencies. ::
|
#. Install functional tests dependencies. ::
|
||||||
|
|
||||||
pip install -r functional-test-requirements.txt
|
pip install -r requirements.txt
|
||||||
|
pip install -r test-requirements.txt
|
||||||
|
|
||||||
#. cd to the marconi/tests/functional directory
|
#. cd to the marconi/tests/functional directory
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ import json
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from marconi.tests.functional import base
|
from marconi.tests.functional import base
|
||||||
from marconi.tests.functional import config
|
|
||||||
from marconi.tests.functional import helpers
|
from marconi.tests.functional import helpers
|
||||||
from marconi.tests.functional import http
|
from marconi.tests.functional import http
|
||||||
|
|
||||||
@ -27,16 +26,6 @@ from marconi.tests.functional import http
|
|||||||
class TestClaims(base.FunctionalTestBase):
|
class TestClaims(base.FunctionalTestBase):
|
||||||
"""Tests for Claims."""
|
"""Tests for Claims."""
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setUpClass(cls):
|
|
||||||
cls.cfg = config.load_config()
|
|
||||||
cls.mconf = cls.load_conf(cls.cfg.marconi.config).conf
|
|
||||||
cls.limits = cls.mconf['limits:transport']
|
|
||||||
|
|
||||||
cls.header = helpers.create_marconi_headers(cls.cfg)
|
|
||||||
cls.headers_response_with_body = set(['location',
|
|
||||||
'content-type'])
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestClaims, self).setUp()
|
super(TestClaims, self).setUp()
|
||||||
|
|
||||||
|
@ -16,26 +16,14 @@ import ddt
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from marconi.tests.functional import base # noqa
|
from marconi.tests.functional import base # noqa
|
||||||
from marconi.tests.functional import config
|
|
||||||
from marconi.tests.functional import helpers
|
from marconi.tests.functional import helpers
|
||||||
from marconi.tests.functional import http
|
from marconi.tests.functional import http
|
||||||
|
|
||||||
|
|
||||||
@ddt.ddt
|
@ddt.ddt
|
||||||
class TestMessages(base.FunctionalTestBase):
|
class TestMessages(base.FunctionalTestBase):
|
||||||
|
|
||||||
"""Tests for Messages."""
|
"""Tests for Messages."""
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setUpClass(cls):
|
|
||||||
cls.cfg = config.load_config()
|
|
||||||
cls.mconf = cls.load_conf(cls.cfg.marconi.config).conf
|
|
||||||
cls.limits = cls.mconf['limits:transport']
|
|
||||||
|
|
||||||
cls.header = helpers.create_marconi_headers(cls.cfg)
|
|
||||||
cls.headers_response_with_body = set(['location',
|
|
||||||
'content-type'])
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestMessages, self).setUp()
|
super(TestMessages, self).setUp()
|
||||||
|
|
||||||
|
@ -19,8 +19,6 @@ import json
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from marconi.tests.functional import base # noqa
|
from marconi.tests.functional import base # noqa
|
||||||
from marconi.tests.functional import config
|
|
||||||
from marconi.tests.functional import helpers
|
|
||||||
from marconi.tests.functional import http
|
from marconi.tests.functional import http
|
||||||
|
|
||||||
|
|
||||||
@ -29,19 +27,12 @@ class TestInsertQueue(base.FunctionalTestBase):
|
|||||||
|
|
||||||
"""Tests for Insert queue."""
|
"""Tests for Insert queue."""
|
||||||
|
|
||||||
@classmethod
|
def setUp(self):
|
||||||
def setUpClass(cls):
|
super(TestInsertQueue, self).setUp()
|
||||||
cls.cfg = config.load_config()
|
self.base_url = '%s/%s' % (self.cfg.marconi.url,
|
||||||
cls.mconf = cls.load_conf(cls.cfg.marconi.config).conf
|
self.cfg.marconi.version)
|
||||||
cls.limits = cls.mconf['limits:transport']
|
|
||||||
|
|
||||||
cls.base_url = '%s/%s' % (cls.cfg.marconi.url,
|
self.headers_response_empty = set(['location'])
|
||||||
cls.cfg.marconi.version)
|
|
||||||
|
|
||||||
cls.header = helpers.create_marconi_headers(cls.cfg)
|
|
||||||
cls.headers_response_empty = set(['location'])
|
|
||||||
cls.headers_response_with_body = set(['content-location',
|
|
||||||
'content-type'])
|
|
||||||
|
|
||||||
@ddt.data('qtestqueue', 'TESTqueue', 'hyphen-name', '_undersore',
|
@ddt.data('qtestqueue', 'TESTqueue', 'hyphen-name', '_undersore',
|
||||||
'i' * 64)
|
'i' * 64)
|
||||||
@ -143,21 +134,12 @@ class TestQueueMetaData(base.FunctionalTestBase):
|
|||||||
|
|
||||||
"""Tests for queue metadata."""
|
"""Tests for queue metadata."""
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setUpClass(cls):
|
|
||||||
cls.cfg = config.load_config()
|
|
||||||
cls.mconf = cls.load_conf(cls.cfg.marconi.config).conf
|
|
||||||
cls.limits = cls.mconf['limits:transport']
|
|
||||||
|
|
||||||
cls.base_url = '%s/%s' % (cls.cfg.marconi.url,
|
|
||||||
cls.cfg.marconi.version)
|
|
||||||
cls.header = helpers.create_marconi_headers(cls.cfg)
|
|
||||||
cls.headers_response_with_body = set(['location',
|
|
||||||
'content-type'])
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestQueueMetaData, self).setUp()
|
super(TestQueueMetaData, self).setUp()
|
||||||
|
|
||||||
|
self.base_url = '%s/%s' % (self.cfg.marconi.url,
|
||||||
|
self.cfg.marconi.version)
|
||||||
|
|
||||||
self.queue_url = self.base_url + '/queues/{}'.format(uuid.uuid1())
|
self.queue_url = self.base_url + '/queues/{}'.format(uuid.uuid1())
|
||||||
http.put(self.queue_url, self.header)
|
http.put(self.queue_url, self.header)
|
||||||
|
|
||||||
@ -200,32 +182,11 @@ class TestQueueMetaData(base.FunctionalTestBase):
|
|||||||
@ddt.ddt
|
@ddt.ddt
|
||||||
class TestQueueMisc(base.FunctionalTestBase):
|
class TestQueueMisc(base.FunctionalTestBase):
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def setUpClass(cls):
|
|
||||||
cls.cfg = config.load_config()
|
|
||||||
cls.mconf = cls.load_conf(cls.cfg.marconi.config).conf
|
|
||||||
cls.limits = cls.mconf['limits:transport']
|
|
||||||
|
|
||||||
cls.header = helpers.create_marconi_headers(cls.cfg)
|
|
||||||
cls.headers_response_empty = set(['location'])
|
|
||||||
cls.headers_response_with_body = set(['content-location',
|
|
||||||
'content-type'])
|
|
||||||
|
|
||||||
cls.base_url = '%s/%s' % (cls.cfg.marconi.url,
|
|
||||||
cls.cfg.marconi.version)
|
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestQueueMisc, self).setUp()
|
super(TestQueueMisc, self).setUp()
|
||||||
|
|
||||||
self.queue = uuid.uuid1()
|
self.base_url = '%s/%s' % (self.cfg.marconi.url,
|
||||||
self.queue_url = ("%(url)s/%(version)s/queues/%(queue)s" %
|
self.cfg.marconi.version)
|
||||||
{'url': self.cfg.marconi.url,
|
|
||||||
'version': self.cfg.marconi.version,
|
|
||||||
'queue': self.queue})
|
|
||||||
|
|
||||||
url = self.queue_url + '/metadata'
|
|
||||||
metadata = {"queue_metadata": "TEST METADATA"}
|
|
||||||
http.put(url, self.header, json.dumps(metadata))
|
|
||||||
|
|
||||||
def test_list_queues(self):
|
def test_list_queues(self):
|
||||||
"""List Queues."""
|
"""List Queues."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user