Changeset 6e2f9ec7979b0e29ef467e5088c1f156b2abdf84
- Timestamp:
- 11/20/10 16:45:59
(3 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
| rdb3c52f |
r6e2f9ec |
|
| 1 | | use Test::More tests => 17; |
|---|
| | 1 | use Test::More tests => 19; |
|---|
| | 2 | use WWW::Curl::Easy; |
|---|
| 2 | 3 | use XML::LibXML; |
|---|
| 3 | 4 | use XML::LibXML::XPathContext; |
|---|
| … | … | |
| 37 | 38 | my $conn = pg('reconnoiter','reconnoiter'); |
|---|
| 38 | 39 | ok($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(); |
|---|
| | 40 | my $sid = undef; |
|---|
| | 41 | if($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 | } |
|---|
| 43 | 47 | ok($sid, 'uuid mapped to sid'); |
|---|
| | 48 | |
|---|
| 44 | 49 | sub do_counts { |
|---|
| | 50 | return (0,0) unless $conn; |
|---|
| 45 | 51 | my $artext = $conn->prepare("select count(*) from noit.metric_text_archive ". |
|---|
| 46 | 52 | " where sid = ?"); |
|---|
| … | … | |
| 58 | 64 | ok(1, 'going to sleep 7 seconds for data to stream'); |
|---|
| 59 | 65 | sleep(7); |
|---|
| 60 | | |
|---|
| 61 | 66 | my $sc = apiclient->new('localhost', $STRATCON_API_PORT); |
|---|
| 62 | 67 | @r = $sc->get('/noits/show'); |
|---|
| … | … | |
| 72 | 77 | cmp_ok($st_n, '<', $f_n, 'numeric metrics loaded'); |
|---|
| 73 | 78 | |
|---|
| | 79 | ### Test real-time streaming. |
|---|
| | 80 | |
|---|
| | 81 | my $curl = WWW::Curl::Easy->new; |
|---|
| | 82 | $curl->setopt(CURLOPT_URL, "http://localhost:$STRATCON_WEB_PORT/data/$uuid\@500"); |
|---|
| | 83 | $curl->setopt(CURLOPT_TIMEOUT, 5); |
|---|
| | 84 | my $response_body; |
|---|
| | 85 | $curl->setopt(CURLOPT_WRITEDATA,\$response_body); |
|---|
| | 86 | my $retcode = 0; |
|---|
| | 87 | $retcode = $curl->perform; |
|---|
| | 88 | is($retcode, 28, 'needed to timeout stream'); |
|---|
| | 89 | |
|---|
| | 90 | my @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. |
|---|
| | 95 | cmp_ok(scalar(@rdata), '>=', 7*4, 'streamed data'); |
|---|
| | 96 | |
|---|
| 74 | 97 | 1; |
|---|
| rca96cb1 |
r6e2f9ec |
|
| 16 | 16 | $NOIT_API_PORT $NOIT_CLI_PORT |
|---|
| 17 | 17 | $STRATCON_API_PORT $STRATCON_CLI_PORT |
|---|
| | 18 | $STRATCON_WEB_PORT |
|---|
| 18 | 19 | pg make_noit_config start_noit stop_noit |
|---|
| 19 | 20 | make_stratcon_config start_stratcon stop_stratcon |
|---|