mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-14 10:13:05 +02:00
45881c74ae
Three major changes were required to get this working: 1) Provide the path to pgbackrest in the build directory when running outside a container. Tests in a container will continue to install and run against /usr/bin/pgbackrest. 1) Set a per-test lock path so tests don't conflict on the default /tmp/pgbackrest path. Also set a per-test log-path while we are at it. 2) Use localhost instead of a custom host for TLS test connections. Tests in containers will continue to update /etc/hosts and use the custom host. Add infrastructure and update harnessCfgLoad*() to get the correct exe and paths loaded for testing. Since new tests are required to verify that running outside a container works, also rework the tests in Travis CI to provide coverage within a reasonable amount of time. Mainly, break up to doc tests by VM and run an abbreviated unit test suite on co6 and co7.
125 lines
6.1 KiB
Ruby
125 lines
6.1 KiB
Ruby
Vagrant.configure(2) do |config|
|
|
config.vm.provider :virtualbox do |vb|
|
|
vb.memory = 4096
|
|
vb.cpus = 8
|
|
end
|
|
|
|
config.vm.box = "ubuntu/bionic64"
|
|
config.vm.box_version = "20180719.0.0"
|
|
|
|
# vagrant plugin install vagrant-disksize
|
|
config.disksize.size = '64GB'
|
|
|
|
config.vm.provider :virtualbox do |vb|
|
|
vb.name = "pgbackrest-test"
|
|
end
|
|
|
|
# Provision the VM
|
|
config.vm.provision "shell", inline: <<-SHELL
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
echo 'Build Begin' && date
|
|
|
|
# Suppress "dpkg-reconfigure: unable to re-open stdin: No file or directory" warning
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
|
|
# Assign a host name
|
|
sed -i 's/^127\.0\.0\.1\t.*/127\.0\.0\.1\tlocalhost pgbackrest-test/' /etc/hosts
|
|
hostnamectl set-hostname pgbackrest-test
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
echo 'Update Apt' && date
|
|
apt-get update
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
echo 'Synchronize Date' && date
|
|
apt-get install -y ntpdate
|
|
ntpdate pool.ntp.org
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
echo 'Use Google DNS' && date
|
|
echo 'supersede domain-name-servers 8.8.8.8;' >> /etc/dhcp/dhclient.conf
|
|
/etc/init.d/networking restart
|
|
|
|
# Set time sync settings so builds don't fail with clock skew errors
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
echo 'Time Sync Settings' && date
|
|
sudo /etc/init.d/virtualbox-guest-utils stop
|
|
sudo /usr/sbin/VBoxService --timesync-set-on-restore --timesync-interval 5000 --timesync-set-threshold 1
|
|
|
|
# Create /tmp/pgbackrest and give ownership to root so we know unit tests are not writing there
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
echo 'Create /tmp/pgbackrest owned by root' && date
|
|
sudo mkdir -p /tmp/pgbackrest
|
|
sudo chown root:root /tmp/pgbackrest
|
|
sudo chmod 700 /tmp/pgbackrest
|
|
|
|
# Mount tmpfs at /home/vagrant/test for faster testing
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
echo 'Mount tmpfs' && date
|
|
sudo -u vagrant mkdir -p -m 770 /home/vagrant/test
|
|
echo 'tmpfs /home/vagrant/test tmpfs size=2560M 0 1' >> /etc/fstab
|
|
mount -a
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
echo 'Install Perl Modules' && date
|
|
apt-get install -y libdbd-pg-perl libxml-checker-perl libyaml-libyaml-perl
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
echo 'Install Build Tools' && date
|
|
apt-get install -y devscripts build-essential lintian git lcov cloc txt2man debhelper libssl-dev zlib1g-dev libperl-dev \
|
|
libxml2-dev liblz4-dev libpq-dev valgrind
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
echo 'Install AWS CLI' && date
|
|
apt-get install -y python-pip
|
|
pip install --upgrade awscli
|
|
|
|
# Configure AWS CLI
|
|
sudo -i -u vagrant aws configure set region us-east-1
|
|
sudo -i -u vagrant aws configure set aws_access_key_id accessKey1
|
|
sudo -i -u vagrant aws configure set aws_secret_access_key verySecretKey1
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
echo 'Install Docker' && date
|
|
curl -fsSL https://get.docker.com | sh
|
|
sudo usermod -aG docker vagrant
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
echo 'Install Dev Utilities' && date
|
|
apt-get install -y vim htop
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
# echo 'Install TeX Live' && date
|
|
# Not installed by default since latex is only needed for releases and PDF development/testing
|
|
# apt-get install -y --no-install-recommends texlive-latex-base texlive-latex-extra texlive-fonts-recommended
|
|
# apt-get install -y texlive-font-utils
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
echo 'Create Postgres Group & pgBackRest User' && date
|
|
adduser --uid=5001 --ingroup=vagrant --disabled-password --gecos "" pgbackrest
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
echo 'Build VM Images' && date
|
|
rm -rf /backrest/test/.vagrant/docker/*
|
|
rm -rf /backrest/test/.vagrant/libc/*
|
|
rm -rf /backrest/test/.vagrant/package/*
|
|
sudo su - vagrant -c '/backrest/test/test.pl --vm-build'
|
|
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
echo 'Build End' && date
|
|
|
|
# Useful commands
|
|
#---------------------------------------------------------------------------------------------------------------------------
|
|
# Force remove all containers:
|
|
# docker rm -f $(docker ps -a -q)
|
|
# Force remove all images:
|
|
# docker rmi -f $(docker images -q)
|
|
SHELL
|
|
|
|
# Don't share the default vagrant folder
|
|
config.vm.synced_folder ".", "/vagrant", disabled: true
|
|
|
|
# Mount backrest path for testing
|
|
config.vm.synced_folder "..", "/backrest"
|
|
end
|