mirror of
https://github.com/percona/percona-toolkit.git
synced 2026-04-26 01:02:25 +08:00
Fix write_services.t samples. Make send_data.t deterministic.
This commit is contained in:
+8
-1
@@ -5160,6 +5160,9 @@ sub send_data {
|
||||
my $lib_dir = $args{lib_dir};
|
||||
my $spool_dir = $args{spool_dir};
|
||||
|
||||
# Optional args
|
||||
my $json = $args{json}; # for testing
|
||||
|
||||
my $service_dir = $spool_dir . '/' . $service;
|
||||
my $service_file = $lib_dir . '/services/' . $service;
|
||||
|
||||
@@ -5189,6 +5192,7 @@ sub send_data {
|
||||
agent => $agent,
|
||||
file => $file,
|
||||
link => $service->links->{send_data},
|
||||
json => $json,
|
||||
);
|
||||
};
|
||||
if ( $EVAL_ERROR ) {
|
||||
@@ -5234,13 +5238,16 @@ sub send_file {
|
||||
my $file = $args{file};
|
||||
my $link = $args{link};
|
||||
|
||||
# Optional args
|
||||
my $json = $args{json}; # for testing
|
||||
|
||||
my $file_size = -s $file;
|
||||
_info("Sending $file ($file_size bytes) to $link");
|
||||
|
||||
# Create a multi-part resource: first the Agent, so Percona knows
|
||||
# from whom this data is coming, then the contents of the file as-is.
|
||||
# We don't know or care about the file's contents, but Percona will.
|
||||
my $agent_json = as_json($agent);
|
||||
my $agent_json = as_json($agent, json => $json);
|
||||
my $data = slurp($file);
|
||||
my $boundary = '--Ym91bmRhcnk='; # "boundary" in base64
|
||||
my $resource = <<CONTENT;
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
{"id":"123","hostname":"prod1"}
|
||||
{
|
||||
"hostname" : "prod1",
|
||||
"id" : "123"
|
||||
}
|
||||
|
||||
--Ym91bmRhcnk=
|
||||
[
|
||||
{
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
"runs" : [
|
||||
{
|
||||
"number" : "0",
|
||||
"options" : "--report-format profile /Users/daniel/p/pt-agent/t/lib/samples/slowlogs/slow008.txt",
|
||||
"options" : "--report-format profile slow008.txt",
|
||||
"output" : "spool",
|
||||
"program" : "/Users/daniel/p/pt-agent/bin/pt-query-digest"
|
||||
"program" : "pt-query-digest"
|
||||
}
|
||||
],
|
||||
"spool_schedule" : "2 * * * *"
|
||||
|
||||
@@ -29,7 +29,7 @@ my $sample = "t/pt-agent/samples";
|
||||
# These aren't the real tests yet: to run_agent(), first we need
|
||||
# a client and Agent, so create mock ones.
|
||||
|
||||
my $json = JSON->new;
|
||||
my $json = JSON->new->canonical([1])->pretty;
|
||||
$json->allow_blessed([]);
|
||||
$json->convert_blessed([]);
|
||||
|
||||
@@ -78,7 +78,7 @@ is_deeply(
|
||||
) or die;
|
||||
|
||||
# #############################################################################
|
||||
# Test send_data()
|
||||
# Test send_data
|
||||
# #############################################################################
|
||||
|
||||
my $tmpdir = tempdir("/tmp/pt-agent.$PID.XXXXXX", CLEANUP => 1);
|
||||
@@ -104,6 +104,7 @@ my $output = output(
|
||||
service => 'query-monitor',
|
||||
lib_dir => $tmpdir,
|
||||
spool_dir => $tmpdir,
|
||||
json => $json, # optional, for testing
|
||||
),
|
||||
},
|
||||
stderr => 1,
|
||||
|
||||
@@ -65,8 +65,8 @@ sub test_write_services {
|
||||
|
||||
my $run0 = Percona::WebAPI::Resource::Run->new(
|
||||
number => '0',
|
||||
program => "$trunk/bin/pt-query-digest",
|
||||
options => "--report-format profile $trunk/t/lib/samples/slowlogs/slow008.txt",
|
||||
program => "pt-query-digest",
|
||||
options => "--report-format profile slow008.txt",
|
||||
output => 'spool',
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user