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);
|
|
|
|
|
2015-06-14 00:25:49 +02:00
|
|
|
use Exporter qw(import);
|
2015-04-08 00:36:59 +02:00
|
|
|
use File::Basename qw(dirname);
|
|
|
|
use File::stat;
|
2015-06-14 00:25:49 +02:00
|
|
|
use Time::HiRes qw(gettimeofday);
|
2015-04-08 00:36:59 +02:00
|
|
|
|
|
|
|
use lib dirname($0) . '/../lib';
|
2015-08-29 20:20:46 +02:00
|
|
|
use BackRest::Common::Log;
|
2015-06-14 00:25:49 +02:00
|
|
|
|
2015-04-08 00:36:59 +02:00
|
|
|
use BackRestTest::BackupTest;
|
2015-06-14 00:25:49 +02:00
|
|
|
use BackRestTest::CommonTest;
|
2015-04-08 00:36:59 +02:00
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Exports
|
|
|
|
####################################################################################################################################
|
|
|
|
our @EXPORT = qw(BackRestTestCompare_Test);
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# BackRestTestCompare_BuildDb
|
|
|
|
####################################################################################################################################
|
|
|
|
sub BackRestTestCompare_BuildDb
|
|
|
|
{
|
|
|
|
my $iTableTotal = shift;
|
|
|
|
my $iTableSize = shift;
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
&log(INFO, "build database: " . fileSizeFormat($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-10-08 17:43:56 +02:00
|
|
|
executeTest("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-10-08 17:43:56 +02:00
|
|
|
executeTest('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-10-08 17:43:56 +02:00
|
|
|
executeTest($strCommand, $bRemote);
|
|
|
|
executeTest('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;
|