buildtest.cli.buildspec

Module Contents

Functions

buildspec_find(args, configuration)

Entry point for buildtest buildspec find command

buildspec_validate(configuration, buildspecs=None, excluded_buildspecs=None, tags=None, executors=None)

Entry point for buildtest buildspec validate. This method is responsible for discovering buildspec

show_buildspecs(name, configuration)

This is the entry point for buildtest buildspec show command which will print content of

summarize_buildspec_cache(configuration)

Attributes

logger

class buildtest.cli.buildspec.BuildspecCache(configuration, rebuild=False, filterfields=None, formatfields=None, roots=None, header=None, terse=None)
default_format_fields = ['name', 'type', 'executor', 'tags', 'description']
filter_fields = ['type', 'executor', 'tags', 'buildspec']
format_fields
table
_check_filter_fields(self)

This method checks filter fields are valid. The filter fields are specified as ``buildtest buildspec find –filter <KEY1>=<VAL1>,<KEY2>=<VAL2>,…

_check_format_fields(self)

This method will check if all format fields are valid. Format fields are passed as comma separated fields: --format field1,field2,field3,...

_discover_buildspecs(self)

This method retrieves buildspecs based on self.paths which is a list of directory paths to search. If --root is specified we process each argument and recursively find all .yml files

_filter_buildspecs(self, executor, tags, schema_type)

This method will return a boolean True/False that determines if buildspec test entry is skipped as part of filter process. The filter are done based on executor, tags, type field. True indicates test needs to be skipped.

Parameters
  • executor (str, required) – ‘executor; field from buildspec recipe

  • tags (str or list, required) – ‘tags’ field from buildspec recipe

  • schema_type (str, required) – ‘type’ field from buildspec recipe

Returns

boolean to determine if we need to skip buildspec

Return type

bool

_validate_buildspecs(self, buildspecs)

Given a list of buildspec files, validate each buildspec using BuildspecParser and return a list of valid buildspecs. Any invalid buildspecs are added to separate list

_write_buildspec_cache(self)

This method is responsible for writing buildspec cache to file

build(self)

This method will build buildspec cache file. If user requests to rebuild cache we remove the file and recreate cache. If cache file exists, we simply load from cache

build_cache(self)

This method will rebuild the buildspec cache file by recursively searching all .yml files specified by input argument paths which is a list of directory roots. The buildspecs are validated and cache file is updated”

Returns

Rebuild cache file

executor_breakdown(self)

This method will return a dictionary with breakdown of executors by test names.

find_buildspecs(self)

This method will find buildspecs based on cache content. We skip any tests based on executor filter, tag filter or type filter and build a table of tests that will be printed using print_buildspecs method.

get_cache(self)

Returns cache file as loaded dictionary

get_invalid_buildspecs(self)

Return a list of invalid buildspecs

get_maintainers(self)

Return a list of maintainers.

get_names(self)

Return a list of test names found in buildspec cache. We only return test names for valid buildspecs

get_paths(self)

Return a list of search paths

get_unique_executors(self)

Return a list of unique executors.

get_unique_tags(self)

Return a list of unique tags.

get_valid_buildspecs(self)

Return a list of valid buildspecs

load_paths(self)

Add all paths to search for buildspecs. We must read configuration file and check property buildspec_roots for list of directories to search. We check all directories exist, if any fail we don’t add them to path. In addition, we add the default buildspec path where we find tutorials and general tests.

lookup_buildspec_by_name(self, name)

Given an input test name, return corresponding buildspec file found in the cache. :param name: Name of test to query in buildspec cache :type name: str, required

print_buildspecfiles(self, terse=None, header=None)

This method implements buildtest buildspec find --buildspec which reports all buildspec files in cache.

Parameters

terse (bool) – This argument controls output of buildtest buildspec find --buildspec which is a boolean. If its True we print output in raw format otherwise we print in table format

print_buildspecs(self, terse=None, header=None)

Print buildspec table

print_by_executors(self, terse=None, header=None)

This method prints executors by tests and implements buildtest buildspec find --group-by-executor command

Parameters

terse (bool) – Print output in machine readable format

print_by_tags(self, terse=None, header=None)

This method prints tags by tests and implements buildtest buildspec find --group-by-tags command

Parameters

terse (bool) – Print output in machine readable format

print_executors(self, terse=None, header=None)

This method implements buildtest buildspec find --executors which reports all executors from cache.

Parameters

terse (bool) – This argument controls output of buildtest buildspec find --executor which is a boolean. If its True we print output in raw format otherwise we print in table format

static print_filter_fields()

This method prints filter fields available for buildspec cache. This method implements command buildtest buildspec find --helpfilter

static print_format_fields()

This method prints format fields available for buildspec cache. This method implements command buildtest buildspec find --helpformat

print_invalid_buildspecs(self, error=None)

Print invalid buildspecs from cache file. This method implements command buildtest buildspec find invalids :param error: controls whether error message for each buildspec is printed. If set to False, the error messages will be omitted :type error: bool, optional

print_maintainer(self, terse=None, header=None)

This method prints maintainers from buildspec cache file which implements buildtest buildspec find --maintainers command.

Parameters

terse (bool) – This argument controls output of buildtest buildspec find --maintainers which is a boolean. If its True we print output in raw format otherwise we print in table format

print_maintainers_by_buildspecs(self, terse=None, header=None)

This method prints maintainers breakdown by buildspecs. This method implements buildtest buildspec find --maintainers-by-buildspecs

Parameters

terse (bool) – Print output in machine readable format

print_paths(self)

This method print buildspec paths, this implements command buildtest buildspec find --paths

print_tags(self, terse=None, header=None)

This method implements buildtest buildspec find --tags which reports a list of unique tags from all buildspecs in cache file.

Parameters

terse (bool) – This argument controls output of buildtest buildspec find --tags which is a boolean. If its True we print output in raw format otherwise we print in table format

tag_breakdown(self)

This method will return a breakdown of tags by test names.

test_breakdown_by_buildspec(self)

This method will return a dictionary with breakdown of buildspecs by test names.

buildtest.cli.buildspec.buildspec_find(args, configuration)

Entry point for buildtest buildspec find command

buildtest.cli.buildspec.buildspec_validate(configuration, buildspecs=None, excluded_buildspecs=None, tags=None, executors=None)

Entry point for buildtest buildspec validate. This method is responsible for discovering buildspec with same options used for building buildspecs that includes --buildspec, --exclude, --tag, and --executor. Upon discovery we pass each buildspec to BuildspecParser class to validate buildspec and report any errors during validation which is raised as exceptions.

Parameters
  • configuration (instance of SiteConfiguration) – An instance of SiteConfiguration class which is the loaded buildtest configuration used for validating the buildspecs.

  • buildspecs (List, optional) – List of paths to buildspec file which can be a file or directory

  • excluded_buildspecs (List, optional) –

  • tags – List of tag names to search for buildspec

  • executors (List, optional) – List of executor names to search for buildspecs

buildtest.cli.buildspec.logger
buildtest.cli.buildspec.show_buildspecs(name, configuration)

This is the entry point for buildtest buildspec show command which will print content of buildspec based on name of test

buildtest.cli.buildspec.summarize_buildspec_cache(configuration)