From f5095a6af064001c94d633123dabe2a59c841bf3 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 26 Oct 2018 18:18:36 +0200 Subject: [PATCH] test: add simple test for importd It tests importing and exporting, and a few other machinectl commands. It currently does not test pulling (i.e. http downloads), but we might want to add that later on. --- test/TEST-25-IMPORT/Makefile | 1 + test/TEST-25-IMPORT/test.sh | 43 +++++++++++ test/TEST-25-IMPORT/testsuite.sh | 128 +++++++++++++++++++++++++++++++ 3 files changed, 172 insertions(+) create mode 120000 test/TEST-25-IMPORT/Makefile create mode 100755 test/TEST-25-IMPORT/test.sh create mode 100755 test/TEST-25-IMPORT/testsuite.sh diff --git a/test/TEST-25-IMPORT/Makefile b/test/TEST-25-IMPORT/Makefile new file mode 120000 index 0000000000..e9f93b1104 --- /dev/null +++ b/test/TEST-25-IMPORT/Makefile @@ -0,0 +1 @@ +../TEST-01-BASIC/Makefile \ No newline at end of file diff --git a/test/TEST-25-IMPORT/test.sh b/test/TEST-25-IMPORT/test.sh new file mode 100755 index 0000000000..188e7233bb --- /dev/null +++ b/test/TEST-25-IMPORT/test.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- +# ex: ts=8 sw=4 sts=4 et filetype=sh +set -e +TEST_DESCRIPTION="test importd" + +. $TEST_BASE_DIR/test-functions + +test_setup() { + create_empty_image + mkdir -p $TESTDIR/root + mount ${LOOPDEV}p1 $TESTDIR/root + + ( + LOG_LEVEL=5 + eval $(udevadm info --export --query=env --name=${LOOPDEV}p2) + + setup_basic_environment + dracut_install dd gunzip mv tar diff + + # setup the testsuite service + cat >$initdir/etc/systemd/system/testsuite.service < /var/tmp/scratch/adirectory/athirdfile + +# Test import-fs +machinectl import-fs /var/tmp/scratch/ +test -d /var/lib/machines/scratch +machinectl image-status scratch + +# Test export-tar +machinectl export-tar scratch /var/tmp/scratch.tar.gz +test -f /var/tmp/scratch.tar.gz +mkdir /var/tmp/extract +(cd /var/tmp/extract ; tar xzf /var/tmp/scratch.tar.gz) +diff -r /var/tmp/scratch/ /var/tmp/extract/ +rm -rf /var/tmp/extract + +# Test import-tar +machinectl import-tar /var/tmp/scratch.tar.gz scratch2 +test -d /var/lib/machines/scratch2 +machinectl image-status scratch2 +diff -r /var/tmp/scratch/ /var/lib/machines/scratch2 + +# Test removal +machinectl remove scratch +! test -f /var/lib/machines/scratch +! machinectl image-status scratch + +# Test clone +machinectl clone scratch2 scratch3 +test -d /var/lib/machines/scratch2 +machinectl image-status scratch2 +test -d /var/lib/machines/scratch3 +machinectl image-status scratch3 +diff -r /var/tmp/scratch/ /var/lib/machines/scratch3 + +# Test removal +machinectl remove scratch2 +! test -f /var/lib/machines/scratch2 +! machinectl image-status scratch2 + +# Test rename +machinectl rename scratch3 scratch4 +test -d /var/lib/machines/scratch4 +machinectl image-status scratch4 +! test -f /var/lib/machines/scratch3 +! machinectl image-status scratch3 +diff -r /var/tmp/scratch/ /var/lib/machines/scratch4 + +# Test removal +machinectl remove scratch4 +! test -f /var/lib/machines/scratch4 +! machinectl image-status scratch4 + +rm -rf /var/tmp/scratch + +echo OK > /testok + +exit 0