1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-06-14 23:44:58 +02:00

Add Perl interface to C storage layer.

Maintaining the storage layer/drivers in two languages is burdensome.  Since the integration tests require the Perl storage layer/drivers we'll need them even after the core code is migrated to C.  Create an interface layer so the Perl code can be removed and new storage drivers/features introduced without adding Perl equivalents.

The goal is to move the integration tests to C so this interface will eventually be removed.  That being the case, the interface was designed for maximum compatibility to ease the transition.  The result looks a bit hacky but we'll improve it as needed until it can be retired.
This commit is contained in:
David Steele
2019-06-26 08:24:58 -04:00
parent bd6c0941e9
commit 4815752ccc
93 changed files with 4412 additions and 12102 deletions

View File

@ -198,8 +198,8 @@ sub run
# Attempt to save without proper path
#---------------------------------------------------------------------------------------------------------------------------
$self->testException(sub {$oManifest->save()}, ERROR_PATH_MISSING,
"unable to open '" . $strBackupManifestFile . "': No such file or directory");
$self->testException(sub {$oManifest->save()}, ERROR_FILE_MISSING,
"unable to open file '${strBackupManifestFile}' for write in missing path");
# Create path and save
#---------------------------------------------------------------------------------------------------------------------------
@ -226,8 +226,8 @@ sub run
# Build error if offline = true and no tablespace path
#---------------------------------------------------------------------------------------------------------------------------
$self->testException(sub {$oManifest->build(storageDb(), $self->{strDbPath}, undef, false, false)}, ERROR_FILE_MISSING,
"unable to stat '" . $self->{strDbPath} . "/" . MANIFEST_TARGET_PGTBLSPC . "': No such file or directory");
$self->testException(sub {$oManifest->build(storageDb(), $self->{strDbPath}, undef, false, false)}, ERROR_PATH_MISSING,
"unable to list file info for missing path '" . $self->{strDbPath} . "/" . MANIFEST_TARGET_PGTBLSPC . "'");
# bOnline = true tests
#---------------------------------------------------------------------------------------------------------------------------
@ -236,7 +236,11 @@ sub run
{bLoad => false, strDbVersion => PG_VERSION_94, iDbCatalogVersion => $self->dbCatalogVersion(PG_VERSION_94)});
# Create expected manifest from base
my $oStorageTemp = $oManifestBase->{oStorage};
$oManifestBase->{oStorage} = undef;
my $oManifestExpected = dclone($oManifestBase);
$oManifestBase->{oStorage} = $oStorageTemp;
$oManifestExpected->{oStorage} = $oStorageTemp;
# Add global/pg_control file and PG_VERSION file and create a directory with a different modes than default
storageDb()->put(storageDb()->openWrite($self->{strDbPath} . '/' . DB_FILE_PGCONTROL,
@ -523,7 +527,11 @@ sub run
# Unskip code path coverage
#---------------------------------------------------------------------------------------------------------------------------
$oStorageTemp = $oManifestExpected->{oStorage};
$oManifestExpected->{oStorage} = undef;
my $oManifestExpectedUnskip = dclone($oManifestExpected);
$oManifestExpected->{oStorage} = $oStorageTemp;
$oManifestExpectedUnskip->{oStorage} = $oStorageTemp;
# Change DB version to 93
$oManifest = new pgBackRest::Manifest(
@ -954,7 +962,7 @@ sub run
storageDb()->remove('postgresql.auto.conf');
storageDb()->remove('hosts');
storageDb()->remove('pg_log/logfile');
storageDb()->remove('global/exclude', {bRecurse => true});
storageDb()->pathRemove('global/exclude', {bRecurse => true});
# Reload the manifest with version < 9.0
#---------------------------------------------------------------------------------------------------------------------------
@ -1229,7 +1237,11 @@ sub run
{bLoad => false, strDbVersion => PG_VERSION_94, iDbCatalogVersion => $self->dbCatalogVersion(PG_VERSION_94)});
# Create expected manifest from base
my $oStorageTemp = $oManifestBase->{oStorage};
$oManifestBase->{oStorage} = undef;
my $oManifestExpected = dclone($oManifestBase);
$oManifestBase->{oStorage} = $oStorageTemp;
$oManifestExpected->{oStorage} = $oStorageTemp;
# Future timestamp on file
#---------------------------------------------------------------------------------------------------------------------------
@ -1255,7 +1267,11 @@ sub run
# Future timestamp in last manifest
#---------------------------------------------------------------------------------------------------------------------------
$oStorageTemp = $oManifestExpected->{oStorage};
$oManifestExpected->{oStorage} = undef;
my $oLastManifest = dclone($oManifestExpected);
$oManifestExpected->{oStorage} = $oStorageTemp;
$oLastManifest->{oStorage} = $oStorageTemp;
# Set a backup label
$oLastManifest->set(MANIFEST_SECTION_BACKUP, MANIFEST_KEY_LABEL, undef, BOGUS);
@ -1507,7 +1523,12 @@ sub run
{
my $oManifest = new pgBackRest::Manifest($strBackupManifestFile, {bLoad => false, strDbVersion => PG_VERSION_94,
iDbCatalogVersion => $self->dbCatalogVersion(PG_VERSION_94)});
my $oStorageTemp = $oManifestBase->{oStorage};
$oManifestBase->{oStorage} = undef;
my $oManifestExpected = dclone($oManifestBase);
$oManifestBase->{oStorage} = $oStorageTemp;
$oManifestExpected->{oStorage} = $oStorageTemp;
# Add a bogus file - all traces to be removed after the manifest has been built to simulate an inital manifest and avoid
# missing files error