Add script to run functional tests locally

- Added script that can run part of functional tests locally
- Added needed mocks in base.py file so that we don't interact with keystone
- Added small a description how to run new script

Change-Id: I1867fb93f540c8f061fd09c40a283ce1ef2c072c
This commit is contained in:
Anastasia Kuznetsova 2014-09-23 19:03:35 +04:00 committed by Renat Akhmerov
parent 411812e5fd
commit aacdb47af3
5 changed files with 85 additions and 3 deletions

View File

@ -77,4 +77,13 @@ To run the examples find them in mistral-extra repository (https://github.com/st
Tests
-----
Information about automated tests for Mistral can be found here: https://wiki.openstack.org/wiki/Mistral/Testing
There is an ability to run part of functional tests in non-openstack mode locally. To do this:
# set *auth_enable=false* in the mistral.conf and restart Mistral
# execute:
bash run_functional_tests.sh
To run tests for only one version need to specify it: bash run_functional_tests.sh v1
More information about automated tests for Mistral can be found here: https://wiki.openstack.org/wiki/Mistral/Testing

View File

@ -14,8 +14,11 @@
# under the License.
import json
import mock
import os
import time
from tempest import auth
from tempest import clients
from tempest.common import rest_client
from tempest import config
@ -266,6 +269,24 @@ class MistralClientV2(MistralClientBase):
return resp, json.loads(body)
class AuthProv(auth.KeystoneV2AuthProvider):
def __init__(self):
self.alt_part = None
def auth_request(self, method, url, *args, **kwargs):
req_url, headers, body = super(AuthProv, self).auth_request(
method, url, *args, **kwargs)
return 'http://localhost:8989/{0}/{1}'.format(
os.environ['VERSION'], url), headers, body
def get_auth(self):
return 'mock_str', 'mock_str'
def base_url(self, *args, **kwargs):
return ''
class TestCase(tempest.test.BaseTestCase):
@classmethod
@ -275,7 +296,12 @@ class TestCase(tempest.test.BaseTestCase):
"""
super(TestCase, cls).setUpClass()
cls.mgr = clients.Manager()
if 'WITHOUT_AUTH' in os.environ:
cls.mgr = mock.MagicMock()
cls.mgr.auth_provider = AuthProv()
else:
cls.mgr = clients.Manager()
if cls._version == 1:
cls.client = MistralClientV1(cls.mgr.auth_provider)
if cls._version == 2:

View File

@ -26,3 +26,4 @@ SQLAlchemy>=0.7.8,!=0.9.5,<=0.9.99
stevedore>=0.14
yaql==0.2.1 # This is not in global requirements
jsonschema>=2.0.0,<3.0.0
mock>=1.0

47
run_functional_tests.sh Executable file
View File

@ -0,0 +1,47 @@
#! /usr/bin/env bash
ARG=$1
function pre_hook() {
export WITHOUT_AUTH="True"
IS_TEMPEST=$(pip freeze | grep tempest)
if [ -z "$IS_TEMPEST" ]
then echo "$(tput setaf 4)No such module 'tempest' in the system. Before running this script please install 'tempest' module using : pip install git+http://github.com/openstack/tempest.git$(tput sgr 0)"
exit 1
fi
}
function run_tests_by_version() {
echo "$(tput setaf 4)Running integration API and workflow execution tests for v$1$(tput sgr 0)"
export VERSION="v$1"
nosetests -v mistral/tests/functional/api/v$1/
unset VERSION
}
function run_tests() {
if [ -z "$ARG" ]
then
run_tests_by_version 1
run_tests_by_version 2
elif [ "$ARG" == "v1" ]
then
run_tests_by_version 1
elif [ "$ARG" == "v2" ]
then
run_tests_by_version 2
fi
}
function post_hook () {
unset LOCAL_RUN
}
#----------main-part----------
echo "$(tput setaf 4)Preparation for tests running...$(tput sgr 0)"
pre_hook
echo "$(tput setaf 4)Running tests...$(tput sgr 0)"
run_tests
post_hook

View File

@ -10,7 +10,6 @@ sphinxcontrib-pecanwsme>=0.8
sphinxcontrib-httpdomain
docutils==0.9.1
fixtures>=0.3.14
mock>=1.0
nose
testrepository>=0.0.18
testtools>=0.9.34