App-Prove-Plugin-Elasticsearch

 view release on metacpan or  search on metacpan

lib/App/Prove/Plugin/Elasticsearch.pm  view on Meta::CPAN

# PODNAME:  App::Prove::Plugin::Elasticsearch
# ABSTRACT: Prove Plugin to upload test results to elastic search as they are executed

package App::Prove::Plugin::Elasticsearch;
$App::Prove::Plugin::Elasticsearch::VERSION = '0.001';
use strict;
use warnings;

use App::Prove::Elasticsearch::Utils();

sub load {
    my ($class, $prove) = @_;

    my $app  = $prove->{app_prove};
    my $args = $prove->{args};

    my $conf = App::Prove::Elasticsearch::Utils::process_configuration($args);

    if (
        scalar(
            grep {
                my $subj = $_;
                grep { $subj eq $_ } qw{server.host server.port}
            } keys(%$conf)
        ) != 2
      ) {
        print
          "# Insufficient information provided to upload test results to elasticsearch.  Skipping...\n";
        return $class;
    }

    $app->harness('App::Prove::Elasticsearch::Harness');
    $app->merge(1);

    my $indexer = App::Prove::Elasticsearch::Utils::require_indexer($conf);
    &{\&{$indexer . "::check_index"}}($conf);

    return $class;
}

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

App::Prove::Plugin::Elasticsearch - Prove Plugin to upload test results to elastic search as they are executed

=head1 VERSION

version 0.001

=head1 SYNOPSIS

`prove -PElasticsearch='server.host=zippy.test,server.port=666,client.blamer=FingerPointer,client.indexer=EvilIndexer,client.versioner=Git,client.autodiscover=ByName`

=head1 DESCRIPTION

This testing plugin itself is highly pluggable to allow for a variety of indexing and searching conditions.

=head2 INDEXER

The default indexer is L<App::Prove::Elasticsearch::Indexer>

Creates an index (if it does not exist)  called 'testsuite' in your specified Elasticsearch instance, which has the following parameters:

=over 4

=item B<body>: the raw text produced by prove -mv from your test.

=item B<elapsed>: the time it took the test to execute

=item B<occurred>: when the test began execution

=item B<executor>: the name of the executor.  This can be passed as executor=.  Defaults to root @ the host executed on.

=item B<version>: the version of the system under test.  See the versioner option as to how this is obtained.

=item B<environment>: the environment of the system under test.  See the platformer option as to how this is obtained.

=item B<name>: the filename of the test run

=item B<path>: the path to the test.  This is to allow tests with the same name at different paths to report correctly.

=item B<status>: whether the test global result was PASS, FAIL, SKIP, etc.  See L<App::Prove::Elasticsearch::Parser> for the rules as to these statuses.

=item B<steps>: detailed information (es object) as to the name, elapsed time, status and step # for each step.

=back

If this index does not exist, it will be created for you.
If an index exists with that name an exception will be thrown.
To override the index name to avoid exceptions, subclass App::Prove::Elasticsearch::Indexer and use your own name.
The name searched for must be a child of the App::Prove::Elasticsearch::Indexer, e.g. App::Prove::Elasticsearch::Indexer::EvilIndexer.

You may have noticed that this pluggable design does not necessarily mean you need to use elasticsearch as your indexer;
so long as the information above is all you need for your test management system, there's no reason you couldn't make a custom indexer for it.

There are also some shipped indexer extensions:

=over 4

=item B<DzilDist>: Names the index based on what your distribution is named in dist.ini

=item B<MMDist>: Names the index based on what your distribution is named in Makefile.PL

=back



( run in 1.185 second using v1.01-cache-2.11-cpan-b16cb0d3907 )