[PATCH 3/4] Move the ostree test out of its own directory.

Chris Lumens clumens at redhat.com
Mon Dec 15 20:25:20 UTC 2014


It is now part of a more general framework for running and validating kickstart
based test cases.  It therefore doesn't need to be off on its own anymore.
---
 tests/Makefile.am                     |   1 -
 tests/kickstart_tests/basic-ostree.ks |  37 +++++++++++
 tests/kickstart_tests/basic-ostree.sh |  62 +++++++++++++++++
 tests/ostree/basic.ks                 |  36 ----------
 tests/ostree/run_ostree_tests.sh      | 122 ----------------------------------
 5 files changed, 99 insertions(+), 159 deletions(-)
 create mode 100644 tests/kickstart_tests/basic-ostree.ks
 create mode 100755 tests/kickstart_tests/basic-ostree.sh
 delete mode 100644 tests/ostree/basic.ks
 delete mode 100755 tests/ostree/run_ostree_tests.sh

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 2dff690..f28ff6b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -50,7 +50,6 @@ dist_check_SCRIPTS = $(srcdir)/glade/*/*.py \
 		     gettext/gettext_potfiles.py \
 		     gettext/style_guide.py \
 		     storage/run_storage_tests.py \
-		     ostree/run_ostree_tests.sh \
 		     install/run_install_test.sh \
 		     kickstart_tests/run_kickstart_tests.sh \
 		     $(srcdir)/gui/*.ks \
diff --git a/tests/kickstart_tests/basic-ostree.ks b/tests/kickstart_tests/basic-ostree.ks
new file mode 100644
index 0000000..0a5b3fa
--- /dev/null
+++ b/tests/kickstart_tests/basic-ostree.ks
@@ -0,0 +1,37 @@
+# Substitute something in for REPO or this will all come crashing down.
+ostreesetup --nogpg --osname=fedora-atomic --remote=fedora-atomic --url=REPO --ref=fedora-atomic/rawhide/x86_64/base/core
+
+bootloader --timeout=1
+zerombr
+clearpart --all
+part --fstype=ext4 --size=4400 /
+part --fstype=ext4 --size=500 /boot
+part --fstype=swap --size=500 swap
+
+keyboard us
+lang en
+timezone America/New_York
+rootpw qweqwe
+shutdown
+
+%post
+cat <<EOF > /lib/systemd/system/default.target.wants/run-test.service
+[Unit]
+Description=Run a test to see if anaconda+ostree worked
+After=basic.target
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/run-test.sh
+EOF
+
+cat <<EOF > /usr/bin/run-test.sh
+#!/bin/bash
+
+# For now, just the fact that we rebooted is good enough.
+echo SUCCESS > /root/RESULT
+shutdown -h now
+EOF
+
+chmod +x /usr/bin/run-test.sh
+%end
diff --git a/tests/kickstart_tests/basic-ostree.sh b/tests/kickstart_tests/basic-ostree.sh
new file mode 100755
index 0000000..4909709
--- /dev/null
+++ b/tests/kickstart_tests/basic-ostree.sh
@@ -0,0 +1,62 @@
+#!/bin/bash
+#
+# Copyright (C) 2014  Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+# Public License for more details.  You should have received a copy of the
+# GNU General Public License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.  Any Red Hat trademarks that are incorporated in the
+# source code or documentation are not subject to the GNU General Public
+# License and may only be used or replicated with the express permission of
+# Red Hat, Inc.
+#
+# Red Hat Author(s): Chris Lumens <clumens at redhat.com>
+
+kernel_args() {
+    echo text
+}
+
+prepare() {
+    ks=$1
+    tmpdir=$2
+
+    if [[ "${TEST_OSTREE_REPO}" == "" ]]; then
+        echo \$TEST_OSTREE_REPO is not set.
+        return 1
+    fi
+
+    sed -e "/ostreesetup/ s|REPO|${TEST_OSTREE_REPO}|" ${ks} > ${tmpdir}/kickstart.ks
+    echo ${tmpdir}/kickstart.ks
+}
+
+validate() {
+    img=$1
+
+    # Now attempt to boot the resulting VM and see if the install
+    # actually worked.  The VM will shut itself down so there's no
+    # need to worry with that here.
+    timeout 5m /usr/bin/qemu-kvm -m 2048 \
+                                 -smp 2 \
+                                 -hda ${img} \
+                                 -vnc localhost:3
+
+    # There should be a /root/RESULT file with results in it.  Check
+    # its contents and decide whether the test finally succeeded or
+    # not.
+    result=$(virt-cat -a ${img} -m /dev/sda2 /ostree/deploy/fedora-atomic/var/roothome/RESULT)
+    if [[ $? != 0 ]]; then
+        status=1
+        echo /root/RESULT does not exist in VM image.
+    elif [[ "${result}" != "SUCCESS" ]]; then
+        status=1
+        echo ${result}
+    fi
+
+    return ${status}
+}
diff --git a/tests/ostree/basic.ks b/tests/ostree/basic.ks
deleted file mode 100644
index c872d03..0000000
--- a/tests/ostree/basic.ks
+++ /dev/null
@@ -1,36 +0,0 @@
-# Substitute something in for REPO or this will all come crashing down.
-ostreesetup --nogpg --osname=fedora-atomic --remote=fedora-atomic --url=REPO --ref=fedora-atomic/rawhide/x86_64/base/core
-
-bootloader --timeout=1
-zerombr
-clearpart --all
-part --fstype=ext4 --size=4400 /
-part --fstype=ext4 --size=500 /boot
-part --fstype=swap --size=500 swap
-
-keyboard us
-timezone America/New_York
-rootpw qweqwe
-shutdown
-
-%post
-cat <<EOF > /lib/systemd/system/default.target.wants/run-test.service
-[Unit]
-Description=Run a test to see if anaconda+ostree worked
-After=basic.target
-
-[Service]
-Type=oneshot
-ExecStart=/usr/bin/run-test.sh
-EOF
-
-cat <<EOF > /usr/bin/run-test.sh
-#!/bin/bash
-
-# For now, just the fact that we rebooted is good enough.
-echo SUCCESS > /root/RESULT
-shutdown -h now
-EOF
-
-chmod +x /usr/bin/run-test.sh
-%end
diff --git a/tests/ostree/run_ostree_tests.sh b/tests/ostree/run_ostree_tests.sh
deleted file mode 100755
index cfc6e81..0000000
--- a/tests/ostree/run_ostree_tests.sh
+++ /dev/null
@@ -1,122 +0,0 @@
-#!/bin/bash
-#
-# Copyright (C) 2014  Red Hat, Inc.
-#
-# This copyrighted material is made available to anyone wishing to use,
-# modify, copy, or redistribute it subject to the terms and conditions of
-# the GNU General Public License v.2, or (at your option) any later version.
-# This program is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY expressed or implied, including the implied warranties of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
-# Public License for more details.  You should have received a copy of the
-# GNU General Public License along with this program; if not, write to the
-# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-# 02110-1301, USA.  Any Red Hat trademarks that are incorporated in the
-# source code or documentation are not subject to the GNU General Public
-# License and may only be used or replicated with the express permission of
-# Red Hat, Inc.
-#
-# Red Hat Author(s): Chris Lumens <clumens at redhat.com>
-
-# Have to be root to run this test, as it requires creating disk iamges.
-if [ ${EUID} != 0 ]; then
-   exit 77
-fi
-
-# The boot.iso location can come from one of two different places:
-# (1) $TEST_BOOT_ISO, if this script is being called from "make check"
-# (2) The command line, if this script is being called directly.
-if [[ "${TEST_BOOT_ISO}" != "" ]]; then
-    IMAGE=${TEST_BOOT_ISO}
-elif [[ $# != 0 ]]; then
-    IMAGE=$1
-    shift
-fi
-
-# The same with the ostree repo.
-if [[ "${TEST_OSTREE_REPO}" != "" ]]; then
-    REPO=${TEST_OSTREE_REPO}
-elif [[ $# != 0 ]]; then
-    REPO=$1
-    shift
-else
-    echo "usage: $0 <boot.iso> <ostree repo>"
-    exit 1
-fi
-
-if [ ! -e "${IMAGE}" ]; then
-    echo "Required boot.iso does not exist."
-    exit 2
-fi
-
-logdir=$(mktemp -d)
-
-status=0
-for ks in ostree/*ks; do
-    # Substitute in the location of an ostree repo here.  This could be one
-    # publically accessible, or a very local and private one that happens
-    # to be fast.
-    ksfile=$(mktemp)
-    sed -e "/ostreesetup/ s|REPO|${REPO}|" ${ks} > ${ksfile}
-
-    echo ${ks}
-    echo ====================
-
-    livemedia-creator --make-disk \
-                      --iso "${IMAGE}" \
-                      --ks ${ksfile} \
-                      --tmp /var/tmp \
-                      --logfile ${logdir}/livemedia.log \
-                      --title Fedora \
-                      --project Fedora \
-                      --releasever 21 \
-                      --ram 2048 \
-                      --vcpus 2 \
-                      --vnc vnc \
-                      --kernel-args text
-    if [ $? != 0 ]; then
-        status=1
-        echo $(grep CRIT ${logdir}/virt-install.log)
-    fi
-
-    rm ${ksfile}
-
-    if [ -f ostree/run_ostree_tests.log ]; then
-        img=$(grep disk_img ostree/run_ostree_tests.log | cut -d= -f2)
-        trimmed=${img## }
-
-        if [ ! -f ${trimmed} ]; then
-            status=1
-            echo Disk image ${trimmed} does not exist.
-            continue
-        fi
-
-        # Now attempt to boot the resulting VM and see if the install
-        # actually worked.  The VM will shut itself down so there's no
-        # need to worry with that here.
-        timeout 5m /usr/bin/qemu-kvm -m 2048 \
-                                     -smp 2 \
-                                     -hda ${trimmed} \
-                                     -vnc localhost:3
-
-        # There should be a /root/RESULT file with results in it.  Check
-        # its contents and decide whether the test finally succeeded or
-        # not.
-        result=$(virt-cat -a ${trimmed} -m /dev/sda2 /ostree/deploy/fedora-atomic/var/roothome/RESULT)
-        if [ $? != 0 ]; then
-            status=1
-            echo /root/RESULT does not exist in VM image.
-        elif [ "${result}" != "SUCCESS" ]; then
-            status=1
-            echo ${result}
-        fi
-    fi
-
-    # Clean it up for the next go around.
-    if [ -f ${trimmed} ]; then
-        rm ${trimmed}
-    fi
-done
-
-rm -r ${logdir}
-exit $status
-- 
1.9.3



More information about the anaconda-patches mailing list