Add script to run functional CLI and client tests locally
Change-Id: Ic6f3e96d037b9096ea9e0689cb4f66b4cb05fb8e
This commit is contained in:
parent
6d1d882134
commit
ad163f0ecf
mistralclient/tests/functional
run_functional_tests.sh
35
mistralclient/tests/functional/cli/base.py
Normal file
35
mistralclient/tests/functional/cli/base.py
Normal file
@ -0,0 +1,35 @@
|
||||
# Copyright (c) 2014 Mirantis, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import os
|
||||
|
||||
from tempest import cli
|
||||
|
||||
|
||||
class MistralCLIAuth(cli.ClientTestBase):
|
||||
|
||||
_mistral_url = None
|
||||
|
||||
def mistral(self, action, flags='', params='', admin=True, fail_ok=False,
|
||||
keystone_version=3):
|
||||
"""Executes Mistral command."""
|
||||
mistral_url_op = "--os-mistral-url %s" % self._mistral_url
|
||||
|
||||
if 'WITHOUT_AUTH' in os.environ:
|
||||
return cli.execute(
|
||||
'mistral %s' % mistral_url_op, action, flags, params)
|
||||
else:
|
||||
return self.cmd_with_auth(
|
||||
'mistral %s' % mistral_url_op, action, flags, params, admin,
|
||||
fail_ok, keystone_version)
|
@ -14,27 +14,19 @@
|
||||
|
||||
import os
|
||||
|
||||
from tempest import cli
|
||||
from tempest import exceptions
|
||||
|
||||
from mistralclient.tests.functional.cli import base
|
||||
|
||||
|
||||
MISTRAL_URL = "http://localhost:8989/v1"
|
||||
|
||||
|
||||
class MistralCLIAuth(cli.ClientTestBase):
|
||||
|
||||
def mistral(self, action, flags='', params='', admin=True, fail_ok=False,
|
||||
keystone_version=3):
|
||||
"""Executes Mistral command."""
|
||||
mistral_url_op = "--os-mistral-url %s" % MISTRAL_URL
|
||||
return self.cmd_with_auth(
|
||||
'mistral %s' % mistral_url_op, action, flags, params, admin,
|
||||
fail_ok, keystone_version)
|
||||
|
||||
|
||||
class SimpleMistralCLITests(MistralCLIAuth):
|
||||
class SimpleMistralCLITests(base.MistralCLIAuth):
|
||||
"""Basic tests, check '-list', '-help' commands."""
|
||||
|
||||
_mistral_url = MISTRAL_URL
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(SimpleMistralCLITests, cls).setUpClass()
|
||||
@ -58,7 +50,9 @@ class SimpleMistralCLITests(MistralCLIAuth):
|
||||
'Description', 'State', 'Tags'])
|
||||
|
||||
|
||||
class ClientTestBase(MistralCLIAuth):
|
||||
class ClientTestBase(base.MistralCLIAuth):
|
||||
|
||||
_mistral_url = MISTRAL_URL
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -14,28 +14,19 @@
|
||||
|
||||
import os
|
||||
|
||||
from tempest import cli
|
||||
from tempest import exceptions
|
||||
|
||||
from mistralclient.tests.functional.cli import base
|
||||
|
||||
|
||||
MISTRAL_URL = "http://localhost:8989/v2"
|
||||
|
||||
|
||||
class MistralCLIAuth(cli.ClientTestBase):
|
||||
|
||||
def mistral(self, action, flags='', params='', admin=True, fail_ok=False,
|
||||
keystone_version=3):
|
||||
"""Executes Mistral command."""
|
||||
mistral_url_op = "--os-mistral-url %s" % MISTRAL_URL
|
||||
|
||||
return self.cmd_with_auth(
|
||||
'mistral %s' % mistral_url_op, action, flags, params, admin,
|
||||
fail_ok, keystone_version)
|
||||
|
||||
|
||||
class SimpleMistralCLITests(MistralCLIAuth):
|
||||
class SimpleMistralCLITests(base.MistralCLIAuth):
|
||||
"""Basic tests, check '-list', '-help' commands."""
|
||||
|
||||
_mistral_url = MISTRAL_URL
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(SimpleMistralCLITests, cls).setUpClass()
|
||||
@ -66,7 +57,9 @@ class SimpleMistralCLITests(MistralCLIAuth):
|
||||
'State'])
|
||||
|
||||
|
||||
class ClientTestBase(MistralCLIAuth):
|
||||
class ClientTestBase(base.MistralCLIAuth):
|
||||
|
||||
_mistral_url = MISTRAL_URL
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
@ -9,22 +9,29 @@ from mistralclient.api.v1 import client as mclient
|
||||
|
||||
|
||||
class ClientAuth(rest_client.RestClient):
|
||||
def __init__(self, auth_provider):
|
||||
def __init__(self, auth_provider, url):
|
||||
super(ClientAuth, self).__init__(auth_provider)
|
||||
|
||||
self.mistral_client = mclient.Client(
|
||||
auth_token=self.auth_provider.get_token(),
|
||||
mistral_url="http://localhost:8989/v1")
|
||||
mistral_url=url)
|
||||
|
||||
|
||||
class MistralBase(testtools.TestCase):
|
||||
|
||||
_mistral_url = None
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(MistralBase, cls).setUpClass()
|
||||
|
||||
mgr = clients.Manager()
|
||||
cls.mistral_client = ClientAuth(mgr.auth_provider).mistral_client
|
||||
if 'WITHOUT_AUTH' in os.environ:
|
||||
cls.mistral_client = mclient.Client(
|
||||
mistral_url=cls._mistral_url)
|
||||
else:
|
||||
mgr = clients.Manager()
|
||||
cls.mistral_client = ClientAuth(
|
||||
mgr.auth_provider, cls._mistral_url).mistral_client
|
||||
|
||||
cls.definition = open(os.path.relpath(
|
||||
'functionaltests/resources/v1/wb_v1.yaml',
|
||||
|
@ -1,7 +1,12 @@
|
||||
from base import MistralBase
|
||||
|
||||
|
||||
class Workbooks(MistralBase):
|
||||
class MistralURLDefine(MistralBase):
|
||||
|
||||
_mistral_url = "http://localhost:8989/v1"
|
||||
|
||||
|
||||
class Workbooks(MistralURLDefine):
|
||||
|
||||
def test_get_workbook_list(self):
|
||||
wbs = self.mistral_client.workbooks.list()
|
||||
@ -36,7 +41,7 @@ class Workbooks(MistralBase):
|
||||
self.assertEqual(self.definition, received_definition)
|
||||
|
||||
|
||||
class Executions(MistralBase):
|
||||
class Executions(MistralURLDefine):
|
||||
|
||||
def test_create_execution(self):
|
||||
execution = self.create_execution()
|
||||
@ -69,7 +74,7 @@ class Executions(MistralBase):
|
||||
self.assertEqual(execution.id, received_exec.id)
|
||||
|
||||
|
||||
class Tasks(MistralBase):
|
||||
class Tasks(MistralURLDefine):
|
||||
|
||||
def test_list_tasks(self):
|
||||
execution = self.create_execution()
|
||||
|
50
run_functional_tests.sh
Executable file
50
run_functional_tests.sh
Executable file
@ -0,0 +1,50 @@
|
||||
#! /usr/bin/env bash
|
||||
|
||||
ARG=$1
|
||||
|
||||
export USER_AUTH_SETTING=$(echo $OS_AUTH_URL)
|
||||
|
||||
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)"
|
||||
fi
|
||||
}
|
||||
|
||||
function run_tests_by_version() {
|
||||
export OS_AUTH_URL=""
|
||||
echo "$(tput setaf 4)Running integration CLI and python-mistralclient tests for v$1$(tput sgr 0)"
|
||||
export VERSION="v$1"
|
||||
nosetests -v mistralclient/tests/functional/cli/v$1/
|
||||
nosetests -v mistralclient/tests/functional/client/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
|
||||
export OS_AUTH_URL=$USER_AUTH_SETTING
|
||||
unset USER_AUTH_SETTING
|
||||
}
|
||||
#----------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
|
Loading…
Reference in New Issue
Block a user