buildtest.menu.build

This module contains all the methods related to “buildtest build” which is used for building test scripts from a Buildspec

Module Contents

Functions

build_phase(builders, printTable=False)

This method will build all tests by invoking class method build for

discover_buildspecs(tags=None, executorname=None, buildspec=None, exclude_buildspec=None, debug=False)

This method discovers all buildspecs and returns a list of discovered

discover_buildspecs_by_executor_name(executor_name)

This method discovers buildspecs by executor name, using --executor-name

discover_buildspecs_by_tags(input_tag)

This method discovers buildspecs by tags, using --tags option

discover_by_buildspecs(buildspec)

Given a buildspec file specified by the user with buildtest build --buildspec,

func_build_subcmd(args, config_opts)

Entry point for buildtest build sub-command. This method will discover

resolve_testdirectory(config_opts, input_testdir=None)

This method resolves which test directory to select. For example, one

run_phase(builders, executor, config_dict, printTable=False)

This method will run all builders with the appropriate executor.

buildtest.menu.build.build_phase(builders, printTable=False)

This method will build all tests by invoking class method build for each builder that generates testscript in the test directory.

Parameters
  • builders (list) – A list of builders

  • printTable (boolean) – Print builder table

buildtest.menu.build.discover_buildspecs(tags=None, executorname=None, buildspec=None, exclude_buildspec=None, debug=False)

This method discovers all buildspecs and returns a list of discovered excluded buildspecs. The input arguments tags, buildspec, exclude_buildspec map to --tags --buildspec and --exclude option in buildtest build.

Parameters
  • tags (str) – Input argument from buildtest build --tags

  • executorname (list) – Input argument from buildtest build --executor-name

  • buildspec (str) – Input argument from buildtest build --buildspec

  • exclude_buildspec – Input argument from buildtest build --exclude

  • debug (boolean) – Boolean to control print messages to stdout

Returns

two lists of discovered and excluded buildspecs

Return type

list, list

buildtest.menu.build.discover_buildspecs_by_executor_name(executor_name)

This method discovers buildspecs by executor name, using --executor-name option from buildtest build command. This method will read BUILDSPEC_CACHE_FILE and search for executor key in buildspec recipe and match with input executor name. The return is a list of matching buildspec with executor name to process.

Parameters

executor_name (string) – Input executor name from command line argument buildtest build --executor-name <name>

Returns

a list of buildspec files that match tag name

Return type

list

buildtest.menu.build.discover_buildspecs_by_tags(input_tag)

This method discovers buildspecs by tags, using --tags option from buildtest build command. This method will read BUILDSPEC_CACHE_FILE and search for tags key in buildspec recipe and match with input tag. Since tags field is a list, we check if input tag is in list and if so we add the entire buildspec into a list. The return is a list of buildspec files to process.

Parameters

input_tag (string) – Input tags from command line argument buildtest build --tags <tags>

Returns

a list of buildspec files that match tag name

Return type

list

buildtest.menu.build.discover_by_buildspecs(buildspec)

Given a buildspec file specified by the user with buildtest build --buildspec, discover one or more files and return a list for buildtest to process. This method is called once per argument of --buildspec or --exclude option. If its a directory path we recursively find all buildspecs with .yml extension. If filepath doesn’t exist or file extension is not .yml we return None and log as an error.

# file path buildtest build –buildspec tutorials/hello.sh.yml

# directory path buildtest build –buildspec tutorials

Parameters

buildspec (str) – Input argument from buildtest build --buildspec

Returns

A list of discovered buildspec with resolved path, if its invalid we return None

Return type

list or None

buildtest.menu.build.func_build_subcmd(args, config_opts)

Entry point for buildtest build sub-command. This method will discover Buildspecs in method discover_buildspecs. If there is an exclusion list this will be checked, once buildtest knows all Buildspecs to process it will begin validation by calling BuildspecParser and followed by an executor instance by invoking BuildExecutor that is responsible for executing the test based on the executor type. A report of all builds, along with test summary will be displayed to screen.

Parameters

args (dict, required) – arguments passed from command line

Return type

None

buildtest.menu.build.logger
buildtest.menu.build.resolve_testdirectory(config_opts, input_testdir=None)

This method resolves which test directory to select. For example, one can specify test directory via command line buildtest build --testdir <path> or path in configuration file. The default is $BUILDTEST_ROOT/var/tests

Parameters
  • config_opts (dict) – loaded buildtest configuration as a dict.

  • input_testdir (str) – Input test directory from command line buildtest build --testdir

Returns

Path to test directory to use

Return type

str

buildtest.menu.build.run_phase(builders, executor, config_dict, printTable=False)

This method will run all builders with the appropriate executor. The executor argument is an instance of BuildExecutor that is responsible for orchestrating builder execution to the appropriate executor class. The executor contains a list of executors picked up from buildtest configuration. For tests running locally, we get the test metadata and count PASS/FAIL test state to tally number of pass and fail test which is printed at end in Test Summary. For tests that need to run via scheduler (Slurm, LSF) the first stage of run will dispatch job, and state will be N/A. We first dispatch all jobs and later poll jobs until they are complete. The poll section is skipped if all tests are run locally. In poll section we regenerate table with all valid_builders and updated test state and returncode and calculate total pass/fail tests. Finally we return a list of valid_builders which are tests that ran through one of the executors. Any test that failed to run or be dispatched will be skipped during run stage and not added in valid_builders. The valid_builders contains the test meta-data that is used for updating test report in next stage.

Parameters
  • builders – A list of builders that need to be run. These correspond to test names

  • executor (BuildExecutor) – The master executor class responsible for invoking appropriate executor class corresponding to builder.

  • config_dict (dict) – loaded buildtest configuration

  • printTable (bool) – boolean to control print statement for run phase

Type

builders: list of objects of type BuilderBase

Returns

A list of valid builders

Return type

list