From 860f34fa7110febb08e0d8bcef752ecdd727ca8a Mon Sep 17 00:00:00 2001 From: Brent Baude Date: Thu, 26 Jan 2017 15:50:23 -0600 Subject: [PATCH] Use secondary disks for storage integration tests Due to a couple of bugs related to loopback and sfdisk, we should be using available secondary disks for testing atomic storage. This is part of the destructive testing we now do. Also, configured vagrant to dispatch two disks so the tests can be done there too. Closes: #851 Approved by: baude --- .redhat-ci.yml | 1 + Atomic/storage.py | 7 ++++++- Vagrantfile | 2 ++ tests/integration/test_storage.sh | 18 ++++++++++++------ 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/.redhat-ci.yml b/.redhat-ci.yml index ac98df2..31199d4 100644 --- a/.redhat-ci.yml +++ b/.redhat-ci.yml @@ -42,6 +42,7 @@ host: distro: centos/7/atomic/continuous specs: secondary-disk: 10 + secondary-disk: 10 context: centos/7/atomic diff --git a/Atomic/storage.py b/Atomic/storage.py index 1f91030..be7e609 100644 --- a/Atomic/storage.py +++ b/Atomic/storage.py @@ -7,6 +7,7 @@ from . import util from .Export import export_docker from .Import import import_docker from .util import NoDockerDaemon, default_docker_lib +import subprocess try: from subprocess import DEVNULL # pylint: disable=no-name-in-module @@ -168,7 +169,11 @@ class Storage(Atomic): self._vgroup(self.args.vgroup) if len(self.args.devices) > 0: self._add_device(self.args.devices) - if util.call(["docker-storage-setup"]) != 0: + try: + util.check_output(["docker-storage-setup"], stderr=subprocess.STDOUT) + except subprocess.CalledProcessError as e: + util.write_out("Return Code: {}".format(e.returncode)) + util.write_out("Failure: {}".format(e.output)) os.rename(self.dss_conf_bak, self.dss_conf) util.call(["docker-storage-setup"]) raise ValueError("docker-storage-setup failed") diff --git a/Vagrantfile b/Vagrantfile index 6fefdb3..fa2fa2f 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -9,6 +9,8 @@ Vagrant.configure(2) do |config| config.vm.provider "libvirt" do |libvirt, override| libvirt.memory = 2048 libvirt.cpus = 3 + libvirt.storage :file, + :type => 'qcow2' end config.vm.synced_folder ".", "/vagrant", disabled: true config.vm.synced_folder ".", "/home/vagrant/atomic", type: "rsync", diff --git a/tests/integration/test_storage.sh b/tests/integration/test_storage.sh index 5482a43..5218955 100755 --- a/tests/integration/test_storage.sh +++ b/tests/integration/test_storage.sh @@ -29,9 +29,16 @@ smarter_copy() { setup () { # Perform setup routines here. smarter_copy /etc/sysconfig/docker-storage-setup /etc/sysconfig/docker-storage-setup.atomic-tests-backup - dd if=/dev/zero of=${WORK_DIR}/img-1 bs=1M count=10 - TEST_DEV_1=$(losetup --show -f -P ${WORK_DIR}/img-1) - TEST_DEV_1_pvs=${TEST_DEV_1}p1 + TEST_DEV_1=/dev/vdb + mount + #MNT=$(mount | grep vdb | awk '{print $3}') + MNT=$(mount | awk '$1 ~/vdb/' | awk '{print $3}') + if [ ${MNT} ]; then + umount $MNT + fi + wipefs -a "$TEST_DEV_1" + fdisk -l + TEST_DEV_1_pvs=${TEST_DEV_1}1 ROOT_DEV=$( awk '$2 ~ /^\/$/ && $1 !~ /rootfs/ { print $1 }' /proc/mounts ) VGROUP=$(lvs --noheadings -o vg_name ${ROOT_DEV} || true) @@ -40,13 +47,12 @@ setup () { teardown () { # Cleanup your test data. set -e - [ -n "$VGROUP" ] && (vgreduce $VGROUP "$TEST_DEV_1_pvs" || true) - losetup -d "$TEST_DEV_1" + wipefs -a "$TEST_DEV_1" smarter_copy /etc/sysconfig/docker-storage-setup.atomic-tests-backup /etc/sysconfig/docker-storage-setup } -trap teardown EXIT setup +trap teardown EXIT # Running without /e/s/d-s-s should fail.