ASNMTAP
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
plugins/jUnit/check_jUnit.pl view on Meta::CPAN
$testcaseTestclass = (defined $ref->{TESTCLASS}) ? '<testclass>'. $ref->{TESTCLASS} .'</testclass>' : '';
$testcaseTimewait = (defined $ref->{TIMEWAIT} and $ref->{TIMEWAIT} > 0) ? '<timewait>'. $ref->{TIMEWAIT} .'</timewait>' : '';
$jUnitMaxtime = $ref->{MAXTIME} if (defined $ref->{MAXTIME} and $ref->{MAXTIME} > 0 and ! defined $maxtime);
$testcases .= "
<testcase>
<server>$testcaseServer</server>
<wlsusername>$testcaseWlsusername</wlsusername>
<wlspassword>$testcaseWlspassword</wlspassword>
<appname>$testcaseAppname</appname>
<ejbname>$testcaseEejbname</ejbname>
<version>$testcaseVersion</version>
<parameters><![CDATA[$testcaseParameters]]></parameters>
$testcaseTestclass
$testcaseTimewait
</testcase>";
}
}
if ($_ACTIVATED and defined $testcases) {
$xml = "<?xml version=\"1.0\" ?>
<junit>
<username>$jUnitUsername</username>
<password>$jUnitPassword</password>
<ukey>$jUnitUkey</ukey>
<type>$jUnitType</type>
<svparam>$jUnitSvparam</svparam>
<maxtime>$jUnitMaxtime</maxtime>
$testcases
</junit>";
}
$sth->finish() or $rv = errorTrapDBI (\$objectPlugins, "sth->finish: $sql");
}
$dbh->disconnect() or $rv = errorTrapDBI (\$objectPlugins, "Sorry, $jUnitServerDbDR:$jUnitServerName:$jUnitServerPort was unable to disconnect.");
}
if (defined $xml) {
print "$xml\n" if ($debug == 4);
($returnCode) = scan_socket_info_jUnit (\$objectPlugins, 'tcp', $jUnitServer, $jUnitPort, $jUnitService, $jUnitRequest, 10, $xml, $debug);
} elsif ( defined $_ACTIVATED and ! $_ACTIVATED ) {
$objectPlugins->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, alert => "Test has been deactivated with status '$_STATUS' onto the jUnit server. PLEASE contact Monitoring Office" }, $TYPE{REPLACE} );
} elsif ( defined $_ACTIVATED and $_STATUS ne 'ASNMTAP' ) {
$objectPlugins->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, alert => "Test has been activated with status '$_STATUS' onto the jUnit server. PLEASE contact Monitoring Office" }, $TYPE{REPLACE} );
} else {
$objectPlugins->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, alert => "No base service defined into the table $jUnitServerTablDR from database $jUnitServerDbDR" }, $TYPE{APPEND} );
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# End plugin - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
$objectPlugins->exit (7);
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub scan_socket_info_jUnit {
my ($asnmtapInherited, $protocol, $host, $port, $service, $request, $socketTimeout, $xml, $debug) = @_;
my ($exit, $result, $action, $socketProtocol);
$exit = 0;
$action = '<NIHIL>';
print "\nscan_socket_info : <$protocol><$host><$port><$service><$request>\n$xml\n\n" if ($debug >= 2);
if ($protocol eq 'tcp' || $protocol eq 'udp') { $socketProtocol = $protocol; } else { $socketProtocol = 'tcp'; }
$SIG{ALRM} = sub { alarm (0); $exit = 1 };
alarm ( 10 ); $exit = 0;
use IO::Socket;
if (defined $socketTimeout) {
$result = new IO::Socket::INET ('Proto' => $socketProtocol, 'PeerAddr' => $host, 'PeerPort' => $port, 'Timeout' => $socketTimeout);
} else {
$result = new IO::Socket::INET ('Proto' => $socketProtocol, 'PeerAddr' => $host, 'PeerPort' => $port);
}
if ($result) {
print "IO::Socket::INET : $result\n" if ($debug >= 2);
} else {
print "IO::Socket::INET : <NIHIL>\n" if ($debug >= 2);
$$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, alert => "Cannot connect to $host:$port" }, $TYPE{APPEND} );
return ( $ERRORS{UNKNOWN} );
}
$result->autoflush(1);
if ($socketProtocol eq 'tcp') {
print "jUnit($port): wait for answer\n" if ($debug >= 2);
while (<$result>) {
chomp;
print "jUnit($port): <$_>\n" if ($debug >= 2);
if ($exit) { $action = '<TIMEOUT>'; last; }
SWITCH: {
if ($_ =~ /^junitserver signal INIT$/) {
$action = 'junitserver signal INIT';
$xml =~ s/\n//g if ($xmlCleanUpLineFeeds);
$xml =~ s/> +</></g if ($xmlCleanUpSpaces);
print $result "$xml\n";
print "$xml\n" if ( $debug );
}
if ($_ =~ /^junitserver signal XML_NOTOK$/) { $action = 'junitserver signal XML_NOTOK'; last; }
if ($_ =~ /^junitserver signal WRONG USER\/PASSWORD$/) { $action = 'junitserver signal WRONG USER/PASSWORD'; last; }
if ($_ =~ /^junitserver signal SENT_OK$/) { $action = 'junitserver signal SENT_OK'; last; }
}
}
} elsif ($socketProtocol eq 'udp') {
print "udp : $service($port), no RFC implementation\n" if ($debug >= 2);
}
alarm (0); $SIG{ALRM} = 'DEFAULT';
close ( $result );
unless (defined $request) { $request = "$service($port)"; }
if ($request eq $action) {
$$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{OK}, alert => $action }, $TYPE{APPEND} );
return ( $ERRORS{OK} );
} else {
$$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, alert => "Wrong answer from $host $service: $action" }, $TYPE{APPEND} );
return ( $ERRORS{UNKNOWN} );
}
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
sub errorTrapDBI {
my ($asnmtapInherited, $error_message) = @_;
$$asnmtapInherited->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, alert => $error_message, error => "$DBI::err ($DBI::errstr)" }, $TYPE{APPEND} );
view all matches for this distributionview release on metacpan - search on metacpan
( run in 0.500 second using v1.00-cache-2.02-grep-82fe00e-cpan-f5108d614456 )