mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2026-03-04 15:54:48 +01:00
Add a major upgrade test - bionic to jammy
This commit is contained in:
46
tests/vagrant/majorupgrade/Vagrantfile
vendored
Normal file
46
tests/vagrant/majorupgrade/Vagrantfile
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
load '../funcs.rb'
|
||||
|
||||
# major upgrade Ubuntu 18.04 (bionic) -> Ubuntu 22.04 (jammy)
|
||||
|
||||
Vagrant.configure("2") do |config|
|
||||
|
||||
config.vm.synced_folder "../../..", "/mailinabox", id: "mailinabox", automount: false
|
||||
config.vm.network "public_network", bridge: "#$default_network_interface"
|
||||
|
||||
|
||||
config.vm.define "major-upgrade-oldvm" do |m1|
|
||||
use_preloaded_box m1, "ubuntu/bionic64", ".."
|
||||
m1.vm.provision :shell, :inline => <<-SH
|
||||
# setup vanilla system, populated with some data
|
||||
cd /mailinabox
|
||||
export PRIMARY_HOSTNAME=majorupgrade.local
|
||||
export FEATURE_MUNIN=false
|
||||
source tests/system-setup/setup-defaults.sh
|
||||
tests/system-setup/vanilla.sh \
|
||||
--checkout-repo="$MIABLDAP_GIT" \
|
||||
--checkout-treeish="$FINAL_RELEASE_TAG_BIONIC64" \
|
||||
--checkout-targetdir="$HOME/miabldap-bionic" \
|
||||
--populate=basic \
|
||||
--populate=totpuser \
|
||||
--capture-state=/tmp/state/oldvm \
|
||||
|| exit 1
|
||||
SH
|
||||
end
|
||||
|
||||
config.vm.define "major-upgrade-newvm" do |m2|
|
||||
use_preloaded_box m2, "ubuntu/jammy64", ".."
|
||||
m2.vm.provision :shell, :inline => <<-SH
|
||||
cd /mailinabox
|
||||
export PRIMARY_HOSTNAME=majorupgrade.local
|
||||
export FEATURE_MUNIN=false
|
||||
tests/system-setup/from-backup.sh \
|
||||
"#{ENV['storage_user']}" \
|
||||
"#{ENV['duplicity_files']}" \
|
||||
"#{ENV['secret_key']}" \
|
||||
"#{ENV['restore_to']}" \
|
||||
--capture-state=/tmp/state/newvm \
|
||||
|| exit 1
|
||||
SH
|
||||
end
|
||||
|
||||
end
|
||||
39
tests/vagrant/majorupgrade/majorupgrade.sh
Executable file
39
tests/vagrant/majorupgrade/majorupgrade.sh
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
|
||||
# run from this script's directory
|
||||
cd $(dirname "$0")
|
||||
|
||||
vagrant destroy -f
|
||||
|
||||
artifact_dir_local="$(dirname "$0")/../../out/majorupgrade"
|
||||
artifact_dir_vm="/mailinabox/tests/out/majorupgrade"
|
||||
oldvm="major-upgrade-oldvm"
|
||||
newvm="major-upgrade-newvm"
|
||||
|
||||
# bring up oldvm, install, populate, and backup
|
||||
# installed source code is in $HOME/miabldap-bionic (see Vagrantfile). $HOME is /root
|
||||
vagrant up $oldvm || exit 1
|
||||
vagrant ssh $oldvm -- "sudo -H bash -c 'cd \$HOME/miabldap-bionic; management/backup.py' && echo 'backup successful'" || exit 2
|
||||
|
||||
# copy artifacts from oldvm to host
|
||||
rm -rf "$artifact_dir_local"
|
||||
mkdir -p "$artifact_dir_local"
|
||||
vagrant ssh $oldvm -- "cd \"$artifact_dir_vm\" || exit 1; sudo -H cp -R /tmp/state/oldvm state || exit 2; sudo -H cp -R /home/user-data/backup backup || exit 3" || exit $?
|
||||
|
||||
# destroy oldvm - bring up newvm
|
||||
vagrant destroy $oldvm -f
|
||||
|
||||
export storage_user="user-data"
|
||||
export duplicity_files="$artifact_dir_vm/backup/encrypted"
|
||||
export secret_key="$artifact_dir_vm/backup/secret_key.txt"
|
||||
export restore_to="/home/user-data"
|
||||
|
||||
vagrant up $newvm || exit 1
|
||||
|
||||
# compare states
|
||||
vagrant ssh $newvm -- "cd /mailinabox; sudo -H bash -c 'source tests/lib/all.sh; installed_state_compare $artifact_dir_vm/state /tmp/state/newvm'" || exit 2
|
||||
|
||||
# run tests
|
||||
vagrant ssh $newvm -- "cd /mailinabox; sudo -H tests/runner.sh upgrade-basic upgrade-totpuser default" || exit 3
|
||||
|
||||
echo 'Success'
|
||||
Reference in New Issue
Block a user