Changeset e754bdaf2061e69f9c3e13dcdf5cc3d95ea2c243 for test
- Timestamp:
- 12/08/10 05:32:28 (2 years ago)
- git-parent:
- Files:
-
- test/t/108_noit_strat.t (modified) (3 diffs)
- test/t/stomp.pm (added)
- test/t/testconfig.pm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
test/t/108_noit_strat.t
r6e2f9ec re754bda 1 use Test::More tests => 19;1 use Test::More tests => 26; 2 2 use WWW::Curl::Easy; 3 use JSON; 3 4 use XML::LibXML; 4 5 use XML::LibXML::XPathContext; 5 6 use testconfig; 6 7 use apiclient; 8 use stomp; 7 9 use Data::Dumper; 8 10 9 11 use strict; 12 my $uuid_re = qr/^[0-9a-fA-F]{4}(?:[0-9a-fA-F]{4}-){4}[0-9a-fA-F]{12}$/; 10 13 my $uuid = '9c2163aa-f4bd-11df-851b-979bd290a553'; 11 14 my $xp = XML::LibXML->new(); 12 15 my $xpc = XML::LibXML::XPathContext->new(); 13 16 17 my $iep_queries = [ 18 { id => '52f1f2ec-0275-11e0-a846-b757d1de0f4a', 19 topic => 'numeric', 20 epl => 'select * from NoitMetricNumeric as r' 21 }, 22 { id => '8f04d54c-0275-11e0-b62c-6fdd90cb8bde', 23 topic => 'text', 24 epl => 'select * from NoitMetricText as r' 25 }, 26 { id => '95f4ed2e-0275-11e0-bdc7-27110e43915b', 27 topic => 'status', 28 epl => 'select * from NoitStatus as r' 29 }, 30 ]; 31 14 32 ok(start_noit("108", { logs_debug => { '' => 'false' } }), 'starting noit'); 15 ok(start_stratcon("108", { noits => [ { address => "127.0.0.1", port => "$NOIT_API_PORT" } ] }), 'starting stratcon');33 ok(start_stratcon("108", { noits => [ { address => "127.0.0.1", port => "$NOIT_API_PORT" } ], iep => { queries => $iep_queries } }), 'starting stratcon'); 16 34 sleep(1); 17 35 my $c = apiclient->new('localhost', $NOIT_API_PORT); … … 88 106 is($retcode, 28, 'needed to timeout stream'); 89 107 90 my @rdata = grep { /^\s*<script id=.*window\.parent\.plot_iframe_data\(\{.*'value':"/ } split(/\R/,$response_body); 108 my @rdata; 109 my $json_text; 110 my $test_S = 0; 111 eval { 112 foreach (split(/\R/,$response_body)) { 113 if(/^\s*<script id=.*window\.parent\.plot_iframe_data\((\{.*?\})\)/) { 114 $json_text = $1; 115 my $json = from_json($json_text); 116 push @rdata, $json; 117 if(!$test_S && $json->{type} eq 'S') { 118 like($json->{id}, $uuid_re, 'status line uuid'); 119 is($json->{check_module}, 'selfcheck', 'status line module'); 120 $test_S = 1; 121 } 122 } 123 } 124 }; 125 if(!$test_S) { 126 ok(0, "status line uuid"); 127 ok(0, "status line module"); 128 } 129 is($@, '', 'json parse errors: ' . ($@ ? $json_text : 'none')); 91 130 92 131 # There are at least 4 metrics for the self check. … … 95 134 cmp_ok(scalar(@rdata), '>=', 7*4, 'streamed data'); 96 135 136 my $stomp; 137 my $payload; 138 my $json; 139 140 $stomp = stomp->new(); 141 $stomp->subscribe('/queue/noit.firehose'); 142 $payload = $stomp->get({timeout => 6}); 143 undef $stomp; 144 ok($payload, 'firehose traffic'); 145 146 $stomp = stomp->new(); 147 $stomp->subscribe('/topic/noit.alerts.numeric'); 148 $payload = $stomp->get({timeout => 6}); 149 eval { $json = from_json($payload); }; 150 is($@, '', 'json numeric payload'); 151 undef $stomp; 152 like($json->{r}->{uuid} || '', $uuid_re, 'numeric match has uuid'); 153 is($json->{r}->{check_module} || '', 'selfcheck', 'modules is set'); 154 97 155 1; test/t/testconfig.pm
r6e2f9ec re754bda 138 138 </components> 139 139 <feeds> 140 <config><extended_id>on</extended_id></config> 140 141 <outlet name="feed"/> 141 142 <log name="check"> … … 358 359 print $o qq{ </broker>\n}; 359 360 } 361 print $o qq{ <queries master="iep">\n}; 362 foreach my $s (@{$opts->{iep}->{statements}}) { 363 print $o qq{ <statement id="$s->{id}" provides="$s->{id}">\n}; 364 print $o qq{ <requires>$s->{requires}</requires>\n} if $s->{requires}; 365 print $o qq{ <epl><![CDATA[$s->{epl}]]></epl>\n}; 366 print $o qq{ </statement>\n}; 367 } 368 foreach my $s (@{$opts->{iep}->{queries}}) { 369 print $o qq{ <query id="$s->{id}" topic="$s->{topic}">\n}; 370 print $o qq{ <epl><![CDATA[$s->{epl}]]></epl>\n}; 371 print $o qq{ </query>\n}; 372 } 373 print $o qq{ </queries>\n}; 360 374 print $o qq{</iep>\n}; 361 375 }
