From 67f98f8666f9d0d2649e48bcb13189597e3fe50a Mon Sep 17 00:00:00 2001
From: HeroicHitesh <email.hiteshkumar@gmail.com>
Date: Thu, 20 May 2021 12:32:36 +0530
Subject: [PATCH] Migrate from testr to stestr

* Replace .testr.conf by .stestr.conf for migration and update
  .gitignore and test-requirements.txt files accordingly
* Use py3 as the default runtime for tox and 3.18.0 as the
  minversion for tox

Signed-off-by: HeroicHitesh <email.hiteshkumar@gmail.com>
Change-Id: If2662e223ad52c8cae965eb6bdf880c1dce962f2
---
 .gitignore            | 21 +++++++++++++++++++--
 .stestr.conf          |  4 ++++
 .testr.conf           | 12 ------------
 test-requirements.txt |  1 +
 tox.ini               |  7 +++----
 5 files changed, 27 insertions(+), 18 deletions(-)
 create mode 100644 .stestr.conf
 delete mode 100644 .testr.conf

diff --git a/.gitignore b/.gitignore
index 7693c17..c3dab8f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,22 @@
 *.pyc
+
+# Packages
+*.egg*
+dist
+build
+
+# Unit test
+.tox/
+.stestr/
+.venv
+
+# pbr generates these
+AUTHORS
+ChangeLog
+
+# Editors
 *.swp
 *~
-.tox
-.testrepository
+
+# Files created by releasenotes build
+releasenotes/build
diff --git a/.stestr.conf b/.stestr.conf
new file mode 100644
index 0000000..f12caa0
--- /dev/null
+++ b/.stestr.conf
@@ -0,0 +1,4 @@
+[DEFAULT]
+test_path=./heat_tempest_plugin/tests/
+top_dir=./
+group_regex=([^\.]*\.)*
diff --git a/.testr.conf b/.testr.conf
deleted file mode 100644
index b1f68d6..0000000
--- a/.testr.conf
+++ /dev/null
@@ -1,12 +0,0 @@
-[DEFAULT]
-test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
-             OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
-             OS_LOG_CAPTURE=${OS_LOG_CAPTURE:-1} \
-             OS_DEBUG=${OS_DEBUG:-1} \
-             OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-500} \
-             OS_TEST_LOCK_PATH=${OS_TEST_LOCK_PATH:-${TMPDIR:-'/tmp'}} \
-             ${PYTHON:-python} -m subunit.run discover -t ${OS_TOP_LEVEL:-./} ${OS_TEST_PATH:-./heat_tempest_plugin} $LISTOPT $IDOPTION
-
-test_id_option=--load-list $IDFILE
-test_list_option=--list
-group_regex=([^\.]*\.)*
diff --git a/test-requirements.txt b/test-requirements.txt
index be225d8..23614af 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -8,3 +8,4 @@ hacking>=2.0,<2.1.0 # Apache-2.0
 # hacking to 3.2.0 or above. hacking 3.2.0 takes
 # care of pyflakes version compatibilty.
 pyflakes>=2.1.1
+stestr>=2.0.0 # Apache-2.0
diff --git a/tox.ini b/tox.ini
index 5aa6b38..07e3180 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,6 +1,6 @@
 [tox]
-envlist = py37,pep8
-minversion = 3.1.1
+envlist = py3,pep8
+minversion = 3.18.0
 skipsdist = True
 ignore_basepython_conflict = True
 
@@ -10,8 +10,7 @@ userdevelop = True
 setenv = VIRTUAL_ENV={envdir}
 deps = -r{toxinidir}/requirements.txt
        -r{toxinidir}/test-requirements.txt
-commands = bash -c 'if [ ! -d ./.testrepository ] ; then testr init ; fi'
-           testr run {posargs}
+commands = stestr run --slowest {posargs}
 
 [testenv:pep8]
 setenv =