1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-10-30 23:37:45 +02:00

Remove pgbackrest test user.

This user was created before we tested in containers to ensure isolation between the pg and repo hosts which were then just directories.  The downside is that this resulted in a lot of sudos to set the pgbackrest user and to remove files which did not belong to the main test user.

Containers provide isolation without needing separate users so we can now safely remove the pgbackrest user.  This allows us to remove most sudos, except where they are explicitly needed in tests.

While we're at it, remove the code that installed the Perl C library (which also required sudo) and simply add the build path to @INC instead.
This commit is contained in:
David Steele
2019-10-12 09:45:18 -04:00
parent 6f0e7f00af
commit 11c7c8fabb
26 changed files with 190 additions and 303 deletions

View File

@@ -57,6 +57,7 @@ sub new
$self->{strTestPath},
$self->{oTest},
$self->{bDryRun},
$self->{strVmHost},
$self->{bVmOut},
$self->{iVmIdx},
$self->{iVmMax},
@@ -87,6 +88,7 @@ sub new
{name => 'strTestPath'},
{name => 'oTest'},
{name => 'bDryRun'},
{name => 'strVmHost'},
{name => 'bVmOut'},
{name => 'iVmIdx'},
{name => 'iVmMax'},
@@ -232,9 +234,7 @@ sub run
# If testing Perl code (or C code that calls Perl code) install bin and Perl C Library
if ($self->{oTest}->{&TEST_VM} ne VM_NONE && (!$self->{oTest}->{&TEST_C} || $self->{oTest}->{&TEST_PERL_REQ}))
{
jobInstallC(
$self->{strBackRestBase}, $self->{oTest}->{&TEST_VM}, $strImage,
!$self->{oTest}->{&TEST_C} && !$self->{oTest}->{&TEST_INTEGRATION});
jobInstallC($self->{strBackRestBase}, $self->{oTest}->{&TEST_VM}, $strImage);
}
}
}
@@ -269,6 +269,7 @@ sub run
($self->{oTest}->{&TEST_CONTAINER} ? 'docker exec -i -u ' . TEST_USER . " ${strImage} " : '') .
abs_path($0) .
" --test-path=${strVmTestPath}" .
" --vm-host=$self->{strVmHost}" .
" --vm=$self->{oTest}->{&TEST_VM}" .
" --vm-id=$self->{iVmIdx}" .
" --module=" . $self->{oTest}->{&TEST_MODULE} .
@@ -753,7 +754,7 @@ sub end
containerRemove("test-$self->{iVmIdx}");
}
executeTest(($self->{oTest}->{&TEST_VM} ne VM_NONE ? "sudo " : '') . "rm -rf ${strHostTestPath}");
executeTest("rm -rf ${strHostTestPath}");
}
$bDone = true;
@@ -776,20 +777,15 @@ sub jobInstallC
my $strBasePath = shift;
my $strVm = shift;
my $strImage = shift;
my $bCopyLibC = shift;
# Install Perl C Library
my $oVm = vmGet();
my $strBuildPath = "${strBasePath}/test/.vagrant/bin/${strVm}";
my $strBuildLibCPath = "${strBuildPath}/libc";
my $strBuildBinPath = "${strBuildPath}/src";
my $strPerlAutoPath = $oVm->{$strVm}{&VMDEF_PERL_ARCH_PATH} . '/auto/pgBackRest/LibC';
executeTest(
"docker exec -i -u root ${strImage} bash -c '" .
(defined($bCopyLibC) && $bCopyLibC ?
"mkdir -p -m 755 ${strPerlAutoPath} && " .
"cp ${strBuildLibCPath}/blib/arch/auto/pgBackRest/LibC/LibC.so ${strPerlAutoPath} && " : '') .
"cp ${strBuildBinPath}/" . PROJECT_EXE . ' /usr/bin/' . PROJECT_EXE . ' && ' .
'chmod 755 /usr/bin/' . PROJECT_EXE . "'");
}