import system-storage-manager-1.4-1.el8

This commit is contained in:
CentOS Sources 2021-05-08 06:11:31 +00:00 committed by Andrew Lukoshko
commit 4f0f0abb42
13 changed files with 2192 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
SOURCES/system-storage-manager-1.4.tar.gz

View File

@ -0,0 +1 @@
14c095c24b57a44eec76807cf788f9cb715cbdb4 SOURCES/system-storage-manager-1.4.tar.gz

View File

@ -0,0 +1,259 @@
From e19db289c5080530f2d2a2f21dde35fd12571c1b Mon Sep 17 00:00:00 2001
From: Jan Tulak <jtulak@redhat.com>
Date: Fri, 10 Aug 2018 17:29:48 +0200
Subject: [PATCH 1/9] ssm: enforce python3
RHEL8 and later have python3 only.
Change all shebangs and version-dependent calls to explicitly use
Python 3 and update the docs respectively. This also marks the end of
python2 support.
Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
INSTALL | 2 +-
Makefile | 8 ++++----
README | 2 +-
bin/ssm | 2 +-
bin/ssm.local | 2 +-
doc/Makefile | 2 +-
doc/generate_usage_includes.py | 2 +-
doc/src/requirements.rst | 2 +-
man8/ssm.8 | 2 +-
test.py | 2 +-
tests/__init__.py | 2 +-
tests/unittests/__init__.py | 2 +-
tests/unittests/common.py | 2 +-
tests/unittests/test_btrfs.py | 2 +-
tests/unittests/test_lvm.py | 2 +-
tests/unittests/test_misc.py | 2 +-
tests/unittests/test_multipath.py | 2 +-
tests/unittests/test_ssm.py | 2 +-
18 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/INSTALL b/INSTALL
index f1f0277..4dbcd2e 100644
--- a/INSTALL
+++ b/INSTALL
@@ -21,7 +21,7 @@ local sources with:
Requirements
************
-Python 2.6 or higher is required to run this tool. System Storage
+Python 3.6 or higher is required to run this tool. System Storage
Manager can only be run as root since most of the commands require
root privileges.
diff --git a/Makefile b/Makefile
index 2d887c4..80ae3f9 100644
--- a/Makefile
+++ b/Makefile
@@ -28,7 +28,7 @@ ifndef PREVIOUS
endif
clean:
- @python setup.py clean
+ @python3 setup.py clean
rm -f MANIFEST
find . -\( -name "*.pyc" -o -name '*.pyo' -o -name "*~" -\) -delete
@@ -36,7 +36,7 @@ git-clean:
git clean -f
install:
- @python setup.py install
+ @python3 setup.py install
spec: check_vars
@(LC_ALL=C date +"* %a %b %e %Y `git config --get user.name` <`git config --get user.email`> - $(VERSION)"; git log --pretty="format:- %s (%an)" $(PREVIOUS)..HEAD| cat; echo -e "\n\n"; cat CHANGES) > CHANGES.bck; mv CHANGES.bck CHANGES
@@ -51,10 +51,10 @@ docs:
@make dist -C doc
source: test clean
- @python setup.py sdist
+ @python3 setup.py sdist
test:
- @python test.py
+ @python3 test.py
push_html:
scp -r doc/_build/singlehtml/* lczerner@shell.sourceforge.net:/home/project-web/storagemanager/htdocs/
diff --git a/README b/README
index fe16990..95f20ae 100644
--- a/README
+++ b/README
@@ -684,7 +684,7 @@ local sources with:
Requirements
************
-Python 2.6 or higher is required to run this tool. System Storage
+Python 3.6 or higher is required to run this tool. System Storage
Manager can only be run as root since most of the commands require
root privileges.
diff --git a/bin/ssm b/bin/ssm
index 53aece6..13b2241 100755
--- a/bin/ssm
+++ b/bin/ssm
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# (C)2011 Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
#
diff --git a/bin/ssm.local b/bin/ssm.local
index d5bedec..94ea9dd 100755
--- a/bin/ssm.local
+++ b/bin/ssm.local
@@ -26,7 +26,7 @@ export PYTHONPATH="$SSMDIR"
# Run coverage if the environment variable is set up.
if [ "$RUN_COVERAGE" = "" ]; then
- python $SSMDIR/bin/ssm "$@"
+ python3 $SSMDIR/bin/ssm "$@"
else
$RUN_COVERAGE $SSMDIR/bin/ssm "$@"
fi
diff --git a/doc/Makefile b/doc/Makefile
index 09ee867..43e531b 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -3,7 +3,7 @@
# You can set these variables from the command line.
SPHINXOPTS =
-SPHINXBUILD = sphinx-build
+SPHINXBUILD = sphinx-build-3
PAPER = a4
BUILDDIR = _build
diff --git a/doc/generate_usage_includes.py b/doc/generate_usage_includes.py
index d7695f8..5ced9e6 100755
--- a/doc/generate_usage_includes.py
+++ b/doc/generate_usage_includes.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
import re
import sys, os
diff --git a/doc/src/requirements.rst b/doc/src/requirements.rst
index 0482e1d..18508e9 100644
--- a/doc/src/requirements.rst
+++ b/doc/src/requirements.rst
@@ -3,7 +3,7 @@
Requirements
============
-Python 2.6 or higher is required to run this tool. System Storage Manager
+Python 3.6 or higher is required to run this tool. System Storage Manager
can only be run as root since most of the commands require root privileges.
There are other requirements listed below, but note that you do not
diff --git a/man8/ssm.8 b/man8/ssm.8
index 12859dc..94ad144 100644
--- a/man8/ssm.8
+++ b/man8/ssm.8
@@ -865,7 +865,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <\fI\%http://www.gnu.org/licenses/\fP>.
.SH REQUIREMENTS
.sp
-Python 2.6 or higher is required to run this tool. System Storage Manager
+Python 3.6 or higher is required to run this tool. System Storage Manager
can only be run as root since most of the commands require root privileges.
.sp
There are other requirements listed below, but note that you do not
diff --git a/test.py b/test.py
index 721fe08..28530fa 100755
--- a/test.py
+++ b/test.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# (C)2011 Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
#
diff --git a/tests/__init__.py b/tests/__init__.py
index 6d8f17e..9f0c266 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# (C)2011 Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
#
diff --git a/tests/unittests/__init__.py b/tests/unittests/__init__.py
index 3776154..512baac 100644
--- a/tests/unittests/__init__.py
+++ b/tests/unittests/__init__.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# (C)2011 Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
#
diff --git a/tests/unittests/common.py b/tests/unittests/common.py
index 5495e22..37e0434 100644
--- a/tests/unittests/common.py
+++ b/tests/unittests/common.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# (C)2011 Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
#
diff --git a/tests/unittests/test_btrfs.py b/tests/unittests/test_btrfs.py
index 36db292..6af94cd 100644
--- a/tests/unittests/test_btrfs.py
+++ b/tests/unittests/test_btrfs.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# (C)2012 Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
#
diff --git a/tests/unittests/test_lvm.py b/tests/unittests/test_lvm.py
index 6489ba8..abe6d6b 100644
--- a/tests/unittests/test_lvm.py
+++ b/tests/unittests/test_lvm.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# (C)2011 Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
#
diff --git a/tests/unittests/test_misc.py b/tests/unittests/test_misc.py
index 2afc88f..cea3d19 100644
--- a/tests/unittests/test_misc.py
+++ b/tests/unittests/test_misc.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# (C)2018 Red Hat, Inc., Jan Tulak <jtulak@redhat.com>
#
diff --git a/tests/unittests/test_multipath.py b/tests/unittests/test_multipath.py
index 7239c2a..49c4a6c 100644
--- a/tests/unittests/test_multipath.py
+++ b/tests/unittests/test_multipath.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# (C)2012 Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
# (C)2016 Red Hat, Inc., Jan Tulak <jtulak@redhat.com>
diff --git a/tests/unittests/test_ssm.py b/tests/unittests/test_ssm.py
index 1fb0297..142bee2 100644
--- a/tests/unittests/test_ssm.py
+++ b/tests/unittests/test_ssm.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# (C)2011 Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
#
--
2.21.0

View File

@ -0,0 +1,511 @@
From a80454ac89489945349f2eb0c0c70d6621b67f5b Mon Sep 17 00:00:00 2001
From: Jan Tulak <jtulak@redhat.com>
Date: Fri, 10 Aug 2018 16:43:45 +0200
Subject: [PATCH 2/9] Remove info command for RHEL
Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
README | 9 --
doc/generate_usage_includes.py | 10 --
doc/src/commands/index.rst | 1 -
doc/src/commands/info.rst | 8 --
doc/src/commands/info.txt | 7 -
man8/ssm.8 | 47 +------
ssmlib/main.py | 32 -----
tests/bashtests/017-info.sh | 230 ---------------------------------
tests/unittests/test_ssm.py | 1 -
9 files changed, 1 insertion(+), 344 deletions(-)
delete mode 100644 doc/src/commands/info.rst
delete mode 100644 doc/src/commands/info.txt
delete mode 100755 tests/bashtests/017-info.sh
diff --git a/README b/README
index 95f20ae..17df34d 100644
--- a/README
+++ b/README
@@ -148,15 +148,6 @@ The following sections can be specified:
Info command
************
-**EXPERIMENTAL** This feature is currently experimental. The output
-format can change and fields can be added or removed.
-
-Show detailed information about all detected devices, pools, volumes
-and snapshots found on the system. The **info** command can be used
-either alone to show all available items, or you can specify a device,
-pool, or any other identifier to see information about the specific
-item.
-
Remove command
**************
diff --git a/doc/generate_usage_includes.py b/doc/generate_usage_includes.py
index 5ced9e6..b672dec 100755
--- a/doc/generate_usage_includes.py
+++ b/doc/generate_usage_includes.py
@@ -12,7 +12,6 @@ SYNOPSIS_INC = "src/synopsis.inc"
OPTIONS_DIR = "src/options/"
SSM_OPTIONS_INC = OPTIONS_DIR + "ssm_options.inc"
CREATE_OPTIONS_INC = OPTIONS_DIR + "create_options.inc"
-INFO_OPTIONS_INC = OPTIONS_DIR + "info_options.inc"
LIST_OPTIONS_INC = OPTIONS_DIR + "list_options.inc"
REMOVE_OPTIONS_INC = OPTIONS_DIR + "remove_options.inc"
RESIZE_OPTIONS_INC = OPTIONS_DIR + "resize_options.inc"
@@ -24,7 +23,6 @@ MIGRATE_OPTIONS_INC = OPTIONS_DIR + "migrate_options.inc"
SSM_USAGE_INC = OPTIONS_DIR + "ssm_usage.inc"
CREATE_USAGE_INC = OPTIONS_DIR + "create_usage.inc"
-INFO_USAGE_INC = OPTIONS_DIR + "info_usage.inc"
LIST_USAGE_INC = OPTIONS_DIR + "list_usage.inc"
REMOVE_USAGE_INC = OPTIONS_DIR + "remove_usage.inc"
RESIZE_USAGE_INC = OPTIONS_DIR + "resize_usage.inc"
@@ -68,10 +66,6 @@ class GenerateIncludes(object):
message = self.format_synopsis(self.ssm_parser.parser_create)
self._write_message(message, CREATE_USAGE_INC)
- def write_info_usage(self):
- message = self.format_synopsis(self.ssm_parser.parser_info)
- self._write_message(message, INFO_USAGE_INC)
-
def write_list_usage(self):
message = self.format_synopsis(self.ssm_parser.parser_list)
self._write_message(message, LIST_USAGE_INC)
@@ -107,7 +101,6 @@ class GenerateIncludes(object):
def write_usage(self):
self.write_ssm_usage()
self.write_create_usage()
- self.write_info_usage()
self.write_list_usage()
self.write_remove_usage()
self.write_resize_usage()
@@ -137,9 +130,6 @@ class GenerateIncludes(object):
message = self._format_options(self.ssm_parser.parser_create)
self._write_message(message, CREATE_OPTIONS_INC)
- message = self._format_options(self.ssm_parser.parser_info)
- self._write_message(message, INFO_OPTIONS_INC)
-
message = self._format_options(self.ssm_parser.parser_list)
self._write_message(message, LIST_OPTIONS_INC)
diff --git a/doc/src/commands/index.rst b/doc/src/commands/index.rst
index 85ee495..d3f0a0f 100644
--- a/doc/src/commands/index.rst
+++ b/doc/src/commands/index.rst
@@ -7,7 +7,6 @@ System Storage Manager Commands
commands_introduction
create
- info
list
remove
resize
diff --git a/doc/src/commands/info.rst b/doc/src/commands/info.rst
deleted file mode 100644
index d2917ef..0000000
--- a/doc/src/commands/info.rst
+++ /dev/null
@@ -1,8 +0,0 @@
-Info command
-============
-
-.. include:: ../options/info_usage.inc
-
-.. include:: info.txt
-
-.. include:: ../options/info_options.inc
\ No newline at end of file
diff --git a/doc/src/commands/info.txt b/doc/src/commands/info.txt
deleted file mode 100644
index 7fadda0..0000000
--- a/doc/src/commands/info.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-**EXPERIMENTAL** This feature is currently experimental. The output format can
-change and fields can be added or removed.
-
-Show detailed information about all detected devices, pools, volumes and
-snapshots found on the system. The **info** command can be used either alone
-to show all available items, or you can specify a device, pool, or any other
-identifier to see information about the specific item.
\ No newline at end of file
diff --git a/man8/ssm.8 b/man8/ssm.8
index 94ad144..5e4057a 100644
--- a/man8/ssm.8
+++ b/man8/ssm.8
@@ -30,43 +30,14 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
-.
-.nr rst2man-indent-level 0
-.
-.de1 rstReportMargin
-\\$1 \\n[an-margin]
-level \\n[rst2man-indent-level]
-level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
--
-\\n[rst2man-indent0]
-\\n[rst2man-indent1]
-\\n[rst2man-indent2]
-..
-.de1 INDENT
-.\" .rstReportMargin pre:
-. RS \\$1
-. nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin]
-. nr rst2man-indent-level +1
-.\" .rstReportMargin post:
-..
-.de UNINDENT
-. RE
-.\" indent \\n[an-margin]
-.\" old: \\n[rst2man-indent\\n[rst2man-indent-level]]
-.nr rst2man-indent-level -1
-.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
-.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
-..
.SH SYNOPSIS
.sp
-\fBssm\fP [\fB\-h\fP] [\fB\-\-version\fP] [\fB\-v\fP] [\fB\-v**v] [\fP\-v**vv] [\fB\-f\fP] [\fB\-b\fP BACKEND] [\fB\-n\fP] {check,resize,create,list,info,add,remove,snapshot,mount,migrate} ...
+\fBssm\fP [\fB\-h\fP] [\fB\-\-version\fP] [\fB\-v\fP] [\fB\-v**v] [\fP\-v**vv] [\fB\-f\fP] [\fB\-b\fP BACKEND] [\fB\-n\fP] {check,resize,create,list,add,remove,snapshot,mount,migrate} ...
.sp
\fBssm\fP \fBcreate\fP [\fB\-h\fP] [\fB\-s\fP SIZE] [\fB\-n\fP NAME] [\fB\-\-fstype\fP FSTYPE] [\fB\-r\fP LEVEL] [\fB\-I\fP STRIPESIZE] [\fB\-i\fP STRIPES] [\fB\-p\fP POOL] [\fB\-e\fP [{luks,plain}]] [\fB\-o\fP MNT_OPTIONS] [\fB\-v\fP VIRTUAL_SIZE] [\fBdevice\fP [\fBdevice\fP ...]] [mount]
.sp
\fBssm\fP \fBlist\fP [\fB\-h\fP] [{volumes,vol,dev,devices,pool,pools,fs,filesystems,snap,snapshots}]
.sp
-\fBssm\fP \fBinfo\fP [\fB\-h\fP] [item]
-.sp
\fBssm\fP \fBremove\fP [\fB\-h\fP] [\fB\-a\fP] [\fBitems\fP [\fBitems\fP ...]]
.sp
\fBssm\fP \fBresize\fP [\fB\-h\fP] [\fB\-s\fP SIZE] \fBvolume\fP [\fBdevice\fP [\fBdevice\fP ...]]
@@ -249,22 +220,6 @@ volume. A size suffix K|k, M|m, G|g, T|t, P|p, E|e can
be used to define \(aqpower of two\(aq units. If no unit is
provided, it defaults to kilobytes.
.UNINDENT
-.SS Info command
-.sp
-\fBssm\fP \fBinfo\fP [\fB\-h\fP] [item]
-.sp
-\fBEXPERIMENTAL\fP This feature is currently experimental. The output format can
-change and fields can be added or removed.
-.sp
-Show detailed information about all detected devices, pools, volumes and
-snapshots found on the system. The \fBinfo\fP command can be used either alone
-to show all available items, or you can specify a device, pool, or any other
-identifier to see information about the specific item.
-.INDENT 0.0
-.TP
-.B \-h\fP,\fB \-\-help
-show this help message and exit
-.UNINDENT
.SS List command
.sp
\fBssm\fP \fBlist\fP [\fB\-h\fP] [{volumes,vol,dev,devices,pool,pools,fs,filesystems,snap,snapshots}]
diff --git a/ssmlib/main.py b/ssmlib/main.py
index 5e99ae4..57a75cc 100644
--- a/ssmlib/main.py
+++ b/ssmlib/main.py
@@ -2032,26 +2032,6 @@ class StorageHandle(object):
elif args.type in ['snap', 'snapshots']:
self.snap.psummary()
- def info(self, args):
- """
- Show a detailed info about an object
- """
- sources = [self.pool, self.dev, self.vol, self.snap]
- create_graph(*sources)
- print("EXPERIMENTAL FEATURE (The format can yet change)\n")
-
- if not args.item:
- for source in sources:
- source.pinfo()
- else:
- found = False
- for source in sources:
- found |= source.pinfo(item=args.item)
- if not found:
- err = "The item '%s' was not found." % args.item
- raise argparse.ArgumentTypeError(err)
-
-
def add(self, args, skip_check=False):
"""
Add devices into the pool
@@ -2585,7 +2565,6 @@ class SsmParser(object):
self.parser_resize = self._get_parser_resize()
self.parser_create = self._get_parser_create()
self.parser_list = self._get_parser_list()
- self.parser_info = self._get_parser_info()
self.parser_add = self._get_parser_add()
self.parser_remove = self._get_parser_remove()
self.parser_snapshot = self._get_parser_snapshot()
@@ -2769,17 +2748,6 @@ class SsmParser(object):
parser_list.set_defaults(func=self.storage.list)
return parser_list
- def _get_parser_info(self):
- """
- Info command
- """
- parser_info = self.subcommands.add_parser("info",
- help='''Show detailed information about
- an object. EXPERIMENTAL''')
- parser_info.add_argument('item', nargs='?')
- parser_info.set_defaults(func=self.storage.info)
- return parser_info
-
def _get_parser_add(self):
"""
Add command
diff --git a/tests/bashtests/017-info.sh b/tests/bashtests/017-info.sh
deleted file mode 100755
index 2e947db..0000000
--- a/tests/bashtests/017-info.sh
+++ /dev/null
@@ -1,230 +0,0 @@
-#!/bin/bash
-#
-# (C)2013 Red Hat, Inc., Jan Tulak <jtulak@redhat.com>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-export test_name='017-info'
-export test_description='Check whether info command prints correct values'
-
-. lib/test
-
-DEV_COUNT=10
-DEV_SIZE=128
-TEST_MAX_SIZE=$(($DEV_COUNT*$DEV_SIZE))
-aux prepare_devs $DEV_COUNT $DEV_SIZE
-aux prepare_mnts 10
-TEST_DEVS=$(cat DEVICES)
-export LVOL_PREFIX="lvol"
-export SSM_DEFAULT_BACKEND='lvm'
-export SSM_LVM_DEFAULT_POOL=$vg1
-export SSM_NONINTERACTIVE='1'
-
-snap1="snap1"
-snap2="snap2"
-
-lvol1=${LVOL_PREFIX}001
-lvol2=${LVOL_PREFIX}002
-lvol3=${LVOL_PREFIX}003
-
-pool0=$vg1
-pool1=$vg2
-pool2=$vg3
-pool3=$vg4
-
-TEST_FS=
-#which mkfs.ext2 && TEST_FS+="ext2 "
-#which mkfs.ext3 && TEST_FS+="ext3 "
-which mkfs.ext4 && TEST_FS+="ext4 "
-which mkfs.xfs && TEST_FS+="xfs"
-
-TEST_MNT=$TESTDIR/mnt
-[ ! -d $TEST_MNT ] && mkdir $TEST_MNT &> /dev/null
-
-# Prepare pools and volumes
-
-vol1=volsf
-vol2=volss
-vol3=volmf
-vol4=volms1
-vol5=volms2
-vol6=volms3
-maxvolsz=$((DEV_SIZE-4))
-size1=$maxvolsz
-size2=$((DEV_SIZE/2))
-size3=$((maxvolsz*2))
-size4=$((DEV_SIZE/2))
-size5=$((DEV_SIZE*2))
-size6=$((DEV_SIZE/4))
-size4s=$((size4-20))
-size2r=$((size2-4))
-size5r=$((size5+16))
-
-## test a btrfs on a partition
-#
-# this is commented out, because the current testing infrastructure is not able
-# to handle such configuration. We need to move away from the lvm-like test suite
-# as anything complex and non-lvm is having issues with it. But at the same time
-# I want this test documented.
-#
-#
-# Test btrfs on a (loopback) partition.
-# This is a reproducer of a reported issue with ssm info.
-#
-# to create the partitions programatically (rather than manually)
-# we're going to simulate the manual input to fdisk
-# The sed script strips off all the comments so that we can
-# document what we're doing in-line with the actual commands
-# Note that a blank line (commented as "defualt" will send a empty
-# line terminated with a newline to take the fdisk default.
-#
-#sed -e 's/\s*\([\+0-9a-zA-Z]*\).*/\1/' << EOF | gdisk ${dev1}
-# n # new partition
-# 1 # partition number 1
-# # default - start at beginning of disk
-# # default - end at end of disk
-# # default - partition type is not important
-# p # print the in-memory partition table
-# w # write the partition table
-# Y # confirm
-# q # and we're done
-#EOF
-#partprobe -s $dev1
-#
-#mkfs.btrfs ${dev1}p1
-#ssm info
-#
-
-
-# Test without a filesystem
-ssm -f create -n $vol1 $dev1
-ssm create -n $vol2 -p $pool1 -s ${size2}M $dev2
-ssm create -n $vol3 -p $pool2 $dev3 $dev4
-ssm add -p $pool3 $dev{5,6,7,8}
-ssm create -p $pool3 -s ${size4}m -n $vol4
-ssm create -p $pool3 -s ${size5}m -n $vol5
-ssm create -p $pool3 -s ${size6}m -n $vol6
-lvchange -an $pool3/$vol6
-
-# test a not found case
-output=$(not ssm info foobarbaznotfound 2>&1 )
-echo "$output" | grep "The item 'foobarbaznotfound' was not found."
-
-# Check vol, dev, pool, resized vol, and snapshot
-output=`ssm info $pool0`
-check info_table none "$output" "pool name" name $pool0
-check info_table none "$output" type lvm volume group
-check info_table none "$output" "logical volume" volume ".*$pool0-$vol1"
-check info_table none "$output" size $size1.00MB
-check info_table none "$output" used $size1.00MB
-
-output=`ssm info $pool1`
-check info_table none "$output" "pool name" name $pool1
-check info_table none "$output" type lvm volume group
-check info_table none "$output" "logical volume" volume ".*$pool1-$vol2"
-check info_table none "$output" size $size1.00MB
-check info_table none "$output" used $size2.00MB
-
-output=`ssm info $pool2`
-check info_table none "$output" "pool name" name $pool2
-check info_table none "$output" type lvm volume group
-check info_table none "$output" "logical volume" volume ".*$pool2-$vol3"
-check info_table none "$output" size $size3.00MB
-check info_table none "$output" used $size3.00MB
-
-output=`ssm info $pool3`
-check info_table none "$output" "pool name" name $pool3
-check info_table none "$output" type lvm volume group
-# The "\|#" is there because info_table none adds a space at the end
-# of the expression, but we have to get rid of it without causing
-# false matches.
-check info_table none "$output" "logical volume.*$vol4\|#" volume ".*$pool3.$vol4"
-check info_table none "$output" "logical volume.*$vol5\|#" volume ".*$pool3.$vol5"
-check info_table none "$output" "logical volume.*$vol6\|#" volume ".*$pool3.$vol6"
-check info_table none "$output" size $((maxvolsz*4)).00MB
-check info_table none "$output" used $((size4+size5+size6)).00MB
-
-
-output=`ssm info $dev1`
-check info_table none "$output" type disk
-check info_table none "$output" "object name" name ".*$dev1"
-check info_table none "$output" "size" $size1.00MB
-
-output=$(ssm info $pool0/$vol1)
-check info_table none "$output" type lvm logical volume
-check info_table none "$output" "object name.*dev/$pool0/$vol1\|#"
-check info_table none "$output" "object name.*mapper/$pool0-$vol1\|#"
-check info_table none "$output" "size" $size1.00MB
-check info_table none "$output" "parent pool"
-check info_table "parent pool" "$output" type lvm volume group
-check info_table "parent pool" "$output" name $pool0
-
-
-# Check ssm vol after resize
-ssm -f resize $pool1/$vol2 -s ${size2r}M
-ssm resize -s ${size5r}m $pool3/$vol5
-
-output=`ssm info $pool1`
-check info_table none "$output" size $size1.00MB
-check info_table none "$output" used $size2r.00MB
-output=`ssm info $pool3/$vol5`
-check info_table none "$output" size $size5r.00MB
-
-ssm snapshot $pool3/$vol4 -n snap1
-ssm snapshot $pool3/$vol4 -s ${size4s}m -n snap2
-output=`ssm info $pool3/snap1`
-check info_table none "$output" type snapshot
-check info_table none "$output" parent volume $pool3/$vol4
-output=`ssm info $pool3/snap2`
-check info_table none "$output" size $size4s.00MB
-
-ssm -f remove -a
-
-# Test with filesystem
-for fs in $TEST_FS ; do
- ssm -f create -n $vol1 $dev1 --fs $fs
- ssm create -n $vol2 -p $pool1 -s ${size2}M $dev2 --fs $fs
-
- # Check fs, vol, dev, pool, resized vol, and snapshot
- output=`ssm info $pool0/$vol1`
- check info_table none "$output" "object name.*$pool0/$vol1"
- check info_table filesystem "$output" "type" $fs
-
- ssm -f remove -a
-
-done
-
-# Create volume with all devices at once
-size=$(($DEV_SIZE*6))
-ssm create --size ${size}M $TEST_DEVS
-
-# Take a snapshot with the default params
-export SSM_DEFAULT_BACKEND='btrfs'
-ssm snapshot --name $snap1 $SSM_LVM_DEFAULT_POOL/$lvol1
-
-output=$(ssm info $SSM_LVM_DEFAULT_POOL/$snap1)
-check info_table none "$output" "object name.*$SSM_LVM_DEFAULT_POOL/$snap1"
-check info_table none "$output" "type" snapshot
-check info_table none "$output" "parent volume.*$SSM_LVM_DEFAULT_POOL/$lvol1"
-
-output=$(ssm info $SSM_LVM_DEFAULT_POOL)
-check info_table none "$output" "type" lvm volume group
-check info_table none "$output" "logical volume.*$snap1"
-
-
-export SSM_DEFAULT_BACKEND='lvm'
-
-
-
-exit 0
diff --git a/tests/unittests/test_ssm.py b/tests/unittests/test_ssm.py
index 142bee2..3fe8f5f 100644
--- a/tests/unittests/test_ssm.py
+++ b/tests/unittests/test_ssm.py
@@ -281,7 +281,6 @@ class SimpleSsmSanityCheck(unittest.TestCase):
self.assert_("resize" in obj)
self.assert_("create" in obj)
self.assert_("list" in obj)
- self.assert_("info" in obj)
self.assert_("add" in obj)
self.assert_("remove" in obj)
self.assert_("snapshot" in obj)
--
2.21.0

View File

@ -0,0 +1,34 @@
From 168e3e9b41cfa4a954576c08cf03e0a18c80edb4 Mon Sep 17 00:00:00 2001
From: Jan Tulak <jtulak@redhat.com>
Date: Thu, 11 Apr 2019 13:17:36 +0200
Subject: [PATCH 3/9] unittests: better multipath message on fail
Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
tests/unittests/test_multipath.py | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tests/unittests/test_multipath.py b/tests/unittests/test_multipath.py
index 49c4a6c..6e58153 100644
--- a/tests/unittests/test_multipath.py
+++ b/tests/unittests/test_multipath.py
@@ -167,13 +167,14 @@ class MultipathFunctionCheck(MockSystemDataSource):
finally:
sys.stdout = self._stdout
vol_entries = 0
- for line in self._stringio.getvalue().splitlines():
+ output = self._stringio.getvalue()
+ for line in output.splitlines():
if line[:6] in ['------', 'Device']:
continue
dev = line.split(" ")
if dev[0] in ['/dev/dm-90', '/dev/dm-91']:
vol_entries += 1
- self.assertEqual(vol_entries, 2, "List vol should show 2 entries for 2 multipath devices, but found {0}.".format(vol_entries))
+ self.assertEqual(vol_entries, 2, "List vol should show 2 entries for 2 multipath devices, but found {0}: {1}".format(vol_entries, output))
# There should be no output for pools
sys.stdout = self._stringio = StringIO()
--
2.21.0

View File

@ -0,0 +1,65 @@
From e92811e297c5eb91a5285e10a7519b53dc45a6d9 Mon Sep 17 00:00:00 2001
From: Jan Tulak <jtulak@redhat.com>
Date: Thu, 11 Apr 2019 14:15:26 +0200
Subject: [PATCH 4/9] bashtests: allow testing of system-wide ssm
This patch allows us to test the installed, system-wide ssm, instead of
the local version.
Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
test.py | 5 +++++
tests/bashtests/lib/test.sh | 13 ++++++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/test.py b/test.py
index 28530fa..5620679 100755
--- a/test.py
+++ b/test.py
@@ -268,6 +268,8 @@ if __name__ == '__main__':
help='run only unit tests')
parser.add_argument('-l', '--logs', dest='want_logs', action='store_true',
help='if a bash test fails, print out it\'s log to stdout')
+ parser.add_argument('-s', '--system', dest='system', action='store_true',
+ help='Test the installed version of ssm in system. Implies --bash.')
parser.add_argument('tests', metavar='TEST', type=str, nargs='*',
help='Specific tests to be run. For bash tests, '
'that means either a full name (001-foo.sh), '
@@ -280,6 +282,9 @@ if __name__ == '__main__':
args = parser.parse_args()
check_system_dependencies()
+ if args.system:
+ args.bash = True
+ os.environ['SSM_TEST_SYSTEM'] = '1'
run_all = not args.unit and not args.bash
if args.unit and args.bash:
diff --git a/tests/bashtests/lib/test.sh b/tests/bashtests/lib/test.sh
index 319cf97..af37d98 100644
--- a/tests/bashtests/lib/test.sh
+++ b/tests/bashtests/lib/test.sh
@@ -15,8 +15,19 @@ TZ=UTC
unset CDPATH
export HERE=$(pwd)
+# If SSM_TEST_SYSTEM is set, run the test on a system-wide version instead of
+# local one.
+if [ "$SSM_TEST_SYSTEM" != "" ]; then
+ export SSM="$(which ssm)"
+ if [ "$SSM" == "" ]; then
+ echo "ERROR: SSM_TEST_SYSTEM set, but ssm wasn't found in PATH."
+ exit 1
+ fi
+else
+ export SSM="$HERE/../../bin/ssm.local"
+fi
+echo "Tested ssm executable is '$SSM'"
export PATH=$HERE/lib:$PATH
-export SSM="$HERE/../../bin/ssm.local"
chmod +x $SSM
# grab some common utilities
--
2.21.0

View File

@ -0,0 +1,742 @@
From 249118233b47afa7f17c0777b79195e5453e98b3 Mon Sep 17 00:00:00 2001
From: Jan Tulak <jtulak@redhat.com>
Date: Wed, 17 Apr 2019 11:43:05 +0200
Subject: [PATCH 5/9] bashtests: remove btrfs tests
Btrfs is not in RHEL8, there is no sense in testing it on CI, so let's
remove all btrfs related tests.
Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
tests/bashtests/006-btrfs-add.sh | 106 ---------------
tests/bashtests/007-btrfs-create.sh | 178 --------------------------
tests/bashtests/008-btrfs-remove.sh | 161 -----------------------
tests/bashtests/010-btrfs-snapshot.sh | 135 -------------------
tests/bashtests/018-migrate.sh | 96 --------------
5 files changed, 676 deletions(-)
delete mode 100755 tests/bashtests/006-btrfs-add.sh
delete mode 100755 tests/bashtests/007-btrfs-create.sh
delete mode 100755 tests/bashtests/008-btrfs-remove.sh
delete mode 100755 tests/bashtests/010-btrfs-snapshot.sh
diff --git a/tests/bashtests/006-btrfs-add.sh b/tests/bashtests/006-btrfs-add.sh
deleted file mode 100755
index f0b6556..0000000
--- a/tests/bashtests/006-btrfs-add.sh
+++ /dev/null
@@ -1,106 +0,0 @@
-#!/bin/bash
-#
-# (C)2012 Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-export test_name='006-btrfs-add'
-test_description='Exercise ssm add with btrfs backend'
-
-. lib/test
-
-DEV_COUNT=10
-DEV_SIZE=300
-TEST_MAX_SIZE=$(($DEV_COUNT*$DEV_SIZE))
-aux prepare_devs $DEV_COUNT $DEV_SIZE
-aux prepare_mnts 10
-TEST_DEVS=$(cat DEVICES)
-export SSM_DEFAULT_BACKEND='btrfs'
-export SSM_BTRFS_DEFAULT_POOL=$vg1
-export VOL_PREFIX="vol"
-export SSM_NONINTERACTIVE='1'
-vol1=${VOL_PREFIX}001
-vol2=${VOL_PREFIX}002
-vol3=${VOL_PREFIX}003
-
-pool1=$vg2
-pool2=$vg3
-
-# Create default pool with all devices at once
-ssm add $TEST_DEVS
-check btrfs_fs_field $SSM_BTRFS_DEFAULT_POOL dev_count $DEV_COUNT
-check list_table "$(ssm list pool)" $SSM_BTRFS_DEFAULT_POOL btrfs 10 none none none
-ssm -f remove $SSM_BTRFS_DEFAULT_POOL
-
-# Specify backend
-ssm -b btrfs add $TEST_DEVS
-check btrfs_fs_field $SSM_BTRFS_DEFAULT_POOL dev_count $DEV_COUNT
-ssm -f remove $SSM_BTRFS_DEFAULT_POOL
-
-export SSM_DEFAULT_BACKEND='lvm'
-ssm --backend btrfs add $TEST_DEVS
-check btrfs_fs_field $SSM_BTRFS_DEFAULT_POOL dev_count $DEV_COUNT
-ssm -f remove $SSM_BTRFS_DEFAULT_POOL
-export SSM_DEFAULT_BACKEND='btrfs'
-
-
-
-ssm add $TEST_DEVS
-check btrfs_fs_field $SSM_BTRFS_DEFAULT_POOL dev_count $DEV_COUNT
-check list_table "$(ssm list pool)" $SSM_BTRFS_DEFAULT_POOL btrfs $DEV_COUNT none none none
-ssm remove $dev1 $dev2 $dev3
-check btrfs_fs_field $SSM_BTRFS_DEFAULT_POOL dev_count $(($DEV_COUNT-3))
-ssm remove $dev4
-check btrfs_fs_field $SSM_BTRFS_DEFAULT_POOL dev_count $(($DEV_COUNT-4))
-check list_table "$(ssm list pool)" $SSM_BTRFS_DEFAULT_POOL btrfs $(($DEV_COUNT-4)) none none none
-ssm -f remove $SSM_BTRFS_DEFAULT_POOL
-
-# Create default pool by adding devices one per a call
-for i in $TEST_DEVS; do
- ssm add $i
-done
-check btrfs_fs_field $SSM_BTRFS_DEFAULT_POOL dev_count $DEV_COUNT
-ssm -f remove $SSM_BTRFS_DEFAULT_POOL
-
-# Create different groups from different devices
-ssm add $dev4
-ssm add $dev1 $dev2 $dev3 -p $pool1
-ssm add --pool $pool2 $dev7 $dev8
-ssm add $dev5 $dev6
-not ssm add $dev5 $dev6 $dev1 -p $pool1
-ssm add $dev9 $dev1 -p $pool1
-ssm add $dev10 -p $pool2
-not ssm add $dev10 -p $pool1
-not ssm add $dev10 $pool2 -p $pool1
-
-check btrfs_fs_field $SSM_BTRFS_DEFAULT_POOL dev_count 3
-check btrfs_fs_field $pool1 dev_count 4
-check btrfs_fs_field $pool2 dev_count 3
-ssm_output=$(ssm list pool)
-check list_table "$ssm_output" $SSM_BTRFS_DEFAULT_POOL btrfs 3 none none none
-check list_table "$ssm_output" $pool1 btrfs 4 none none none
-check list_table "$ssm_output" $pool2 btrfs 3 none none none
-
-ssm -f remove --all
-
-ssm add --help
-
-# Some cases which should fail
-not ssm _garbage_
-not ssm add
-not ssm add _garbage_
-not ssm add $dev1 ${dev1}not_exist
-not check btrfs_fs_field $SSM_BTRFS_DEFAULT_POOL label $SSM_BTRFS_DEFAULT_POOL
-not ssm add _somepool
-not ssm add $dev1 $dev2 $dev3 -p $pool1 _otherpool
diff --git a/tests/bashtests/007-btrfs-create.sh b/tests/bashtests/007-btrfs-create.sh
deleted file mode 100755
index 162b7b2..0000000
--- a/tests/bashtests/007-btrfs-create.sh
+++ /dev/null
@@ -1,178 +0,0 @@
-#!/bin/bash
-#
-# (C)2012 Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-export test_name='007-btrfs-create'
-test_description='Exercise ssm create command with btrfs backend'
-
-. lib/test
-
-DEV_COUNT=10
-DEV_SIZE=300
-TEST_MAX_SIZE=$(($DEV_COUNT*$DEV_SIZE))
-aux prepare_devs $DEV_COUNT $DEV_SIZE
-aux prepare_mnts 10
-TEST_DEVS=$(cat DEVICES)
-export SSM_DEFAULT_BACKEND='btrfs'
-export SSM_BTRFS_DEFAULT_POOL=$vg1
-export VOL_PREFIX="vol"
-export SSM_NONINTERACTIVE='1'
-vol1=${VOL_PREFIX}001
-vol2=${VOL_PREFIX}002
-vol3=${VOL_PREFIX}003
-
-pool1=$vg2
-pool2=$vg3
-
-dehumanise() {
- for v in "${@:-$(</dev/stdin)}"
- do
- echo $v | awk \
- 'BEGIN{IGNORECASE = 1}
- function printpower(n,b,p) {printf "%u\n", n*b^p; next}
- /[0-9]$/{print $1;next};
- /K(iB)?$/{printpower($1, 2, 10)};
- /M(iB)?$/{printpower($1, 2, 20)};
- /G(iB)?$/{printpower($1, 2, 30)};
- /T(iB)?$/{printpower($1, 2, 40)};
- /KB$/{ printpower($1, 10, 3)};
- /MB$/{ printpower($1, 10, 6)};
- /GB$/{ printpower($1, 10, 9)};
- /TB$/{ printpower($1, 10, 12)}'
- done
-}
-# Create volume with all devices at once
-ssm create $TEST_DEVS $mnt1
-not ssm create $TEST_DEVS -p $pool1
-
-# List and see if Free + Used == Total (allow 5 percent difference for rounding)
-ssm list pools
-test 1 -eq "$(dehumanise `ssm list pools | grep SSMTEST | awk '{print $4 $5 " " $6 $7 " " $8 $9}'` | paste - - - | awk '{print (($1 + $2 - $3) < (0.05 * $3))}')"
-
-#Create subvolume with nonexisting path
-not ssm create -n $vol1/$vol2
-
-check btrfs_fs_field $SSM_BTRFS_DEFAULT_POOL dev_count $DEV_COUNT
-check list_table "$(ssm list vol)" $SSM_BTRFS_DEFAULT_POOL $SSM_BTRFS_DEFAULT_POOL none btrfs none none btrfs $mnt1
-ssm create
-ssm create --name $vol1
-ssm create --name $vol1/$vol2
-check btrfs_vol_field $mnt1 vol_count 3
-check btrfs_vol_field $mnt1 subvolume $vol1
-check btrfs_vol_field $mnt1 subvolume $vol1/$vol2
-ssm_output=$(ssm list vol)
-check list_table "$ssm_output" $SSM_BTRFS_DEFAULT_POOL $SSM_BTRFS_DEFAULT_POOL none btrfs none none btrfs $mnt1
-check list_table "$ssm_output" $SSM_BTRFS_DEFAULT_POOL:....-..-..-....... $SSM_BTRFS_DEFAULT_POOL none btrfs none none btrfs $mnt1/....-..-..-.......
-check list_table "$ssm_output" $SSM_BTRFS_DEFAULT_POOL:$vol1 $SSM_BTRFS_DEFAULT_POOL none btrfs none none btrfs $mnt1/$vol1
-check list_table "$ssm_output" $SSM_BTRFS_DEFAULT_POOL:$vol1/$vol2 $SSM_BTRFS_DEFAULT_POOL none btrfs none none btrfs $mnt1/$vol1/$vol2
-umount $mnt1
-ssm -f remove $SSM_BTRFS_DEFAULT_POOL
-
-# Create volume with just one device
-ssm create $dev1
-not ssm create $dev1 -p $pool1
-ssm -f remove $SSM_BTRFS_DEFAULT_POOL
-
-# Specify backend
-ssm --backend btrfs create $dev1
-not ssm create $dev1 -p $pool1
-ssm -f remove $SSM_BTRFS_DEFAULT_POOL
-
-export SSM_DEFAULT_BACKEND='lvm'
-ssm -b btrfs create $dev1
-not ssm create $dev1 -p $pool1
-ssm -f remove $SSM_BTRFS_DEFAULT_POOL
-export SSM_DEFAULT_BACKEND='btrfs'
-
-# Create raid 0 volume with just one device
-ssm create -r 0 $dev1 $dev2 $dev3 $dev4
-not ssm create $dev1 -p $pool1
-ssm -f remove $SSM_BTRFS_DEFAULT_POOL
-
-# Create raid 1 volume with just one device
-ssm create -r 1 $dev1 $dev2 $dev3 $dev4
-not ssm create $dev1 -p $pool1
-ssm -f remove $SSM_BTRFS_DEFAULT_POOL
-
-# Create raid 10 volume with just one device
-ssm create -r 10 $dev1 $dev2 $dev3 $dev4
-ssm check $SSM_BTRFS_DEFAULT_POOL
-not ssm create $dev1 -p $pool1
-ssm -f remove $SSM_BTRFS_DEFAULT_POOL
-
-# Create several volumes with several pools
-ssm create $dev1 $mnt1
-ssm create --name $vol1
-check btrfs_fs_field $SSM_BTRFS_DEFAULT_POOL dev_count 1
-check btrfs_vol_field $mnt1 subvolume $vol1
-
-ssm create --pool $pool1 $dev2 $dev3 $mnt2
-ssm create --name $vol2 --pool $pool1
-# Also try to mount the subvolume somewhere else
-ssm create --name $vol3 --pool $pool1 $mnt3
-check btrfs_fs_field $pool1 dev_count 2
-check btrfs_vol_field $mnt2 subvolume $vol2
-check btrfs_vol_field $mnt1 vol_count 1
-check btrfs_vol_field $mnt2 vol_count 2
-not check btrfs_vol_field $mnt2 subvolume $vol1
-
-ssm create --name $vol1 --pool $pool2 $dev4 $dev5 $dev6
-check btrfs_fs_field $pool2 dev_count 3
-ssm create --name $vol2 --pool $pool2 $dev7 $dev8
-ssm create --name $vol1 --pool $pool2 $dev9 $mnt4
-check btrfs_fs_field $pool2 dev_count 6
-check btrfs_vol_field $mnt2 subvolume $vol2
-check btrfs_vol_field $mnt4 subvolume $vol1
-check btrfs_vol_field $mnt2 vol_count 2
-check btrfs_vol_field $mnt4 vol_count 2
-not check btrfs_vol_field $mnt2 subvolume $vol1
-ssm_output=$(ssm list vol)
-check list_table "$ssm_output" $SSM_BTRFS_DEFAULT_POOL $SSM_BTRFS_DEFAULT_POOL none btrfs none none btrfs $mnt1
-check list_table "$ssm_output" $SSM_BTRFS_DEFAULT_POOL:$vol1 $SSM_BTRFS_DEFAULT_POOL none btrfs none none btrfs $mnt1/$vol1
-check list_table "$ssm_output" $pool1 $pool1 none btrfs none none btrfs $mnt2
-check list_table "$ssm_output" $pool1:$vol2 $pool1 none btrfs none none btrfs $mnt2/$vol2
-check list_table "$ssm_output" $pool1:$vol3 $pool1 none btrfs none none btrfs $mnt3
-check list_table "$ssm_output" $pool2 $pool2 none btrfs none none btrfs
-check list_table "$ssm_output" $pool2:$vol1 $pool2 none btrfs none none btrfs $mnt4
-check list_table "$ssm_output" $pool2:$vol2 $pool2 none btrfs none none btrfs
-ssm_output=$(ssm list pool)
-check list_table "$ssm_output" $SSM_BTRFS_DEFAULT_POOL btrfs 1 none none none
-check list_table "$ssm_output" $pool1 btrfs 2 none none none
-check list_table "$ssm_output" $pool2 btrfs 6 none none none
-
-umount_all
-ssm -f remove $SSM_BTRFS_DEFAULT_POOL $pool1 $pool2
-
-# Create root mounted soubvolume and then another subvolume mounted at different mount point
-ssm create $TEST_DEVS $mnt1
-ssm create --name $vol1 $mnt2
-ssm create --name $vol1/$vol2 $mnt3
-
-# Create subvolume with already existing path
-not ssm create --name $vol1/$vol2
-not ssm create --name $vol1 $mnt3
-ssm_output=$(ssm list vol)
-check list_table "$ssm_output" $SSM_BTRFS_DEFAULT_POOL $SSM_BTRFS_DEFAULT_POOL none btrfs none none btrfs $mnt1
-check list_table "$ssm_output" $SSM_BTRFS_DEFAULT_POOL:$vol1 $SSM_BTRFS_DEFAULT_POOL none btrfs none none btrfs $mnt2
-check list_table "$ssm_output" $SSM_BTRFS_DEFAULT_POOL:$vol1/$vol2 $SSM_BTRFS_DEFAULT_POOL none btrfs none none btrfs $mnt3
-umount_all
-ssm -f remove $SSM_BTRFS_DEFAULT_POOL
-
-ssm create --help
-
-# Some cases which should fail
-not ssm create
-not ssm -f remove --all
diff --git a/tests/bashtests/008-btrfs-remove.sh b/tests/bashtests/008-btrfs-remove.sh
deleted file mode 100755
index 705a76d..0000000
--- a/tests/bashtests/008-btrfs-remove.sh
+++ /dev/null
@@ -1,161 +0,0 @@
-#!/bin/bash
-#
-# (C)2012 Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-export test_name='008-btrfs-remove'
-test_description='Exercise ssm remove command with btrfs backend'
-
-. lib/test
-
-DEV_COUNT=10
-DEV_SIZE=300
-TEST_MAX_SIZE=$(($DEV_COUNT*$DEV_SIZE))
-aux prepare_devs $DEV_COUNT $DEV_SIZE
-aux prepare_mnts 10
-TEST_DEVS=$(cat DEVICES)
-export SSM_DEFAULT_BACKEND='btrfs'
-export SSM_BTRFS_DEFAULT_POOL=$vg1
-export VOL_PREFIX="vol"
-export SSM_NONINTERACTIVE='1'
-vol1=${VOL_PREFIX}001
-vol2=${VOL_PREFIX}002
-vol3=${VOL_PREFIX}003
-
-pool1=$vg2
-pool2=$vg3
-
-# Remove subvolume
-ssm create $TEST_DEVS
-ssm create --name $vol1
-check btrfs_fs_field $SSM_BTRFS_DEFAULT_POOL label $SSM_BTRFS_DEFAULT_POOL
-ssm -f remove $SSM_BTRFS_DEFAULT_POOL
-not check btrfs_fs_field $SSM_BTRFS_DEFAULT_POOL label $SSM_BTRFS_DEFAULT_POOL
-
-# Remove volume group
-ssm create $TEST_DEVS $mnt1
-ssm create --name $vol1
-check btrfs_fs_field $SSM_BTRFS_DEFAULT_POOL dev_count $DEV_COUNT
-check btrfs_vol_field $mnt1 subvolume $vol1
-ssm list
-ssm -f remove $mnt1/$vol1
-check btrfs_fs_field $SSM_BTRFS_DEFAULT_POOL dev_count $DEV_COUNT
-not check btrfs_vol_field $mnt1 subvolume $vol1
-umount $mnt1
-ssm -f remove $SSM_BTRFS_DEFAULT_POOL
-
-# Remove unused devices from the pool
-ssm create $dev1
-btrfs filesystem show
-ssm add $TEST_DEVS
-btrfs filesystem show
-check btrfs_fs_field $SSM_BTRFS_DEFAULT_POOL dev_count $DEV_COUNT
-# Skip first few devices, because btrfs is now in a raid mode
-# and won't allow us to delete the last few devices.
-# We only want to see if removal works, so deleting only some is ok.
-ssm -f remove $(echo $TEST_DEVS | cut -d' ' -f5-)
-btrfs filesystem show
-ssm list
-check btrfs_fs_field $SSM_BTRFS_DEFAULT_POOL dev_count 4
-ssm -f remove --all
-
-# Remove multiple things
-ssm add $dev1 $dev2 -p $pool1
-ssm create --pool $pool2 $dev3 $dev4 $mnt1
-ssm create --name $vol1 -p $pool2
-ssm create --name $vol1 $dev5 $dev6 $mnt3
-ssm create --name $vol2 $dev7 $dev8
-ssm add $dev9
-
-check btrfs_fs_field $pool1 dev_count 2
-check btrfs_fs_field $pool2 dev_count 2
-check btrfs_vol_field $mnt1 vol_count 1
-check btrfs_vol_field $mnt1 subvolume $vol1
-check btrfs_fs_field $SSM_BTRFS_DEFAULT_POOL dev_count 5
-check btrfs_vol_field $mnt3 vol_count 1
-check btrfs_vol_field $mnt3 subvolume $vol2
-
-ssm list
-
-export SSM_DEFAULT_BACKEND='lvm'
-ssm -f remove $pool1 ${pool2}:$vol1 $mnt3/$vol2 $dev9
-export SSM_DEFAULT_BACKEND='btrfs'
-
-not check btrfs_fs_field $pool1 label $pool1
-not check btrfs_vol_field $mnt1 subvolume $vol1
-not check btrfs_vol_field $mnt2 subvolume $vol2
-check btrfs_fs_field $SSM_BTRFS_DEFAULT_POOL dev_count 4
-umount_all
-ssm -f remove --all
-
-# Remove all
-ssm add $dev1 $dev2 -p $pool1
-ssm create --pool $pool2 $dev3 $dev4 $mnt1
-ssm create --name $vol1 -p $pool2
-ssm create --name $vol1 $dev5 $dev6 $mnt3
-ssm create --name $vol2 $dev7 $dev8
-ssm create --name $vol3 $mnt2
-ssm add $dev9
-
-# We can not remove mounted fs
-not ssm remove $pool2
-
-# We can not remove mounted subvolume
-not ssm remove ${SSM_BTRFS_DEFAULT_POOL}:${vol3}
-
-check btrfs_fs_field $pool1 dev_count 2
-check btrfs_fs_field $pool2 dev_count 2
-check btrfs_vol_field $mnt1 vol_count 1
-check btrfs_vol_field $mnt1 subvolume $vol1
-check btrfs_fs_field $SSM_BTRFS_DEFAULT_POOL dev_count 5
-check btrfs_vol_field $mnt3 vol_count 2
-check btrfs_vol_field $mnt3 subvolume $vol2
-check btrfs_vol_field $mnt2 subvolume $vol3
-
-# but we can force it
-ssm -f remove ${SSM_BTRFS_DEFAULT_POOL}:${vol3}
-not check btrfs_vol_field $mnt2 subvolume $vol3
-
-umount_all
-ssm -f remove --all
-
-#Remove subvolume which is not mounted
-ssm create $dev1 $dev2
-ssm create --name $vol1
-ssm create --name $vol2
-ssm create --name ${vol1}/${vol3} $mnt1
-
-check btrfs_vol_field $mnt1 vol_count 3
-ssm remove ${SSM_BTRFS_DEFAULT_POOL}:$vol2
-ssm list
-
-check btrfs_vol_field $mnt1 vol_count 2
-check btrfs_fs_field $SSM_BTRFS_DEFAULT_POOL dev_count 2
-check btrfs_vol_field $mnt1 subvolume $vol1
-not check btrfs_vol_field $mnt1 subvolume $vol2
-check btrfs_vol_field $mnt1 subvolume ${vol1}/${vol3}
-
-umount_all
-ssm -f remove --all
-
-not check btrfs_fs_field $pool1 label $pool1
-not check btrfs_fs_field $pool2 label $pool2
-not check btrfs_fs_field $SSM_BTRFS_DEFAULT_POOL label $SSM_BTRFS_DEFAULT_POOL
-
-ssm remove --help
-
-# Some cases which should fail
-not ssm remove
-not ssm -f remove --all
diff --git a/tests/bashtests/010-btrfs-snapshot.sh b/tests/bashtests/010-btrfs-snapshot.sh
deleted file mode 100755
index 075dedf..0000000
--- a/tests/bashtests/010-btrfs-snapshot.sh
+++ /dev/null
@@ -1,135 +0,0 @@
-#!/bin/bash
-#
-# (C)2012 Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program 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 General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-export test_name='010-btrfs-snapshot'
-test_description='Exercise ssm snapshot command with btrfs'
-
-. lib/test
-
-DEV_COUNT=10
-DEV_SIZE=300
-TEST_MAX_SIZE=$(($DEV_COUNT*$DEV_SIZE))
-aux prepare_devs $DEV_COUNT $DEV_SIZE
-aux prepare_mnts 10
-TEST_DEVS=$(cat DEVICES)
-export SSM_DEFAULT_BACKEND='btrfs'
-export SSM_BTRFS_DEFAULT_POOL=$vg1
-export VOL_PREFIX="vol"
-export SSM_NONINTERACTIVE='1'
-vol1=${VOL_PREFIX}001
-vol2=${VOL_PREFIX}002
-vol3=${VOL_PREFIX}003
-
-pool1=$vg2
-pool2=$vg3
-
-snap1="snap1"
-snap2="snap2"
-snap3="snap3"
-snap4="snap4"
-snap5="snap5"
-snap6="snap6"
-
-
-# Create volume with all devices at once
-ssm create $TEST_DEVS $mnt1
-
-# Take a snapshot with the default params
-export SSM_DEFAULT_BACKEND='lvm'
-ssm snapshot $mnt1
-check btrfs_vol_field $mnt1 vol_count 1
-check list_table "$(ssm list snap)" $SSM_BTRFS_DEFAULT_POOL:snap-....-..-..-....... $SSM_BTRFS_DEFAULT_POOL none btrfs $mnt1/snap-....-..-..-.......
-export SSM_DEFAULT_BACKEND='btrfs'
-
-umount $mnt1
-# Remove entire pool
-ssm -f remove $SSM_BTRFS_DEFAULT_POOL
-
-# Create volume with all devices at once
-ssm create $TEST_DEVS
-
-# Take a snapshot with the default params
-ssm snapshot $SSM_BTRFS_DEFAULT_POOL
-mount LABEL=$SSM_BTRFS_DEFAULT_POOL $mnt1
-check btrfs_vol_field $mnt1 vol_count 1
-umount $mnt1
-
-# Remove entire pool
-ssm -f remove $SSM_BTRFS_DEFAULT_POOL
-
-# Create volume with all devices at once
-ssm create $TEST_DEVS
-
-# Take a snapshot with defined name
-ssm snapshot --name $snap1 $SSM_BTRFS_DEFAULT_POOL
-ssm snapshot --name $snap2 $SSM_BTRFS_DEFAULT_POOL
-ssm snapshot --name $snap3 $SSM_BTRFS_DEFAULT_POOL
-mount LABEL=$SSM_BTRFS_DEFAULT_POOL $mnt1
-check btrfs_vol_field $mnt1 vol_count 3
-check btrfs_vol_field $mnt1 subvolume $snap1
-check btrfs_vol_field $mnt1 subvolume $snap2
-check btrfs_vol_field $mnt1 subvolume $snap3
-ssm_output=$(ssm list vol)
-check list_table "$ssm_output" $SSM_BTRFS_DEFAULT_POOL $SSM_BTRFS_DEFAULT_POOL none btrfs none none btrfs $mnt1
-not check list_table "$ssm_output" $SSM_BTRFS_DEFAULT_POOL:$snap1 $SSM_BTRFS_DEFAULT_POOL none btrfs none none btrfs $mnt1/$snap1
-not check list_table "$ssm_output" $SSM_BTRFS_DEFAULT_POOL:$snap2 $SSM_BTRFS_DEFAULT_POOL none btrfs none none btrfs $mnt1/$snap2
-not check list_table "$ssm_output" $SSM_BTRFS_DEFAULT_POOL:$snap3 $SSM_BTRFS_DEFAULT_POOL none btrfs none none btrfs $mnt1/$snap3
-ssm_output=$(ssm list snap)
-not check list_table "$ssm_output" $SSM_BTRFS_DEFAULT_POOL $SSM_BTRFS_DEFAULT_POOL none btrfs btrfs $mnt1
-check list_table "$ssm_output" $SSM_BTRFS_DEFAULT_POOL:$snap1 $SSM_BTRFS_DEFAULT_POOL none btrfs $mnt1/$snap1
-check list_table "$ssm_output" $SSM_BTRFS_DEFAULT_POOL:$snap2 $SSM_BTRFS_DEFAULT_POOL none btrfs $mnt1/$snap2
-check list_table "$ssm_output" $SSM_BTRFS_DEFAULT_POOL:$snap3 $SSM_BTRFS_DEFAULT_POOL none btrfs $mnt1/$snap3
-
-# Remove the snapshot volumes
-ssm -f remove $SSM_BTRFS_DEFAULT_POOL:$snap1 $SSM_BTRFS_DEFAULT_POOL:$snap2 $SSM_BTRFS_DEFAULT_POOL:$snap3
-not check btrfs_vol_field $mnt1 subvolume $snap1
-not check btrfs_vol_field $mnt1 subvolume $snap2
-not check btrfs_vol_field $mnt1 subvolume $snap3
-
-# Take a snapshot with defined name when volume is mounted
-ssm snapshot --name $snap1 $SSM_BTRFS_DEFAULT_POOL
-ssm snapshot --name $snap2 $mnt1
-ssm snapshot --name $snap3 $SSM_BTRFS_DEFAULT_POOL
-
-ssm snapshot --name $snap4 $mnt1/$snap3
-ssm snapshot --name $snap3/$snap4/$snap5 $mnt1
-check btrfs_vol_field $mnt1 vol_count 5
-check btrfs_vol_field $mnt1 subvolume $snap1
-check btrfs_vol_field $mnt1 subvolume $snap2
-check btrfs_vol_field $mnt1 subvolume $snap3
-check btrfs_vol_field $mnt1 subvolume $snap3/$snap4
-check btrfs_vol_field $mnt1 subvolume $snap3/$snap4/$snap5
-ssm_output=$(ssm list vol)
-check list_table "$ssm_output" $SSM_BTRFS_DEFAULT_POOL $SSM_BTRFS_DEFAULT_POOL none btrfs none none btrfs $mnt1
-ssm_output=$(ssm list snap)
-check list_table "$ssm_output" $SSM_BTRFS_DEFAULT_POOL:$snap1 $SSM_BTRFS_DEFAULT_POOL none btrfs $mnt1/$snap1
-check list_table "$ssm_output" $SSM_BTRFS_DEFAULT_POOL:$snap2 $SSM_BTRFS_DEFAULT_POOL none btrfs $mnt1/$snap2
-check list_table "$ssm_output" $SSM_BTRFS_DEFAULT_POOL:$snap3 $SSM_BTRFS_DEFAULT_POOL none btrfs $mnt1/$snap3
-check list_table "$ssm_output" $SSM_BTRFS_DEFAULT_POOL:$snap3/$snap4 $SSM_BTRFS_DEFAULT_POOL none btrfs $mnt1/$snap3/$snap4
-check list_table "$ssm_output" $SSM_BTRFS_DEFAULT_POOL:$snap3/$snap4/$snap5 $SSM_BTRFS_DEFAULT_POOL none btrfs $mnt1/$snap3/$snap4/$snap5
-
-umount_all
-
-ssm -f remove --all
-ssm snapshot --help
-
-# Some cases which should fail
-not ssm snapshot
-ssm create $TEST_DEVS
-not ssm snapshot $SSM_BTRFS_DEFAULT_POOL/$lvol1
-
-ssm -f remove --all
diff --git a/tests/bashtests/018-migrate.sh b/tests/bashtests/018-migrate.sh
index fa378fd..fa1a745 100755
--- a/tests/bashtests/018-migrate.sh
+++ b/tests/bashtests/018-migrate.sh
@@ -80,79 +80,6 @@ not ssm migrate $mnt1 $dev1
#wipefs -a $dev1
#wipefs -a $dev2
-# BTRFS
-export SSM_DEFAULT_BACKEND='btrfs'
-
-# Simple btrfs migrate to plain device
-#ssm create $dev1
-#check btrfs_devices $SSM_BTRFS_DEFAULT_POOL $dev1
-#ssm migrate $dev1 $dev2
-#check btrfs_devices $SSM_BTRFS_DEFAULT_POOL $dev2
-#test_volume $SSM_BTRFS_DEFAULT_POOL
-# Btrfs migrate on device with signature (ext4)
-#not ssm migrate $dev2 $dev3
-#ssm -f migrate $dev2 $dev3
-#check btrfs_devices $SSM_BTRFS_DEFAULT_POOL $dev3
-#test_volume $SSM_BTRFS_DEFAULT_POOL
-#ssm -f remove --all
-
-# Simple btrfs migrate of mounted fs
-ssm create $dev1 $mnt1
-check btrfs_devices $SSM_BTRFS_DEFAULT_POOL $dev1
-not ssm migrate $mnt1 $dev2
-ssm migrate $dev1 $dev2
-check btrfs_devices $SSM_BTRFS_DEFAULT_POOL $dev2
-umount $mnt1
-ssm check $SSM_BTRFS_DEFAULT_POOL
-ssm -f remove --all
-
-# Migrate device from multi-device btrfs
-ssm create -p $vg1 $dev1 $dev2
-ssm create -p $vg2 $dev3 $dev4 $dev5
-ssm -f migrate $dev2 $dev6
-check btrfs_devices $vg1 $dev1 $dev6
-check btrfs_devices $vg2 $dev3 $dev4 $dev5
-test_volume $vg1
-test_volume $vg2
-
-# Migrate to a device already used in btrfs pool
-not ssm migrate $dev1 $dev3
-ssm -f migrate $dev1 $dev3
-check btrfs_devices $vg1 $dev3 $dev6
-check btrfs_devices $vg2 $dev4 $dev5
-test_volume $vg1
-test_volume $vg2
-ssm -f remove --all
-
-# Do not allow migrate between devices within a single pool in btrfs
-ssm create $dev1 $dev2 $dev3 $dev4
-not ssm migrate $dev1 $dev2
-not ssm -f migrate $dev1 $dev2
-check btrfs_devices $SSM_BTRFS_DEFAULT_POOL $dev1 $dev2 $dev3 $dev4
-ssm -f remove --all
-
-# migrate plain device to a device in btrfs pool - not used
-#ssm create -p $vg1 $dev1 $dev2 $dev3
-#mkfs.ext4 -F $dev4
-#not ssm migrate $dev4 $dev3
-#ssm -f migrate $dev4 $dev3
-#check btrfs_devices $vg1 $dev1 $dev2
-#test_volume $vg1
-#fsck.ext4 -fn $dev3
-
-# migrate plain device to a device in btrfs pool - used completely
-#ssm -f add -p $vg1 $dev3
-#ssm mount $vg1 $mnt1
-# Fill it up as much as we can, we do not care if dd fails
-#! dd if=/dev/zero of=$mnt1/file bs=1M
-#sync
-#umount $mnt1
-#not ssm migrate $dev4 $dev1
-#not ssm -f migrate $dev4 $dev1
-#check btrfs_devices $vg1 $dev1 $dev2 $dev3
-#test_volume $vg1
-#ssm -f remove --all
-
export SSM_DEFAULT_BACKEND='lvm'
# LVM
@@ -252,29 +179,6 @@ check vg_devices $SSM_LVM_DEFAULT_POOL $dev1 $dev2 $dev3 $dev5
#test_volume $dev5
ssm -f remove --all
-# migrate from btrfs pool to lvm
-wipefs -a $dev4 $dev5
-ssm -b btrfs create -p $vg1 $dev1 $dev2 $dev3
-ssm -b lvm create --fs ext4 -p $vg2 $dev4 $dev5
-not ssm migrate $dev5 $dev3
-ssm -f migrate $dev5 $dev3
-check btrfs_devices $vg1 $dev1 $dev2
-check vg_devices $vg2 $dev4 $dev5 $dev3
-test_volume $vg1
-test_volume $vg2/$lvol1
-ssm -f remove --all
-
-# migrate from lvm to btrfs pool
-ssm -b btrfs create -p $vg1 $dev1 $dev2 $dev3
-ssm -b lvm create --fs ext4 -p $vg2 $dev4 $dev5
-ssm add -p $vg2 $dev6
-not ssm migrate $dev3 $dev6
-ssm -f migrate $dev3 $dev6
-check btrfs_devices $vg1 $dev1 $dev2 $dev6
-check vg_devices $vg2 $dev4 $dev5
-test_volume $vg1
-test_volume $vg2/$lvol1
-ssm -f remove --all
# CRYPT
--
2.21.0

View File

@ -0,0 +1,163 @@
From 63b1437d96468d0fc81ea6ed0def628b98cbb285 Mon Sep 17 00:00:00 2001
From: Jan Tulak <jtulak@redhat.com>
Date: Tue, 24 Jul 2018 14:11:13 +0200
Subject: [PATCH 6/9] tests: add bash test skipping capabilities
Not all tests can be run all the time. If e.g. a required tool for some
backend is missing, it is better to skip the test and mark it so, rather
than fail, leaving the developer to search why.
Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
.gitignore | 1 +
test.py | 35 ++++++++++++++++++++++++++++----
tests/bashtests/016-multipath.sh | 4 ++--
tests/bashtests/lib/utils.sh | 5 +++++
4 files changed, 39 insertions(+), 6 deletions(-)
diff --git a/.gitignore b/.gitignore
index 53af491..d0038e8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,4 +5,5 @@ doc/src/options/
*.pyc
*.swp
tests/bashtests/*.bad
+tests/bashtests/*.skipped
tests/bashtests/*.out
diff --git a/test.py b/test.py
index 5620679..9c2610e 100755
--- a/test.py
+++ b/test.py
@@ -103,7 +103,7 @@ def check_system_dependencies():
return True
-def run_bash_tests(names, want_logs=False):
+def run_bash_tests(names, exclude=[], want_logs=False):
cur = os.getcwd()
os.chdir('./tests/bashtests')
command = ['ls', '-m']
@@ -112,6 +112,7 @@ def run_bash_tests(names, want_logs=False):
failed = []
passed = []
+ skipped = []
count = 0
misc.run('./set.sh', stdout=False)
output = misc.run(command, stdout=False)[1]
@@ -122,12 +123,20 @@ def run_bash_tests(names, want_logs=False):
continue
if names and script not in names and script[:3] not in names:
continue
+ if exclude and (script in exclude or script[:3] in exclude):
+ skipped.append(script)
+ print("{0:<29} \033[90m[SKIPPED]\033[0m".format(script))
+ continue
+
count += 1
sys.stdout.write("{0:<29}".format(script) + " ")
sys.stdout.flush()
bad_file = re.sub("\.sh$",".bad", script)
+ skip_file = re.sub("\.sh$",".skipped", script)
if os.access(bad_file, os.R_OK):
os.remove(bad_file)
+ if os.access(skip_file, os.R_OK):
+ os.remove(skip_file)
ret, out, err = misc.run(['./' + script], stdout=False, can_fail=True)
if ret:
print("\033[91m[FAILED]\033[0m")
@@ -140,6 +149,11 @@ def run_bash_tests(names, want_logs=False):
print("\033[93m[WARNING]\033[0m")
with open(bad_file, 'w') as f:
f.write(out)
+ elif re.search("\[TEST SKIPPED\]", out):
+ print("\033[90m[SKIPPED]\033[0m")
+ skipped.append(script)
+ with open(skip_file, 'w') as f:
+ f.write(out)
else:
print("\033[92m[PASSED]\033[0m")
passed.append(script)
@@ -156,6 +170,10 @@ def run_bash_tests(names, want_logs=False):
print("Ran {0} tests in {1} seconds.".format(count, round(t1, 2)))
print("{0} tests PASSED: {1}".format(len(passed), ", ".join(passed)))
ret = 0
+ if len(skipped) > 0:
+ print("{0} tests SKIPPED: {1}".format(len(skipped), ", ".join(skipped)))
+ print("See files with \"skipped\" extension for output")
+
if len(failed) > 0:
print("{0} tests FAILED: {1}".format(len(failed), ", ".join(failed)))
print("See files with \"bad\" extension for output")
@@ -269,7 +287,11 @@ if __name__ == '__main__':
parser.add_argument('-l', '--logs', dest='want_logs', action='store_true',
help='if a bash test fails, print out it\'s log to stdout')
parser.add_argument('-s', '--system', dest='system', action='store_true',
- help='Test the installed version of ssm in system. Implies --bash.')
+ help='test the installed version of ssm in system. implies --bash.')
+ parser.add_argument('--skip', metavar='TEST', type=str, nargs='+',
+ help='Bash tests to to be skipped. '
+ 'Can\'t be used together with an explicit list of tests to run.'
+ 'Tests can be specified either with a full name, or by just their number.')
parser.add_argument('tests', metavar='TEST', type=str, nargs='*',
help='Specific tests to be run. For bash tests, '
'that means either a full name (001-foo.sh), '
@@ -277,10 +299,15 @@ if __name__ == '__main__':
'For unit tests, it means something like '
'BtrfsFunctionCheck.test_btrfs_resize for a specific test, '
'BtrfsFunctionCheck for specific test suite '
- 'and test_btrfs for a whole file of tests.')
+ 'and test_btrfs for a whole file of tests.'
+ 'Can\'t be used together with --skip.')
args = parser.parse_args()
+ if args.skip and args.tests:
+ print("Do not use --skip together with a list of tests to be run.")
+ sys.exit(1)
+
check_system_dependencies()
if args.system:
args.bash = True
@@ -306,5 +333,5 @@ if __name__ == '__main__':
print("\nRoot privileges required to run more tests!\n")
sys.exit(0)
print("[+] Running bash tests")
- result = run_bash_tests(names=args.tests, want_logs=args.want_logs)
+ result = run_bash_tests(names=args.tests, exclude=args.skip, want_logs=args.want_logs)
sys.exit(result)
diff --git a/tests/bashtests/016-multipath.sh b/tests/bashtests/016-multipath.sh
index a8e8855..5a43e24 100755
--- a/tests/bashtests/016-multipath.sh
+++ b/tests/bashtests/016-multipath.sh
@@ -25,11 +25,11 @@ if ! mpath_is_configured; then
echo "Multipath is not installed or configured!"
echo "If it is installed, then you need to have an empty configuration created with this:"
echo "sudo mpathconf --enable --with_multipathd y"
- exit 1
+ skip_test
fi
if [ mpath_verify -eq 0]; then
echo "This test can't be run, because there already is an existing multipath configuration."
- exit 1
+ skip_test
fi
export COLUMNS=1024
diff --git a/tests/bashtests/lib/utils.sh b/tests/bashtests/lib/utils.sh
index 5627770..7b87f89 100644
--- a/tests/bashtests/lib/utils.sh
+++ b/tests/bashtests/lib/utils.sh
@@ -205,3 +205,8 @@ if [ -n "$PREFIX" ]; then
eval "mnt$i=$mnt"
done
fi
+
+skip_test() {
+ echo "[TEST SKIPPED]"
+ exit 0
+}
--
2.21.0

View File

@ -0,0 +1,26 @@
From ee669a077d48bf1c5e3ffd8bf14b79d640055c93 Mon Sep 17 00:00:00 2001
From: Jan Tulak <jtulak@redhat.com>
Date: Tue, 23 Apr 2019 14:23:21 +0200
Subject: [PATCH 7/9] show available memory when running tests
Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
test.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/test.py b/test.py
index 9c2610e..3c8ba4f 100755
--- a/test.py
+++ b/test.py
@@ -309,6 +309,8 @@ if __name__ == '__main__':
sys.exit(1)
check_system_dependencies()
+ os.system('free -h')
+
if args.system:
args.bash = True
os.environ['SSM_TEST_SYSTEM'] = '1'
--
2.21.0

View File

@ -0,0 +1,29 @@
From 56160e073deee585ea75a2ee69b2706918430ebe Mon Sep 17 00:00:00 2001
From: Jan Tulak <jtulak@redhat.com>
Date: Tue, 23 Apr 2019 16:10:36 +0200
Subject: [PATCH 8/9] tests: 018 - remove unnecessary check for crypt
This is migrate test, not crypt test, so we don't have to test
what version of encryption was used; Hardcoded value like the removed
line leads to trouble when the system default changes.
Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
tests/bashtests/018-migrate.sh | 1 -
1 file changed, 1 deletion(-)
diff --git a/tests/bashtests/018-migrate.sh b/tests/bashtests/018-migrate.sh
index fa1a745..898f827 100755
--- a/tests/bashtests/018-migrate.sh
+++ b/tests/bashtests/018-migrate.sh
@@ -196,7 +196,6 @@ crypt_vol1=${CRYPT_VOL_PREFIX}001
passwd="cai0ohMo8M"
pass | ssm create $dev1
-check crypt_vol_field $crypt_vol1 type LUKS1
check crypt_vol_field $crypt_vol1 device $dev1
check list_table "$(ssm list vol)" $crypt_vol1 $SSM_CRYPT_DEFAULT_POOL none crypt
--
2.21.0

View File

@ -0,0 +1,76 @@
From bf5770bb1b25c35a978f446e479e12f9f6805e76 Mon Sep 17 00:00:00 2001
From: Jan Tulak <jtulak@redhat.com>
Date: Tue, 23 Apr 2019 16:15:51 +0200
Subject: [PATCH 9/9] tests: rhel8 changed default luks1 to luks2
Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
tests/bashtests/012-crypt-create.sh | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/tests/bashtests/012-crypt-create.sh b/tests/bashtests/012-crypt-create.sh
index b668339..bf39637 100755
--- a/tests/bashtests/012-crypt-create.sh
+++ b/tests/bashtests/012-crypt-create.sh
@@ -67,17 +67,17 @@ ssm remove ${DEV}/$crypt_vol1
# Create encrypted volume
pass | ssm create $dev1
-check crypt_vol_field $crypt_vol1 type LUKS1
+check crypt_vol_field $crypt_vol1 type LUKS2
check crypt_vol_field $crypt_vol1 device $dev1
check list_table "$(ssm list vol)" $crypt_vol1 $SSM_CRYPT_DEFAULT_POOL none crypt
pass | ssm create $dev2 -e
-check crypt_vol_field $crypt_vol2 type LUKS1
+check crypt_vol_field $crypt_vol2 type LUKS2
check crypt_vol_field $crypt_vol2 device $dev2
check list_table "$(ssm list vol)" $crypt_vol2 $SSM_CRYPT_DEFAULT_POOL none crypt
pass | ssm create -e luks $dev3
-check crypt_vol_field $crypt_vol3 type LUKS1
+check crypt_vol_field $crypt_vol3 type LUKS2
check crypt_vol_field $crypt_vol3 device $dev3
check list_table "$(ssm list vol)" $crypt_vol3 $SSM_CRYPT_DEFAULT_POOL none crypt
@@ -115,16 +115,16 @@ export SSM_DEFAULT_BACKEND='lvm'
# Try a short password with backend different than crypt
! echo -e "a\na" | ssm create $dev1 -e luks
-! check crypt_vol_field $crypt_vol1 type LUKS1
+! check crypt_vol_field $crypt_vol1 type LUKS2
# force it
echo -e "a\na" | ssm -f create $dev1 -e luks
-check crypt_vol_field $crypt_vol1 type LUKS1
+check crypt_vol_field $crypt_vol1 type LUKS2
ssm remove ${DEV}/$crypt_vol1
ssm -f remove $SSM_LVM_DEFAULT_POOL || true
pass | ssm create --fs $fs3 $dev1 $dev2 $mnt1 -e
check mountpoint $crypt_vol1 $mnt1
-check crypt_vol_field $crypt_vol1 type LUKS1
+check crypt_vol_field $crypt_vol1 type LUKS2
check crypt_vol_field $crypt_vol1 device ${SSM_LVM_DEFAULT_POOL}-$lvol1
check list_table "$(ssm list vol)" $crypt_vol1 $SSM_CRYPT_DEFAULT_POOL none $fs3 none none crypt
check list_table "$(ssm list vol)" $SSM_LVM_DEFAULT_POOL/$lvol1 $SSM_LVM_DEFAULT_POOL none linear
@@ -138,7 +138,7 @@ check list_table "$(ssm list vol)" $SSM_LVM_DEFAULT_POOL/$lvol2 $SSM_LVM_DEFAULT
check lv_field $SSM_LVM_DEFAULT_POOL/$lvol2 pv_count 4
pass | ssm create $dev5 -e luks
-check crypt_vol_field $crypt_vol3 type LUKS1
+check crypt_vol_field $crypt_vol3 type LUKS2
check crypt_vol_field $crypt_vol3 device ${SSM_LVM_DEFAULT_POOL}-$lvol3
check list_table "$(ssm list vol)" $crypt_vol3 $SSM_CRYPT_DEFAULT_POOL none crypt
check list_table "$(ssm list vol)" $SSM_LVM_DEFAULT_POOL/$lvol3 $SSM_LVM_DEFAULT_POOL none linear
@@ -161,7 +161,7 @@ ssm -f remove $SSM_LVM_DEFAULT_POOL
ssm create $dev1 $dev2
ssm list
pass | ssm -b crypt create $DM_DEV_DIR/$SSM_LVM_DEFAULT_POOL/$lvol1
-check crypt_vol_field $crypt_vol1 type LUKS1
+check crypt_vol_field $crypt_vol1 type LUKS2
check crypt_vol_field $crypt_vol1 device ${SSM_LVM_DEFAULT_POOL}-$lvol1
check list_table "$(ssm list vol)" $crypt_vol1 $SSM_CRYPT_DEFAULT_POOL none crypt
check list_table "$(ssm list vol)" $SSM_LVM_DEFAULT_POOL/$lvol1 $SSM_LVM_DEFAULT_POOL none linear
--
2.21.0

View File

@ -0,0 +1,102 @@
From a3419509c2f4baadd453fc650cef894a6b53329b Mon Sep 17 00:00:00 2001
From: Jan Tulak <jtulak@redhat.com>
Date: Thu, 6 Jun 2019 13:13:15 +0200
Subject: [PATCH] crypt: accept versions with -rc suffix as well
SSM crashed if cryptsetup --version produced a string like cryptsetup
1.2.3-rc0. Make sure that the -rc and similar suffixes doesn't matter.
Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
ssmlib/backends/crypt.py | 2 ++
tests/unittests/__init__.py | 3 +-
tests/unittests/test_crypt.py | 52 +++++++++++++++++++++++++++++++++++
3 files changed, 56 insertions(+), 1 deletion(-)
create mode 100644 tests/unittests/test_crypt.py
diff --git a/ssmlib/backends/crypt.py b/ssmlib/backends/crypt.py
index 8d93fe9..dd203e0 100644
--- a/ssmlib/backends/crypt.py
+++ b/ssmlib/backends/crypt.py
@@ -52,6 +52,8 @@ MAX_DEVS = 999
def get_cryptsetup_version():
try:
output = misc.run(['cryptsetup', '--version'], can_fail=True)[1]
+ # drop -rc and similar additions
+ output = re.sub(r"-.*$", '', output)
version = list(map(int, output.strip().split()[-1].split('.', 3)))
except (OSError, AttributeError):
version = [0, 0, 0]
diff --git a/tests/unittests/__init__.py b/tests/unittests/__init__.py
index 512baac..52cd1ba 100644
--- a/tests/unittests/__init__.py
+++ b/tests/unittests/__init__.py
@@ -15,4 +15,5 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-__all__ = ["test_ssm", "test_lvm", "test_btrfs", "test_misc", "test_multipath"]
+__all__ = ["test_ssm", "test_lvm", "test_btrfs", "test_misc", "test_multipath",
+ "test_crypt"]
diff --git a/tests/unittests/test_crypt.py b/tests/unittests/test_crypt.py
new file mode 100644
index 0000000..2acb58a
--- /dev/null
+++ b/tests/unittests/test_crypt.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+#
+# (C)2012 Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Unittests for the system storage manager btrfs backend
+
+
+import unittest
+from ssmlib import main
+from ssmlib import misc
+from ssmlib import problem
+from ssmlib.backends import crypt
+from tests.unittests.common import *
+from unittest.mock import MagicMock, patch
+
+IGNORE_CMDS = ['udevadm']
+
+class CryptFunctionCheck(MockSystemDataSource):
+
+ def test_get_version(self):
+ """Traceback (most recent call last):
+ File "./test.py", line 32, in <module>
+ from ssmlib import main
+ File "/var/str/source/ssmlib/main.py", line 31, in <module>
+ from ssmlib.backends import lvm, crypt, btrfs, md, multipath
+ File "/var/str/source/ssmlib/backends/crypt.py", line 60, in <module>
+ CRYPTSETUP_VERSION = get_cryptsetup_version()
+ File "/var/str/source/ssmlib/backends/crypt.py", line 55, in get_cryptsetup_version
+ version = list(map(int, output.strip().split()[-1].split('.', 3)))
+ ValueError: invalid literal for int() with base 10: '0-rc0'
+ """
+
+ mock = MagicMock(return_value=(None, "cryptsetup 1.2.3-rc0"))
+ with patch('ssmlib.misc.run', mock):
+ self.assertEqual([1, 2, 3], crypt.get_cryptsetup_version())
+
+ mock = MagicMock(return_value=(None, "cryptsetup 10.21.32"))
+ with patch('ssmlib.misc.run', mock):
+ self.assertEqual([10, 21, 32], crypt.get_cryptsetup_version())
\ No newline at end of file
--
2.21.0

View File

@ -0,0 +1,183 @@
%{!?_pkgdocdir: %global _pkgdocdir %{_docdir}/%{name}-%{version}}
Name: system-storage-manager
Version: 1.4
Release: 1%{?dist}
Summary: A single tool to manage your storage
Group: System Environment/Base
License: GPLv2+
URL: https://system-storage-manager.github.io/
Source0: https://github.com/system-storage-manager/ssm/archive/%{name}-%{version}.tar.gz
Patch1: 0001-ssm-enforce-python3.patch
Patch2: 0002-Remove-info-command-for-RHEL.patch
Patch3: 0003-unittests-better-multipath-message-on-fail.patch
Patch4: 0004-bashtests-allow-testing-of-system-wide-ssm.patch
Patch5: 0005-bashtests-remove-btrfs-tests.patch
Patch6: 0006-tests-add-bash-test-skipping-capabilities.patch
Patch7: 0007-show-available-memory-when-running-tests.patch
Patch8: 0008-tests-018-remove-unnecessary-check-for-crypt.patch
Patch9: 0009-tests-rhel8-changed-default-luks1-to-luks2.patch
Patch10: 0010-crypt-accept-versions-with-rc-suffix-as-well.patch
BuildArch: noarch
BuildRequires: python3-devel
BuildRequires: python3-sphinx
BuildRequires: python3-pwquality
Requires: util-linux
Requires: which
Requires: xfsprogs
Requires: e2fsprogs
Requires: python3-pwquality
%description
System Storage Manager provides an easy to use command line interface to manage
your storage using various technologies like lvm, btrfs, encrypted volumes and
more.
In more sophisticated enterprise storage environments, management with Device
Mapper (dm), Logical Volume Manager (LVM), or Multiple Devices (md) is becoming
increasingly more difficult. With file systems added to the mix, the number of
tools needed to configure and manage storage has grown so large that it is
simply not user friendly. With so many options for a system administrator to
consider, the opportunity for errors and problems is large.
The btrfs administration tools have shown us that storage management can be
simplified, and we are working to bring that ease of use to Linux file systems
in general.
You should install the ssm if you need to manage your storage with various
technologies via a single unified interface.
%prep
%setup -q -n ssm-%{name}-%{version}
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%build
make docs
%install
rm -rf ${RPM_BUILD_ROOT}
%{__python3} setup.py install --root=${RPM_BUILD_ROOT}
if [ "%{_pkgdocdir}" != "%{_docdir}/%{name}-%{version}" ]; then
mv ${RPM_BUILD_ROOT}/{%{_docdir}/%{name}-%{version},%{_pkgdocdir}}
fi
%check
# run unit tests, these have to pass
%{__python3} test.py -u
%files
%{_bindir}/ssm
%{_pkgdocdir}/
%{_mandir}/man8/ssm.8*
%{python3_sitelib}/ssmlib/
%{python3_sitelib}/*.egg-info
%changelog
*Wed Jun 5 2019 Jan Tulak <jtulak@redhat.com> - 1.4-1:
- Bring changes from upstream 1.4 (mostly bugfixes)
- Remove multipath from the list of default backends (rhbz#1685019)
- Fix locale issue (rhbz#1679587)
*Fri Feb 15 2019 Jan Tulak <jtulak@redhat.com> - 1.2-3:
- Gating tests implementation, which meant adding few more changes
to the existing patches (#1681969)
- sphinx patch was merged to python3 change
- add seq numbers to patch files
*Fri Feb 15 2019 Jan Tulak <jtulak@redhat.com> - 1.2-2:
- fix poor luks password leads to ssm crash (rhbz#1670714)
* Sun Aug 12 2018 Jan Tulak <jtulak@redhat.com> - 1.2-1
- Upstream release 1.2 which fixes:
- use pwquality to test password strength for cryptsetup (#1141871)
- add multipath detection support (#1309729)
- add migrate command (#1014708)
* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.5-1
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
* Mon Oct 30 2017 Jan Tulak <jtulak@redhat.com> - 0.5-0
- New upstream stable version 0.5
* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.4-14
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.4-13
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
* Mon Dec 19 2016 Miro Hrončok <mhroncok@redhat.com> - 0.4-12
- Rebuild for Python 3.6
* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.4-11
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages
* Fri Feb 05 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.4-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
* Tue Nov 10 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.4-9
- Rebuilt for https://fedoraproject.org/wiki/Changes/python3.5
* Mon Jul 27 2015 Lukas Czerner <lczerner@redhat.com> 0.4-7
- Big upstream update
- Python3 support (#1239016)
- Error out if file system is not supported (#1196428)
* Fri Jun 19 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.4-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild
* Sun Jun 08 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.4-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild
* Mon Jan 20 2014 Lukas Czerner <lczerner@redhat.com> 0.4-4
- Update to a new upstream release v0.4
- Remove btrfs resize support
- Unmount all btrfs subvolumes when removing a filesystem
- Fix size argument parsing for create and snapshot command
- Fix list output for some cases
- Add support to create encrypted volumes with crypt backend
- Add dry-run option
- Fix removing volumes with crypt backend
- Add raid1 and raid10 support for lvm backend
- Allow to check btrfs volumes
- Fix error handling when trying to resize btrfs subvolume
- Fix ssm mount command so it detects directory properly
- Suppress backtrace when a command fails
- Fix ssm to recognize units in new btrfs output properly
- Use correct sysfs file to get size for a partition
- Fix ssm to be able add a device with signature to btrfs file system
- Resognize btrfs devices from new btrfs output properly
* Mon Dec 16 2013 Ville Skyttä <ville.skytta@iki.fi> - 0.2-4
- Install docs to %%{_pkgdocdir} where available (#994122).
* Sun Aug 04 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.2-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild
* Fri Feb 15 2013 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_19_Mass_Rebuild
* Fri Jun 1 2012 Lukas Czerner <lczerner@redhat.com> 0.2-1
- Initial version of the package