« plugins/templates/check_template-WebTransact-XML-Monitoring.pl
↑ Summary
t/Templates/Plugins/WebTransact/check_template-WebTransact-XML-Cactus-parser.t »
| 1 | #!/usr/bin/env perl | ||||||||||
| 2 | # ---------------------------------------------------------------------------------------------------------- | ||||||||||
| 3 | # © Copyright 2003-2011 by Alex Peeters [alex.peeters@citap.be] | ||||||||||
| 4 | # ---------------------------------------------------------------------------------------------------------- | ||||||||||
| 5 | # 2011/mm/dd, v3.002.003, check_template-WebTransact-XML.pl | ||||||||||
| 6 | # ---------------------------------------------------------------------------------------------------------- | ||||||||||
| 7 | |||||||||||
| 8 | 3 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 3 | ▶ | use warnings; # Must be used in test mode only. This reduces a little process speed | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | #use diagnostics; # Must be used in test mode only. This reduces a lot of process speed | ||||||||||
| 11 | |||||||||||
| 12 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||
| 13 | |||||||||||
| 14 | 0 | ▶ | BEGIN { if ( $ENV{ASNMTAP_PERL5LIB} ) { eval 'use lib ( "$ENV{ASNMTAP_PERL5LIB}" )'; } } | ||||||||
|
Subroutine
BEGIN: called CC=2 SCAR=9.2
Branch: 1 branch
| |||||||||||
| 15 | |||||||||||
| 16 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||
| 17 | |||||||||||
| 18 | 3 | ▶ | use ASNMTAP::Asnmtap::Plugins v3.002.003; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 3 | ▶ | use ASNMTAP::Asnmtap::Plugins qw(:PLUGINS); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | |||||||||||
| 21 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||
| 22 | |||||||||||
| 23 | 3 | my $objectPlugins = ASNMTAP::Asnmtap::Plugins->new ( | |||||||||
| 24 | _programName => 'check_template-WebTransact-XML.pl', | ||||||||||
| 25 | _programDescription => "WebTransact XML plugin template for testing the '$APPLICATION'", | ||||||||||
| 26 | _programVersion => '3.002.003', | ||||||||||
| 27 | _programGetOptions => ['environment|e:s', 'proxy:s', 'timeout|t:i', 'trendline|T:i'], | ||||||||||
| 28 | _timeout => 30, | ||||||||||
| 29 | _debug => 0); | ||||||||||
| 30 | |||||||||||
| 31 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||
| 32 | |||||||||||
| 33 | 3 | ▶ | use ASNMTAP::Asnmtap::Plugins::WebTransact; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 34 | 3 | ▶ | use ASNMTAP::Asnmtap::Plugins::XML qw(&extract_XML); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 35 | |||||||||||
| 36 | 1 | my @URLS = (); | |||||||||
| 37 | 1 | my $objectWebTransact = ASNMTAP::Asnmtap::Plugins::WebTransact->new ( \$objectPlugins, \@URLS ); | |||||||||
| 38 | |||||||||||
| 39 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||
| 40 | # Start plugin - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||
| 41 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||
| 42 | |||||||||||
| 43 | 3 | ▶ | use constant HEADER1 => '<?xml version="1.0" encoding="UTF-8" ?>'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 44 | 3 | ▶ | use constant FOOTER1 => '</testsuites>'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 45 | |||||||||||
| 46 | 3 | ▶ | use constant HEADER2 => '<?xml version="1.0" encoding="UTF-8"?>'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 47 | 3 | ▶ | use constant FOOTER2 => '</MonitoringXML>'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 48 | |||||||||||
| 49 | 1 | my ($returnCode, $result, $xml); | |||||||||
| 50 | |||||||||||
| 51 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||
| 52 | |||||||||||
| 53 | 1 | @URLS = ( | |||||||||
| 54 | { Method => 'GET', Url => 'http://asnmtap.citap.com/ServletTestRunner.xml', Qs_var => [], Qs_fixed => [], Exp => "\Q<testsuites>\E", Exp_Fault => ">>>NIHIL<<<", Msg => "ServletTestRunner.xml", Msg_Fault => "ServletTestRunner.xml" }, | ||||||||||
| 55 | ); | ||||||||||
| 56 | |||||||||||
| 57 | 1 | $returnCode = $objectWebTransact->check ( { } ); | |||||||||
| 58 | 1 | undef $objectWebTransact; | |||||||||
| 59 | 1 | ▶ | $objectPlugins->exit (7) if ( $returnCode ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | |||||||||||
| 61 | 0 | $result = $objectPlugins->pluginValue ('result'); | |||||||||
| 62 | 0 | ($returnCode, $xml) = extract_XML ( asnmtapInherited => \$objectPlugins, resultXML => $result, headerXML => HEADER1, footerXML => FOOTER1 ); | |||||||||
| 63 | 0 | ▶ | $objectPlugins->exit (7) if ( $returnCode ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 64 | |||||||||||
| 65 | 0 | ▶ | if ( $xml->{testsuite}->{failures} + $xml->{testsuite}->{errors} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 66 | 0 | $objectPlugins->pluginValues ( { stateValue => $ERRORS{CRITICAL}, error => 'failures or errors' }, $TYPE{APPEND} ); | |||||||||
| 67 | 0 | $objectPlugins->exit (7); | |||||||||
| 68 | } | ||||||||||
| 69 | |||||||||||
| 70 | 0 | ($returnCode, $xml) = extract_XML ( asnmtapInherited => \$objectPlugins, filenameXML => 'xml/Monitoring-1.0.xml', headerXML => HEADER2, footerXML => FOOTER2, validateDTD => 1, filenameDTD => 'dtd/Monitoring-1.0.dtd' ); | |||||||||
| 71 | 0 | ▶ | $objectPlugins->exit (7) if ( $returnCode ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 72 | |||||||||||
| 73 | 0 | ▶ | if ( $xml->{Monitoring}->{Schema}->{Value} ne "1.0" ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 74 | 0 | $objectPlugins->pluginValues ( { stateValue => $ERRORS{UNKNOWN}, error => 'wrong schema' }, $TYPE{APPEND} ); | |||||||||
| 75 | 0 | $objectPlugins->exit (7); | |||||||||
| 76 | } | ||||||||||
| 77 | |||||||||||
| 78 | 0 | $objectPlugins->pluginValues ( { stateValue => $ERRORS{OK}, alert => 'XML validated' }, $TYPE{APPEND} ); | |||||||||
| 79 | |||||||||||
| 80 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||
| 81 | # End plugin - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||
| 82 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||
| 83 | |||||||||||
| 84 | 0 | $objectPlugins->exit (7); | |||||||||
| 85 | |||||||||||
| 86 | # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||||||||||
| 87 | |||||||||||
| 88 | __END__ | ||||||||||