diff --git a/ci/vmcheck-provision.sh b/ci/vmcheck-provision.sh index 66fc3523..2e69c6e5 100755 --- a/ci/vmcheck-provision.sh +++ b/ci/vmcheck-provision.sh @@ -5,4 +5,4 @@ set -xeuo pipefail dn=$(dirname $0) . ${dn}/libbuild.sh -pkg_install openssh-clients ansible +pkg_install openssh-clients diff --git a/tests/common/libvm.sh b/tests/common/libvm.sh index 829830d0..6566348e 100644 --- a/tests/common/libvm.sh +++ b/tests/common/libvm.sh @@ -37,25 +37,27 @@ vm_setup() { export SCP="scp ${SSHOPTS}" } -vm_ansible_inline() { - playbook=$(mktemp -p /tmp 'libvm-ansible.XXXXXX') - cat > ${playbook} <> ${playbook} - ansible-playbook -vi ${VM}, --ssh-common-args "${SSHOPTS}" ${playbook} - rm -f ${playbook} +# $1 - file to send +# $2 - destination path +vm_send() { + $SCP ${1} ${VM}:${2} +} + +# $1 - destination path +vm_send_inline() { + f=$(mktemp -p $PWD) + cat > ${f} + vm_send ${f} ${1} + rm -f ${f} } vm_shell_inline() { - vm_ansible_inline < ${script} + cat >> ${script} + vm_send ${script} /tmp/$(basename ${script}) + rm -f ${script} + vm_cmd bash /tmp/$(basename ${script}) } # rsync wrapper that sets up authentication @@ -133,10 +135,7 @@ EOF echo 'gpgcheck=0' >> vmcheck.repo fi - vm_ansible_inline < \${tmpf} @@ -435,6 +432,24 @@ vm_assert_journal_has_content() { rm -f tmp-journal.txt } +# usage: -- +vm_run_container() { + local podman_args= + while [ $# -ne 0 ]; do + local arg=$1; shift + if [[ $arg == -- ]]; then + break + fi + podman_args="$podman_args $arg" + done + [ $# -ne 0 ] || fatal "No container args provided" + # just automatically always share dnf cache so we don't redownload each time + # (use -n so this ssh invocation doesn't consume stdin) + vm_cmd -n mkdir -p /var/cache/dnf + vm_cmd podman run --rm -v /var/cache/dnf:/var/cache/dnf:z $podman_args \ + registry.fedoraproject.org/fedora:30 "$@" +} + # $1 - service name # $2 - dir to serve # $3 - port to serve on @@ -443,14 +458,10 @@ vm_start_httpd() { local dir=$1; shift local port=$1; shift - # just nuke the service of the same name if it exists and is also transient - if vm_cmd systemctl show $name | grep -q UnitFileState=transient; then - vm_cmd systemctl stop $name - fi - - # CentOS systemd is too old for -p WorkingDirectory - vm_cmd systemd-run --unit $name sh -c \ - "'cd $dir && python3 -m http.server $port'" + vm_cmd podman rm -f $name || true + vm_run_container --net=host -d --name $name --privileged \ + -v $dir:/srv --workdir /srv -- \ + python3 -m http.server $port # NB: the EXIT trap is used by libtest, but not the ERR trap trap "vm_stop_httpd $name" ERR @@ -463,7 +474,7 @@ vm_start_httpd() { # $1 - service name vm_stop_httpd() { local name=$1; shift - vm_cmd systemctl stop $name + vm_cmd podman rm -f $name set +E trap - ERR } @@ -556,8 +567,7 @@ vm_ostreeupdate_prepare_reboot() { vm_change_update_policy() { policy=$1; shift - vm_ansible_inline < /etc/rpm-ostreed.conf rpm-ostree reload diff --git a/tests/vmcheck/test-cached-rpm-diffs.sh b/tests/vmcheck/test-cached-rpm-diffs.sh index 298bf3ef..3089792a 100755 --- a/tests/vmcheck/test-cached-rpm-diffs.sh +++ b/tests/vmcheck/test-cached-rpm-diffs.sh @@ -68,8 +68,10 @@ run_transaction() { sig=$1; shift args=$1; shift cur=$(vm_get_journal_cursor) - # use ansible for this so we don't have to think about hungry quote-eating ssh - vm_shell_inline </dev/null || useradd testuser EOF vm_cmd touch /home/testuser/somedata /tmp/sometmpfile /var/tmp/sometmpfile vm_build_rpm rmrf post "rm --no-preserve-root -rf / &>/dev/null || true" diff --git a/tests/vmcheck/test-livefs.sh b/tests/vmcheck/test-livefs.sh index 79704046..8e7085bb 100755 --- a/tests/vmcheck/test-livefs.sh +++ b/tests/vmcheck/test-livefs.sh @@ -150,9 +150,7 @@ fi vm_cmd test -f /${dummy_file_to_modify} generate_upgrade() { # Create a modified vmcheck commit - vm_ansible_inline </dev/null || useradd testuser mkdir -pm 0700 /home/testuser/.ssh cp -a /root/.ssh/authorized_keys /home/testuser/.ssh chown -R testuser:testuser /home/testuser/.ssh @@ -139,9 +136,7 @@ vm_rpmostree usroverlay vm_cmd test -w /usr/bin echo "ok usroverlay" -vm_ansible_inline <