提交 e2f2d250 编写于 作者: L Lucas Meneghel Rodrigues

avocado: Remove datadir plugin

Since the 'config' plugin supersedes functionality
in the 'datadir' plugin, let's remove it from avocado.
Update the configuration accordingly.
Signed-off-by: NLucas Meneghel Rodrigues <lmr@redhat.com>
上级 bbd45a0c
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See LICENSE for more details.
#
# Copyright: Red Hat Inc. 2013-2014
# Author: Lucas Meneghel Rodrigues <lmr@redhat.com>
from avocado.plugins import plugin
from avocado.core import output
from avocado.core import data_dir
from avocado.settings import settings
class DataDirList(plugin.Plugin):
"""
Implements the avocado 'datadir' subcommand
"""
name = 'datadir'
enabled = True
def configure(self, parser):
self.parser = parser.subcommands.add_parser(
'datadir',
help='List all relevant directories used by avocado')
super(DataDirList, self).configure(self.parser)
def run(self, args):
view = output.View()
view.notify(event="message", msg='Config files read (in order):')
for cfg_path in settings.config_paths:
view.notify(event="message", msg=' %s' % cfg_path)
if settings.config_paths_failed:
view.notify(event="minor", msg='')
view.notify(event="error", msg='Config files that failed to read:')
for cfg_path in settings.config_paths_failed:
view.notify(event="error", msg=' %s' % cfg_path)
view.notify(event="message", msg='')
view.notify(event="minor", msg="Avocado replaces config dirs that can't be accessed")
view.notify(event="minor", msg="with sensible defaults. Please edit your local config")
view.notify(event="minor", msg="file to customize values")
view.notify(event="message", msg='')
view.notify(event="message", msg='Avocado Data Directories:')
view.notify(event="minor", msg=' base dir ' + data_dir.get_base_dir())
view.notify(event="minor", msg=' tests dir ' + data_dir.get_test_dir())
view.notify(event="minor", msg=' data dir ' + data_dir.get_data_dir())
view.notify(event="minor", msg=' logs dir ' + data_dir.get_logs_dir())
view.notify(event="minor", msg=' tmp dir ' + data_dir.get_tmp_dir())
......@@ -31,7 +31,9 @@ Config file parsing order
Avocado starts by parsing what it calls system wide config file, that is shipped to all avocado users on a system
wide directory, ``/etc/avocado/avocado.conf``. Then it'll verify if there's a local user config file, that is located
usually in ``~/.config/avocado/avocado.conf``. The order of the parsing matters, so the system wide file is parsed,
then the user config file is parsed last, so that the user can override values at will.
then the user config file is parsed last, so that the user can override values at will. There is another directory
that will be scanned by extra config files, ``/etc/avocado/conf.d``. This directory may contain plugin config files,
and extra additional config files that the system administrator/avocado developers might judge necessary to put there.
Please note that for base directories, if you chose a directory that can't be properly used by avocado (some directories
require read access, others, read and write access), avocado will fall back to some defaults. So if your regular user
......@@ -43,8 +45,8 @@ Plugin config files
Plugins can also be configured by config files. In order to not disturb the main avocado config file, those plugins,
if they wish so, may install additional config files to ``/etc/avocado/conf.d/[pluginname].conf``, that will be parsed
after the system wide config file. Users can override those values as well at the local config file level. So considering
the hypothetical plugin config::
after the system wide config file. Users can override those values as well at the local config file level.
Considering the hypothetical plugin config::
[plugin.salad]
base = ceasar
......@@ -84,3 +86,50 @@ configuration, after all the files are parsed in their correct resolution order.
The command also shows the order in which your config files were parsed, giving you a better understanding of
what's going on. The Section.Key nomenclature was inspired in ``git config --list`` output.
Avocado Data Directories
========================
When running tests, we are frequently looking to:
* Locate tests
* Write logs to a given location
* Grab files that will be useful for tests, such as ISO files or VM disk
images
Avocado has a module dedicated to find those paths, to avoid cumbersome
path manipulation magic that people had to do in previous test frameworks [1].
If you want to list all relevant directories for your test, you can use
`avocado config --datadir` command to list those directories. Executing
it will give you an output similar to the one seen below::
$ avocado config --datadir
Config files read (in order):
/etc/avocado/avocado.conf
/home/lmr/.config/avocado/avocado.conf
Avocado replaces config dirs that can't be accessed
with sensible defaults. Please edit your local config
file to customize values
Avocado Data Directories:
base /home/lmr/avocado
tests /home/lmr/Code/avocado.lmr/examples/tests
data /home/lmr/avocado/data
logs /home/lmr/avocado/job-results
tmp /var/tmp/avocado
Note that, while avocado will do its best to use the config values you
provide in the config file, if it can't write values to the locations
provided, it will fall back to (we hope) reasonable defaults, and we
notify the user about that in the output of the command.
The relevant API documentation and meaning of each of those data directories
is in :mod:`avocado.core.data_dir`, so it's higly recommended you take a look.
You may set your preferred data dirs by setting them in the avocado config files.
The next section of the documentation explains how you can see and set config
values that modify the behavior for the avocado utilities and plugins.
[1] For example, autotest.
========================
Avocado Data Directories
========================
When running tests, we are frequently looking to:
* Locate tests
* Write logs to a given location
* Grab files that will be useful for tests, such as ISO files or VM disk
images
Avocado has a module dedicated to find those paths, to avoid cumbersome
path manipulation magic that people had to do in previous test frameworks [1].
If you want to list all relevant directories for your test, there's a builtin
avocado plugin called ``datadir`` to do that. You can run::
$ avocado datadir
Avocado Data Directories:
base dir: /home/lmr/avocado
tests dir: /home/lmr/avocado/tests
data dir: /home/lmr/avocado/data
logs dir: /home/lmr/avocado/logs
tmp dir: /tmp/avocado
The relevant API documentation and meaning of each of those data directories
is in :mod:`avocado.core.data_dir`, so it's higly recommended you take a look.
You may set your preferred data dirs by setting them in the avocado config files.
The next section of the documentation explains how you can see and set config
values that modify the behavior for the avocado utilities and plugins.
[1] For example, autotest.
\ No newline at end of file
......@@ -14,7 +14,6 @@ Contents:
Introduction
GetStartedGuide
DataDir
Configuration
WritingTests
ResultsSpecification
......
......@@ -348,9 +348,20 @@ class PluginsTest(unittest.TestCase):
(expected_rc, result))
self.assertNotIn('Disabled', output)
def test_datadir_plugin(self):
def test_config_plugin(self):
os.chdir(basedir)
cmd_line = './scripts/avocado datadir'
cmd_line = './scripts/avocado config'
result = process.run(cmd_line, ignore_status=True)
output = result.stdout
expected_rc = 0
self.assertEqual(result.exit_status, expected_rc,
"Avocado did not return rc %d:\n%s" %
(expected_rc, result))
self.assertNotIn('Disabled', output)
def test_config_plugin_datadir(self):
os.chdir(basedir)
cmd_line = './scripts/avocado config --datadir'
result = process.run(cmd_line, ignore_status=True)
output = result.stdout
expected_rc = 0
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册