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: support own configuration and suite configuration #5998

Closed
clebergnu opened this issue Aug 12, 2024 · 0 comments · Fixed by #6006
Closed

Runnable: support own configuration and suite configuration #5998

clebergnu opened this issue Aug 12, 2024 · 0 comments · Fixed by #6006
Assignees
Labels
bug customer:Passt Requirements/issues raised by the Passt project

Comments

@clebergnu
Copy link
Contributor

Describe the bug
Currently, as a convenience, a Runnable instantiated without a config, is given a configuration that matches its kind. Example:

from avocado.core.nrunner.runnable import Runnable
>>> Runnable(kind='noop', uri=None).config
{'runner.identifier_format': '{uri}'}

Also currently, the suite will overwrite a runnable's config with its own.

The problem with this approach is that when a Runnable is used in a Suite with its own configuration, it's not possible to distinguish what was originally an empty configuration (that was turned into the default one).

Steps to reproduce
Create a noop_config.json file such as:

{"kind": "noop", "uri": "noop", "config": {"runner.identifier_format": "nothing-op"}}

Run: avocado run noop_config.json

Expected behavior
The precedence of configuration should be:

  1. The runnable's own config
  2. The suite's config
  3. The default value for the registered setting

For the command above:

JOB ID     : 9376b4739f2238c5cd97d828a2c484f856fb5697
JOB LOG    : /home/cleber/avocado/job-results/job-2024-08-12T06.01-9376b47/job.log
 (1/1) nothing-op: STARTED
 (1/1) nothing-op: PASS (0.00 s)
RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML   : /home/cleber/avocado/job-results/job-2024-08-12T06.01-9376b47/results.html
JOB TIME   : 2.52 s

Current behavior
Currently, the suite will overwrite a runnable's config with its own.

For the command above:

JOB ID     : 9376b4739f2238c5cd97d828a2c484f856fb5697
JOB LOG    : /home/cleber/avocado/job-results/job-2024-08-12T06.01-9376b47/job.log
 (1/1) noop: STARTED
 (1/1) noop: PASS (0.00 s)
RESULTS    : PASS 1 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML   : /home/cleber/avocado/job-results/job-2024-08-12T06.01-9376b47/results.html
JOB TIME   : 2.52 s

System information (please complete the following information):

  • OS: LSB Version: :core-5.0-amd64:core-5.0-noarch:cxx-5.0-amd64:cxx-5.0-noarch:desktop-5.0-amd64:desktop-5.0-noarch:languages-5.0-amd64:languages-5.0-noarch:printing-5.0-amd64:printing-5.0-noarch Distributor ID: Fedora Description: Fedora release 40 (Forty) Release: 40 Codename: Forty
  • Avocado version: 1ac7fce
  • Avocado installation method: git
@clebergnu clebergnu added bug customer:Passt Requirements/issues raised by the Passt project labels Aug 12, 2024
@clebergnu clebergnu added this to the 107 - Codename TBD milestone Aug 12, 2024
@clebergnu clebergnu self-assigned this Aug 12, 2024
clebergnu added a commit to clebergnu/avocado that referenced this issue Aug 22, 2024
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.

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 added a commit to clebergnu/avocado that referenced this issue Aug 22, 2024
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.

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 added a commit to clebergnu/avocado that referenced this issue Aug 22, 2024
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 added a commit to clebergnu/avocado that referenced this issue Aug 22, 2024
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug customer:Passt Requirements/issues raised by the Passt project
Projects
Status: Done 107
Development

Successfully merging a pull request may close this issue.

1 participant