tests: Adapt to rpm-ostree daemon
No doubt better ways are possible but this is the least messy thing I could come up on a deadline.
This commit is contained in:
parent
a1b7ed5f9c
commit
0326568a4a
@ -1,6 +1,7 @@
|
||||
include $(top_srcdir)/buildutil/glib-tap.mk
|
||||
|
||||
CLEANFILES += \
|
||||
tests/setup-session.sh \
|
||||
tests/compose/yum/empty tests/compose/yum/repodata/repomd.xml \
|
||||
tests/compose/test-repo.repo \
|
||||
tests/compose/yum/repodata/*.bz2 \
|
||||
@ -33,6 +34,13 @@ installed_test_data = tests/libtest.sh \
|
||||
tests/compose/test-repo.repo.in \
|
||||
$(NULL)
|
||||
|
||||
tests/setup-session.sh: tests/setup-session.sh.in
|
||||
cat $< | sed -e "s|[@]LIBEXECDIR[@]|$(libexecdir)|" > $@
|
||||
|
||||
test_installed_extra_scripts = \
|
||||
tests/setup-session.sh \
|
||||
$(NULL)
|
||||
|
||||
nobase_installed_test_DATA += $(shell find tests/compose/yum/ -type f) \
|
||||
$(NULL)
|
||||
|
||||
|
@ -117,7 +117,7 @@ installed_test_meta_DATA = $(installed_testcases:=.test)
|
||||
%.test: %$(EXEEXT) Makefile
|
||||
$(AM_V_GEN) (echo '[Test]' > $@.tmp; \
|
||||
echo 'Type=session' >> $@.tmp; \
|
||||
echo 'Exec=$(installed_testdir)/$(notdir $<)' >> $@.tmp; \
|
||||
echo 'Exec=$(installed_testdir)/setup-session.sh $(installed_testdir)/$(notdir $<)' >> $@.tmp; \
|
||||
mv $@.tmp $@)
|
||||
|
||||
CLEANFILES += $(installed_test_meta_DATA)
|
||||
|
@ -60,7 +60,20 @@ get_connection_for_path (gchar *sysroot,
|
||||
NULL
|
||||
};
|
||||
|
||||
if (!sysroot)
|
||||
/* This is only intended for use by installed tests.
|
||||
* Note that it disregards the 'sysroot' and 'force_peer' options
|
||||
* and assumes the service activation command has been configured
|
||||
* to use the desired system root path. */
|
||||
if (g_getenv ("RPMOSTREE_USE_SESSION_BUS") != NULL)
|
||||
{
|
||||
if (sysroot != NULL)
|
||||
g_warning ("RPMOSTREE_USE_SESSION_BUS set, ignoring --sysroot=%s", sysroot);
|
||||
|
||||
connection = g_bus_get_sync (G_BUS_TYPE_SESSION, cancellable, error);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (sysroot == NULL)
|
||||
sysroot = "/";
|
||||
|
||||
if (g_strcmp0 ("/", sysroot) == 0 && force_peer == FALSE)
|
||||
|
@ -356,7 +356,17 @@ main (int argc,
|
||||
|
||||
if (service_dbus_fd == -1)
|
||||
{
|
||||
name_owner_id = g_bus_own_name (G_BUS_TYPE_SYSTEM,
|
||||
GBusType bus_type;
|
||||
|
||||
/* To facilitate testing, use whichever message bus activated
|
||||
* this process. If the process was started directly, assume
|
||||
* the system bus. */
|
||||
if (g_getenv ("DBUS_STARTER_BUS_TYPE") != NULL)
|
||||
bus_type = G_BUS_TYPE_STARTER;
|
||||
else
|
||||
bus_type = G_BUS_TYPE_SYSTEM;
|
||||
|
||||
name_owner_id = g_bus_own_name (bus_type,
|
||||
DBUS_NAME,
|
||||
G_BUS_NAME_OWNER_FLAGS_NONE,
|
||||
on_bus_acquired,
|
||||
|
@ -244,7 +244,7 @@ EOF
|
||||
ostree --repo=${test_tmpdir}/testos-repo fsck -q
|
||||
|
||||
cd ${test_tmpdir}
|
||||
mkdir sysroot
|
||||
# sysroot dir already made by setup-session.sh
|
||||
ostree admin --sysroot=sysroot init-fs sysroot
|
||||
ostree admin --sysroot=sysroot os-init testos
|
||||
|
||||
|
60
tests/setup-session.sh.in
Executable file
60
tests/setup-session.sh.in
Executable file
@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Configure a D-Bus session for shell script tests
|
||||
#
|
||||
# Copyright (C) 2015 Red Hat, Inc.
|
||||
#
|
||||
# This library is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU Lesser General Public
|
||||
# License as published by the Free Software Foundation; either
|
||||
# version 2 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public
|
||||
# License along with this library; if not, write to the
|
||||
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
# Boston, MA 02111-1307, USA.
|
||||
|
||||
test_tmpdir=$(pwd)
|
||||
|
||||
exec_binary="@LIBEXECDIR@/rpm-ostreed"
|
||||
|
||||
mkdir sysroot
|
||||
mkdir session-services
|
||||
|
||||
# Create a busconfig file with a custom <servicedir>
|
||||
cat > session.conf <<EOF
|
||||
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
|
||||
<busconfig>
|
||||
<type>session</type>
|
||||
|
||||
<!-- Enable to assist with debugging -->
|
||||
<!-- <syslog/> -->
|
||||
|
||||
<listen>unix:tmpdir=/tmp</listen>
|
||||
|
||||
<servicedir>${test_tmpdir}/session-services</servicedir>
|
||||
|
||||
<policy context="default">
|
||||
<allow send_destination="*" eavesdrop="true"/>
|
||||
<allow eavesdrop="true"/>
|
||||
<allow own="*"/>
|
||||
</policy>
|
||||
</busconfig>
|
||||
EOF
|
||||
|
||||
# Create a service file with a custom --sysroot
|
||||
cat > session-services/rpmostree.service <<EOF
|
||||
[D-BUS Service]
|
||||
Name=org.projectatomic.rpmostree1
|
||||
Exec=${exec_binary} --debug --sysroot=${test_tmpdir}/sysroot
|
||||
EOF
|
||||
|
||||
export RPMOSTREE_USE_SESSION_BUS=1
|
||||
|
||||
dbus-run-session --config-file=${test_tmpdir}/session.conf $@
|
@ -29,22 +29,26 @@ setup_os_repository "archive-z2" "syslinux"
|
||||
|
||||
echo "ok setup"
|
||||
|
||||
# Note: Daemon already knows what sysroot to use, so avoid passing
|
||||
# --sysroot=sysroot to rpm-ostree commands as it will result
|
||||
# in a warning message.
|
||||
|
||||
# This initial deployment gets kicked off with some kernel arguments
|
||||
ostree --repo=sysroot/ostree/repo remote add --set=gpg-verify=false testos file://$(pwd)/testos-repo testos/buildmaster/x86_64-runtime
|
||||
ostree --repo=sysroot/ostree/repo pull testos:testos/buildmaster/x86_64-runtime
|
||||
ostree admin --sysroot=sysroot deploy --karg=root=LABEL=MOO --karg=quiet --os=testos testos:testos/buildmaster/x86_64-runtime
|
||||
|
||||
rpm-ostree status --sysroot=sysroot | tee OUTPUT-status.txt
|
||||
rpm-ostree status | tee OUTPUT-status.txt
|
||||
|
||||
assert_file_has_content OUTPUT-status.txt '1.0.10'
|
||||
|
||||
os_repository_new_commit
|
||||
rpm-ostree upgrade --sysroot=sysroot --os=testos
|
||||
rpm-ostree upgrade --os=testos
|
||||
|
||||
ostree --repo=sysroot/ostree/repo remote add --set=gpg-verify=false otheros file://$(pwd)/testos-repo testos/buildmaster/x86_64-runtime
|
||||
rpm-ostree rebase --sysroot=sysroot --os=testos otheros:
|
||||
rpm-ostree rebase --os=testos otheros:
|
||||
|
||||
rpm-ostree status --sysroot=sysroot | tee OUTPUT-status.txt
|
||||
rpm-ostree status | tee OUTPUT-status.txt
|
||||
|
||||
assert_not_file_has_content OUTPUT-status.txt '1.0.10'
|
||||
version=$(date "+%Y%m%d.0")
|
||||
|
Loading…
Reference in New Issue
Block a user