Make init_agent() stop on 403 (too many agents).

This commit is contained in:
Daniel Nichter
2013-09-23 11:55:27 -07:00
parent 53d494ad0b
commit f6f121ca82
2 changed files with 51 additions and 1 deletions

View File

@@ -274,6 +274,50 @@ is_deeply(
"PUT then GET Agent"
) or diag(Dumper($ua->{requests}));
# #############################################################################
# Status 403 (too many agents) should abort further attempts.
# #############################################################################
$ua->{responses}->{post} = [
{ # 1, the fake error
code => 403,
},
];
@ok = qw(1 1 0);
@wait = ();
@log = ();
$ua->{requests} = [];
$output = output(
sub {
($got_agent) = pt_agent::init_agent(
agent => $post_agent,
action => 'post',
link => "/agents",
client => $client,
interval => $interval,
tries => 3,
oktorun => $oktorun,
);
},
stderr => 1,
);
is(
scalar @wait,
0,
"Too many agents (403): no wait"
);
is_deeply(
$ua->{requests},
[
'POST /agents',
],
"Too many agents (403): no further requests"
) or diag(Dumper($ua->{requests}));
# #############################################################################
# Done.
# #############################################################################