Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
test Hypnotoad log
  • Loading branch information
kraih committed Aug 31, 2013
1 parent da2b5ff commit a6c016c
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions t/mojo/hypnotoad.t
Expand Up @@ -16,16 +16,19 @@ use FindBin;
use IO::Socket::INET;
use Mojo::IOLoop;
use Mojo::UserAgent;
use Mojo::Util 'spurt';
use Mojo::Util qw(slurp spurt);

# Prepare script
my $dir = tempdir CLEANUP => 1;
my $script = catdir $dir, 'myapp.pl';
my $log = catdir $dir, 'mojo.log';
my $port1 = Mojo::IOLoop->generate_port;
my $port2 = Mojo::IOLoop->generate_port;
spurt <<EOF, $script;
use Mojolicious::Lite;
app->log->path('$log');
plugin Config => {
default => {
hypnotoad => {
Expand All @@ -36,7 +39,7 @@ plugin Config => {
}
};
app->log->level('fatal');
app->log->level('debug');
get '/hello' => {text => 'Hello Hypnotoad!'};
Expand Down Expand Up @@ -93,6 +96,8 @@ is $tx->res->body, 'Hello Hypnotoad!', 'right content';
spurt <<EOF, $script;
use Mojolicious::Lite;
app->log->path('$log');
plugin Config => {
default => {
hypnotoad => {
Expand All @@ -103,7 +108,7 @@ plugin Config => {
}
};
app->log->level('fatal');
app->log->level('debug');
get '/hello' => {text => 'Hello World!'};
Expand Down Expand Up @@ -178,6 +183,12 @@ sleep 1
PeerPort => $port2
);

# Check log
$log = slurp $log;
like $log, qr/Worker \d+ started\./, 'right message';
like $log, qr/Starting zero downtime software upgrade\./, 'right message';
like $log, qr/Upgrade successful, stopping $old\./, 'right message';

sub _pid {
return undef unless open my $file, '<', catdir($dir, 'hypnotoad.pid');
my $pid = <$file>;
Expand Down

0 comments on commit a6c016c

Please sign in to comment.