Skip to content

Config default values refactoring #6145

@richtja

Description

@richtja

Describe the bug
Avocado uses avocado.coere.settings.Settings class as a single source of truth for the whole avocado configuration. This class should be responsible for defaults creation, therefore we souldn't set the defaults anywhere else to keep consistence of the system.

We had a discussion about this issue in #6112 with this concusion:
Setting the default at get time (from the avocado.core.settings perspective) is actually very rare.

This is an occurrence of the "exception" we give to runners (because they might not have access to the configuration coming from avocado.core.settings:

avocado/core/utils/messages.py:    log_level = config.get("job.output.loglevel", logging.DEBUG)

Also a runner related exception:

avocado/core/nrunner/runnable.py:            fmt = self.config.get("runner.identifier_format", "{uri}")

This looks like a bug to me:

avocado/core/main.py:    crash_dir_path = os.path.join(config.get("datadir.paths.data_dir"), "crashes")

These are a different (internal to the parser) self.config:

avocado/core/parser.py:            args = self.config.get(section, "args")
avocado/core/parser.py:        kwargs = self.config.get(section, "kwargs", fallback="")
avocado/core/parser.py:        return self.config.get(section, "uri")
avocado/core/parser.py:            files = self.config.get("kinds", kind)

This should be made into a core setting (as in avocado/core/__init__.py):

avocado/core/suite.py:                for name, value in self.config.get("run.test_parameters", [])

Another set of exceptions for runners:

avocado/plugins/runners/exec_test.py:        skip_codes = runnable.config.get("runner.exectest.exitcodes.skip", [])
avocado/plugins/runners/exec_test.py:        clear_env = runnable.config.get("runner.exectest.clear_env", None)
avocado/plugins/runners/sysinfo.py:        for cmd in self.sysinfo_config.get("commands", []):
avocado/plugins/runners/sysinfo.py:        for filename in self.sysinfo_config.get("files", []):
avocado/plugins/runners/sysinfo.py:            for fail_cmd in self.sysinfo_config.get("fail_commands", []):
avocado/plugins/runners/sysinfo.py:            for fail_filename in self.sysinfo_config.get("fail_files", []):

These are just a hack and not related to actual settings:

avocado/plugins/assets.py:        if not job.config.get("stdout_claimed_by", None):
avocado/plugins/human.py:        stdout_claimed_by = config.get("stdout_claimed_by", None)
avocado/plugins/human.py:        replay_enabled = replay_source_job = job.config.get("replay_sourcejob", False)
avocado/plugins/human.py:            if not job.config.get("stdout_claimed_by", None):
avocado/plugins/runner_nrunner.py:            test_suite.config.get("run.max_parallel_tasks"), len(self.runtime_tasks)

Overall, we need to address the situation where runners do not have access to the defaults from avocado.core.settings but should not crash.


Base on all this data we need to refactor config defaults usage in our code to remove the occurrences where the runners set their own defaults instead of using the one from Settings.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Long Term (Next Q) Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions