1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-14 10:13:05 +02:00

Altered rsync comparison test to use a specially crafted table that has a 70% compression ratio.

Improved the output of file_size_format().
This commit is contained in:
David Steele 2015-04-11 12:31:39 -04:00
parent 9fe7f87e3a
commit b8ce891603
3 changed files with 24 additions and 37 deletions

View File

@ -329,15 +329,15 @@ sub file_size_format
if ($lFileSize < (1024 * 1024)) if ($lFileSize < (1024 * 1024))
{ {
return int($lFileSize / 1024) . 'KB'; return (int($lFileSize / 102.4) / 10) . 'KB';
} }
if ($lFileSize < (1024 * 1024 * 1024)) if ($lFileSize < (1024 * 1024 * 1024))
{ {
return int($lFileSize / 1024 / 1024) . 'MB'; return (int($lFileSize / 1024 / 102.4) / 10) . 'MB';
} }
return int($lFileSize / 1024 / 1024 / 1024) . 'GB'; return (int($lFileSize / 1024 / 1024 / 102.4) / 10) . 'GB';
} }
#################################################################################################################################### ####################################################################################################################################

BIN
test/data/test.table.bin Normal file

Binary file not shown.

View File

@ -34,34 +34,17 @@ sub BackRestTestCompare_BuildDb
my $iTableTotal = shift; my $iTableTotal = shift;
my $iTableSize = shift; my $iTableSize = shift;
my $iDbOid = BackRestTestBackup_PgSelectOne("select oid from pg_database where datname = 'postgres'"); &log(INFO, "build database: " . file_size_format($iTableTotal * $iTableSize * 1024 * 1024));
for (my $iTableIdx = 0; $iTableIdx < $iTableTotal; $iTableIdx++) for (my $iTableIdx = 0; $iTableIdx < $iTableTotal; $iTableIdx++)
{ {
my $strTableName = "test_${iTableIdx}"; my $strSourceFile = BackRestTestCommon_DataPathGet() . "/test.table.bin";
my $strTableFile = BackRestTestCommon_DbCommonPathGet() . "/test-${iTableIdx}";
BackRestTestBackup_PgExecute("create table ${strTableName} (id int)"); for (my $iTableSizeIdx = 0; $iTableSizeIdx < $iTableSize; $iTableSizeIdx++)
my $iTableOid = BackRestTestBackup_PgSelectOne("select oid from pg_class where relname = '${strTableName}'");
my $strTableFile = BackRestTestCommon_DbCommonPathGet() . "/base/${iDbOid}/${iTableOid}";
my $lSize;
do
{ {
BackRestTestBackup_PgExecute("do \$\$ declare iIndex int; begin for iIndex in 1..289000 loop " . BackRestTestCommon_Execute("cat ${strSourceFile} >> ${strTableFile}");
"insert into ${strTableName} values (1); end loop; end \$\$;");
BackRestTestBackup_PgExecute("checkpoint");
my $oStat = stat($strTableFile);
# Evaluate error
if (!defined($oStat))
{
confess "cannot stat ${strTableFile}";
}
$lSize = $oStat->size;
} }
while ($lSize < $iTableSize * 1024 * 1024);
} }
} }
@ -87,9 +70,11 @@ sub BackRestTestCompare_Test
"rmt ${bRemote}")) {next} "rmt ${bRemote}")) {next}
# Create the cluster and paths # Create the cluster and paths
BackRestTestBackup_Create($bRemote, undef, false); BackRestTestBackup_Create($bRemote, false);
BackRestTestCommon_PathCreate(BackRestTestCommon_DbCommonPathGet() . '/pg_tblspc');
BackRestTestCompare_BuildDb(48, 10); BackRestTestCompare_BuildDb(48, 10);
BackRestTestBackup_ClusterStop(); BackRestTestCommon_Execute('sync');
for (my $bRemote = true; $bRemote <= true; $bRemote++) for (my $bRemote = true; $bRemote <= true; $bRemote++)
{ {
@ -98,41 +83,43 @@ sub BackRestTestCompare_Test
my $strCommand; my $strCommand;
BackRestTestCommon_CreateRepo($bRemote); BackRestTestCommon_CreateRepo($bRemote);
&log(INFO, ($bRsync ? 'rsync' : 'backrest') . " test");
if ($bRsync) if ($bRsync)
{ {
$strCommand = 'rsync -zvlhprtogHS --delete ' . BackRestTestCommon_DbCommonPathGet() . '/ ' . $strCommand = 'rsync --compress-level=6 -zvlhprtogHS --delete ' .
($bRemote ? BackRestTestCommon_UserBackRestGet . '@' . BackRestTestCommon_HostGet . ':' : '') . ($bRemote ? BackRestTestCommon_UserGet . '@' . BackRestTestCommon_HostGet . ':' : '') .
BackRestTestCommon_RepoPathGet(); BackRestTestCommon_DbCommonPathGet() . '/ ' . BackRestTestCommon_RepoPathGet() . ';' .
'gzip -r "' . BackRestTestCommon_RepoPathGet() . '"';
} }
else else
{ {
$strCommand = BackRestTestCommon_CommandMainGet() . $strCommand = BackRestTestCommon_CommandMainGet() .
' --stanza=main' . ' --stanza=main' .
# ' "--cmd-psql=' . BackRestTestCommon_CommandPsqlGet() . '"' .
# ' "--cmd-psql-option= -p ' . BackRestTestCommon_DbPortGet . '"' .
($bRemote ? ' "--db-host=' . BackRestTestCommon_HostGet . '"' . ($bRemote ? ' "--db-host=' . BackRestTestCommon_HostGet . '"' .
' "--db-user=' . BackRestTestCommon_UserGet . '"' : '') . ' "--db-user=' . BackRestTestCommon_UserGet . '"' : '') .
' --log-level-file=debug' . # ' --log-level-file=debug' .
' --no-start-stop' . ' --no-start-stop' .
# ' --no-compress' . # ' --no-compress' .
' --thread-max=4' . ' --thread-max=4' .
' "--db-path=' . BackRestTestCommon_DbCommonPathGet() . '"' . ' "--db-path=' . BackRestTestCommon_DbCommonPathGet() . '"' .
' "--repo-path=' . BackRestTestCommon_RepoPathGet() . '"' . ' "--repo-path=' . BackRestTestCommon_RepoPathGet() . '"' .
' --type=full backup'; ' --type=full backup';
} }
my $fTimeBegin = gettimeofday(); my $fTimeBegin = gettimeofday();
BackRestTestCommon_Execute($strCommand, !$bRsync && $bRemote); BackRestTestCommon_Execute($strCommand, $bRemote);
BackRestTestCommon_Execute('sync');
my $fTimeEnd = gettimeofday(); my $fTimeEnd = gettimeofday();
&log(INFO, ($bRsync ? 'rsync' : 'backrest') . " time = " . (int(($fTimeEnd - $fTimeBegin) * 100) / 100)); &log(INFO, " time = " . (int(($fTimeEnd - $fTimeBegin) * 100) / 100));
} }
} }
if (BackRestTestCommon_Cleanup()) if (BackRestTestCommon_Cleanup())
{ {
&log(INFO, 'cleanup'); &log(INFO, 'cleanup');
BackRestTestBackup_Drop(true); BackRestTestBackup_Drop();
} }
} }
} }