From bafe5357c2ad8cf9f87bf726db9cd8a3a1825123 Mon Sep 17 00:00:00 2001
From: Masayuki Igawa <masayuki@igawa.io>
Date: Wed, 27 Dec 2017 16:16:23 +0900
Subject: [PATCH] Switch to use stestr directly

This commit makes to use stestr instead of ostestr
directly. ostestr>1.0.0 has started to use stestr instead of
testrepository. So there is no reason to use ostestr anymore.

Change-Id: I6327d50c9f6dd19f1de24b9b51532104fb3e916e
---
 .../{run_ostestr.sh => run_stestr.sh}         |  2 +-
 test-requirements.txt                         |  3 +--
 tox.ini                                       | 25 +++++++++++--------
 3 files changed, 17 insertions(+), 13 deletions(-)
 rename openstackclient/tests/functional/{run_ostestr.sh => run_stestr.sh} (96%)

diff --git a/openstackclient/tests/functional/run_ostestr.sh b/openstackclient/tests/functional/run_stestr.sh
similarity index 96%
rename from openstackclient/tests/functional/run_ostestr.sh
rename to openstackclient/tests/functional/run_stestr.sh
index a6adad965c..229b42b676 100755
--- a/openstackclient/tests/functional/run_ostestr.sh
+++ b/openstackclient/tests/functional/run_stestr.sh
@@ -13,4 +13,4 @@ fi
 echo 'Running tests with:'
 env | grep OS
 
-ostestr $*
+stestr run $*
diff --git a/test-requirements.txt b/test-requirements.txt
index fcd7bc7803..0c64e906a0 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -15,8 +15,7 @@ requests-mock>=1.1.0 # Apache-2.0
 sphinx>=1.6.2 # BSD
 stevedore>=1.20.0 # Apache-2.0
 os-client-config>=1.28.0 # Apache-2.0
-os-testr>=1.0.0 # Apache-2.0
-testrepository>=0.0.18 # Apache-2.0/BSD
+stestr>=1.0.0 # Apache-2.0
 testtools>=2.2.0 # MIT
 tempest>=17.1.0 # Apache-2.0
 osprofiler>=1.4.0 # Apache-2.0
diff --git a/tox.ini b/tox.ini
index 8ce7ce8c93..8b5454f4ac 100644
--- a/tox.ini
+++ b/tox.ini
@@ -14,8 +14,8 @@ deps =
   -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt}
   -r{toxinidir}/test-requirements.txt
   -r{toxinidir}/requirements.txt
-commands = ostestr {posargs}
-whitelist_externals = ostestr
+commands = stestr run {posargs}
+whitelist_externals = stestr
 
 [testenv:fast8]
 # Use same environment directory as pep8 env to save space and install time
@@ -63,20 +63,20 @@ commands =
     pip install -q -U -e "git+file://{toxinidir}/../os-client-config#egg=os_client_config"
     pip install -q -e "git+file://{toxinidir}/../python-openstacksdk#egg=openstacksdk"
     pip freeze
-    ostestr {posargs}
-whitelist_externals = ostestr
+    stestr run {posargs}
+whitelist_externals = stestr
 
 [testenv:functional]
 setenv = OS_TEST_PATH=./openstackclient/tests/functional
 passenv = OS_*
-whitelist_externals = openstackclient/tests/functional/run_ostestr.sh
+whitelist_externals = openstackclient/tests/functional/run_stestr.sh
 commands =
-    {toxinidir}/openstackclient/tests/functional/run_ostestr.sh {posargs}
+    {toxinidir}/openstackclient/tests/functional/run_stestr.sh {posargs}
 
 [testenv:functional-tips]
 setenv = OS_TEST_PATH=./openstackclient/tests/functional
 passenv = OS_*
-whitelist_externals = openstackclient/tests/functional/run_ostestr.sh
+whitelist_externals = openstackclient/tests/functional/run_stestr.sh
 commands =
     pip install -q -U -e "git+file://{toxinidir}/../cliff#egg=cliff"
     pip install -q -U -e "git+file://{toxinidir}/../keystoneauth#egg=keystoneauth"
@@ -84,15 +84,20 @@ commands =
     pip install -q -U -e "git+file://{toxinidir}/../os-client-config#egg=os_client_config"
     pip install -q -U -e "git+file://{toxinidir}/../python-openstacksdk#egg=openstacksdk"
     pip freeze
-    {toxinidir}/openstackclient/tests/functional/run_ostestr.sh {posargs}
+    {toxinidir}/openstackclient/tests/functional/run_stestr.sh {posargs}
 
 [testenv:venv]
 commands = {posargs}
 
 [testenv:cover]
+setenv =
+    VIRTUAL_ENV={envdir}
+    PYTHON=coverage run --source openstackclient --parallel-mode
 commands =
-    python setup.py test --coverage --testr-args='{posargs}'
-    coverage report
+    stestr -q run {posargs}
+    coverage combine
+    coverage html -d cover
+    coverage xml -o cover/coverage.xml
 
 [testenv:debug]
 passenv = OS_*