Merge "Cleanup integration tests setup"

This commit is contained in:
Jenkins 2016-07-13 22:43:28 +00:00 committed by Gerrit Code Review
commit 45b97743fd
7 changed files with 6 additions and 95 deletions

View File

@ -25,7 +25,7 @@ setenv = {[testenv]setenv}
setenv = {[testenv]setenv} setenv = {[testenv]setenv}
ZAQAR_TEST_INTEGRATION=1 ZAQAR_TEST_INTEGRATION=1
OS_TEST_PATH=./zaqar/tests/functional OS_TEST_PATH=./zaqar/tests/functional
commands = python setup.py testr --slowest --testr-args='--concurrency 1' commands = python setup.py testr --slowest --testr-args='--concurrency 1 {posargs}'
[testenv:pep8] [testenv:pep8]
commands = flake8 commands = flake8
@ -86,4 +86,4 @@ import_exceptions = zaqar.openstack.common.gettextutils._,zaqar.i18n._
# upstream infra does not yet support it. Once that's fixed, we can # upstream infra does not yet support it. Once that's fixed, we can
# drop the install_command. # drop the install_command.
install_command = pip install -U --force-reinstall {opts} {packages} install_command = pip install -U --force-reinstall {opts} {packages}
commands = sphinx-build -a -E -W -d install-guide/build/doctrees -b html install-guide/source install-guide/build/html commands = sphinx-build -a -E -W -d install-guide/build/doctrees -b html install-guide/source install-guide/build/html

View File

@ -2,14 +2,7 @@
# run_tests = True # run_tests = True
unreliable = True unreliable = True
[auth]
# auth_on = False
# url = https://127.0.0.1:5000/v2.0/tokens
# username = None
# password = None
[zaqar] [zaqar]
# run_server = True
# url = http://0.0.0.0:8888 # url = http://0.0.0.0:8888
# config = functional-zaqar.conf # config = functional-zaqar.conf

View File

@ -95,15 +95,10 @@ class FunctionalTestBase(testing.TestBase):
self.__class__.class_ttl_gc_interval = 60 self.__class__.class_ttl_gc_interval = 60
if _TEST_INTEGRATION: if _TEST_INTEGRATION:
# TODO(kgriffs): This code should be replaced to use if not (self.server and self.server.is_alive()):
# an external wsgi server instance. self.server = self.server_class()
self.server.start(self.mconf)
# NOTE(flaper87): Use running instances. self.addCleanup(self.server.process.terminate)
if self.cfg.zaqar.run_server:
if not (self.server and self.server.is_alive()):
self.server = self.server_class()
self.server.start(self.mconf)
self.addCleanup(self.server.process.terminate)
self.client = http.Client() self.client = http.Client()
else: else:
@ -117,10 +112,6 @@ class FunctionalTestBase(testing.TestBase):
self.headers = helpers.create_zaqar_headers(self.cfg) self.headers = helpers.create_zaqar_headers(self.cfg)
if self.cfg.auth.auth_on:
auth_token = helpers.get_keystone_token(self.cfg, self.client)
self.headers["X-Auth-Token"] = auth_token
self.headers_response_with_body = {'location', 'content-type'} self.headers_response_with_body = {'location', 'content-type'}
self.client.set_headers(self.headers) self.client.set_headers(self.headers)

View File

@ -23,16 +23,8 @@ _DEFAULT = (
cfg.BoolOpt("run_tests", default=True), cfg.BoolOpt("run_tests", default=True),
) )
_AUTH_OPTIONS = (
cfg.BoolOpt("auth_on", default=False),
cfg.StrOpt("url", default="https://127.0.0.1:5000/v2.0/tokens"),
cfg.StrOpt("username"),
cfg.StrOpt("password"),
)
_ZAQAR_OPTIONS = ( _ZAQAR_OPTIONS = (
cfg.BoolOpt("run_server", default=True),
cfg.StrOpt("url", default="http://127.0.0.1:8888"), cfg.StrOpt("url", default="http://127.0.0.1:8888"),
cfg.StrOpt("config", default="functional-zaqar.conf"), cfg.StrOpt("config", default="functional-zaqar.conf"),
) )
@ -47,7 +39,6 @@ _HEADERS_OPTIONS = (
def load_config(): def load_config():
conf = cfg.ConfigOpts() conf = cfg.ConfigOpts()
conf.register_opts(_DEFAULT) conf.register_opts(_DEFAULT)
conf.register_opts(_AUTH_OPTIONS, group="auth")
conf.register_opts(_ZAQAR_OPTIONS, group="zaqar") conf.register_opts(_ZAQAR_OPTIONS, group="zaqar")
conf.register_opts(_HEADERS_OPTIONS, group="headers") conf.register_opts(_HEADERS_OPTIONS, group="headers")

View File

@ -18,28 +18,6 @@ import string
import uuid import uuid
def get_keystone_token(conf, client):
"""Gets Keystone Auth token."""
body = {
'auth': {
'passwordCredentials': {
'username': conf.auth.username,
'password': conf.auth.password
},
},
}
header = {"Content-Type": "application/json",
"Accept": "application/json"}
response = client.post(url=conf.auth.url,
headers=header,
data=body)
response_body = response.json()
return response_body['access']['token']['id']
def create_zaqar_headers(conf): def create_zaqar_headers(conf):
"""Returns headers to be used for all Zaqar requests.""" """Returns headers to be used for all Zaqar requests."""

View File

@ -13,7 +13,6 @@
# 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.
import copy
import uuid import uuid
import ddt import ddt
@ -125,26 +124,6 @@ class TestInsertQueue(base.V1FunctionalTestBase):
test_insert_queue_invalid_name.tags = ['negative'] test_insert_queue_invalid_name.tags = ['negative']
def test_insert_queue_invalid_authtoken(self):
"""Insert Queue with invalid authtoken."""
# NOTE(flaper87): Currently, tearDown
# depends on this attribute. Needs to
# be fixed.
self.url = self.base_url + '/queues/invalidauthtoken'
self.addCleanup(self.client.delete, self.url)
if not self.cfg.auth.auth_on:
self.skipTest("Auth is not on!")
header = copy.copy(self.header)
header['X-Auth-Token'] = 'invalid'
result = self.client.put(self.url, headers=header)
self.assertEqual(401, result.status_code)
test_insert_queue_invalid_authtoken.tags = ['negative']
def test_insert_queue_header_plaintext(self): def test_insert_queue_header_plaintext(self):
"""Insert Queue with 'Accept': 'plain/text'.""" """Insert Queue with 'Accept': 'plain/text'."""
path = '/queues/plaintextheader' path = '/queues/plaintextheader'

View File

@ -13,7 +13,6 @@
# 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.
import copy
import uuid import uuid
import ddt import ddt
@ -116,26 +115,6 @@ class TestInsertQueue(base.V1_1FunctionalTestBase):
test_insert_queue_invalid_name.tags = ['negative'] test_insert_queue_invalid_name.tags = ['negative']
def test_insert_queue_invalid_authtoken(self):
"""Insert Queue with invalid authtoken."""
# NOTE(flaper87): Currently, tearDown
# depends on this attribute. Needs to
# be fixed.
self.url = self.base_url + '/queues/invalidauthtoken'
self.addCleanup(self.client.delete, self.url)
if not self.cfg.auth.auth_on:
self.skipTest("Auth is not on!")
header = copy.copy(self.header)
header['X-Auth-Token'] = 'invalid'
result = self.client.put(self.url, headers=header)
self.assertEqual(401, result.status_code)
test_insert_queue_invalid_authtoken.tags = ['negative']
def test_insert_queue_header_plaintext(self): def test_insert_queue_header_plaintext(self):
"""Insert Queue with 'Accept': 'plain/text'.""" """Insert Queue with 'Accept': 'plain/text'."""
path = '/queues/plaintextheader' path = '/queues/plaintextheader'