App-Prove-Plugin-Elasticsearch

 view release on metacpan or  search on metacpan

META.json  view on Meta::CPAN

{
   "abstract" : "Prove Plugin to upload test results to elastic search as they are executed",
   "author" : [
      "George S. Baugh <teodesian@cpan.org>"
   ],
   "dynamic_config" : 0,
   "generated_by" : "Dist::Zilla version 6.006, CPAN::Meta::Converter version 2.150001",
   "license" : [
      "perl_5"
   ],
   "meta-spec" : {
      "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",

META.yml  view on Meta::CPAN

---
abstract: 'Prove Plugin to upload test results to elastic search as they are executed'
author:
  - 'George S. Baugh <teodesian@cpan.org>'
build_requires:
  ExtUtils::MakeMaker: '0'
  File::Spec: '0'
  FindBin: '0'
  IO::Handle: '0'
  IPC::Open3: '0'
  Test::Class: '0'
  Test::Deep: '0'

Makefile.PL  view on Meta::CPAN

# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.006.
use strict;
use warnings;

use 5.006;

use ExtUtils::MakeMaker;

my %WriteMakefileArgs = (
  "ABSTRACT" => "Prove Plugin to upload test results to elastic search as they are executed",
  "AUTHOR" => "George S. Baugh <teodesian\@cpan.org>",
  "CONFIGURE_REQUIRES" => {
    "ExtUtils::MakeMaker" => 0
  },
  "DISTNAME" => "App-Prove-Plugin-Elasticsearch",
  "EXE_FILES" => [
    "bin/ape",
    "bin/testd"
  ],
  "LICENSE" => "perl",

README  view on Meta::CPAN



This archive contains the distribution App-Prove-Plugin-Elasticsearch,
version 0.001:

  Prove Plugin to upload test results to elastic search as they are executed

This software is copyright (c) 2018 by George S. Baugh.

This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.


This README file was generated by Dist::Zilla::Plugin::Readme v6.006.

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

# ABSTRACT: Determine the responsible for tests via Changes file for upload to elasticsearch
# PODNAME: App::Prove::Elasticsearch::Blamer::Default

package App::Prove::Elasticsearch::Blamer::Default;
$App::Prove::Elasticsearch::Blamer::Default::VERSION = '0.001';
use strict;
use warnings;
use utf8;

use File::Basename qw{dirname};
use Cwd qw{abs_path};

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

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

App::Prove::Elasticsearch::Blamer::Default - Determine the responsible for tests via Changes file for upload to elasticsearch

=head1 VERSION

version 0.001

=head1 SUBROUTINES

=head2 get_responsible_party

Get the responsible party from Changes

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

# ABSTRACT: Determine the responsible party for tests via environment variable for upload to elasticsearch
# PODNAME: App::Prove::Elasticsearch::Blamer::Env

package App::Prove::Elasticsearch::Blamer::Env;
$App::Prove::Elasticsearch::Blamer::Env::VERSION = '0.001';
use strict;
use warnings;
use utf8;

sub get_responsible_party {
    die "TESTSUITE_EXECUTOR not set" unless $ENV{TESTSUITE_EXECUTOR};

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

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

App::Prove::Elasticsearch::Blamer::Env - Determine the responsible party for tests via environment variable for upload to elasticsearch

=head1 VERSION

version 0.001

=head1 SUBROUTINES

=head2 get_responsible_party

Get the responsible party from $ENV{TESTSUITE_EXECUTOR}

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

# ABSTRACT: Determine the responsible party for tests via git for upload to elasticsearch
# PODNAME: App::Prove::Elasticsearch::Blamer::Git

package App::Prove::Elasticsearch::Blamer::Git;
$App::Prove::Elasticsearch::Blamer::Git::VERSION = '0.001';
use strict;
use warnings;
use utf8;

use Git;

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

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

App::Prove::Elasticsearch::Blamer::Git - Determine the responsible party for tests via git for upload to elasticsearch

=head1 VERSION

version 0.001

=head1 SUBROUTINES

=head2 get_responsible_party

Get the responsible party from the author.email in git-config

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

# ABSTRACT: Determine the responsible party for tests via system user & hostname for upload to elasticsearch
# PODNAME: App::Prove::Elasticsearch::Blamer::Env

package App::Prove::Elasticsearch::Blamer::System;
$App::Prove::Elasticsearch::Blamer::System::VERSION = '0.001';
use strict;
use warnings;
use utf8;

use System::Info;

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

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

App::Prove::Elasticsearch::Blamer::Env - Determine the responsible party for tests via system user & hostname for upload to elasticsearch

=head1 VERSION

version 0.001

=head1 SUBROUTINES

=head2 get_responsible_party

Get the responsible party as your system user @ hostname.

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

# PODNAME:  App::Prove::Elasticsearch::Harness
# ABSTRACT: Harness for uploading test results to elasticsearch

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

use parent qw/TAP::Harness/;

# inject parser_class as Test::Rail::Parser.
sub new {

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

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

App::Prove::Elasticsearch::Harness - Harness for uploading test results to elasticsearch

=head1 VERSION

version 0.001

=head1 DESCRIPTION

Connective tissue between the elasticsearch prove plugin and the parser, which does all the real work.
You shouldn't need to modify, or even be aware of this module.

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

# ABSTRACT: Define what data is to be uploaded to elasticsearch, and handle it's uploading
# PODNAME: App::Prove::Elasticsearch::Indexer

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

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

use Search::Elasticsearch();

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

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

App::Prove::Elasticsearch::Indexer - Define what data is to be uploaded to elasticsearch, and handle it's uploading

=head1 VERSION

version 0.001

=head1 SYNOPSIS

    App::Prove::Elasticsearch::Indexer::check_index({ 'server.host' => 'zippy.test', 'server.port' => 9600 });

=head1 VARIABLES

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

# PODNAME:  App::Prove::Elasticsearch::Parser
# ABSTRACT: Capture the output of prove, and upload the results of the test to elasticsearch

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

use parent qw/TAP::Parser/;

use Clone qw{clone};
use File::Basename qw{basename dirname};

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


    #Notify user about bad plan a bit better, supposing we haven't bailed
    if (!$self->is_good_plan() && !$self->{'is_bailout'}) {
        $self->{'raw_output'} .=
            "\n# ERROR: Bad plan.  You ran "
          . $self->tests_run
          . " tests, but planned "
          . $self->tests_planned . ".";
    }

    $self->{upload} = {
        body    => $self->{raw_output},
        elapsed => $self->{elapsed},
        occurred =>
          strftime("%Y-%m-%d %H:%M:%S", localtime($self->{starttime}->[0])),
        status        => $status,
        platform      => $self->{platform},
        executor      => $self->{executor},
        version       => $self->{sut_version},
        test_version  => $self->{test_version},
        name          => basename($self->{file}),
        path          => dirname($self->{file}),
        steps         => $self->{steps},
        steps_planned => $self->tests_planned
    };

    &{\&{$self->{indexer} . "::index_results"}}($self->{upload});
    return $status;
}

sub planCallback {
    my ($plan) = @_;
    my $self = $plan->{'parser'};
    $self->{raw_output} .= $plan->as_string . "\n";
}

sub make_result {

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

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

App::Prove::Elasticsearch::Parser - Capture the output of prove, and upload the results of the test to elasticsearch

=head1 VERSION

version 0.001

=head1 SYNOPSIS

    App::Prove::Elasticsearch::Parser->new();

=head1 CONSTRUCTOR

=head2 new

Creates a TAP::Parser that will upload test results to your repository using the provided indexer.

=head1 OVERRIDDEN CALLBACKS

=head2 unknownCallback

Checks for status overrides (% mark_status=DISCARD) and records unknown lines for later upload.

=head2 commentCallback

=head2 planCallback

=head2 bailoutCallback

These do little more than record the information printed during prove for upload to the result index.

=head2 testCallback

Captures step information and runtime, along with the raw text of the assertion.

=head2 EOFCallback

Actually does the uploading of the result to the index.

Sets test global status as the 'most anomalous' result encountered in the test in the following order (most to least):

=over 4

=item Bailout

=item Skipped (when skip_all happens)

=item Failed

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

# ABSTRACT: Determine the platform of the system under test via System::Info for upload to elasticsearch
# PODNAME: App::Prove::Elasticsearch::Platformer::Default

package App::Prove::Elasticsearch::Platformer::Default;
$App::Prove::Elasticsearch::Platformer::Default::VERSION = '0.001';
use strict;
use warnings;
use utf8;

use System::Info;

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

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

App::Prove::Elasticsearch::Platformer::Default - Determine the platform of the system under test via System::Info for upload to elasticsearch

=head1 VERSION

version 0.001

=head1 SUBROUTINES

=head2 get_platforms

Return the OS version and perl version as an array.

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

# ABSTRACT: Determine the platform(s) of the system under test via environment variable for upload to elasticsearch
# PODNAME: App::Prove::Elasticsearch::Platformer::Env

package App::Prove::Elasticsearch::Platformer::Env;
$App::Prove::Elasticsearch::Platformer::Env::VERSION = '0.001';
use strict;
use warnings;
use utf8;

sub get_platforms {
    die "TESTSUITE_PLATFORM not set" unless $ENV{TESTSUITE_PLATFORM};

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

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

App::Prove::Elasticsearch::Platformer::Env - Determine the platform(s) of the system under test via environment variable for upload to elasticsearch

=head1 VERSION

version 0.001

=head1 SUBROUTINES

=head2 get_platforms

Return the OS version and perl version as an array.

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

# ABSTRACT: Determine the version of a system under test via the module's Changes file for upload to elasticsearch
# PODNAME: App::Prove::Elasticsearch::Versioner::Default

package App::Prove::Elasticsearch::Versioner::Default;
$App::Prove::Elasticsearch::Versioner::Default::VERSION = '0.001';
use strict;
use warnings;
use utf8;

use File::Basename qw{dirname};
use Cwd qw{abs_path};

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

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

App::Prove::Elasticsearch::Versioner::Default - Determine the version of a system under test via the module's Changes file for upload to elasticsearch

=head1 VERSION

version 0.001

=head1 SUBROUTINES

=head2 get_version

Reads Changes and returns the version therein.

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

# ABSTRACT: Determine the version of a system under test via environment variable for upload to elasticsearch
# PODNAME: App::Prove::Elasticsearch::Versioner::Env

package App::Prove::Elasticsearch::Versioner::Env;
$App::Prove::Elasticsearch::Versioner::Env::VERSION = '0.001';
use strict;
use warnings;
use utf8;

sub get_version {
    die "TESTSUITE_VERSION not set" unless $ENV{TESTSUITE_VERSION};

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

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

App::Prove::Elasticsearch::Versioner::Env - Determine the version of a system under test via environment variable for upload to elasticsearch

=head1 VERSION

version 0.001

=head1 SUBROUTINES

=head2 get_version

Reads $ENV{TESTSUITE_VERSION} and returns the version therein.

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

# ABSTRACT: Determine the version of a system under test via git for upload to elasticsearch
# PODNAME: App::Prove::Elasticsearch::Versioner::Git

package App::Prove::Elasticsearch::Versioner::Git;
$App::Prove::Elasticsearch::Versioner::Git::VERSION = '0.001';
use strict;
use warnings;
use utf8;

use Git;

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

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

App::Prove::Elasticsearch::Versioner::Git - Determine the version of a system under test via git for upload to elasticsearch

=head1 VERSION

version 0.001

=head1 SUBROUTINES

=head2 get_version

Reads your git log and returns the current SHA as the version.

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) = @_;

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


    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;

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

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

lib/App/ape/test.pm  view on Meta::CPAN

package App::ape::test;
$App::ape::test::VERSION = '0.001';

# ABSTRACT: Run a test manually and upload the results to Elasticsearch
# PODNAME: App::Ape::test

use strict;
use warnings;

use Getopt::Long qw{GetOptionsFromArray};
use App::Prove::Elasticsearch::Utils;
use Pod::Usage;
use File::Temp;
use POSIX qw{strftime};

lib/App/ape/test.pm  view on Meta::CPAN

            print "No such case $case->{name} on filesystem, skipping.\n";
            next;
        }
        my $executor =
          &{\&{$self->{blamer} . "::get_responsible_party"}}($case->{name});

        my $occurred = time();
        my $output   = $self->get_test_commentary();
        my $elapsed  = time() - $occurred;

        my $upload = {
            body         => $output,
            elapsed      => $elapsed,
            occurred     => strftime("%Y-%m-%d %H:%M:%S", localtime($occurred)),
            status       => $self->{options}{status},
            platform     => $self->{platforms},
            executor     => $executor,
            version      => $self->{version},
            test_version => $case->{version},
            name         => basename($case->{name}),
            path         => dirname($case->{name}),
        };

        eval { &{\&{$self->{indexer} . "::index_results"}}($upload) };
        print "$@\n" if $@;
    }
    $0 = "ape test: shutting down";
    return 0;
}

sub get_test_commentary {
    my $self = shift;

    my ($fh, $filename);

lib/App/ape/test.pm  view on Meta::CPAN

1;

__END__

=pod

=encoding UTF-8

=head1 NAME

App::Ape::test - Run a test manually and upload the results to Elasticsearch

=head1 VERSION

version 0.001

=head1 USAGE

Adding new results:

    ape test -s OK [ -e 55 -d defect1 ] test1 ... testN

lib/App/ape/test.pm  view on Meta::CPAN

=head1 CONSTRUCTOR

=head2 new(@ARGV)

Process arguments and include all relevant plugins to add a test result.

=head1 METHODS

=head2 run()

Executes the upload of results to Elasticsearch.

=head2 get_test_commentary

If the user has passed a --body, we will read it.
Otherwise, open up an EDITOR/VISUAL session to allow them to write to a temp file their test body.

=head1 AUTHOR

George S. Baugh <teodesian@cpan.org>

t/App-Prove-Elasticsearch-Parser.t  view on Meta::CPAN

                 'source'            => "$FindBin::Bin/data/pass.test",
                 'spool'             => undef,
                 'switches'          => [],
    };

    my $p;
    is(exception { $p = App::Prove::Elasticsearch::Parser->new( $opts ) }, undef, "make_parser executes all the way through");
    SKIP: {
        skip("Couldn't build parser",9) unless $p;
        is(exception {$p->run()}, undef, "Running parser works");
        is($p->{upload}->{version},'666',"Version correctly recognized");
        is($p->{upload}->{executor},'billy',"Executor correctly recognized");
        is($p->{upload}->{path},"$FindBin::Bin/data","Path correctly recognized");
        is($p->{upload}->{name},"pass.test","Test name correctly recognized");
        cmp_bag($p->{upload}->{platform},['zippyOS'],"Platform(s) correctly recognized");
        #status, steps, body
        like($p->{upload}->{body},qr/yay/i,"Full test output captured");
        is(scalar(@{$p->{upload}->{steps}}),1,"Test steps captured");
        is($p->{upload}->{status},'OK',"Test status captured");
    }

    #Verify status overrides
    $opts->{source} = "$FindBin::Bin/data/discard.test";
    is(exception { $p = App::Prove::Elasticsearch::Parser->new( $opts ) }, undef, "make_parser executes all the way through");
    SKIP: {
        skip("Couldn't build parser",3) unless $p;
        is(exception {$p->run()}, undef, "Running parser works");
        is($p->{global_status},'DISCARD',"Global status override correctly acquired");
        is($p->{upload},undef,"Made no attempt to upload when status DISCARD was indicated");
    }
}

t/App-Prove-Plugin-Elasticsearch.t  view on Meta::CPAN

    local *App::Prove::Elasticsearch::Utils::process_configuration = sub { return $straightdope };
    local *App::Prove::Elasticsearch::Utils::require_indexer = sub { return 'App::Prove::Elasticsearch::Indexer' };
    use warnings;

    my $p = {args => [], app_prove => App::Prove->new()};
    is(exception { App::Prove::Plugin::Elasticsearch->load($p) }, undef, "Happy path can execute all the way through");

    $straightdope = {};
    my $out = '';
    is(exception { $out = capture_merged { App::Prove::Plugin::Elasticsearch->load($p) } }, undef, "Zero-Conf path can execute all the way through");
    like($out,qr/insufficient information/i,"Zero-conf run skips upload");
}

t/data/Makefile.PL  view on Meta::CPAN

# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.010.
use strict;
use warnings;

use 5.006;

use ExtUtils::MakeMaker;

my %WriteMakefileArgs = (
  "ABSTRACT" => "Prove Plugin to upload test results to elastic search as they are executed",
  "AUTHOR" => "George S. Baugh <teodesian\@cpan.org>",
  "CONFIGURE_REQUIRES" => {
    "ExtUtils::MakeMaker" => 0
  },
  "DISTNAME" => "App-Prove-Plugin-Elasticsearch",
  "LICENSE" => "perl",
  "MIN_PERL_VERSION" => "5.006",
  "NAME" => "App::Prove::Plugin::Elasticsearch",
  "PREREQ_PM" => {
    "Clone" => 0,



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