2015-04-08 00:36:59 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
####################################################################################################################################
|
|
|
|
# CompareTest.pl - Performance comparison tests between rsync and backrest
|
|
|
|
####################################################################################################################################
|
|
|
|
package BackRestTest::CompareTest;
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Perl includes
|
|
|
|
####################################################################################################################################
|
|
|
|
use strict;
|
|
|
|
use warnings FATAL => qw(all);
|
|
|
|
use Carp qw(confess);
|
|
|
|
|
|
|
|
use File::Basename qw(dirname);
|
|
|
|
use Time::HiRes qw(gettimeofday);
|
|
|
|
use File::stat;
|
|
|
|
use Exporter qw(import);
|
|
|
|
|
|
|
|
use lib dirname($0) . '/../lib';
|
|
|
|
use BackRest::Utility;
|
|
|
|
use BackRestTest::CommonTest;
|
|
|
|
use BackRestTest::BackupTest;
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Exports
|
|
|
|
####################################################################################################################################
|
|
|
|
our @EXPORT = qw(BackRestTestCompare_Test);
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# BackRestTestCompare_BuildDb
|
|
|
|
####################################################################################################################################
|
|
|
|
sub BackRestTestCompare_BuildDb
|
|
|
|
{
|
|
|
|
my $iTableTotal = shift;
|
|
|
|
my $iTableSize = shift;
|
|
|
|
|
2015-04-11 18:31:39 +02:00
|
|
|
&log(INFO, "build database: " . file_size_format($iTableTotal * $iTableSize * 1024 * 1024));
|
2015-04-08 00:36:59 +02:00
|
|
|
|
|
|
|
for (my $iTableIdx = 0; $iTableIdx < $iTableTotal; $iTableIdx++)
|
|
|
|
{
|
2015-04-11 18:31:39 +02:00
|
|
|
my $strSourceFile = BackRestTestCommon_DataPathGet() . "/test.table.bin";
|
|
|
|
my $strTableFile = BackRestTestCommon_DbCommonPathGet() . "/test-${iTableIdx}";
|
2015-04-08 00:36:59 +02:00
|
|
|
|
2015-04-11 18:31:39 +02:00
|
|
|
for (my $iTableSizeIdx = 0; $iTableSizeIdx < $iTableSize; $iTableSizeIdx++)
|
2015-04-08 00:36:59 +02:00
|
|
|
{
|
2015-04-11 18:31:39 +02:00
|
|
|
BackRestTestCommon_Execute("cat ${strSourceFile} >> ${strTableFile}");
|
2015-04-08 00:36:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# BackRestTestCompare_Test
|
|
|
|
####################################################################################################################################
|
|
|
|
sub BackRestTestCompare_Test
|
|
|
|
{
|
|
|
|
my $strTest = shift;
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
# Test rsync
|
|
|
|
#-------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
if ($strTest eq 'all' || $strTest eq 'rsync')
|
|
|
|
{
|
|
|
|
my $iRun = 0;
|
|
|
|
my $bRemote = false;
|
|
|
|
|
|
|
|
&log(INFO, "Test rsync\n");
|
|
|
|
|
|
|
|
# Increment the run, log, and decide whether this unit test should be run
|
|
|
|
if (!BackRestTestCommon_Run(++$iRun,
|
|
|
|
"rmt ${bRemote}")) {next}
|
|
|
|
|
|
|
|
# Create the cluster and paths
|
2015-04-11 18:31:39 +02:00
|
|
|
BackRestTestBackup_Create($bRemote, false);
|
|
|
|
BackRestTestCommon_PathCreate(BackRestTestCommon_DbCommonPathGet() . '/pg_tblspc');
|
|
|
|
|
2015-04-08 00:36:59 +02:00
|
|
|
BackRestTestCompare_BuildDb(48, 10);
|
2015-04-11 18:31:39 +02:00
|
|
|
BackRestTestCommon_Execute('sync');
|
2015-04-08 00:36:59 +02:00
|
|
|
|
|
|
|
for (my $bRemote = true; $bRemote <= true; $bRemote++)
|
|
|
|
{
|
|
|
|
for (my $bRsync = true; $bRsync >= false; $bRsync--)
|
|
|
|
{
|
|
|
|
my $strCommand;
|
|
|
|
BackRestTestCommon_CreateRepo($bRemote);
|
|
|
|
|
2015-04-11 18:31:39 +02:00
|
|
|
&log(INFO, ($bRsync ? 'rsync' : 'backrest') . " test");
|
|
|
|
|
2015-04-08 00:36:59 +02:00
|
|
|
if ($bRsync)
|
|
|
|
{
|
2015-04-11 18:31:39 +02:00
|
|
|
$strCommand = 'rsync --compress-level=6 -zvlhprtogHS --delete ' .
|
|
|
|
($bRemote ? BackRestTestCommon_UserGet . '@' . BackRestTestCommon_HostGet . ':' : '') .
|
|
|
|
BackRestTestCommon_DbCommonPathGet() . '/ ' . BackRestTestCommon_RepoPathGet() . ';' .
|
|
|
|
'gzip -r "' . BackRestTestCommon_RepoPathGet() . '"';
|
2015-04-08 00:36:59 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$strCommand = BackRestTestCommon_CommandMainGet() .
|
|
|
|
' --stanza=main' .
|
|
|
|
($bRemote ? ' "--db-host=' . BackRestTestCommon_HostGet . '"' .
|
|
|
|
' "--db-user=' . BackRestTestCommon_UserGet . '"' : '') .
|
2015-04-11 18:31:39 +02:00
|
|
|
# ' --log-level-file=debug' .
|
2015-04-08 00:36:59 +02:00
|
|
|
' --no-start-stop' .
|
|
|
|
# ' --no-compress' .
|
2015-04-11 18:31:39 +02:00
|
|
|
' --thread-max=4' .
|
2015-04-08 00:36:59 +02:00
|
|
|
' "--db-path=' . BackRestTestCommon_DbCommonPathGet() . '"' .
|
|
|
|
' "--repo-path=' . BackRestTestCommon_RepoPathGet() . '"' .
|
|
|
|
' --type=full backup';
|
|
|
|
}
|
|
|
|
|
|
|
|
my $fTimeBegin = gettimeofday();
|
2015-04-11 18:31:39 +02:00
|
|
|
BackRestTestCommon_Execute($strCommand, $bRemote);
|
|
|
|
BackRestTestCommon_Execute('sync');
|
2015-04-08 00:36:59 +02:00
|
|
|
my $fTimeEnd = gettimeofday();
|
|
|
|
|
2015-04-11 18:31:39 +02:00
|
|
|
&log(INFO, " time = " . (int(($fTimeEnd - $fTimeBegin) * 100) / 100));
|
2015-04-08 00:36:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (BackRestTestCommon_Cleanup())
|
|
|
|
{
|
|
|
|
&log(INFO, 'cleanup');
|
2015-04-11 18:31:39 +02:00
|
|
|
BackRestTestBackup_Drop();
|
2015-04-08 00:36:59 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|