[Avocado-devel] [RFC] Environment Variables
Amador Pahim
apahim at redhat.com
Wed May 25 08:31:24 UTC 2016
Hi folks,
We have requests to handle the environment variables that we can set to
the tests. This is the RFC in that regard, with a summary of the ideas
already exposed in the original request and some additional planning.
The original request is here:
https://trello.com/c/Ddcly0oG/312-mechanism-to-provide-environment-variables-to-tests-run-on-a-virtual-machine-remote
Motivation
==========
Avocado tests are executed in a fork process or even in a remote
machine. Regardless the fact that Avocado is hard coded to set some
environment variables, they are for internal consumption and user is not
allowed to control/configure its behavior.
The motivation is the request to provide users an interface to set
and/or keep environment variables for test consumption.
Use cases
=========
1) Use the command line or the config file to set the environment
variables in tests processes environment; access those variables from
inside the test.
2) Copy from current environment some environment variable(s) to the
tests processes environment; access those variables from inside the test.
Proposal
========
- To create a command line option, under the `run` command, to set
environment variables that will be available in tests environment process:
$ avocado run --test-env='FOO=BAR,FOO1=BAR1' passtest.py
- To create an option in config file with a dictionary of environment
variables to set in test process environment. It can be used as a
replacement or complement to the command line option (with lower priority):
[tests.env]
test_env_vars = {'FOO': 'BAR', 'FOO1': 'BAR1'}
- Create an option in config file with a list of environment variable
names to copy from avocado main process environment to the test process
environment (similar to env_keep in the /etc/sudoers file):
[tests.env]
env_keep = ['FOO', 'FOO1', 'FOO2']
For every configuration entry point, the setting have to be respected in
local and remote executions.
Drawbacks
=========
While setting an environment variable, user will be able to change the
behavior of a test and probably the behavior of Avocado itself. Maybe
even the OS behavior as well. We should:
- Warn users about the danger when using such options.
- Protect Avocado environment variables from overwriting.
Looking forward to read your comments.
Best Regards,
--
Amador Pahim
More information about the Avocado-devel
mailing list