view release on metacpan or search on metacpan
lib/Integrator/Module/Build.pm view on Meta::CPAN
module, you can use Module::Start to create a new test harness. Here
is an example on how to create a test harness called 'my-test-module'
using the module-starter script available from Module::Starter:
module-starter --mb \
--email='my-email@cydone.com' \
--author='User Name' \
--module='My::Test::Module'
Then, you want to edit the Build.PL file under My-Test-Module with the
proper Integrator credentials (go to L<https://www.partnerscydone.com> to
request your demo credentials, a specific Build.PL file will be sent
to you within a demo test harness).
Here is a typical Build.PL file used to instantiate such a perl test
harness (note the 'Integrator::Module::Build' lines):
use strict;
use warnings;
use Integrator::Module::Build;
my $builder = Integrator::Module::Build->new(
lib/Integrator/Module/Build.pm view on Meta::CPAN
eval {
require Digest::MD5;
import Digest::MD5 'md5_hex'
};
if ($@) { # oups, no Digest::MD5
require Digest::Perl::MD5;
import Digest::Perl::MD5 'md5_hex'
}
}
### # We need to protect the credentials of the harness user since they
### # could be stored locally. But the warning is not required when first
### # installing IMB. Hence we test Build.PL to see if it contains IMB before
### # going any further. Then we can issue the warning if the credentails
### # are not properly protected.
### if (_file_contains_text('Build.PL', qr{Integrator::Module::Build\s*->\s*new})) {
### foreach my $file (qw{ Build.PL _build/build_params}) {
### warn( "SECURITY WARNING: '$file' is readable or writeable by others, ".
### "change file permissions with 'chmod 700 $file'")
### unless (_is_rw_safe($file));
### }
lib/Integrator/Module/Build.pm view on Meta::CPAN
=cut
# This sub also sends the MD5 and the local configuration to the server.
sub ACTION_integrator_sync {
my $self = shift;
my $xml = shift;
my $t = time;
my $store_mode='YES'; #initial assumption
my $credentials = _get_integrator_credentials($self);
print "== LOCAL DATABASE LOOKUP ===========================================\n";
unless (defined $xml) {
$store_mode='NO';
my $names = join('', (keys %{$self->config_data('regressions')}));
unless ($names eq '') {
my $stored = $self->config_data('regressions');
#list reports to upload
print "Loading test runs that are ready for upload:\n";
$xml = _generate_signed_xml_from_struct($self, $credentials, $stored);
########### Removed this on Jan 8th 2007, not needed !!!!
########### #url encode the document
########### $xml =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
########### Removed this on Jan 8th 2007, not needed !!!!
print "done.\n";
}
else {
print "No local test result found. You might want execute the tests first. Exiting.\n";
exit -1;
}
}
print "== INTEGRATOR SERVER DATA UPLOADING ================================\n";
print "Sending data to server\n";
my $response = _harness_post_url($credentials, $xml);
print "done.\n";
#look in the server response and update local stuff
if ($response->{_rc} eq "200") {
print "HTTP transfer done.\n";
print "Analysing results...\n";
my $xs = XML::Simple->new();
my %IN_options = (
NoAttr => 0,
ForceArray => 1,
lib/Integrator/Module/Build.pm view on Meta::CPAN
used with: ./Build integrator_download_test_definition
./Build integrator_download_test_definition --file=complete_this.xml
This action is used to download all test definition data from the current
project in Cydone Integrator.
=cut
sub ACTION_integrator_download_test_definition {
my $self = shift;
my $credentials = _get_integrator_credentials($self);
$credentials->{integrator_test_definition_post}{value} = 'api/downloadTestDefinition';
#$credentials->{integrator_test_definition_post}{value} = 'frontend_dev.php/api/downloadTestDefinition';
my $t = time;
my @files;
my $xml;
#get the filenames of xml files to complete, or setup default download
if (defined $self->{args}{param_file}) {
@files = _get_valid_filenames($self->{args}{param_file});
}
else {
push(@files, '___DEFAULT___weird_file_name___');
print "Default download: all data.\n";
$xml = _get_default_xml($credentials);
}
foreach my $file (@files) {
#list file to upload
unless ($file eq '___DEFAULT___weird_file_name___') {
print "Loading xml file '$file' for upload:\n";
open FIN,"$file" or die "Error opening file: $!";
$xml = join('', (<FIN>));
close FIN or die "Error closing file: $!";
print "done.\n";
}
print "Contacting server: ... fake ping for now ...";
print "done.\n";
print "Sending data to server\n";
my $response = _test_definition_post_url($credentials, $xml);
print "done.\n";
_analyse_server_answer($self, $response);
last if ($file eq '___DEFAULT___weird_file_name___');
}
print "Performed download in " .(time - $t). " sec.\n";
}
# a template sub to fake a default xml file
sub _get_default_xml {
my $credentials = shift;
return << "EOT";
<xml>
<version>1.0</version>
<integrator_version>1.0</integrator_version>
<integrator_test>
<project_code>$credentials->{integrator_project_code}{value}</project_code>
</integrator_test>
</xml>
EOT
}
=head2 ACTION_integrator_send_xml
used with: ./Build integrator_send_xml
./Build integrator_send_xml --file=commands_api.xml
This action is used to send a an xml api file to Cydone Integrator.
=cut
sub ACTION_integrator_send_xml {
my $self = shift;
my $credentials = _get_integrator_credentials($self);
$credentials->{integrator_test_definition_post}{value} = 'api/doapi';
my $t = time;
my @files;
#get the filenames to upload
if (defined $self->{args}{file}) {
@files = _get_valid_filenames($self->{args}{file});
}
else {
my $default_file = 'server_answer.xml';
lib/Integrator/Module/Build.pm view on Meta::CPAN
print "Loading xml file '$file' for upload:\n";
open FIN,"$file" or die "Error opening file: $!";
my $xml = join('', (<FIN>));
close FIN or die "Error closing file: $!";
print "done.\n";
print "Contacting server: ... fake ping for now ...";
print "done.\n";
print "Sending data to server\n";
my $response = _test_definition_post_url($credentials, $xml);
print "done.\n";
_analyse_server_answer($self, $response);
}
print "Performed upload in " .(time - $t). " sec.\n";
}
=head2 ACTION_integrator_upload_test_definition
used with: ./Build integrator_upload_test_definition
./Build integrator_upload_test_definition --file=definition.xml
This action is used to send a test definition xml file to Cydone Integrator.
=cut
sub ACTION_integrator_upload_test_definition {
my $self = shift;
my $credentials = _get_integrator_credentials($self);
$credentials->{integrator_test_definition_post}{value} = 'api/uploadTestDefinition';
#$credentials->{integrator_test_definition_post}{value} = 'frontend_dev.php/api/uploadTestDefinition';
my $t = time;
my @files;
#get the filenames to upload
if (defined $self->{args}{file}) {
@files = _get_valid_filenames($self->{args}{file});
}
else {
my $default_file = 'server_answer.xml';
lib/Integrator/Module/Build.pm view on Meta::CPAN
print "Loading xml file '$file' for upload:\n";
open FIN,"$file" or die "Error opening file: $!";
my $xml = join('', (<FIN>));
close FIN or die "Error closing file: $!";
print "done.\n";
print "Contacting server: ... fake ping for now ...";
print "done.\n";
print "Sending data to server\n";
my $response = _test_definition_post_url($credentials, $xml);
print "done.\n";
_analyse_server_answer($self, $response);
}
print "Performed upload in " .(time - $t). " sec.\n";
}
sub _analyse_server_answer {
my $self = shift;
my $response = shift;
lib/Integrator/Module/Build.pm view on Meta::CPAN
command-line if more information is required.
=cut
# This action sub, called as a ./Build parameter, is used to compile all log results from
# the _build/integrator file (under the integrator_test_log key) in one huge xml file
# using the Test::TAP::XML report tool
sub ACTION_integrator_xml_report {
my $self = shift;
my $credentials = _get_integrator_credentials($self, qr{or_project_code|or_lab_code});
my $t = time;
my $xml = _generate_signed_xml_from_struct( $self, $credentials, $self->config_data('regressions'));
open FOUT, ">", "report.xml" or die "Error: could not create report.xml file, $!, $?";
print FOUT $xml;
close FOUT or die "Error: could not close report.xml after creating, $!, $?";
print STDERR "Generated xtml report in file \"report.xml\". Took ". (time - $t). " sec.\n";
}
sub _remove_undefs {
my $struct = shift;
foreach my $key (keys %{$struct}) {
lib/Integrator/Module/Build.pm view on Meta::CPAN
sub _print_table_header {
my $user = shift;
my $date = shift;
return <<"EOT";
<tr>
<th colspan="4" class="r">Test case run by $user, started on $date</th>
</tr>
EOT
}
sub _get_integrator_credentials {
my $self = shift;
my $filter = shift; #optional parameter to filter-in credentials to use
my $p = $self->{properties};
my $cred = {
integrator_project_code => {
default => 'my_project',
question => 'a project code',
order => 10,
regexp => qr{\w},
},
integrator_lab_code => {
default => 'first',
lib/Integrator/Module/Build.pm view on Meta::CPAN
#this parameter has a default value and is no longer required from the user...
$cred->{integrator_sync_page}{value} |= 'api/doapi';
#clean-up the urls
$cred->{integrator_url}{value} =~ s/\/$//g;
$cred->{integrator_sync_page}{value} =~ s/\/$//g;
$cred->{integrator_sync_page}{value} =~ s/^\///g;
$cred->{complete_url}{value} = $cred->{integrator_url}{value} .'/'. $cred->{integrator_sync_page}{value};
if($cred->{integrator_http_realm}) {
$browser->credentials(URI->new($cred->{integrator_url}{value})->host_port, #yark !
$cred->{integrator_http_realm}{value},
$cred->{integrator_http_user}{value} => $cred->{integrator_http_pwd}{value});
}
# Pass request to the user agent and get a response back
my $res = $browser->post( $cred->{complete_url}{value},
[
'query' => $xml,
'user_name' => $cred->{integrator_user}{value},
'password' => $cred->{integrator_pwd}{value}
lib/Integrator/Module/Build.pm view on Meta::CPAN
$browser->agent("Integrator::Module::Build/$Integrator::Module::Build::VERSION");
#clean-up the urls
$cred->{integrator_url}{value} =~ s/\/$//g;
$cred->{integrator_test_definition_post}{value} =~ s/\/$//g;
$cred->{integrator_test_definition_post}{value} =~ s/^\///g;
$cred->{complete_url}{value} = $cred->{integrator_url}{value}
.'/'. $cred->{integrator_test_definition_post}{value};
if($cred->{integrator_http_realm}) {
$browser->credentials(URI->new($cred->{integrator_url}{value})->host_port, #yark !
$cred->{integrator_http_realm}{value},
$cred->{integrator_http_user}{value} => $cred->{integrator_http_pwd}{value});
}
# Pass request to the user agent and get a response back
my $res = $browser->post( $cred->{complete_url}{value},
[
'query' => $xml,
'user_name' => $cred->{integrator_user}{value},
'password' => $cred->{integrator_pwd}{value}