Skip to content

Latest commit

 

History

History
108 lines (62 loc) · 7.23 KB

configuration.adoc

File metadata and controls

108 lines (62 loc) · 7.23 KB

Configuration high level overview

configuration files

Main configuration is inside config/config.yaml. Content of that file is also merged with PRIVATE/config.yaml and PRIVATE/config/config.yaml if such files exist. You shouldn’t submit private configuraion and/or credential files to public Git repos thus PRIVATE is a good place to put them in. It defaults to bushslicer_dir/private dir and is listed in .gitignore not to be submitted to the BushSlicer repo.

We have also some configuration in config/cucumber.yml. There are some profiles defined for easily calling with proper options.

lib/configuration.rb is the class that handles the logic behind reading, merging and accessing configuration.

global configuration

This is the the global section inside config/config.yaml. Some generic defaults like git_repo_url or browser.

Some of these options can be overwritten by environment variables, see #env_overrides inside lib/configuration.rb

environment configuration

Under environments there are default options for different environment types. The name of environment does not matter, you can rename environment but if you use same options, the end result should be the same. Names are to just make it easy to start with some reasonable defaults.

The default environment is determined by the default_environment global option. It’s usually set by the BUSHSLICER_DEFAULT_ENVIRONMENT env variable.

Let’s take one example - OCP4 environment. It has as a default hosts_type: SSHAccessibleHost. If we want to override it, we can specify env variable OPENSHIFT_ENV_OCP4_HOSTS_TYPE. Its the same with any other option. All variables that start with OPENSHIFT_ENV_<env name>_SOMETHING get an option for the named environment set. The first part OPENSHIFT_ENV_<env name>_ is removed, then the other part SOMETHING is downcased and converted to a Symbol to become a key in the configuration Hash that is passed to the environment class constructor. That is taken care of in the #load_env private method of BushSlicer::EnvironmentManager class.

user configuration

UserManager, whatever it is inherits options used to create environment. The user manager should only use options prefixed with :user_manager_. Because it inherits environment configuration, all such options can be provided or overriden by environment variables.

So far we only have StaticUserManager so users are defined with the OPENSHIFT_ENV_OCP4_USER_MANAGER_USERS env variable. Two ways to provide a user:

  • by user/password

  • by token

User/password pairs are easier unless you run in environment where you can’t login with a password, e.g. google auth, kerberos auth, etc. You have to generate a token via browser and then supply it to BushSlicer.

Username should be written in full. e.g. with kerberos auth the client tool can take a short username like asd. But you need to use the full username like asd@EXAMPLE.COM.

Some examples:

  • export OPENSHIFT_ENV_OCP4_USER_MANAGER_USERS=joe:password - one user with name joe and password password

  • export OPENSHIFT_ENV_OCP4_USER_MANAGER_USERS=:eKORXg2tqwoNsTmd2s1OdhG2w0vOq9y7R6HbM4pgQ8U one user where we only have a token (username auto-discovered)

  • export OPENSHIFT_ENV_OCP4_USER_MANAGER_USERS=joe:password,:eKORXg2tqwoNsTmd2s1OdhG2w0vOq9y7R6HbM4pgQ8U,alice:password - 3 users where first and last specified by user/password pairs and the second one with a token; usually you use only one approach but it’s possible to mix

other configuration

So far we also have optional_classes root configuration option. It is used to define some classes to be instantiated with particular options. See Configuration#get_optional_class_instance.

Also we have services to define some third party services options. Access to those configuration options is not wrapped in any way. Information should be accessed directly, see below.

Web Driver

For tests which require a web browser:

The typical configuration requires a local "driver" binary to configure and launch a subprocess. Please install the driver for the browser you would prefer to use:

Firefox: Please download the server from https://github.com/mozilla/geckodriver/releases and place it somewhere on your PATH. See https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver for more information. The config defaults to firefox, so you’re all set!

Chrome: Please download the driver from http://chromedriver.storage.googleapis.com/index.html that matches the version of Chrome you are using, place it somewhere on your PATH and set the following environment variable.

  • export BUSHSLICER_CONFIG='{"global": {"browser": "chrome"}}'

You may instead specify a remote Selenium URL to connect to, e.g.:

  • export BUSHSLICER_CONFIG='{"global": {"browser": "chrome", "selenium_url": "http://localhost:4444/wd/hub"}}'

accessing configuration

Whenever you are, you should usually have the convenience #conf method available to get current loaded configuration. Reference to configuration is kept in the Manager object Manager#conf but direct use from manager is discouraged.

To access global options just type conf[:option_name]. If option is nested, you could do: conf[:neting0, :nesting1, :options_name]. This guarantees you that you don’t get an exception looking for nested options but just get a nil when the option is not defined.

To access non-global options, you need to write the root option name first, e.g. conf[:optional_classes, :tcms_tc_manager, :class]. What is a root option name you can see in Configuration#[] method.

Configuration YAML helper classes

Instead of simple kay:value pairs in a configuration it is possible to use so called Helper classes supported by Ruby YAML processor like:

input_entry: !ruby/object:BushSlicer::ConfigEnvVariable var_name: ENVVAR1

Above example means the key input_entry contains a value extracted from the content of shell environment variable ENVVAR1. This approach can be used anywhere in the configuration.

Available Helper classed: * ConfigEnvVariable - content of environment variable * ConfigEnvFile - path for file with content of environment variable

ConfigEnvVariable

The aim of this helper class is a simple injecting of value from shell environment variable. It is useful in the case when the simple value is expected by the configuration.

Parameters: var_name - the name of shell environment variable for its content

ConfigEnvFile

The aim of this helper class is an easy injection of file path. The file path is a reference to created temporary file where is stored a content from shell environment variable after its base64 decoding. Temporary file is deleted at the end of execution automatically. It is useful in case when the file path is expected by the configuration.

Parameters: var_name - the name of shell environment variable for its content

Additional environment variables for launch_instance.rb

It is possible to specify additional environment variables which are available in the running context of Ruby templates and invoked Shell scripts. This approach works differently than template’s variables.

Environment variables for exporting into the running context are specified by sub-section install-envvars under the global section inside config/config.yaml.