You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Environment variables visible to test - but not just tests, prepare scripts or Ansible playbooks must be considered too! - are composed from various sources:
External sources
run: --environment and --environment-file CLI options
plan: environment and environment-file fmf keys
importing plan: environment fmf key of the importing plan
Untangling the environment, one step at a time. At this moment, the best we can do is to document the order, but it's far from being clean, nice, and desirable.
untangle plan environment from test environment, and add plan environment to the final environment in the execute plugin
drop the duplication of "run" environment, run.environment and "plan CLI environment" seems to be the same thing. refactor run environment to use the same composition approach so we can better track the sources:
plan environment file - when it's pulled from guests, is it saved into the same runner path? Plan may prepare different content on different guests, sharing single local path might be incorrectly enforcing one version to all guests. Possibly a bug waiting to be noticed.
Expose TMT_SOURCE_DIR to prepare and finish phases Probably not reasonable, as prepare and finish phases are not tied to one discover phase like execute phases are.
Assorted notes
Current (rough) ordering
AFAICT, the rough order of precedence, as of now, is something like the following:
provision[].environment
test[].environment
"plan environment"
$TMT_PLAN_ENVIRONMENT_FILE
plan environment-file key
plan environment key
importing plan "native" environment
importing plan environment-file key
importing plan environment key
importing plan importing plan ...
run environment saved in the workdir (--environment and --environment-file from previous invocations)
tmt run --environment
tmt run --environment-file
plan intrinsic variables: TMT_VERSION, TMT_TREE, ...
plugin intrinsic variables
abort context
reboot context
restart context
pidfile context
restraint context
test framework
...
Desired state
This should be the desired order of precedence, from the weakest to strongest sources:
test[].environment
plan environment-file key
plan environment key
importing plan "native" environment
importing plan environment-file key
importing plan environment key
importing plan importing plan ...
provision[].environment
$TMT_PLAN_ENVIRONMENT_FILE
command-line input:
tmt run
run environment saved in the workdir (--environment-file and --environment from previous invocations)
tmt run --environment-file
tmt run --environment
tmt * export
tmt * export --environment-file
tmt * export --environment
tmt try
tmt try --environment-file
tmt try --environment
plugin intrinsic variables
abort context
reboot context
restart context
pidfile context
restraint context
test framework
guest topology
plan intrinsic variables: TMT_VERSION, TMT_TREE, ...
Environment variables visible to test - but not just tests,
preparescripts or Ansible playbooks must be considered too! - are composed from various sources:External sources
--environmentand--environment-fileCLI optionsenvironmentandenvironment-filefmf keysenvironmentfmf key of the importing planprovisionphases ("per-guest environment"):environmentfmf key,--environmentCLI optionenvironmentfmf keyInternal sources
Environment variables recognized by tmt
(Did I miss any source?)
The question is: in which order shall they be applied? We are not 100 % sure, and then there are users asking.
The goal is to put together a documentation similar to https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable
Status
Untangling the environment, one step at a time. At this moment, the best we can do is to document the order, but it's far from being clean, nice, and desirable.
executepluginrun.environmentand "plan CLI environment" seems to be the same thing. refactor run environment to use the same composition approach so we can better track the sources:tmt runcollects its environment #4415TMT_SOURCE_DIRaddition elsewhere - when it's needed, who needs to add it, do we need another context, etc.TMT_SOURCE_DIRenvvar setting out of thediscoverstep #4616envparameters toenvironment#4614**self._environment_from_cliinPlan.environment, and**self._environment_from_cliinRun.environmentprepare/installorprepare/artifact- do they expose variables as they should?ansibleExposeProbably not reasonable, asTMT_SOURCE_DIRtoprepareandfinishphasesprepareandfinishphases are not tied to onediscoverphase likeexecutephases are.Assorted notes
Current (rough) ordering
AFAICT, the rough order of precedence, as of now, is something like the following:
provision[].environmenttest[].environment$TMT_PLAN_ENVIRONMENT_FILEenvironment-filekeyenvironmentkeyenvironment-filekeyenvironmentkey--environmentand--environment-filefrom previous invocations)tmt run --environmenttmt run --environment-fileTMT_VERSION,TMT_TREE, ...Desired state
This should be the desired order of precedence, from the weakest to strongest sources:
test[].environmentenvironment-filekeyenvironmentkeyenvironment-filekeyenvironmentkeyprovision[].environment$TMT_PLAN_ENVIRONMENT_FILEtmt run--environment-fileand--environmentfrom previous invocations)tmt run --environment-filetmt run --environmenttmt * exporttmt * export --environment-filetmt * export --environmenttmt trytmt try --environment-filetmt try --environmentTMT_VERSION,TMT_TREE, ...