mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-29 01:21:37 +00:00
Make init_agent() tries required. Load service earlier in send_data() and run_service(). Fix init_agent.t.
This commit is contained in:
@@ -109,6 +109,7 @@ my $output = output(
|
||||
link => "/agents",
|
||||
client => $client,
|
||||
interval => $interval,
|
||||
tries => 4,
|
||||
);
|
||||
},
|
||||
stderr => 1,
|
||||
@@ -152,7 +153,7 @@ $ua->{responses}->{post} = [
|
||||
$ua->{responses}->{get} = [
|
||||
{
|
||||
headers => { 'X-Percona-Resource-Type' => 'Agent' },
|
||||
content => $return_agent,
|
||||
content => as_hashref($return_agent, with_links =>1 ),
|
||||
},
|
||||
];
|
||||
|
||||
@@ -162,12 +163,13 @@ $ua->{requests} = [];
|
||||
|
||||
$output = output(
|
||||
sub {
|
||||
$got_agent = pt_agent::init_agent(
|
||||
($got_agent) = pt_agent::init_agent(
|
||||
agent => $post_agent,
|
||||
action => 'post',
|
||||
link => "/agents",
|
||||
client => $client,
|
||||
interval => $interval,
|
||||
tries => 5,
|
||||
oktorun => $oktorun,
|
||||
);
|
||||
},
|
||||
@@ -175,10 +177,10 @@ $output = output(
|
||||
);
|
||||
|
||||
is(
|
||||
$got_agent->hostname,
|
||||
($got_agent ? $got_agent->hostname : ''),
|
||||
'host2',
|
||||
'Got and returned Agent after error'
|
||||
) or diag($output, Dumper(as_hashref($got_agent, with_links => 1)));
|
||||
) or diag($output, Dumper($got_agent));
|
||||
|
||||
is(
|
||||
scalar @wait,
|
||||
@@ -196,14 +198,11 @@ is_deeply(
|
||||
"POST POST GET new Agent after error"
|
||||
) or diag(Dumper($ua->{requests}));
|
||||
|
||||
TODO: {
|
||||
local $TODO = "False-positive";
|
||||
like(
|
||||
$output,
|
||||
qr{WARNING Failed to POST /agents},
|
||||
"POST /agents failure logged after error"
|
||||
) or diag(Dumper($ua->{requests}));
|
||||
}
|
||||
like(
|
||||
$log[3],
|
||||
qr{WARNING Failed to POST /agents},
|
||||
"POST /agents failure logged after error"
|
||||
) or diag(Dumper($ua->{requests}), Dumper(\@log));
|
||||
|
||||
# #############################################################################
|
||||
# Init an existing agent, i.e. update it.
|
||||
@@ -233,7 +232,7 @@ $ua->{responses}->{get} = [
|
||||
{
|
||||
code => 200,
|
||||
headers => { 'X-Percona-Resource-Type' => 'Agent' },
|
||||
content => $return_agent,
|
||||
content => as_hashref($return_agent, with_links =>1 ),
|
||||
}
|
||||
];
|
||||
|
||||
@@ -242,12 +241,13 @@ $ua->{requests} = [];
|
||||
|
||||
$output = output(
|
||||
sub {
|
||||
$got_agent = pt_agent::init_agent(
|
||||
($got_agent) = pt_agent::init_agent(
|
||||
agent => $put_agent,
|
||||
action => 'put',
|
||||
link => "/agents/123",
|
||||
client => $client,
|
||||
interval => $interval,
|
||||
tries => 4,
|
||||
);
|
||||
},
|
||||
stderr => 1,
|
||||
|
Reference in New Issue
Block a user