Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runnable and Suite configuration support #6006

Merged

Conversation

clebergnu
Copy link
Contributor

This change allows for the a runnable configuration and the suite and default configuration to coexist with the correct behavior.

In short, if the suite has a configuration, it will become the new default configuration for a runnable, while its own configuration will not be touched.

Fixes: #5998

@clebergnu clebergnu added the customer:Passt Requirements/issues raised by the Passt project label Aug 22, 2024
@clebergnu clebergnu added this to the 107 - Codename TBD milestone Aug 22, 2024
@clebergnu clebergnu self-assigned this Aug 22, 2024
@clebergnu clebergnu requested a review from richtja August 22, 2024 05:55
Copy link
Contributor

@richtja richtja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @clebergnu, thank you for your work. I have one comment related to config initialization which IMO needs to be resolved and one about deprecation of from_avocado_config which doesn't needs to be resolved here, but if won't, we need to create an issue about it.

avocado/core/nrunner/runnable.py Show resolved Hide resolved
avocado/core/nrunner/runnable.py Outdated Show resolved Hide resolved
@clebergnu
Copy link
Contributor Author

Hi @richtja, thanks for the review. I've addressed both issues, and explained the additional changes to the verification of values in the commit message, reading:

    Because the purpose of the default_config and config are different,
    the checks for the values they may contain are different.  The
    default_config should contain the exact keys as in the used config.
    The config itself, on the other hand, may contain nothing, or some
    values, but it should never be more than a subset of the config.

Copy link
Contributor

@richtja richtja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @clebergnu, thanks for the update. I just noticed that Runnable.from_avocado_config is also used in sysinfo plugin, can you please update that as well, so we won't use deprecated code in avocado plugins. Thanks

The Runnable.get_configuration_used_by_kind() is the right place
to return all configuration used by a runnable, and that includes
the global configuration used by all runners.

Signed-off-by: Cleber Rosa <[email protected]>
There's a warning that should be given to users passing configuration
that is not used by runnables of a specific kind.  This refactors
that into its own method, and adds tests for it.

Signed-off-by: Cleber Rosa <[email protected]>
The behavior of setting the filtered configuration should be applied
at every single instantiation.  Let's unify that at the class'
__init__ method.

Signed-off-by: Cleber Rosa <[email protected]>
Since it provides the same signature as the main class initilization
method.  Internally, let's switch to it, while still allowing people
that is creating their own runnables time to switch.

Signed-off-by: Cleber Rosa <[email protected]>
Right now, there's a conflict of interest on the "config" attribute
of a runnable: it serves as both a convenience holder of default
values from Avocado's configuration (default values set by the
settings API itself or in current configuration files), and the
actual configuration defined in the runnable API.

This introduces a different config holder, one with the default
configuration known at the time the class is istantiated.

At this point, it's a separate entity, but it will cooperate with
config, so that the config attribute will provide either the value
set in the runnable itself or in the default config.

Signed-off-by: Cleber Rosa <[email protected]>
This change allows for the a runnable configuration and the suite and
default configuration to coexist with the correct behavior.

In short, if the suite has a configuration, it will become the new
default configuration for a runnable, while its own configuration will
not be touched.

Because the purpose of the default_config and config are different,
the checks for the values they may contain are different.  The
default_config should contain the exact keys as in the used config.
The config itself, on the other hand, may contain nothing, or some
values, but it should never be more than a subset of the config.

Note: there's an opportunity here for changing the data
structure used for the "config" attribute, one that looks
up the value in the "default_config" if it doesn't exist
in the actual "config".  But, given that the size of the
"default_config" will always be very small (given that
it's filtered to contain only the used configuration
by the runner) it seemed an unnecessary optimization
at this time.

Fixes: avocado-framework#5998
Signed-off-by: Cleber Rosa <[email protected]>
@clebergnu
Copy link
Contributor Author

Hi @clebergnu, thanks for the update. I just noticed that Runnable.from_avocado_config is also used in sysinfo plugin, can you please update that as well, so we won't use deprecated code in avocado plugins. Thanks

Good catch! Just updated it! Thanks!

@clebergnu clebergnu requested a review from richtja August 22, 2024 14:54
Copy link
Contributor

@richtja richtja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just waiting for the CI to pass.

@clebergnu
Copy link
Contributor Author

Merging based on @richtja approval and CI status.

@clebergnu clebergnu merged commit 6097f08 into avocado-framework:master Aug 22, 2024
57 of 58 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer:Passt Requirements/issues raised by the Passt project
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Runnable: support own configuration and suite configuration
2 participants