Example #1
0
def run_tests(validations, publishers=None, config_path=None,
              environment_name=None, config=None, dry_run=False,
              processes=1, print_banner=True, timeout=60, timeout_retries=2):
    """Main entry point into Alarmageddon.

    Run the given validations and report them to given publishers.

    Either both `config_path` and `environment_name` should not be None,
    or `config` should not be None.

    :param validations: List of :py:class:`~.validation.Validation` objects
      that Alarmageddon will perform.
    :param publishers: List of :py:class:`~.publisher.Publisher`
      objects that Alarmageddon will publish validation results to.
    :param dry_run: When True, will prevent Alarmageddon from performing
      validations or publishing results, and instead will print which
      validations will be published by which publishers upon failure.
    :param processes: The number of worker processes to spawn.
    :param print_banner: When True, print the Alarmageddon banner.
    :timeout: If a validation runs for longer than this number of seconds,
      Alarmageddon will kill the process running it.

    .. deprecated:: 1.0.0
        These parameters are no longer used: *config_path*,
        *environment_name*, *config*.
        Configuration happens when constructing publishers instead.

    """

    if config is not None:
        warnings.warn("config keyword argument in run_tests is deprecated" +
                      " and has no effect.", DeprecationWarning)
    if config_path is not None:
        warnings.warn("config_path keyword argument in run_tests is" +
                      " deprecated and has no effect.", DeprecationWarning)
    if environment_name is not None:
        warnings.warn("environment_name keyword argument in run_tests is " +
                      "deprecated and has no effect.", DeprecationWarning)



    publishers = publishers or []
    publishers.append(junit.JUnitPublisher("results.xml"))

    # We assume that if one is calling run_tests one actually wanted
    # to run some tests, not just fail silently
    if not validations:
        raise ValueError("run_tests expected non-empty list of validations," +
                         "got {} instead".format(validations))

    if print_banner:
        banner.print_banner(True)

    #always dry run. this will catch weird issues with enrichment
    do_dry_run(validations, publishers)

    if not dry_run:
        # run all of the tests
        _run_validations(validations, Reporter(publishers), processes,
                timeout, timeout_retries)
Example #2
0
def test_print_monochrome_banner():
    print_banner(color=False)
Example #3
0
def test_print_color_banner():
    print_banner(color=True)