From e8b1634d8f1c92862fc5400295e19bc914b3c2ed Mon Sep 17 00:00:00 2001
From: Nguyen Hai <nguyentrihai93@gmail.com>
Date: Thu, 7 Jun 2018 17:57:32 +0900
Subject: [PATCH] Switch to using stestr

stestr is maintained project to which all Openstack projects
should migrate.

[1] https://etherpad.openstack.org/p/YVR-python-pti
[2] https://governance.openstack.org/tc/reference/pti/python.html

Change-Id: Icc11037bd56a75a8d9abbdfda10a832437502565
---
 .gitignore            |  1 +
 .stestr.conf          |  3 +++
 .testr.conf           |  4 ----
 lower-constraints.txt |  2 +-
 test-requirements.txt |  2 +-
 tox.ini               | 16 +++++++++++-----
 6 files changed, 17 insertions(+), 11 deletions(-)
 create mode 100644 .stestr.conf
 delete mode 100644 .testr.conf

diff --git a/.gitignore b/.gitignore
index 4a895abc..868d2014 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,6 +20,7 @@ run_tests.log
 .idea/
 .tox/
 .venv/
+.stestr/
 
 # Files created by releasenotes build
 releasenotes/build
diff --git a/.stestr.conf b/.stestr.conf
new file mode 100644
index 00000000..f4b9d34d
--- /dev/null
+++ b/.stestr.conf
@@ -0,0 +1,3 @@
+[DEFAULT]
+test_path=./tackerclient/tests/unit
+top_path=./
diff --git a/.testr.conf b/.testr.conf
deleted file mode 100644
index 316dc9ec..00000000
--- a/.testr.conf
+++ /dev/null
@@ -1,4 +0,0 @@
-[DEFAULT]
-test_command=OS_STDOUT_CAPTURE=1 OS_STDERR_CAPTURE=1 ${PYTHON:-python} -m subunit.run discover -t ./ ${OS_TEST_PATH:-./tackerclient/tests/unit} $LISTOPT $IDOPTION
-test_id_option=--load-list $IDFILE
-test_list_option=--list
diff --git a/lower-constraints.txt b/lower-constraints.txt
index 67047a33..ff6d9b90 100644
--- a/lower-constraints.txt
+++ b/lower-constraints.txt
@@ -53,8 +53,8 @@ requestsexceptions==1.2.0
 rfc3986==0.3.1
 simplejson==3.5.1
 six==1.10.0
+stestr==2.0.0
 stevedore==1.20.0
-testrepository==0.0.18
 testtools==2.2.0
 traceback2==1.4.0
 unittest2==1.1.0
diff --git a/test-requirements.txt b/test-requirements.txt
index 2d9bd108..bf783f16 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -5,6 +5,6 @@ hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
 coverage!=4.4,>=4.0 # Apache-2.0
 fixtures>=3.0.0 # Apache-2.0/BSD
 python-subunit>=1.0.0 # Apache-2.0/BSD
-testrepository>=0.0.18 # Apache-2.0/BSD
+stestr>=2.0.0 # Apache-2.0
 testtools>=2.2.0 # MIT
 mock>=2.0.0 # BSD
diff --git a/tox.ini b/tox.ini
index 2cb4c961..6a8db5b0 100644
--- a/tox.ini
+++ b/tox.ini
@@ -11,10 +11,10 @@ setenv = VIRTUAL_ENV={envdir}
 usedevelop = True
 install_command = pip install {opts} {packages}
 deps =
-       -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt}
-       -r{toxinidir}/requirements.txt
-       -r{toxinidir}/test-requirements.txt
-commands = python setup.py testr --testr-args='{posargs}'
+  -c{env:UPPER_CONSTRAINTS_FILE:https://git.openstack.org/cgit/openstack/requirements/plain/upper-constraints.txt}
+  -r{toxinidir}/requirements.txt
+  -r{toxinidir}/test-requirements.txt
+commands = stestr run --slowest {posargs}
 
 [testenv:pep8]
 commands = flake8
@@ -32,7 +32,13 @@ deps = -r{toxinidir}/doc/requirements.txt
 commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasenotes/source releasenotes/build/html
 
 [testenv:cover]
-commands = python setup.py testr --coverage --testr-args='{posargs}'
+setenv =
+    PYTHON=coverage run --source tackerclient --parallel-mode
+commands =
+    stestr run {posargs}
+    coverage combine
+    coverage html -d cover
+    coverage xml -o cover/coverage.xml
 
 [flake8]
 # E125 continuation line does not distinguish itself from next logical line