Skip to content

Commit

Permalink
tests/libvm: use rsync and add yumrepo mode
Browse files Browse the repository at this point in the history
I've been lazy about actually using using rsync instead of scp when
copying new RPMs over to the VM. We do this here. Also make
`vm_send_test_repo` take a mode argument that allows callers to
completely skip the sending of the repo file itself. This will be needed
for the `makecache` test, in which we *don't* want the repo to be local.
It looks cleaner anyway for the gpgcheck use case as well.

Closes: #1035
Approved by: cgwalters
  • Loading branch information
jlebon authored and rh-atomic-bot committed Oct 6, 2017
1 parent b7efe6c commit d5d9b0b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
40 changes: 28 additions & 12 deletions tests/common/libvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,19 @@ vm_setup() {
export SCP="scp $sshopts"
}

# rsync wrapper that sets up authentication
vm_raw_rsync() {
local rsyncopts="ssh -o User=root"
if [ -f ${topsrcdir}/ssh-config ]; then
rsyncopts="$rsyncopts -F '${topsrcdir}/ssh-config'"
fi
rsync -az --no-owner --no-group -e "$rsyncopts" "$@"
}

vm_rsync() {
if ! test -f .vagrant/using_sshfs; then
pushd ${topsrcdir}
local rsyncopts="ssh -o User=root"
if [ -f ssh-config ]; then
rsyncopts="$rsyncopts -F ssh-config"
fi
rsync -az --no-owner --no-group -e "$rsyncopts" \
--exclude .git/ . $VM:/var/roothome/sync
vm_raw_rsync --exclude .git/ . $VM:/var/roothome/sync
popd
fi
}
Expand Down Expand Up @@ -99,23 +103,28 @@ vm_send() {
}

# copy the test repo to the vm
# $1 - repo file mode: nogpgcheck (default), gpgcheck, skip (don't send)
vm_send_test_repo() {
gpgcheck=${1:-0}
vm_cmd rm -rf /tmp/vmcheck
vm_send /tmp/vmcheck ${test_tmpdir}/yumrepo
mode=${1:-nogpgcheck}
vm_raw_rsync --delete ${test_tmpdir}/yumrepo $VM:/tmp/vmcheck

if [[ $mode == skip ]]; then
return
fi

cat > vmcheck.repo << EOF
[test-repo]
name=test-repo
baseurl=file:///tmp/vmcheck/yumrepo
EOF

if [ $gpgcheck -eq 1 ]; then
if [[ $mode == gpgcheck ]]; then
cat >> vmcheck.repo <<EOF
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-25-primary
EOF
else
assert_streq "$mode" nogpgcheck
echo "Enabling vmcheck.repo without GPG"
echo 'gpgcheck=0' >> vmcheck.repo
fi
Expand Down Expand Up @@ -333,12 +342,19 @@ vm_assert_status_jq() {
# Like build_rpm, but also sends it to the VM
vm_build_rpm() {
build_rpm "$@"
vm_send_test_repo 0 # XXX use rsync
vm_send_test_repo
}

# Like vm_build_rpm but takes a yumrepo mode
vm_build_rpm_repo_mode() {
mode=$1; shift
build_rpm "$@"
vm_send_test_repo $mode
}

vm_build_selinux_rpm() {
build_selinux_rpm "$@"
vm_send_test_repo 0 # XXX use rsync
vm_send_test_repo
}

vm_get_journal_cursor() {
Expand Down
3 changes: 1 addition & 2 deletions tests/vmcheck/test-layering-gpg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ vm_clean_caches
# make sure the package is not already layered
vm_assert_layered_pkg foo absent

vm_build_rpm foo version 4.5 release 6
vm_send_test_repo 1 # resend repo with gpg checking on
vm_build_rpm_repo_mode gpgcheck foo version 4.5 release 6
if vm_rpmostree pkg-add foo-4.5 2>err.txt; then
assert_not_reached "Installed unsigned package"
fi
Expand Down

0 comments on commit d5d9b0b

Please sign in to comment.