Skip to content

Commit

Permalink
Merge pull request #318 from mtreinish/remove-sql-repository-type
Browse files Browse the repository at this point in the history
Remove deprecated sql repository type and repo_type options
  • Loading branch information
masayukig authored Apr 5, 2022
2 parents a841650 + 2be7905 commit ba5995e
Show file tree
Hide file tree
Showing 18 changed files with 75 additions and 709 deletions.
41 changes: 11 additions & 30 deletions doc/source/MANUAL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -594,29 +594,15 @@ from the repository. For example::
Repositories
------------

stestr uses a data repository to keep track of test previous test runs. There
are different backend types that each offer different advantages. There are
currently 2 repository types to choose from, **file** and **sql**.

You can choose which repository type you want with the ``--repo-type``/``-r``
cli flag. **file** is the current default.
stestr uses a data repository to keep track of test previous test runs.

You can also specify an alternative repository with the ``--repo-url``/``-u``
cli flags. The default value for a **file** repository type is to use the
directory: ``$CWD/.stestr``. For a **sql** repository type is to use a sqlite
database located at: ``$CWD/.stestr.sqlite``.
cli flags. The default value is to use the directory: ``$CWD/.stestr``.

.. note:: Make sure you put these flags before the cli subcommand

.. note:: Different repository types that use local storage will conflict with
each other in the same directory. If you initialize one repository type
and then try to use another in the same directory, it will not
work.

File
''''
The default stestr repository type has a very simple disk structure. It
contains the following files:
The stestr repository has a very simple disk structure. It contains the
following files:

* format: This file identifies the precise layout of the repository, in case
future changes are needed.
Expand All @@ -630,16 +616,11 @@ contains the following files:

* #N - all the streams inserted in the repository are given a serial number.

SQL
'''
This is an experimental repository backend, that is based on the `subunit2sql`_
library.

.. note:: The sql repository type requirements are not installed by default.
They are listed under the 'sql' setuptools extras. You can install them
with pip by running: ``pip install 'stestr[sql]'``

.. warning:: The sql repository type is deprecated and will be removed in the
4.0.0 release.
* times.dbm: A dbm database (using Python's
```dbm.dumb`` <https://docs.python.org/3/library/dbm.html#module-dbm.dumb>`__
implementation) that stores the record of the last elapsed time for each test
executed.

.. _subunit2sql:
* meta.dbm: An dbm file that maps a run id (which will be the integer file
documented above) to an arbitrary string metadata field describing the run.
Right now this must be manually specified.
1 change: 0 additions & 1 deletion doc/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Repository
api/repository/abstract
api/repository/file
api/repository/memory
api/repository/sql

Commands
--------
Expand Down
7 changes: 0 additions & 7 deletions doc/source/api/repository/sql.rst

This file was deleted.

6 changes: 2 additions & 4 deletions stestr/bisect_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@
class IsolationAnalyzer:

def __init__(self, latest_run, conf, run_func, repo, test_path=None,
top_dir=None, group_regex=None, repo_type='file',
top_dir=None, group_regex=None,
repo_url=None, serial=False, concurrency=0):
super().__init__()
self._worker_to_test = None
self._test_to_worker = None
self.latest_run = latest_run
self.conf = conf
self.group_regex = group_regex
self.repo_type = repo_type
self.repo_url = repo_url
self.serial = serial
self.concurrency = concurrency
Expand All @@ -54,12 +53,11 @@ def bisect_tests(self, spurious_failures):
bottom:bottom + check_width] + [spurious_failure]
cmd = self.conf.get_run_command(
test_ids, group_regex=self.group_regex,
repo_type=self.repo_type, repo_url=self.repo_url,
repo_url=self.repo_url,
serial=self.serial, concurrency=self.concurrency,
test_path=self.test_path, top_dir=self.top_dir)
self.run_func(cmd, False,
pretty_out=False,
repo_type=self.repo_type,
repo_url=self.repo_url)
# check that the test we're probing still failed - still
# awkward.
Expand Down
9 changes: 3 additions & 6 deletions stestr/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,11 @@ def _set_common_opts(self, parser):
"command. If one isn't specified then "
".stestr.conf in the directory that a command"
" is running from is used")
parser.add_argument('--repo-type', '-r', dest='repo_type',
choices=['file', 'sql'], default='file',
help="DEPRECATED: Select the repo backend to use")
parser.add_argument('--repo-url', '-u', dest='repo_url',
default=None,
help="Set the repo url to use. An acceptable value"
" for this depends on the repository type "
"used.")
help="Set the repo url to use. This should just "
"be the path to the stestr repository "
"directory")
parser.add_argument('--test-path', '-t', dest='test_path',
default=None,
help="Set the test path to use for unittest "
Expand Down
18 changes: 5 additions & 13 deletions stestr/commands/failing.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ def take_action(self, parsed_args):
list_opt = args.list or user_conf.failing.get('list', False)
else:
list_opt = args.list
return failing(repo_type=self.app_args.repo_type,
repo_url=self.app_args.repo_url,
return failing(repo_url=self.app_args.repo_url,
list_tests=list_opt, subunit=args.subunit)


Expand All @@ -82,7 +81,7 @@ def _get_id():
return output_result, summary_result


def failing(repo_type='file', repo_url=None, list_tests=False, subunit=False,
def failing(repo_url=None, list_tests=False, subunit=False,
stdout=sys.stdout):
"""Print the failing tests from the most recent run in the repository
Expand All @@ -91,12 +90,9 @@ def failing(repo_type='file', repo_url=None, list_tests=False, subunit=False,
tests if ``list_tests`` is true. If ``subunit`` is true a subunit stream
with just the failed tests will be printed to STDOUT.
Note this function depends on the cwd for the repository if `repo_type` is
set to file and `repo_url` is not specified it will use the repository
located at CWD/.stestr
Note this function depends on the cwd for the repository if `repo_url` is
not specified it will use the repository located at CWD/.stestr
:param str repo_type: This is the type of repository to use. Valid choices
are 'file' and 'sql'.
:param str repo_url: The url of the repository to use.
:param bool list_test: Show only a list of failing tests.
:param bool subunit: Show output as a subunit stream.
Expand All @@ -107,11 +103,7 @@ def failing(repo_type='file', repo_url=None, list_tests=False, subunit=False,
for failures.
:rtype: int
"""
if repo_type not in ['file', 'sql']:
stdout.write('Repository type %s is not a type' % repo_type)
return 1

repo = util.get_repo_open(repo_type, repo_url)
repo = util.get_repo_open('file', repo_url)
run = repo.get_failing()
if subunit:
return _show_subunit(run)
Expand Down
50 changes: 17 additions & 33 deletions stestr/commands/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ def take_action(self, parsed_args):
if user_conf.history_show.get('show-metadata',
None) is not None:
show_metadata = args.show_metadata
return history_list(repo_type=self.app_args.repo_type,
repo_url=self.app_args.repo_url,
return history_list(repo_url=self.app_args.repo_url,
show_metadata=show_metadata)


Expand Down Expand Up @@ -138,7 +137,6 @@ def take_action(self, parsed_args):
all_attachments = args.all_attachments
return history_show(
args.run_id,
repo_type=self.app_args.repo_type,
repo_url=self.app_args.repo_url,
subunit_out=args.subunit,
pretty_out=pretty_out, color=color,
Expand All @@ -161,7 +159,7 @@ def get_parser(self, prog_name):

def take_action(self, parsed_args):
args = parsed_args
history_remove(args.run_id, repo_type=self.app_args.repo_type,
history_remove(args.run_id,
repo_url=self.app_args.repo_url)


Expand Down Expand Up @@ -206,16 +204,13 @@ def collect_data(stream, test):
return {'passed': successful, 'runtime': run_time, 'start': start_time}


def history_list(repo_type='file', repo_url=None, show_metadata=False,
def history_list(repo_url=None, show_metadata=False,
stdout=sys.stdout):
"""Show a list of runs in a repository
Note this function depends on the cwd for the repository if `repo_type` is
set to file and `repo_url` is not specified it will use the repository
located at CWD/.stestr
Note this function depends on the cwd for the repository if `repo_url` is
not specified it will use the repository located at CWD/.stestr
:param str repo_type: This is the type of repository to use. Valid choices
are 'file' and 'sql'.
:param str repo_url: The url of the repository to use.
:param bool show_metadata: If set to ``True`` a column with any metadata
for a run will be included in the output.
Expand All @@ -233,7 +228,7 @@ def history_list(repo_type='file', repo_url=None, show_metadata=False,
else:
field_names = ('Run ID', 'Passed', 'Runtime', 'Date')
try:
repo = util.get_repo_open(repo_type, repo_url)
repo = util.get_repo_open('file', repo_url)
except abstract.RepositoryNotFound as e:
stdout.write(str(e) + '\n')
return 1
Expand All @@ -257,7 +252,7 @@ def history_list(repo_type='file', repo_url=None, show_metadata=False,
return (field_names, rows)


def history_show(run_id, repo_type='file', repo_url=None, subunit_out=False,
def history_show(run_id, repo_url=None, subunit_out=False,
pretty_out=True, color=False, stdout=sys.stdout,
suppress_attachments=False, all_attachments=False,
show_binary_attachments=False):
Expand All @@ -267,13 +262,10 @@ def history_show(run_id, repo_type='file', repo_url=None, subunit_out=False,
to STDOUT. It can optionally print the subunit stream for the last run
to STDOUT if the ``subunit`` option is set to true.
Note this function depends on the cwd for the repository if `repo_type` is
set to file and `repo_url` is not specified it will use the repository
located at CWD/.stestr
Note this function depends on the cwd for the repository if `repo_url` is
not specified it will use the repository located at CWD/.stestr
:param str run_id: The run id to show
:param str repo_type: This is the type of repository to use. Valid choices
are 'file' and 'sql'.
:param str repo_url: The url of the repository to use.
:param bool subunit_out: Show output as a subunit stream.
:param pretty_out: Use the subunit-trace output filter.
Expand All @@ -293,7 +285,7 @@ def history_show(run_id, repo_type='file', repo_url=None, subunit_out=False,
:rtype: int
"""
try:
repo = util.get_repo_open(repo_type, repo_url)
repo = util.get_repo_open('file', repo_url)
except abstract.RepositoryNotFound as e:
stdout.write(str(e) + '\n')
return 1
Expand All @@ -313,15 +305,10 @@ def history_show(run_id, repo_type='file', repo_url=None, subunit_out=False,
return 0
case = run.get_test()
try:
if repo_type == 'file':
if run_id:
previous_run = int(run_id) - 1
else:
previous_run = repo.get_test_run(repo.latest_id() - 1)
# TODO(mtreinish): add a repository api to get the previous_run to
# unify this logic
if run_id:
previous_run = int(run_id) - 1
else:
previous_run = None
previous_run = repo.get_test_run(repo.latest_id() - 1)
except KeyError:
previous_run = None
failed = False
Expand All @@ -348,17 +335,14 @@ def history_show(run_id, repo_type='file', repo_url=None, subunit_out=False,
return 0


def history_remove(run_id, repo_type='file', repo_url=None, stdout=sys.stdout):
def history_remove(run_id, repo_url=None, stdout=sys.stdout):
"""Remove a run from a repository
Note this function depends on the cwd for the repository if `repo_type` is
set to file and `repo_url` is not specified it will use the repository
located at CWD/.stestr
Note this function depends on the cwd for the repository if `repo_url` is
not specified it will use the repository located at CWD/.stestr
:param str run_id: The run id to remove from the repository. Also, can be
set to ``all`` which will remove all runs from the repository.
:param str repo_type: This is the type of repository to use. Valid choices
are 'file' and 'sql'.
:param str repo_url: The url of the repository to use.
:param file stdout: The output file to write all output to. By default
this is sys.stdout
Expand All @@ -368,7 +352,7 @@ def history_remove(run_id, repo_type='file', repo_url=None, stdout=sys.stdout):
:rtype: int
"""
try:
repo = util.get_repo_open(repo_type, repo_url)
repo = util.get_repo_open('file', repo_url)
except abstract.RepositoryNotFound as e:
stdout.write(str(e) + '\n')
return 1
Expand Down
20 changes: 5 additions & 15 deletions stestr/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import errno
import sys
import warnings

from cliff import command

Expand All @@ -25,35 +24,26 @@ class Init(command.Command):
"""Create a new repository."""

def take_action(self, parsed_args):
init(self.app_args.repo_type, self.app_args.repo_url)
init(self.app_args.repo_url)


def init(repo_type='file', repo_url=None, stdout=sys.stdout):
def init(repo_url=None, stdout=sys.stdout):
"""Initialize a new repository
This function will create initialize a new repostiory if one does not
exist. If one exists the command will fail.
Note this function depends on the cwd for the repository if `repo_type` is
set to file and `repo_url` is not specified it will use the repository
located at CWD/.stestr
Note this function depends on the cwd for the repository if `repo_url` is
not specified it will use the repository located at CWD/.stestr
:param str repo_type: This is the type of repository to use. Valid choices
are 'file' and 'sql'.
:param str repo_url: The url of the repository to use.
:return return_code: The exit code for the command. 0 for success and > 0
for failures.
:rtype: int
"""
if repo_type == 'sql':
msg = ("WARNING: The sql repository type is deprecated and will be "
"removed in the 4.0.0 release. Instead use the file "
"repository type\n")
sys.stderr.write(msg)
warnings.warn(msg, DeprecationWarning, stacklevel=2)
try:
util.get_repo_initialise(repo_type, repo_url)
util.get_repo_initialise('file', repo_url)
except OSError as e:
if e.errno != errno.EEXIST:
raise
Expand Down
Loading

0 comments on commit ba5995e

Please sign in to comment.