[Test] Add test for simple app based on rally api
* Add functional test for simple app based on rally api Change-Id: I9044805507b83639c7f75fe844997359486269c1
This commit is contained in:
parent
da46a90971
commit
ae49377418
30
tests/ci/rally_app.py
Normal file
30
tests/ci/rally_app.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Copyright 2016: Mirantis Inc.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
"""Simple app based on rally api for testing porpuses"""
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from rally import api as rapi
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
api = rapi.API(config_args=sys.argv[1:])
|
||||||
|
print(len(api.task.list()))
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
30
tests/functional/test_lib_api.py
Normal file
30
tests/functional/test_lib_api.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Copyright 2016: Mirantis Inc.
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
import subprocess
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from tests.functional import utils
|
||||||
|
|
||||||
|
|
||||||
|
class LibAPITestCase(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_rally_lib(self):
|
||||||
|
rally = utils.Rally(force_new_db=True)
|
||||||
|
cdir = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
app = os.path.join(cdir, "../ci/rally_app.py")
|
||||||
|
subprocess.check_output(
|
||||||
|
["python", app, "--config-file", rally.config_filename])
|
@ -86,6 +86,7 @@ class Rally(object):
|
|||||||
self.tmp_dir = tempfile.mkdtemp()
|
self.tmp_dir = tempfile.mkdtemp()
|
||||||
self.env = copy.deepcopy(os.environ)
|
self.env = copy.deepcopy(os.environ)
|
||||||
self.env["HOME"] = self.tmp_dir
|
self.env["HOME"] = self.tmp_dir
|
||||||
|
self.config_filename = None
|
||||||
|
|
||||||
if force_new_db or ("RCI_KEEP_DB" not in os.environ):
|
if force_new_db or ("RCI_KEEP_DB" not in os.environ):
|
||||||
config_filename = os.path.join(self.tmp_dir, "conf")
|
config_filename = os.path.join(self.tmp_dir, "conf")
|
||||||
@ -98,6 +99,7 @@ class Rally(object):
|
|||||||
self.args = ["rally", "--config-file", config_filename]
|
self.args = ["rally", "--config-file", config_filename]
|
||||||
subprocess.call(["rally-manage", "--config-file", config_filename,
|
subprocess.call(["rally-manage", "--config-file", config_filename,
|
||||||
"db", "recreate"], env=self.env)
|
"db", "recreate"], env=self.env)
|
||||||
|
self.config_filename = config_filename
|
||||||
else:
|
else:
|
||||||
self.args = ["rally"]
|
self.args = ["rally"]
|
||||||
subprocess.call(["rally-manage", "db", "recreate"], env=self.env)
|
subprocess.call(["rally-manage", "db", "recreate"], env=self.env)
|
||||||
|
Loading…
Reference in New Issue
Block a user