Show
Ignore:
Timestamp:
12/08/10 05:32:28 (4 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1291786348 +0000
git-parent:

[8c720f9a4bd5979520e9c7ec00d9bea8d305391b]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1291786348 +0000
Message:

update the tests to test the new extended_id stuff. refs #331

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • test/t/108_noit_strat.t

    r6e2f9ec re754bda  
    1 use Test::More tests => 19
     1use Test::More tests => 26
    22use WWW::Curl::Easy; 
     3use JSON; 
    34use XML::LibXML; 
    45use XML::LibXML::XPathContext; 
    56use testconfig; 
    67use apiclient; 
     8use stomp; 
    79use Data::Dumper; 
    810 
    911use strict; 
     12my $uuid_re = qr/^[0-9a-fA-F]{4}(?:[0-9a-fA-F]{4}-){4}[0-9a-fA-F]{12}$/; 
    1013my $uuid = '9c2163aa-f4bd-11df-851b-979bd290a553'; 
    1114my $xp = XML::LibXML->new(); 
    1215my $xpc = XML::LibXML::XPathContext->new(); 
    1316 
     17my $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 
    1432ok(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'); 
     33ok(start_stratcon("108", { noits => [ { address => "127.0.0.1", port => "$NOIT_API_PORT" } ], iep => { queries => $iep_queries } }), 'starting stratcon'); 
    1634sleep(1); 
    1735my $c = apiclient->new('localhost', $NOIT_API_PORT); 
     
    88106is($retcode, 28, 'needed to timeout stream'); 
    89107 
    90 my @rdata = grep { /^\s*<script id=.*window\.parent\.plot_iframe_data\(\{.*'value':"/ } split(/\R/,$response_body); 
     108my @rdata; 
     109my $json_text; 
     110my $test_S = 0; 
     111eval { 
     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}; 
     125if(!$test_S) { 
     126  ok(0, "status line uuid"); 
     127  ok(0, "status line module"); 
     128
     129is($@, '', 'json parse errors: ' . ($@ ? $json_text : 'none')); 
    91130 
    92131# There are at least 4 metrics for the self check. 
     
    95134cmp_ok(scalar(@rdata), '>=', 7*4, 'streamed data'); 
    96135 
     136my $stomp; 
     137my $payload; 
     138my $json; 
     139 
     140$stomp = stomp->new(); 
     141$stomp->subscribe('/queue/noit.firehose'); 
     142$payload = $stomp->get({timeout => 6}); 
     143undef $stomp; 
     144ok($payload, 'firehose traffic'); 
     145 
     146$stomp = stomp->new(); 
     147$stomp->subscribe('/topic/noit.alerts.numeric'); 
     148$payload = $stomp->get({timeout => 6}); 
     149eval { $json = from_json($payload); }; 
     150is($@, '', 'json numeric payload'); 
     151undef $stomp; 
     152like($json->{r}->{uuid} || '', $uuid_re, 'numeric match has uuid'); 
     153is($json->{r}->{check_module} || '', 'selfcheck', 'modules is set'); 
     154 
    971551; 
  • test/t/testconfig.pm

    r6e2f9ec re754bda  
    138138    </components> 
    139139    <feeds> 
     140      <config><extended_id>on</extended_id></config> 
    140141      <outlet name="feed"/> 
    141142      <log name="check"> 
     
    358359    print $o qq{    </broker>\n}; 
    359360  } 
     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}; 
    360374  print $o qq{</iep>\n}; 
    361375}