From 3e728f945f42e28c4f912c58a45c297d219e03bb Mon Sep 17 00:00:00 2001
From: Vu Cong Tuan <tuanvc@vn.fujitsu.com>
Date: Tue, 24 Jul 2018 15:21:16 +0700
Subject: [PATCH] Switch to stestr

According to Openstack summit session [1],
stestr is maintained project to which all Openstack projects should migrate.
Let's switch to stestr as other projects have already moved to it.

[1] https://etherpad.openstack.org/p/YVR-python-pti

Change-Id: I1c4aaa0e0909f5272ab970950e3d21662dee2227
---
 .gitignore            |  3 +--
 .stestr.conf          |  3 +++
 .testr.conf           |  7 -------
 lower-constraints.txt |  2 +-
 requirements.txt      |  6 +++---
 test-requirements.txt |  2 +-
 tools/cover.sh        | 14 ++++++++++++--
 tox.ini               |  2 +-
 8 files changed, 22 insertions(+), 17 deletions(-)
 create mode 100644 .stestr.conf
 delete mode 100644 .testr.conf

diff --git a/.gitignore b/.gitignore
index ed95d113..17ed1608 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,8 +25,7 @@ pip-log.txt
 .tox
 cover
 cover-master
-nosetests.xml
-.testrepository
+.stestr/
 .venv
 
 # Translations
diff --git a/.stestr.conf b/.stestr.conf
new file mode 100644
index 00000000..8189a278
--- /dev/null
+++ b/.stestr.conf
@@ -0,0 +1,3 @@
+[DEFAULT]
+test_path=${OS_TEST_PATH:-./}
+top_dir=./
diff --git a/.testr.conf b/.testr.conf
deleted file mode 100644
index 6d83b3c4..00000000
--- a/.testr.conf
+++ /dev/null
@@ -1,7 +0,0 @@
-[DEFAULT]
-test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
-             OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
-             OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
-             ${PYTHON:-python} -m subunit.run discover -t ./ . $LISTOPT $IDOPTION
-test_id_option=--load-list $IDFILE
-test_list_option=--list
diff --git a/lower-constraints.txt b/lower-constraints.txt
index 0d4f5051..e989e565 100644
--- a/lower-constraints.txt
+++ b/lower-constraints.txt
@@ -103,7 +103,7 @@ sphinxcontrib-websupport==1.0.1
 statsd==3.2.1
 stevedore==1.20.0
 tenacity==3.2.1
-testrepository==0.0.18
+stestr==2.0.0
 testscenarios==0.4
 testtools==2.2.0
 traceback2==1.4.0
diff --git a/requirements.txt b/requirements.txt
index 87eb5826..230787bc 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -5,7 +5,7 @@ pbr!=2.1.0,>=2.0.0 # Apache-2.0
 
 Babel!=2.4.0,>=2.3.4 # BSD
 six>=1.10.0 # MIT
-keystoneauth1>=3.3.0 # Apache-2.0
+keystoneauth1>=3.4.0 # Apache-2.0
 stevedore>=1.20.0 # Apache-2.0
 requests>=2.14.2 # Apache-2.0
 oslo.i18n>=3.15.3 # Apache-2.0
@@ -14,6 +14,6 @@ oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0
 oslo.utils>=3.33.0 # Apache-2.0
 os-client-config>=1.28.0 # Apache-2.0
 osc-lib>=1.8.0 # Apache-2.0
-PrettyTable<0.8,>=0.7.1 # BSD
-cryptography!=2.0,>=1.9 # BSD/Apache-2.0
+PrettyTable<0.8,>=0.7.2 # BSD
+cryptography>=2.1 # BSD/Apache-2.0
 decorator>=3.4.0 # BSD
diff --git a/test-requirements.txt b/test-requirements.txt
index 72fed3f4..f625855c 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -8,7 +8,7 @@ fixtures>=3.0.0 # Apache-2.0/BSD
 python-openstackclient>=3.12.0 # Apache-2.0
 oslotest>=3.2.0 # Apache-2.0
 osprofiler>=1.4.0 # Apache-2.0
-testrepository>=0.0.18 # Apache-2.0/BSD
+stestr>=2.0.0 # Apache-2.0
 testscenarios>=0.4 # Apache-2.0/BSD
 testtools>=2.2.0 # MIT
 mock>=2.0.0 # BSD
diff --git a/tools/cover.sh b/tools/cover.sh
index 42baf5d8..74b25d9b 100755
--- a/tools/cover.sh
+++ b/tools/cover.sh
@@ -30,7 +30,12 @@ fi
 git checkout HEAD^
 
 baseline_report=$(mktemp -t magnumclient_coverageXXXXXXX)
-find . -type f -name "*.pyc" -delete && python setup.py testr --coverage --testr-args="$*"
+find . -type f -name "*.pyc" -delete
+stestr run "$*"
+coverage combine
+coverage report --fail-under=80 --skip-covered
+coverage html -d cover
+coverage xml -o cover/coverage.xml
 coverage report > $baseline_report
 mv cover cover-master
 cat $baseline_report
@@ -40,7 +45,12 @@ baseline_missing=$(awk 'END { print $3 }' $baseline_report)
 git checkout -
 
 current_report=$(mktemp -t magnumclient_coverageXXXXXXX)
-find . -type f -name "*.pyc" -delete && python setup.py testr --coverage --testr-args="$*"
+find . -type f -name "*.pyc" -delete
+stestr run "$*"
+coverage combine
+coverage report --fail-under=80 --skip-covered
+coverage html -d cover
+coverage xml -o cover/coverage.xml
 coverage report > $current_report
 current_missing=$(awk 'END { print $3 }' $current_report)
 
diff --git a/tox.ini b/tox.ini
index c089277b..0d4aaff4 100644
--- a/tox.ini
+++ b/tox.ini
@@ -16,7 +16,7 @@ deps =
        -r{toxinidir}/test-requirements.txt
 commands =
   find . -type f -name "*.py[c|o]" -delete
-  python setup.py testr --slowest --testr-args='{posargs}'
+  stestr run --slowest {posargs}
 
 [testenv:bandit]
 basepython = python3