vmcheck: adapt for non-vagrant hosts
This is just the final bit required to make sure the vagrant and non-vagrant paths can work happily together. It's mostly minor fixes, though the most major change which also affects vagrant is that we now sync to the root home dir, rather than ~vagrant. Closes: #524 Approved by: cgwalters
This commit is contained in:
parent
2d12d436ec
commit
12c4b5b16f
@ -91,7 +91,7 @@ check-local:
|
||||
@echo " *** NOTE ***"
|
||||
@echo " *** NOTE ***"
|
||||
|
||||
.PHONY: vmsync vmshell vmcheck testenv
|
||||
.PHONY: vmsync vmoverlay vmshell vmcheck testenv
|
||||
|
||||
vmsync:
|
||||
@env $(BASE_TESTS_ENVIRONMENT) ./tests/vmcheck/sync.sh
|
||||
|
15
Vagrantfile
vendored
15
Vagrantfile
vendored
@ -4,12 +4,8 @@
|
||||
|
||||
Vagrant.configure(2) do |config|
|
||||
|
||||
if ENV['VAGRANT_BOX']
|
||||
config.vm.box = ENV['VAGRANT_BOX']
|
||||
else
|
||||
config.vm.box = "centosah/7alpha"
|
||||
config.vm.box_url = 'https://ci.centos.org/artifacts/sig-atomic/centos-continuous/images-alpha/cloud/latest/images/centos-atomic-host-7-vagrant-libvirt.box'
|
||||
end
|
||||
config.vm.box = "centosah/7alpha"
|
||||
config.vm.box_url = 'https://ci.centos.org/artifacts/sig-atomic/centos-continuous/images-alpha/cloud/latest/images/centos-atomic-host-7-vagrant-libvirt.box'
|
||||
|
||||
config.vm.hostname = "centosah-dev"
|
||||
|
||||
@ -17,10 +13,11 @@ Vagrant.configure(2) do |config|
|
||||
end
|
||||
|
||||
if Vagrant.has_plugin?('vagrant-sshfs')
|
||||
config.vm.synced_folder ".", "/var/home/vagrant/sync", type: 'sshfs'
|
||||
config.vm.synced_folder ".", "/var/roothome/sync", type: 'sshfs'
|
||||
File.write('.vagrant/using_sshfs', '')
|
||||
end
|
||||
# turn off the default rsync in the vagrant box (the vm tooling does this
|
||||
# for use already)
|
||||
|
||||
# turn off the default rsync in the vagrant box
|
||||
config.vm.synced_folder ".", "/home/vagrant/sync", disabled: true
|
||||
|
||||
config.vm.provider "libvirt" do |libvirt, override|
|
||||
|
@ -28,27 +28,21 @@ vm_setup() {
|
||||
fi
|
||||
|
||||
local sshopts="-F ${topsrcdir}/ssh-config \
|
||||
-o User=root \
|
||||
-o User=root \
|
||||
-o ControlMaster=auto \
|
||||
-o ControlPath=${topsrcdir}/ssh.sock \
|
||||
-o ControlPersist=yes"
|
||||
export SSH="ssh $sshopts vmcheck"
|
||||
export SCP="scp $sshopts"
|
||||
if grep -q 'User.*vagrant' ${topsrcdir}/ssh-config; then
|
||||
export using_sshfs=yes
|
||||
else
|
||||
export using_sshfs=no
|
||||
fi
|
||||
}
|
||||
|
||||
vm_rsync() {
|
||||
if test ${using_sshfs} = yes; then
|
||||
return
|
||||
if ! test -f .vagrant/using_sshfs; then
|
||||
pushd ${topsrcdir}
|
||||
rsync -az --no-owner --no-group -e "ssh -F ssh-config" \
|
||||
--exclude .git/ . vmcheck:/var/roothome/sync
|
||||
popd
|
||||
fi
|
||||
pushd ${topsrcdir}
|
||||
rsync -az --no-owner --no-group --filter ":- .gitignore" \
|
||||
-e "ssh -F ssh-config" --exclude .git/ . vmcheck:/root/sync
|
||||
popd
|
||||
}
|
||||
|
||||
# run command in vm
|
||||
@ -99,7 +93,7 @@ vm_ssh_wait() {
|
||||
vm_reboot() {
|
||||
vm_cmd systemctl reboot || :
|
||||
sleep 2 # give time for port to go down
|
||||
vm_ssh_wait 10
|
||||
vm_ssh_wait 30
|
||||
}
|
||||
|
||||
# check that the given files exist on the VM
|
||||
|
@ -2,8 +2,15 @@
|
||||
set -euo pipefail
|
||||
|
||||
# Execute this code path on the host
|
||||
if test -z "${OVERLAY_IN_VM:-}"; then
|
||||
if test -z "${INSIDE_VM:-}"; then
|
||||
. ${commondir}/libvm.sh
|
||||
vm_setup
|
||||
|
||||
if ! vm_ssh_wait 30; then
|
||||
echo "ERROR: A running VM is required for 'make vmcheck'."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -x
|
||||
|
||||
topdir=$(git rev-parse --show-toplevel)
|
||||
@ -11,7 +18,9 @@ if test -z "${OVERLAY_IN_VM:-}"; then
|
||||
rm insttree -rf
|
||||
make install DESTDIR=$(pwd)/insttree
|
||||
vm_rsync
|
||||
ssh -o User=root -F ssh-config vmcheck "env OVERLAY_IN_VM=1 ~vagrant/sync/tests/vmcheck/overlay.sh"
|
||||
|
||||
$SSH "env INSIDE_VM=1 /var/roothome/sync/tests/vmcheck/overlay.sh"
|
||||
vm_reboot
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@ -36,9 +45,7 @@ fi
|
||||
cd /ostree/repo/tmp
|
||||
rm vmcheck -rf
|
||||
ostree checkout $commit vmcheck --fsync=0
|
||||
rsync -rv ~vagrant/sync/insttree/usr/ vmcheck/usr/
|
||||
rsync -rv /var/roothome/sync/insttree/usr/ vmcheck/usr/
|
||||
ostree refs --delete vmcheck || true
|
||||
ostree commit -b vmcheck -s '' --tree=dir=vmcheck --link-checkout-speedup
|
||||
ostree admin deploy vmcheck
|
||||
systemctl reboot
|
||||
|
||||
|
34
tests/vmcheck/sync.sh
Normal file → Executable file
34
tests/vmcheck/sync.sh
Normal file → Executable file
@ -1,10 +1,32 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
. ${commondir}/libvm.sh
|
||||
if test -z "${INSIDE_VM:-}"; then
|
||||
|
||||
set -x
|
||||
cd ${builddir}
|
||||
rm insttree -rf
|
||||
make install DESTDIR=$(pwd)/insttree
|
||||
ssh -o User=root -F ssh-config vmcheck "ostree admin unlock; cd ~vagrant/sync && rsync -rv insttree/usr/ /usr/ && systemctl restart rpm-ostreed"
|
||||
# do this in the host
|
||||
. ${commondir}/libvm.sh
|
||||
vm_setup
|
||||
|
||||
if ! vm_ssh_wait 30; then
|
||||
echo "ERROR: A running VM is required for 'make vmcheck'."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
set -x
|
||||
|
||||
topdir=$(git rev-parse --show-toplevel)
|
||||
cd ${topdir}
|
||||
rm insttree -rf
|
||||
make install DESTDIR=$(pwd)/insttree
|
||||
vm_rsync
|
||||
|
||||
$SSH "env INSIDE_VM=1 /var/roothome/sync/tests/vmcheck/sync.sh"
|
||||
exit 0
|
||||
else
|
||||
|
||||
# then do this in the VM
|
||||
set -x
|
||||
ostree admin unlock || :
|
||||
rsync -rv /var/roothome/sync/insttree/usr/ /usr/
|
||||
systemctl restart rpm-ostreed
|
||||
fi
|
||||
|
@ -7,7 +7,7 @@ set -euo pipefail
|
||||
vm_setup
|
||||
|
||||
# stand up ssh connection and sanity check that it all works
|
||||
if ! vm_ssh_wait 20; then
|
||||
if ! vm_ssh_wait 30; then
|
||||
echo "ERROR: A running VM is required for 'make vmcheck'."
|
||||
exit 1
|
||||
fi
|
||||
|
@ -61,6 +61,6 @@
|
||||
register: rpmq_fuse_sshfs
|
||||
changed_when: False
|
||||
failed_when: False
|
||||
|
||||
|
||||
- command: rpm-ostree install fuse-sshfs
|
||||
when: rpmq_fuse_sshfs.rc != 0
|
||||
|
Loading…
Reference in New Issue
Block a user