From 65538f145d48e24258987f11cdbdace051d69507 Mon Sep 17 00:00:00 2001 From: sslypushenko Date: Mon, 22 Sep 2014 16:32:21 +0300 Subject: [PATCH] Rename refstack-client to refstack_client This renaming and change of project structure is necessary for adding the unit tests. Change-Id: I1893afbb05c86c83312983b12ce601d59a7fb417 --- .testr.conf | 2 +- refstack-client | 31 +++++++++++++++++++ {tests => refstack_client}/__init__.py | 0 .../refstack_client.py | 13 +++----- .../scripts/prep_cloud.py | 0 .../subunit_processor.py | 0 .../tests}/__init__.py | 0 refstack_client/tests/unit/__init__.py | 0 .../tests}/unit/tests.py | 0 setup.cfg | 2 +- tox.ini | 2 +- 11 files changed, 38 insertions(+), 12 deletions(-) create mode 100755 refstack-client rename {tests => refstack_client}/__init__.py (100%) rename refstack-client/refstack-client => refstack_client/refstack_client.py (96%) rename {refstack-client => refstack_client}/scripts/prep_cloud.py (100%) rename {refstack-client => refstack_client}/subunit_processor.py (100%) rename {tests/unit => refstack_client/tests}/__init__.py (100%) create mode 100644 refstack_client/tests/unit/__init__.py rename {tests => refstack_client/tests}/unit/tests.py (100%) diff --git a/.testr.conf b/.testr.conf index 2109af6..5ffe9b7 100644 --- a/.testr.conf +++ b/.testr.conf @@ -1,4 +1,4 @@ [DEFAULT] -test_command=OS_STDOUT_CAPTURE=1 OS_STDERR_CAPTURE=1 ${PYTHON:-python} -m subunit.run discover -t ./ ./tests $LISTOPT $IDOPTION +test_command=OS_STDOUT_CAPTURE=1 OS_STDERR_CAPTURE=1 ${PYTHON:-python} -m subunit.run discover -t ./ ./refstack_client/tests $LISTOPT $IDOPTION test_id_option=--load-list $IDFILE test_list_option=--list diff --git a/refstack-client b/refstack-client new file mode 100755 index 0000000..3978d9e --- /dev/null +++ b/refstack-client @@ -0,0 +1,31 @@ +#!/usr/bin/env python +# +# Copyright (c) 2014 Piston Cloud Computing, 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. +# + + +""" +Run Tempest and upload results to Refstack. + +This module runs the Tempest test suite on an OpenStack environment given a +Tempest configuration file. + +""" +from refstack_client import refstack_client + +if __name__ == '__main__': + args = refstack_client.parse_cli_args() + test = refstack_client.RefstackClient(args) + test.run() \ No newline at end of file diff --git a/tests/__init__.py b/refstack_client/__init__.py similarity index 100% rename from tests/__init__.py rename to refstack_client/__init__.py diff --git a/refstack-client/refstack-client b/refstack_client/refstack_client.py similarity index 96% rename from refstack-client/refstack-client rename to refstack_client/refstack_client.py index b4b2350..170a6fc 100755 --- a/refstack-client/refstack-client +++ b/refstack_client/refstack_client.py @@ -29,7 +29,6 @@ import ConfigParser import json import logging import os -import requests import subprocess import time @@ -39,7 +38,7 @@ from subunit_processor import SubunitProcessor class RefstackClient: - log_format = "%(asctime)s %(name)s %(levelname)s %(message)s" + log_format = "%(asctime)s %(name)s:%(lineno)d %(levelname)s %(message)s" def __init__(self, args): '''Prepare a tempest test against a cloud.''' @@ -184,8 +183,8 @@ class RefstackClient: self.logger.error('%s failed to complete' % (e)) -if __name__ == '__main__': - ''' Generate tempest.conf from a tempest.conf.sample and then run test.''' +def parse_cli_args(args=None): + parser = argparse.ArgumentParser(description='Starts a tempest test', formatter_class=argparse. ArgumentDefaultsHelpFormatter) @@ -224,8 +223,4 @@ if __name__ == '__main__': type=str, help='Specify a subset of test cases to run ' '(e.g. --test-cases tempest.api.compute).') - - args = parser.parse_args() - - test = RefstackClient(args) - test.run() + return parser.parse_args(args=args) diff --git a/refstack-client/scripts/prep_cloud.py b/refstack_client/scripts/prep_cloud.py similarity index 100% rename from refstack-client/scripts/prep_cloud.py rename to refstack_client/scripts/prep_cloud.py diff --git a/refstack-client/subunit_processor.py b/refstack_client/subunit_processor.py similarity index 100% rename from refstack-client/subunit_processor.py rename to refstack_client/subunit_processor.py diff --git a/tests/unit/__init__.py b/refstack_client/tests/__init__.py similarity index 100% rename from tests/unit/__init__.py rename to refstack_client/tests/__init__.py diff --git a/refstack_client/tests/unit/__init__.py b/refstack_client/tests/unit/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/unit/tests.py b/refstack_client/tests/unit/tests.py similarity index 100% rename from tests/unit/tests.py rename to refstack_client/tests/unit/tests.py diff --git a/setup.cfg b/setup.cfg index cd4bd35..2df8b50 100644 --- a/setup.cfg +++ b/setup.cfg @@ -20,7 +20,7 @@ classifier = [files] packages = - refstack-client + refstack_client [global] setup-hooks = diff --git a/tox.ini b/tox.ini index 0d88f2e..8fdd644 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py33,pep8 +envlist = py27,pep8 minversion = 1.6 skipsdist = True