Changeset 6e2f9ec7979b0e29ef467e5088c1f156b2abdf84

Show
Ignore:
Timestamp:
11/20/10 16:45:59 (4 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1290271559 +0000
git-parent:

[db3c52f2b600b58a7cc93533c8892a27a7ac844b]

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

test the realtime streaming stuff

Files:

Legend:

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

    rdb3c52f r6e2f9ec  
    1 use Test::More tests => 17; 
     1use Test::More tests => 19; 
     2use WWW::Curl::Easy; 
    23use XML::LibXML; 
    34use XML::LibXML::XPathContext; 
     
    3738my $conn = pg('reconnoiter','reconnoiter'); 
    3839ok($conn, 'data store connection'); 
    39 my $st=$conn->prepare("select sid from stratcon.map_uuid_to_sid where id = ?"); 
    40 $st->execute($uuid); 
    41 my ($sid) = $st->fetchrow(); 
    42 $st->finish(); 
     40my $sid = undef; 
     41if($conn) { 
     42  my $st=$conn->prepare("select sid from stratcon.map_uuid_to_sid where id = ?"); 
     43  $st->execute($uuid); 
     44  ($sid) = $st->fetchrow(); 
     45  $st->finish(); 
     46
    4347ok($sid, 'uuid mapped to sid'); 
     48 
    4449sub do_counts { 
     50  return (0,0) unless $conn; 
    4551  my $artext = $conn->prepare("select count(*) from noit.metric_text_archive ". 
    4652                              " where sid = ?"); 
     
    5864ok(1, 'going to sleep 7 seconds for data to stream'); 
    5965sleep(7); 
    60  
    6166my $sc = apiclient->new('localhost', $STRATCON_API_PORT); 
    6267@r = $sc->get('/noits/show'); 
     
    7277cmp_ok($st_n, '<', $f_n, 'numeric metrics loaded'); 
    7378 
     79### Test real-time streaming. 
     80 
     81my $curl = WWW::Curl::Easy->new; 
     82$curl->setopt(CURLOPT_URL, "http://localhost:$STRATCON_WEB_PORT/data/$uuid\@500"); 
     83$curl->setopt(CURLOPT_TIMEOUT, 5); 
     84my $response_body; 
     85$curl->setopt(CURLOPT_WRITEDATA,\$response_body); 
     86my $retcode = 0; 
     87$retcode = $curl->perform; 
     88is($retcode, 28, 'needed to timeout stream'); 
     89 
     90my @rdata = grep { /^\s*<script id=.*window\.parent\.plot_iframe_data\(\{.*'value':"/ } split(/\R/,$response_body); 
     91 
     92# There are at least 4 metrics for the self check. 
     93# in 5 seconds - (1 second lag) - jittered start at 500ms period, 
     94# it should run at least 7 times. 
     95cmp_ok(scalar(@rdata), '>=', 7*4, 'streamed data'); 
     96 
    74971; 
  • test/t/testconfig.pm

    rca96cb1 r6e2f9ec  
    1616             $NOIT_API_PORT $NOIT_CLI_PORT 
    1717             $STRATCON_API_PORT $STRATCON_CLI_PORT 
     18             $STRATCON_WEB_PORT 
    1819             pg make_noit_config start_noit stop_noit 
    1920             make_stratcon_config start_stratcon stop_stratcon