summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnastasia Kuznetsova <akuznetsova@mirantis.com>2014-09-23 19:03:35 +0400
committerRenat Akhmerov <rakhmerov@mirantis.com>2014-09-25 22:53:43 +0000
commitaacdb47af3dd18237c0ba8b73eb8ef0a2fb86b01 (patch)
treeeca13917e52c5efedeabcc3e5f58f7703f2a8365
parent411812e5fde38f79c3d750af44d49bf8a09c13e4 (diff)
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
Notes
Notes (review): Verified+2: Jenkins Code-Review+2: Nikolay Mahotkin <nmakhotkin@mirantis.com> Workflow+1: Nikolay Mahotkin <nmakhotkin@mirantis.com> Code-Review+2: Renat Akhmerov <rakhmerov@mirantis.com> Submitted-by: Jenkins Submitted-at: Fri, 26 Sep 2014 06:26:30 +0000 Reviewed-on: https://review.openstack.org/123465 Project: stackforge/mistral Branch: refs/heads/master
-rw-r--r--README.rst11
-rw-r--r--mistral/tests/functional/base.py28
-rw-r--r--requirements.txt1
-rwxr-xr-xrun_functional_tests.sh47
-rw-r--r--test-requirements.txt1
5 files changed, 85 insertions, 3 deletions
diff --git a/README.rst b/README.rst
index 9b6c303..a5f35e6 100644
--- a/README.rst
+++ b/README.rst
@@ -77,4 +77,13 @@ To run the examples find them in mistral-extra repository (https://github.com/st
77Tests 77Tests
78----- 78-----
79 79
80Information about automated tests for Mistral can be found here: https://wiki.openstack.org/wiki/Mistral/Testing 80There is an ability to run part of functional tests in non-openstack mode locally. To do this:
81
82 # set *auth_enable=false* in the mistral.conf and restart Mistral
83 # execute:
84
85 bash run_functional_tests.sh
86
87To run tests for only one version need to specify it: bash run_functional_tests.sh v1
88
89More information about automated tests for Mistral can be found here: https://wiki.openstack.org/wiki/Mistral/Testing
diff --git a/mistral/tests/functional/base.py b/mistral/tests/functional/base.py
index 4b06e64..9705675 100644
--- a/mistral/tests/functional/base.py
+++ b/mistral/tests/functional/base.py
@@ -14,8 +14,11 @@
14# under the License. 14# under the License.
15 15
16import json 16import json
17import mock
18import os
17import time 19import time
18 20
21from tempest import auth
19from tempest import clients 22from tempest import clients
20from tempest.common import rest_client 23from tempest.common import rest_client
21from tempest import config 24from tempest import config
@@ -266,6 +269,24 @@ class MistralClientV2(MistralClientBase):
266 return resp, json.loads(body) 269 return resp, json.loads(body)
267 270
268 271
272class AuthProv(auth.KeystoneV2AuthProvider):
273
274 def __init__(self):
275 self.alt_part = None
276
277 def auth_request(self, method, url, *args, **kwargs):
278 req_url, headers, body = super(AuthProv, self).auth_request(
279 method, url, *args, **kwargs)
280 return 'http://localhost:8989/{0}/{1}'.format(
281 os.environ['VERSION'], url), headers, body
282
283 def get_auth(self):
284 return 'mock_str', 'mock_str'
285
286 def base_url(self, *args, **kwargs):
287 return ''
288
289
269class TestCase(tempest.test.BaseTestCase): 290class TestCase(tempest.test.BaseTestCase):
270 291
271 @classmethod 292 @classmethod
@@ -275,7 +296,12 @@ class TestCase(tempest.test.BaseTestCase):
275 """ 296 """
276 super(TestCase, cls).setUpClass() 297 super(TestCase, cls).setUpClass()
277 298
278 cls.mgr = clients.Manager() 299 if 'WITHOUT_AUTH' in os.environ:
300 cls.mgr = mock.MagicMock()
301 cls.mgr.auth_provider = AuthProv()
302 else:
303 cls.mgr = clients.Manager()
304
279 if cls._version == 1: 305 if cls._version == 1:
280 cls.client = MistralClientV1(cls.mgr.auth_provider) 306 cls.client = MistralClientV1(cls.mgr.auth_provider)
281 if cls._version == 2: 307 if cls._version == 2:
diff --git a/requirements.txt b/requirements.txt
index afcc4b8..79829ee 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -26,3 +26,4 @@ SQLAlchemy>=0.7.8,!=0.9.5,<=0.9.99
26stevedore>=0.14 26stevedore>=0.14
27yaql==0.2.1 # This is not in global requirements 27yaql==0.2.1 # This is not in global requirements
28jsonschema>=2.0.0,<3.0.0 28jsonschema>=2.0.0,<3.0.0
29mock>=1.0
diff --git a/run_functional_tests.sh b/run_functional_tests.sh
new file mode 100755
index 0000000..5c5886a
--- /dev/null
+++ b/run_functional_tests.sh
@@ -0,0 +1,47 @@
1#! /usr/bin/env bash
2
3ARG=$1
4
5function pre_hook() {
6 export WITHOUT_AUTH="True"
7 IS_TEMPEST=$(pip freeze | grep tempest)
8 if [ -z "$IS_TEMPEST" ]
9 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)"
10 exit 1
11 fi
12}
13
14function run_tests_by_version() {
15 echo "$(tput setaf 4)Running integration API and workflow execution tests for v$1$(tput sgr 0)"
16 export VERSION="v$1"
17 nosetests -v mistral/tests/functional/api/v$1/
18 unset VERSION
19}
20
21function run_tests() {
22 if [ -z "$ARG" ]
23 then
24 run_tests_by_version 1
25 run_tests_by_version 2
26 elif [ "$ARG" == "v1" ]
27 then
28 run_tests_by_version 1
29 elif [ "$ARG" == "v2" ]
30 then
31 run_tests_by_version 2
32 fi
33}
34
35function post_hook () {
36 unset LOCAL_RUN
37}
38
39#----------main-part----------
40
41echo "$(tput setaf 4)Preparation for tests running...$(tput sgr 0)"
42pre_hook
43echo "$(tput setaf 4)Running tests...$(tput sgr 0)"
44run_tests
45
46post_hook
47
diff --git a/test-requirements.txt b/test-requirements.txt
index d4519ae..4db8eab 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -10,7 +10,6 @@ sphinxcontrib-pecanwsme>=0.8
10sphinxcontrib-httpdomain 10sphinxcontrib-httpdomain
11docutils==0.9.1 11docutils==0.9.1
12fixtures>=0.3.14 12fixtures>=0.3.14
13mock>=1.0
14nose 13nose
15testrepository>=0.0.18 14testrepository>=0.0.18
16testtools>=0.9.34 15testtools>=0.9.34