diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/.gitignore | 4 | ||||
-rw-r--r-- | test/Makefile.in | 165 | ||||
-rw-r--r-- | test/api/Makefile.in | 61 | ||||
-rw-r--r-- | test/api/lvtest.c | 64 | ||||
-rw-r--r-- | test/api/lvtest.sh | 21 | ||||
-rw-r--r-- | test/api/pe_start.c | 47 | ||||
-rw-r--r-- | test/api/pe_start.sh | 21 | ||||
-rw-r--r-- | test/api/percent.c | 23 | ||||
-rw-r--r-- | test/api/percent.sh | 20 | ||||
-rw-r--r-- | test/api/test.c | 20 | ||||
-rw-r--r-- | test/api/thin_percent.c | 68 | ||||
-rw-r--r-- | test/api/thin_percent.sh | 37 | ||||
-rw-r--r-- | test/api/vgtest.sh | 10 | ||||
-rw-r--r-- | test/check.sh | 198 | ||||
-rw-r--r-- | test/harness.c | 221 | ||||
-rw-r--r-- | test/harness.sh | 50 | ||||
-rw-r--r-- | test/lib/aux.sh | 551 | ||||
-rw-r--r-- | test/lib/check.sh | 282 | ||||
-rw-r--r-- | test/lib/get.sh | 45 | ||||
-rw-r--r-- | test/lib/harness.c | 393 | ||||
-rw-r--r-- | test/lib/lvm-wrapper.sh | 32 | ||||
-rw-r--r-- | test/lib/not.c (renamed from test/not.c) | 3 | ||||
-rw-r--r-- | test/lib/test.sh | 79 | ||||
-rw-r--r-- | test/lib/utils.sh | 215 | ||||
-rw-r--r-- | test/lvm-utils.sh | 153 | ||||
-rwxr-xr-x | test/mkdtemp | 120 | ||||
-rw-r--r--[-rwxr-xr-x] | test/shell/000-basic.sh (renamed from test/t-000-basic.sh) | 15 | ||||
-rw-r--r-- | test/shell/activate-minor.sh | 19 | ||||
-rw-r--r-- | test/shell/activate-missing-segment.sh | 29 | ||||
-rw-r--r-- | test/shell/activate-missing.sh (renamed from test/t-activate-missing.sh) | 35 | ||||
-rw-r--r-- | test/shell/activate-partial.sh (renamed from test/t-activate-partial.sh) | 5 | ||||
-rw-r--r-- | test/shell/clvmd-restart.sh | 53 | ||||
-rw-r--r-- | test/shell/covercmd.sh | 102 | ||||
-rw-r--r-- | test/shell/discards-thin.sh | 50 | ||||
-rw-r--r-- | test/shell/dmeventd-restart.sh (renamed from test/t-dmeventd-restart.sh) | 35 | ||||
-rw-r--r-- | test/shell/dumpconfig.sh | 45 | ||||
-rw-r--r-- | test/shell/fsadm.sh | 160 | ||||
-rw-r--r-- | test/shell/inconsistent-metadata.sh | 80 | ||||
-rw-r--r-- | test/shell/listings.sh (renamed from test/t-listings.sh) | 62 | ||||
-rw-r--r-- | test/shell/lock-blocking.sh (renamed from test/t-lock-blocking.sh) | 21 | ||||
-rw-r--r-- | test/shell/lvchange-mirror.sh (renamed from test/t-lvchange-mirror.sh) | 16 | ||||
-rw-r--r-- | test/shell/lvchange-partial.sh | 66 | ||||
-rw-r--r-- | test/shell/lvconvert-mirror-basic-0.sh (renamed from test/t-lvconvert-mirror-basic-0.sh) | 3 | ||||
-rw-r--r-- | test/shell/lvconvert-mirror-basic-1.sh (renamed from test/t-lvconvert-mirror-basic-1.sh) | 3 | ||||
-rw-r--r-- | test/shell/lvconvert-mirror-basic-2.sh (renamed from test/t-lvconvert-mirror-basic-2.sh) | 3 | ||||
-rw-r--r-- | test/shell/lvconvert-mirror-basic-3.sh (renamed from test/t-lvconvert-mirror-basic-3.sh) | 3 | ||||
-rw-r--r-- | test/shell/lvconvert-mirror-basic.sh (renamed from test/t-lvconvert-mirror-basic.sh) | 64 | ||||
-rw-r--r-- | test/shell/lvconvert-mirror.sh | 280 | ||||
-rw-r--r-- | test/shell/lvconvert-raid.sh | 223 | ||||
-rw-r--r-- | test/shell/lvconvert-raid10.sh | 56 | ||||
-rw-r--r-- | test/shell/lvconvert-repair-dmeventd.sh (renamed from test/t-lvconvert-repair-dmeventd.sh) | 16 | ||||
-rw-r--r-- | test/shell/lvconvert-repair-policy.sh (renamed from test/t-lvconvert-repair-policy.sh) | 61 | ||||
-rw-r--r-- | test/shell/lvconvert-repair-replace.sh | 92 | ||||
-rw-r--r-- | test/shell/lvconvert-repair-snapshot.sh | 27 | ||||
-rw-r--r-- | test/shell/lvconvert-repair-transient-dmeventd.sh | 29 | ||||
-rw-r--r-- | test/shell/lvconvert-repair-transient.sh (renamed from test/t-lvconvert-repair-transient.sh) | 20 | ||||
-rw-r--r-- | test/shell/lvconvert-repair.sh | 140 | ||||
-rw-r--r-- | test/shell/lvconvert-thin.sh | 43 | ||||
-rw-r--r-- | test/shell/lvconvert-twostep.sh (renamed from test/t-lvconvert-twostep.sh) | 15 | ||||
-rw-r--r-- | test/shell/lvcreate-large-raid.sh | 71 | ||||
-rw-r--r-- | test/shell/lvcreate-large-raid10.sh | 40 | ||||
-rw-r--r-- | test/shell/lvcreate-large.sh | 40 | ||||
-rw-r--r-- | test/shell/lvcreate-mirror.sh (renamed from test/t-lvcreate-mirror.sh) | 18 | ||||
-rw-r--r-- | test/shell/lvcreate-operation.sh (renamed from test/t-lvcreate-operation.sh) | 21 | ||||
-rw-r--r--[-rwxr-xr-x] | test/shell/lvcreate-pvtags.sh (renamed from test/t-lvcreate-pvtags.sh) | 16 | ||||
-rw-r--r-- | test/shell/lvcreate-raid.sh | 49 | ||||
-rw-r--r-- | test/shell/lvcreate-raid10.sh | 42 | ||||
-rw-r--r-- | test/shell/lvcreate-repair.sh | 99 | ||||
-rw-r--r-- | test/shell/lvcreate-small-snap.sh (renamed from test/t-lvcreate-small-snap.sh) | 6 | ||||
-rw-r--r-- | test/shell/lvcreate-striped-mirror.sh | 65 | ||||
-rw-r--r-- | test/shell/lvcreate-thin-power2.sh | 39 | ||||
-rw-r--r-- | test/shell/lvcreate-thin-snap.sh | 57 | ||||
-rw-r--r-- | test/shell/lvcreate-thin.sh | 211 | ||||
-rw-r--r--[-rwxr-xr-x] | test/shell/lvcreate-usage.sh (renamed from test/t-lvcreate-usage.sh) | 63 | ||||
-rw-r--r--[-rwxr-xr-x] | test/shell/lvextend-percent-extents.sh (renamed from test/t-lvextend-percent-extents.sh) | 67 | ||||
-rw-r--r-- | test/shell/lvextend-snapshot-dmeventd.sh | 61 | ||||
-rw-r--r-- | test/shell/lvextend-snapshot-policy.sh (renamed from test/t-lvextend-snapshot-policy.sh) | 32 | ||||
-rw-r--r-- | test/shell/lvm-init.sh (renamed from test/t-lvm-init.sh) | 4 | ||||
-rw-r--r--[-rwxr-xr-x] | test/shell/lvmcache-exercise.sh (renamed from test/t-lvmcache-exercise.sh) | 14 | ||||
-rw-r--r-- | test/shell/lvmetad-disabled.sh | 26 | ||||
-rw-r--r-- | test/shell/lvmetad-dump.sh | 38 | ||||
-rw-r--r-- | test/shell/lvmetad-lvm1.sh | 22 | ||||
-rw-r--r-- | test/shell/lvmetad-pvs.sh | 19 | ||||
-rw-r--r-- | test/shell/lvmetad-pvscan-cache.sh | 23 | ||||
-rw-r--r-- | test/shell/lvmetad-restart.sh | 23 | ||||
-rw-r--r-- | test/shell/lvmetad-test.sh | 34 | ||||
-rw-r--r-- | test/shell/lvmetad-warning.sh | 27 | ||||
-rw-r--r-- | test/shell/lvresize-mirror.sh (renamed from test/t-lvresize-mirror.sh) | 19 | ||||
-rw-r--r-- | test/shell/lvresize-raid.sh | 80 | ||||
-rw-r--r-- | test/shell/lvresize-raid10.sh | 46 | ||||
-rw-r--r-- | test/shell/lvresize-rounding.sh | 90 | ||||
-rw-r--r--[-rwxr-xr-x] | test/shell/lvresize-usage.sh (renamed from test/t-lvresize-usage.sh) | 3 | ||||
-rw-r--r-- | test/shell/mdata-strings.sh | 38 | ||||
-rw-r--r-- | test/shell/metadata-balance.sh | 232 | ||||
-rw-r--r-- | test/shell/metadata-dirs.sh | 43 | ||||
-rw-r--r--[-rwxr-xr-x] | test/shell/metadata.sh (renamed from test/t-metadata.sh) | 66 | ||||
-rw-r--r-- | test/shell/mirror-names.sh | 132 | ||||
-rw-r--r--[-rwxr-xr-x] | test/shell/mirror-vgreduce-removemissing.sh (renamed from test/t-mirror-vgreduce-removemissing.sh) | 338 | ||||
-rw-r--r-- | test/shell/name-mangling.sh | 231 | ||||
-rw-r--r-- | test/shell/nomda-missing.sh (renamed from test/t-nomda-missing.sh) | 40 | ||||
-rw-r--r--[-rwxr-xr-x] | test/shell/pool-labels.sh (renamed from test/t-pool-labels.sh) | 11 | ||||
-rw-r--r-- | test/shell/pv-duplicate.sh | 25 | ||||
-rw-r--r-- | test/shell/pv-min-size.sh | 31 | ||||
-rw-r--r--[-rwxr-xr-x] | test/shell/pv-range-overflow.sh (renamed from test/t-pv-range-overflow.sh) | 10 | ||||
-rw-r--r-- | test/shell/pvchange-usage.sh | 65 | ||||
-rw-r--r--[-rwxr-xr-x] | test/shell/pvcreate-metadata0.sh (renamed from test/t-pvcreate-metadata0.sh) | 14 | ||||
-rw-r--r-- | test/shell/pvcreate-operation-md.sh (renamed from test/t-pvcreate-operation-md.sh) | 96 | ||||
-rw-r--r-- | test/shell/pvcreate-operation.sh | 130 | ||||
-rw-r--r--[-rwxr-xr-x] | test/shell/pvcreate-usage.sh (renamed from test/t-pvcreate-usage.sh) | 159 | ||||
-rw-r--r-- | test/shell/pvmove-basic.sh | 383 | ||||
-rw-r--r--[-rwxr-xr-x] | test/shell/pvremove-usage.sh (renamed from test/t-pvremove-usage.sh) | 56 | ||||
-rw-r--r--[-rwxr-xr-x] | test/shell/read-ahead.sh (renamed from test/t-read-ahead.sh) | 45 | ||||
-rw-r--r-- | test/shell/snapshot-autoumount-dmeventd.sh | 45 | ||||
-rw-r--r--[-rwxr-xr-x] | test/shell/snapshot-merge.sh (renamed from test/t-snapshot-merge.sh) | 68 | ||||
-rw-r--r-- | test/shell/snapshots-of-mirrors.sh (renamed from test/t-snapshots-of-mirrors.sh) | 12 | ||||
-rw-r--r--[-rwxr-xr-x] | test/shell/tags.sh (renamed from test/t-tags.sh) | 57 | ||||
-rw-r--r-- | test/shell/test-partition.sh (renamed from test/t-test-partition.sh) | 11 | ||||
-rw-r--r-- | test/shell/thin-autoumount-dmeventd.sh | 70 | ||||
-rw-r--r-- | test/shell/topology-support.sh (renamed from test/t-topology-support.sh) | 67 | ||||
-rw-r--r-- | test/shell/unknown-segment.sh (renamed from test/t-unknown-segment.sh) | 2 | ||||
-rw-r--r-- | test/shell/unlost-pv.sh (renamed from test/t-unlost-pv.sh) | 38 | ||||
-rw-r--r-- | test/shell/vgcfgbackup-usage.sh (renamed from test/t-vgcfgbackup-usage.sh) | 39 | ||||
-rw-r--r-- | test/shell/vgchange-maxlv.sh (renamed from test/t-vgchange-maxlv.sh) | 11 | ||||
-rw-r--r-- | test/shell/vgchange-partial.sh | 52 | ||||
-rw-r--r-- | test/shell/vgchange-sysinit.sh | 51 | ||||
-rw-r--r-- | test/shell/vgchange-usage.sh (renamed from test/t-vgchange-usage.sh) | 26 | ||||
-rw-r--r-- | test/shell/vgcreate-usage.sh | 163 | ||||
-rw-r--r-- | test/shell/vgextend-restoremissing.sh (renamed from test/t-vgextend-restoremissing.sh) | 14 | ||||
-rw-r--r-- | test/shell/vgextend-usage.sh | 130 | ||||
-rw-r--r-- | test/shell/vgimportclone.sh | 39 | ||||
-rw-r--r-- | test/shell/vgmerge-operation.sh | 79 | ||||
-rw-r--r-- | test/shell/vgmerge-usage.sh | 67 | ||||
-rw-r--r-- | test/shell/vgreduce-removemissing-snapshot.sh | 35 | ||||
-rw-r--r--[-rwxr-xr-x] | test/shell/vgreduce-usage.sh (renamed from test/t-vgreduce-usage.sh) | 70 | ||||
-rw-r--r--[-rwxr-xr-x] | test/shell/vgrename-usage.sh (renamed from test/t-vgrename-usage.sh) | 27 | ||||
-rw-r--r-- | test/shell/vgsplit-operation.sh | 294 | ||||
-rw-r--r-- | test/shell/vgsplit-stacked.sh (renamed from test/t-vgsplit-stacked.sh) | 17 | ||||
-rw-r--r-- | test/shell/vgsplit-usage.sh | 168 | ||||
-rwxr-xr-x | test/t-covercmd.sh | 82 | ||||
-rw-r--r-- | test/t-fsadm.sh | 123 | ||||
-rw-r--r-- | test/t-inconsistent-metadata.sh | 75 | ||||
-rw-r--r-- | test/t-lvconvert-mirror.sh | 242 | ||||
-rw-r--r-- | test/t-lvconvert-repair-replace.sh | 61 | ||||
-rw-r--r-- | test/t-lvconvert-repair.sh | 89 | ||||
-rw-r--r-- | test/t-lvextend-snapshot-dmeventd.sh | 51 | ||||
-rwxr-xr-x | test/t-mdata-strings.sh | 33 | ||||
-rwxr-xr-x | test/t-metadata-balance.sh | 232 | ||||
-rw-r--r-- | test/t-mirror-names.sh | 156 | ||||
-rwxr-xr-x | test/t-pvchange-usage.sh | 66 | ||||
-rwxr-xr-x | test/t-pvcreate-operation.sh | 121 | ||||
-rwxr-xr-x | test/t-pvmove-basic.sh | 374 | ||||
-rw-r--r-- | test/t-snapshot-autoumount-dmeventd.sh | 41 | ||||
-rwxr-xr-x | test/t-vgcreate-usage.sh | 163 | ||||
-rw-r--r-- | test/t-vgextend-usage.sh | 129 | ||||
-rwxr-xr-x | test/t-vgmerge-operation.sh | 81 | ||||
-rwxr-xr-x | test/t-vgmerge-usage.sh | 73 | ||||
-rwxr-xr-x | test/t-vgsplit-operation.sh | 290 | ||||
-rwxr-xr-x | test/t-vgsplit-usage.sh | 187 | ||||
-rw-r--r-- | test/test-utils.sh | 457 | ||||
-rw-r--r-- | test/unit/Makefile.in | 33 | ||||
-rw-r--r-- | test/unit/bitset_t.c | 133 | ||||
-rw-r--r-- | test/unit/config_t.c | 156 | ||||
-rw-r--r-- | test/unit/matcher_data.h | 1013 | ||||
-rw-r--r-- | test/unit/matcher_t.c | 85 | ||||
-rw-r--r-- | test/unit/run.c | 29 | ||||
-rw-r--r-- | test/unit/string_t.c | 83 |
166 files changed, 9733 insertions, 4961 deletions
diff --git a/test/.gitignore b/test/.gitignore deleted file mode 100644 index 2351bfc..0000000 --- a/test/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -.bin-dir-stamp -Makefile -bin -init.sh diff --git a/test/Makefile.in b/test/Makefile.in index 86542c1..5bbd1d6 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -1,4 +1,4 @@ -# Copyright (C) 2007-2010 Red Hat, Inc. All rights reserved. +# Copyright (C) 2007-2012 Red Hat, Inc. All rights reserved. # # This file is part of LVM2. # @@ -12,119 +12,130 @@ #TEST_OPTS=--verbose --debug SHELL_PATH ?= $(SHELL) -TAR ?= $(TAR) RM ?= rm -f -subdir := $(shell pwd|sed 's,.*/,,') +subdir = $(shell pwd|sed 's,.*/,,') srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ -abs_srcdir = @abs_srcdir@ -abs_builddir = @abs_builddir@ -abs_top_builddir = @abs_top_builddir@ -abs_top_srcdir = @abs_top_srcdir@ +abs_srcdir = "@abs_srcdir@" +abs_builddir = "@abs_builddir@" +abs_top_builddir = "@abs_top_builddir@" +abs_top_srcdir = "@abs_top_srcdir@" + +SUBDIRS = api unit +SOURCES = lib/not.c lib/harness.c + +include $(top_builddir)/make.tmpl T ?= . S ?= @ # never match anything by default VERBOSE ?= 0 -RUN = $(shell find $(srcdir) -regextype posix-egrep \( -name t-\*.sh -or -path */api/\*.sh \) -and -regex "$(srcdir)/.*($(T)).*" -and -not -regex "$(srcdir)/.*($(S)).*" | sort) -RUN_BASE = $(shell echo $(RUN) | xargs -n 1 echo | sed -e s,^$(srcdir)/,,) +ALL = $(shell find $(srcdir) \( -path \*/shell/\*.sh -or -path \*/api/\*.sh \) | sort) +RUN = $(shell find $(srcdir) -regextype posix-egrep \( -path \*/shell/\*.sh -or -path \*/api/\*.sh \) -and -regex "$(srcdir)/.*($(T)).*" -and -not -regex "$(srcdir)/.*($(S)).*" | sort) +RUN_BASE = $(subst $(srcdir)/,,$(RUN)) # Shell quote; SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) -SUPPORT := $(srcdir)/test-utils.sh \ - $(srcdir)/lvm-utils.sh - ifeq ("@UDEV_SYNC@", "yes") dm_udev_synchronisation = 1 endif -all check: init.sh - make -C api tests - @echo Testing with locking_type 1 - VERBOSE=$(VERBOSE) ./bin/harness $(RUN_BASE) - @echo Testing with locking_type 3 - VERBOSE=$(VERBOSE) LVM_TEST_LOCKING=3 ./bin/harness $(RUN_BASE) - -check_cluster: init.sh - make -C api tests +all: check + +help: + @echo -e "\nAvailable targets:" + @echo " all Default target, run check." + @echo " check Run all tests." + @echo " check_local Run tests without clvmd and lvmetad." + @echo " check_cluster Run tests with cluster daemon." + @echo " check_lvmetad Run tests with lvmetad daemon." + @echo " clean Clean dir." + @echo " help Display callable targets." + @echo -e "\nSupported variables:" + @echo " LVM_TEST_DEVDIR Set to '/dev' to run on real /dev." + @echo " LVM_TEST_DIR Where to create test files [TMPDIR]." + @echo " LVM_TEST_LOCKING Normal (1), Cluster (3)." + @echo " LVM_TEST_LVMETAD Start lvmetad (1)." + @echo " LVM_TEST_NODEBUG Do not debug lvm commands." + @echo " LVM_TEST_PARALLEL May skip agresive wipe of LVMTEST resources." + @echo " LVM_VERIFY_UDEV Default verify state for lvm.conf." + @echo " S Skip given test (regex)." + @echo " T Run given test (regex)." + @echo " VERBOSE Verbose output (1), timing (2)." + +check: check_local check_cluster check_lvmetad + +check_cluster: .tests-stamp @echo Testing with locking_type 3 - VERBOSE=$(VERBOSE) LVM_TEST_LOCKING=3 ./bin/harness $(RUN_BASE) + VERBOSE=$(VERBOSE) LVM_TEST_LOCKING=3 ./lib/harness $(RUN_BASE) -check_local: init.sh - make -C api tests +check_local: .tests-stamp @echo Testing with locking_type 1 - VERBOSE=$(VERBOSE) LVM_TEST_LOCKING=1 ./bin/harness $(RUN_BASE) + VERBOSE=$(VERBOSE) LVM_TEST_LOCKING=1 ./lib/harness $(RUN_BASE) + +check_lvmetad: .tests-stamp + @echo Testing with lvmetad on + VERBOSE=$(VERBOSE) LVM_TEST_LVMETAD=1 ./lib/harness $(RUN_BASE) -bin/not: $(srcdir)/not.c .bin-dir-stamp - $(CC) -o bin/not $< - ln -sf not bin/should +lib/should: lib/not + ln -sf not lib/should -bin/harness: $(srcdir)/harness.c .bin-dir-stamp - $(CC) -o bin/harness $< +lib/%: lib/%.o .lib-dir-stamp + $(CC) $(LDFLAGS) -o $@ $< -bin/check: $(srcdir)/check.sh .bin-dir-stamp - cp $< bin/check - chmod +x bin/check +lib/%: $(srcdir)/lib/%.sh .lib-dir-stamp + cp $< $@ + chmod +x $@ -init.sh: $(srcdir)/Makefile.in .bin-dir-stamp bin/not bin/check bin/harness $(RUN) $(SUPPORT) $(UNIT) - rm -f $@-t $@ +lib/paths: $(srcdir)/Makefile.in .lib-dir-stamp + $(RM) $@-t echo 'top_srcdir=$(top_srcdir)' >> $@-t echo 'abs_top_builddir=$(abs_top_builddir)' >> $@-t - echo 'abs_top_srcdir=$(abs_top_builddir)' >> $@-t - echo 'PATH=$$abs_top_builddir/test/bin:$$PATH' >> $@-t - LDLPATH="\$$abs_top_builddir/libdm"; \ - LDLPATH="$$LDLPATH:\$$abs_top_builddir/tools"; \ - LDLPATH="$$LDLPATH:\$$abs_top_builddir/liblvm"; \ - LDLPATH="$$LDLPATH:\$$abs_top_builddir/daemons/dmeventd"; \ - LDLPATH="$$LDLPATH:\$$abs_top_builddir/daemons/dmeventd/plugins/lvm2"; \ - LDLPATH="$$LDLPATH:\$$abs_top_builddir/daemons/dmeventd/plugins/mirror"; \ - LDLPATH="$$LDLPATH:\$$abs_top_builddir/daemons/dmeventd/plugins/snapshot"; \ - echo "export LD_LIBRARY_PATH=\"$$LDLPATH\"" >> $@-t - echo 'top_srcdir=$(top_srcdir)' >> $@-t + echo 'abs_top_srcdir=$(abs_top_srcdir)' >> $@-t echo 'abs_srcdir=$(abs_srcdir)' >> $@-t echo 'abs_builddir=$(abs_builddir)' >> $@-t - echo 'export PATH' >> $@-t echo 'export DM_UDEV_SYNCHRONISATION=$(dm_udev_synchronisation)' >> $@-t - chmod a-w $@-t + echo 'export THIN=@THIN@' >> $@-t + echo 'export LVMETAD_PIDFILE=@LVMETAD_PIDFILE@' >> $@-t mv $@-t $@ - @if test "$(srcdir)" != . ; then \ - echo "Copying tests to builddir."; \ - cp $(SUPPORT) .; \ - for f in $(RUN); do cp $$f `echo $$f | sed -e s,^$(srcdir)/,,`; done; \ - fi -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +LIB = lib/not lib/should lib/harness \ + lib/check lib/aux lib/test lib/utils lib/get lib/lvm-wrapper \ + lib/paths + +CMDS = lvm $(shell cat $(top_builddir)/tools/.commands) -.bin-dir-stamp: lvm-wrapper - rm -rf bin - mkdir bin - for i in lvm $$(cat ../tools/.commands); do \ - ln -s ../lvm-wrapper bin/$$i; \ - done - ln -s "$(abs_top_builddir)/tools/dmsetup" bin/dmsetup - ln -s "$(abs_top_builddir)/daemons/clvmd/clvmd" bin/clvmd - ln -s "$(abs_top_builddir)/daemons/dmeventd/dmeventd" bin/dmeventd +.tests-stamp: $(ALL) $(LIB) $(SUBDIRS) + @if test "$(srcdir)" != . ; then \ + echo "Linking tests to builddir."; \ + $(MKDIR_P) shell; \ + for f in $(subst $(srcdir)/,,$(ALL)); do \ + ln -sf $(abs_top_srcdir)/test/$$f $$f; \ + done; \ + fi touch $@ -lvm-wrapper: Makefile - rm -f $@-t $@ - echo '#!/bin/sh' > $@-t - echo 'cmd=$$(echo ./$$0|sed "s,.*/,,")' >> $@-t - echo 'test "$$cmd" = lvm &&' >> $@-t - echo 'exec "$(abs_top_builddir)/tools/lvm" "$$@"' >> $@-t - echo 'exec "$(abs_top_builddir)/tools/lvm" "$$cmd" "$$@"' >> $@-t - chmod a-w,a+x $@-t - mv $@-t $@ +.lib-dir-stamp: + $(MKDIR_P) lib + for i in $(CMDS); do ln -fs lvm-wrapper lib/$$i; done + ln -fs $(abs_top_builddir)/tools/dmsetup lib/dmsetup + ln -fs $(abs_top_builddir)/daemons/clvmd/clvmd lib/clvmd + ln -fs $(abs_top_builddir)/daemons/dmeventd/dmeventd lib/dmeventd + ln -fs $(abs_top_builddir)/daemons/lvmetad/lvmetad lib/lvmetad + ln -fs $(abs_top_srcdir)/scripts/vgimportclone.sh lib/vgimportclone + ln -fs $(abs_top_srcdir)/scripts/fsadm.sh lib/fsadm + touch $@ clean: - rm -rf init.sh lvm-wrapper bin .bin-dir-stamp - if test "$(srcdir)" != . ; then rm -f $(subst $(srcdir)/, ,$(RUN)) lvm2app.sh ; fi + test "$(srcdir)" = . || $(RM) $(RUN_BASE) + +CLEAN_TARGETS += .lib-dir-stamp .tests-stamp $(LIB) $(addprefix lib/,$(CMDS)) \ + lib/clvmd lib/dmeventd lib/dmsetup lib/lvmetad lib/fsadm lib/vgimportclone -distclean: clean - rm -f Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ .NOTPARALLEL: diff --git a/test/api/Makefile.in b/test/api/Makefile.in index b3fb751..7ad6743 100644 --- a/test/api/Makefile.in +++ b/test/api/Makefile.in @@ -1,5 +1,5 @@ # -# Copyright (C) 2009 Red Hat, Inc. All rights reserved. +# Copyright (C) 2009-2012 Red Hat, Inc. All rights reserved. # # This file is part of LVM2. # @@ -15,47 +15,46 @@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ -ifeq ("@DEBUG@", "yes") - DEFS += -DDEBUG -endif - -TARGETS = -test_SOURCES = test.c -wrapper_SOURCES = test.c -INCLUDES += -I../../include - -UNIT = vgtest.t percent.t +TARGETS = +ifeq ("@APPLIB@", "yes") +TARGETS += test +SOURCES = test.c + +TARGETS += \ + lvtest.t \ + percent.t \ + pe_start.t \ + thin_percent.t \ + vgtest.t + +SOURCES2 = \ + lvtest.c \ + percent.c \ + pe_start.c \ + thin_percent.c \ + vgtest.c -LVMLIBS = @LVM2APP_LIB@ -ldevmapper -DEPLIBS = $(top_builddir)/liblvm/liblvm2app.so $(top_builddir)/libdm/libdevmapper.so - -DEFS += -D_REENTRANT +endif include $(top_builddir)/make.tmpl -LDFLAGS = -L$(top_builddir)/libdm -L$(top_builddir)/liblvm +DEFS += -D_REENTRANT +DEPLIBS += $(top_builddir)/liblvm/liblvm2app.so $(top_builddir)/libdm/libdevmapper.so +LDFLAGS += -L$(top_builddir)/liblvm +LVMLIBS = @LVM2APP_LIB@ -ldevmapper ifeq ("@DMEVENTD@", "yes") - LVMLIBS += -ldevmapper-event - LDFLAGS += -L$(top_builddir)/daemons/dmeventd + LVMLIBS += -ldevmapper-event + LDFLAGS += -L$(top_builddir)/daemons/dmeventd endif -test_OBJECTS = $(test_SOURCES:.c=.o) -wrapper_OBJECTS = $(wrapper_SOURCES:.c=.o) -OBJECTS = $(test_OBJECTS) - -all: tests test - -tests: $(UNIT) - -test: $(test_OBJECTS) $(DEPLIBS) - $(CC) -o test $(test_OBJECTS) $(CFLAGS) $(LDFLAGS) $(LVMLIBS) $(LIBS) $(READLINE_LIBS) +LVMLIBS += $(LIBS) %.t: %.o $(DEPLIBS) - $(CC) -o $@ $(<) $(CFLAGS) $(LDFLAGS) $(LVMLIBS) $(LIBS) + $(CC) -o $@ $(<) $(LDFLAGS) $(LVMLIBS) -wrapper: $(wrapper_OBJECTS) $(DEPLIBS) - $(CC) -o wrapper $(wrapper_OBJECTS) $(CFLAGS) $(LDFLAGS) $(LVMLIBS) $(LIBS) -lreadline +test: $(OBJECTS) $(DEPLIBS) + $(CC) -o $@ $(OBJECTS) $(LDFLAGS) $(LVMLIBS) $(READLINE_LIBS) Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) && $(SHELL) ./config.status test/api/Makefile diff --git a/test/api/lvtest.c b/test/api/lvtest.c new file mode 100644 index 0000000..c0fee65 --- /dev/null +++ b/test/api/lvtest.c @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2010 Red Hat, Inc. All rights reserved. + * + * This file is part of LVM2. + * + * 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 Lesser General Public License v.2.1. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#undef NDEBUG + +#include "lvm2app.h" +#include "assert.h" + +#define err(args...) \ + do { fprintf(stderr, args); goto bad; } while (0) + +int main(int argc, char *argv[]) +{ + lvm_t handle; + vg_t vg; + lv_t lv; + int r = -1; + + if (!(handle = lvm_init(NULL))) + return -1; + + if (!(vg = lvm_vg_open(handle, argv[1], "w", 0))) + err("VG open %s failed.\n", argv[1]); + + if (!(lv = lvm_lv_from_name(vg, "test"))) + err("LV test not found.\n"); + + if (lvm_lv_deactivate(lv)) + err("LV test deactivation failed.\n"); + + if (lvm_lv_activate(lv)) + err("LV test activation failed.\n"); + + if (lvm_lv_activate(lv)) + err("LV test repeated activation failed.\n"); + + if (lvm_lv_rename(lv, "test1")) + err("LV test rename to test1 failed.\n"); + + if (lvm_lv_rename(lv, "test2")) + err("LV test1 rename to test2 failed.\n"); + + if (lvm_lv_rename(lv, "test")) + err("LV test2 rename to test failed.\n"); + + if (lvm_vg_close(vg)) + err("VG close failed.\n"); + + r = 0; +bad: + lvm_quit(handle); + return r; +} diff --git a/test/api/lvtest.sh b/test/api/lvtest.sh new file mode 100644 index 0000000..0b7684a --- /dev/null +++ b/test/api/lvtest.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# Copyright (C) 2011 Red Hat, Inc. All rights reserved. +# +# This file is part of LVM2. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +aux prepare_vg 1 + +lvcreate -n test -l 5 $vg +aux apitest lvtest $vg + +check lv_field $vg/test lv_name test diff --git a/test/api/pe_start.c b/test/api/pe_start.c new file mode 100644 index 0000000..129f8a2 --- /dev/null +++ b/test/api/pe_start.c @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2011 Red Hat, Inc. All rights reserved. + * + * This file is part of LVM2. + * + * 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 Lesser General Public License v.2.1. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#undef NDEBUG + +#include "lvm2app.h" +#include "assert.h" + +int main(int argc, char *argv[]) +{ + lvm_t handle; + vg_t vg = NULL; + pv_t pv; + struct lvm_property_value v; + + handle = lvm_init(NULL); + assert(handle); + + vg = lvm_vg_create(handle, argv[1]); + assert(vg); + + if (lvm_vg_extend(vg, argv[2])) + abort(); + + pv = lvm_pv_from_name(vg, argv[2]); + assert(pv); + + v = lvm_pv_get_property(pv, "pe_start"); + assert(v.is_valid); + fprintf(stderr, "pe_start = %d\n", (int)v.value.integer); + assert(v.value.integer == 2048 * 512); + + lvm_vg_close(vg); + lvm_quit(handle); + return 0; +} diff --git a/test/api/pe_start.sh b/test/api/pe_start.sh new file mode 100644 index 0000000..20ba8ec --- /dev/null +++ b/test/api/pe_start.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# Copyright (C) 2011 Red Hat, Inc. All rights reserved. +# +# This file is part of LVM2. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +aux prepare_devs 2 + +aux apitest pe_start test_vg $dev1 + +not vgs test_vg +not pvs $dev1 diff --git a/test/api/percent.c b/test/api/percent.c index a3be1eb..c5fa434 100644 --- a/test/api/percent.c +++ b/test/api/percent.c @@ -12,9 +12,10 @@ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "lvm2app.h" +#undef NDEBUG -#define assert(x) do { if (!(x)) goto bad; } while (0) +#include "lvm2app.h" +#include "assert.h" int main(int argc, char *argv[]) { @@ -22,6 +23,7 @@ int main(int argc, char *argv[]) vg_t vg = NULL; lv_t lv; struct lvm_property_value v; + struct lvm_property_value d; handle = lvm_init(NULL); assert(handle); @@ -36,7 +38,7 @@ int main(int argc, char *argv[]) assert(v.is_valid); assert(v.value.integer == PERCENT_0); - lv = lvm_lv_from_name(vg, "mirr"); + lv = lvm_lv_from_name(vg, "mirr"); assert(lv); v = lvm_lv_get_property(lv, "copy_percent"); @@ -50,15 +52,12 @@ int main(int argc, char *argv[]) assert(v.is_valid); assert(v.value.integer == 50 * PERCENT_1); + d = lvm_lv_get_property(lv, "data_percent"); + assert(d.is_valid); + assert(d.value.integer == v.value.integer); + lvm_vg_close(vg); - return 0; -bad: - if (handle && lvm_errno(handle)) - fprintf(stderr, "LVM Error: %s\n", lvm_errmsg(handle)); - if (vg) - lvm_vg_close(vg); - if (handle) - lvm_quit(handle); - return 1; + lvm_quit(handle); + return 0; } diff --git a/test/api/percent.sh b/test/api/percent.sh index 4362eb2..07b8bc6 100644 --- a/test/api/percent.sh +++ b/test/api/percent.sh @@ -1,4 +1,4 @@ -# +#!/bin/sh # Copyright (C) 2010 Red Hat, Inc. All rights reserved. # # This file is part of LVM2. @@ -11,13 +11,19 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test + +kernel_at_least 2 6 33 || skip + aux prepare_devs 2 -vgcreate -c n -s 4k $vg $devs -lvcreate -n foo $vg -l 5 + +vgcreate -c n -s 4k $vg $(cat DEVICES) +lvcreate -l 5 -n foo $vg lvcreate -s -n snap $vg/foo -l 2 -c 4k lvcreate -s -n snap2 $vg/foo -l 6 -c 4k -dd if=/dev/urandom of=$DM_DEV_DIR/$vg/snap2 count=1 bs=1024 +dd if=/dev/urandom of="$DM_DEV_DIR/$vg/snap2" count=1 bs=1024 lvcreate -m 1 -n mirr $vg -l 1 --mirrorlog core -lvs -apitest percent $vg +lvs $vg +aux apitest percent $vg + +vgremove -ff $vg diff --git a/test/api/test.c b/test/api/test.c index 434baea..b27aed1 100644 --- a/test/api/test.c +++ b/test/api/test.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -12,13 +12,18 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #include <stdio.h> #include <string.h> #include <stdlib.h> -#include <readline/readline.h> +#include <ctype.h> +#include "configure.h" #include "lvm2app.h" +#ifdef READLINE_SUPPORT +#include <readline/readline.h> + #define MAX_ARGS 64 static int lvm_split(char *str, int *argc, char **argv, int max) @@ -868,6 +873,10 @@ static void _lvsegs_in_lv(char **argv, int argc) _print_property_value("seg_start_pe", v); v = lvm_lvseg_get_property(lvl->lvseg, "seg_size"); _print_property_value("seg_size", v); + v = lvm_lvseg_get_property(lvl->lvseg, "devices"); + _print_property_value("devices", v); + v = lvm_lvseg_get_property(lvl->lvseg, "seg_pe_ranges"); + _print_property_value("seg_pe_ranges", v); } } @@ -1071,6 +1080,13 @@ static int lvmapi_test_shell(lvm_t libh) free(input); return 0; } +#else /* !READLINE_SUPPORT */ +static int lvmapi_test_shell(lvm_t libh) +{ + printf("Build without readline library, no interactive testing.\n"); + return 1; +} +#endif int main (int argc, char *argv[]) { diff --git a/test/api/thin_percent.c b/test/api/thin_percent.c new file mode 100644 index 0000000..2c8b19b --- /dev/null +++ b/test/api/thin_percent.c @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2012 Red Hat, Inc. All rights reserved. + * + * This file is part of LVM2. + * + * 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 Lesser General Public License v.2.1. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#undef NDEBUG + +#include "lvm2app.h" +#include "assert.h" + +int main(int argc, char *argv[]) +{ + lvm_t handle; + vg_t vg; + lv_t lv; + struct lvm_property_value v; + + handle = lvm_init(NULL); + assert(handle); + + vg = lvm_vg_open(handle, argv[1], "r", 0); + assert(vg); + + lv = lvm_lv_from_name(vg, "pool"); + assert(lv); + + v = lvm_lv_get_property(lv, "data_percent"); + assert(v.is_valid); + assert(v.value.integer == 25 * PERCENT_1); + + + lv = lvm_lv_from_name(vg, "thin"); + assert(lv); + + v = lvm_lv_get_property(lv, "data_percent"); + assert(v.is_valid); + assert(v.value.integer == 50 * PERCENT_1); + + + lv = lvm_lv_from_name(vg, "snap"); + assert(lv); + + v = lvm_lv_get_property(lv, "data_percent"); + assert(v.is_valid); + assert(v.value.integer == 75 * PERCENT_1); + + v = lvm_lv_get_property(lv, "snap_percent"); + assert(v.is_valid); + assert(v.value.integer == PERCENT_INVALID); + + v = lvm_lv_get_property(lv, "origin"); + assert(v.is_valid); + assert(strcmp(v.value.string, "thin") == 0); + + lvm_vg_close(vg); + lvm_quit(handle); + + return 0; +} diff --git a/test/api/thin_percent.sh b/test/api/thin_percent.sh new file mode 100644 index 0000000..9287cf3 --- /dev/null +++ b/test/api/thin_percent.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# Copyright (C) 2012 Red Hat, Inc. All rights reserved. +# +# This file is part of LVM2. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +aux have_thin 1 0 0 || skip + +# disable thin_check if not present in system +which thin_check || aux lvmconf 'global/thin_check_executable = ""' + +aux prepare_devs 2 + +vgcreate -s 64k $vg $(cat DEVICES) + +lvcreate -L5M -T $vg/pool + +lvcreate -V1M -T $vg/pool -n thin +dd if=/dev/urandom of="$DM_DEV_DIR/$vg/thin" count=2 bs=256K + +lvcreate -s $vg/thin -n snap +dd if=/dev/urandom of="$DM_DEV_DIR/$vg/snap" count=3 bs=256K + +lvs $vg + +aux apitest thin_percent $vg + +vgremove -ff $vg diff --git a/test/api/vgtest.sh b/test/api/vgtest.sh index 35daa44..6c0be4e 100644 --- a/test/api/vgtest.sh +++ b/test/api/vgtest.sh @@ -1,3 +1,4 @@ +#!/bin/sh # Copyright (C) 2008 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -12,7 +13,8 @@ # tests lvm2app library # -. ./test-utils.sh -aux prepare_devs 2 -pvcreate $dev1 $dev2 -apitest vgtest $vg1 $dev1 $dev2 +. lib/test + +aux prepare_pvs 2 + +aux apitest vgtest $vg1 "$dev1" "$dev2" diff --git a/test/check.sh b/test/check.sh deleted file mode 100644 index 843ce86..0000000 --- a/test/check.sh +++ /dev/null @@ -1,198 +0,0 @@ -#!/bin/bash - -# Copyright (C) 2010 Red Hat, Inc. All rights reserved. -# -# 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. -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -# check.sh: assert various things about volumes - -# USAGE -# check linear VG LV -# check lv_on VG LV PV - -# check mirror VG LV [LOGDEV|core] -# check mirror_nonredundant VG LV -# check mirror_legs VG LV N -# check mirror_images_on VG LV DEV [DEV...] - -# ... - -set -e -o pipefail - -lvl() { - lvs -a --noheadings "$@" -} - -lvdevices() { - lvl -odevices "$@" | sed 's/([^)]*)//g; s/,/ /g' -} - -mirror_images_redundant() -{ - vg=$1 - lv=$vg/$2 - - lvs -a $vg -o+devices - for i in `lvdevices $lv`; do - echo "# $i:" - lvdevices $vg/$i | sort | uniq - done > check.tmp.all - - (grep -v ^# check.tmp.all || true) | sort | uniq -d > check.tmp - - test "`cat check.tmp | wc -l`" -eq 0 || { - echo "mirror images of $lv expected redundant, but are not:" - cat check.tmp.all - exit 1 - } -} - -mirror_images_on() { - vg=$1 - lv=$2 - - shift 2 - - for i in `lvdevices $lv`; do - lv_on $vg $lv $1 - shift - done -} - -lv_on() -{ - lv="$1/$2" - lvdevices $lv | grep -F "$3" || { - echo "LV $lv expected on $3 but is not:" >&2 - lvdevices $lv >&2 - exit 1 - } - test `lvdevices $lv | grep -vF "$3" | wc -l` -eq 0 || { - echo "LV $lv contains unexpected devices:" >&2 - lvdevices $lv >&2 - exit 1 - } -} - -mirror_log_on() -{ - vg="$1" - lv="$2" - where="$3" - if test "$where" = "core"; then - lvl -omirror_log "$vg/$lv" | not grep mlog - else - lv_on $vg "${lv}_mlog" "$where" - fi -} - -lv_is_contiguous() -{ - test `lvl --segments $1 | wc -l` -eq 1 || { - echo "LV $1 expected to be contiguous, but is not:" - lvl --segments $1 - exit 1 - } -} - -lv_is_clung() -{ - test `lvdevices $1 | sort | uniq | wc -l` -eq 1 || { - echo "LV $1 expected to be clung, but is not:" - lvdevices $! | sort | uniq - exit 1 - } -} - -mirror_images_contiguous() -{ - for i in `lvdevices $1/$2`; do - lv_is_contiguous $1/$i - done -} - -mirror_images_clung() -{ - for i in `lvdevices $1/$2`; do - lv_is_clung $1/$i - done -} - -mirror() { - mirror_nonredundant "$@" - mirror_images_redundant "$1" "$2" -} - -mirror_nonredundant() { - lv="$1/$2" - lvs -oattr "$lv" | grep -q "^ *m.....$" || { - echo "$lv expected a mirror, but is not:" - lvs -a $lv - exit 1 - } - if test -n "$3"; then mirror_log_on "$1" "$2" "$3"; fi -} - -mirror_legs() { - lv="$1/$2" - expect="$3" - lvdevices "$lv" - real=`lvdevices "$lv" | wc -w` - test "$expect" = "$real" -} - -mirror_no_temporaries() -{ - vg=$1 - lv=$2 - lvl -oname $vg | grep $lv | not grep "tmp" || { - echo "$lv has temporary mirror images unexpectedly:" - lvl $vg | grep $lv - exit 1 - } -} - -linear() { - lv="$1/$2" - lvl -ostripes "$lv" | grep -q "1" || { - echo "$lv expected linear, but is not:" - lvl "$lv" -o+devices - exit 1 - } -} - -active() { - lv="$1/$2" - lvl -oattr "$lv" 2> /dev/null | grep -q "^ *....a.$" || { - echo "$lv expected active, but lvs says it's not:" - lvl "$lv" -o+devices 2>/dev/null - exit 1 - } - dmsetup table | egrep -q "$1-$2: *[^ ]+" || { - echo "$lv expected active, lvs thinks it is but there are no mappings!" - dmsetup table | grep $1-$2: - exit 1 - } -} - -inactive() { - lv="$1/$2" - lvl -oattr "$lv" 2> /dev/null | grep -q '^ *....[-isd].$' || { - echo "$lv expected inactive, but lvs says it's not:" - lvl "$lv" -o+devices 2>/dev/null - exit 1 - } - dmsetup table | not egrep -q "$1-$2: *[^ ]+" || { - echo "$lv expected inactive, lvs thinks it is but there are mappings!" - dmsetup table | grep $1-$2: - exit 1 - } -} - -"$@" diff --git a/test/harness.c b/test/harness.c deleted file mode 100644 index 0162278..0000000 --- a/test/harness.c +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (C) 2010 Red Hat, Inc. All rights reserved. - * - * This file is part of LVM2. - * - * 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. - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <fcntl.h> -#include <string.h> -#include <stdio.h> -#include <sys/socket.h> -#include <sys/wait.h> -#include <unistd.h> -#include <stdlib.h> - -pid_t pid; -int fds[2]; - -#define MAX 1024 - -struct stats { - int nfailed; - int nskipped; - int npassed; - int nwarned; - int status[MAX]; -}; - -struct stats s; - -char *readbuf = NULL; -int readbuf_sz = 0, readbuf_used = 0; - -int die = 0; -int verbose = 0; - -#define PASSED 0 -#define SKIPPED 1 -#define FAILED 2 -#define WARNED 3 - -void handler( int s ) { - signal( s, SIG_DFL ); - kill( pid, s ); - die = s; -} - -void dump() { - fwrite(readbuf, 1, readbuf_used, stdout); -} - -void clear() { - readbuf_used = 0; -} - -void drain() { - int sz; - char buf[2048]; - while (1) { - sz = read(fds[1], buf, 2048); - if (verbose) - write(1, buf, sz); - if (sz <= 0) - return; - if (readbuf_used + sz >= readbuf_sz) { - readbuf_sz = readbuf_sz ? 2 * readbuf_sz : 4096; - readbuf = realloc(readbuf, readbuf_sz); - } - if (!readbuf) - exit(205); - memcpy(readbuf + readbuf_used, buf, sz); - readbuf_used += sz; - readbuf[readbuf_used] = 0; - } -} - -void passed(int i, char *f) { - if (strstr(readbuf, "TEST WARNING")) { - ++s.nwarned; - s.status[i] = WARNED; - printf("warnings\n"); - } else { - ++ s.npassed; - s.status[i] = PASSED; - printf("passed.\n"); - } -} - -void skipped(int i, char *f) { - ++ s.nskipped; - s.status[i] = SKIPPED; - printf("skipped.\n"); -} - -void failed(int i, char *f, int st) { - ++ s.nfailed; - s.status[i] = FAILED; - if(die == 2) { - printf("interrupted.\n"); - return; - } - printf("FAILED.\n"); - printf("-- FAILED %s ------------------------------------\n", f); - dump(); - printf("-- FAILED %s (end) ------------------------------\n", f); -} - -void run(int i, char *f) { - pid = fork(); - if (pid < 0) { - perror("Fork failed."); - exit(201); - } else if (pid == 0) { - close(0); - dup2(fds[0], 1); - dup2(fds[0], 2); - execlp("bash", "bash", f, NULL); - perror("execlp"); - fflush(stderr); - _exit(202); - } else { - char buf[128]; - snprintf(buf, 128, "%s ...", f); - buf[127] = 0; - printf("Running %-40s ", buf); - fflush(stdout); - int st, w; - while ((w = waitpid(pid, &st, WNOHANG)) == 0) { - drain(); - usleep(20000); - } - if (w != pid) { - perror("waitpid"); - exit(206); - } - drain(); - if (WIFEXITED(st)) { - if (WEXITSTATUS(st) == 0) { - passed(i, f); - } else if (WEXITSTATUS(st) == 200) { - skipped(i, f); - } else { - failed(i, f, st); - } - } else { - failed(i, f, st); - } - clear(); - } -} - -int main(int argc, char **argv) { - int i; - - if (argc >= MAX) { - fprintf(stderr, "Sorry, my head exploded. Please increase MAX.\n"); - exit(1); - } - - s.nwarned = s.nfailed = s.npassed = s.nskipped = 0; - - char *config = getenv("LVM_TEST_CONFIG"), - *config_debug, - *be_verbose = getenv("VERBOSE"); - if (be_verbose && atoi(be_verbose)) - verbose = 1; // XXX - config = config ? config : ""; - asprintf(&config_debug, "%s\n%s\n", config, "log { verbose=4 }"); - - if (socketpair(PF_UNIX, SOCK_STREAM, 0, fds)) { - perror("socketpair"); - return 201; - } - - if ( fcntl( fds[1], F_SETFL, O_NONBLOCK ) == -1 ) { - perror("fcntl on socket"); - return 202; - } - - /* set up signal handlers */ - for (i = 0; i <= 32; ++i) { - if (i == SIGCHLD || i == SIGWINCH || i == SIGURG) - continue; - signal(i, handler); - } - - /* run the tests */ - for (i = 1; i < argc; ++ i) { - run(i, argv[i]); - if (die) - break; - } - - printf("\n## %d tests: %d OK, %d warnings, %d failures; %d skipped\n", - s.nwarned + s.npassed + s.nfailed + s.nskipped, - s.npassed, s.nwarned, s.nfailed, s.nskipped); - - /* print out a summary */ - if (s.nfailed || s.nskipped) { - for (i = 1; i < argc; ++ i) { - switch (s.status[i]) { - case FAILED: - printf("FAILED: %s\n", argv[i]); - break; - case SKIPPED: - printf("skipped: %s\n", argv[i]); - break; - } - } - printf("\n"); - return s.nfailed > 0 || die; - } - return die; -} diff --git a/test/harness.sh b/test/harness.sh deleted file mode 100644 index b4bdd69..0000000 --- a/test/harness.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/sh - -# Copyright (C) 2010 Red Hat, Inc. All rights reserved. -# -# 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. -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -tests="$@" -test -z "$tests" && tests=`echo t-*.sh` - -for t in $tests; do - printf "Running %-40s" "$t ..." - out=`bash ./$t 2>&1` - ret=$? - if test $ret = 0; then - echo " passed." - elif test $ret = 200; then - skipped="$skipped $t" - echo " skipped." - else - echo " FAILED!" - len=`echo $t | wc -c` - # fancy formatting... - printf -- "--- Output: $t -" - for i in `seq $(($len + 14)) 78`; do echo -n "-"; done; echo - printf "%s\n" "$out" - printf -- "--- End: $t ----" - for i in `seq $(($len + 14)) 78`; do echo -n "-"; done; echo - failed="$failed $t" - fi -done - -if test -n "$failed"; then - echo "Tests skipped:" - for t in $skipped; do - printf "\t%s\n" $t - done - echo "TESTS FAILED:" - for t in $failed; do - printf "\t%s\n" $t - done - exit 1 -else - echo "All tests passed." -fi diff --git a/test/lib/aux.sh b/test/lib/aux.sh new file mode 100644 index 0000000..7c0c189 --- /dev/null +++ b/test/lib/aux.sh @@ -0,0 +1,551 @@ +#!/bin/bash +# Copyright (C) 2011-2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/utils + +run_valgrind() { + # Execute script which may use $TESTNAME for creating individual + # log files for each execute command + exec "${VALGRIND:-valg}" "$@" +} + +expect_failure() { + echo "TEST EXPECT FAILURE" +} + +prepare_clvmd() { + test "${LVM_TEST_LOCKING:-0}" -ne 3 && return # not needed + + if pgrep clvmd ; then + echo "Cannot use fake cluster locking with real clvmd ($(pgrep clvmd)) running." + skip + fi + + # skip if we don't have our own clvmd... + (which clvmd 2>/dev/null | grep "$abs_builddir") || skip + + # skip if we singlenode is not compiled in + (clvmd --help 2>&1 | grep "Available cluster managers" | grep "singlenode") || skip + +# lvmconf "activation/monitoring = 1" + local run_valgrind= + test -z "$LVM_VALGRIND_CLVMD" || run_valgrind="run_valgrind" + $run_valgrind lib/clvmd -Isinglenode -d 1 -f & + local local_clvmd=$! + sleep .3 + # extra sleep for slow valgrind + test -z "$LVM_VALGRIND_CLVMD" || sleep 7 + # check that it is really running now + ps $local_clvmd || die + echo $local_clvmd > LOCAL_CLVMD +} + +prepare_dmeventd() { + if pgrep dmeventd ; then + echo "Cannot test dmeventd with real dmeventd ($(pgrep dmeventd)) running." + skip + fi + + # skip if we don't have our own dmeventd... + (which dmeventd 2>/dev/null | grep "$abs_builddir") || skip + + lvmconf "activation/monitoring = 1" + + dmeventd -f "$@" & + echo $! > LOCAL_DMEVENTD + + # FIXME wait for pipe in /var/run instead + sleep .3 +} + +prepare_lvmetad() { + # skip if we don't have our own lvmetad... + (which lvmetad 2>/dev/null | grep "$abs_builddir") || skip + + lvmconf "global/use_lvmetad = 1" + lvmconf "devices/md_component_detection = 0" + + local run_valgrind= + test -z "$LVM_VALGRIND_LVMETAD" || run_valgrind="run_valgrind" + + echo "preparing lvmetad..." + $run_valgrind lvmetad -f "$@" -s "$TESTDIR/lvmetad.socket" -l wire,debug & + echo $! > LOCAL_LVMETAD + while ! test -e "$TESTDIR/lvmetad.socket"; do echo -n .; sleep .1; done # wait for the socket + echo ok +} + +notify_lvmetad() { + if test -e LOCAL_LVMETAD; then + pvscan --cache "$@" || true + fi +} + +teardown_devs_prefixed() { + local prefix=$1 + local stray=${2:-0} + local IFS=$IFS_NL + local dm + + # Resume suspended devices first + for dm in $(dm_info suspended,name | grep "^Suspended:.*$prefix"); do + echo "dmsetup resume \"${dm#Suspended:}\"" + dmsetup resume "${dm#Suspended:}" || true + done + + local mounts=( $(grep "$prefix" /proc/mounts | cut -d' ' -f1) ) + if test ${#mounts[@]} -gt 0; then + test "$stray" -eq 0 || echo "Removing stray mounted devices containing $prefix: ${mounts[@]}" + if umount -fl "${mounts[@]}"; then + udev_wait + fi + fi + + # Remove devices, start with closed (sorted by open count) + local remfail=no + local need_udev_wait=0 + init_udev_transaction + for dm in $(dm_info name --sort open | grep "$prefix"); do + dmsetup remove "$dm" &>/dev/null || remfail=yes + need_udev_wait=1 + done + finish_udev_transaction + test $need_udev_wait -eq 0 || udev_wait + + if test $remfail = yes; then + local num_devs + local num_remaining_devs=999 + while num_devs=$(dm_table | grep "$prefix" | wc -l) && \ + test $num_devs -lt $num_remaining_devs -a $num_devs -ne 0; do + test "$stray" -eq 0 || echo "Removing $num_devs stray mapped devices with names beginning with $prefix: " + for dm in $(dm_info name --sort open | grep "$prefix") ; do + dmsetup remove -f "$dm" || true + done + num_remaining_devs=$num_devs + done + fi +} + +teardown_devs() { + # Delete any remaining dm/udev semaphores + teardown_udev_cookies + + test -z "$PREFIX" || { + rm -rf "$TESTDIR/dev/$PREFIX"* + teardown_devs_prefixed "$PREFIX" + } + + # NOTE: SCSI_DEBUG_DEV test must come before the LOOP test because + # prepare_scsi_debug_dev() also sets LOOP to short-circuit prepare_loop() + if test -f SCSI_DEBUG_DEV; then + test ${LVM_TEST_PARALLEL:-0} -eq 1 || modprobe -r scsi_debug + else + test ! -f LOOP || losetup -d $(cat LOOP) || true + test ! -f LOOPFILE || rm -f $(cat LOOPFILE) + fi + rm -f DEVICES # devs is set in prepare_devs() + rm -f LOOP + + # Attempt to remove any loop devices that failed to get torn down if earlier tests aborted + test ${LVM_TEST_PARALLEL:-0} -eq 1 -o -z "$COMMON_PREFIX" || { + teardown_devs_prefixed "$COMMON_PREFIX" 1 + local stray_loops=( $(losetup -a | grep "$COMMON_PREFIX" | cut -d: -f1) ) + test ${#stray_loops[@]} -eq 0 || { + echo "Removing stray loop devices containing $COMMON_PREFIX: ${stray_loops[@]}" + losetup -d "${stray_loops[@]}" + } + } +} + +teardown() { + echo -n "## teardown..." + test ! -s LOCAL_LVMETAD || \ + (kill -TERM "$(cat LOCAL_LVMETAD)" && sleep 1 && + kill -KILL "$(cat LOCAL_LVMETAD)" 2> /dev/null) || true + + dm_table | not egrep -q "$vg|$vg1|$vg2|$vg3|$vg4" || { + # Avoid activation of dmeventd if there is no pid + cfg=$(test -s LOCAL_DMEVENTD || echo "--config activation{monitoring=0}") + vgremove -ff $cfg \ + $vg $vg1 $vg2 $vg3 $vg4 &>/dev/null || rm -f debug.log + } + + test -s LOCAL_CLVMD && { + kill -INT "$(cat LOCAL_CLVMD)" + test -z "$LVM_VALGRIND_CLVMD" || sleep 1 + sleep .1 + kill -9 "$(cat LOCAL_CLVMD)" &>/dev/null || true + } + + echo -n . + + pgrep dmeventd || true + test ! -s LOCAL_DMEVENTD || kill -9 "$(cat LOCAL_DMEVENTD)" || true + + echo -n . + + test -d "$DM_DEV_DIR/mapper" && teardown_devs + + echo -n . + + test -n "$TESTDIR" && { + cd "$TESTOLDPWD" + rm -rf "$TESTDIR" || echo BLA + } + + echo "ok" + + test ${LVM_TEST_PARALLEL:-0} -eq 1 -o -n "$RUNNING_DMEVENTD" || not pgrep dmeventd #&>/dev/null +} + +make_ioerror() { + echo 0 10000000 error | dmsetup create -u ${PREFIX}-ioerror ioerror + ln -s "$DM_DEV_DIR/mapper/ioerror" "$DM_DEV_DIR/ioerror" +} + +prepare_loop() { + local size=${1=32} + local i + local slash + + test -f LOOP && LOOP=$(cat LOOP) + echo -n "## preparing loop device..." + + # skip if prepare_scsi_debug_dev() was used + if test -f SCSI_DEBUG_DEV -a -f LOOP ; then + echo "(skipped)" + return 0 + fi + + test ! -e LOOP + test -n "$DM_DEV_DIR" + + for i in 0 1 2 3 4 5 6 7; do + test -e "$DM_DEV_DIR/loop$i" || mknod "$DM_DEV_DIR/loop$i" b 7 $i + done + + echo -n . + + local LOOPFILE="$PWD/test.img" + dd if=/dev/zero of="$LOOPFILE" bs=$((1024*1024)) count=0 seek=$(($size-1)) 2> /dev/null + if LOOP=$(losetup -s -f "$LOOPFILE" 2>/dev/null); then + : + elif LOOP=$(losetup -f) && losetup "$LOOP" "$LOOPFILE"; then + # no -s support + : + else + # no -f support + # Iterate through $DM_DEV_DIR/loop{,/}{0,1,2,3,4,5,6,7} + for slash in '' /; do + for i in 0 1 2 3 4 5 6 7; do + local dev="$DM_DEV_DIR/loop$slash$i" + ! losetup "$dev" >/dev/null 2>&1 || continue + # got a free + losetup "$dev" "$LOOPFILE" + LOOP=$dev + break + done + test -z "$LOOP" || break + done + fi + test -n "$LOOP" # confirm or fail + echo "$LOOP" > LOOP + echo "ok ($LOOP)" +} + +# A drop-in replacement for prepare_loop() that uses scsi_debug to create +# a ramdisk-based SCSI device upon which all LVM devices will be created +# - scripts must take care not to use a DEV_SIZE that will enduce OOM-killer +prepare_scsi_debug_dev() { + local DEV_SIZE=$1 + local SCSI_DEBUG_PARAMS=${@:2} + + test -f "SCSI_DEBUG_DEV" && return 0 + test -z "$LOOP" + test -n "$DM_DEV_DIR" + + # Skip test if awk isn't available (required for get_sd_devs_) + which awk || skip + + # Skip test if scsi_debug module is unavailable or is already in use + modprobe --dry-run scsi_debug || skip + lsmod | grep -q scsi_debug && skip + + # Create the scsi_debug device and determine the new scsi device's name + # NOTE: it will _never_ make sense to pass num_tgts param; + # last param wins.. so num_tgts=1 is imposed + modprobe scsi_debug dev_size_mb=$DEV_SIZE $SCSI_DEBUG_PARAMS num_tgts=1 || skip + sleep 2 # allow for async Linux SCSI device registration + + local DEBUG_DEV="/dev/$(grep -H scsi_debug /sys/block/*/device/model | cut -f4 -d /)" + test -b "$DEBUG_DEV" || return 1 # should not happen + + # Create symlink to scsi_debug device in $DM_DEV_DIR + SCSI_DEBUG_DEV="$DM_DEV_DIR/$(basename $DEBUG_DEV)" + echo "$SCSI_DEBUG_DEV" > SCSI_DEBUG_DEV + echo "$SCSI_DEBUG_DEV" > LOOP + # Setting $LOOP provides means for prepare_devs() override + test "$LVM_TEST_DEVDIR" != "/dev" && ln -snf "$DEBUG_DEV" "$SCSI_DEBUG_DEV" +} + +cleanup_scsi_debug_dev() { + teardown_devs + rm -f SCSI_DEBUG_DEV LOOP +} + +prepare_devs() { + local n=${1:-3} + local devsize=${2:-34} + local pvname=${3:-pv} + local loopsz + + prepare_loop $(($n*$devsize)) + echo -n "## preparing $n devices..." + + if ! loopsz=$(blockdev --getsz "$LOOP" 2>/dev/null); then + loopsz=$(blockdev --getsize "$LOOP" 2>/dev/null) + fi + + local size=$(($loopsz/$n)) + devs= + + init_udev_transaction + for i in $(seq 1 $n); do + local name="${PREFIX}$pvname$i" + local dev="$DM_DEV_DIR/mapper/$name" + devs="$devs $dev" + echo 0 $size linear "$LOOP" $((($i-1)*$size)) > "$name.table" + dmsetup create -u "TEST-$name" "$name" "$name.table" + done + finish_udev_transaction + + #for i in `seq 1 $n`; do + # local name="${PREFIX}$pvname$i" + # dmsetup info -c $name + #done + #for i in `seq 1 $n`; do + # local name="${PREFIX}$pvname$i" + # dmsetup table $name + #done + + echo $devs > DEVICES + echo "ok" +} + +disable_dev() { + local dev + + init_udev_transaction + for dev in "$@"; do + maj=$(($(stat --printf=0x%t "$dev"))) + min=$(($(stat --printf=0x%T "$dev"))) + echo "Disabling device $dev ($maj:$min)" + dmsetup remove -f "$dev" || true + notify_lvmetad --major "$maj" --minor "$min" + done + finish_udev_transaction +} + +enable_dev() { + local dev + + init_udev_transaction + for dev in "$@"; do + local name=$(echo "$dev" | sed -e 's,.*/,,') + dmsetup create -u "TEST-$name" "$name" "$name.table" || \ + dmsetup load "$name" "$name.table" + # using device name (since device path does not exists yes with udev) + dmsetup resume "$name" + notify_lvmetad "$dev" + done + finish_udev_transaction +} + +backup_dev() { + local dev + + for dev in "$@"; do + dd if="$dev" of="$dev.backup" bs=1024 + done +} + +restore_dev() { + local dev + + for dev in "$@"; do + test -e "$dev.backup" || \ + die "Internal error: $dev not backed up, can't restore!" + dd of="$dev" if="$dev.backup" bs=1024 + done +} + +prepare_pvs() { + prepare_devs "$@" + pvcreate -ff $devs +} + +prepare_vg() { + teardown_devs + + prepare_pvs "$@" + vgcreate -c n $vg $devs +} + +lvmconf() { + LVM_TEST_LOCKING=${LVM_TEST_LOCKING:-1} + if test "$DM_DEV_DIR" = "/dev"; then + LVM_VERIFY_UDEV=${LVM_VERIFY_UDEV:-0} + else + LVM_VERIFY_UDEV=${LVM_VERIFY_UDEV:-1} + fi + test -f CONFIG_VALUES || { + cat > CONFIG_VALUES <<-EOF +devices/dir = "$DM_DEV_DIR" +devices/scan = "$DM_DEV_DIR" +devices/filter = [ "a|$DM_DEV_DIR/mirror|", "a|$DM_DEV_DIR/mapper/.*pv[0-9_]*$|", "r|.*|" ] +devices/cache_dir = "$TESTDIR/etc" +devices/sysfs_scan = 0 +devices/default_data_alignment = 1 +devices/md_component_detection = 0 +log/syslog = 0 +log/indent = 1 +log/level = 9 +log/file = "$TESTDIR/debug.log" +log/overwrite = 1 +log/activation = 1 +log/verbose = 0 +activation/retry_deactivation = 1 +backup/backup = 0 +backup/archive = 0 +global/abort_on_internal_errors = 1 +global/detect_internal_vg_cache_corruption = 1 +global/library_dir = "$TESTDIR/lib" +global/locking_dir = "$TESTDIR/var/lock/lvm" +global/locking_type=$LVM_TEST_LOCKING +global/si_unit_consistency = 1 +global/fallback_to_local_locking = 0 +activation/checks = 1 +activation/udev_sync = 1 +activation/udev_rules = 1 +activation/verify_udev_operations = $LVM_VERIFY_UDEV +activation/polling_interval = 0 +activation/snapshot_autoextend_percent = 50 +activation/snapshot_autoextend_threshold = 50 +activation/monitoring = 0 +EOF + } + + local v + for v in "$@"; do + echo "$v" >> CONFIG_VALUES + done + + rm -f CONFIG + local s + for s in $(cat CONFIG_VALUES | cut -f1 -d/ | sort | uniq); do + echo "$s {" >> CONFIG + local k + for k in $(grep ^"$s"/ CONFIG_VALUES | cut -f1 -d= | sed -e 's, *$,,' | sort | uniq); do + grep "^$k" CONFIG_VALUES | tail -n 1 | sed -e "s,^$s/, ," >> CONFIG + done + echo "}" >> CONFIG + echo >> CONFIG + done + mv -f CONFIG etc/lvm.conf +} + +apitest() { + local t=$1 + shift + test -x "$abs_top_builddir/test/api/$t.t" || skip + "$abs_top_builddir/test/api/$t.t" "$@" && rm -f debug.log +} + +api() { + test -x "$abs_top_builddir/test/api/wrapper" || skip + "$abs_top_builddir/test/api/wrapper" "$@" && rm -f debug.log +} + +udev_wait() { + pgrep udev >/dev/null || return 0 + which udevadm >/dev/null || return 0 + if test -n "$1" ; then + udevadm settle --exit-if-exists="$1" || true + else + udevadm settle --timeout=15 || true + fi +} + +# wait_for_sync <VG/LV> +wait_for_sync() { + local i + for i in {1..500} ; do + check in_sync $1 $2 && return + sleep .2 + done + + echo "Sync is taking too long - assume stuck" + return 1 +} + +# +# Check wheter kernel [dm module] target exist +# at least in expected version +# +# [dm-]target-name major minor revision +# +# i.e. dm_target_at_least dm-thin-pool 1 0 +target_at_least() +{ + case "$1" in + dm-*) modprobe "$1" || true ;; + esac + + local version=$(dmsetup targets 2>/dev/null | grep "${1##dm-} " 2>/dev/null) + version=${version##* v} + shift + + local major=$(echo "$version" | cut -d. -f1) + test -z "$1" && return 0 + test -n "$major" || return 1 + test "$major" -gt "$1" && return 0 + test "$major" -eq "$1" || return 1 + + test -z "$2" && return 0 + local minor=$(echo "$version" | cut -d. -f2) + test -n "$minor" || return 1 + test "$minor" -gt "$2" && return 0 + test "$minor" -eq "$2" || return 1 + + test -z "$3" && return 0 + local revision=$(echo "$version" | cut -d. -f3) + test "$revision" -ge "$3" 2>/dev/null || return 1 +} + +have_thin() +{ + target_at_least dm-thin-pool "$@" || exit 1 + test "$THIN" = shared || test "$THIN" = internal || exit 1 + + # disable thin_check if not present in system + which thin_check || lvmconf 'global/thin_check_executable = ""' +} + +# check if lvm shell is build-in (needs readline) +have_readline() +{ + echo version | lvm &>/dev/null +} + +test -f DEVICES && devs=$(cat DEVICES) + +#unset LVM_VALGRIND +"$@" diff --git a/test/lib/check.sh b/test/lib/check.sh new file mode 100644 index 0000000..6b7849f --- /dev/null +++ b/test/lib/check.sh @@ -0,0 +1,282 @@ +#!/bin/bash +# Copyright (C) 2010-2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# check.sh: assert various things about volumes + +# USAGE: +# check linear VG LV +# check lv_on VG LV PV + +# check mirror VG LV [LOGDEV|core] +# check mirror_nonredundant VG LV +# check mirror_legs VG LV N +# check mirror_images_on VG LV DEV [DEV...] + +# ... + +test -z "$BASH" || set -e -o pipefail + +die() { + echo "$@" >&2 + return 1 +} + +lvl() { + lvs -a --noheadings "$@" +} + +lvdevices() { + get lv_devices "$@" +} + +mirror_images_redundant() { + local vg=$1 + local lv=$vg/$2 + lvs -a $vg -o+devices + for i in $(lvdevices $lv); do + echo "# $i:" + lvdevices $vg/$i | sort | uniq + done > check.tmp.all + + (grep -v ^# check.tmp.all || true) | sort | uniq -d > check.tmp + + test $(cat check.tmp | wc -l) -eq 0 || \ + die "mirror images of $lv expected redundant, but are not:" \ + $(cat check.tmp.all) +} + +lv_on() { + local lv=$1/$2 + (lvdevices $lv | grep -F "$3") || \ + die "LV $lv expected on $3 but is not:" \ + $(lvdevices $lv) + test $(lvdevices $lv | grep -vF "$3" | wc -l) -eq 0 || \ + die "LV $lv contains unexpected devices:" \ + $(lvdevices $lv) +} + +mirror_images_on() { + local vg=$1 + local lv=$2 + shift 2 + for i in $(lvdevices $lv); do + lv_on $vg $lv $1 + shift + done +} + +mirror_log_on() { + local vg=$1 + local lv=$2 + local where=$3 + if test "$where" = "core"; then + get lv_field $vg/$lv mirror_log | not grep mlog + else + lv_on $vg ${lv}_mlog "$where" + fi +} + +lv_is_contiguous() { + local lv=$1/$2 + test $(lvl --segments $lv | wc -l) -eq 1 || \ + die "LV $lv expected to be contiguous, but is not:" \ + $(lvl --segments $lv) +} + +lv_is_clung() { + local lv=$1/$2 + test $(lvdevices $lv | sort | uniq | wc -l) -eq 1 || \ + die "LV $lv expected to be clung, but is not:" \ + $(lvdevices $lv | sort | uniq) +} + +mirror_images_contiguous() { + for i in $(lvdevices $1/$2); do + lv_is_contiguous $1 $i + done +} + +mirror_images_clung() { + for i in $(lvdevices $1/$2); do + lv_is_clung $1 $i + done +} + +mirror() { + mirror_nonredundant "$@" + mirror_images_redundant $1 $2 +} + +mirror_nonredundant() { + local lv=$1/$2 + local attr=$(get lv_field $lv attr) + (echo "$attr" | grep "^m........$" >/dev/null) || { + if (echo "$attr" | grep "^o........$" >/dev/null) && + lvs -a | fgrep "[${2}_mimage" >/dev/null; then + echo "TEST WARNING: $lv is a snapshot origin and looks like a mirror," + echo "assuming it is actually a mirror" + else + die "$lv expected a mirror, but is not:" \ + $(lvs $lv) + fi + } + test -z "$3" || mirror_log_on $1 $2 "$3" +} + +mirror_legs() { + local expect=$3 + test "$expect" -eq $(lvdevices $1/$2 | wc -w) +} + +mirror_no_temporaries() { + local vg=$1 + local lv=$2 + (lvl -o name $vg | grep $lv | not grep "tmp") || \ + die "$lv has temporary mirror images unexpectedly:" \ + $(lvl $vg | grep $lv) +} + +linear() { + local lv=$1/$2 + test $(get lv_field $lv stripes -a) -eq 1 || \ + die "$lv expected linear, but is not:" \ + $(lvl $lv -o+devices) +} + +# in_sync <VG> <LV> +# Works for "mirror" and "raid*" +in_sync() { + local a + local b + local idx + local type + local lvm_name="$1/$2" + local dm_name=$(echo $lvm_name | sed s:-:--: | sed s:/:-:) + + if ! a=(`dmsetup status $dm_name`); then + die "Unable to get sync status of $1" + elif [ ${a[2]} = "snapshot-origin" ]; then + if ! a=(`dmsetup status ${dm_name}-real`); then + die "Unable to get sync status of $1" + fi + fi + + if [ ${a[2]} = "raid" ]; then + # Last argument is the sync ratio for RAID + idx=$((${#a[@]} - 1)) + type=${a[3]} + elif [ ${a[2]} = "mirror" ]; then + # 4th Arg tells us how far to the sync ratio + idx=$((${a[3]} + 4)) + type=${a[2]} + else + die "Unable to get sync ratio for target type '${a[2]}'" + fi + + b=( $(echo ${a[$idx]} | sed s:/:' ':) ) + + if [ ${b[0]} != ${b[1]} ]; then + echo "$lvm_name ($type) is not in-sync" + return 1 + fi + + if [[ ${a[$(($idx - 1))]} =~ a ]]; then + die "$lvm_name in-sync, but 'a' characters in health status" + fi + + echo "$lvm_name ($type) is in-sync" + return 0 +} + +active() { + local lv=$1/$2 + (get lv_field $lv attr | grep "^....a....$" >/dev/null) || \ + die "$lv expected active, but lvs says it's not:" \ + $(lvl $lv -o+devices) + dmsetup info $1-$2 >/dev/null || + die "$lv expected active, lvs thinks it is but there are no mappings!" +} + +inactive() { + local lv=$1/$2 + (get lv_field $lv attr | grep "^....[-isd]....$" >/dev/null) || \ + die "$lv expected inactive, but lvs says it's not:" \ + $(lvl $lv -o+devices) + not dmsetup info $1-$2 2>/dev/null || \ + die "$lv expected inactive, lvs thinks it is but there are mappings!" +} + +# Check for list of LVs from given VG +lv_exists() { + local vg=$1 + local lv= + while [ $# -gt 1 ]; do + shift + lv="$lv $vg/$1" + done + lvl $lv &>/dev/null || \ + die "$lv expected to exist but does not" +} + +pv_field() { + local actual=$(get pv_field "$1" "$2" "${@:4}") + test "$actual" = "$3" || \ + die "pv_field: PV=\"$1\", field=\"$2\", actual=\"$actual\", expected=\"$3\"" +} + +vg_field() { + local actual=$(get vg_field $1 "$2" "${@:4}") + test "$actual" = "$3" || \ + die "vg_field: vg=$1, field=\"$2\", actual=\"$actual\", expected=\"$3\"" +} + +lv_field() { + local actual=$(get lv_field $1 "$2" "${@:4}") + test "$actual" = "$3" || \ + die "lv_field: lv=$lv, field=\"$2\", actual=\"$actual\", expected=\"$3\"" +} + +compare_fields() { + local cmd1=$1 + local obj1=$2 + local field1=$3 + local cmd2=$4 + local obj2=$5 + local field2=$6 + local val1=$($cmd1 --noheadings -o "$field1" "$obj1") + local val2=$($cmd2 --noheadings -o "$field2" "$obj2") + test "$val1" = "$val2" || \ + die "compare_fields $obj1($field1): $val1 $obj2($field2): $val2" +} + +compare_vg_field() { + local vg1=$1 + local vg2=$2 + local field=$3 + local val1=$(vgs --noheadings -o "$field" $vg1) + local val2=$(vgs --noheadings -o "$field" $vg2) + test "$val1" = "$val2" || \ + die "compare_vg_field: $vg1: $val1, $vg2: $val2" +} + +pvlv_counts() { + local local_vg=$1 + local num_pvs=$2 + local num_lvs=$3 + local num_snaps=$4 + lvs -o+devices $local_vg + vg_field $local_vg pv_count $num_pvs + vg_field $local_vg lv_count $num_lvs + vg_field $local_vg snap_count $num_snaps +} + +unset LVM_VALGRIND +"$@" diff --git a/test/lib/get.sh b/test/lib/get.sh new file mode 100644 index 0000000..4197f47 --- /dev/null +++ b/test/lib/get.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# Copyright (C) 2011-2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# get.sh: get various values from volumes +# +# USAGE: +# get pv_field PV field [pvs params] +# get vg_field VG field [vgs params] +# get lv_field LV field [lvs params] +# +# get lv_devices LV [lvs params] + + +# trims only leading prefix, we should not need trim trailing spaces +trim_() { + #local var=${var%"${var##*[! ]}"} # remove trailing space characters + echo ${1#"${1%%[! ]*}"} # remove leading space characters +} + +pv_field() { + trim_ "$(pvs --noheadings -o $2 ${@:3} $1)" +} + +vg_field() { + trim_ "$(vgs --noheadings -o $2 ${@:3} $1)" +} + +lv_field() { + trim_ "$(lvs --noheadings -o $2 ${@:3} $1)" +} + +lv_devices() { + lv_field $1 devices -a "${@:2}" | sed 's/([^)]*)//g; s/,/ /g' +} + +unset LVM_VALGRIND +"$@" diff --git a/test/lib/harness.c b/test/lib/harness.c new file mode 100644 index 0000000..929bfc8 --- /dev/null +++ b/test/lib/harness.c @@ -0,0 +1,393 @@ +/* + * Copyright (C) 2010-2012 Red Hat, Inc. All rights reserved. + * + * This file is part of LVM2. + * + * 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. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#define _GNU_SOURCE +#include <fcntl.h> +#include <string.h> +#include <stdio.h> +#include <sys/socket.h> +#include <sys/wait.h> +#include <unistd.h> +#include <stdlib.h> +#include <time.h> +#include <sys/time.h> + +static pid_t pid; +static int fds[2]; + +#define MAX 1024 + +struct stats { + int nfailed; + int nskipped; + int npassed; + int nknownfail; + int nwarned; + int status[MAX]; +}; + +static struct stats s; + +static char *readbuf = NULL; +static int readbuf_sz = 0, readbuf_used = 0; + +static int die = 0; +static int verbose = 0; /* >1 with timestamps */ +static int interactive = 0; /* disable all redirections */ + +struct subst { + const char *key; + char *value; +}; + +static struct subst subst[2]; + +#define PASSED 0 +#define SKIPPED 1 +#define FAILED 2 +#define WARNED 3 +#define KNOWNFAIL 4 + +static void handler( int sig ) { + signal( sig, SIG_DFL ); + kill( pid, sig ); + die = sig; +} + +static int outline(char *buf, int start, int force) { + char *from = buf + start; + char *next = strchr(buf + start, '\n'); + + if (!next && !force) /* not a complete line yet... */ + return start; + + if (!next) + next = from + strlen(from); + else + ++next; + + if (!strncmp(from, "@TESTDIR=", 9)) { + subst[0].key = "@TESTDIR@"; + subst[0].value = strndup(from + 9, next - from - 9 - 1); + } else if (!strncmp(from, "@PREFIX=", 8)) { + subst[1].key = "@PREFIX@"; + subst[1].value = strndup(from + 8, next - from - 8 - 1); + } else { + char *line = strndup(from, next - from); + char *a = line, *b; + do { + int idx = -1; + int i; + b = line + strlen(line); + for ( i = 0; i < 2; ++i ) { + if (subst[i].key) { + // printf("trying: %s -> %s\n", subst[i].value, subst[i].key); + char *stop = strstr(a, subst[i].value); + if (stop && stop < b) { + idx = i; + b = stop; + } + } + } + fwrite(a, 1, b - a, stdout); + a = b; + + if ( idx >= 0 ) { + fprintf(stdout, "%s", subst[idx].key); + a += strlen(subst[idx].value); + } + } while (b < line + strlen(line)); + free(line); + } + + return next - buf + (force ? 0 : 1); +} + +static void dump(void) { + int counter_last = -1, counter = 0; + + while ( counter < readbuf_used && counter != counter_last ) { + counter_last = counter; + counter = outline( readbuf, counter, 1 ); + } +} + +static void trickle(void) { + static int counter_last = -1, counter = 0; + + if (counter_last > readbuf_used) { + counter_last = -1; + counter = 0; + } + while ( counter < readbuf_used && counter != counter_last ) { + counter_last = counter; + counter = outline( readbuf, counter, 1 ); + } +} + +static void clear(void) { + readbuf_used = 0; +} + +static int64_t _get_time_us(void) +{ + struct timeval tv; + + (void) gettimeofday(&tv, 0); + return (int64_t) tv.tv_sec * 1000000 + (int64_t) tv.tv_usec; +} + +static void _append_buf(const char *buf, size_t len) +{ + if ((readbuf_used + len) >= readbuf_sz) { + readbuf_sz = readbuf_sz ? 2 * readbuf_sz : 4096; + readbuf = realloc(readbuf, readbuf_sz); + } + + if (!readbuf) + exit(205); + + memcpy(readbuf + readbuf_used, buf, len); + readbuf_used += len; +} + +static const char *_append_with_stamp(const char *buf, int stamp) +{ + static const char spaces[] = " "; + static int64_t t_last; + static int64_t t_start = 0; + int64_t t_now; + char stamp_buf[32]; /* Bigger to always fit both numbers */ + const char *be; + const char *bb = buf; + size_t len; + + while ((be = strchr(bb, '\n'))) { + if (stamp++ == 0) { + t_now = _get_time_us(); + if (!t_start) + t_start = t_last = t_now; + len = snprintf(stamp_buf, sizeof(stamp_buf), + "%8.3f%8.4f ", + (t_now - t_start) / 1000000.f, + (t_now - t_last) / 1000000.f); + _append_buf(stamp_buf, (len < (sizeof(spaces) - 1)) ? + len : (sizeof(spaces) - 1)); + t_last = t_now; + } + + _append_buf(bb, be + 1 - bb); + bb = be + 1; + + if (stamp > 0 && bb[0]) + _append_buf(spaces, sizeof(spaces) - 1); + } + + return bb; +} + +static void drain(void) { + char buf[4096]; + const char *bp; + int stamp = 0; + int sz; + + while ((sz = read(fds[1], buf, sizeof(buf) - 1)) > 0) { + buf[sz] = '\0'; + bp = (verbose < 2) ? buf : _append_with_stamp(buf, stamp); + + if (sz > (bp - buf)) { + _append_buf(bp, sz - (bp - buf)); + stamp = -1; /* unfinished line */ + } else + stamp = 0; + + readbuf[readbuf_used] = 0; + + if (verbose) + trickle(); + } +} + +static const char *duration(time_t start) +{ + static char buf[16]; + int t = (int)(time(NULL) - start); + + sprintf(buf, "%2d:%02d", t / 60, t % 60); + return buf; +} + +static void passed(int i, char *f, time_t t) { + if (readbuf && strstr(readbuf, "TEST EXPECT FAIL")) { + ++ s.npassed; + s.status[i] = PASSED; + printf("passed (UNEXPECTED). %s\n", duration(t)); + } else if (readbuf && strstr(readbuf, "TEST WARNING")) { + ++s.nwarned; + s.status[i] = WARNED; + printf("warnings %s\n", duration(t)); + } else { + ++ s.npassed; + s.status[i] = PASSED; + printf("passed. %s\n", duration(t)); + } +} + +static void skipped(int i, char *f) { + ++ s.nskipped; + s.status[i] = SKIPPED; + printf("skipped.\n"); +} + +static void failed(int i, char *f, int st) { + if (readbuf && strstr(readbuf, "TEST EXPECT FAIL")) { + printf("FAILED (expected).\n"); + s.status[i] = KNOWNFAIL; + ++ s.nknownfail; + return; + } + + ++ s.nfailed; + s.status[i] = FAILED; + if(die == 2) { + printf("interrupted.\n"); + return; + } + printf("FAILED.\n"); + if (!verbose) { + printf("-- FAILED %s ------------------------------------\n", f); + dump(); + printf("-- FAILED %s (end) ------------------------------\n", f); + } +} + +static void run(int i, char *f) { + pid = fork(); + if (pid < 0) { + perror("Fork failed."); + exit(201); + } else if (pid == 0) { + if (!interactive) { + close(0); + dup2(fds[0], 1); + dup2(fds[0], 2); + close(fds[0]); + close(fds[1]); + } + execlp("bash", "bash", f, NULL); + perror("execlp"); + fflush(stderr); + _exit(202); + } else { + int st, w; + time_t start = time(NULL); + char buf[128]; + snprintf(buf, 128, "%s ...", f); + buf[127] = 0; + printf("Running %-50s ", buf); + fflush(stdout); + while ((w = waitpid(pid, &st, WNOHANG)) == 0) { + drain(); + usleep(20000); + } + if (w != pid) { + perror("waitpid"); + exit(206); + } + drain(); + if (WIFEXITED(st)) { + if (WEXITSTATUS(st) == 0) { + passed(i, f, start); + } else if (WEXITSTATUS(st) == 200) { + skipped(i, f); + } else { + failed(i, f, st); + } + } else { + failed(i, f, st); + } + clear(); + } +} + +int main(int argc, char **argv) { + const char *be_verbose = getenv("VERBOSE"), + *be_interactive = getenv("INTERACTIVE"); + time_t start = time(NULL); + int i; + + if (argc >= MAX) { + fprintf(stderr, "Sorry, my head exploded. Please increase MAX.\n"); + exit(1); + } + + if (be_verbose) + verbose = atoi(be_verbose); + + if (be_interactive) + interactive = atoi(be_interactive); + + if (socketpair(PF_UNIX, SOCK_STREAM, 0, fds)) { + perror("socketpair"); + return 201; + } + + if ( fcntl( fds[1], F_SETFL, O_NONBLOCK ) == -1 ) { + perror("fcntl on socket"); + return 202; + } + + /* set up signal handlers */ + for (i = 0; i <= 32; ++i) { + if (i == SIGCHLD || i == SIGWINCH || i == SIGURG) + continue; + signal(i, handler); + } + + /* run the tests */ + for (i = 1; i < argc; ++ i) { + run(i, argv[i]); + if (die) + break; + } + + printf("\n## %d tests %s : %d OK, %d warnings, %d failures, %d known failures; %d skipped\n", + s.nwarned + s.npassed + s.nfailed + s.nskipped, + duration(start), + s.npassed, s.nwarned, s.nfailed, s.nknownfail, s.nskipped); + + /* print out a summary */ + if (s.nfailed || s.nskipped || s.nknownfail) { + for (i = 1; i < argc; ++ i) { + switch (s.status[i]) { + case FAILED: + printf("FAILED: %s\n", argv[i]); + break; + case KNOWNFAIL: + printf("FAILED (expected): %s\n", argv[i]); + break; + case SKIPPED: + printf("skipped: %s\n", argv[i]); + break; + } + } + printf("\n"); + return s.nfailed > 0 || die; + } + + free(readbuf); + + return die; +} diff --git a/test/lib/lvm-wrapper.sh b/test/lib/lvm-wrapper.sh new file mode 100644 index 0000000..d3a2a36 --- /dev/null +++ b/test/lib/lvm-wrapper.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# Copyright (C) 2011-2012 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/paths + +CMD=${0##*/} +test "$CMD" != lvm || unset CMD + +# Multiple level of LVM_VALGRIND support +# the higher level the more commands are traced +if test -n "$LVM_VALGRIND"; then + RUN_VALGRIND="aux run_valgrind"; + case "$CMD" in + lvs|pvs|vgs|vgck|vgscan) + test "$LVM_VALGRIND" -gt 2 || unset RUN_VALGRIND ;; + pvcreate|pvremove|lvremove|vgcreate|vgremove) + test "$LVM_VALGRIND" -gt 1 || unset RUN_VALGRIND ;; + *) + test "$LVM_VALGRIND" -gt 0 || unset RUN_VALGRIND ;; + esac +fi + +$RUN_VALGRIND "$abs_top_builddir/tools/lvm" $CMD "$@" && \ + rm -f debug.log # Remove log for successful command diff --git a/test/not.c b/test/lib/not.c index 534a356..9f6b988 100644 --- a/test/not.c +++ b/test/lib/not.c @@ -15,10 +15,11 @@ #include <unistd.h> #include <stdio.h> #include <stdarg.h> +#include <string.h> #include <sys/types.h> #include <sys/wait.h> -int finished(const char *cmd, int status) { +static int finished(const char *cmd, int status) { if (!strcmp(cmd, "not")) return !status; if (!strcmp(cmd, "should")) { diff --git a/test/lib/test.sh b/test/lib/test.sh new file mode 100644 index 0000000..3729749 --- /dev/null +++ b/test/lib/test.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# Copyright (C) 2011-2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# sanitize the environment +LANG=C +LC_ALL=C +TZ=UTC + +# Put script name into variable, so it can used in external scripts +TESTNAME=${0##*/} +# Nice debug message +PS4='#${BASH_SOURCE[0]##*/}:${LINENO}+ ' +export TESTNAME PS4 + +unset CDPATH + +# grab some common utilities +. lib/utils + +TESTOLDPWD=$(pwd) +COMMON_PREFIX="LVMTEST" +PREFIX="${COMMON_PREFIX}$$" + +TESTDIR=$(mkdtemp "${LVM_TEST_DIR:-$TESTOLDPWD}" "$PREFIX.XXXXXXXXXX") || \ + die "failed to create temporary directory in ${LVM_TEST_DIR:-$TESTOLDPWD}" +RUNNING_DMEVENTD=$(pgrep dmeventd) || true + +export TESTOLDPWD TESTDIR COMMON_PREFIX PREFIX RUNNING_DMEVENTD + +test -n "$BASH" && trap 'set +vx; STACKTRACE; set -vx' ERR +trap 'aux teardown' EXIT # don't forget to clean up + +DM_DEV_DIR="$TESTDIR/dev" +LVM_SYSTEM_DIR="$TESTDIR/etc" +mkdir "$LVM_SYSTEM_DIR" "$TESTDIR/lib" "$DM_DEV_DIR" +if test -n "$LVM_TEST_DEVDIR" ; then + DM_DEV_DIR=$LVM_TEST_DEVDIR +else + mknod "$DM_DEV_DIR/testnull" c 1 3 || die "mknod failed"; + echo >"$DM_DEV_DIR/testnull" || \ + die "Filesystem does support devices in $DM_DEV_DIR (mounted with nodev?)" + mkdir "$DM_DEV_DIR/mapper" +fi + +export DM_DEV_DIR LVM_SYSTEM_DIR + +cd "$TESTDIR" + +echo "$TESTNAME" >TESTNAME + +# Setting up symlink from $i to $TESTDIR/lib +find "$abs_top_builddir/daemons/dmeventd/plugins/" -name '*.so' \ + -exec ln -s -t lib "{}" + +find "$abs_top_builddir/test/lib" ! \( -name '*.sh' -o -name '*.[cdo]' \ + -o -name '*~' \) -exec ln -s -t lib "{}" + + +# Set vars from utils now that we have TESTDIR/PREFIX/... +prepare_test_vars + +test -n "$BASH" && set -eE -o pipefail + +aux lvmconf +aux prepare_clvmd +test -n "$LVM_TEST_LVMETAD" && { + aux prepare_lvmetad + export LVM_LVMETAD_SOCKET="$TESTDIR/lvmetad.socket" +} +echo "@TESTDIR=$TESTDIR" +echo "@PREFIX=$PREFIX" + +set -vx diff --git a/test/lib/utils.sh b/test/lib/utils.sh new file mode 100644 index 0000000..70d9f66 --- /dev/null +++ b/test/lib/utils.sh @@ -0,0 +1,215 @@ +#!/bin/bash +# Copyright (C) 2011-2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +set -e +MAX_TRIES=4 +IFS_NL=' +' + +die() { + echo "$@" >&2 + return 1 +} + +rand_bytes() { + n=$1 + + chars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" + + dev_rand="/dev/urandom" + if test -r "$dev_rand"; then + # Note: 256-length($chars) == 194; 3 copies of $chars is 186 + 8 = 194. + head -c"$n" "$dev_rand" | tr -c "$chars" "01234567$chars$chars$chars" + return + fi + + cmds='date; date +%N; free; who -a; w; ps auxww; ps ef; netstat -n' + data=$( (eval "$cmds") 2>&1 | gzip ) + + n_plus_50=$(expr $n + 50) + + # Ensure that $data has length at least 50+$n + while :; do + len=$(echo "$data" | wc -c) + test $n_plus_50 -le $len && break; + data=$( (echo "$data"; eval "$cmds") 2>&1 | gzip ) + done + + echo "$data" | dd bs=1 skip=50 count=$n 2>/dev/null \ + | tr -c "$chars" "01234567$chars$chars$chars" +} + +mkdtemp() { + case $# in + 2) ;; + *) die "Usage: mkdtemp DIR TEMPLATE";; + esac + + destdir=$1 + template=$2 + + case "$template" in + *XXXX) ;; + *) die "Invalid template: $template (must have a suffix of at least 4 X's)";; + esac + + fail=0 + + # First, try to use mktemp. + d=$(env -u TMPDIR mktemp -d -t -p "$destdir" "$template" 2>/dev/null) || fail=1 + + # The resulting name must be in the specified directory. + case "$d" in "${destdir}"*);; *) fail=1;; esac + + # It must have created the directory. + test -d "$d" || fail=1 + + # It must have 0700 permissions. + perms=$(ls -dgo "$d" 2>/dev/null) || fail=1 + case "$perms" in drwx------*) ;; *) fail=1;; esac + + test $fail = 0 && { echo "$d"; return; } + + # If we reach this point, we'll have to create a directory manually. + + # Get a copy of the template without its suffix of X's. + base_template=$(echo "$template" | sed 's/XX*$//') + + # Calculate how many X's we've just removed. + nx=$(expr length "$template" - length "$base_template") + + err= + i=1 + while :; do + X=$(rand_bytes "$nx") + candidate_dir="$destdir/$base_template$X" + err=$(mkdir -m 0700 "$candidate_dir" 2>&1) && \ + { echo "$candidate_dir"; return; } + test $MAX_TRIES -le $i && break; + i=$(expr $i + 1) + done + die "$err" +} + +STACKTRACE() { + trap - ERR + local i=0 + + echo "## - $0:${BASH_LINENO[0]}" + while FUNC=${FUNCNAME[$i]}; test "$FUNC" != "main"; do + echo "## $i ${FUNC}() called from ${BASH_SOURCE[$i]}:${BASH_LINENO[$i]}" + i=$(($i + 1)) + done + + test ${LVM_TEST_PARALLEL:-0} -eq 1 -o -n "$RUNNING_DMEVENTD" -o -f LOCAL_DMEVENTD || { + pgrep dmeventd &>/dev/null && \ + die "** During test dmeventd has been started!" + } + + # Get backtraces from coredumps + if which gdb &>/dev/null; then + echo bt full > gdb_commands.txt + echo l >> gdb_commands.txt + echo quit >> gdb_commands.txt + for core in $(ls core* 2>/dev/null); do + bin=$(gdb -batch -c "$core" 2>&1 | grep "generated by" | \ + sed -e "s,.*generated by \`\([^ ']*\).*,\1,") + gdb -batch -c "$core" -x gdb_commands.txt $(which "$bin") + done + fi + + test -z "$LVM_TEST_NODEBUG" -a -f debug.log && { + sed -e "s,^,## DEBUG: ,;s,$top_srcdir/\?,," < debug.log + } + + test -f SKIP_THIS_TEST && exit 200 +} + +init_udev_transaction() { + if test "$DM_UDEV_SYNCHRONISATION" = 1; then + local cookie=$(dmsetup udevcreatecookie) + # Cookie is not generated if udev is not running! + test -z "$cookie" || export DM_UDEV_COOKIE=$cookie + fi +} + +finish_udev_transaction() { + if test "$DM_UDEV_SYNCHRONISATION" = 1 -a -n "$DM_UDEV_COOKIE"; then + dmsetup udevreleasecookie + unset DM_UDEV_COOKIE + fi +} + +teardown_udev_cookies() { + if test "$DM_UDEV_SYNCHRONISATION" = 1; then + # Delete any cookies created more than 10 minutes ago + # and not used in the last 10 minutes. + # Log only non-zero semaphores count + (dmsetup udevcomplete_all -y 10 | grep -v "^0 ") || true + fi +} + +dm_info() { + should dmsetup info --noheadings -c -o "$@" +} + +dm_table() { + should dmsetup table "$@" +} + +skip() { + touch SKIP_THIS_TEST + exit 200 +} + +kernel_at_least() { + local major=$(uname -r | cut -d. -f1) + local minor=$(uname -r | cut -d. -f2 | cut -d- -f1) + + test "$major" -gt "$1" && return 0 + test "$major" -eq "$1" || return 1 + test "$minor" -gt "$2" && return 0 + test "$minor" -eq "$2" || return 1 + test -z "$3" && return 0 + + local minor2=$(uname -r | cut -d. -f3 | cut -d- -f1) + test -z "$minor2" -a "$3" -ne 0 && return 1 + test "$minor2" -ge "$3" 2>/dev/null || return 1 +} + +prepare_test_vars() { + vg="${PREFIX}vg" + lv=LV + + for i in $(seq 1 16); do + name="${PREFIX}pv$i" + dev="$DM_DEV_DIR/mapper/$name" + eval "dev$i=\"$dev\"" + eval "lv$i=LV$i" + eval "vg$i=${PREFIX}vg$i" + done +} + +# check if $abs_top_builddir was already set via 'lib/paths' +test -n "${abs_top_builddir+varset}" || . lib/paths || die "you must run make first" + +case "$PATH" in +*"$abs_top_builddir/test/lib"*) ;; +*) + PATH="$abs_top_builddir/test/lib":$PATH + for d in daemons/dmeventd/plugins/mirror daemons/dmeventd/plugins/snapshot \ + daemons/dmeventd/plugins/lvm2 daemons/dmeventd liblvm tools libdm; do + LD_LIBRARY_PATH="$abs_top_builddir/$d":$LD_LIBRARY_PATH + done + export PATH LD_LIBRARY_PATH ;; +esac + +test -z "$PREFIX" || prepare_test_vars diff --git a/test/lvm-utils.sh b/test/lvm-utils.sh deleted file mode 100644 index fec4e2c..0000000 --- a/test/lvm-utils.sh +++ /dev/null @@ -1,153 +0,0 @@ -# Put lvm-related utilities here. -# This file is sourced from test-lib.sh. - -# Copyright (C) 2007, 2008 Red Hat, Inc. All rights reserved. -# -# 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. -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -export LVM_SUPPRESS_FD_WARNINGS=1 - -ME=$(basename "$0") -warn() { echo >&2 "$ME: $@"; } - -trim() -{ - trimmed=${1%% } - trimmed=${trimmed## } - - echo "$trimmed" -} - -compare_two_fields_() -{ - local cmd1=$1; - local obj1=$2; - local field1=$3; - local cmd2=$4; - local obj2=$5; - local field2=$6; - local val1; - local val2; - - val1=$($cmd1 --noheadings -o $field1 $obj1) - val2=$($cmd2 --noheadings -o $field2 $obj2) -if test "$verbose" = "t" -then - echo "compare_two_fields_ $obj1($field1): $val1 $obj2($field2): $val2" -fi - test "$val1" = "$val2" -} - -compare_vg_field_() -{ - local vg1=$1; - local vg2=$2; - local field=$3; - local val1; - local val2; - - val1=$(vgs --noheadings -o $field $vg1) - val2=$(vgs --noheadings -o $field $vg2) -if test "$verbose" = "t" -then - echo "compare_vg_field_ VG1: $val1 VG2: $val2" -fi - test "$val1" = "$val2" -} - - -get_pv_field() { - local pv=$1 - local field=$2 - local value - pvs --noheading -o $field $pv | sed 's/^ *//' -} - -get_vg_field() { - local vg=$1 - local field=$2 - local value - vgs --noheading -o $field $vg | sed 's/^ *//' -} - -get_lv_field() { - local lv=$1 - local field=$2 - local value - lvs --noheading -o $field $lv | sed 's/^ *//' -} - -check_vg_field_() -{ - local vg=$1; - local field=$2; - local expected=$3; - local actual; - - actual=$(trim $(vgs --noheadings -o $field $vg)) -if test "$verbose" = "t" -then - echo "check_vg_field_ VG=$vg, field=$field, actual=$actual, expected=$expected" -fi - test "$actual" = "$expected" -} - -check_pv_field_() -{ - local pv=$1; - local field=$2; - local expected=$3; - local pvs_args=$4; # optional - local actual; - - actual=$(trim $(pvs --noheadings $pvs_args -o $field $pv)) -if test "$verbose" = "t" -then - echo "check_pv_field_ PV=$pv, field=$field, actual=$actual, expected=$expected" -fi - test "$actual" = "$expected" -} - -check_lv_field_() -{ - local lv=$1; - local field=$2; - local expected=$3; - local actual; - - actual=$(trim $(lvs --noheadings -o $field $lv)) -if test "$verbose" = "t" -then - echo "check_lv_field_ LV=$lv, field=$field, actual=$actual, expected=$expected" -fi - test "$actual" = "$expected" -} - -vg_validate_pvlv_counts_() -{ - local local_vg=$1 - local num_pvs=$2 - local num_lvs=$3 - local num_snaps=$4 - - lvs -a -o+devices $local_vg - - check_vg_field_ $local_vg pv_count $num_pvs && \ - check_vg_field_ $local_vg lv_count $num_lvs && \ - check_vg_field_ $local_vg snap_count $num_snaps -} - -dmsetup_has_dm_devdir_support_() -{ - # Detect support for the envvar. If it's supported, the - # following command will fail with the expected diagnostic. - out=$(DM_DEV_DIR=j dmsetup version 2>&1) - test "$?:$out" = "1:Invalid DM_DEV_DIR envvar value." -o \ - "$?:$out" = "1:Invalid DM_DEV_DIR environment variable value." -} diff --git a/test/mkdtemp b/test/mkdtemp deleted file mode 100755 index 89be8ac..0000000 --- a/test/mkdtemp +++ /dev/null @@ -1,120 +0,0 @@ -#!/bin/sh -# Create a temporary directory, sort of like mktemp -d does. - -# Copyright (C) 2007 Red Hat, Inc. All rights reserved. -# -# 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. -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -# Written by Jim Meyering. - -# Usage: mkdtemp /tmp phoey.XXXXXXXXXX - -# First, try to use the mktemp program. -# Failing that, we'll roll our own mktemp-like function: -# - try to get random bytes from /dev/urandom -# - failing that, generate output from a combination of quickly-varying -# sources and gzip. Ignore non-varying gzip header, and extract -# "random" bits from there. -# - given those bits, map to file-name bytes using tr, and try to create -# the desired directory. -# - make only $MAX_TRIES attempts - -ME=$(basename "$0") -die() { echo >&2 "$ME: $@"; exit 1; } - -MAX_TRIES=4 - -rand_bytes() -{ - n=$1 - - chars=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 - - dev_rand=/dev/urandom - if test -r "$dev_rand"; then - # Note: 256-length($chars) == 194; 3 copies of $chars is 186 + 8 = 194. - head -c$n "$dev_rand" | tr -c $chars 01234567$chars$chars$chars - return - fi - - cmds='date; date +%N; free; who -a; w; ps auxww; ps ef; netstat -n' - data=$( (eval "$cmds") 2>&1 | gzip ) - - n_plus_50=$(expr $n + 50) - - # Ensure that $data has length at least 50+$n - while :; do - len=$(echo "$data"|wc -c) - test $n_plus_50 -le $len && break; - data=$( (echo "$data"; eval "$cmds") 2>&1 | gzip ) - done - - echo "$data" \ - | dd bs=1 skip=50 count=$n 2>/dev/null \ - | tr -c $chars 01234567$chars$chars$chars -} - -mkdtemp() -{ - case $# in - 2);; - *) die "Usage: $ME DIR TEMPLATE";; - esac - - destdir=$1 - template=$2 - - case $template in - *XXXX) ;; - *) die "invalid template: $template (must have a suffix of at least 4 X's)";; - esac - - fail=0 - - # First, try to use mktemp. - d=$(env -u TMPDIR mktemp -d -t -p "$destdir" "$template" 2>/dev/null) \ - || fail=1 - - # The resulting name must be in the specified directory. - case $d in "$destdir"*);; *) fail=1;; esac - - # It must have created the directory. - test -d "$d" || fail=1 - - # It must have 0700 permissions. - perms=$(ls -dgo "$d" 2>/dev/null) || fail=1 - case $perms in drwx------*) ;; *) fail=1;; esac - - test $fail = 0 && { - echo "$d" - return - } - - # If we reach this point, we'll have to create a directory manually. - - # Get a copy of the template without its suffix of X's. - base_template=$(echo "$template"|sed 's/XX*$//') - - # Calculate how many X's we've just removed. - nx=$(expr length "$template" - length "$base_template") - - err= - i=1 - while :; do - X=$(rand_bytes $nx) - candidate_dir="$destdir/$base_template$X" - err=$(mkdir -m 0700 "$candidate_dir" 2>&1) \ - && { echo "$candidate_dir"; return; } - test $MAX_TRIES -le $i && break; - i=$(expr $i + 1) - done - die "$err" -} - -mkdtemp "$@" diff --git a/test/t-000-basic.sh b/test/shell/000-basic.sh index ed76a6f..83e6efe 100755..100644 --- a/test/t-000-basic.sh +++ b/test/shell/000-basic.sh @@ -1,4 +1,5 @@ -# Copyright (C) 2009 Red Hat, Inc. All rights reserved. +#!/bin/sh +# Copyright (C) 2009-2011 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions @@ -8,11 +9,11 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test lvm version -v=$abs_top_srcdir/lib/misc/lvm-version.h +v=$abs_top_builddir/lib/misc/lvm-version.h sed -n "/#define LVM_VERSION ./s///p" "$v" | sed "s/ .*//" > expected lvm pvmove --version|sed -n "1s/.*: *\([0-9][^ ]*\) .*/\1/p" > actual @@ -20,11 +21,9 @@ lvm pvmove --version|sed -n "1s/.*: *\([0-9][^ ]*\) .*/\1/p" > actual # ensure they are the same diff -u actual expected -mknod $DM_DEV_DIR/null c 1 3 || \ - error "Can't create nodes on filesystem" -echo >$DM_DEV_DIR/null || \ - error "Filesystem for tests does not allow using device nodes (check nodev)" - # ensure we can create devices (uses dmsetup, etc) aux prepare_devs 5 +# ensure we do not crash on a bug in config file +aux lvmconf 'log/prefix = 1""' +not lvs $(cat DEVICES) diff --git a/test/shell/activate-minor.sh b/test/shell/activate-minor.sh new file mode 100644 index 0000000..5433f01 --- /dev/null +++ b/test/shell/activate-minor.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# Copyright (C) 2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +aux prepare_vg 2 +lvcreate -a n --zero n -l 1 -n foo $vg +lvchange $vg/foo -My --major=255 --minor=123 +lvchange $vg/foo -a y +dmsetup info $vg-foo | tee info +egrep "^Major, minor: *[0-9]+, 123" info diff --git a/test/shell/activate-missing-segment.sh b/test/shell/activate-missing-segment.sh new file mode 100644 index 0000000..55ec7ec --- /dev/null +++ b/test/shell/activate-missing-segment.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# Copyright (C) 2010 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# Test activation behaviour with devices missing. +# - snapshots and their origins are only activated together; if one fails, both +# fail +# - partial mirrors are not activated (but maybe they should? maybe we should +# instead lvconvert --repair them?) +# - linear LVs with bits missing are not activated + +. lib/test + +aux prepare_vg 2 + +lvcreate -l100%FREE -n span $vg +vgchange -a n $vg + +aux disable_dev "$dev1" +not vgchange -a y $vg +vgchange -a y --partial $vg +check active $vg span diff --git a/test/t-activate-missing.sh b/test/shell/activate-missing.sh index 4242f21..4676ee1 100644 --- a/test/t-activate-missing.sh +++ b/test/shell/activate-missing.sh @@ -1,5 +1,4 @@ -#!/bin/bash - +#!/bin/sh # Copyright (C) 2010 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -17,22 +16,22 @@ # instead lvconvert --repair them?) # - linear LVs with bits missing are not activated -. ./test-utils.sh +. lib/test -prepare_vg 4 +aux prepare_vg 4 -lvcreate -l1 -n linear1 $vg $dev1 -lvcreate -l1 -n linear2 $vg $dev2 -lvcreate -l2 -n linear12 $vg $dev1:4 $dev2:4 +lvcreate -l1 -n linear1 $vg "$dev1" +lvcreate -l1 -n linear2 $vg "$dev2" +lvcreate -l2 -n linear12 $vg "$dev1":4 "$dev2":4 -lvcreate -l1 -n origin1 $vg $dev1 -lvcreate -s $vg/origin1 -l1 -n s_napshot2 $dev2 +lvcreate -l1 -n origin1 $vg "$dev1" +lvcreate -s $vg/origin1 -l1 -n s_napshot2 "$dev2" -lvcreate -l1 -m1 -n mirror12 --mirrorlog core $vg $dev1 $dev2 -lvcreate -l1 -m1 -n mirror123 $vg $dev1 $dev2 $dev3 +lvcreate -l1 -m1 -n mirror12 --mirrorlog core $vg "$dev1" "$dev2" +lvcreate -l1 -m1 -n mirror123 $vg "$dev1" "$dev2" "$dev3" vgchange -a n $vg -disable_dev $dev1 +aux disable_dev "$dev1" not vgchange -a y $vg not vgck $vg @@ -45,8 +44,8 @@ check inactive $vg mirror12 check inactive $vg mirror123 vgchange -a n $vg -enable_dev $dev1 -disable_dev $dev2 +aux enable_dev "$dev1" +aux disable_dev "$dev2" not vgchange -a y $vg not vgck $vg @@ -59,8 +58,8 @@ check inactive $vg mirror12 check inactive $vg mirror123 vgchange -a n $vg -enable_dev $dev2 -disable_dev $dev3 +aux enable_dev "$dev2" +aux disable_dev "$dev3" not vgchange -a y $vg not vgck $vg @@ -73,8 +72,8 @@ check inactive $vg mirror123 check active $vg mirror12 vgchange -a n $vg -enable_dev $dev3 -disable_dev $dev4 +aux enable_dev "$dev3" +aux disable_dev "$dev4" vgchange -a y $vg not vgck $vg diff --git a/test/t-activate-partial.sh b/test/shell/activate-partial.sh index b6bf9cb..4a06fc1 100644 --- a/test/t-activate-partial.sh +++ b/test/shell/activate-partial.sh @@ -1,3 +1,4 @@ +#!/bin/sh # Copyright (C) 2010 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -8,13 +9,13 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test aux prepare_vg 3 lvcreate -m 1 -l 1 -n mirror $vg lvchange -a n $vg/mirror -disable_dev $dev1 +aux disable_dev "$dev1" not vgreduce --removemissing $vg not lvchange -v -a y $vg/mirror diff --git a/test/shell/clvmd-restart.sh b/test/shell/clvmd-restart.sh new file mode 100644 index 0000000..2b341e5 --- /dev/null +++ b/test/shell/clvmd-restart.sh @@ -0,0 +1,53 @@ +#!/bin/sh +# Copyright (C) 2011 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# set before test's clvmd is started, so it's passed in environ +export LVM_CLVMD_BINARY=clvmd +export LVM_BINARY=lvm + +. lib/test + +# only clvmd based test, skip otherwise +test -e LOCAL_CLVMD || skip +read LOCAL_CLVMD < LOCAL_CLVMD + +aux prepare_pvs 1 + +vgcreate --clustered y $vg $(cat DEVICES) + +lvcreate -an --zero n -n $lv1 -l1 $vg +lvcreate -an --zero n -n $lv2 -l1 $vg +lvcreate -l1 $vg + +lvchange -aey $vg/$lv1 +lvchange -aey $vg/$lv2 + +"$LVM_CLVMD_BINARY" -S +sleep .2 +# restarted clvmd has the same PID (no fork, only execvp) +NEW_LOCAL_CLVMD=$(pgrep clvmd) +test "$LOCAL_CLVMD" -eq "$NEW_LOCAL_CLVMD" + +# try restart once more + +"$LVM_CLVMD_BINARY" -S +sleep .2 +# restarted clvmd has the same PID (no fork, only execvp) +NEW_LOCAL_CLVMD=$(pgrep clvmd) +test "$LOCAL_CLVMD" -eq "$NEW_LOCAL_CLVMD" + +# FIXME: Hmm - how could we test exclusivity is preserved in singlenode ? +lvchange -an $vg/$lv1 +lvchange -ay $vg/$lv1 + +"$LVM_CLVMD_BINARY" -R + +vgremove -ff $vg diff --git a/test/shell/covercmd.sh b/test/shell/covercmd.sh new file mode 100644 index 0000000..b77d378 --- /dev/null +++ b/test/shell/covercmd.sh @@ -0,0 +1,102 @@ +#!/bin/sh +# Copyright (C) 2008-2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# +# tests basic functionality of read-ahead and ra regressions +# + +. lib/test + +aux prepare_devs 5 + +TEST_UUID="aaaaaa-aaaa-aaaa-aaaa-aaaa-aaaa-aaaaaa" + +pvcreate "$dev1" +pvcreate --metadatacopies 0 "$dev2" +pvcreate --metadatacopies 0 "$dev3" +pvcreate "$dev4" +pvcreate --norestorefile -u $TEST_UUID --metadatacopies 0 "$dev5" +vgcreate -c n $vg $(cat DEVICES) +lvcreate -l 5 -i5 -I256 -n $lv $vg + +if aux have_readline; then +# test *scan and *display tools +cat <<EOF | lvm +pvscan +vgscan +lvscan +lvmdiskscan +vgdisplay --units k $vg +lvdisplay --units g $vg +pvdisplay -c "$dev1" +pvdisplay -s "$dev1" +vgdisplay -c $vg +vgdisplay -s $vg +lvdisplay -c $vg +EOF + +for i in h b s k m g t p e H B S K M G T P E; do + echo pvdisplay --units $i "$dev1" +done | lvm +else +pvscan +vgscan +lvscan +lvmdiskscan +vgdisplay --units k $vg +lvdisplay --units g $vg +pvdisplay -c "$dev1" +pvdisplay -s "$dev1" +vgdisplay -c $vg +vgdisplay -s $vg +lvdisplay -c $vg + +for i in h b s k m g t p e H B S K M G T P E; do + pvdisplay --units $i "$dev1" +done +fi + + +# test vgexport vgimport tools +vgchange -an $vg +vgexport $vg +vgimport $vg +vgchange -ay $vg + +# "-persistent y --major 254 --minor 20" +# "-persistent n" +# test various lvm utils +for i in dumpconfig formats segtypes; do + lvm $i +done + +for i in pr "p rw" an ay "-monitor y" "-monitor n" \ + -refresh "-addtag MYTAG" "-deltag MYETAG"; do + lvchange -$i $vg/$lv +done + +pvck "$dev1" +vgck $vg +lvrename $vg $lv $lv-rename +vgcfgbackup -f backup.$$ $vg +vgchange -an $vg +vgcfgrestore -f backup.$$ $vg +pvremove -y -ff "$dev5" +not vgcfgrestore -f backup.$$ $vg +pvcreate -u $TEST_UUID --restorefile backup.$$ "$dev5" +vgremove -f $vg +pvresize --setphysicalvolumesize 10M "$dev1" + +# test various errors and obsoleted tools +not lvmchange +not lvrename $vg +not lvrename $vg-xxx +not lvrename $vg $vg/$lv-rename $vg/$lv diff --git a/test/shell/discards-thin.sh b/test/shell/discards-thin.sh new file mode 100644 index 0000000..84688b4 --- /dev/null +++ b/test/shell/discards-thin.sh @@ -0,0 +1,50 @@ +#!/bin/sh + +# Copyright (C) 2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# test support of thin discards +# + +. lib/test + +# +# Main +# +aux have_thin 1 1 0 || skip + +aux prepare_pvs 2 64 + +vgcreate $vg -s 64K $(cat DEVICES) + +# Create named pool only +lvcreate -l1 --discards ignore -T $vg/pool +check lv_field $vg/pool discards "ignore" +lvcreate -l1 --discards nopassdown -T $vg/pool1 +check lv_field $vg/pool1 discards "nopassdown" +lvcreate -l1 --discards passdown -T $vg/pool2 +check lv_field $vg/pool2 discards "passdown" + +lvchange --discards nopassdown $vg/pool2 + +# cannot convert active ignore -> passdown +not lvchange --discards passdown $vg/pool + +# cannot convert active nopassdown -> ignore +not lvchange --discards ignore $vg/pool1 + +# deactivate +lvchange -an $vg/pool $vg/pool1 +lvchange --discards passdown $vg/pool +check lv_field $vg/pool discards "passdown" +lvchange --discards ignore $vg/pool1 +check lv_field $vg/pool1 discards "ignore" + +vgremove -ff $vg diff --git a/test/t-dmeventd-restart.sh b/test/shell/dmeventd-restart.sh index 6368d77..fa9db46 100644 --- a/test/t-dmeventd-restart.sh +++ b/test/shell/dmeventd-restart.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Copyright (C) 2008 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -9,12 +9,11 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test -prepare_vg 5 -prepare_dmeventd +aux prepare_dmeventd -which mkfs.ext2 || exit 200 +aux prepare_vg 5 lvcreate -m 3 --ig -L 1 -n 4way $vg lvchange --monitor y $vg/4way @@ -22,11 +21,31 @@ lvcreate -m 2 --ig -L 1 -n 3way $vg lvchange --monitor y $vg/3way dmeventd -R -f & -LOCAL_DMEVENTD="$!" - -sleep 1 # wait a bit, so we talk to the new dmeventd later +echo $! >LOCAL_DMEVENTD +sleep 2 # wait a bit, so we talk to the new dmeventd later lvchange --monitor y --verbose $vg/3way 2>&1 | tee lvchange.out grep 'already monitored' lvchange.out lvchange --monitor y --verbose $vg/4way 2>&1 | tee lvchange.out grep 'already monitored' lvchange.out + +# now try what happens if no dmeventd is running +kill -9 $(cat LOCAL_DMEVENTD) +rm LOCAL_DMEVENTD + +dmeventd -R -f & +echo $! >LOCAL_DMEVENTD + +# wait longer as tries to communicate with killed daemon +sleep 7 +# now dmeventd should not be running +not pgrep dmeventd +rm LOCAL_DMEVENTD + +# set dmeventd path +aux lvmconf "dmeventd/executable=\"$abs_top_builddir/test/lib/dmeventd\"" +lvchange --monitor y --verbose $vg/3way 2>&1 | tee lvchange.out +pgrep dmeventd >LOCAL_DMEVENTD +not grep 'already monitored' lvchange.out + +vgremove -ff $vg diff --git a/test/shell/dumpconfig.sh b/test/shell/dumpconfig.sh new file mode 100644 index 0000000..a16f753 --- /dev/null +++ b/test/shell/dumpconfig.sh @@ -0,0 +1,45 @@ +#!/bin/sh +# Copyright (C) 2011 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +flatten() { + cat > flatten.config + for s in `egrep '^[a-z]+ {$' flatten.config | sed -e s,{$,,`; do + sed -e "/^$s/,/^}/p;d" flatten.config | sed -e '1d;$d' | sed -e "s,^[ \t]*,$s/,"; + done +} + +# clvmd might not be started fast enough and +# lvm still activates locking for all commands. +# FIXME: Either make longer start delay, +# or even better do not initialize +# locking for commands like 'dumpconfig' +#aux lvmconf "global/locking_type=0" + +lvm dumpconfig -f lvmdumpconfig +flatten < lvmdumpconfig | sort > config.dump +flatten < etc/lvm.conf | sort > config.input +# check that dumpconfig output corresponds to the lvm.conf input +diff -wu config.input config.dump + +# and that merging multiple config files (through tags) works +lvm dumpconfig -f lvmdumpconfig +flatten < lvmdumpconfig | not grep 'log/verbose=1' +lvm dumpconfig -f lvmdumpconfig +flatten < lvmdumpconfig | grep 'log/indent=1' + +aux lvmconf 'tags/@foo {}' +echo 'log { verbose = 1 }' > etc/lvm_foo.conf +lvm dumpconfig -f lvmdumpconfig +flatten < lvmdumpconfig | grep 'log/verbose=1' +lvm dumpconfig -f lvmdumpconfig +flatten < lvmdumpconfig | grep 'log/indent=1' diff --git a/test/shell/fsadm.sh b/test/shell/fsadm.sh new file mode 100644 index 0000000..4e624db --- /dev/null +++ b/test/shell/fsadm.sh @@ -0,0 +1,160 @@ +#!/bin/sh +# Copyright (C) 2008-2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +test_description='Exercise fsadm filesystem resize' + +. lib/test + +aux prepare_vg 1 100 + +# set to "skip" to avoid testing given fs and test warning result +# i.e. check_reiserfs=skip +check_ext3= +check_xfs= +check_reiserfs= + +which mkfs.ext3 || check_ext3=${check_ext3:-mkfs.ext3} +which fsck.ext3 || check_ext3=${check_ext3:-fsck.ext3} +which mkfs.xfs || check_xfs=${check_xfs:-mkfs.xfs} +which xfs_check || check_xfs=${check_xfs:-xfs_check} +which mkfs.reiserfs || check_reiserfs=${check_reiserfs:-mkfs.reiserfs} +which reiserfsck || check_reiserfs=${check_reiserfs:-reiserfsck} + +vg_lv=$vg/$lv1 +vg_lv2=$vg/${lv1}bar +dev_vg_lv="$DM_DEV_DIR/$vg_lv" +dev_vg_lv2="$DM_DEV_DIR/$vg_lv2" +mount_dir="mnt" +mount_space_dir="mnt space dir" +# for recursive call +export LVM_BINARY=$(which lvm) + +test ! -d "$mount_dir" && mkdir "$mount_dir" +test ! -d "$mount_space_dir" && mkdir "$mount_space_dir" + +cleanup_mounted_and_teardown() +{ + umount "$mount_dir" || true + umount "$mount_space_dir" || true + aux teardown +} + +fscheck_ext3() +{ + fsck.ext3 -p -F -f "$dev_vg_lv" +} + +fscheck_xfs() +{ + xfs_check "$dev_vg_lv" +} + +fscheck_reiserfs() +{ + reiserfsck --check -p -f "$dev_vg_lv" </dev/null +} + +check_missing() +{ + eval local t=$\check_$1 + test -z "$t" && return 0 + test "$t" = skip && return 1 + # trick for warning test + echo "WARNING: fsadm test skipped $1 tests, $t tool is missing" + return 1 +} + +# Test for block sizes != 1024 (rhbz #480022) +lvcreate -n $lv1 -L20M $vg +lvcreate -n ${lv1}bar -L10M $vg +trap 'cleanup_mounted_and_teardown' EXIT + +if check_missing ext2; then + mkfs.ext2 -b4096 -j "$dev_vg_lv" + + fsadm --lvresize resize $vg_lv 30M + # Fails - not enough space for 4M fs + not fsadm -y --lvresize resize "$dev_vg_lv" 4M + lvresize -L+10M -r $vg_lv + lvreduce -L10M -r $vg_lv + + fscheck_ext3 + mount "$dev_vg_lv" "$mount_dir" + not fsadm -y --lvresize resize $vg_lv 4M + echo n | not lvresize -L4M -r -n $vg_lv + lvresize -L+20M -r -n $vg_lv + umount "$mount_dir" + fscheck_ext3 + + lvresize -f -L20M $vg_lv +fi + +if check_missing ext3; then + mkfs.ext3 -b4096 -j "$dev_vg_lv" + mkfs.ext3 -b4096 -j "$dev_vg_lv2" + + fsadm --lvresize resize $vg_lv 30M + # Fails - not enough space for 4M fs + not fsadm -y --lvresize resize "$dev_vg_lv" 4M + lvresize -L+10M -r $vg_lv + lvreduce -L10M -r $vg_lv + + fscheck_ext3 + mount "$dev_vg_lv" "$mount_dir" + lvresize -L+10M -r $vg_lv + mount "$dev_vg_lv2" "$mount_space_dir" + fsadm --lvresize -e -y resize $vg_lv2 25M + + not fsadm -y --lvresize resize $vg_lv 4M + echo n | not lvresize -L4M -r -n $vg_lv + lvresize -L+20M -r -n $vg_lv + umount "$mount_dir" + umount "$mount_space_dir" + fscheck_ext3 + + lvresize -f -L20M $vg_lv +fi + +if check_missing xfs; then + mkfs.xfs -l internal,size=1000b -f "$dev_vg_lv" + + fsadm --lvresize resize $vg_lv 30M + # Fails - not enough space for 4M fs + lvresize -L+10M -r $vg_lv + not lvreduce -L10M -r $vg_lv + + fscheck_xfs + mount "$dev_vg_lv" "$mount_dir" + lvresize -L+10M -r -n $vg_lv + umount "$mount_dir" + fscheck_xfs + + lvresize -f -L20M $vg_lv +fi + +if check_missing reiserfs; then + mkfs.reiserfs -s 513 -f "$dev_vg_lv" + + fsadm --lvresize resize $vg_lv 30M + lvresize -L+10M -r $vg_lv + fsadm --lvresize -y resize $vg_lv 10M + + fscheck_reiserfs + mount "$dev_vg_lv" "$mount_dir" + + fsadm -y --lvresize resize $vg_lv 30M + umount "$mount_dir" + fscheck_reiserfs + + lvresize -f -L20M $vg_lv +fi + +vgremove -ff $vg diff --git a/test/shell/inconsistent-metadata.sh b/test/shell/inconsistent-metadata.sh new file mode 100644 index 0000000..9f4ffd2 --- /dev/null +++ b/test/shell/inconsistent-metadata.sh @@ -0,0 +1,80 @@ +#!/bin/sh +# Copyright (C) 2008 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +aux prepare_vg 3 12 + +lvcreate -m 1 -l 1 -n mirror $vg +lvcreate -l 1 -n resized $vg +lvchange -a n $vg/mirror + +aux backup_dev $(cat DEVICES) + +init() { + aux restore_dev $(cat DEVICES) + lvs -o lv_name,lv_size --units k $vg | tee lvs.out + grep resized lvs.out | not grep 8192 + lvresize -L 8192K $vg/resized + aux restore_dev "$dev1" +} + +check() { + lvs -o lv_name,lv_size --units k $vg | tee lvs.out + grep resized lvs.out | grep 8192 +} + +# vgscan fixes up metadata (needs --cache option for direct scan if lvmetad is used) +test -e LOCAL_LVMETAD && cache="--cache" +init +vgscan $cache 2>&1 | tee cmd.out +grep "Inconsistent metadata found for VG $vg" cmd.out +test -e LOCAL_LVMETAD && vgrename $vg foo && vgrename foo $vg # trigger a write +vgscan $cache 2>&1 | tee cmd.out +not grep "Inconsistent metadata found for VG $vg" cmd.out +check + +# only vgscan would have noticed metadata inconsistencies when lvmetad is active +if !test -e LOCAL_LVMETAD; then + # vgdisplay fixes + init + vgdisplay $vg 2>&1 | tee cmd.out + grep "Inconsistent metadata found for VG $vg" cmd.out + vgdisplay $vg 2>&1 | tee cmd.out + not grep "Inconsistent metadata found for VG $vg" cmd.out + check + + # lvs fixes up + init + lvs $vg 2>&1 | tee cmd.out + grep "Inconsistent metadata found for VG $vg" cmd.out + vgdisplay $vg 2>&1 | tee cmd.out + not grep "Inconsistent metadata found for VG $vg" cmd.out + check + + # vgs fixes up as well + init + vgs $vg 2>&1 | tee cmd.out + grep "Inconsistent metadata found for VG $vg" cmd.out + vgs $vg 2>&1 | tee cmd.out + not grep "Inconsistent metadata found for VG $vg" cmd.out + check +fi + +echo Check auto-repair of failed vgextend - metadata written to original pv but not new pv +vgremove -f $vg +pvremove -ff $(cat DEVICES) +pvcreate $(cat DEVICES) +aux backup_dev "$dev2" +vgcreate $vg "$dev1" +vgextend $vg "$dev2" +aux restore_dev "$dev2" +should check compare_fields vgs $vg vg_mda_count pvs "$dev2" vg_mda_count diff --git a/test/t-listings.sh b/test/shell/listings.sh index 9ea10b6..b6e4dfa 100644 --- a/test/t-listings.sh +++ b/test/shell/listings.sh @@ -1,3 +1,4 @@ +#!/bin/sh # Copyright (C) 2008 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -12,64 +13,50 @@ # tests functionality of lvs, pvs, vgs, *display tools # -. ./test-utils.sh - -get_lvs_() -{ - case $(lvs --units s --nosuffix --noheadings -o $1_read_ahead "$vg"/"$lv") in - *$2) true ;; - *) false ;; - esac -} +. lib/test aux prepare_devs 5 -pvcreate $dev1 -pvcreate --metadatacopies 0 $dev2 -pvcreate --metadatacopies 0 $dev3 -pvcreate $dev4 -pvcreate --metadatacopies 0 $dev5 +pvcreate "$dev1" +pvcreate --metadatacopies 0 "$dev2" +pvcreate --metadatacopies 0 "$dev3" +pvcreate "$dev4" +pvcreate --metadatacopies 0 "$dev5" #COMM bz195276 -- pvs doesn't show PVs until a VG is created -pvs --noheadings|tee out -test $(wc -l <out) -eq 5 +test $(pvs --noheadings $(cat DEVICES) | wc -l) -eq 5 #COMM pvs with segment attributes works even for orphans -pvs --noheadings -o seg_all,pv_all,lv_all,vg_all | tee out -test $(wc -l <out) -eq 5 +test $(pvs --noheadings -o seg_all,pv_all,lv_all,vg_all $(cat DEVICES) | wc -l) -eq 5 -vgcreate -c n $vg $devs +vgcreate -c n $vg $(cat DEVICES) #COMM pvs and vgs report mda_count, mda_free (bz202886, bz247444) -pvs -o +pv_mda_count,pv_mda_free $devs -for I in $dev2 $dev3 $dev5; do - aux check_pv_field_ $I pv_mda_count 0 - aux check_pv_field_ $I pv_mda_free 0 +pvs -o +pv_mda_count,pv_mda_free $(cat DEVICES) +for I in "$dev2" "$dev3" "$dev5"; do + check pv_field $I pv_mda_count 0 + check pv_field $I pv_mda_free 0 done vgs -o +vg_mda_count,vg_mda_free $vg -aux check_vg_field_ $vg vg_mda_count 2 +check vg_field $vg vg_mda_count 2 #COMM pvs doesn't display --metadatacopies 0 PVs as orphans (bz409061) -pvdisplay $dev2|grep "VG Name.*$vg" -test $(pvs -o vg_name --noheadings $dev2) = $vg +pvdisplay "$dev2"|grep "VG Name.*$vg" +check pv_field "$dev2" vg_name $vg #COMM lvs displays snapshots (bz171215) lvcreate -l4 -n $lv1 $vg lvcreate -l4 -s -n $lv2 $vg/$lv1 -lvs $vg --noheadings|tee out -test $(wc -l <out) -eq 2 -lvs -a --noheadings|tee out +test $(lvs --noheadings $vg | wc -l) -eq 2 # should lvs -a display cow && real devices? (it doesn't) -test $(wc -l <out) -eq 2 +test $(lvs -a --noheadings $vg | wc -l) -eq 2 dmsetup ls|grep $PREFIX|grep -v "LVMTEST.*pv." lvremove -f $vg/$lv2 #COMM lvs -a displays mirror legs and log -lvcreate -l4 -m2 -n$lv3 $vg -lvs $vg --noheadings|tee out -test $(wc -l <out) -eq 2 -lvs -a --noheadings|tee out -test $(wc -l <out) -eq 6 +lvcreate -l4 -m2 -n $lv3 $vg +test $(lvs --noheadings $vg | wc -l) -eq 2 +test $(lvs -a --noheadings $vg | wc -l) -eq 6 dmsetup ls|grep $PREFIX|grep -v "LVMTEST.*pv." #COMM vgs with options from pvs still treats arguments as VGs (bz193543) @@ -77,7 +64,6 @@ vgs -o pv_name,vg_name $vg # would complain if not #COMM pvdisplay --maps feature (bz149814) -pvdisplay $devs >out -pvdisplay --maps $devs >out2 +pvdisplay $(cat DEVICES) >out +pvdisplay --maps $(cat DEVICES) >out2 not diff out out2 - diff --git a/test/t-lock-blocking.sh b/test/shell/lock-blocking.sh index 166340c..480a73b 100644 --- a/test/t-lock-blocking.sh +++ b/test/shell/lock-blocking.sh @@ -11,26 +11,31 @@ test_description='test some blocking / non-blocking multi-vg operations' -. ./test-utils.sh +. lib/test aux prepare_devs 3 -test -n "$LOCAL_CLVMD" && exit 200 -pvcreate $dev1 $dev2 -vgcreate $vg $dev1 $dev2 +test -e LOCAL_CLVMD && skip +pvcreate "$dev1" "$dev2" +vgcreate $vg "$dev1" "$dev2" # if wait_for_locks set, vgremove should wait for orphan lock # flock process should have exited by the time first vgremove completes flock -w 5 $TESTDIR/var/lock/lvm/P_orphans -c "sleep 10" & -flock_pid=`jobs -p` +while ! test -f $TESTDIR/var/lock/lvm/P_orphans ; do sleep .1 ; done + vgremove --config 'global { wait_for_locks = 1 }' $vg not vgremove --config 'global { wait_for_locks = 1 }' $vg -not ps $flock_pid # finished + +test ! -f $TESTDIR/var/lock/lvm/P_orphans # if wait_for_locks not set, vgremove should fail on non-blocking lock # we must wait for flock process at the end - vgremove won't wait -vgcreate $vg $dev1 $dev2 +vgcreate $vg "$dev1" "$dev2" flock -w 5 $TESTDIR/var/lock/lvm/P_orphans -c "sleep 10" & + +while ! test -f $TESTDIR/var/lock/lvm/P_orphans ; do sleep .1 ; done flock_pid=`jobs -p` + not vgremove --config 'global { wait_for_locks = 0 }' $vg -ps $flock_pid # still running +test -f $TESTDIR/var/lock/lvm/P_orphans # still running kill $flock_pid diff --git a/test/t-lvchange-mirror.sh b/test/shell/lvchange-mirror.sh index 7c915be..26656d4 100644 --- a/test/t-lvchange-mirror.sh +++ b/test/shell/lvchange-mirror.sh @@ -9,20 +9,22 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test + +aux prepare_dmeventd aux prepare_vg 3 # force resync 2-way active mirror -lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0-1 -check mirror $vg $lv1 $dev3 +lvcreate -l2 -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev3":0-1 +check mirror $vg $lv1 "$dev3" echo y | lvchange --resync $vg/$lv1 -check mirror $vg $lv1 $dev3 +check mirror $vg $lv1 "$dev3" lvremove -ff $vg # force resync 2-way inactive mirror -lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0-1 +lvcreate -l2 -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev3":0-1 lvchange -an $vg/$lv1 -check mirror $vg $lv1 $dev3 +check mirror $vg $lv1 "$dev3" lvchange --resync $vg/$lv1 -check mirror $vg $lv1 $dev3 +check mirror $vg $lv1 "$dev3" lvremove -ff $vg diff --git a/test/shell/lvchange-partial.sh b/test/shell/lvchange-partial.sh new file mode 100644 index 0000000..fe642d4 --- /dev/null +++ b/test/shell/lvchange-partial.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# Copyright (C) 2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +aux target_at_least dm-raid 1 1 0 || skip + +aux prepare_vg 2 + +lvcreate --type raid1 -m 1 -l 2 -n $lv1 $vg +lvchange -an $vg/$lv1 +aux disable_dev "$dev1" + +# +# Test for allowable metadata changes +# +# contiguous_ARG +lvchange -C y $vg/$lv1 +lvchange -C n $vg/$lv1 + +# permission_ARG +lvchange -p r $vg/$lv1 +lvchange -p rw $vg/$lv1 + +# readahead_ARG +lvchange -r none $vg/$lv1 +lvchange -r auto $vg/$lv1 + +# persistent_ARG +lvchange -M y --minor 56 --major 253 $vg/$lv1 +lvchange -M n $vg/$lv1 + +# addtag_ARG +# deltag_ARG +lvchange --addtag foo $vg/$lv1 +lvchange --deltag foo $vg/$lv1 + +# +# Test for disallowed metadata changes +# +# resync_ARG +not lvchange --resync $vg/$lv1 + +# alloc_ARG +not lvchange --alloc anywhere $vg/$lv1 + +# discards_ARG +not lvchange --discards ignore $vg/$lv1 + +# zero_ARG +not lvchange --zero y $vg/$lv1 + +# +# Ensure that allowed args don't cause disallowed args to get through +# +not lvchange --resync -ay $vg/$lv1 +not lvchange --resync --addtag foo $vg/$lv1 + diff --git a/test/t-lvconvert-mirror-basic-0.sh b/test/shell/lvconvert-mirror-basic-0.sh index eec6d5c..dc71bb8 100644 --- a/test/t-lvconvert-mirror-basic-0.sh +++ b/test/shell/lvconvert-mirror-basic-0.sh @@ -1,3 +1,4 @@ +#!/bin/sh # Copyright (C) 2010 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -8,5 +9,5 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./t-lvconvert-mirror-basic.sh +. ./shell/lvconvert-mirror-basic.sh test_many 0 diff --git a/test/t-lvconvert-mirror-basic-1.sh b/test/shell/lvconvert-mirror-basic-1.sh index 7019dbb..b7ebf9e 100644 --- a/test/t-lvconvert-mirror-basic-1.sh +++ b/test/shell/lvconvert-mirror-basic-1.sh @@ -1,3 +1,4 @@ +#!/bin/sh # Copyright (C) 2010 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -8,5 +9,5 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./t-lvconvert-mirror-basic.sh +. ./shell/lvconvert-mirror-basic.sh test_many 1 diff --git a/test/t-lvconvert-mirror-basic-2.sh b/test/shell/lvconvert-mirror-basic-2.sh index 85d54c9..d47f77d 100644 --- a/test/t-lvconvert-mirror-basic-2.sh +++ b/test/shell/lvconvert-mirror-basic-2.sh @@ -1,3 +1,4 @@ +#!/bin/sh # Copyright (C) 2010 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -8,5 +9,5 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./t-lvconvert-mirror-basic.sh +. ./shell/lvconvert-mirror-basic.sh test_many 2 diff --git a/test/t-lvconvert-mirror-basic-3.sh b/test/shell/lvconvert-mirror-basic-3.sh index 0c57580..732fb2d 100644 --- a/test/t-lvconvert-mirror-basic-3.sh +++ b/test/shell/lvconvert-mirror-basic-3.sh @@ -1,3 +1,4 @@ +#!/bin/sh # Copyright (C) 2010 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -8,5 +9,5 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./t-lvconvert-mirror-basic.sh +. ./shell/lvconvert-mirror-basic.sh test_many 3 diff --git a/test/t-lvconvert-mirror-basic.sh b/test/shell/lvconvert-mirror-basic.sh index 880bd09..a0f50f6 100644 --- a/test/t-lvconvert-mirror-basic.sh +++ b/test/shell/lvconvert-mirror-basic.sh @@ -1,4 +1,5 @@ -# Copyright (C) 2010 Red Hat, Inc. All rights reserved. +#!/bin/sh +# Copyright (C) 2010-2012 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions @@ -8,17 +9,14 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test -log_name_to_count() -{ - if [ "$1" = "mirrored" ]; then - echo 2 - elif [ "$1" = "disk" ]; then - echo 1 - else - echo 0 - fi +log_name_to_count() { + case "$1" in + mirrored) echo 2 ;; + disk) echo 1 ;; + *) echo 0 ;; + esac } # FIXME: For test_[up|down]convert, I'd still like to be able @@ -38,15 +36,14 @@ log_name_to_count() # 2-way disk-log mirror while not active # -> test_lvconvert 2 disk 3 disk 0 -test_lvconvert() -{ +test_lvconvert() { local start_count=$1 local start_count_p1=$(($start_count + 1)) local start_log_type=$2 local finish_count=$3 local finish_count_p1=$(($finish_count + 1)) local finish_log_type=$4 - local dev_array=($dev1 $dev2 $dev3 $dev4 $dev5) + local dev_array=("$dev1" "$dev2" "$dev3" "$dev4" "$dev5") local start_log_count local finish_log_count local max_log_count @@ -54,37 +51,25 @@ test_lvconvert() local active=true local i - if [ "$start_log_type" = "disk" ] && - [ "$finish_log_type" = "mirrored" ]; then - echo "FIXME: disk -> mirrored log conversion not yet supported by LVM" - return 0 - fi - test "$5" = "active" && active=false #test $finish_count -gt $start_count && up=true # Do we have enough devices for the mirror images? - if [ $start_count_p1 -gt ${#dev_array[@]} ]; then - echo "Action requires too many devices" - return 1 - fi + test $start_count_p1 -gt ${#dev_array[@]} && \ + die "Action requires too many devices" # Do we have enough devices for the mirror images? - if [ $finish_count_p1 -gt ${#dev_array[@]} ]; then - echo "Action requires too many devices" - return 1 - fi + test $finish_count_p1 -gt ${#dev_array[@]} && \ + die "Action requires too many devices" - start_log_count=`log_name_to_count $start_log_type` - finish_log_count=`log_name_to_count $finish_log_type` + start_log_count=$(log_name_to_count $start_log_type) + finish_log_count=$(log_name_to_count $finish_log_type) if [ $finish_log_count -gt $start_log_count ]; then max_log_count=$finish_log_count else max_log_count=$start_log_count fi - prepare_vg 5 - if [ $start_count -gt 0 ]; then # Are there extra devices for the log or do we overlap if [ $(($start_count_p1 + $start_log_count)) -gt ${#dev_array[@]} ]; then @@ -100,21 +85,17 @@ test_lvconvert() fi lvs -a -o name,copy_percent,devices $vg - if ! $active; then - lvchange -an $vg/$lv1 - fi + test $active || lvchange -an $vg/$lv1 # Are there extra devices for the log or do we overlap if [ $(($finish_count_p1 + $finish_log_count)) -gt ${#dev_array[@]} ]; then alloc="--alloc anywhere" fi - echo y | lvconvert -m $finish_count --mirrorlog $finish_log_type \ + lvconvert -m $finish_count --mirrorlog $finish_log_type \ $vg/$lv1 $alloc - if ! $active; then - lvchange -ay $vg/$lv1 - fi + test $active || lvchange -ay $vg/$lv1 check mirror_no_temporaries $vg $lv1 if [ "$finish_count_p1" -eq 1 ]; then @@ -129,7 +110,8 @@ test_lvconvert() fi } -aux prepare_vg 5 +aux prepare_pvs 5 5 +vgcreate -c n -s 128k $vg $(cat DEVICES) test_many() { i=$1 @@ -141,7 +123,9 @@ test_many() { : "Testing mirror conversion -m$i/$k -> -m$j/$l" : ---------------------------------------------------- test_lvconvert $i $k $j $l 0 + lvremove -ff $vg test_lvconvert $i $k $j $l 1 + lvremove -ff $vg done done done diff --git a/test/shell/lvconvert-mirror.sh b/test/shell/lvconvert-mirror.sh new file mode 100644 index 0000000..c09b8fd --- /dev/null +++ b/test/shell/lvconvert-mirror.sh @@ -0,0 +1,280 @@ +#!/bin/sh +# Copyright (C) 2010 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +aux prepare_pvs 5 10 +# FIXME - test fails with extent size < 512k +vgcreate -c n -s 512k $vg $(cat DEVICES) + +# convert from linear to 2-way mirror +lvcreate -l2 -n $lv1 $vg "$dev1" +lvconvert -i1 -m+1 $vg/$lv1 "$dev2" "$dev3:0-1" +check mirror $vg $lv1 "$dev3" +lvremove -ff $vg + +# convert from linear to 2-way mirror - with tags and volume_list (bz683270) +lvcreate -l2 -n $lv1 $vg --addtag hello +lvconvert -i1 -m+1 $vg/$lv1 \ + --config 'activation { volume_list = [ "@hello" ] }' +lvremove -ff $vg + +# convert from 2-way to 3-way mirror - with tags and volume_list (bz683270) +lvcreate -l2 -m1 -n $lv1 $vg --addtag hello +lvconvert -i1 -m+1 $vg/$lv1 \ + --config 'activation { volume_list = [ "@hello" ] }' +lvremove -ff $vg + +# convert from 2-way mirror to linear +lvcreate -l2 -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev3:0-1" +lvconvert -m-1 $vg/$lv1 +check linear $vg $lv1 +lvremove -ff $vg +# and now try removing a specific leg (bz453643) +lvcreate -l2 -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev3:0-1" +lvconvert -m0 $vg/$lv1 "$dev2" +check lv_on $vg $lv1 "$dev1" +lvremove -ff $vg + +# convert from disklog to corelog, active +lvcreate -l2 -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev3:0-1" +lvconvert -f --mirrorlog core $vg/$lv1 +check mirror $vg $lv1 core +lvremove -ff $vg + +# convert from corelog to disklog, active +lvcreate -l2 -m1 --mirrorlog core -n $lv1 $vg "$dev1" "$dev2" +lvconvert --mirrorlog disk $vg/$lv1 "$dev3:0-1" +check mirror $vg $lv1 "$dev3" +lvremove -ff $vg + +# bz192865: lvconvert log of an inactive mirror lv +# convert from disklog to corelog, inactive +lvcreate -l2 -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev3:0-1" +lvchange -an $vg/$lv1 +echo y | lvconvert -f --mirrorlog core $vg/$lv1 +check mirror $vg $lv1 core +lvremove -ff $vg + +# convert from corelog to disklog, inactive +lvcreate -l2 -m1 --mirrorlog core -n $lv1 $vg "$dev1" "$dev2" +lvchange -an $vg/$lv1 +lvconvert --mirrorlog disk $vg/$lv1 "$dev3:0-1" +check mirror $vg $lv1 "$dev3" +lvremove -ff $vg + +# convert linear to 2-way mirror with 1 PV +lvcreate -l2 -n $lv1 $vg "$dev1" +not lvconvert -m+1 --mirrorlog core $vg/$lv1 "$dev1" +lvremove -ff $vg + +# Start w/ 3-way mirror +# Test pulling primary image before mirror in-sync (should fail) +# Test pulling primary image after mirror in-sync (should work) +# Test that the correct devices remain in the mirror +lvcreate -l2 -m2 -n $lv1 $vg "$dev1" "$dev2" "$dev4" "$dev3:0" +# FIXME: +# This is somewhat timing dependent - sync /could/ finish before +# we get a chance to have this command fail +should not lvconvert -m-1 $vg/$lv1 "$dev1" + +lvconvert $vg/$lv1 # wait +lvconvert -m2 $vg/$lv1 "$dev1" "$dev2" "$dev4" "$dev3:0" # If the above "should" failed... + +aux wait_for_sync $vg $lv1 +lvconvert -m-1 $vg/$lv1 "$dev1" +check mirror_images_on $lv1 "$dev2" "$dev4" +lvconvert -m-1 $vg/$lv1 "$dev2" +check linear $vg $lv1 +check lv_on $vg $lv1 "$dev4" +lvremove -ff $vg + +# No parallel lvconverts on a single LV please + +lvcreate -l5 -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev3:0" +check mirror $vg $lv1 +check mirror_legs $vg $lv1 2 +lvconvert -m+1 -b $vg/$lv1 "$dev4" + +# Next convert should fail b/c we can't have 2 at once +should not lvconvert -m+1 $vg/$lv1 "$dev5" +lvconvert $vg/$lv1 # wait +lvconvert -m2 $vg/$lv1 # In case the above "should" actually failed + +check mirror $vg $lv1 "$dev3" +check mirror_no_temporaries $vg $lv1 +check mirror_legs $vg $lv1 3 +lvremove -ff $vg + +# add 1 mirror to core log mirror, but +# implicitly keep log as 'core' +lvcreate -l2 -m1 --mirrorlog core -n $lv1 $vg "$dev1" "$dev2" +lvconvert -m +1 -i1 $vg/$lv1 + +check mirror $vg $lv1 core +check mirror_no_temporaries $vg $lv1 +check mirror_legs $vg $lv1 3 +lvremove -ff $vg + +# remove 1 mirror from corelog'ed mirror; should retain 'core' log type +lvcreate -l2 -m2 --corelog -n $lv1 $vg +lvconvert -m -1 -i1 $vg/$lv1 + +check mirror $vg $lv1 core +check mirror_no_temporaries $vg $lv1 +check mirror_legs $vg $lv1 2 +lvremove -ff $vg + +# add 1 mirror then add 1 more mirror during conversion +# FIXME this has been explicitly forbidden? +#lvcreate -l2 -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev3":0 +#lvconvert -m+1 -b $vg/$lv1 "$dev4" +#lvconvert -m+1 $vg/$lv1 "$dev5" +# +#check mirror $vg $lv1 "$dev3" +#check mirror_no_temporaries $vg $lv1 +#check mirror_legs $vg $lv1 4 +#lvremove -ff $vg + +# Linear to mirror with mirrored log using --alloc anywhere +lvcreate -l2 -n $lv1 $vg "$dev1" +lvconvert -m +1 --mirrorlog mirrored --alloc anywhere $vg/$lv1 "$dev1" "$dev2" +should check mirror $vg $lv1 +lvremove -ff $vg + +# convert inactive mirror and start polling +lvcreate -l2 -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev3:0" +lvchange -an $vg/$lv1 +lvconvert -m+1 $vg/$lv1 "$dev4" +lvchange -ay $vg/$lv1 +lvconvert $vg/$lv1 # wait +check mirror $vg $lv1 "$dev3" +check mirror_no_temporaries $vg $lv1 +lvremove -ff $vg + +# --------------------------------------------------------------------- +# removal during conversion + +# "remove newly added mirror" +lvcreate -l2 -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev3:0" +lvconvert -m+1 -b $vg/$lv1 "$dev4" +lvconvert -m-1 $vg/$lv1 "$dev4" +lvconvert $vg/$lv1 # wait + +check mirror $vg $lv1 "$dev3" +check mirror_no_temporaries $vg $lv1 +check mirror_legs $vg $lv1 2 +lvremove -ff $vg + +# "remove one of newly added mirrors" +lvcreate -l2 -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev3:0" +lvconvert -m+2 -b $vg/$lv1 "$dev4" "$dev5" +lvconvert -m-1 $vg/$lv1 "$dev4" +lvconvert $vg/$lv1 # wait + +check mirror $vg $lv1 "$dev3" +check mirror_no_temporaries $vg $lv1 +check mirror_legs $vg $lv1 3 +lvremove -ff $vg + +# "remove from original mirror (the original is still mirror)" +lvcreate -l2 -m2 -n $lv1 $vg "$dev1" "$dev2" "$dev5" "$dev3:0" +lvconvert -m+1 -b $vg/$lv1 "$dev4" +lvconvert -m-1 $vg/$lv1 "$dev2" +lvconvert $vg/$lv1 + +check mirror $vg $lv1 "$dev3" +check mirror_no_temporaries $vg $lv1 +check mirror_legs $vg $lv1 3 +lvremove -ff $vg + +# "remove from original mirror (the original becomes linear)" +lvcreate -l2 -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev3:0" +lvconvert -m+1 -b $vg/$lv1 "$dev4" +lvconvert -m-1 $vg/$lv1 "$dev2" +lvconvert $vg/$lv1 + +check mirror $vg $lv1 "$dev3" +check mirror_no_temporaries $vg $lv1 +check mirror_legs $vg $lv1 2 +lvremove -ff $vg + +# --------------------------------------------------------------------- + +# "rhbz440405: lvconvert -m0 incorrectly fails if all PEs allocated" +lvcreate -l`pvs --noheadings -ope_count "$dev1"` -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev3:0" +aux wait_for_sync $vg $lv1 +lvconvert -m0 $vg/$lv1 "$dev1" +check linear $vg $lv1 +lvremove -ff $vg + +# "rhbz264241: lvm mirror doesn't lose it's "M" --nosync attribute after being down and the up converted" +lvcreate -l2 -m1 -n$lv1 --nosync $vg +lvconvert -m0 $vg/$lv1 +lvconvert -m1 $vg/$lv1 +lvs --noheadings -o attr $vg/$lv1 | grep '^ *m' +lvremove -ff $vg + +# lvconvert from linear (on multiple PVs) to mirror +lvcreate -l 8 -n $lv1 $vg "$dev1:0-3" "$dev2:0-3" +lvconvert -m1 $vg/$lv1 + +should check mirror $vg $lv1 +check mirror_legs $vg $lv1 2 +lvremove -ff $vg + +# BZ 463272: disk log mirror convert option is lost if downconvert option is also given +lvcreate -l1 -m2 --corelog -n $lv1 $vg "$dev1" "$dev2" "$dev3" +aux wait_for_sync $vg $lv1 +lvconvert -m1 --mirrorlog disk $vg/$lv1 +check mirror $vg $lv1 +not check mirror $vg $lv1 core +lvremove -ff $vg + +# --- +# add mirror and disk log + +# "add 1 mirror and disk log" +lvcreate -l2 -m1 --mirrorlog core -n $lv1 $vg "$dev1" "$dev2" + +# FIXME on next line, specifying $dev3:0 $dev4 (i.e log device first) fails (!) +lvconvert -m+1 --mirrorlog disk -i1 $vg/$lv1 "$dev4" "$dev3:0" + +check mirror $vg $lv1 "$dev3" +check mirror_no_temporaries $vg $lv1 +check mirror_legs $vg $lv1 3 +lvremove -ff $vg + +# simple mirrored stripe +lvcreate -i2 -l10 -n $lv1 $vg +lvconvert -m1 -i1 $vg/$lv1 +lvreduce -f -l1 $vg/$lv1 +lvextend -f -l10 $vg/$lv1 +lvremove -ff $vg/$lv1 + +# extents must be divisible +lvcreate -l15 -n $lv1 $vg +not lvconvert -m1 --corelog --stripes 2 $vg/$lv1 +lvremove -ff $vg + +# Should not be able to add images to --nosync mirror +# but should be able to after 'lvchange --resync' +lvcreate -m 1 -l1 -n $lv1 $vg --nosync +not lvconvert -m +1 $vg/$lv1 +lvchange --resync -y $vg/$lv1 +lvconvert -m +1 $vg/$lv1 +lvremove -ff $vg + +lvcreate -m 1 --corelog -l1 -n $lv1 $vg --nosync +not lvconvert -m +1 $vg/$lv1 +lvchange --resync -y $vg/$lv1 +lvconvert -m +1 $vg/$lv1 +lvremove -ff $vg diff --git a/test/shell/lvconvert-raid.sh b/test/shell/lvconvert-raid.sh new file mode 100644 index 0000000..4fa766d --- /dev/null +++ b/test/shell/lvconvert-raid.sh @@ -0,0 +1,223 @@ +#!/bin/sh +# Copyright (C) 2011-2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +get_image_pvs() { + local d + local images + + images=`dmsetup ls | grep ${1}-${2}_.image_.* | cut -f1 | sed -e s:-:/:` + lvs --noheadings -a -o devices $images | sed s/\(.\)// +} + +######################################################## +# MAIN +######################################################## +aux target_at_least dm-raid 1 1 0 || skip +aux kernel_at_least 3 2 0 || skip + +# 9 PVs needed for RAID10 testing (3-stripes/2-mirror - replacing 3 devs) +aux prepare_pvs 9 80 +vgcreate -c n -s 256k $vg $(cat DEVICES) + +########################################### +# RAID1 convert tests +########################################### +for under_snap in false true; do +for i in 1 2 3 4; do + for j in 1 2 3 4; do + if [ $i -eq 1 ]; then + from="linear" + else + from="$i-way" + fi + if [ $j -eq 1 ]; then + to="linear" + else + to="$j-way" + fi + + echo -n "Converting from $from to $to" + if $under_snap; then + echo -n " (while under a snapshot)" + fi + echo + + if [ $i -eq 1 ]; then + # Shouldn't be able to create with just 1 image + not lvcreate --type raid1 -m 0 -l 2 -n $lv1 $vg + + lvcreate -l 2 -n $lv1 $vg + else + lvcreate --type raid1 -m $(($i - 1)) -l 2 -n $lv1 $vg + aux wait_for_sync $vg $lv1 + fi + + if $under_snap; then + lvcreate -s $vg/$lv1 -n snap -l 2 + fi + + lvconvert -m $((j - 1)) $vg/$lv1 + + # FIXME: ensure no residual devices + + if [ $j -eq 1 ]; then + check linear $vg $lv1 + fi + lvremove -ff $vg + done +done +done + +############################################## +# RAID1 - shouldn't be able to add image +# if created '--nosync', but should +# be able to after 'lvchange --resync' +############################################## +lvcreate --type raid1 -m 1 -l 2 -n $lv1 $vg --nosync +not lvconvert -m +1 $vg/$lv1 +lvchange --resync -y $vg/$lv1 +aux wait_for_sync $vg $lv1 +lvconvert -m +1 $vg/$lv1 +lvremove -ff $vg + +# 3-way to 2-way convert while specifying devices +lvcreate --type raid1 -m 2 -l 2 -n $lv1 $vg $dev1 $dev2 $dev3 +aux wait_for_sync $vg $lv1 +lvconvert -m1 $vg/$lv1 $dev2 +lvremove -ff $vg + +# +# FIXME: Add tests that specify particular devices to be removed +# + +########################################### +# RAID1 split tests +########################################### +# 3-way to 2-way/linear +lvcreate --type raid1 -m 2 -l 2 -n $lv1 $vg +aux wait_for_sync $vg $lv1 +lvconvert --splitmirrors 1 -n $lv2 $vg/$lv1 +check lv_exists $vg $lv1 +check linear $vg $lv2 +# FIXME: ensure no residual devices +lvremove -ff $vg + +# 2-way to linear/linear +lvcreate --type raid1 -m 1 -l 2 -n $lv1 $vg +aux wait_for_sync $vg $lv1 +lvconvert --splitmirrors 1 -n $lv2 $vg/$lv1 +check linear $vg $lv1 +check linear $vg $lv2 +# FIXME: ensure no residual devices +lvremove -ff $vg + +# 3-way to linear/2-way +lvcreate --type raid1 -m 2 -l 2 -n $lv1 $vg +aux wait_for_sync $vg $lv1 +# FIXME: Can't split off a RAID1 from a RAID1 yet +# 'should' results in "warnings" +should lvconvert --splitmirrors 2 -n $lv2 $vg/$lv1 +#check linear $vg $lv1 +#check lv_exists $vg $lv2 +# FIXME: ensure no residual devices +lvremove -ff $vg + +########################################### +# RAID1 split + trackchanges / merge +########################################### +# 3-way to 2-way/linear +lvcreate --type raid1 -m 2 -l 2 -n $lv1 $vg +aux wait_for_sync $vg $lv1 +lvconvert --splitmirrors 1 --trackchanges $vg/$lv1 +check lv_exists $vg $lv1 +check linear $vg ${lv1}_rimage_2 +lvconvert --merge $vg/${lv1}_rimage_2 +# FIXME: ensure no residual devices +lvremove -ff $vg + +########################################### +# Mirror to RAID1 conversion +########################################### +for i in 1 2 3 ; do + lvcreate --type mirror -m $i -l 2 -n $lv1 $vg + aux wait_for_sync $vg $lv1 + lvconvert --type raid1 $vg/$lv1 + lvremove -ff $vg +done + +########################################### +# Device Replacement Testing +########################################### +# RAID1: Replace up to n-1 devices - trying different combinations +# Test for 2-way to 4-way RAID1 LVs +for i in {1..3}; do + lvcreate --type raid1 -m $i -l 2 -n $lv1 $vg + + for j in $(seq $(($i + 1))); do # The number of devs to replace at once + for o in $(seq 0 $i); do # The offset into the device list + replace="" + + devices=( $(get_image_pvs $vg $lv1) ) + + for k in $(seq $j); do + index=$((($k + $o) % ($i + 1))) + replace="$replace --replace ${devices[$index]}" + done + aux wait_for_sync $vg $lv1 + + if [ $j -ge $((i + 1)) ]; then + # Can't replace all at once. + not lvconvert $replace $vg/$lv1 + else + lvconvert $replace $vg/$lv1 + fi + done + done + + lvremove -ff $vg +done + +# RAID 4/5/6 (can replace up to 'parity' devices) +for i in 4 5 6; do + lvcreate --type raid$i -i 3 -l 3 -n $lv1 $vg + + if [ $i -eq 6 ]; then + dev_cnt=5 + limit=2 + else + dev_cnt=4 + limit=1 + fi + + for j in {1..3}; do + for o in $(seq 0 $i); do + replace="" + + devices=( $(get_image_pvs $vg $lv1) ) + + for k in $(seq $j); do + index=$((($k + $o) % $dev_cnt)) + replace="$replace --replace ${devices[$index]}" + done + aux wait_for_sync $vg $lv1 + + if [ $j -gt $limit ]; then + not lvconvert $replace $vg/$lv1 + else + lvconvert $replace $vg/$lv1 + fi + done + done + + lvremove -ff $vg +done diff --git a/test/shell/lvconvert-raid10.sh b/test/shell/lvconvert-raid10.sh new file mode 100644 index 0000000..2e4381d --- /dev/null +++ b/test/shell/lvconvert-raid10.sh @@ -0,0 +1,56 @@ +#!/bin/sh +# Copyright (C) 2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +get_image_pvs() { + local d + local images + + images=`dmsetup ls | grep ${1}-${2}_.image_.* | cut -f1 | sed -e s:-:/:` + lvs --noheadings -a -o devices $images | sed s/\(.\)// +} + +######################################################## +# MAIN +######################################################## +# RAID10: Can replace 'copies - 1' devices from each stripe +# Tests are run on 2-way mirror, 3-way stripe RAID10 +aux target_at_least dm-raid 1 3 1 || skip + +# 9 PVs needed for RAID10 testing (3-stripes/2-mirror - replacing 3 devs) +aux prepare_pvs 9 80 +vgcreate -c n -s 256k $vg $(cat DEVICES) + +lvcreate --type raid10 -m 1 -i 3 -l 3 -n $lv1 $vg +aux wait_for_sync $vg $lv1 + +# Can replace any single device +for i in $(get_image_pvs $vg $lv1); do + lvconvert --replace $i $vg/$lv1 + aux wait_for_sync $vg $lv1 +done + +# Can't replace adjacent devices +devices=( $(get_image_pvs $vg $lv1) ) +not lvconvert --replace ${devices[0]} --replace ${devices[1]} $vg/$lv1 +not lvconvert --replace ${devices[2]} --replace ${devices[3]} $vg/$lv1 +not lvconvert --replace ${devices[4]} --replace ${devices[5]} $vg/$lv1 + +# Can replace non-adjacent devices +for i in 0 1; do + lvconvert \ + --replace ${devices[$i]} \ + --replace ${devices[$(($i + 2))]} \ + --replace ${devices[$(($i + 4))]} \ + $vg/$lv1 + aux wait_for_sync $vg $lv1 +done diff --git a/test/t-lvconvert-repair-dmeventd.sh b/test/shell/lvconvert-repair-dmeventd.sh index f80a410..66e4cc8 100644 --- a/test/t-lvconvert-repair-dmeventd.sh +++ b/test/shell/lvconvert-repair-dmeventd.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Copyright (C) 2008 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -9,18 +9,20 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test -prepare_vg 5 -prepare_dmeventd +which mkfs.ext2 || skip -which mkfs.ext2 || exit 200 +aux prepare_vg 5 +aux prepare_dmeventd lvcreate -m 3 --ig -L 1 -n 4way $vg lvchange --monitor y $vg/4way -disable_dev $dev2 $dev4 +aux disable_dev "$dev2" "$dev4" mkfs.ext2 $DM_DEV_DIR/$vg/4way sleep 10 # FIXME: need a "poll" utility, akin to "check" -enable_dev $dev2 $dev4 +aux enable_dev "$dev2" "$dev4" check mirror $vg 4way check mirror_legs $vg 4way 2 + +vgremove -ff $vg diff --git a/test/t-lvconvert-repair-policy.sh b/test/shell/lvconvert-repair-policy.sh index 1f31215..e595d34 100644 --- a/test/t-lvconvert-repair-policy.sh +++ b/test/shell/lvconvert-repair-policy.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Copyright (C) 2008 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -9,19 +9,21 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test -prepare_vg 4 +aux prepare_vg 4 +aux lvmconf 'allocation/maximise_cling = 0' +aux lvmconf 'allocation/mirror_logs_require_separate_pvs = 1' # Clean-up and create a 2-way mirror, where the the # leg devices are always on $dev[12] and the log # is always on $dev3. ($dev4 behaves as a spare) cleanup() { vgreduce --removemissing $vg - for d in "$@"; do enable_dev $d; done - for d in "$@"; do vgextend $vg $d; done + for d in "$@"; do aux enable_dev "$d"; done + for d in "$@"; do vgextend $vg "$d"; done lvremove -ff $vg/mirror - lvcreate -m 1 --ig -l 2 -n mirror $vg $dev1 $dev2 $dev3:0 + lvcreate -m 1 --ig -l 2 -n mirror $vg "$dev1" "$dev2" "$dev3":0 } repair() { @@ -32,49 +34,58 @@ lvcreate -m 1 -L 1 -n mirror $vg lvchange -a n $vg/mirror # Fail a leg of a mirror. -aux disable_dev $dev1 +aux disable_dev "$dev1" lvchange --partial -a y $vg/mirror repair 'activation { mirror_image_fault_policy = "remove" }' check linear $vg mirror -aux cleanup $dev1 +cleanup "$dev1" + +# Fail a leg of a mirror. +# Expected result: Mirror (leg replaced, should retain log) +aux disable_dev "$dev1" +repair 'activation { mirror_image_fault_policy = "replace" mirror_log_fault_policy = "remove" }' +check mirror $vg mirror +check active $vg mirror_mlog +cleanup "$dev1" # Fail a leg of a mirror. # Expected result: Mirror (leg replaced) -aux disable_dev $dev1 +aux disable_dev "$dev1" repair 'activation { mirror_image_fault_policy = "replace" }' check mirror $vg mirror -lvs | grep mirror_mlog -aux cleanup $dev1 +check active $vg mirror_mlog +cleanup "$dev1" # Fail a leg of a mirror (use old name for policy specification) # Expected result: Mirror (leg replaced) -aux disable_dev $dev1 -repair 'activation { mirror_device_fault_policy = "replace" }' +aux disable_dev "$dev1" +repair 'activation { mirror_image_fault_policy = "replace" }' check mirror $vg mirror -lvs | grep mirror_mlog -aux cleanup $dev1 +check active $vg mirror_mlog +cleanup "$dev1" # Fail a leg of a mirror w/ no available spare -# Expected result: 2-way with corelog -aux disable_dev $dev2 $dev4 +# Expected result: linear +# (or 2-way with leg/log overlap if alloc anywhere) +aux disable_dev "$dev2" "$dev4" repair 'activation { mirror_image_fault_policy = "replace" }' check mirror $vg mirror -lvs | not grep mirror_mlog -aux cleanup $dev2 $dev4 +not check lv_exists $vg mirror_mlog +cleanup "$dev2" "$dev4" # Fail the log device of a mirror w/ no available spare # Expected result: mirror w/ corelog -aux disable_dev $dev3 $dev4 +aux disable_dev "$dev3" "$dev4" repair 'activation { mirror_image_fault_policy = "replace" }' $vg/mirror check mirror $vg mirror -lvs | not grep mirror_mlog -aux cleanup $dev3 $dev4 +not check lv_exists $vg mirror_mlog +cleanup "$dev3" "$dev4" # Fail the log device with a remove policy # Expected result: mirror w/ corelog lvchange -a y $vg/mirror -aux disable_dev $dev3 $dev4 +aux disable_dev "$dev3" "$dev4" repair 'activation { mirror_log_fault_policy = "remove" }' check mirror $vg mirror core -lvs | not grep mirror_mlog -cleanup $dev3 $dev4 +not check lv_exists $vg mirror_mlog +cleanup "$dev3" "$dev4" diff --git a/test/shell/lvconvert-repair-replace.sh b/test/shell/lvconvert-repair-replace.sh new file mode 100644 index 0000000..974628a --- /dev/null +++ b/test/shell/lvconvert-repair-replace.sh @@ -0,0 +1,92 @@ +#!/bin/sh +# Copyright (C) 2008 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +aux prepare_vg 6 +aux lvmconf 'allocation/maximise_cling = 0' +aux lvmconf 'allocation/mirror_logs_require_separate_pvs = 1' + +# 3-way, disk log +# multiple failures, full replace +lvcreate --mirrorlog disk -m 2 --ig -L 1 -n 3way $vg "$dev1" "$dev2" "$dev3" "$dev4":0-1 +aux disable_dev "$dev1" "$dev2" +echo y | lvconvert --repair $vg/3way 2>&1 | tee 3way.out +lvs -a -o +devices $vg | not grep unknown +not grep "WARNING: Failed" 3way.out +vgreduce --removemissing $vg +check mirror $vg 3way +aux enable_dev "$dev1" "$dev2" + +vgremove -ff $vg; vgcreate -c n $vg "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" "$dev6" + +# 2-way, mirrored log +# Double log failure, full replace +lvcreate --mirrorlog mirrored -m 1 --ig -L 1 -n 2way $vg \ + "$dev1" "$dev2" "$dev3":0 "$dev4":0 +aux disable_dev "$dev3" "$dev4" +echo y | lvconvert --repair $vg/2way 2>&1 | tee 2way.out +lvs -a -o +devices $vg | not grep unknown +not grep "WARNING: Failed" 2way.out +vgreduce --removemissing $vg +check mirror $vg 2way +aux enable_dev "$dev3" "$dev4" + +vgremove -ff $vg; vgcreate -c n $vg "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" "$dev6" + +# 3-way, mirrored log +# Single log failure, replace +lvcreate --mirrorlog mirrored -m 2 --ig -L 1 -n 3way $vg \ + "$dev1" "$dev2" "$dev3" "$dev4":0 "$dev5":0 +aux disable_dev "$dev4" +echo y | lvconvert --repair $vg/3way 2>&1 | tee 3way.out +lvs -a -o +devices $vg | not grep unknown +not grep "WARNING: Failed" 3way.out +vgreduce --removemissing $vg +check mirror $vg 3way +aux enable_dev "$dev4" + +vgremove -ff $vg; vgcreate -c n $vg "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" + +# 3-way, disk log +# multiple failures, partial replace +lvcreate --mirrorlog disk -m 2 --ig -L 1 -n 3way $vg "$dev1" "$dev2" "$dev3" "$dev4" +aux disable_dev "$dev1" "$dev2" +echo y | lvconvert --repair $vg/3way 2>&1 | tee 3way.out +grep "WARNING: Failed" 3way.out +lvs -a -o +devices $vg | not grep unknown +vgreduce --removemissing $vg +check mirror $vg 3way +aux enable_dev "$dev1" "$dev2" +lvchange -a n $vg/3way + +vgremove -ff $vg; vgcreate -c n $vg "$dev1" "$dev2" "$dev3" + +lvcreate --mirrorlog disk -m 1 --ig -L 1 -n 2way $vg "$dev1" "$dev2" "$dev3" +aux disable_dev "$dev1" +echo y | lvconvert --repair $vg/2way 2>&1 | tee 2way.out +grep "WARNING: Failed" 2way.out +lvs -a -o +devices $vg | not grep unknown +vgreduce --removemissing $vg +check mirror $vg 2way +aux enable_dev "$dev1" "$dev2" +lvchange -a n $vg/2way + +vgremove -ff $vg; vgcreate -c n $vg "$dev1" "$dev2" "$dev3" "$dev4" + +# Test repair of inactive mirror with log failure +# Replacement should fail, but covert should succeed (switch to corelog) +lvcreate -m 2 --ig -l 2 -n mirror2 $vg "$dev1" "$dev2" "$dev3" "$dev4":0 +vgchange -a n $vg +pvremove -ff -y "$dev4" +echo 'y' | lvconvert -y --repair $vg/mirror2 +check mirror $vg mirror2 +vgs $vg diff --git a/test/shell/lvconvert-repair-snapshot.sh b/test/shell/lvconvert-repair-snapshot.sh new file mode 100644 index 0000000..786b950 --- /dev/null +++ b/test/shell/lvconvert-repair-snapshot.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# Copyright (C) 2011 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +aux prepare_vg 5 +aux lvmconf 'allocation/maximise_cling = 0' +aux lvmconf 'allocation/mirror_logs_require_separate_pvs = 1' + +lvcreate -m 3 --ig -L 2M -n 4way $vg "$dev1" "$dev2" "$dev3" "$dev4" "$dev5":0 +lvcreate -s $vg/4way -L 2M -n snap + +aux disable_dev "$dev2" "$dev4" +echo n | lvconvert --repair $vg/4way 2>&1 | tee 4way.out +lvs -a -o +devices $vg | not grep unknown +vgreduce --removemissing $vg +aux enable_dev "$dev2" "$dev4" +lvs -a -o +devices $vg +check mirror $vg 4way "$dev5" diff --git a/test/shell/lvconvert-repair-transient-dmeventd.sh b/test/shell/lvconvert-repair-transient-dmeventd.sh new file mode 100644 index 0000000..ac687eb --- /dev/null +++ b/test/shell/lvconvert-repair-transient-dmeventd.sh @@ -0,0 +1,29 @@ +#!/bin/sh +# Copyright (C) 2011 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +aux prepare_vg 5 +aux prepare_dmeventd + +lvcreate -m 3 --ig -L 1 -n 4way $vg +lvchange --monitor y $vg/4way +aux disable_dev "$dev2" "$dev4" +mkfs.ext3 $DM_DEV_DIR/$vg/4way +aux enable_dev "$dev2" "$dev4" +sleep 3 +lvs -a -o +devices $vg | not grep unknown +check mirror $vg 4way +check mirror_legs $vg 4way 2 +lvs -a -o +devices $vg | not grep mimage_1 +lvs -a -o +devices $vg | not grep mimage_3 + +vgremove -f $vg diff --git a/test/t-lvconvert-repair-transient.sh b/test/shell/lvconvert-repair-transient.sh index b4e1a06..beacf89 100644 --- a/test/t-lvconvert-repair-transient.sh +++ b/test/shell/lvconvert-repair-transient.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Copyright (C) 2008 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -9,20 +9,20 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test -prepare_vg 5 - -exit 200 # this breaks upstream .33 and RHEL6 kernel :( - -# fail multiple devices +aux prepare_vg 5 lvcreate -m 3 --ig -L 1 -n 4way $vg -disable_dev $dev2 $dev4 -mkfs.ext3 $DM_DEV_DIR/$vg/4way -enable_dev $dev2 $dev4 +aux disable_dev "$dev2" "$dev4" +mkfs.ext3 $DM_DEV_DIR/$vg/4way & +sleep 1 +aux enable_dev "$dev2" "$dev4" echo n | lvconvert --repair $vg/4way 2>&1 | tee 4way.out lvs -a -o +devices | not grep unknown vgreduce --removemissing $vg check mirror $vg 4way lvchange -a n $vg/4way +wait + +vgremove -f $vg diff --git a/test/shell/lvconvert-repair.sh b/test/shell/lvconvert-repair.sh new file mode 100644 index 0000000..51bc9de --- /dev/null +++ b/test/shell/lvconvert-repair.sh @@ -0,0 +1,140 @@ +#!/bin/sh +# Copyright (C) 2008 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +recreate_vg_() +{ + vgremove -ff $vg + vgcreate -c n $vg $(cat DEVICES) +} + +aux lvmconf 'allocation/maximise_cling = 0' +aux lvmconf 'allocation/mirror_logs_require_separate_pvs = 1' + +# fail multiple devices + +# 4-way, disk log => 2-way, disk log +aux prepare_vg 8 +lvcreate -m 3 --ig -L 1 -n 4way $vg "$dev1" "$dev2" "$dev3" "$dev4" "$dev5":0 +aux disable_dev "$dev2" "$dev4" +echo n | lvconvert --repair $vg/4way 2>&1 | tee 4way.out +lvs -a -o +devices $vg | not grep unknown +vgreduce --removemissing $vg +aux enable_dev "$dev2" "$dev4" +check mirror $vg 4way "$dev5" + +# 3-way, disk log => linear +recreate_vg_ +lvcreate -m 2 --ig -L 1 -n 3way $vg +aux disable_dev "$dev1" "$dev2" +echo n | lvconvert --repair $vg/3way +check linear $vg 3way +lvs -a -o +devices $vg | not grep unknown +lvs -a -o +devices $vg | not grep mlog +dmsetup ls | grep $PREFIX | not grep mlog +vgreduce --removemissing $vg +aux enable_dev "$dev1" "$dev2" +check linear $vg 3way + +# fail just log and get it removed + +# 3-way, disk log => 3-way, core log +recreate_vg_ +lvcreate -m 2 --ig -L 1 -n 3way $vg "$dev1" "$dev2" "$dev3" "$dev4":0 +aux disable_dev "$dev4" +echo n | lvconvert --repair $vg/3way +check mirror $vg 3way core +lvs -a -o +devices $vg | not grep unknown +lvs -a -o +devices $vg | not grep mlog +dmsetup ls | grep $PREFIX | not grep mlog +vgreduce --removemissing $vg +aux enable_dev "$dev4" + +# 3-way, mirrored log => 3-way, core log +recreate_vg_ +lvcreate -m 2 --mirrorlog mirrored --ig -L 1 -n 3way $vg \ + "$dev1" "$dev2" "$dev3" "$dev4":0 "$dev5":0 +aux disable_dev "$dev4" "$dev5" +echo n | lvconvert --repair $vg/3way +check mirror $vg 3way core +lvs -a -o +devices $vg | not grep unknown +lvs -a -o +devices $vg | not grep mlog +dmsetup ls | grep $PREFIX | not grep mlog +vgreduce --removemissing $vg +aux enable_dev "$dev4" "$dev5" + +# 2-way, disk log => 2-way, core log +recreate_vg_ +lvcreate -m 1 --ig -L 1 -n 2way $vg "$dev1" "$dev2" "$dev3":0 +aux disable_dev "$dev3" +echo n | lvconvert --repair $vg/2way +check mirror $vg 2way core +lvs -a -o +devices $vg | not grep unknown +lvs -a -o +devices $vg | not grep mlog +vgreduce --removemissing $vg +aux enable_dev "$dev3" + +# fail single devices + +recreate_vg_ +vgreduce $vg "$dev4" + +lvcreate -m 1 --ig -L 1 -n mirror $vg +lvchange -a n $vg/mirror +vgextend $vg "$dev4" +aux disable_dev "$dev1" +lvchange --partial -a y $vg/mirror + +not vgreduce -v --removemissing $vg +lvconvert -y --repair $vg/mirror +vgreduce --removemissing $vg + +aux enable_dev "$dev1" +vgextend $vg "$dev1" +aux disable_dev "$dev2" +lvconvert -y --repair $vg/mirror +vgreduce --removemissing $vg + +aux enable_dev "$dev2" +vgextend $vg "$dev2" +aux disable_dev "$dev3" +lvconvert -y --repair $vg/mirror +vgreduce --removemissing $vg +aux enable_dev "$dev3" +vgextend $vg "$dev3" +lvremove -ff $vg + +if aux target_at_least dm-raid 1 1 0; then + # RAID5 single replace + lvcreate --type raid5 -i 2 -l 2 -n $lv1 $vg "$dev1" "$dev2" "$dev3" + aux wait_for_sync $vg $lv1 + aux disable_dev "$dev3" + lvconvert -y --repair $vg/$lv1 + vgreduce --removemissing $vg + aux enable_dev "$dev3" + vgextend $vg "$dev3" + lvremove -ff $vg + + # RAID6 double replace + lvcreate --type raid5 -i 3 -l 2 -n $lv1 $vg \ + "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" + aux wait_for_sync $vg $lv1 + aux disable_dev "$dev4" "$dev5" + lvconvert -y --repair $vg/$lv1 + vgreduce --removemissing $vg + aux enable_dev "$dev4" + aux enable_dev "$dev5" + vgextend $vg "$dev4" "$dev5" + lvremove -ff $vg +fi + +vgremove -ff $vg diff --git a/test/shell/lvconvert-thin.sh b/test/shell/lvconvert-thin.sh new file mode 100644 index 0000000..97ccc09 --- /dev/null +++ b/test/shell/lvconvert-thin.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +# Copyright (C) 2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +# +# Main +# +aux have_thin 1 0 0 || skip + +aux prepare_pvs 4 64 + +vgcreate $vg -s 64K $(cat DEVICES) + +# create mirrored LVs for data and metadata volumes +lvcreate -aey -l8 -m1 --mirrorlog core -n $lv1 $vg +lvcreate -aey -l4 -m1 --mirrorlog core -n $lv2 $vg + +lvconvert -c 64K --thinpool $vg/$lv1 --poolmetadata $vg/$lv2 + +lvcreate -V10M -T $vg/$lv1 --name $lv3 + +# check lvrename work properly +lvrename $vg/$lv1 $vg/pool +check lv_field $vg/pool name "pool" + +lvrename $vg/$lv3 $vg/$lv4 +check lv_field $vg/$lv4 name "$lv4" + +# not yet supported conversions +not lvconvert -m 1 $vg/pool +not lvconvert -m 1 $vg/$lv3 + +vgremove -ff $vg diff --git a/test/t-lvconvert-twostep.sh b/test/shell/lvconvert-twostep.sh index c499fdd..c45e7bc 100644 --- a/test/t-lvconvert-twostep.sh +++ b/test/shell/lvconvert-twostep.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Copyright (C) 2010 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -9,13 +9,18 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test aux prepare_vg 4 + lvcreate -m 1 --mirrorlog disk --ig -L 1 -n mirror $vg -not lvconvert -m 2 --mirrorlog core $vg/mirror $dev3 2>&1 | tee errs +not lvconvert -m 2 --mirrorlog core $vg/mirror "$dev3" 2>&1 | tee errs grep "two steps" errs -lvconvert -m 2 $vg/mirror $dev3 + +lvconvert -m 2 $vg/mirror "$dev3" lvconvert --mirrorlog core $vg/mirror -not lvconvert -m 1 --mirrorlog disk $vg/mirror $dev3 2>&1 | tee errs +not lvconvert -m 1 --mirrorlog disk $vg/mirror "$dev3" 2>&1 | tee errs +grep "two steps" errs + +not lvconvert -m 1 --mirrorlog mirrored $vg/mirror "$dev3" "$dev4" 2>&1 | tee errs grep "two steps" errs diff --git a/test/shell/lvcreate-large-raid.sh b/test/shell/lvcreate-large-raid.sh new file mode 100644 index 0000000..8768bb3 --- /dev/null +++ b/test/shell/lvcreate-large-raid.sh @@ -0,0 +1,71 @@ +#!/bin/sh +# Copyright (C) 2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# 'Exercise some lvcreate diagnostics' + +. lib/test + +aux target_at_least dm-raid 1 1 0 || skip + +aux prepare_vg 5 + +lvcreate -s -l 20%FREE -n $lv1 $vg --virtualsize 256T +lvcreate -s -l 20%FREE -n $lv2 $vg --virtualsize 256T +lvcreate -s -l 20%FREE -n $lv3 $vg --virtualsize 256T +lvcreate -s -l 20%FREE -n $lv4 $vg --virtualsize 256T +lvcreate -s -l 20%FREE -n $lv5 $vg --virtualsize 256T + +#FIXME this should be 1024T +#check lv_field $vg/$lv size "128.00m" + +aux lvmconf 'devices/filter = [ "a/dev\/mapper\/.*$/", "a/dev\/LVMTEST/", "r/.*/" ]' + +pvcreate $DM_DEV_DIR/$vg/$lv[12345] +vgcreate -c n $vg1 $DM_DEV_DIR/$vg/$lv[12345] + +# bz837927 START + +# +# Create large RAID LVs +# +# We need '--nosync' or our virtual devices won't work +lvcreate --type raid1 -m 1 -L 200T -n $lv1 $vg1 --nosync +check lv_field $vg1/$lv1 size "200.00t" +lvremove -ff $vg1 + +for segtype in raid4 raid5 raid6; do + lvcreate --type $segtype -i 3 -L 750T -n $lv1 $vg1 --nosync + check lv_field $vg1/$lv1 size "750.00t" + lvremove -ff $vg1 +done + +# +# Convert large linear to RAID1 (belong in different test script?) +# +lvcreate -L 200T -n $lv1 $vg1 +# Need to deactivate or the up-convert will start sync'ing +lvchange -an $vg1/$lv1 +lvconvert --type raid1 -m 1 $vg1/$lv1 +check lv_field $vg1/$lv1 size "200.00t" +lvremove -ff $vg1 + +# +# Extending large RAID LV (belong in different script?) +# +lvcreate --type raid1 -m 1 -L 200T -n $lv1 $vg1 --nosync +check lv_field $vg1/$lv1 size "200.00t" +lvextend -L +200T $vg1/$lv1 +check lv_field $vg1/$lv1 size "400.00t" +lvremove -ff $vg1 + +# bz837927 END + +lvremove -ff $vg diff --git a/test/shell/lvcreate-large-raid10.sh b/test/shell/lvcreate-large-raid10.sh new file mode 100644 index 0000000..c9d4a2a --- /dev/null +++ b/test/shell/lvcreate-large-raid10.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# Copyright (C) 2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# 'Exercise some lvcreate diagnostics' + +. lib/test + +aux target_at_least dm-raid 1 3 0 || skip + +aux prepare_vg 5 + +lvcreate -s -l 20%FREE -n $lv1 $vg --virtualsize 256T +lvcreate -s -l 20%FREE -n $lv2 $vg --virtualsize 256T +lvcreate -s -l 20%FREE -n $lv3 $vg --virtualsize 256T +lvcreate -s -l 20%FREE -n $lv4 $vg --virtualsize 256T +lvcreate -s -l 20%FREE -n $lv5 $vg --virtualsize 256T + +aux lvmconf 'devices/filter = [ "a/dev\/mapper\/.*$/", "a/dev\/LVMTEST/", "r/.*/" ]' + +pvcreate $DM_DEV_DIR/$vg/$lv[12345] +vgcreate -c n $vg1 $DM_DEV_DIR/$vg/$lv[12345] + +# +# Create large RAID LVs +# +# We need '--nosync' or our virtual devices won't work + +lvcreate --type raid10 -m 1 -i 2 -L 200T -n $lv1 $vg1 --nosync +check lv_field $vg1/$lv1 size "200.00t" +lvremove -ff $vg1 + +lvremove -ff $vg diff --git a/test/shell/lvcreate-large.sh b/test/shell/lvcreate-large.sh new file mode 100644 index 0000000..b61ccca --- /dev/null +++ b/test/shell/lvcreate-large.sh @@ -0,0 +1,40 @@ +#!/bin/sh +# Copyright (C) 2011 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# 'Exercise some lvcreate diagnostics' + +. lib/test + +aux prepare_vg 4 + +lvcreate -s -l 100%FREE -n $lv $vg --virtualsize 1024T + +#FIXME this should be 1024T +#check lv_field $vg/$lv size "128.00m" + +aux lvmconf 'devices/filter = [ "a/dev\/mapper\/.*$/", "a/dev\/LVMTEST/", "r/.*/" ]' + +pvcreate $DM_DEV_DIR/$vg/$lv +vgcreate -c n $vg1 $DM_DEV_DIR/$vg/$lv + +lvcreate -l 100%FREE -n $lv1 $vg1 +check lv_field $vg1/$lv1 size "1024.00t" +lvresize -f -l 72%VG $vg1/$lv1 +check lv_field $vg1/$lv1 size "737.28t" +lvremove -ff $vg1/$lv1 + +lvcreate -l 100%VG -n $lv1 $vg1 +check lv_field $vg1/$lv1 size "1024.00t" +lvresize -f -l 72%VG $vg1/$lv1 +check lv_field $vg1/$lv1 size "737.28t" +lvremove -ff $vg1/$lv1 + +lvremove -ff $vg/$lv diff --git a/test/t-lvcreate-mirror.sh b/test/shell/lvcreate-mirror.sh index ae3fceb..1f95387 100644 --- a/test/t-lvcreate-mirror.sh +++ b/test/shell/lvcreate-mirror.sh @@ -9,31 +9,33 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test aux prepare_vg 5 80 +aux lvmconf 'allocation/maximise_cling = 0' +aux lvmconf 'allocation/mirror_logs_require_separate_pvs = 1' # 2-way mirror with corelog, 2 PVs -lvcreate -l2 -m1 --mirrorlog core -n $lv1 $vg $dev1 $dev2 +lvcreate -l2 -m1 --mirrorlog core -n $lv1 $vg "$dev1" "$dev2" check mirror_images_redundant $vg $lv1 lvremove -ff $vg # 2-way mirror with disklog, 3 PVs -lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0-1 +lvcreate -l2 -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev3":0-1 check mirror_images_redundant $vg $lv1 -check mirror_log_on $vg $lv1 $dev3 +check mirror_log_on $vg $lv1 "$dev3" lvremove -ff $vg # 3-way mirror with disklog, 4 PVs -lvcreate -l2 -m2 --mirrorlog disk -n $lv1 $vg $dev1 $dev2 $dev4 $dev3:0-1 +lvcreate -l2 -m2 --mirrorlog disk -n $lv1 $vg "$dev1" "$dev2" "$dev4" "$dev3":0-1 check mirror_images_redundant $vg $lv1 -check mirror_log_on $vg $lv1 $dev3 +check mirror_log_on $vg $lv1 "$dev3" lvremove -ff $vg # lvcreate --nosync is in 100% sync after creation (bz429342) -lvcreate -l2 -m1 --nosync -n $lv1 $vg $dev1 $dev2 $dev3:0-1 2>out +lvcreate -l2 -m1 --nosync -n $lv1 $vg "$dev1" "$dev2" "$dev3":0-1 2>out grep "New mirror won't be synchronised." out lvs -o copy_percent --noheadings $vg/$lv1 | grep 100.00 lvremove -ff $vg # creating 2-way mirror with disklog from 2 PVs fails -not lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 +not lvcreate -l2 -m1 -n $lv1 $vg "$dev1" "$dev2" diff --git a/test/t-lvcreate-operation.sh b/test/shell/lvcreate-operation.sh index 8a31759..0ef3138 100644 --- a/test/t-lvcreate-operation.sh +++ b/test/shell/lvcreate-operation.sh @@ -11,32 +11,31 @@ # 'Exercise some lvcreate diagnostics' -. ./test-utils.sh +. lib/test cleanup_lvs() { lvremove -ff $vg - if dmsetup table|grep $vg; then - echo "ERROR: lvremove did leave some some mappings in DM behind!" - return 1 - fi + (dm_table | not grep $vg) || \ + die "ERROR: lvremove did leave some some mappings in DM behind!" } -prepare_pvs 2 -aux pvcreate --metadatacopies 0 $dev1 -aux vgcreate -c n $vg $devs +aux prepare_pvs 2 +aux pvcreate --metadatacopies 0 "$dev1" +aux vgcreate -c n $vg $(cat DEVICES) # --- # Create snapshots of LVs on --metadatacopies 0 PV (bz450651) -lvcreate -n$lv1 -l4 $vg $dev1 +lvcreate -n$lv1 -l4 $vg "$dev1" lvcreate -n$lv2 -l4 -s $vg/$lv1 +lvcreate -n$lv3 -l4 --permission r -s $vg/$lv1 cleanup_lvs # --- # Create mirror on two devices with mirrored log using --alloc anywhere -lvcreate -m 1 -l4 -n $lv1 --mirrorlog mirrored $vg --alloc anywhere $dev1 $dev2 +lvcreate -m 1 -l4 -n $lv1 --mirrorlog mirrored $vg --alloc anywhere "$dev1" "$dev2" cleanup_lvs # -- # Create mirror on one dev with mirrored log using --alloc anywhere, should fail -not lvcreate -m 1 -l4 -n $lv1 --mirrorlog mirrored $vg --alloc anywhere $dev1 +not lvcreate -m 1 -l4 -n $lv1 --mirrorlog mirrored $vg --alloc anywhere "$dev1" cleanup_lvs diff --git a/test/t-lvcreate-pvtags.sh b/test/shell/lvcreate-pvtags.sh index b9a4380..806fff1 100755..100644 --- a/test/t-lvcreate-pvtags.sh +++ b/test/shell/lvcreate-pvtags.sh @@ -1,3 +1,4 @@ +#!/bin/sh # Copyright (C) 2008 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -8,14 +9,17 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test aux prepare_pvs 3 +aux lvmconf 'allocation/maximise_cling = 0' +aux lvmconf 'allocation/mirror_logs_require_separate_pvs = 1' + # not required, just testing -aux pvcreate --metadatacopies 0 $dev1 +aux pvcreate --metadatacopies 0 "$dev1" -vgcreate -c n $vg $devs -pvchange --addtag fast $devs +vgcreate -c n $vg $(cat DEVICES) +pvchange --addtag fast $(cat DEVICES) # 3 stripes with 3 PVs (selected by tag, @fast) is fine lvcreate -l3 -i3 $vg @fast @@ -39,4 +43,6 @@ not lvcreate -l1 -m2 $vg @fast not lvcreate -l1 -m3 --corelog $vg @fast # lvcreate mirror with a single PV arg -not lvcreate -l1 -m1 --corelog $vg $dev1 +not lvcreate -l1 -m1 --corelog $vg "$dev1" + +vgremove -ff $vg diff --git a/test/shell/lvcreate-raid.sh b/test/shell/lvcreate-raid.sh new file mode 100644 index 0000000..05c7428 --- /dev/null +++ b/test/shell/lvcreate-raid.sh @@ -0,0 +1,49 @@ +#!/bin/sh +# Copyright (C) 2011-2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +######################################################## +# MAIN +######################################################## +aux target_at_least dm-raid 1 1 0 || skip + +aux prepare_pvs 6 20 # 6 devices for RAID10 (2-mirror,3-stripe) test +vgcreate -c n -s 512k $vg $(cat DEVICES) + +########################################### +# Create, wait for sync, remove tests +########################################### + +# Create RAID1 (implicit 2-way) +lvcreate --type raid1 -l 2 -n $lv1 $vg +aux wait_for_sync $vg $lv1 +lvremove -ff $vg + +# Create RAID1 (explicit 2-way) +lvcreate --type raid1 -m 1 -l 2 -n $lv1 $vg +aux wait_for_sync $vg $lv1 +lvremove -ff $vg + +# Create RAID1 (explicit 3-way) +lvcreate --type raid1 -m 2 -l 2 -n $lv1 $vg +aux wait_for_sync $vg $lv1 +lvremove -ff $vg + +# Create RAID 4/5/6 (explicit 3-stripe + parity devs) +for i in raid4 \ + raid5 raid5_ls raid5_la raid5_rs raid5_ra \ + raid6 raid6_zr raid6_nr raid6_nc; do + + lvcreate --type $i -l 3 -i 3 -n $lv1 $vg + aux wait_for_sync $vg $lv1 + lvremove -ff $vg +done diff --git a/test/shell/lvcreate-raid10.sh b/test/shell/lvcreate-raid10.sh new file mode 100644 index 0000000..63d086f --- /dev/null +++ b/test/shell/lvcreate-raid10.sh @@ -0,0 +1,42 @@ +#!/bin/sh +# Copyright (C) 2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +######################################################## +# MAIN +######################################################## +aux target_at_least dm-raid 1 3 0 || skip + +aux prepare_pvs 6 20 # 6 devices for RAID10 (2-mirror,3-stripe) test +vgcreate -c n -s 512k $vg $(cat DEVICES) + +# +# Create RAID10: +# + + +# Should not allow more than 2-way mirror +not lvcreate --type raid10 -m 2 -i 2 -l 2 -n $lv1 $vg + +# 2-way mirror, 2-stripes +lvcreate --type raid10 -m 1 -i 2 -l 2 -n $lv1 $vg +aux wait_for_sync $vg $lv1 +lvremove -ff $vg + +# 2-way mirror, 3-stripes +lvcreate --type raid10 -m 1 -i 3 -l 3 -n $lv1 $vg +aux wait_for_sync $vg $lv1 +lvremove -ff $vg + +# +# FIXME: Add tests that specify particular PVs to use for creation +# diff --git a/test/shell/lvcreate-repair.sh b/test/shell/lvcreate-repair.sh new file mode 100644 index 0000000..8971536 --- /dev/null +++ b/test/shell/lvcreate-repair.sh @@ -0,0 +1,99 @@ +#!/bin/sh +# Copyright (C) 2011-2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +aux prepare_vg 3 + +# fail multiple devices +for i in "$dev1" "$dev2" "$dev3" ; do + for j in "$dev2" "$dev3" ; do + if test "$i" = "$j" ; then continue ; fi + + vgremove -ff $vg + vgcreate $vg "$dev1" "$dev2" "$dev3" + # exit 1 + + lvcreate -l1 -n $lv1 $vg "$dev1" + + aux disable_dev "$i" "$j" + + vgreduce --removemissing --force $vg + + # check if reduced device was removed + test "$i" = "$dev1" && dm_table | not egrep "$vg-$lv1: *[^ ]+" + + lvcreate -l1 -n $lv2 $vg + + test "$i" != "$dev1" && check lv_exists $vg $lv1 + check lv_exists $vg $lv2 + + aux enable_dev "$i" "$j" + vgscan + + test "$i" != "$dev1" && check lv_exists $vg $lv1 + check lv_exists $vg $lv2 + done +done + +vgremove -ff $vg +vgcreate $vg "$dev1" "$dev2" "$dev3" + +# use tricky 'dd' +for i in "$dev1" "$dev2" "$dev3" ; do + for j in "$dev2" "$dev3" ; do + + if test "$i" = "$j" ; then continue ; fi + + dd if="$i" of=backup_i bs=256K count=1 + dd if="$j" of=backup_j bs=256K count=1 + + lvcreate -l1 -n $lv1 $vg "$dev1" + + dd if=backup_j of="$j" bs=256K count=1 + dd if=backup_i of="$i" bs=256K count=1 + + check lv_exists $vg $lv1 + # mda should be now consistent + lvremove -f $vg/$lv1 + done +done + + +# confuse lvm with active LV left behind +dd if="$dev1" of=backup_i bs=256K count=1 +dd if="$dev2" of=backup_j bs=256K count=1 + +lvcreate -l1 $vg "$dev1" + +dd if=backup_j of="$dev2" bs=256K count=1 +dd if=backup_i of="$dev1" bs=256K count=1 + +# CHECKME: following command writes here: +# vgreduce --removemissing --force $vg +# +# WARNING: Inconsistent metadata found for VG LVMTESTvg - updating to use version 2 +# Volume group "LVMTESTvg" is already consistent + +# dirty game +dd if=/dev/zero of="$dev3" bs=256K count=1 +aux notify_lvmetad "$dev3" # udev be watching you + +vgreduce --removemissing --force $vg + +# FIXME: here is LV1 left active - but metadata does not know about it +# and lvcreate does not check whether such device exists in the table +# so it ends with: +# +# device-mapper: create ioctl failed: Device or resource busy +# Failed to activate new LV. + +should lvcreate -l1 $vg "$dev1" diff --git a/test/t-lvcreate-small-snap.sh b/test/shell/lvcreate-small-snap.sh index 789c099..9b43868 100644 --- a/test/t-lvcreate-small-snap.sh +++ b/test/shell/lvcreate-small-snap.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Copyright (C) 2010 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -9,11 +9,11 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test aux prepare_pvs 3 -vgcreate -c n -s 1k $vg $devs +vgcreate -c n -s 1k $vg $(cat DEVICES) lvcreate -n one -l 10 $vg lvcreate -s -l 8 -n snapA $vg/one diff --git a/test/shell/lvcreate-striped-mirror.sh b/test/shell/lvcreate-striped-mirror.sh new file mode 100644 index 0000000..9a55a97 --- /dev/null +++ b/test/shell/lvcreate-striped-mirror.sh @@ -0,0 +1,65 @@ +#!/bin/sh +# Copyright (C) 2010 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test +aux prepare_vg 9 + +lvcreate -i2 -l2 -m1 --mirrorlog core -n $lv1 $vg 2>&1 | tee log +not grep "Rounding" log +check mirror_images_redundant $vg $lv1 +lvremove -ff $vg + +lvcreate -i2 -l4 -m1 --mirrorlog core -n $lv1 $vg 2>&1 | tee log +not grep "Rounding" log +check mirror_images_redundant $vg $lv1 +lvremove -ff $vg + +lvcreate -i3 -l3 -m1 --mirrorlog core -n $lv1 $vg 2>&1 | tee log +not grep "Rounding" log +check mirror_images_redundant $vg $lv1 +lvremove -ff $vg + +lvcreate -i4 -l4 -m1 --mirrorlog core -n $lv1 $vg 2>&1 | tee log +not grep "Rounding" log +check mirror_images_redundant $vg $lv1 +lvremove -ff $vg + + +lvcreate -i2 -l2 -m2 --mirrorlog core -n $lv1 $vg 2>&1 | tee log +not grep "Rounding" log +check mirror_images_redundant $vg $lv1 +lvremove -ff $vg + +lvcreate -i3 -l3 -m2 --mirrorlog core -n $lv1 $vg 2>&1 | tee log +not grep "Rounding" log +check mirror_images_redundant $vg $lv1 +lvremove -ff $vg + +lvcreate -i2 -l2 -m3 --mirrorlog core -n $lv1 $vg 2>&1 | tee log +not grep "Rounding" log +check mirror_images_redundant $vg $lv1 +lvremove -ff $vg + +lvcreate -i3 -l2 -m2 --mirrorlog core -n $lv1 $vg 2>&1 | tee log +grep "Rounding size (2 extents) up to .* (3 extents)" log +lvremove -ff $vg + +lvcreate -i3 -l4 -m2 --mirrorlog core -n $lv1 $vg 2>&1 | tee log +grep "Rounding size (4 extents) up to .* (6 extents)" log +lvremove -ff $vg + +lvcreate -i3 -l4 -m1 --mirrorlog core -n $lv1 $vg 2>&1 | tee log +grep "Rounding size (4 extents) up to .* (6 extents)" log +lvremove -ff $vg + +lvcreate -i4 -l4 -m1 --mirrorlog core -n $lv1 $vg 2>&1 | tee log +not grep "Rounding" log +lvremove -ff $vg diff --git a/test/shell/lvcreate-thin-power2.sh b/test/shell/lvcreate-thin-power2.sh new file mode 100644 index 0000000..882b05c --- /dev/null +++ b/test/shell/lvcreate-thin-power2.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# Copyright (C) 2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# test support for non-power-of-2 thin chunk size +# + +. lib/test + +# +# Main +# +aux have_thin 1 4 0 || skip + +aux prepare_pvs 2 64 + +vgcreate $vg -s 64K $(cat DEVICES) + +# create non-power-of-2 pool +lvcreate -l100 -c 192 -T $vg/pool + +check lv_field $vg/pool discards "ignore" + +# check we cannot change discards settings +not lvchange --discard passdown $vg/pool +not lvchange --discard nopassdown $vg/pool + +# must be multiple of 64KB +not lvcreate -l100 -c 168 -T $vg/pool1 + +vgremove -ff $vg diff --git a/test/shell/lvcreate-thin-snap.sh b/test/shell/lvcreate-thin-snap.sh new file mode 100644 index 0000000..23f91f9 --- /dev/null +++ b/test/shell/lvcreate-thin-snap.sh @@ -0,0 +1,57 @@ +#!/bin/sh + +# Copyright (C) 2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +check_lv_field_modules_() +{ + mod=$1 + shift + + for d in $*; do + check lv_field $vg/$d modules $mod + done +} + + +# +# Main +# +aux have_thin 1 0 0 || skip + +aux prepare_pvs 2 64 + +vgcreate $vg -s 64K $(cat DEVICES) + +lvcreate -L10M -V10M -T $vg/pool --name $lv1 +mkfs.ext4 $DM_DEV_DIR/$vg/$lv1 +# create thin snapshot of thin LV +lvcreate -s $vg/$lv1 +# check snapshot filesystem was properly frozen before snapping +fsck -p $DM_DEV_DIR/$vg/lvol0 +lvcreate -s $vg/$lv1 --name $lv2 +lvcreate -s $vg/$lv1 --name $vg/$lv3 +lvcreate --type snapshot $vg/$lv1 +lvcreate --type snapshot $vg/$lv1 --name $lv4 +lvcreate --type snapshot $vg/$lv1 --name $vg/$lv5 + +# create old-style snapshot +lvcreate -s -L10M --name oldsnap1 $vg/$lv2 +lvcreate -s -L10M --name oldsnap2 $vg/$lv2 + +# thin snap of snap of snap... +lvcreate -s --name sn1 $vg/$lv2 +lvcreate -s --name sn2 $vg/sn1 +lvcreate -s --name sn3 $vg/sn2 +lvcreate -s --name sn4 $vg/sn3 + +vgremove -ff $vg diff --git a/test/shell/lvcreate-thin.sh b/test/shell/lvcreate-thin.sh new file mode 100644 index 0000000..e651a81 --- /dev/null +++ b/test/shell/lvcreate-thin.sh @@ -0,0 +1,211 @@ +#!/bin/sh + +# Copyright (C) 2011-2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# test currently needs to drop +# 'return NULL' in _lv_create_an_lv after log_error("Can't create %s without using " + +. lib/test + +check_lv_field_modules_() +{ + mod=$1 + shift + + for d in $*; do + check lv_field $vg/$d modules $mod + done +} + + +# +# Main +# +aux have_thin 1 0 0 || skip + +aux prepare_pvs 2 64 + +vgcreate $vg -s 64K $(cat DEVICES) + +# Create named pool only +lvcreate -l1 -T $vg/pool1 +lvcreate -l1 -T --thinpool $vg/pool2 +lvcreate -l1 -T --thinpool pool3 $vg +lvcreate -l1 --type thin $vg/pool4 +lvcreate -l1 --type thin --thinpool $vg/pool5 +lvcreate -l1 --type thin --thinpool pool6 $vg +lvcreate -l1 --type thin-pool $vg/pool7 +lvcreate -l1 --type thin-pool --thinpool $vg/pool8 +lvcreate -l1 --type thin-pool --thinpool pool9 $vg + +lvremove -ff $vg/pool1 $vg/pool2 $vg/pool3 $vg/pool4 $vg/pool5 $vg/pool6 $vg/pool7 $vg/pool8 $vg/pool9 +check vg_field $vg lv_count 0 + + +# Create default pool name +lvcreate -l1 -T $vg +lvcreate -l1 --type thin $vg +lvcreate -l1 --type thin-pool $vg + +lvremove -ff $vg/lvol0 $vg/lvol1 $vg/lvol2 +check vg_field $vg lv_count 0 + + +# Create default pool and default thin LV +lvcreate -l1 -V2G -T $vg +lvcreate -l1 -V2G --type thin $vg + +lvremove -ff $vg + + +# Create named pool and default thin LV +lvcreate -L4M -V2G -T $vg/pool1 +lvcreate -L4M -V2G -T --thinpool $vg/pool2 +lvcreate -L4M -V2G -T --thinpool pool3 $vg +lvcreate -L4M -V2G --type thin $vg/pool4 +lvcreate -L4M -V2G --type thin --thinpool $vg/pool5 +lvcreate -L4M -V2G --type thin --thinpool pool6 $vg + +check lv_exists $vg lvol0 lvol1 lvol2 lvol3 lvol4 lvol5 +lvremove -ff $vg + + +# Create named pool and named thin LV +lvcreate -L4M -V2G -T $vg/pool1 --name lv1 +lvcreate -L4M -V2G -T $vg/pool2 --name $vg/lv2 +lvcreate -L4M -V2G -T --thinpool $vg/pool3 --name lv3 +lvcreate -L4M -V2G -T --thinpool $vg/pool4 --name $vg/lv4 +lvcreate -L4M -V2G -T --thinpool pool5 --name lv5 $vg +lvcreate -L4M -V2G -T --thinpool pool6 --name $vg/lv6 $vg + +check lv_exists $vg lv1 lv2 lv3 lv4 lv5 lv6 +lvremove -ff $vg + + +lvcreate -L4M -V2G --type thin $vg/pool1 --name lv1 +lvcreate -L4M -V2G --type thin $vg/pool2 --name $vg/lv2 +lvcreate -L4M -V2G --type thin --thinpool $vg/pool3 --name lv3 +lvcreate -L4M -V2G --type thin --thinpool $vg/pool4 --name $vg/lv4 +lvcreate -L4M -V2G --type thin --thinpool pool5 --name lv5 $vg +lvcreate -L4M -V2G --type thin --thinpool pool6 --name $vg/lv6 $vg + +check lv_exists $vg lv1 lv2 lv3 lv4 lv5 lv6 +lvremove -ff $vg + + +# Create default thin LV in existing pool +lvcreate -L4M -T $vg/pool +lvcreate -V2G -T $vg/pool +lvcreate -V2G -T --thinpool $vg/pool +lvcreate -V2G -T --thinpool pool $vg +lvcreate -V2G --type thin $vg/pool +lvcreate -V2G --type thin --thinpool $vg/pool +lvcreate -V2G --type thin --thinpool pool $vg + +check lv_exists $vg lvol0 lvol1 lvol2 lvol3 lvol4 lvol5 + + +# Create named thin LV in existing pool +lvcreate -V2G -T $vg/pool --name lv1 +lvcreate -V2G -T $vg/pool --name $vg/lv2 +lvcreate -V2G -T --thinpool $vg/pool --name lv3 +lvcreate -V2G -T --thinpool $vg/pool --name $vg/lv4 +lvcreate -V2G -T --thinpool pool --name lv5 $vg +lvcreate -V2G -T --thinpool pool --name $vg/lv6 $vg +lvcreate -V2G --type thin $vg/pool --name lv7 +lvcreate -V2G --type thin $vg/pool --name $vg/lv8 +lvcreate -V2G --type thin --thinpool $vg/pool --name lv9 +lvcreate -V2G --type thin --thinpool $vg/pool --name $vg/lv10 +lvcreate -V2G --type thin --thinpool pool --name lv11 $vg +lvcreate -V2G --type thin --thinpool pool --name $vg/lv12 $vg + +check lv_exists $vg lv1 lv2 lv3 lv4 lv5 lv6 lv7 lv8 lv9 lv10 lv11 lv12 +check vg_field $vg lv_count 19 + +lvremove -ff $vg +check vg_field $vg lv_count 0 + +# Create thin snapshot of thinLV +lvcreate -L10M -V10M -T $vg/pool --name lv1 +mkfs.ext4 $DM_DEV_DIR/$vg/lv1 +lvcreate -s $vg/lv1 +fsck -p $DM_DEV_DIR/$vg/lvol0 +lvcreate -s $vg/lv1 --name lv2 +lvcreate -s $vg/lv1 --name $vg/lv3 +lvcreate --type snapshot $vg/lv1 +lvcreate --type snapshot $vg/lv1 --name lv4 +lvcreate --type snapshot $vg/lv1 --name $vg/lv5 + +check_lv_field_modules_ thin-pool lv1 lvol0 lv2 lv3 lvol1 lv4 lv5 +check vg_field $vg lv_count 8 +lvremove -ff $vg + + +# Normal Snapshots of thinLV +lvcreate -L4M -V2G -T $vg/pool --name lv1 +lvcreate -s $vg/lv1 -l1 +lvcreate -s $vg/lv1 -l1 --name lv2 +lvcreate -s $vg/lv1 -l1 --name $vg/lv3 +lvcreate -s lv1 -L4M --name $vg/lv4 + +check_lv_field_modules_ snapshot lvol0 lv2 lv3 lv4 +check vg_field $vg lv_count 6 + +lvremove -ff $vg +check vg_field $vg lv_count 0 + +lvdisplay $vg + +# Fail cases +# Too small pool size (1 extent 64KB) for given chunk size +not lvcreate --chunksize 256 -l1 -T $vg/pool1 +# Too small chunk size (min is 64KB - 128 sectors) +not lvcreate --chunksize 32 -l1 -T $vg/pool1 +# Too large chunk size (max is 1GB) +not lvcreate -L4M --chunksize 2G -T $vg/pool1 + +lvcreate -L4M -V2G --name lv1 -T $vg/pool1 +# Origin name is not accepted +not lvcreate -s $vg/lv1 -L4M -V2G --name $vg/lv4 + +# Check we cannot create mirror and thin or thinpool together +not lvcreate -T mirpool -L4M --alloc anywhere -m1 $vg +not lvcreate --thinpool mirpool -L4M --alloc anywhere -m1 $vg + +vgremove -ff $vg + +# Test --poolmetadatasize range +# allocating large devices for testing +aux teardown_devs +aux prepare_pvs 10 16500 +vgcreate $vg -s 64K $(cat DEVICES) + +lvcreate -L4M --chunksize 128 --poolmetadatasize 0 -T $vg/pool1 2>out +grep "WARNING: Minimum" out +# FIXME: metadata allocation fails, if PV doesn't have at least 16GB +# i.e. pool metadata device cannot be multisegment +lvcreate -L4M --chunksize 64k --poolmetadatasize 17G -T $vg/pool2 2>out +grep "WARNING: Maximum" out +check lv_field $vg/pool1_tmeta size "2.00m" +check lv_field $vg/pool2_tmeta size "16.00g" +lvremove -ff $vg + +# Test automatic calculation of pool metadata size +lvcreate -L160G -T $vg/pool +check lv_field $vg/pool lv_metadata_size "80.00m" +check lv_field $vg/pool chunksize "128.00k" +lvremove -ff $vg/pool + +lvcreate -L10G --chunksize 256 -T $vg/pool1 +lvcreate -L60G --chunksize 1024 -T $vg/pool2 +check lv_field $vg/pool1_tmeta size "2.50m" +check lv_field $vg/pool2_tmeta size "3.75m" +vgremove -ff $vg diff --git a/test/t-lvcreate-usage.sh b/test/shell/lvcreate-usage.sh index 0bb06ab..ddde401 100755..100644 --- a/test/t-lvcreate-usage.sh +++ b/test/shell/lvcreate-usage.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2008 Red Hat, Inc. All rights reserved. +# Copyright (C) 2008-2011 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions @@ -11,11 +11,11 @@ # 'Exercise some lvcreate diagnostics' -. ./test-utils.sh +. lib/test aux prepare_pvs 4 -aux pvcreate --metadatacopies 0 $dev1 -vgcreate -cn $vg $devs +aux pvcreate --metadatacopies 0 "$dev1" +vgcreate -cn $vg $(cat DEVICES) # "lvcreate rejects repeated invocation (run 2 times) (bz178216)" lvcreate -n $lv -l 4 $vg @@ -26,34 +26,34 @@ not lvremove -ff $vg/$lv # "lvcreate rejects a negative stripe_size" not lvcreate -L 64m -n $lv -i2 --stripesize -4 $vg 2>err; -grep "^ Negative stripesize is invalid\$" err +grep "Negative stripesize is invalid" err # 'lvcreate rejects a too-large stripesize' not lvcreate -L 64m -n $lv -i2 --stripesize 4294967291 $vg 2>err -grep "^ Stripe size cannot be larger than" err +grep "Stripe size cannot be larger than" err # 'lvcreate w/single stripe succeeds with diagnostics to stdout' lvcreate -L 64m -n $lv -i1 --stripesize 4 $vg 2> err | tee out -grep "^ Ignoring stripesize argument with single stripe\$" out +grep "Ignoring stripesize argument with single stripe" out lvdisplay $vg lvremove -ff $vg # 'lvcreate w/default (64KB) stripe size succeeds with diagnostics to stdout' lvcreate -L 64m -n $lv -i2 $vg > out -grep "^ Using default stripesize" out +grep "Using default stripesize" out lvdisplay $vg -check_lv_field_ $vg/$lv stripesize "64.00k" +check lv_field $vg/$lv stripesize "64.00k" lvremove -ff $vg # 'lvcreate rejects an invalid number of stripes' not lvcreate -L 64m -n $lv -i129 $vg 2>err -grep "^ Number of stripes (129) must be between 1 and 128\$" err +grep "Number of stripes (129) must be between 1 and 128" err # The case on lvdisplay output is to verify that the LV was not created. # 'lvcreate rejects an invalid stripe size' not lvcreate -L 64m -n $lv -i2 --stripesize 3 $vg 2>err -grep "^ Invalid stripe size" err -case $(lvdisplay $vg) in "") true ;; *) false ;; esac +grep "Invalid stripe size" err +test -z "$(lvdisplay $vg)" # Setting max_lv works. (bz490298) lvremove -ff $vg @@ -70,8 +70,7 @@ not lvcreate -l1 -m1 -n $lv4 $vg lvremove -ff $vg/$lv3 lvcreate -l1 -m1 -n $lv3 $vg -lvs -vgs -o +max_lv +vgs -o +max_lv $vg not lvcreate -l1 -n $lv4 $vg not lvcreate -l1 -m1 -n $lv4 $vg @@ -89,16 +88,16 @@ vgchange -l 0 $vg # lvcreate rejects invalid chunksize, accepts between 4K and 512K # validate origin_size vgremove -ff $vg -vgcreate -cn $vg $devs +vgcreate -cn $vg $(cat DEVICES) lvcreate -L 32m -n $lv1 $vg not lvcreate -L 8m -n $lv2 -s --chunksize 3k $vg/$lv1 not lvcreate -L 8m -n $lv2 -s --chunksize 1024k $vg/$lv1 lvcreate -L 8m -n $lv2 -s --chunksize 4k $vg/$lv1 -check_lv_field_ $vg/$lv2 chunk_size 4.00k -check_lv_field_ $vg/$lv2 origin_size 32.00m +check lv_field $vg/$lv2 chunk_size "4.00k" +check lv_field $vg/$lv2 origin_size "32.00m" lvcreate -L 8m -n $lv3 -s --chunksize 512k $vg/$lv1 -check_lv_field_ $vg/$lv3 chunk_size 512.00k -check_lv_field_ $vg/$lv3 origin_size 32.00m +check lv_field $vg/$lv3 chunk_size "512.00k" +check lv_field $vg/$lv3 origin_size "32.00m" lvremove -ff $vg vgchange -l 0 $vg @@ -111,10 +110,10 @@ grep "Non-zero region size must be supplied." err not lvcreate -L 32m -n $lv -R 11k $vg not lvcreate -L 32m -n $lv -R 1k $vg lvcreate -L 32m -n $lv --regionsize 128m -m 1 $vg -check_lv_field_ $vg/$lv regionsize "32.00m" +check lv_field $vg/$lv regionsize "32.00m" lvremove -ff $vg lvcreate -L 32m -n $lv --regionsize 4m -m 1 $vg -check_lv_field_ $vg/$lv regionsize "4.00m" +check lv_field $vg/$lv regionsize "4.00m" lvremove -ff $vg # snapshot with virtual origin works @@ -122,20 +121,30 @@ lvcreate -s --virtualoriginsize 64m -L 32m -n $lv1 $vg lvrename $vg/$lv1 $vg/$lv2 lvcreate -s --virtualoriginsize 64m -L 32m -n $lv1 $vg lvchange -a n $vg/$lv1 -lvremove $vg/$lv1 +lvremove -ff $vg/$lv1 lvremove -ff $vg # readahead default (auto), none, #, auto lvcreate -L 32m -n $lv $vg -check_lv_field_ $vg/$lv lv_read_ahead "auto" +check lv_field $vg/$lv lv_read_ahead "auto" lvremove -ff $vg lvcreate -L 32m -n $lv --readahead none $vg -check_lv_field_ $vg/$lv lv_read_ahead "0" +check lv_field $vg/$lv lv_read_ahead "0" +check lv_field $vg/$lv lv_kernel_read_ahead "0" lvremove -ff $vg lvcreate -L 32m -n $lv --readahead 8k $vg -check_lv_field_ $vg/$lv lv_read_ahead "8.00k" +check lv_field $vg/$lv lv_read_ahead "8.00k" +check lv_field $vg/$lv lv_kernel_read_ahead "8.00k" lvremove -ff $vg lvcreate -L 32m -n $lv --readahead auto $vg -check_lv_field_ $vg/$lv lv_read_ahead "auto" +check lv_field $vg/$lv lv_read_ahead "auto" +check lv_field $vg/$lv lv_kernel_read_ahead "128.00k" +lvremove -ff $vg +lvcreate -L 32m -n $lv -i2 --stripesize 16k --readahead auto $vg +check lv_field $vg/$lv lv_read_ahead "auto" +check lv_field $vg/$lv lv_kernel_read_ahead "128.00k" +lvremove -ff $vg +lvcreate -L 32m -n $lv -i2 --stripesize 128k --readahead auto $vg +check lv_field $vg/$lv lv_read_ahead "auto" +check lv_field $vg/$lv lv_kernel_read_ahead "512.00k" lvremove -ff $vg - diff --git a/test/t-lvextend-percent-extents.sh b/test/shell/lvextend-percent-extents.sh index d020dec..1d59082 100755..100644 --- a/test/t-lvextend-percent-extents.sh +++ b/test/shell/lvextend-percent-extents.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2008 Red Hat, Inc. All rights reserved. +# Copyright (C) 2008-2011 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions @@ -11,7 +11,7 @@ # 'Check extents percentage arguments' -. ./test-utils.sh +. lib/test aux prepare_vg 2 128 @@ -19,34 +19,34 @@ lvcreate -L 64m -n $lv $vg # 'lvextend rejects both size and extents without PVs' not lvextend -l 10 -L 64m $vg/$lv 2>err -grep "^ Please specify either size or extents but not both.\$" err +grep "Please specify either size or extents but not both." err # 'lvextend rejects both size and extents with PVs' -not lvextend -l 10 -L 64m $vg/$lv $dev1 2>err -grep "^ Please specify either size or extents but not both.\$" err +not lvextend -l 10 -L 64m $vg/$lv "$dev1" 2>err +grep "Please specify either size or extents but not both." err # 'lvextend accepts no size or extents but one PV - bz154691' -lvextend $vg/$lv $dev1 >out -grep "^ Logical volume $lv successfully resized\$" out -check_pv_field_ $dev1 pv_free "0" +lvextend $vg/$lv "$dev1" >out +grep "Logical volume $lv successfully resized" out +check pv_field "$dev1" pv_free "0" -lvremove -f $vg/$lv +lvremove -f $vg/$lv # 'lvextend computes necessary free space correctly - bz213552' -vgsize=$(vgs -o vg_extent_count --noheadings) +vgsize=$(get vg_field $vg vg_extent_count) lvcreate -l $vgsize -n $lv $vg lvreduce -f -l $(( $vgsize / 2 )) $vg/$lv lvextend -l $vgsize $vg/$lv -# 'Reset LV to original size' -lvremove -f $vg/$lv +# 'Reset LV to original size' +lvremove -f $vg/$lv lvcreate -L 64m -n $lv $vg # 'lvextend accepts no size but extents 100%PVS and two PVs - bz154691' -lvextend -l +100%PVS $vg/$lv $dev1 $dev2 >out -grep "^ Logical volume $lv successfully resized\$" out -check_pv_field_ $dev1 pv_free "0" -check_pv_field_ $dev2 pv_free "0" +lvextend -l +100%PVS $vg/$lv "$dev1" "$dev2" >out +grep "Logical volume $lv successfully resized" out +check pv_field "$dev1" pv_free "0" +check pv_field "$dev2" pv_free "0" # Exercise the range overlap code. Allocate every 2 extents. # @@ -68,34 +68,39 @@ check_pv_field_ $dev2 pv_free "0" # Total number of extents should be 12 + overlap = 12 + 6 = 18. # Thus, total size for the LV should be 18 * 4M = 72M # -# 'Reset LV to 12 extents, allocate every other 2 extents' -create_pvs=`for i in $(seq 0 4 20); do echo -n "\$dev1:$i-$(($i + 1)) "; done` +# 'Reset LV to 12 extents, allocate every other 2 extents' +create_pvs=$(for i in $(seq 0 4 20); do echo -n "$dev1:$i-$(($i + 1)) "; done) lvremove -f $vg/$lv lvcreate -l 12 -n $lv $vg $create_pvs -check_lv_field_ $vg/$lv lv_size "48.00m" +check lv_field $vg/$lv lv_size "48.00m" -# 'lvextend with partially allocated PVs and extents 100%PVS with PE ranges' -extend_pvs=`for i in $(seq 0 6 18); do echo -n "\$dev1:$i-$(($i + 2)) "; done` +# 'lvextend with partially allocated PVs and extents 100%PVS with PE ranges' +extend_pvs=$(for i in $(seq 0 6 18); do echo -n "$dev1:$i-$(($i + 2)) "; done) lvextend -l +100%PVS $vg/$lv $extend_pvs >out -grep "^ Logical volume $lv successfully resized\$" out -check_lv_field_ $vg/$lv lv_size "72.00m" +grep "Logical volume $lv successfully resized" out +check lv_field $vg/$lv lv_size "72.00m" # Simple seg_count validation; initially create the LV with half the # of # extents (should be 1 lv segment), extend it (should go to 2 segments), # then reduce (should be back to 1) # FIXME: test other segment fields such as seg_size, pvseg_start, pvseg_size lvremove -f $vg/$lv -pe_count=$(pvs -o pv_pe_count --noheadings $dev1) +pe_count=$(get pv_field "$dev1" pv_pe_count) pe1=$(( $pe_count / 2 )) lvcreate -l $pe1 -n $lv $vg -pesize=$(lvs -ovg_extent_size --units b --nosuffix --noheadings $vg/$lv) +pesize=$(get lv_field $vg/$lv vg_extent_size --units b --nosuffix) segsize=$(( $pe1 * $pesize / 1024 / 1024 ))m -check_lv_field_ $vg/$lv seg_count 1 -check_lv_field_ $vg/$lv seg_start 0 -check_lv_field_ $vg/$lv seg_start_pe 0 -#check_lv_field_ $vg/$lv seg_size $segsize +check lv_field $vg/$lv seg_count "1" +check lv_field $vg/$lv seg_start "0" +check lv_field $vg/$lv seg_start_pe "0" +#check lv_field $vg/$lv seg_size $segsize lvextend -l +$(( $pe_count * 1 )) $vg/$lv -check_lv_field_ $vg/$lv seg_count 2 +check lv_field $vg/$lv seg_count "2" lvreduce -f -l -$(( $pe_count * 1 )) $vg/$lv -check_lv_field_ $vg/$lv seg_count 1 +check lv_field $vg/$lv seg_count "1" +# do not reduce to 0 extents +lvremove -f $vg/$lv +lvcreate -i2 -I 64k -l10 -n $lv $vg +lvreduce -f -l1 $vg/$lv +check lv_field $vg/$lv lv_size "8.00m" diff --git a/test/shell/lvextend-snapshot-dmeventd.sh b/test/shell/lvextend-snapshot-dmeventd.sh new file mode 100644 index 0000000..98bec19 --- /dev/null +++ b/test/shell/lvextend-snapshot-dmeventd.sh @@ -0,0 +1,61 @@ +#!/bin/sh +# Copyright (C) 2010-2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +extend() { + lvextend --use-policies --config "activation { snapshot_autoextend_threshold = $1 }" $vg/snap +} + +write_() { + dd if=/dev/zero of="$DM_DEV_DIR/$vg/snap" bs=1k count=$2 seek=$1 +} + +percent_() { + get lv_field $vg/snap snap_percent | cut -d. -f1 +} + +wait_for_change_() { + # dmeventd only checks every 10 seconds :( + for i in $(seq 1 15) ; do + test "$(percent_)" != "$1" && return + sleep 1 + done + + return 1 # timeout +} + +aux prepare_dmeventd +aux prepare_vg 2 + +lvcreate -L16M -n base $vg +lvcreate -s -L4M -n snap $vg/base + +write_ 0 1000 +test 24 -eq $(percent_) + +lvchange --monitor y $vg/snap + +write_ 1000 1700 +pre=$(percent_) +wait_for_change_ $pre +test $pre -gt $(percent_) + +# check that a second extension happens; we used to fail to extend when the +# utilisation ended up between THRESH and (THRESH + 10)... see RHBZ 754198 +# (the utilisation after the write should be 57 %) + +write_ 2700 2000 +pre=$(percent_) +wait_for_change_ $pre +test $pre -gt $(percent_) + +vgremove -f $vg diff --git a/test/t-lvextend-snapshot-policy.sh b/test/shell/lvextend-snapshot-policy.sh index 76ea980..2f5d84b 100644 --- a/test/t-lvextend-snapshot-policy.sh +++ b/test/shell/lvextend-snapshot-policy.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Copyright (C) 2010 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -9,39 +9,41 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test + +which mkfs.ext2 || skip extend() { - lvextend --use-policies --config "activation { snapshot_extend_threshold = $1 }" $vg/snap + lvextend --use-policies --config "activation { snapshot_autoextend_threshold = $1 }" $vg/snap } write() { - mount $DM_DEV_DIR/$vg/snap mnt - dd if=/dev/zero of=mnt/file$1 bs=1k count=$2 + mount "$DM_DEV_DIR/$vg/snap" mnt + dd if=/dev/zero of="mnt/file$1" bs=1k count=$2 umount mnt } percent() { - lvs $vg/snap -o snap_percent --noheadings | cut -c4- | cut -d. -f1 + get lv_field $vg/snap snap_percent | cut -d. -f1 } -which mkfs.ext2 || exit 200 - +aux prepare_dmeventd aux prepare_vg 2 + lvcreate -l 8 -n base $vg -mkfs.ext2 $DM_DEV_DIR/$vg/base +mkfs.ext2 "$DM_DEV_DIR/$vg/base" lvcreate -s -l 4 -n snap $vg/base mkdir mnt write 1 4096 -pre=`percent` +pre=$(percent) extend 50 -post=`percent` +test $pre -eq $(percent) -test $pre = $post write 2 4096 -pre=`percent` +pre=$(percent) extend 50 -post=`percent` -test $pre -gt $post +test $pre -gt $(percent) + +vgremove -f $vg diff --git a/test/t-lvm-init.sh b/test/shell/lvm-init.sh index cf324e4..8eb7814 100644 --- a/test/t-lvm-init.sh +++ b/test/shell/lvm-init.sh @@ -1,3 +1,4 @@ +#!/bin/sh # Copyright (C) 2008 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -12,10 +13,9 @@ # tests lvm initialization, and especially negative tests of error paths # -. ./test-utils.sh +. lib/test aux prepare_devs 5 # invalid units not pvs --config 'global { units = "<" }' - diff --git a/test/t-lvmcache-exercise.sh b/test/shell/lvmcache-exercise.sh index aecb4a9..b1e2b92 100755..100644 --- a/test/t-lvmcache-exercise.sh +++ b/test/shell/lvmcache-exercise.sh @@ -1,3 +1,4 @@ +#!/bin/sh # Copyright (C) 2008 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -8,16 +9,15 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test aux prepare_pvs 5 -vgcreate $vg1 $dev1 -vgcreate $vg2 $dev3 +vgcreate $vg1 "$dev1" +vgcreate $vg2 "$dev3" -disable_dev $dev1 +aux disable_dev "$dev1" pvscan -vgcreate $vg1 $dev2 -enable_dev $dev1 -pvs +vgcreate $vg1 "$dev2" +aux enable_dev "$dev1" pvs diff --git a/test/shell/lvmetad-disabled.sh b/test/shell/lvmetad-disabled.sh new file mode 100644 index 0000000..41a3a19 --- /dev/null +++ b/test/shell/lvmetad-disabled.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# Copyright (C) 2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +test -e LOCAL_LVMETAD || skip +kill $(cat LOCAL_LVMETAD) + +test -e $LVMETAD_PIDFILE && skip +lvmetad +test -e $LVMETAD_PIDFILE +cp $LVMETAD_PIDFILE LOCAL_LVMETAD +pvs 2>&1 | not grep "lvmetad is running" +aux lvmconf "global/use_lvmetad = 0" +pvs 2>&1 | grep "lvmetad is running" + +kill $(cat $LVMETAD_PIDFILE) +not ls $LVMETAD_PIDFILE diff --git a/test/shell/lvmetad-dump.sh b/test/shell/lvmetad-dump.sh new file mode 100644 index 0000000..e49eb68 --- /dev/null +++ b/test/shell/lvmetad-dump.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# Copyright (C) 2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test +test -e LOCAL_LVMETAD || skip + +aux prepare_pvs 2 +vgcreate $vg1 $dev1 $dev2 +lvcreate -n bar -l 1 $vg1 + +lvmetad_talk() { + if type -p socat >& /dev/null; then + socat "unix-connect:$1" - + elif echo | nc -U "$1"; then + nc -U "$1" + else + echo "WARNING: Neither socat nor nc -U seems to be available." 1>&2 + echo "# DUMP FAILED" + return 1 + fi +} + +lvmetad_dump() { + (echo 'request="dump"'; echo '##') | lvmetad_talk "$@" +} + +(echo | lvmetad_talk ./lvmetad.socket) || skip +lvmetad_dump ./lvmetad.socket | tee lvmetad.txt + +grep $vg1 lvmetad.txt diff --git a/test/shell/lvmetad-lvm1.sh b/test/shell/lvmetad-lvm1.sh new file mode 100644 index 0000000..528eec2 --- /dev/null +++ b/test/shell/lvmetad-lvm1.sh @@ -0,0 +1,22 @@ +#!/bin/sh +# Copyright (C) 2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +test -e LOCAL_LVMETAD || skip +aux prepare_devs 2 +pvcreate --metadatatype 1 $dev1 +vgscan --cache +pvs | grep $dev1 +vgcreate --metadatatype 1 $vg1 $dev1 +vgscan --cache +vgs | grep $vg1 +pvs | grep $dev1 diff --git a/test/shell/lvmetad-pvs.sh b/test/shell/lvmetad-pvs.sh new file mode 100644 index 0000000..80b421c --- /dev/null +++ b/test/shell/lvmetad-pvs.sh @@ -0,0 +1,19 @@ +#!/bin/sh +# Copyright (C) 2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +aux prepare_pvs 1 20000 +pvs $(cat DEVICES) | grep "$dev1" + +# check for PV size overflows +pvs $(cat DEVICES) | grep 19.53g +pvs $(cat DEVICES) | not grep 16.00e diff --git a/test/shell/lvmetad-pvscan-cache.sh b/test/shell/lvmetad-pvscan-cache.sh new file mode 100644 index 0000000..a27b6ad --- /dev/null +++ b/test/shell/lvmetad-pvscan-cache.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# Copyright (C) 2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +test -e LOCAL_LVMETAD || skip + +aux prepare_pvs 2 + +vgcreate $vg1 $dev1 $dev2 +vgs | grep $vg1 + +pvscan --cache + +vgs | grep $vg1 diff --git a/test/shell/lvmetad-restart.sh b/test/shell/lvmetad-restart.sh new file mode 100644 index 0000000..10268c2 --- /dev/null +++ b/test/shell/lvmetad-restart.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# Copyright (C) 2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +test -e LOCAL_LVMETAD || skip +aux prepare_pvs 2 + +vgcreate $vg1 $dev1 $dev2 +vgs | grep $vg1 + +kill $(cat LOCAL_LVMETAD) +aux prepare_lvmetad + +vgs | grep $vg1 diff --git a/test/shell/lvmetad-test.sh b/test/shell/lvmetad-test.sh new file mode 100644 index 0000000..7e801f1 --- /dev/null +++ b/test/shell/lvmetad-test.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# Copyright (C) 2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +aux prepare_pvs 2 + +vgcreate $vg1 $dev1 $dev2 --test +vgs | not grep $vg1 +vgcreate $vg1 $dev1 $dev2 +vgs | grep $vg1 + +lvcreate -n bar -l 1 $vg1 --test +lvs | not grep bar +lvcreate -n bar -l 1 $vg1 +lvs | grep bar + +lvremove $vg1/bar -f --test +lvs | grep bar +lvremove $vg1/bar -f +lvs | not grep bar + +vgremove $vg1 --test +vgs | grep $vg1 +vgremove $vg1 +vgs | not grep $vg1 diff --git a/test/shell/lvmetad-warning.sh b/test/shell/lvmetad-warning.sh new file mode 100644 index 0000000..3a97a1b --- /dev/null +++ b/test/shell/lvmetad-warning.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# Copyright (C) 2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +test -e LOCAL_LVMETAD || skip +aux prepare_pvs 2 + +vgcreate $vg1 $dev1 $dev2 +lvchange -ay $vg1 2>&1 | not grep "Failed to connect" +kill $(cat LOCAL_LVMETAD) +lvchange -ay $vg1 2>&1 | grep "Failed to connect" +lvchange -ay $vg1 --sysinit 2>&1 | not grep "Failed to connect" +aux lvmconf 'global/use_lvmetad = 0' +lvchange -ay $vg1 2>&1 | not grep "Failed to connect" +lvchange -ay $vg1 --sysinit 2>&1 | not grep "Failed to connect" +aux prepare_lvmetad +lvchange -ay $vg1 2>&1 | not grep "Failed to connect" +lvchange -ay $vg1 --sysinit 2>&1 | not grep "Failed to connect" diff --git a/test/t-lvresize-mirror.sh b/test/shell/lvresize-mirror.sh index 0d63102..a10f7cd 100644 --- a/test/t-lvresize-mirror.sh +++ b/test/shell/lvresize-mirror.sh @@ -9,30 +9,31 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test + aux prepare_vg 5 80 # extend 2-way mirror -lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0-1 +lvcreate -l2 -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev3":0-1 lvchange -an $vg/$lv1 lvextend -l+2 $vg/$lv1 -check mirror $vg $lv1 $dev3 +check mirror $vg $lv1 "$dev3" check mirror_images_contiguous $vg $lv1 lvremove -ff $vg # reduce 2-way mirror -lvcreate -l4 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0-1 +lvcreate -l4 -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev3":0-1 lvchange -an $vg/$lv1 lvreduce -l-2 $vg/$lv1 -check mirror $vg $lv1 $dev3 +check mirror $vg $lv1 "$dev3" lvremove -ff $vg # extend 2-way mirror (cling if not contiguous) -lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0-1 -lvcreate -l1 -n $lv2 $vg $dev1 -lvcreate -l1 -n $lv3 $vg $dev2 +lvcreate -l2 -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev3":0-1 +lvcreate -l1 -n $lv2 $vg "$dev1" +lvcreate -l1 -n $lv3 $vg "$dev2" lvchange -an $vg/$lv1 lvextend -l+2 $vg/$lv1 -check mirror $vg $lv1 $dev3 +check mirror $vg $lv1 "$dev3" check mirror_images_clung $vg $lv1 lvremove -ff $vg diff --git a/test/shell/lvresize-raid.sh b/test/shell/lvresize-raid.sh new file mode 100644 index 0000000..f999a31 --- /dev/null +++ b/test/shell/lvresize-raid.sh @@ -0,0 +1,80 @@ +#!/bin/sh +# Copyright (C) 2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +aux target_at_least dm-raid 1 1 0 || skip + +aux prepare_vg 5 80 + +# Extend a 2-way RAID1 +for deactivate in true false; do + lvcreate --type raid1 -m 1 -l 2 -n $lv1 $vg + + if $deactivate; then + lvchange -an $vg/$lv1 + fi + + lvresize -l +2 $vg/$lv1 + + #check raid_images_contiguous $vg $lv1 + + lvremove -ff $vg +done + +# Reduce 2-way RAID1 +for deactivate in true false; do + lvcreate --type raid1 -m 1 -l 4 -n $lv1 $vg + + if $deactivate; then + lvchange -an $vg/$lv1 + fi + + should lvresize -y -l -2 $vg/$lv1 + + #check raid_images_contiguous $vg $lv1 + + lvremove -ff $vg +done + +# Extend 3-striped RAID 4/5/6 +for i in 4 5 6 ; do + for deactivate in true false; do + lvcreate --type raid$i -i 3 -l 3 -n $lv1 $vg + + if $deactivate; then + lvchange -an $vg/$lv1 + fi + + lvresize -l +3 $vg/$lv1 + + #check raid_images_contiguous $vg $lv1 + + lvremove -ff $vg + done +done + +# Reduce 3-striped RAID 4/5/6 +for i in 4 5 6 ; do + for deactivate in true false; do + lvcreate --type raid$i -i 3 -l 6 -n $lv1 $vg + + if $deactivate; then + lvchange -an $vg/$lv1 + fi + + should lvresize -y -l -3 $vg/$lv1 + + #check raid_images_contiguous $vg $lv1 + + lvremove -ff $vg + done +done diff --git a/test/shell/lvresize-raid10.sh b/test/shell/lvresize-raid10.sh new file mode 100644 index 0000000..9b71708 --- /dev/null +++ b/test/shell/lvresize-raid10.sh @@ -0,0 +1,46 @@ +#!/bin/sh +# Copyright (C) 2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +aux target_at_least dm-raid 1 3 0 || skip + +aux prepare_vg 5 80 + +# Extend RAID10 (2-stripes, 2-mirror) +for deactivate in true false; do + lvcreate --type raid10 -m 1 -i 2 -l 2 -n $lv1 $vg + + if $deactivate; then + lvchange -an $vg/$lv1 + fi + + lvresize -l +2 $vg/$lv1 + + #check raid_images_contiguous $vg $lv1 + + lvremove -ff $vg +done + +# Reduce RAID10 (2-stripes, 2-mirror) +for deactivate in true false; do + lvcreate --type raid10 -m 1 -i 2 -l 4 -n $lv1 $vg + + if $deactivate; then + lvchange -an $vg/$lv1 + fi + + should lvresize -y -l -2 $vg/$lv1 + + #check raid_images_contiguous $vg $lv1 + + lvremove -ff $vg +done diff --git a/test/shell/lvresize-rounding.sh b/test/shell/lvresize-rounding.sh new file mode 100644 index 0000000..ad8d9c0 --- /dev/null +++ b/test/shell/lvresize-rounding.sh @@ -0,0 +1,90 @@ +#!/bin/sh +# Copyright (C) 2007-2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +aux prepare_pvs 3 22 + +vgcreate -s 32K $vg "$dev1" "$dev2" "$dev3" + +lvcreate -l4 -i3 -I64 $vg + +lvcreate -l8 -i2 -I64 $vg + +lvcreate -l16 $vg + +lvcreate -l32 -i3 -I64 -n $lv1 $vg + +lvresize -l+64 -i3 -I64 $vg/$lv1 + +lvresize -l+64 -i3 -I128 $vg/$lv1 + +#lvcreate -l100%FREE -i3 -I64 --alloc anywhere $vg + +dmsetup table + +vgcfgbackup -f /tmp/vg $vg +vgremove -f $vg + +# 15 extents +aux prepare_vg 3 22 + +# Block some extents +lvcreate -l4 -i3 $vg +lvcreate -l1 $vg + +lvcreate -l100%FREE -n $lv1 -i3 $vg +check vg_field $vg vg_free_count 2 +lvremove -f $vg/$lv1 + +lvcreate -l1 -n $lv1 -i3 $vg +lvextend -l+100%FREE -i3 $vg/$lv1 +check vg_field $vg vg_free_count 2 + +lvreduce -f -l50%LV $vg/$lv1 +vgremove -f $vg + + +vgcreate -s 4M $vg "$dev1" "$dev2" "$dev3" + +# Expect to play with 15 extents +check vg_field $vg vg_free_count 15 + +# Should be rounded to 12 extents +lvcreate -l10 -n lv -i3 $vg +check vg_field $vg vg_free_count 3 + +# Should want 16 extents +not lvextend -l+4 $vg/lv + +# Round up to whole free space +lvextend -l+100%FREE $vg/lv +check vg_field $vg vg_free_count 0 + +# Rounds up and should reduce just by 3 extents +lvreduce -f -l-4 $vg/lv +check vg_field $vg vg_free_count 3 + +# Should round up to 15 extents +lvextend -f -l+1 $vg/lv +check vg_field $vg vg_free_count 0 + +lvreduce -f -l-4 $vg/lv +check vg_field $vg vg_free_count 3 + +lvextend -l90%VG $vg/lv +check vg_field $vg vg_free_count 0 + +not lvreduce -f -l-10%LV $vg/lv +check vg_field $vg vg_free_count 0 + +lvreduce -f -l-20%LV $vg/lv +check vg_field $vg vg_free_count 3 diff --git a/test/t-lvresize-usage.sh b/test/shell/lvresize-usage.sh index d9860e9..51ef221 100755..100644 --- a/test/t-lvresize-usage.sh +++ b/test/shell/lvresize-usage.sh @@ -1,3 +1,4 @@ +#!/bin/sh # Copyright (C) 2007-2008 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -8,7 +9,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test aux prepare_vg 2 diff --git a/test/shell/mdata-strings.sh b/test/shell/mdata-strings.sh new file mode 100644 index 0000000..16e9360 --- /dev/null +++ b/test/shell/mdata-strings.sh @@ -0,0 +1,38 @@ +#!/bin/sh +# Copyright (C) 2008-2011 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# 'Test for proper escaping of strings in metadata (bz431474)' + +. lib/test + +aux prepare_devs 2 +aux lvmconf 'devices/global_filter = [ "a|.*LVMTEST.*dev/mapper/.*pv[0-9_]*$|", "r|.*|" ]' + +# for udev impossible to create +pv_ugly="__\"!@#\$%^&*,()|@||'\\\"__pv1" + +# 'set up temp files, loopback devices' +name=$(basename "$dev1") +dmsetup rename "$name" "$PREFIX$pv_ugly" +dev1=$(dirname "$dev1")/"$PREFIX$pv_ugly" + +dm_table | grep -F "$pv_ugly" + +# 'pvcreate, vgcreate on filename with backslashed chars' +created="$dev1" +# when used with real udev without fallback, it will fail here +pvcreate "$dev1" || created="$dev2" +pvdisplay | should grep -F "$pv_ugly" +should check pv_field "$dev1" pv_name "$dev1" +vgcreate $vg "$created" +# 'no parse errors and VG really exists' +vgs $vg 2>err +not grep "Parse error" err diff --git a/test/shell/metadata-balance.sh b/test/shell/metadata-balance.sh new file mode 100644 index 0000000..88ac114 --- /dev/null +++ b/test/shell/metadata-balance.sh @@ -0,0 +1,232 @@ +#!/bin/sh +# Copyright (C) 2008 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +aux prepare_devs 6 + +echo Make sure we can ignore / un-ignore mdas on a per-PV basis +for pv_in_vg in 1 0; do +for mdacp in 1 2; do + pvcreate --metadatacopies $mdacp "$dev1" "$dev2" + pvcreate --metadatacopies 0 "$dev3" + if [ $pv_in_vg = 1 ]; then + vgcreate -c n $vg "$dev1" "$dev2" "$dev3" + fi + pvchange --metadataignore y "$dev1" + check pv_field "$dev1" pv_mda_count $mdacp + check pv_field "$dev1" pv_mda_used_count 0 + check pv_field "$dev2" pv_mda_count $mdacp + check pv_field "$dev2" pv_mda_used_count $mdacp + if [ $pv_in_vg = 1 ]; then + check vg_field $vg vg_mda_count $(($mdacp * 2)) + check vg_field $vg vg_mda_used_count $mdacp + check vg_field $vg vg_mda_copies unmanaged + fi + pvchange --metadataignore n "$dev1" + check pv_field "$dev1" pv_mda_count $mdacp + check pv_field "$dev1" pv_mda_used_count $mdacp + if [ $pv_in_vg = 1 ]; then + check vg_field $vg vg_mda_count $(($mdacp * 2)) + check vg_field $vg vg_mda_used_count $(($mdacp * 2)) + check vg_field $vg vg_mda_copies unmanaged + vgremove -f $vg + fi +done +done + +# Check if a PV has unignored (used) mdas, and if so, ignore +pvignore_ () { + pv_mda_used_count=$(get pv_field "$1" pv_mda_used_count) + if [ $pv_mda_used_count -ne 0 ]; then + pvchange --metadataignore y $1 + fi +} + +# Check if a PV has ignored mdas, and if so, unignore (make used) +pvunignore_ () { + pv_mda_count=$(get pv_field "$1" pv_mda_count) + pv_mda_used_count=$(get pv_field "$1" pv_mda_used_count) + if [ $pv_mda_count -gt $pv_mda_used_count ]; then + pvchange --metadataignore n $1 + fi +} + +echo Test of vgmetadatacopies with vgcreate and vgchange +for mdacp in 1 2; do + pvcreate --metadatacopies $mdacp "$dev1" "$dev2" "$dev4" "$dev5" + check pv_field "$dev1" pv_mda_used_count $mdacp + check pv_field "$dev2" pv_mda_used_count $mdacp + check pv_field "$dev4" pv_mda_used_count $mdacp + check pv_field "$dev5" pv_mda_used_count $mdacp + pvcreate --metadatacopies 0 "$dev3" + vgcreate -c n $vg "$dev1" "$dev2" "$dev3" + check vg_field $vg vg_mda_copies unmanaged + echo ensure both --vgmetadatacopies and --metadatacopies accepted + vgchange --metadatacopies $(($mdacp * 1)) $vg + echo --vgmetadatacopies is persistent on disk + echo --vgmetadatacopies affects underlying pv mda ignore + check vg_field $vg vg_mda_copies $(($mdacp * 1)) + check vg_field $vg vg_mda_used_count $(($mdacp * 1)) + vgchange --vgmetadatacopies $(($mdacp * 2)) $vg + check vg_field $vg vg_mda_copies $(($mdacp * 2)) + check vg_field $vg vg_mda_used_count $(($mdacp * 2)) + echo allow setting metadatacopies larger than number of PVs + vgchange --vgmetadatacopies $(($mdacp * 5)) $vg + check vg_field $vg vg_mda_copies $(($mdacp * 5)) + check vg_field $vg vg_mda_used_count $(($mdacp * 2)) + echo setting to 0 disables automatic balancing + vgchange --vgmetadatacopies unmanaged $vg + check vg_field $vg vg_mda_copies unmanaged + vgremove -f $vg + echo vgcreate succeeds even when creating a VG w/all ignored mdas + pvchange --metadataignore y "$dev1" "$dev2" + check pv_field "$dev1" pv_mda_count $mdacp + check pv_field "$dev2" pv_mda_used_count 0 + vgcreate -c n $vg "$dev1" "$dev2" + check vg_field $vg vg_mda_copies unmanaged + vgremove -f $vg + echo vgcreate succeeds with a specific number of metadata copies + vgcreate -c n --vgmetadatacopies $(($mdacp * 2)) $vg "$dev1" "$dev2" + check vg_field $vg vg_mda_copies $(($mdacp * 2)) + vgremove -f $vg + vgcreate -c n --vgmetadatacopies $(($mdacp * 1)) $vg "$dev1" "$dev2" + check vg_field $vg vg_mda_copies $(($mdacp * 1)) + vgremove -f $vg + echo vgcreate succeeds with a larger value than total metadatacopies + vgcreate -c n --vgmetadatacopies $(($mdacp * 5)) $vg "$dev1" "$dev2" + check vg_field $vg vg_mda_copies $(($mdacp * 5)) + vgremove -f $vg + echo vgcreate succeeds with --vgmetadatacopies unmanaged + vgcreate -c n --vgmetadatacopies unmanaged $vg "$dev1" "$dev2" + check vg_field $vg vg_mda_copies unmanaged + vgremove -f $vg + pvunignore_ "$dev1" + pvunignore_ "$dev2" + pvunignore_ "$dev4" + pvunignore_ "$dev5" + echo vgcreate succeds with small value of --metadatacopies, ignores mdas + vgcreate -c n --vgmetadatacopies 1 $vg "$dev1" "$dev2" "$dev4" "$dev5" + check vg_field $vg vg_mda_copies 1 + check vg_field $vg vg_mda_count $(($mdacp * 4)) + check vg_field $vg vg_mda_used_count 1 + echo Setting a larger value should trigger non-ignore of mdas + vgchange --metadatacopies 3 $vg + check vg_field $vg vg_mda_copies 3 + check vg_field $vg vg_mda_used_count 3 + echo Setting all should trigger unignore of all mdas + vgchange --vgmetadatacopies all $vg + check vg_field $vg vg_mda_count $(($mdacp * 4)) + check vg_field $vg vg_mda_copies unmanaged + check vg_field $vg vg_mda_used_count $(($mdacp * 4)) + echo --vgmetadatacopies 0 should be unmanaged for vgchange and vgcreate + vgchange --vgmetadatacopies 0 $vg + check vg_field $vg vg_mda_copies unmanaged + vgremove -f $vg + vgcreate -c n --vgmetadatacopies 0 $vg "$dev1" "$dev2" "$dev4" "$dev5" + check vg_field $vg vg_mda_copies unmanaged + vgremove -f $vg +done + +echo Test vgextend / vgreduce with vgmetadatacopies +for mdacp in 1 2; do + pvcreate --metadatacopies $mdacp "$dev1" "$dev2" "$dev4" "$dev5" + pvcreate --metadatacopies 0 "$dev3" + echo Set a large value of vgmetadatacopies + vgcreate -c n --vgmetadatacopies $(($mdacp * 5)) $vg "$dev1" "$dev2" "$dev3" + check vg_field $vg vg_mda_copies $(($mdacp * 5)) + echo Ignore mdas on devices to be used for vgextend + echo Large value of vgetadatacopies should automatically un-ignore mdas + pvchange --metadataignore y "$dev4" "$dev5" + check pv_field "$dev4" pv_mda_used_count 0 + vgextend $vg "$dev4" "$dev5" + check pv_field "$dev4" pv_mda_used_count $mdacp + check pv_field "$dev5" pv_mda_used_count $mdacp + vgremove -f $vg + echo Set a small value of vgmetadatacopies + vgcreate -c n --vgmetadatacopies $(($mdacp * 1)) $vg "$dev1" "$dev2" "$dev3" + check vg_field $vg vg_mda_copies $(($mdacp * 1)) + echo Ignore mdas on devices to be used for vgextend + echo Small value of vgetadatacopies should leave mdas as ignored + pvchange --metadataignore y "$dev4" "$dev5" + check pv_field "$dev4" pv_mda_used_count 0 + vgextend $vg "$dev4" "$dev5" + check pv_field "$dev4" pv_mda_used_count 0 + check pv_field "$dev5" pv_mda_used_count 0 + echo vgreduce of ignored pv w/mda should not trigger any change to ignore bits + vgreduce $vg "$dev4" + check pv_field "$dev4" pv_mda_used_count 0 + check pv_field "$dev5" pv_mda_used_count 0 + echo vgreduce of un-ignored pv w/mda should trigger un-ignore on an mda + vgreduce $vg "$dev1" "$dev2" "$dev3" + check pv_field "$dev5" pv_mda_used_count $mdacp + check vg_field $vg vg_mda_copies $(($mdacp * 1)) + pvunignore_ "$dev1" + pvunignore_ "$dev2" + echo setting vgmetadatacopies to unmanaged should allow vgextend to add w/out balancing + vgchange --vgmetadatacopies unmanaged $vg + vgextend $vg "$dev1" "$dev2" + check vg_field $vg vg_mda_copies unmanaged + check vg_field $vg vg_mda_count $(($mdacp * 3)) + check vg_field $vg vg_mda_used_count $((mdacp * 3)) + check pv_field "$dev1" pv_mda_used_count $mdacp + check pv_field "$dev2" pv_mda_used_count $mdacp + vgremove -f $vg +done + +echo Test special situations, vgsplit, vgmerge, etc +for mdacp in 1 2; do + pvcreate --metadatacopies $mdacp "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" + vgcreate -c n --vgmetadatacopies 2 $vg1 "$dev1" "$dev2" "$dev3" + vgcreate -c n --vgmetadatacopies $(($mdacp * 1)) $vg2 "$dev4" "$dev5" + echo vgsplit/vgmerge preserves value of metadata copies + check vg_field $vg1 vg_mda_copies 2 + check vg_field $vg2 vg_mda_copies $(($mdacp * 1)) + vgsplit $vg1 $vg2 "$dev1" + check vg_field $vg2 vg_mda_copies $(($mdacp * 1)) + vgmerge $vg1 $vg2 + check vg_field $vg1 vg_mda_copies 2 + check vg_field $vg1 vg_mda_count $(($mdacp * 5)) + echo vgsplit into new vg sets proper value of vgmetadatacopies + vgsplit --vgmetadatacopies $(($mdacp * 2)) $vg1 $vg2 "$dev1" "$dev2" + check vg_field $vg2 vg_mda_copies $(($mdacp * 2)) + echo vgchange fails if given both vgmetadatacopies and metadatacopies + not vgchange --vgmetadatacopies 5 --metadatacopies 7 $vg2 + vgremove -f $vg1 $vg2 +done + +echo Test combination of --vgmetadatacopies and pvchange --metadataignore +for mdacp in 1 2; do + pvcreate --metadatacopies $mdacp "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" + vgcreate -c n --vgmetadatacopies $(($mdacp * 1)) $vg1 "$dev1" "$dev2" + check vg_field $vg1 vg_mda_copies $(($mdacp * 1)) + check vg_field $vg1 vg_mda_used_count $(($mdacp * 1)) + pvignore_ "$dev3" + echo Ensure vgextend of PVs with ignored MDAs does not add to vg_mda_used_count + vgextend $vg1 "$dev3" + check vg_field $vg1 vg_mda_used_count $(($mdacp * 1)) + echo Using pvchange to unignore should update vg_mda_used_count + pvchange -f --metadataignore n "$dev3" + check pv_field "$dev3" pv_mda_used_count $mdacp + check vg_field $vg1 vg_mda_used_count $(($mdacp * 2)) + echo Set unmanaged on the vg should keep ignore bits the same during vgextend + vgchange --vgmetadatacopies unmanaged $vg1 + check vg_field $vg1 vg_mda_used_count $(($mdacp * 2)) + pvunignore_ "$dev4" + vgextend $vg1 "$dev4" + check pv_field "$dev4" pv_mda_used_count $mdacp + check vg_field $vg1 vg_mda_used_count $(($mdacp * 3)) + echo Using pvchange to ignore should update vg_mda_used_count + pvchange -f --metadataignore y "$dev4" + check pv_field "$dev4" pv_mda_used_count 0 + check vg_field $vg1 vg_mda_used_count $(($mdacp * 2)) + vgremove -f $vg1 +done diff --git a/test/shell/metadata-dirs.sh b/test/shell/metadata-dirs.sh new file mode 100644 index 0000000..852ce35 --- /dev/null +++ b/test/shell/metadata-dirs.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# Copyright (C) 2011 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +aux prepare_devs 3 + +pvcreate --metadatacopies 0 $(cat DEVICES) +not vgcreate $vg $(cat DEVICES) + +aux lvmconf "metadata/dirs = [ \"$TESTDIR/mda\" ]" + +vgcreate $vg "$dev1" +check vg_field $vg vg_mda_count 1 +vgremove -ff $vg + +vgcreate $vg $(cat DEVICES) +check vg_field $vg vg_mda_count 1 +vgremove -ff $vg + +pvcreate --metadatacopies 1 --metadataignore y "$dev1" +vgcreate $vg $(cat DEVICES) +check vg_field $vg vg_mda_count 2 +vgremove -ff $vg + +pvcreate --metadatacopies 1 --metadataignore n "$dev1" +vgcreate $vg $(cat DEVICES) +check vg_field $vg vg_mda_count 2 +vgremove -ff $vg + +pvcreate --metadatacopies 0 "$dev1" +aux lvmconf "metadata/dirs = [ \"$TESTDIR/mda\", \"$TESTDIR/mda2\" ]" +vgcreate $vg $(cat DEVICES) +check vg_field $vg vg_mda_count 2 +vgremove -ff $vg diff --git a/test/t-metadata.sh b/test/shell/metadata.sh index 49066c7..a9f8640 100755..100644 --- a/test/t-metadata.sh +++ b/test/shell/metadata.sh @@ -1,3 +1,4 @@ +#!/bin/sh # Copyright (C) 2008 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -8,73 +9,68 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test aux prepare_devs 5 -pvcreate $dev1 -pvcreate --metadatacopies 0 $dev2 -pvcreate --metadatacopies 0 $dev3 -pvcreate $dev4 -pvcreate --metadatacopies 0 $dev5 +pvcreate "$dev1" +pvcreate --metadatacopies 0 "$dev2" +pvcreate --metadatacopies 0 "$dev3" +pvcreate "$dev4" +pvcreate --metadatacopies 0 "$dev5" -vgcreate -c n "$vg" $devs +vgcreate -c n $vg $(cat DEVICES) lvcreate -n $lv -l 1 -i5 -I256 $vg -pvchange -x n $dev1 -pvchange -x y $dev1 +pvchange -x n "$dev1" +pvchange -x y "$dev1" vgchange -a n $vg -pvchange --uuid $dev1 -pvchange --uuid $dev2 +pvchange --uuid "$dev1" +pvchange --uuid "$dev2" vgremove -f $vg # check that PVs without metadata don't cause too many full device rescans (bz452606) for mdacp in 1 0; do - pvcreate --metadatacopies $mdacp $devs - pvcreate $dev1 - vgcreate -c n $vg $devs + pvcreate --metadatacopies $mdacp $(cat DEVICES) + pvcreate "$dev1" + vgcreate -c n $vg $(cat DEVICES) lvcreate -n $lv1 -l 2 -i5 -I256 $vg lvcreate -n $lv2 -m2 -l 2 $vg - #lvchange -an $vg - lvchange -an $vg/$lv1 - lvchange -an $vg/$lv2 + lvchange -an $vg/$lv1 $vg/$lv2 vgchange -ay $vg - lvchange -vvvv -an $vg/$lv1 >out$mdacp 2>&1 - lvchange -vvvv -an $vg/$lv2 >>out$mdacp 2>&1 + lvchange -an $vg/$lv1 $vg/$lv2 vgremove -f $vg done not grep "Cached VG .* incorrect PV list" out0 # some M1 metadata tests -pvcreate -M1 $dev1 -pvcreate -M1 $dev2 -pvcreate -M1 $dev3 -pv3_uuid=$(pvs --noheadings -o pv_uuid $dev3) -vgcreate -M1 -c n $vg $dev1 $dev2 $dev3 -pvchange --uuid $dev1 +pvcreate -M1 "$dev1" "$dev2" "$dev3" +pv3_uuid=$(get pv_field "$dev3" pv_uuid) +vgcreate -M1 -c n $vg "$dev1" "$dev2" "$dev3" +pvchange --uuid "$dev1" # verify pe_start of all M1 PVs pv_align="128.00k" -check_pv_field_ $dev1 pe_start $pv_align -check_pv_field_ $dev2 pe_start $pv_align -check_pv_field_ $dev3 pe_start $pv_align +check pv_field "$dev1" pe_start $pv_align +check pv_field "$dev2" pe_start $pv_align +check pv_field "$dev3" pe_start $pv_align -pvs --units k -o name,pe_start,vg_mda_size,vg_name +pvs --units k -o name,pe_start,vg_mda_size,vg_name $(cat DEVICES) # upgrade from v1 to v2 metadata vgconvert -M2 $vg # verify pe_start of all M2 PVs -check_pv_field_ $dev1 pe_start $pv_align -check_pv_field_ $dev2 pe_start $pv_align -check_pv_field_ $dev3 pe_start $pv_align +check pv_field "$dev1" pe_start $pv_align +check pv_field "$dev2" pe_start $pv_align +check pv_field "$dev3" pe_start $pv_align -pvs --units k -o name,pe_start,vg_mda_size,vg_name +pvs --units k -o name,pe_start,vg_mda_size,vg_name $(cat DEVICES) # create backup and then restore $dev3 vgcfgbackup -f $TESTDIR/bak-%s $vg -pvcreate -ff -y --restorefile $TESTDIR/bak-$vg --uuid $pv3_uuid $dev3 +pvcreate -ff -y --restorefile $TESTDIR/bak-$vg --uuid $pv3_uuid "$dev3" vgcfgrestore -f $TESTDIR/bak-$vg $vg # verify pe_start of $dev3 -check_pv_field_ $dev3 pe_start $pv_align +check pv_field "$dev3" pe_start $pv_align diff --git a/test/shell/mirror-names.sh b/test/shell/mirror-names.sh new file mode 100644 index 0000000..d6c67ee --- /dev/null +++ b/test/shell/mirror-names.sh @@ -0,0 +1,132 @@ +#!/bin/sh +# Copyright (C) 2007-2012 Red Hat, Inc. All rights reserved. +# Copyright (C) 2007-2008 NEC Corporation +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +test_description="check namings of mirrored LV" + +. lib/test + +# --------------------------------------------------------------------- +# Utilities + +lv_devices_() { + local d + local lv=$1 + shift + local devices=$@ + local devs=$(get lv_field $lv devices -a | sed 's/([0-9]*)//g; s/ //g; s/,/ /g') + + for d in $devs; do + (echo $devices | grep $d) || return 1 + devices=$(echo $devices | sed "s/$d//") + done + + test -z "$(echo $devices | sed 's/ //g')" +} + +lv_mirror_log_() { + test $(get lv_field $1 mirror_log) = $2 +} + +lv_convert_lv_() { + get lv_field $1 convert_lv +} + +# --------------------------------------------------------------------- +# Common environment setup/cleanup for each sub testcases + +check_and_cleanup_lvs_() { + lvs -a -o+devices $vg + lvremove -ff $vg + (dm_table | not grep $vg) || \ + die "ERROR: lvremove did leave some some mappings in DM behind!" +} + +# --------------------------------------------------------------------- +# Initialize PVs and VGs + +aux prepare_vg 5 80 + +check_and_cleanup_lvs_ + +# --------------------------------------------------------------------- +# basic + +#COMM "init: lvcreate" + +#COMM "mirror images are ${lv1}_mimage_x" +lvcreate -l2 -m1 -n $lv1 $vg +lv_devices_ $vg/$lv1 ${lv1}_mimage_0 ${lv1}_mimage_1 + +#COMM "mirror log is ${lv1}_mlog" +lv_mirror_log_ $vg/$lv1 ${lv1}_mlog + +# "cleanup" +check_and_cleanup_lvs_ + +#COMM "mirror with name longer than 22 characters (bz221322)" +name="LVwithanamelogerthan22characters_butidontwonttocounthem" +lvcreate -m1 -l2 -n $name $vg +lvs $vg/$name +check_and_cleanup_lvs_ + +# --------------------------------------------------------------------- +# lvrename + +#COMM "init: lvrename" + +#COMM "renamed mirror names: $lv1 to $lv2" +lvcreate -l2 -m1 -n $lv1 $vg +lvrename $vg/$lv1 $vg/$lv2 +lv_devices_ $vg/$lv2 ${lv2}_mimage_0 ${lv2}_mimage_1 +lv_mirror_log_ $vg/$lv2 ${lv2}_mlog + +#COMM "cleanup" +check_and_cleanup_lvs_ + +# --------------------------------------------------------------------- +# lvconvert + +#COMM "init: lvconvert" + +#COMM "converting mirror names is ${lv1}_mimagetmp_2" +lvcreate -l2 -m1 -n $lv1 $vg +lvconvert -m+1 -i+40 -b $vg/$lv1 +convlv=$(lv_convert_lv_ $vg/$lv1) +test $convlv = ${lv1}_mimagetmp_2 +lv_devices_ $vg/$lv1 $convlv ${lv1}_mimage_2 +lv_devices_ $vg/$convlv ${lv1}_mimage_0 ${lv1}_mimage_1 +lv_mirror_log_ $vg/$convlv ${lv1}_mlog + +#COMM "mirror log name after re-adding is ${lv1}_mlog" \ +lvconvert --mirrorlog core $vg/$lv1 +lvconvert --mirrorlog disk $vg/$lv1 +convlv=$(lv_convert_lv_ $vg/$lv1) +lv_devices_ $vg/$lv1 $convlv ${lv1}_mimage_2 +lv_devices_ $vg/$convlv ${lv1}_mimage_0 ${lv1}_mimage_1 +lv_mirror_log_ $vg/$convlv ${lv1}_mlog + +#COMM "renamed converting mirror names: $lv1 to $lv2" \ +lvrename $vg/$lv1 $vg/$lv2 +convlv=$(lv_convert_lv_ $vg/$lv2) +lv_devices_ $vg/$lv2 $convlv ${lv2}_mimage_2 +lv_devices_ $vg/$convlv ${lv2}_mimage_0 ${lv2}_mimage_1 +lv_mirror_log_ $vg/$convlv ${lv2}_mlog + +#COMM "cleanup" +check_and_cleanup_lvs_ + +# Temporary mirror log should have "_mlogtmp_<n>" suffix +# but currently lvconvert doesn't have an option to add the log. +# If such feature is added in future, a test for that should +# be added. + +# --------------------------------------------------------------------- diff --git a/test/t-mirror-vgreduce-removemissing.sh b/test/shell/mirror-vgreduce-removemissing.sh index 0f6a8b0..232c2be 100755..100644 --- a/test/t-mirror-vgreduce-removemissing.sh +++ b/test/shell/mirror-vgreduce-removemissing.sh @@ -1,4 +1,5 @@ -# Copyright (C) 2008 Red Hat, Inc. All rights reserved. +#!/bin/sh +# Copyright (C) 2008-2012 Red Hat, Inc. All rights reserved. # Copyright (C) 2007 NEC Corporation # # This copyrighted material is made available to anyone wishing to use, @@ -11,21 +12,20 @@ test_description="ensure that 'vgreduce --removemissing' works on mirrored LV" -. ./test-utils.sh +. lib/test lv_is_on_ () { local lv=$vg/$1 shift - local pvs=$* + local pvs=$@ echo "Check if $lv is exactly on PVs $pvs" rm -f out1 out2 echo $pvs | sed 's/ /\n/g' | sort | uniq > out1 lvs -a -o+devices $lv - lvs -a -odevices --noheadings $lv | \ - sed 's/([^)]*)//g; s/[ ,]/\n/g' | sort | uniq > out2 + get lv_devices $lv | sed 's/ /\n/g' | sort | uniq > out2 || true diff --ignore-blank-lines out1 out2 } @@ -34,21 +34,22 @@ mimages_are_on_ () { local lv=$1 shift - local pvs="$*" + local pvs=$@ local mimages local i echo "Check if mirror images of $lv are on PVs $pvs" rm -f out1 out2 echo $pvs | sed 's/ /\n/g' | sort | uniq > out1 + lvs --noheadings -a -o lv_name $vg > lvs_log + mimages=$(grep "${lv}_mimage_" lvs_log | \ + sed 's/\[//g; s/\]//g' || true) - mimages=$(lvs --noheadings -a -o lv_name $vg | grep "${lv}_mimage_" | \ - sed 's/\[//g; s/\]//g') for i in $mimages; do echo "Checking $vg/$i" lvs -a -o+devices $vg/$i - lvs -a -odevices --noheadings $vg/$i | \ - sed 's/([^)]*)//g; s/ //g; s/,/ /g' | sort | uniq >> out2 + lvs -a -odevices --noheadings $vg/$i > lvs_log + sed 's/([^)]*)//g; s/ //g; s/,/ /g' lvs_log | sort | uniq >> out2 || true done diff --ignore-blank-lines out1 out2 @@ -56,23 +57,22 @@ mimages_are_on_ () mirrorlog_is_on_() { - local lv="$1"_mlog + local lv=${1}_mlog shift - lv_is_on_ $lv $* + lv_is_on_ $lv "$@" } lv_is_linear_() { echo "Check if $1 is linear LV (i.e. not a mirror)" - lvs -o stripes,attr --noheadings $vg/$1 | sed 's/ //g' - lvs -o stripes,attr --noheadings $vg/$1 | sed 's/ //g' | grep -q '^1-' + get lv_field $vg/$1 "stripes,attr" | grep "^1 -" >/dev/null } rest_pvs_() { local index=$1 local num=$2 - local rem="" + local rem= local n for n in $(seq 1 $(($index - 1))) $(seq $(($index + 1)) $num); do @@ -86,41 +86,34 @@ rest_pvs_() # --------------------------------------------------------------------- # Initialize PVs and VGs -prepare_vg 5 +aux prepare_vg 5 # --------------------------------------------------------------------- # Common environment setup/cleanup for each sub testcases prepare_lvs_() { - lvremove -ff $vg; - if dmsetup table|grep $vg; then - echo "ERROR: lvremove did leave some some mappings in DM behind!" - return 1 - fi - : + lvremove -ff $vg + (dm_table | not grep $vg) || \ + die "ERROR: lvremove did leave some some mappings in DM behind!" } check_and_cleanup_lvs_() { - lvs -a -o+devices $vg - lvremove -ff $vg - if dmsetup table|grep $vg; then - echo "ERROR: lvremove did leave some some mappings in DM behind!" - return 1 - fi + lvs -a -o+devices $vg + prepare_lvs_ } recover_vg_() { - enable_dev $* - pvcreate -ff $* - vgextend $vg $* + aux enable_dev "$@" + pvcreate -ff "$@" + vgextend $vg "$@" check_and_cleanup_lvs_ } -#COMM "check environment setup/cleanup" -prepare_lvs_ +#COMM "check environment setup/cleanup" +prepare_lvs_ check_and_cleanup_lvs_ # --------------------------------------------------------------------- @@ -128,17 +121,17 @@ check_and_cleanup_lvs_ #COMM "basic: fail the 2nd mirror image of 2-way mirrored LV" prepare_lvs_ -lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0 +lvcreate -l2 -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev3":0 lvchange -an $vg/$lv1 -aux mimages_are_on_ $lv1 $dev1 $dev2 +mimages_are_on_ $lv1 $dev1 $dev2 mirrorlog_is_on_ $lv1 $dev3 -disable_dev $dev2 +aux disable_dev "$dev2" vgreduce --removemissing --force $vg lv_is_linear_ $lv1 -lv_is_on_ $lv1 $dev1 +lv_is_on_ $lv1 "$dev1" # "cleanup" -recover_vg_ $dev2 +recover_vg_ "$dev2" # --------------------------------------------------------------------- # LV has 3 images in flat, @@ -149,15 +142,15 @@ test_3way_mirror_fail_1_() { local index=$1 - lvcreate -l2 -m2 -n $lv1 $vg $dev1 $dev2 $dev3 $dev4:0 + lvcreate -l2 -m2 -n $lv1 $vg "$dev1" "$dev2" "$dev3" "$dev4":0 lvchange -an $vg/$lv1 - aux mimages_are_on_ $lv1 $dev1 $dev2 $dev3 - mirrorlog_is_on_ $lv1 $dev4 - eval disable_dev \$dev$index + mimages_are_on_ $lv1 "$dev1" "$dev2" "$dev3" + mirrorlog_is_on_ $lv1 "$dev4" + eval aux disable_dev \$dev$index vgreduce --removemissing --force $vg lvs -a -o+devices $vg mimages_are_on_ $lv1 $(rest_pvs_ $index 3) - mirrorlog_is_on_ $lv1 $dev4 + mirrorlog_is_on_ $lv1 "$dev4" } for n in $(seq 1 3); do @@ -176,15 +169,15 @@ test_3way_mirror_fail_2_() { local index=$1 - lvcreate -l2 -m2 -n $lv1 $vg $dev1 $dev2 $dev3 $dev4:0 + lvcreate -l2 -m2 -n $lv1 $vg "$dev1" "$dev2" "$dev3" "$dev4":0 lvchange -an $vg/$lv1 - mimages_are_on_ $lv1 $dev1 $dev2 $dev3 - mirrorlog_is_on_ $lv1 $dev4 + mimages_are_on_ $lv1 "$dev1" "$dev2" "$dev3" + mirrorlog_is_on_ $lv1 "$dev4" rest_pvs_ $index 3 - disable_dev $(rest_pvs_ $index 3) + aux disable_dev $(rest_pvs_ $index 3) vgreduce --force --removemissing $vg lvs -a -o+devices $vg - aux lv_is_linear_ $lv1 + lv_is_linear_ $lv1 eval lv_is_on_ $lv1 \$dev$n } @@ -204,16 +197,17 @@ test_3way_mirror_plus_1_fail_1_() { local index=$1 - lvcreate -l2 -m2 -n $lv1 $vg $dev1 $dev2 $dev3 $dev5:0 - lvchange -an $vg/$lv1 - lvconvert -m+1 $vg/$lv1 $dev4 - mimages_are_on_ $lv1 $dev1 $dev2 $dev3 $dev4 - mirrorlog_is_on_ $lv1 $dev5 - eval disable_dev \$dev$n - vgreduce --removemissing --force $vg - lvs -a -o+devices $vg - mimages_are_on_ $lv1 $(rest_pvs_ $index 4) - mirrorlog_is_on_ $lv1 $dev5 + lvcreate -l2 -m2 -n $lv1 $vg "$dev1" "$dev2" "$dev3" "$dev5":0 + lvchange -an $vg/$lv1 + lvconvert -m+1 $vg/$lv1 "$dev4" + check mirror_images_on $vg $lv1 "$dev1" "$dev2" "$dev3" "$dev4" + check mirror_log_on $vg $lv1 "$dev5" + eval aux disable_dev \$dev$index + lvs -a -o +devices + vgreduce --removemissing --force $vg + lvs -a -o+devices # $vg + check mirror_images_on $vg $lv1 "$dev5" # $(rest_pvs_ $index 4) + check mirror_log_on $vg $lv1 "$dev5" } for n in $(seq 1 4); do @@ -232,17 +226,18 @@ test_3way_mirror_plus_1_fail_3_() { local index=$1 - lvcreate -l2 -m2 -n $lv1 $vg $dev1 $dev2 $dev3 $dev5:0 - lvchange -an $vg/$lv1 - lvconvert -m+1 $vg/$lv1 $dev4 - mimages_are_on_ $lv1 $dev1 $dev2 $dev3 $dev4 - mirrorlog_is_on_ $lv1 $dev5 - disable_dev $(rest_pvs_ $index 4) - vgreduce --removemissing --force $vg - lvs -a -o+devices $vg + lvcreate -l2 -m2 -n $lv1 $vg "$dev1" "$dev2" "$dev3" "$dev5":0 + lvchange -an $vg/$lv1 + lvconvert -m+1 $vg/$lv1 "$dev4" + check mirror_images_on $vg $lv1 "$dev1" "$dev2" "$dev3" "$dev4" + check mirror_log_on $vg $lv1 "$dev5" + lvs -a -o+devices $vg + aux disable_dev $(rest_pvs_ $index 4) + vgreduce --removemissing --force $vg + lvs -a -o+devices $vg eval local dev=\$dev$n - mimages_are_on_ $lv1 $dev || lv_is_on_ $lv1 $dev - not mirrorlog_is_on_ $lv1 $dev5 + check linear $vg $lv1 + check lv_on $vg $lv1 $dev } for n in $(seq 1 4); do @@ -261,21 +256,21 @@ test_2way_mirror_plus_2_fail_1_() { local index=$1 - lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev5:0 - lvchange -an $vg/$lv1 - lvconvert -m+2 $vg/$lv1 $dev3 $dev4 - mimages_are_on_ $lv1 $dev1 $dev2 $dev3 $dev4 - mirrorlog_is_on_ $lv1 $dev5 - eval disable_dev \$dev$n - vgreduce --removemissing --force $vg - lvs -a -o+devices $vg - mimages_are_on_ $lv1 $(rest_pvs_ $index 4) - mirrorlog_is_on_ $lv1 $dev5 + lvcreate -l2 -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev5":0 + lvchange -an $vg/$lv1 + lvconvert -m+2 $vg/$lv1 "$dev3" "$dev4" + mimages_are_on_ $lv1 "$dev1" "$dev2" "$dev3" "$dev4" + mirrorlog_is_on_ $lv1 "$dev5" + eval aux disable_dev \$dev$n + vgreduce --removemissing --force $vg + lvs -a -o+devices $vg + mimages_are_on_ $lv1 $(rest_pvs_ $index 4) + mirrorlog_is_on_ $lv1 "$dev5" } for n in $(seq 1 4); do - #COMM "fail mirror image $(($n - 1)) of 4-way (2 converting) mirrored LV" - prepare_lvs_ + #COMM "fail mirror image $(($n - 1)) of 4-way (2 converting) mirrored LV" + prepare_lvs_ test_2way_mirror_plus_2_fail_1_ $n eval recover_vg_ \$dev$n done @@ -289,17 +284,17 @@ test_2way_mirror_plus_2_fail_3_() { local index=$1 - lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev5:0 - lvchange -an $vg/$lv1 - lvconvert -m+2 $vg/$lv1 $dev3 $dev4 - mimages_are_on_ $lv1 $dev1 $dev2 $dev3 $dev4 - mirrorlog_is_on_ $lv1 $dev5 - disable_dev $(rest_pvs_ $index 4) - vgreduce --removemissing --force $vg - lvs -a -o+devices $vg + lvcreate -l2 -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev5":0 + lvchange -an $vg/$lv1 + lvconvert -m+2 $vg/$lv1 "$dev3" "$dev4" + mimages_are_on_ $lv1 "$dev1" "$dev2" "$dev3" "$dev4" + mirrorlog_is_on_ $lv1 "$dev5" + aux disable_dev $(rest_pvs_ $index 4) + vgreduce --removemissing --force $vg + lvs -a -o+devices $vg eval local dev=\$dev$n mimages_are_on_ $lv1 $dev || lv_is_on_ $lv1 $dev - not mirrorlog_is_on_ $lv1 $dev5 + not mirrorlog_is_on_ $lv1 "$dev5" } for n in $(seq 1 4); do @@ -312,110 +307,109 @@ done # --------------------------------------------------------------------- # log device is gone (flat mirror and stacked mirror) -#COMM "fail mirror log of 2-way mirrored LV" -prepare_lvs_ -lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev5:0 -lvchange -an $vg/$lv1 -mimages_are_on_ $lv1 $dev1 $dev2 -mirrorlog_is_on_ $lv1 $dev5 -disable_dev $dev5 -vgreduce --removemissing --force $vg -mimages_are_on_ $lv1 $dev1 $dev2 -not mirrorlog_is_on_ $lv1 $dev5 -recover_vg_ $dev5 - -#COMM "fail mirror log of 3-way (1 converting) mirrored LV" -prepare_lvs_ -lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev5:0 -lvchange -an $vg/$lv1 -lvconvert -m+1 $vg/$lv1 $dev3 -mimages_are_on_ $lv1 $dev1 $dev2 $dev3 -mirrorlog_is_on_ $lv1 $dev5 -disable_dev $dev5 -vgreduce --removemissing --force $vg -mimages_are_on_ $lv1 $dev1 $dev2 $dev3 -not mirrorlog_is_on_ $lv1 $dev5 -recover_vg_ $dev5 +#COMM "fail mirror log of 2-way mirrored LV" +prepare_lvs_ +lvcreate -l2 -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev5":0 +lvchange -an $vg/$lv1 +mimages_are_on_ $lv1 "$dev1" "$dev2" +mirrorlog_is_on_ $lv1 "$dev5" +aux disable_dev "$dev5" +vgreduce --removemissing --force $vg +mimages_are_on_ $lv1 "$dev1" "$dev2" +not mirrorlog_is_on_ $lv1 "$dev5" +recover_vg_ "$dev5" + +#COMM "fail mirror log of 3-way (1 converting) mirrored LV" +prepare_lvs_ +lvcreate -l2 -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev5":0 +lvchange -an $vg/$lv1 +lvconvert -m+1 $vg/$lv1 "$dev3" +mimages_are_on_ $lv1 "$dev1" "$dev2" "$dev3" +mirrorlog_is_on_ $lv1 "$dev5" +aux disable_dev "$dev5" +vgreduce --removemissing --force $vg +mimages_are_on_ $lv1 "$dev1" "$dev2" "$dev3" +not mirrorlog_is_on_ $lv1 "$dev5" +recover_vg_ "$dev5" # --------------------------------------------------------------------- # all images are gone (flat mirror and stacked mirror) #COMM "fail all mirror images of 2-way mirrored LV" -prepare_lvs_ -lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev5:0 -lvchange -an $vg/$lv1 -mimages_are_on_ $lv1 $dev1 $dev2 -mirrorlog_is_on_ $lv1 $dev5 -disable_dev $dev1 $dev2 -vgreduce --removemissing --force $vg +prepare_lvs_ +lvcreate -l2 -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev5":0 +lvchange -an $vg/$lv1 +mimages_are_on_ $lv1 "$dev1" "$dev2" +mirrorlog_is_on_ $lv1 "$dev5" +aux disable_dev "$dev1" "$dev2" +vgreduce --removemissing --force $vg not lvs $vg/$lv1 -recover_vg_ $dev1 $dev2 +recover_vg_ "$dev1" "$dev2" #COMM "fail all mirror images of 3-way (1 converting) mirrored LV" -prepare_lvs_ -lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev5:0 -lvchange -an $vg/$lv1 -lvconvert -m+1 $vg/$lv1 $dev3 -mimages_are_on_ $lv1 $dev1 $dev2 $dev3 -mirrorlog_is_on_ $lv1 $dev5 -disable_dev $dev1 $dev2 $dev3 -vgreduce --removemissing --force $vg +prepare_lvs_ +lvcreate -l2 -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev5":0 +lvchange -an $vg/$lv1 +lvconvert -m+1 $vg/$lv1 "$dev3" +mimages_are_on_ $lv1 "$dev1" "$dev2" "$dev3" +mirrorlog_is_on_ $lv1 "$dev5" +aux disable_dev "$dev1" "$dev2" "$dev3" +vgreduce --removemissing --force $vg not lvs $vg/$lv1 -recover_vg_ $dev1 $dev2 $dev3 +recover_vg_ "$dev1" "$dev2" "$dev3" # --------------------------------------------------------------------- # Multiple LVs #COMM "fail a mirror image of one of mirrored LV" -prepare_lvs_ -lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev5:0 -lvchange -an $vg/$lv1 -lvcreate -l2 -m1 -n $lv2 $vg $dev3 $dev4 $dev5:1 -lvchange -an $vg/$lv2 -mimages_are_on_ $lv1 $dev1 $dev2 -mimages_are_on_ $lv2 $dev3 $dev4 -mirrorlog_is_on_ $lv1 $dev5 -mirrorlog_is_on_ $lv2 $dev5 -disable_dev $dev2 -vgreduce --removemissing --force $vg -mimages_are_on_ $lv2 $dev3 $dev4 -mirrorlog_is_on_ $lv2 $dev5 -lv_is_linear_ $lv1 -lv_is_on_ $lv1 $dev1 -recover_vg_ $dev2 +prepare_lvs_ +lvcreate -l2 -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev5":0 +lvchange -an $vg/$lv1 +lvcreate -l2 -m1 -n $lv2 $vg "$dev3" "$dev4" "$dev5":1 +lvchange -an $vg/$lv2 +mimages_are_on_ $lv1 "$dev1" "$dev2" +mimages_are_on_ $lv2 "$dev3" "$dev4" +mirrorlog_is_on_ $lv1 "$dev5" +mirrorlog_is_on_ $lv2 "$dev5" +aux disable_dev "$dev2" +vgreduce --removemissing --force $vg +mimages_are_on_ $lv2 "$dev3" "$dev4" +mirrorlog_is_on_ $lv2 "$dev5" +lv_is_linear_ $lv1 +lv_is_on_ $lv1 "$dev1" +recover_vg_ "$dev2" #COMM "fail mirror images, one for each mirrored LV" -prepare_lvs_ -lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev5:0 -lvchange -an $vg/$lv1 -lvcreate -l2 -m1 -n $lv2 $vg $dev3 $dev4 $dev5:1 -lvchange -an $vg/$lv2 -mimages_are_on_ $lv1 $dev1 $dev2 -mimages_are_on_ $lv2 $dev3 $dev4 -mirrorlog_is_on_ $lv1 $dev5 -mirrorlog_is_on_ $lv2 $dev5 -disable_dev $dev2 -disable_dev $dev4 -vgreduce --removemissing --force $vg -lv_is_linear_ $lv1 -lv_is_on_ $lv1 $dev1 -lv_is_linear_ $lv2 -lv_is_on_ $lv2 $dev3 -recover_vg_ $dev2 $dev4 +prepare_lvs_ +lvcreate -l2 -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev5":0 +lvchange -an $vg/$lv1 +lvcreate -l2 -m1 -n $lv2 $vg "$dev3" "$dev4" "$dev5":1 +lvchange -an $vg/$lv2 +mimages_are_on_ $lv1 "$dev1" "$dev2" +mimages_are_on_ $lv2 "$dev3" "$dev4" +mirrorlog_is_on_ $lv1 "$dev5" +mirrorlog_is_on_ $lv2 "$dev5" +aux disable_dev "$dev2" +aux disable_dev "$dev4" +vgreduce --removemissing --force $vg +lv_is_linear_ $lv1 +lv_is_on_ $lv1 "$dev1" +lv_is_linear_ $lv2 +lv_is_on_ $lv2 "$dev3" +recover_vg_ "$dev2" "$dev4" # --------------------------------------------------------------------- # no failure #COMM "no failures" -prepare_lvs_ -lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev5:0 -lvchange -an $vg/$lv1 -mimages_are_on_ $lv1 $dev1 $dev2 -mirrorlog_is_on_ $lv1 $dev5 -vgreduce --removemissing --force $vg -mimages_are_on_ $lv1 $dev1 $dev2 -mirrorlog_is_on_ $lv1 $dev5 +prepare_lvs_ +lvcreate -l2 -m1 -n $lv1 $vg "$dev1" "$dev2" "$dev5":0 +lvchange -an $vg/$lv1 +mimages_are_on_ $lv1 "$dev1" "$dev2" +mirrorlog_is_on_ $lv1 "$dev5" +vgreduce --removemissing --force $vg +mimages_are_on_ $lv1 "$dev1" "$dev2" +mirrorlog_is_on_ $lv1 "$dev5" check_and_cleanup_lvs_ # --------------------------------------------------------------------- - diff --git a/test/shell/name-mangling.sh b/test/shell/name-mangling.sh new file mode 100644 index 0000000..5b92e60 --- /dev/null +++ b/test/shell/name-mangling.sh @@ -0,0 +1,231 @@ +#!/bin/sh +# Copyright (C) 2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +name_prefix=$RANDOM + +CHARACTER_WHITELIST="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789#+-.:=@_" +FAIL_MIXED_STR="contains mixed mangled and unmangled characters" +FAIL_MULTI_STR="seems to be mangled more than once" +FAIL_BLACK_STR="should be mangled but it contains blacklisted characters" +CORRECT_FORM_STR="name already in correct form" +RENAMING_STR="renaming to" + +function create_dm_dev() +{ + local mode=$1 + local name=$2; + + if [ $mode = "none" ]; then + # there's no mangling done - we must use --verifyudev here in + # case we're testing with udev so we have the nodes in place, + # udev would not create them - it can't handle unmangled names + verify_udev="--verifyudev" + else + verify_udev="" + fi + + dmsetup create "${name_prefix}$name" $verify_udev --manglename $mode --table "0 1 zero" +} + +function remove_dm_dev() +{ + local mode=$1 + local name=$2 + + if [ $mode = "none" ]; then + verify_udev="--verifyudev" + else + verify_udev="" + fi + + dmsetup remove $verify_udev --manglename $mode "${name_prefix}$name" +} + +function check_create_and_remove() +{ + local mode=$1 + local input_name=$2 + local dm_name=$3 + local r=0 + + if [ $mode = "none" ]; then + verify_udev="--verifyudev" + else + verify_udev="" + fi + + dmsetup create "${name_prefix}$input_name" $verify_udev --manglename $mode --table "0 1 zero" 2>err && \ + test -b "$DM_DEV_DIR/mapper/${name_prefix}$dm_name" && \ + dmsetup remove "${name_prefix}$input_name" $verify_udev --manglename $mode || r=1 + + if [ $dm_name = "FAIL_MIXED" ]; then + r=0 + grep "$FAILED_MIXED_STR" err || r=1 + elif [ $dm_name = "FAIL_MULTI" ]; then + r=0 + grep "$FAILED_MULTI_STR" err || r=1 + elif [ $dm_name = "FAIL_BLACK" ]; then + r=0 + grep "$FAILED_BLACK_STR" err || r=1 + fi + + return $r +} + +function check_dm_field() +{ + local mode=$1 + local dm_name="$2" + local field=$3 + local expected="$4" + + value=$(dmsetup info --rows --noheadings --manglename $mode -c -o $field "${DM_DEV_DIR}/mapper/${name_prefix}$dm_name" 2> err || true) + + if [ "$expected" = "FAIL_MIXED" ]; then + grep "$FAIL_MIXED_STR" err + elif [ "$expected" = "FAIL_MULTI" ]; then + grep "$FAIL_MULTI_STR" err + elif [ "$expected" = "FAIL_BLACK" ]; then + grep "$FAIL_BLACK_STR" err + else + test "$value" = "${name_prefix}$expected" + fi +} + +function check_expected_names() +{ + local mode=$1 + local dm_name="$2" + local r=0 + + create_dm_dev none "$dm_name" + + test -b "$DM_DEV_DIR/mapper/${name_prefix}$dm_name" && \ + check_dm_field none "$dm_name" name "$dm_name" && \ + check_dm_field $mode "$dm_name" name "$3" && \ + check_dm_field $mode "$dm_name" mangled_name "$4" && \ + check_dm_field $mode "$dm_name" unmangled_name "$5" || r=1 + + remove_dm_dev none "$dm_name" + + return $r +} + +function check_mangle_cmd() +{ + local mode=$1 + local dm_name="$2" + local expected="$3" + local rename_expected=0 + local r=0 + + create_dm_dev none "$dm_name" + + dmsetup mangle --manglename $mode "${name_prefix}$dm_name" 1>out 2>err || true; + + if [ "$expected" = "OK" ]; then + grep "$CORRECT_FORM_STR" out || r=1 + elif [ "$expected" = "FAIL_MIXED" ]; then + grep "$FAIL_MIXED_STR" err || r=1 + elif [ "$expected" = "FAIL_MULTI" ]; then + grep "$FAIL_MULTI_STR" err || r=1 + else + rename_expected=1 + grep -F "$RENAMING_STR ${name_prefix}$expected" out || r=1 + fi + + if [ $r = 0 -a $rename_expected = 1 ]; then + # successfuly renamed to expected name + remove_dm_dev none "$expected" + elif [ $r = 1 ]; then + # failed to rename to expected or renamed when it should not - find the new name + new_name=$(sed -e "s/.*: $RENAMING_STR //g" out) + # try to remove any of the form - falling back to less probable error scenario + dmsetup remove --verifyudev --manglename none "$new_name" || \ + remove_dm_dev none "$dm_name" || remove_dm_dev none "$expected" + else + # successfuly done nothing + remove_dm_dev none "$dm_name" + fi + + return $r +} + +# check dmsetup can process path where the last component is not equal dm name (rhbz #797322) +r=0 +create_dm_dev auto "abc" +ln -s ${DM_DEV_DIR}/mapper/${name_prefix}abc ${DM_DEV_DIR}/${name_prefix}xyz +dmsetup status ${DM_DEV_DIR}/${name_prefix}xyz || r=1 +remove_dm_dev auto "abc" +if [ r = 1 ]; then + exit 1 +fi + +### ALL WHITELISTED CHARACTERS ### +# none of these should be mangled in any mode +name="$CHARACTER_WHITELIST" +for mode in auto hex none; do + check_expected_names $mode "$name" "$name" "$name" "$name" + check_mangle_cmd $mode "$name" "OK" +done + + +#### NONE MANGLING MODE ### +check_create_and_remove none 'a b' 'a b' +check_create_and_remove none 'a\x20b' 'a\x20b' +check_create_and_remove none 'a b\x20c' 'a b\x20c' +check_create_and_remove none 'a\x5cx20b' 'a\x5cx20b' + +check_expected_names none 'a b' 'a b' 'a\x20b' 'a b' +check_expected_names none 'a\x20b' 'a\x20b' 'a\x20b' 'a b' +check_expected_names none 'a b\x20c' 'a b\x20c' 'FAIL_MIXED' 'a b c' +check_expected_names none 'a\x5cx20b' 'a\x5cx20b' 'a\x5cx20b' 'a\x20b' + +check_mangle_cmd none 'a b' 'OK' +check_mangle_cmd none 'a\x20b' 'a b' +check_mangle_cmd none 'a b\x20c' 'a b c' +check_mangle_cmd none 'a\x5cx20b' 'a\x20b' + + +### AUTO MANGLING MODE ### +check_create_and_remove auto 'a b' 'a\x20b' +check_create_and_remove auto 'a\x20b' 'a\x20b' +check_create_and_remove auto 'a b\x20c' 'FAIL_MIXED' +check_create_and_remove auto 'a\x5cx20b' 'FAIL_MULTI' + +check_expected_names auto 'a b' 'FAIL_BLACK' 'FAIL_BLACK' 'FAIL_BLACK' +check_expected_names auto 'a\x20b' 'a b' 'a\x20b' 'a b' +check_expected_names auto 'a b\x20c' 'FAIL_BLACK' 'FAIL_BLACK' 'FAIL_BLACK' +check_expected_names auto 'a\x5cx20b' 'FAIL_MULTI' 'FAIL_MULTI' 'FAIL_MULTI' + +check_mangle_cmd auto 'a b' 'a\x20b' +check_mangle_cmd auto 'a\x20b' 'OK' +check_mangle_cmd auto 'a b\x20c' 'FAIL_MIXED' +check_mangle_cmd auto 'a\x5cx20b' 'FAIL_MULTI' + + +### HEX MANGLING MODE ### +check_create_and_remove hex 'a b' 'a\x20b' +check_create_and_remove hex 'a\x20b' 'a\x5cx20b' +check_create_and_remove hex 'a b\x20c' 'a\x20b\x5cx20c' +check_create_and_remove hex 'a\x5cx20b' 'a\x5cx5cx20b' + +check_expected_names hex 'a b' 'FAIL_BLACK' 'FAIL_BLACK' 'FAIL_BLACK' +check_expected_names hex 'a\x20b' 'a b' 'a\x20b' 'a b' +check_expected_names hex 'a b\x20c' 'FAIL_BLACK' 'FAIL_BLACK' 'FAIL_BLACK' +check_expected_names hex 'a\x5cx20b' 'a\x20b' 'a\x5cx20b' 'a\x20b' + +check_mangle_cmd hex 'a b' 'a\x20b' +check_mangle_cmd hex 'a\x20b' 'OK' +check_mangle_cmd hex 'a b\x20c' 'FAIL_MIXED' +check_mangle_cmd hex 'a\x5cx20b' 'OK' diff --git a/test/t-nomda-missing.sh b/test/shell/nomda-missing.sh index fb0b882..2cf759e 100644 --- a/test/t-nomda-missing.sh +++ b/test/shell/nomda-missing.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Copyright (C) 2010 Red Hat, Inc. All rights reserved. # @@ -10,25 +10,25 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test -prepare_devs 4 -pvcreate $dev1 $dev2 -pvcreate --metadatacopies 0 $dev3 $dev4 -vgcreate -c n $vg $dev1 $dev2 $dev3 $dev4 +aux prepare_devs 4 +pvcreate "$dev1" "$dev2" +pvcreate --metadatacopies 0 "$dev3" "$dev4" +vgcreate -c n $vg "$dev1" "$dev2" "$dev3" "$dev4" -lvcreate -l1 -n linear1 $vg $dev1 -lvcreate -l1 -n linear2 $vg $dev2 -lvcreate -l2 -n linear12 $vg $dev1:4 $dev2:4 +lvcreate -l1 -n linear1 $vg "$dev1" +lvcreate -l1 -n linear2 $vg "$dev2" +lvcreate -l2 -n linear12 $vg "$dev1":4 "$dev2":4 -lvcreate -l1 -n origin1 $vg $dev1 -lvcreate -s $vg/origin1 -l1 -n s_napshot2 $dev2 +lvcreate -l1 -n origin1 $vg "$dev1" +lvcreate -s $vg/origin1 -l1 -n s_napshot2 "$dev2" -lvcreate -l1 -m1 -n mirror12 --mirrorlog core $vg $dev1 $dev2 -lvcreate -l1 -m1 -n mirror123 $vg $dev1 $dev2 $dev3 +lvcreate -l1 -m1 -n mirror12 --mirrorlog core $vg "$dev1" "$dev2" +lvcreate -l1 -m1 -n mirror123 $vg "$dev1" "$dev2" "$dev3" vgchange -a n $vg -disable_dev $dev1 +aux disable_dev "$dev1" not vgchange -a y $vg not vgck $vg @@ -41,8 +41,8 @@ check inactive $vg mirror12 check inactive $vg mirror123 vgchange -a n $vg -enable_dev $dev1 -disable_dev $dev2 +aux enable_dev "$dev1" +aux disable_dev "$dev2" not vgchange -a y $vg not vgck $vg @@ -55,8 +55,8 @@ check inactive $vg mirror12 check inactive $vg mirror123 vgchange -a n $vg -enable_dev $dev2 -disable_dev $dev3 +aux enable_dev "$dev2" +aux disable_dev "$dev3" not vgchange -a y $vg not vgck $vg @@ -69,8 +69,8 @@ check inactive $vg mirror123 check active $vg mirror12 vgchange -a n $vg -enable_dev $dev3 -disable_dev $dev4 +aux enable_dev "$dev3" +aux disable_dev "$dev4" vgchange -a y $vg not vgck $vg diff --git a/test/t-pool-labels.sh b/test/shell/pool-labels.sh index 57f4f9a..9d3fa03 100755..100644 --- a/test/t-pool-labels.sh +++ b/test/shell/pool-labels.sh @@ -1,3 +1,4 @@ +#!/bin/sh # Copyright (C) 2007 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -8,7 +9,9 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test + +env printf "" || skip # skip if printf is not available # create the old GFS pool labeled linear devices create_pool_label_() @@ -16,11 +19,11 @@ create_pool_label_() # FIXME # echo -e is bashism, dash builtin sh doesn't do \xNN in printf either # printf comes from coreutils, and is probably not posix either - env printf "\x01\x16\x70\x06\x5f\xcf\xff\xb9\xf8\x24\x8apool1" | dd of=$2 bs=5 seek=1 conv=notrunc + env printf "\x01\x16\x70\x06\x5f\xcf\xff\xb9\xf8\x24\x8apool1" | dd of="$2" bs=5 seek=1 conv=notrunc env printf "\x04\x01\x03\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x0$1\x68\x01\x16\x70\x00\x00\x00\x00\x00\x06\x5f\xd0" | dd of=$2 bs=273 seek=1 conv=notrunc + aux notify_lvmetad "$2" } -env printf "" || exit 200 # skip if printf is not available aux prepare_devs 2 @@ -32,7 +35,7 @@ not pvcreate "$dev1" # check that vgdisplay and pvcreate -ff works with the pool device vgdisplay --config 'global { locking_type = 0 }' -disable_dev "$dev2" +aux disable_dev "$dev2" # FIXME! since pool1 cannot be opened, vgdisplay gives error... should we say # "not" there instead, checking that it indeed does fail? vgdisplay --config 'global { locking_type = 0 }' || true diff --git a/test/shell/pv-duplicate.sh b/test/shell/pv-duplicate.sh new file mode 100644 index 0000000..6a22cd1 --- /dev/null +++ b/test/shell/pv-duplicate.sh @@ -0,0 +1,25 @@ +#!/bin/sh +# Copyright (C) 2011 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# 'Exercise duplicate metadata diagnostics' + +. lib/test + +aux prepare_devs 3 + +vgcreate -c n --metadatasize 128k $vg1 "$dev1" + +# copy mda +dd if="$dev1" of="$dev2" bs=256K count=1 +dd if="$dev1" of="$dev3" bs=256K count=1 + +pvs "$dev1" +vgs $vg1 diff --git a/test/shell/pv-min-size.sh b/test/shell/pv-min-size.sh new file mode 100644 index 0000000..59250cf --- /dev/null +++ b/test/shell/pv-min-size.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# Copyright (C) 2011 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +# use small default size - 512KB +aux lvmconf 'devices/pv_min_size = 512' + +aux prepare_pvs 1 8 + +check pv_field "$dev1" pv_name "$dev1" + +# increase min size beyond created PV size 10MB +aux lvmconf 'devices/pv_min_size = 10240' + +# and test device is not visible +not check pv_field "$dev1" pv_name "$dev1" + +# set too low value errornous value +aux lvmconf 'devices/pv_min_size = -100' + +# check the incorrect value is printed +pvs "$dev1" 2>&1 | grep -- -100 diff --git a/test/t-pv-range-overflow.sh b/test/shell/pv-range-overflow.sh index 04674cb..0f353dd 100755..100644 --- a/test/t-pv-range-overflow.sh +++ b/test/shell/pv-range-overflow.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2008 Red Hat, Inc. All rights reserved. +# Copyright (C) 2008-2011 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions @@ -11,7 +11,7 @@ # 'Ensure that pvmove diagnoses PE-range values 2^32 and larger.' -. ./test-utils.sh +. lib/test aux prepare_vg 2 @@ -20,13 +20,13 @@ lvcreate -L4 -n"$lv" $vg # Test for the bogus diagnostic reported in BZ 284771 # http://bugzilla.redhat.com/284771. # 'run pvmove with an unrecognized LV name to show bad diagnostic' -not pvmove -v -nbogus $dev1 $dev2 2> err -grep " Logical volume bogus not found." err +not pvmove -v -nbogus "$dev1" "$dev2" 2> err +grep "Logical volume bogus not found." err # With lvm-2.02.28 and earlier, on a system with 64-bit "long int", # the PE range parsing code would accept values up to 2^64-1, but would # silently truncate them to int32_t. I.e., $dev1:$(echo 2^32|bc) would be # treated just like $dev1:0. # 'run the offending pvmove command' -not pvmove -v -n$lv $dev1:4294967296 $dev2 +not pvmove -v -n$lv "$dev1":4294967296 "$dev2" diff --git a/test/shell/pvchange-usage.sh b/test/shell/pvchange-usage.sh new file mode 100644 index 0000000..d5a2ebb --- /dev/null +++ b/test/shell/pvchange-usage.sh @@ -0,0 +1,65 @@ +#!/bin/sh +# Copyright (C) 2008 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# 'Test pvchange option values' + +. lib/test + +aux prepare_devs 4 + +for mda in 0 1 2 +do +# "setup pv with metadatacopies = $mda" + pvcreate "$dev4" + pvcreate --metadatacopies $mda "$dev1" + vgcreate $vg1 "$dev1" "$dev4" + +# "pvchange adds/dels tag to pvs with metadatacopies = $mda " + pvchange "$dev1" --addtag test$mda + check pv_field "$dev1" pv_tags test$mda + pvchange "$dev1" --deltag test$mda + check pv_field "$dev1" pv_tags "" + +# "vgchange disable/enable allocation for pvs with metadatacopies = $mda (bz452982)" + pvchange "$dev1" -x n + check pv_field "$dev1" pv_attr --- + pvchange "$dev1" -x y + check pv_field "$dev1" pv_attr a-- + +# 'remove pv' + vgremove $vg1 + pvremove "$dev1" "$dev4" +done + +# "pvchange uuid" +pvcreate --metadatacopies 0 "$dev1" +pvcreate --metadatacopies 2 "$dev2" +vgcreate $vg1 "$dev1" "$dev2" +pvchange -u "$dev1" +pvchange -u "$dev2" +check pvlv_counts $vg1 2 0 0 +pvchange -u --all +check pvlv_counts $vg1 2 0 0 + +# "pvchange rejects uuid change under an active lv" +lvcreate -l 16 -i 2 -n $lv --alloc anywhere $vg1 +check pvlv_counts $vg1 2 1 0 +not pvchange -u "$dev1" +lvchange -an $vg1/$lv +pvchange -u "$dev1" + +# "cleanup" +lvremove -f $vg1/$lv +vgremove $vg1 + +# "pvchange reject --addtag to lvm1 pv" +pvcreate -M1 "$dev1" +not pvchange "$dev1" --addtag test diff --git a/test/t-pvcreate-metadata0.sh b/test/shell/pvcreate-metadata0.sh index 8447ce5..9154e75 100755..100644 --- a/test/t-pvcreate-metadata0.sh +++ b/test/shell/pvcreate-metadata0.sh @@ -15,7 +15,7 @@ # # 'Test pvcreate without metadata on all pvs' -. ./test-utils.sh +. lib/test aux prepare_devs 2 128 @@ -23,10 +23,10 @@ aux prepare_devs 2 128 pvcreate "$dev1" pvcreate --metadatacopies 0 "$dev2" -# "check lv snapshot" -vgcreate -c n "$vg" "$dev1" "$dev2" -lvcreate -n "$lv" -l 60%FREE "$vg" -lvcreate -s -n $lv2 -l 10%FREE "$vg"/"$lv" -pvdisplay +# "check lv snapshot" +vgcreate -c n $vg "$dev1" "$dev2" +lvcreate -n $lv -l 60%FREE $vg +lvcreate -s -n $lv2 -l 10%FREE $vg/$lv +pvdisplay lvdisplay -vgremove -f "$vg" +vgremove -f $vg diff --git a/test/t-pvcreate-operation-md.sh b/test/shell/pvcreate-operation-md.sh index cab63a0..9bdc4a1 100644 --- a/test/t-pvcreate-operation-md.sh +++ b/test/shell/pvcreate-operation-md.sh @@ -1,3 +1,4 @@ +#!/bin/sh # Copyright (C) 2009 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -8,19 +9,20 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +. lib/test + # skip this test if mdadm or sfdisk (or others) aren't available -which mdadm || exit 200 -which sfdisk || exit 200 -which perl || exit 200 -which awk || exit 200 -which cut || exit 200 +which mdadm || skip +which sfdisk || skip +which perl || skip +which awk || skip +which cut || skip test -f /proc/mdstat && grep -q raid0 /proc/mdstat || \ -modprobe raid0 || exit 200 - -. ./test-utils.sh + modprobe raid0 || skip -prepare_lvmconf '[ "a|/dev/md.*|", "a/dev\/mapper\/.*$/", "r/.*/" ]' +aux lvmconf 'devices/md_component_detection = 1' +aux lvmconf 'devices/filter = [ "a|/dev/md.*|", "a/dev\/mapper\/.*$/", "r/.*/" ]' aux prepare_devs 2 # Have MD use a non-standard name to avoid colliding with an existing MD device @@ -34,110 +36,114 @@ mdadm_maj=$(mdadm --version 2>&1 | perl -pi -e 's|.* v(\d+).*|\1|') cleanup_md() { # sleeps offer hack to defeat: 'md: md127 still in use' # see: https://bugzilla.redhat.com/show_bug.cgi?id=509908#c25 - sleep 2 - mdadm --stop $mddev || true + aux udev_wait + mdadm --stop "$mddev" || true + aux udev_wait if [ -b "$mddev" ]; then # mdadm doesn't always cleanup the device node sleep 2 - rm -f $mddev + rm -f "$mddev" fi } cleanup_md_and_teardown() { cleanup_md - teardown + aux teardown } # create 2 disk MD raid0 array (stripe_width=128K) -test -b "$mddev" && exit 200 -mdadm --create --metadata=1.0 $mddev --auto=md --level 0 --raid-devices=2 --chunk 64 $dev1 $dev2 -trap 'aux cleanup_md_and_teardown' EXIT # cleanup this MD device at the end of the test -test -b "$mddev" || exit 200 +test -b "$mddev" && skip +mdadm --create --metadata=1.0 "$mddev" --auto=md --level 0 --raid-devices=2 --chunk 64 "$dev1" "$dev2" +trap 'cleanup_md_and_teardown' EXIT # cleanup this MD device at the end of the test +test -b "$mddev" || skip # Test alignment of PV on MD without any MD-aware or topology-aware detection # - should treat $mddev just like any other block device pv_align="1.00m" pvcreate --metadatasize 128k \ --config 'devices {md_chunk_alignment=0 data_alignment_detection=0 data_alignment_offset_detection=0}' \ - $mddev -check_pv_field_ $mddev pe_start $pv_align + "$mddev" +check pv_field "$mddev" pe_start $pv_align # Test md_chunk_alignment independent of topology-aware detection pv_align="1.00m" pvcreate --metadatasize 128k \ --config 'devices {data_alignment_detection=0 data_alignment_offset_detection=0}' \ - $mddev -check_pv_field_ $mddev pe_start $pv_align + "$mddev" +check pv_field "$mddev" pe_start $pv_align -# Get linux minor version -linux_minor=$(echo `uname -r` | cut -d'.' -f3 | cut -d'-' -f1) # Test newer topology-aware alignment detection # - first added to 2.6.31 but not "reliable" until 2.6.33 -if [ $linux_minor -ge 33 ]; then +if kernel_at_least 2 6 33 ; then pv_align="1.00m" # optimal_io_size=131072, minimum_io_size=65536 pvcreate --metadatasize 128k \ - --config 'devices { md_chunk_alignment=0 }' $mddev - check_pv_field_ $mddev pe_start $pv_align + --config 'devices { md_chunk_alignment=0 }' "$mddev" + check pv_field "$mddev" pe_start $pv_align fi # partition MD array directly, depends on blkext in Linux >= 2.6.28 -if [ $linux_minor -ge 28 ]; then +if kernel_at_least 2 6 28 ; then # create one partition - sfdisk $mddev <<EOF + sfdisk "$mddev" <<EOF ,,83 EOF # make sure partition on MD is _not_ removed # - tests partition -> parent lookup via sysfs paths - not pvcreate --metadatasize 128k $mddev + not pvcreate --metadatasize 128k "$mddev" # verify alignment_offset is accounted for in pe_start # - topology infrastructure is available in Linux >= 2.6.31 # - also tests partition -> parent lookup via sysfs paths # Oh joy: need to lookup /sys/block/md127 rather than /sys/block/md_lvm_test0 - mddev_maj_min=$(ls -lL $mddev | awk '{ print $5 $6 }' | perl -pi -e 's|,|:|') + mddev_maj_min=$(ls -lL "$mddev" | awk '{ print $5 $6 }' | perl -pi -e 's|,|:|') mddev_p_sysfs_name=$(echo /sys/dev/block/${mddev_maj_min}/*p1) base_mddev_p=`basename $mddev_p_sysfs_name` mddev_p=/dev/${base_mddev_p} + # in case the system is running without devtmpfs /dev + # wait here for created device node on tmpfs + aux udev_wait "$mddev_p" + test -b "$mddev_p" || skip + # Checking for 'alignment_offset' in sysfs implies Linux >= 2.6.31 # but reliable alignment_offset support requires kernel.org Linux >= 2.6.33 sysfs_alignment_offset=/sys/dev/block/${mddev_maj_min}/${base_mddev_p}/alignment_offset - [ -f $sysfs_alignment_offset -a $linux_minor -ge 33 ] && \ + [ -f $sysfs_alignment_offset ] && kernel_at_least 2 6 33 && \ alignment_offset=`cat $sysfs_alignment_offset` || \ alignment_offset=0 - if [ $alignment_offset -gt 0 ]; then + if [ $alignment_offset -gt 0 ]; then # default alignment is 1M, add alignment_offset pv_align=$((1048576+$alignment_offset))B - pvcreate --metadatasize 128k $mddev_p - check_pv_field_ $mddev_p pe_start $pv_align "--units b" - pvremove $mddev_p + pvcreate --metadatasize 128k "$mddev_p" + check pv_field "$mddev_p" pe_start $pv_align --units b + pvremove "$mddev_p" fi fi # Test newer topology-aware alignment detection w/ --dataalignment override -if [ $linux_minor -ge 33 ]; then +if kernel_at_least 2 6 33 ; then cleanup_md - pvcreate -f $dev1 - pvcreate -f $dev2 + pvcreate -f "$dev1" + pvcreate -f "$dev2" # create 2 disk MD raid0 array (stripe_width=2M) - test -b "$mddev" && exit 200 - mdadm --create --metadata=1.0 $mddev --auto=md --level 0 --raid-devices=2 --chunk 1024 $dev1 $dev2 - test -b "$mddev" || exit 200 + test -b "$mddev" && skip + mdadm --create --metadata=1.0 "$mddev" --auto=md --level 0 --raid-devices=2 --chunk 1024 "$dev1" "$dev2" + test -b "$mddev" || skip # optimal_io_size=2097152, minimum_io_size=1048576 pv_align="2.00m" pvcreate --metadatasize 128k \ - --config 'devices { md_chunk_alignment=0 }' $mddev - check_pv_field_ $mddev pe_start $pv_align + --config 'devices { md_chunk_alignment=0 }' "$mddev" + check pv_field "$mddev" pe_start $pv_align # now verify pe_start alignment override using --dataalignment pv_align="192.00k" pvcreate --dataalignment 64k --metadatasize 128k \ - --config 'devices { md_chunk_alignment=0 }' $mddev - check_pv_field_ $mddev pe_start $pv_align + --config 'devices { md_chunk_alignment=0 }' "$mddev" + check pv_field "$mddev" pe_start $pv_align fi diff --git a/test/shell/pvcreate-operation.sh b/test/shell/pvcreate-operation.sh new file mode 100644 index 0000000..55fff4e --- /dev/null +++ b/test/shell/pvcreate-operation.sh @@ -0,0 +1,130 @@ +# Copyright (C) 2008 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +aux lvmconf 'devices/md_component_detection = 1' + +aux prepare_devs 4 + +for mdatype in 1 2 +do +# pvcreate (lvm$mdatype) refuses to overwrite an mounted filesystem (bz168330) + test ! -d mnt && mkdir mnt + if mke2fs "$dev1"; then + mount "$dev1" mnt + not pvcreate -M$mdatype "$dev1" 2>err + grep "Can't open "$dev1" exclusively. Mounted filesystem?" err + umount "$dev1" + fi + +# pvcreate (lvm$mdatype) succeeds when run repeatedly (pv not in a vg) (bz178216) + pvcreate -M$mdatype "$dev1" + pvcreate -M$mdatype "$dev1" + pvremove -f "$dev1" + +# pvcreate (lvm$mdatype) fails when PV belongs to VG +# pvcreate -M$mdatype "$dev1" + vgcreate -M$mdatype $vg1 "$dev1" + not pvcreate -M$mdatype "$dev1" + + vgremove -f $vg1 + pvremove -f "$dev1" + +# pvcreate (lvm$mdatype) fails when PV1 does and PV2 does not belong to VG + pvcreate -M$mdatype "$dev1" + pvcreate -M$mdatype "$dev2" + vgcreate -M$mdatype $vg1 "$dev1" + +# pvcreate a second time on $dev2 and $dev1 + not pvcreate -M$mdatype "$dev2" "$dev1" + + vgremove -f $vg1 + pvremove -f "$dev2" "$dev1" + +# NOTE: Force pvcreate after test completion to ensure clean device +#test_expect_success +# "pvcreate (lvm$mdatype) fails on md component device" +# 'mdadm -C -l raid0 -n 2 /dev/md0 "$dev1" "$dev2" && +# pvcreate -M$mdatype "$dev1"; +# status=$?; echo status=$status; test $status != 0 && +# mdadm --stop /dev/md0 && +# pvcreate -ff -y -M$mdatype "$dev1" "$dev2" && +# pvremove -f "$dev1" "$dev2"' +done + +# pvcreate (lvm2) fails without -ff when PV with metadatacopies=0 belongs to VG +pvcreate --metadatacopies 0 "$dev1" +pvcreate --metadatacopies 1 "$dev2" +vgcreate $vg1 "$dev1" "$dev2" +not pvcreate "$dev1" +vgremove -f $vg1 +pvremove -f "$dev2" "$dev1" + +# pvcreate (lvm2) succeeds with -ff when PV with metadatacopies=0 belongs to VG +pvcreate --metadatacopies 0 "$dev1" +pvcreate --metadatacopies 1 "$dev2" +vgcreate $vg1 "$dev1" "$dev2" +pvcreate -ff -y "$dev1" +vgreduce --removemissing $vg1 +vgremove -ff $vg1 +pvremove -f "$dev2" "$dev1" + +for i in 0 1 2 3 +do +# pvcreate (lvm2) succeeds writing LVM label at sector $i + pvcreate --labelsector $i "$dev1" + dd if="$dev1" bs=512 skip=$i count=1 2>/dev/null | strings | grep LABELONE >/dev/null + pvremove -f "$dev1" +done + +# pvcreate (lvm2) fails writing LVM label at sector 4 +not pvcreate --labelsector 4 "$dev1" + +backupfile=$PREFIX.mybackupfile +uuid1=freddy-fred-fred-fred-fred-fred-freddy +uuid2=freddy-fred-fred-fred-fred-fred-fredie +bogusuuid=fred + +# pvcreate rejects uuid option with less than 32 characters +not pvcreate --norestorefile --uuid $bogusuuid "$dev1" + +# pvcreate rejects uuid option without restorefile +not pvcreate --uuid $uuid1 "$dev1" + +# pvcreate rejects uuid already in use +pvcreate --norestorefile --uuid $uuid1 "$dev1" +not pvcreate --norestorefile --uuid $uuid1 "$dev2" + +# pvcreate rejects non-existent file given with restorefile +not pvcreate --uuid $uuid1 --restorefile $backupfile "$dev1" + +# pvcreate rejects restorefile with uuid not found in file +pvcreate --norestorefile --uuid $uuid1 "$dev1" +vgcfgbackup -f $backupfile +not pvcreate --uuid $uuid2 --restorefile $backupfile "$dev2" + +# vgcfgrestore of a VG containing a PV with zero PEs (bz #820116) +# (use case: one PV in a VG used solely to keep metadata) +size_mb=$(($(blockdev --getsz $dev1) / 2048)) +pvcreate --metadatasize $size_mb $dev1 +vgcreate $vg1 $dev1 +vgcfgbackup -f $backupfile +vgcfgrestore -f $backupfile $vg1 +vgremove -f $vg1 +pvremove -f $dev1 + +# pvcreate wipes swap signature when forced +dd if=/dev/zero of="$dev1" bs=1024 count=64 +mkswap "$dev1" +blkid -c /dev/null "$dev1" | grep "swap" +pvcreate -f "$dev1" +# blkid cannot make up its mind whether not finding anything it knows is a failure or not +(blkid -c /dev/null "$dev1" || true) | not grep "swap" diff --git a/test/t-pvcreate-usage.sh b/test/shell/pvcreate-usage.sh index 35dc1c0..148802f 100755..100644 --- a/test/t-pvcreate-usage.sh +++ b/test/shell/pvcreate-usage.sh @@ -12,64 +12,62 @@ test_description='Test pvcreate option values' PAGESIZE=$(getconf PAGESIZE) -. ./test-utils.sh +. lib/test aux prepare_devs 4 #COMM 'pvcreate rejects negative setphysicalvolumesize' -not pvcreate --setphysicalvolumesize -1024 $dev1 +not pvcreate --setphysicalvolumesize -1024 "$dev1" #COMM 'pvcreate rejects negative metadatasize' -not pvcreate --metadatasize -1024 $dev1 +not pvcreate --metadatasize -1024 "$dev1" # x. metadatasize 0, defaults to 255 # FIXME: unable to check default value, not in reporting cmds # should default to 255 according to code -# check_pv_field_ pv_mda_size 255 +# check pv_field pv_mda_size 255 #COMM 'pvcreate accepts metadatasize 0' -pvcreate --metadatasize 0 $dev1 -pvremove $dev1 +pvcreate --metadatasize 0 "$dev1" +pvremove "$dev1" #Verify vg_mda_size is smaller pv_mda_size -pvcreate --metadatasize 512k $dev1 -pvcreate --metadatasize 96k $dev2 -vgcreate $vg $dev1 $dev2 -compare_two_fields_ vgs $vg vg_mda_size pvs $dev2 pv_mda_size -vgremove -ff $vg +pvcreate --metadatasize 512k "$dev1" +pvcreate --metadatasize 96k "$dev2" +vgcreate $vg "$dev1" "$dev2" +check compare_fields vgs $vg vg_mda_size pvs "$dev2" pv_mda_size +vgremove $vg # x. metadatasize too large # For some reason we allow this, even though there's no room for data? ##COMM 'pvcreate rejects metadatasize too large' -#not pvcreate --metadatasize 100000000000000 $dev1 +#not pvcreate --metadatasize 100000000000000 "$dev1" #COMM 'pvcreate rejects metadatacopies < 0' -not pvcreate --metadatacopies -1 $dev1 +not pvcreate --metadatacopies -1 "$dev1" #COMM 'pvcreate accepts metadatacopies = 0, 1, 2' for j in metadatacopies pvmetadatacopies do -pvcreate --$j 0 $dev1 -pvcreate --$j 1 $dev2 -pvcreate --$j 2 $dev3 -check_pv_field_ $dev1 pv_mda_count 0 -check_pv_field_ $dev2 pv_mda_count 1 -check_pv_field_ $dev3 pv_mda_count 2 -pvremove $dev1 -pvremove $dev2 -pvremove $dev3 +pvcreate --$j 0 "$dev1" +pvcreate --$j 1 "$dev2" +pvcreate --$j 2 "$dev3" +check pv_field "$dev1" pv_mda_count 0 +check pv_field "$dev2" pv_mda_count 1 +check pv_field "$dev3" pv_mda_count 2 +pvremove "$dev1" "$dev2" "$dev3" done #COMM 'pvcreate rejects metadatacopies > 2' -not pvcreate --metadatacopies 3 $dev1 +not pvcreate --metadatacopies 3 "$dev1" #COMM 'pvcreate rejects invalid device' -not pvcreate $dev1bogus +not pvcreate "$dev1"bogus #COMM 'pvcreate rejects labelsector < 0' -not pvcreate --labelsector -1 $dev1 +not pvcreate --labelsector -1 "$dev1" #COMM 'pvcreate rejects labelsector > 1000000000000' -not pvcreate --labelsector 1000000000000 $dev1 +not pvcreate --labelsector 1000000000000 "$dev1" # other possibilites based on code inspection (not sure how hard) # x. device too small (min of 512 * 1024 KB) @@ -82,108 +80,107 @@ not pvcreate --labelsector 1000000000000 $dev1 # x. set size to value inconsistent with device / PE size #COMM 'pvcreate basic dataalignment sanity checks' -not pvcreate --dataalignment -1 $dev1 -not pvcreate -M 1 --dataalignment 1 $dev1 -not pvcreate --dataalignment 1e $dev1 +not pvcreate --dataalignment -1 "$dev1" +not pvcreate -M 1 --dataalignment 1 "$dev1" +not pvcreate --dataalignment 1e "$dev1" #COMM 'pvcreate always rounded up to page size for start of device' -#pvcreate --metadatacopies 0 --dataalignment 1 $dev1 +#pvcreate --metadatacopies 0 --dataalignment 1 "$dev1" # amuse shell experts -#check_pv_field_ $dev1 pe_start $(($(getconf PAGESIZE)/1024))".00k" +#check pv_field "$dev1" pe_start $(($(getconf PAGESIZE)/1024))".00k" #COMM 'pvcreate sets data offset directly' -pvcreate --dataalignment 512k $dev1 -check_pv_field_ $dev1 pe_start 512.00k +pvcreate --dataalignment 512k "$dev1" +check pv_field "$dev1" pe_start "512.00k" #COMM 'vgcreate/vgremove do not modify data offset of existing PV' -vgcreate $vg $dev1 --config 'devices { data_alignment = 1024 }' -check_pv_field_ $dev1 pe_start 512.00k +vgcreate $vg "$dev1" --config 'devices { data_alignment = 1024 }' +check pv_field "$dev1" pe_start "512.00k" vgremove $vg --config 'devices { data_alignment = 1024 }' -check_pv_field_ $dev1 pe_start 512.00k +check pv_field "$dev1" pe_start "512.00k" #COMM 'pvcreate sets data offset next to mda area' -pvcreate --metadatasize 100k --dataalignment 100k $dev1 -check_pv_field_ $dev1 pe_start 200.00k +pvcreate --metadatasize 100k --dataalignment 100k "$dev1" +check pv_field "$dev1" pe_start "200.00k" # metadata area start is aligned according to pagesize -# pagesize should be 64k or 4k ... -if [ $PAGESIZE -eq 65536 ] ; then - pv_align="192.50k" -else - pv_align="133.00k" -fi +case "$PAGESIZE" in + 65536) pv_align="192.50k" ;; + 8192) pv_align="136.50k" ;; + *) pv_align="133.00k" ;; +esac -pvcreate --metadatasize 128k --dataalignment 3.5k $dev1 -check_pv_field_ $dev1 pe_start $pv_align +pvcreate --metadatasize 128k --dataalignment 3.5k "$dev1" +check pv_field "$dev1" pe_start $pv_align -pvcreate --metadatasize 128k --metadatacopies 2 --dataalignment 3.5k $dev1 -check_pv_field_ $dev1 pe_start $pv_align +pvcreate --metadatasize 128k --metadatacopies 2 --dataalignment 3.5k "$dev1" +check pv_field "$dev1" pe_start $pv_align # data area is aligned to 1M by default, # data area start is shifted by the specified alignment_offset -pv_align="1052160B" # 1048576 + (7*512) -pvcreate --metadatasize 128k --dataalignmentoffset 7s $dev1 -check_pv_field_ $dev1 pe_start $pv_align "--units b" +pv_align=1052160B # 1048576 + (7*512) +pvcreate --metadatasize 128k --dataalignmentoffset 7s "$dev1" +check pv_field "$dev1" pe_start $pv_align --units b # 2nd metadata area is created without problems when # data area start is shifted by the specified alignment_offset -pvcreate --metadatasize 128k --metadatacopies 2 --dataalignmentoffset 7s $dev1 -check_pv_field_ $dev1 pv_mda_count 2 +pvcreate --metadatasize 128k --metadatacopies 2 --dataalignmentoffset 7s "$dev1" +check pv_field "$dev1" pv_mda_count 2 # FIXME: compare start of 2nd mda with and without --dataalignmentoffset #COMM 'pv with LVM1 compatible data alignment can be convereted' #compatible == LVM1_PE_ALIGN == 64k -pvcreate --dataalignment 256k $dev1 -vgcreate -s 1m $vg $dev1 +pvcreate --dataalignment 256k "$dev1" +vgcreate -s 1m $vg "$dev1" vgconvert -M1 $vg vgconvert -M2 $vg -check_pv_field_ $dev1 pe_start 256.00k +check pv_field "$dev1" pe_start 256.00k vgremove $vg #COMM 'pv with LVM1 incompatible data alignment cannot be convereted' -pvcreate --dataalignment 10k $dev1 -vgcreate -s 1m $vg $dev1 +pvcreate --dataalignment 10k "$dev1" +vgcreate -s 1m $vg "$dev1" not vgconvert -M1 $vg vgremove $vg #COMM 'vgcfgrestore allows pe_start=0' #basically it produces nonsense, but it tests vgcfgrestore, #not that final cfg is usable... -pvcreate --metadatacopies 0 $dev1 -pvcreate $dev2 -vgcreate $vg $dev1 $dev2 -vgcfgbackup -f "$(pwd)/backup.$$" $vg -sed 's/pe_start = [0-9]*/pe_start = 0/' "$(pwd)/backup.$$" > "$(pwd)/backup.$$1" -vgcfgrestore -f "$(pwd)/backup.$$1" $vg -check_pv_field_ $dev1 pe_start 0 -check_pv_field_ $dev2 pe_start 0 +pvcreate --metadatacopies 0 "$dev1" +pvcreate "$dev2" +vgcreate $vg "$dev1" "$dev2" +vgcfgbackup -f backup.$$ $vg +sed 's/pe_start = [0-9]*/pe_start = 0/' backup.$$ > backup.$$1 +vgcfgrestore -f backup.$$1 $vg +check pv_field "$dev1" pe_start "0" +check pv_field "$dev2" pe_start "0" vgremove $vg -echo test pvcreate --metadataignore +echo "test pvcreate --metadataignore" for pv_in_vg in 1 0; do for mdacp in 1 2; do for ignore in y n; do - echo pvcreate --metadataignore has proper mda_count and mda_used_count - pvcreate --metadatacopies $mdacp --metadataignore $ignore $dev1 $dev2 - check_pv_field_ $dev1 pv_mda_count $mdacp - check_pv_field_ $dev2 pv_mda_count $mdacp + echo "pvcreate --metadataignore has proper mda_count and mda_used_count" + pvcreate --metadatacopies $mdacp --metadataignore $ignore "$dev1" "$dev2" + check pv_field "$dev1" pv_mda_count "$mdacp" + check pv_field "$dev2" pv_mda_count "$mdacp" if [ $ignore = y ]; then - check_pv_field_ $dev1 pv_mda_used_count 0 - check_pv_field_ $dev2 pv_mda_used_count 0 + check pv_field "$dev1" pv_mda_used_count "0" + check pv_field "$dev2" pv_mda_used_count "0" else - check_pv_field_ $dev1 pv_mda_used_count $mdacp - check_pv_field_ $dev2 pv_mda_used_count $mdacp + check pv_field "$dev1" pv_mda_used_count "$mdacp" + check pv_field "$dev2" pv_mda_used_count "$mdacp" fi - echo vgcreate has proper vg_mda_count and vg_mda_used_count + echo "vgcreate has proper vg_mda_count and vg_mda_used_count" if [ $pv_in_vg = 1 ]; then - vgcreate -c n "$vg" $dev1 $dev2 - check_vg_field_ $vg vg_mda_count $(($mdacp * 2)) + vgcreate -c n $vg "$dev1" "$dev2" + check vg_field $vg vg_mda_count "$(($mdacp * 2))" if [ $ignore = y ]; then - check_vg_field_ $vg vg_mda_used_count 1 + check vg_field $vg vg_mda_used_count "1" else - check_vg_field_ $vg vg_mda_used_count $(($mdacp * 2)) + check vg_field $vg vg_mda_used_count "$(($mdacp * 2))" fi - check_vg_field_ $vg vg_mda_copies unmanaged + check vg_field $vg vg_mda_copies "unmanaged" vgremove $vg fi done diff --git a/test/shell/pvmove-basic.sh b/test/shell/pvmove-basic.sh new file mode 100644 index 0000000..e95fc36 --- /dev/null +++ b/test/shell/pvmove-basic.sh @@ -0,0 +1,383 @@ +#!/bin/sh +# Copyright (C) 2008-2012 Red Hat, Inc. All rights reserved. +# Copyright (C) 2007 NEC Corporation +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +test_description="ensure that pvmove works with basic options" + +. lib/test + +which mkfs.ext2 || skip +which md5sum || skip + +# --------------------------------------------------------------------- +# Utilities + +lvdev_() { + echo "$DM_DEV_DIR/$1/$2" +} + +lv_is_on_() { + local lv=$1 #allready vg/lv + shift 1 + lvs -a -odevices --noheadings $lv | sed 's/,/\n/g' > out +#is on all specified devs + for d in $*; do grep "$d(" out; done +#isn't on any other dev (we are set -e remember) + for d in $*; do ! grep -v "$d(" out; done + return 0 +} + +save_dev_sum_() { + mkfs.ext2 $1 > /dev/null && md5sum $1 > md5.$(basename $1) +} + +check_dev_sum_() { + md5sum -c md5.$(basename $1) +} + +create_vg_() { + vgcreate -c n -s 128k $vg $(cat DEVICES) +} +# --------------------------------------------------------------------- +# Initialize PVs and VGs + +#aux prepare_vg 5 30 +aux prepare_pvs 5 5 +create_vg_ + +# --------------------------------------------------------------------- +# Common environment setup/cleanup for each sub testcases +FIRST="" + +prepare_lvs_() { + lvcreate -l2 -n $lv1 $vg "$dev1" + test -z "$FIRST" && lv_is_on_ $vg/$lv1 "$dev1" + lvcreate -l9 -i3 -n $lv2 $vg "$dev2" "$dev3" "$dev4" + test -z "$FIRST" && lv_is_on_ $vg/$lv2 "$dev2" "$dev3" "$dev4" + lvextend -l+2 $vg/$lv1 "$dev2" + test -z "$FIRST" && lv_is_on_ $vg/$lv1 "$dev1" "$dev2" + lvextend -l+2 $vg/$lv1 "$dev3" + test -z "$FIRST" && lv_is_on_ $vg/$lv1 "$dev1" "$dev2" "$dev3" + lvextend -l+2 $vg/$lv1 "$dev1" + test -z "$FIRST" && lv_is_on_ $vg/$lv1 "$dev1" "$dev2" "$dev3" "$dev1" + lvcreate -l1 -n $lv3 $vg "$dev2" + test -z "$FIRST" && lv_is_on_ $vg/$lv3 "$dev2" + save_dev_sum_ $(lvdev_ $vg $lv1) + save_dev_sum_ $(lvdev_ $vg $lv2) + save_dev_sum_ $(lvdev_ $vg $lv3) + if test -z "$FIRST" ; then + get lv_field $vg/$lv1 devices > ${lv1}_devs + get lv_field $vg/$lv2 devices > ${lv2}_devs + get lv_field $vg/$lv3 devices > ${lv3}_devs + fi + FIRST=done +} + +lv_not_changed_() { + get lv_field $1 devices > out + diff $(basename $1)_devs out +} + +check_and_cleanup_lvs_() { + lvs -a -o+devices $vg + check_dev_sum_ $(lvdev_ $vg $lv1) + check_dev_sum_ $(lvdev_ $vg $lv2) + check_dev_sum_ $(lvdev_ $vg $lv3) + lvs -a -o name $vg > out && ! grep ^pvmove out + lvremove -ff $vg + (dm_table | not grep $vg) || \ + die "ERROR: lvremove did leave some some mappings in DM behind!" +} + +#COMM "check environment setup/cleanup" +prepare_lvs_ +check_and_cleanup_lvs_ + +# --------------------------------------------------------------------- +# pvmove tests + +# --- +# filter by LV + +#COMM "only specified LV is moved: from pv2 to pv5 only for lv1" +prepare_lvs_ +pvmove -i1 -n $vg/$lv1 "$dev2" "$dev5" +lv_is_on_ $vg/$lv1 "$dev1" "$dev5" "$dev3" "$dev1" +lv_not_changed_ $vg/$lv2 +lv_not_changed_ $vg/$lv3 +check_and_cleanup_lvs_ + +# --- +# segments in a LV + +#COMM "the 1st seg of 3-segs LV is moved: from pv1 of lv1 to pv4" +prepare_lvs_ +pvmove -i0 -n $vg/$lv1 "$dev1" "$dev4" +lv_is_on_ $vg/$lv1 "$dev4" "$dev2" "$dev3" "$dev4" +lv_not_changed_ $vg/$lv2 +lv_not_changed_ $vg/$lv3 +check_and_cleanup_lvs_ + +#COMM "the 2nd seg of 3-segs LV is moved: from pv2 of lv1 to pv4" +prepare_lvs_ +pvmove -i0 -n $vg/$lv1 "$dev2" "$dev4" +lv_is_on_ $vg/$lv1 "$dev1" "$dev4" "$dev3" "$dev1" +lv_not_changed_ $vg/$lv2 +lv_not_changed_ $vg/$lv3 +check_and_cleanup_lvs_ + +#COMM "the 3rd seg of 3-segs LV is moved: from pv3 of lv1 to pv4" +prepare_lvs_ +pvmove -i0 -n $vg/$lv1 "$dev3" "$dev4" +lv_is_on_ $vg/$lv1 "$dev1" "$dev2" "$dev4" "$dev1" +lv_not_changed_ $vg/$lv2 +lv_not_changed_ $vg/$lv3 +check_and_cleanup_lvs_ + +# --- +# multiple LVs matching + +#COMM "1 out of 3 LVs is moved: from pv4 to pv5" +prepare_lvs_ +pvmove -i0 "$dev4" "$dev5" +lv_not_changed_ $vg/$lv1 +lv_is_on_ $vg/$lv2 "$dev2" "$dev3" "$dev5" +lv_not_changed_ $vg/$lv3 +check_and_cleanup_lvs_ + +#COMM "2 out of 3 LVs are moved: from pv3 to pv5" +prepare_lvs_ +pvmove -i0 "$dev3" "$dev5" +lv_is_on_ $vg/$lv1 "$dev1" "$dev2" "$dev5" "$dev1" +lv_is_on_ $vg/$lv2 "$dev2" "$dev5" "$dev4" +lv_not_changed_ $vg/$lv3 +check_and_cleanup_lvs_ + +#COMM "3 out of 3 LVs are moved: from pv2 to pv5" +prepare_lvs_ +pvmove -i0 "$dev2" "$dev5" +lv_is_on_ $vg/$lv1 "$dev1" "$dev5" "$dev3" "$dev1" +lv_is_on_ $vg/$lv2 "$dev5" "$dev3" "$dev4" +lv_is_on_ $vg/$lv3 "$dev5" +check_and_cleanup_lvs_ + +# --- +# areas of striping + +#COMM "move the 1st stripe: from pv2 of lv2 to pv1" +prepare_lvs_ +pvmove -i0 -n $vg/$lv2 "$dev2" "$dev1" +lv_not_changed_ $vg/$lv1 +lv_is_on_ $vg/$lv2 "$dev1" "$dev3" "$dev4" +lv_not_changed_ $vg/$lv3 +check_and_cleanup_lvs_ + +#COMM "move the 2nd stripe: from pv3 of lv2 to pv1" +prepare_lvs_ +pvmove -i0 -n $vg/$lv2 "$dev3" "$dev1" +lv_not_changed_ $vg/$lv1 +lv_is_on_ $vg/$lv2 "$dev2" "$dev1" "$dev4" +lv_not_changed_ $vg/$lv3 +check_and_cleanup_lvs_ + +#COMM "move the 3rd stripe: from pv4 of lv2 to pv1" +prepare_lvs_ +pvmove -i0 -n $vg/$lv2 "$dev4" "$dev1" +lv_not_changed_ $vg/$lv1 +lv_is_on_ $vg/$lv2 "$dev2" "$dev3" "$dev1" +lv_not_changed_ $vg/$lv3 +check_and_cleanup_lvs_ + +# --- +# partial segment match (source segment splitted) + +#COMM "match to the start of segment:from pv2:0-0 to pv5" +prepare_lvs_ +pvmove -i0 "$dev2":0-0 "$dev5" +lv_not_changed_ $vg/$lv1 +lv_is_on_ $vg/$lv2 "$dev5" "$dev2" "$dev3" "$dev4" +lv_not_changed_ $vg/$lv3 +check_and_cleanup_lvs_ + +#COMM "match to the middle of segment: from pv2:1-1 to pv5" +prepare_lvs_ +pvmove -i0 "$dev2":1-1 "$dev5" +lv_not_changed_ $vg/$lv1 +lv_is_on_ $vg/$lv2 "$dev2" "$dev5" "$dev2" "$dev3" "$dev4" +lv_not_changed_ $vg/$lv3 +check_and_cleanup_lvs_ + +#COMM "match to the end of segment: from pv2:2-2 to pv5" +prepare_lvs_ +pvmove -i0 "$dev2":2-2 "$dev5" +lv_not_changed_ $vg/$lv1 +lv_is_on_ $vg/$lv2 "$dev2" "$dev5" "$dev3" "$dev4" +lv_not_changed_ $vg/$lv3 +check_and_cleanup_lvs_ + +# --- +# destination segment splitted + +#COMM "no destination split: from pv2:0-2 to pv5" +prepare_lvs_ +pvmove -i0 "$dev2":0-2 "$dev5" +lv_not_changed_ $vg/$lv1 +lv_is_on_ $vg/$lv2 "$dev5" "$dev3" "$dev4" +lv_not_changed_ $vg/$lv3 +check_and_cleanup_lvs_ + +#COMM "destination split into 2: from pv2:0-2 to pv5:5-5 and pv4:5-6" +prepare_lvs_ +pvmove -i0 --alloc anywhere "$dev2":0-2 "$dev5":5-5 "$dev4":5-6 +lv_not_changed_ $vg/$lv1 +lv_is_on_ $vg/$lv2 "$dev5" "$dev4" "$dev3" "$dev4" +lv_not_changed_ $vg/$lv3 +check_and_cleanup_lvs_ + +#COMM "destination split into 3: from pv2:0-2 to {pv3,4,5}:5-5" +prepare_lvs_ +pvmove -i0 --alloc anywhere "$dev2":0-2 "$dev3":5-5 "$dev4":5-5 "$dev5":5-5 +lv_not_changed_ $vg/$lv1 +lv_is_on_ $vg/$lv2 "$dev3" "$dev4" "$dev5" "$dev3" "$dev4" +lv_not_changed_ $vg/$lv3 +check_and_cleanup_lvs_ + +# --- +# alloc policy (anywhere, contiguous) with both success and failure cases + +#COMM "alloc normal on same PV for source and destination: from pv3:0-2 to pv3:5-7" +prepare_lvs_ +not pvmove -i0 "$dev3":0-2 "$dev3":5-7 +# "(cleanup previous test)" +lv_not_changed_ $vg/$lv1 +lv_not_changed_ $vg/$lv2 +lv_not_changed_ $vg/$lv3 +check_and_cleanup_lvs_ + +#COMM "alloc anywhere on same PV for source and destination: from pv3:0-2 to pv3:5-7" +prepare_lvs_ +pvmove -i0 --alloc anywhere "$dev3":0-2 "$dev3":5-7 +lv_not_changed_ $vg/$lv1 +lv_is_on_ $vg/$lv2 "$dev2" "$dev3" "$dev4" +lv_not_changed_ $vg/$lv3 +check_and_cleanup_lvs_ + +#COMM "alloc anywhere but better area available: from pv3:0-2 to pv3:5-7 or pv5:5-6,pv4:5-5" +prepare_lvs_ +pvmove -i0 --alloc anywhere "$dev3":0-2 "$dev3":5-7 "$dev5":5-6 "$dev4":5-5 +lv_not_changed_ $vg/$lv1 +#lv_is_on_ $vg/$lv2 "$dev2" "$dev5" "$dev4" "$dev4" +lv_not_changed_ $vg/$lv3 +check_and_cleanup_lvs_ + +#COMM "alloc contiguous but area not available: from pv2:0-2 to pv5:5-5 and pv4:5-6" +prepare_lvs_ +not pvmove -i0 --alloc contiguous "$dev2":0-2 "$dev5":5-5 "$dev4":5-6 +# "(cleanup previous test)" +lv_not_changed_ $vg/$lv1 +lv_not_changed_ $vg/$lv2 +lv_not_changed_ $vg/$lv3 +check_and_cleanup_lvs_ + +#COMM "alloc contiguous and contiguous area available: from pv2:0-2 to pv5:0-0,pv5:3-5 and pv4:5-6" +prepare_lvs_ +pvmove -i0 --alloc contiguous "$dev2":0-2 "$dev5":0-0 "$dev5":3-5 "$dev4":5-6 +lv_not_changed_ $vg/$lv1 +lv_is_on_ $vg/$lv2 "$dev5" "$dev3" "$dev4" +lv_not_changed_ $vg/$lv3 +check_and_cleanup_lvs_ + +# --- +# multiple segments in a LV + +#COMM "multiple source LVs: from pv3 to pv5" +prepare_lvs_ +pvmove -i0 "$dev3" "$dev5" +lv_is_on_ $vg/$lv1 "$dev1" "$dev2" "$dev5" +lv_is_on_ $vg/$lv2 "$dev2" "$dev5" "$dev4" +lv_not_changed_ $vg/$lv3 +check_and_cleanup_lvs_ + +# --- +# move inactive LV + +#COMM "move inactive LV: from pv2 to pv5" +prepare_lvs_ +lvchange -an $vg/$lv1 +lvchange -an $vg/$lv3 +pvmove -i0 "$dev2" "$dev5" +lv_is_on_ $vg/$lv1 "$dev1" "$dev5" "$dev3" +lv_is_on_ $vg/$lv2 "$dev5" "$dev3" "$dev4" +lv_is_on_ $vg/$lv3 "$dev5" +check_and_cleanup_lvs_ + +# --- +# other failure cases + +#COMM "no PEs to move: from pv3 to pv1" +prepare_lvs_ +pvmove -i0 "$dev3" "$dev1" +not pvmove -i0 "$dev3" "$dev1" +# "(cleanup previous test)" +lv_is_on_ $vg/$lv1 "$dev1" "$dev2" "$dev1" +lv_is_on_ $vg/$lv2 "$dev2" "$dev1" "$dev4" +lv_not_changed_ $vg/$lv3 +check_and_cleanup_lvs_ + +#COMM "no space available: from pv2:0-0 to pv1:0-0" +prepare_lvs_ +not pvmove -i0 "$dev2":0-0 "$dev1":0-0 +# "(cleanup previous test)" +lv_not_changed_ $vg/$lv1 +lv_not_changed_ $vg/$lv2 +lv_not_changed_ $vg/$lv3 +check_and_cleanup_lvs_ + +#COMM 'same source and destination: from pv1 to pv1' +prepare_lvs_ +not pvmove -i0 "$dev1" "$dev1" +#"(cleanup previous test)" +lv_not_changed_ $vg/$lv1 +lv_not_changed_ $vg/$lv2 +lv_not_changed_ $vg/$lv3 +check_and_cleanup_lvs_ + +#COMM "sum of specified destination PEs is large enough, but it includes source PEs and the free PEs are not enough" +prepare_lvs_ +not pvmove --alloc anywhere "$dev1":0-2 "$dev1":0-2 "$dev5":0-0 2> err +#"(cleanup previous test)" +grep "Insufficient free space" err +lv_not_changed_ $vg/$lv1 +lv_not_changed_ $vg/$lv2 +lv_not_changed_ $vg/$lv3 +check_and_cleanup_lvs_ + +# --------------------------------------------------------------------- + +#COMM "pvmove abort" +prepare_lvs_ +pvmove -i100 -b "$dev1" "$dev3" +pvmove --abort +check_and_cleanup_lvs_ + +#COMM "pvmove out of --metadatacopies 0 PV (bz252150)" +vgremove -ff $vg +pvcreate $(cat DEVICES) +pvcreate --metadatacopies 0 "$dev1" "$dev2" +create_vg_ +lvcreate -l4 -n $lv1 $vg "$dev1" +pvmove "$dev1" + +#COMM "pvmove fails activating mirror, properly restores state before pvmove" +dmsetup create $vg-pvmove0 --notable +not pvmove -i 1 "$dev2" +test $(dmsetup info --noheadings -c -o suspended $vg-$lv1) = "Active" +dmsetup remove $vg-pvmove0 diff --git a/test/t-pvremove-usage.sh b/test/shell/pvremove-usage.sh index 5b5700f..c6d724b 100755..100644 --- a/test/t-pvremove-usage.sh +++ b/test/shell/pvremove-usage.sh @@ -9,60 +9,60 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test aux prepare_devs 3 -pvcreate $dev1 -pvcreate --metadatacopies 0 $dev2 -pvcreate --metadatacopies 2 $dev3 -pvremove $dev2 +pvcreate "$dev1" +pvcreate --metadatacopies 0 "$dev2" +pvcreate --metadatacopies 2 "$dev3" +pvremove "$dev2" # failing, but still removing everything what can be removed # is somewhat odd as default, what do we have -f for? -pvs | not grep $dev2 -pvcreate --metadatacopies 0 $dev2 +pvs | not grep "$dev2" +pvcreate --metadatacopies 0 "$dev2" # check pvremove refuses to remove pv in a vg -vgcreate -c n $vg $dev1 $dev2 -not pvremove $dev2 $dev3 +vgcreate -c n $vg "$dev1" "$dev2" +not pvremove "$dev2" "$dev3" for mdacp in 0 1 2; do # check pvremove truly wipes the label (pvscan wont find) (---metadatacopies $mdacp) - pvcreate --metadatacopies $mdacp $dev3 - pvremove $dev3 + pvcreate --metadatacopies $mdacp "$dev3" + pvremove "$dev3" # try to remove agail - should fail cleanly - not pvremove $dev3 - pvscan | not grep $dev3 + not pvremove "$dev3" + pvscan | not grep "$dev3" # bz179473 refuse to wipe non-PV device without -f - not pvremove $dev3 - pvremove -f $dev3 + not pvremove "$dev3" + pvremove -f "$dev3" # reset setup vgremove -ff $vg - pvcreate --metadatacopies $mdacp $dev1 - pvcreate $dev2 - vgcreate $vg $dev1 $dev2 + pvcreate --metadatacopies $mdacp "$dev1" + pvcreate "$dev2" + vgcreate $vg "$dev1" "$dev2" # pvremove -f fails when pv in a vg (---metadatacopies $mdacp) - not pvremove -f $dev1 - pvs $dev1 + not pvremove -f "$dev1" + pvs "$dev1" # pvremove -ff fails without confirmation when pv in a vg (---metadatacopies $mdacp) - echo n | not pvremove -ff $dev1 + echo n | not pvremove -ff "$dev1" # pvremove -ff succeds with confirmation when pv in a vg (---metadatacopies $mdacp) - pvremove -ffy $dev1 - not pvs $dev1 + pvremove -ffy "$dev1" + not pvs "$dev1" vgreduce --removemissing $vg - pvcreate --metadatacopies $mdacp $dev1 - vgextend $vg $dev1 + pvcreate --metadatacopies $mdacp "$dev1" + vgextend $vg "$dev1" # pvremove -ff -y is sufficient when pv in a vg (---metadatacopies $mdacp)" ' - echo n | pvremove -ff -y $dev1 + pvremove -ff -y "$dev1" vgreduce --removemissing $vg - pvcreate --metadatacopies $mdacp $dev1 - vgextend $vg $dev1 + pvcreate --metadatacopies $mdacp "$dev1" + vgextend $vg "$dev1" done diff --git a/test/t-read-ahead.sh b/test/shell/read-ahead.sh index 6130561..8c8f42c 100755..100644 --- a/test/t-read-ahead.sh +++ b/test/shell/read-ahead.sh @@ -15,48 +15,35 @@ test_description='Test read-ahead functionality' -. ./test-utils.sh - - -get_lvs_() { - lvs --units s --nosuffix --noheadings -o $1 "$vg"/"$lv" -} - -check_lvs_() { - case $(get_lvs_ $1) in - *$2) true ;; - *) false ;; - esac -} +. lib/test aux prepare_vg 5 #COMM "test various read ahead settings (bz450922)" -lvcreate -n "$lv" -l 100%FREE -i5 -I256 "$vg" -ra="$(get_lvs_ lv_kernel_read_ahead)" -test "$(( ( $ra / 5 ) * 5 ))" -eq $ra -lvdisplay "$vg"/"$lv" -not lvchange -r auto "$vg"/"$lv" 2>&1 | grep auto -check_lvs_ lv_read_ahead auto -check_lvs_ lv_kernel_read_ahead 5120 -lvchange -r 640 "$vg/$lv" -check_lvs_ lv_read_ahead 640 -lvremove -ff "$vg" +lvcreate -l 100%FREE -i5 -I256 -n $lv $vg +ra=$(get lv_field $vg/$lv lv_kernel_read_ahead --units s --nosuffix) +test $(( ( $ra / 5 ) * 5 )) -eq $ra +not lvchange -r auto $vg/$lv 2>&1 | grep auto +check lv_field $vg/$lv lv_read_ahead auto +check lv_field $vg/$lv lv_kernel_read_ahead 5120 --units s --nosuffix +lvchange -r 640 $vg/$lv +check lv_field $vg/$lv lv_read_ahead 640 --units s --nosuffix +lvremove -ff $vg #COMM "read ahead is properly inherited from underlying PV" -blockdev --setra 768 $dev1 +blockdev --setra 768 "$dev1" vgscan -lvcreate -n $lv -L4m $vg $dev1 +lvcreate -n $lv -L4m $vg "$dev1" test $(blockdev --getra $DM_DEV_DIR/$vg/$lv) -eq 768 lvremove -ff $vg # Check default, active/inactive values for read_ahead / kernel_read_ahead lvcreate -n $lv -l 50%FREE $vg lvchange -an $vg/$lv -check_lv_field_ $vg/$lv lv_read_ahead auto -check_lv_field_ $vg/$lv lv_kernel_read_ahead -1 +check lv_field $vg/$lv lv_read_ahead auto +check lv_field $vg/$lv lv_kernel_read_ahead -1 lvchange -r 512 $vg/$lv lvchange -ay $vg/$lv -check_lv_field_ $vg/$lv lv_read_ahead 256.00k -check_lv_field_ $vg/$lv lv_kernel_read_ahead 256.00k +check lv_field $vg/$lv lv_read_ahead 256.00k +check lv_field $vg/$lv lv_kernel_read_ahead 256.00k lvremove -ff $vg diff --git a/test/shell/snapshot-autoumount-dmeventd.sh b/test/shell/snapshot-autoumount-dmeventd.sh new file mode 100644 index 0000000..3b4b711 --- /dev/null +++ b/test/shell/snapshot-autoumount-dmeventd.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# Copyright (C) 2010-2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# no automatic extensions please + +. lib/test + +which mkfs.ext2 || skip + +aux lvmconf "activation/snapshot_autoextend_percent = 0" \ + "activation/snapshot_autoextend_threshold = 100" + +aux prepare_dmeventd +aux prepare_vg 2 +mntdir="${PREFIX}mnt" + +lvcreate -l 8 -n base $vg +mkfs.ext2 "$DM_DEV_DIR/$vg/base" + +lvcreate -s -l 4 -n snap $vg/base +lvchange --monitor y $vg/snap + +mkdir "$mntdir" +mount "$DM_DEV_DIR/mapper/$vg-snap" "$mntdir" +mount +cat /proc/mounts | grep "$mntdir" +dd if=/dev/zero of="$mntdir/file$1" bs=1M count=16 +sync +#dmeventd only checks every 10 seconds :( +for i in {1..10}; do + cat /proc/mounts | grep "$mntdir" || break + sleep 1 +done + +cat /proc/mounts | not grep "$mntdir" + +vgremove -f $vg diff --git a/test/t-snapshot-merge.sh b/test/shell/snapshot-merge.sh index 72d96da..a42b6f8 100755..100644 --- a/test/t-snapshot-merge.sh +++ b/test/shell/snapshot-merge.sh @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2010 Red Hat, Inc. All rights reserved. +# Copyright (C) 2010-2012 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions @@ -8,14 +8,12 @@ # 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -set -xv -which mkfs.ext3 || exit 200 +. lib/test -. ./test-utils.sh +which mkfs.ext3 || skip -lvdev_() -{ +lvdev_() { echo "$DM_DEV_DIR/$1/$2" } @@ -23,16 +21,15 @@ snap_lv_name_() { echo ${1}_snap } -setup_merge() { +setup_merge_() { local VG_NAME=$1 local LV_NAME=$2 - local NUM_EXTRA_SNAPS="$3" - test -z "$NUM_EXTRA_SNAPS" && NUM_EXTRA_SNAPS=0 + local NUM_EXTRA_SNAPS=${3:-0} local BASE_SNAP_LV_NAME=$(snap_lv_name_ $LV_NAME) lvcreate -n $LV_NAME -l 50%FREE $VG_NAME lvcreate -s -n $BASE_SNAP_LV_NAME -l 20%FREE ${VG_NAME}/${LV_NAME} - mkfs.ext3 $(lvdev_ $VG_NAME $LV_NAME) + mkfs.ext3 "$(lvdev_ $VG_NAME $LV_NAME)" if [ $NUM_EXTRA_SNAPS -gt 0 ]; then for i in `seq 1 $NUM_EXTRA_SNAPS`; do @@ -42,13 +39,13 @@ setup_merge() { } aux prepare_vg 1 100 - +mkdir test_mnt # test full merge of a single LV -setup_merge $vg $lv1 +setup_merge_ $vg $lv1 # now that snapshot LV is created: test if snapshot-merge target is available -$(dmsetup targets | grep -q snapshot-merge) || exit 200 -lvs -a +aux target_at_least snapshot-merge 1 0 0 || skip + # make sure lvconvert --merge requires explicit LV listing not lvconvert --merge 2>err lvconvert --merge $vg/$(snap_lv_name_ $lv1) @@ -56,28 +53,27 @@ lvremove -f $vg/$lv1 # test that an actively merging snapshot may not be removed -setup_merge $vg $lv1 +setup_merge_ $vg $lv1 lvconvert -i+100 --merge --background $vg/$(snap_lv_name_ $lv1) not lvremove -f $vg/$(snap_lv_name_ $lv1) lvremove -f $vg/$lv1 # "onactivate merge" test -setup_merge $vg $lv1 -lvs -a -mkdir test_mnt -mount $(lvdev_ $vg $lv1) test_mnt +setup_merge_ $vg $lv1 +mount "$(lvdev_ $vg $lv1)" test_mnt lvconvert --merge $vg/$(snap_lv_name_ $lv1) # -- refresh LV while FS is still mounted (merge must not start), # verify 'snapshot-origin' target is still being used lvchange --refresh $vg/$lv1 umount test_mnt -rm -r test_mnt -dmsetup table ${vg}-${lv1} | grep -q " snapshot-origin " +dm_table $vg-$lv1 | grep " snapshot-origin " + # -- refresh LV to start merge (now that FS is unmounted), # an active merge uses the 'snapshot-merge' target lvchange --refresh $vg/$lv1 -dmsetup table ${vg}-${lv1} | grep -q " snapshot-merge " +# check whether it's still merging - or maybe got already merged (slow test) +dm_table $vg-$lv1 | grep " snapshot-merge " || dm_table $vg-$lv1 | grep " linear " # -- don't care if merge is still active; lvremove at this point # may test stopping an active merge lvremove -f $vg/$lv1 @@ -86,38 +82,33 @@ lvremove -f $vg/$lv1 # "onactivate merge" test # -- deactivate/remove after disallowed merge attempt, tests # to make sure preload of origin's metadata is _not_ performed -setup_merge $vg $lv1 -lvs -a -mkdir test_mnt -mount $(lvdev_ $vg $lv1) test_mnt +setup_merge_ $vg $lv1 +mount "$(lvdev_ $vg $lv1)" test_mnt lvconvert --merge $vg/$(snap_lv_name_ $lv1) # -- refresh LV while FS is still mounted (merge must not start), # verify 'snapshot-origin' target is still being used lvchange --refresh $vg/$lv1 umount test_mnt -rm -r test_mnt -dmsetup table ${vg}-${lv1} | grep -q " snapshot-origin " +dm_table $vg-$lv1 | grep " snapshot-origin " >/dev/null lvremove -f $vg/$lv1 # test multiple snapshot merge; tests copy out that is driven by merge -setup_merge $vg $lv1 1 -lvs -a +setup_merge_ $vg $lv1 1 lvconvert --merge $vg/$(snap_lv_name_ $lv1) lvremove -f $vg/$lv1 # test merging multiple snapshots that share the same tag -setup_merge $vg $lv1 -setup_merge $vg $lv2 -lvs -a +setup_merge_ $vg $lv1 +setup_merge_ $vg $lv2 lvchange --addtag this_is_a_test $vg/$(snap_lv_name_ $lv1) lvchange --addtag this_is_a_test $vg/$(snap_lv_name_ $lv2) lvconvert --merge @this_is_a_test -lvs | not grep $(snap_lv_name_ $lv1) -lvs | not grep $(snap_lv_name_ $lv2) -lvremove -f $vg/$lv1 -lvremove -f $vg/$lv2 +lvs $vg >out +not grep $(snap_lv_name_ $lv1) out +not grep $(snap_lv_name_ $lv2) out +lvremove -f $vg/$lv1 $vg/$lv2 # FIXME following tests would need to poll merge progress, via periodic lvs? # Background processes don't lend themselves to lvm testsuite... @@ -128,5 +119,4 @@ lvremove -f $vg/$lv2 # test: multiple onactivate merge - -vgremove -f "$vg" +vgremove -f $vg diff --git a/test/t-snapshots-of-mirrors.sh b/test/shell/snapshots-of-mirrors.sh index fbde102..183d3ac 100644 --- a/test/t-snapshots-of-mirrors.sh +++ b/test/shell/snapshots-of-mirrors.sh @@ -1,3 +1,4 @@ +#!/bin/sh # Copyright (C) 2010 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -8,12 +9,13 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test -prepare_vg 4 +aux prepare_vg 4 -# Create snapshot of a mirror origin +# Attempt to create snapshot of a mirror origin - should fail lvcreate -m 1 -L 10M -n lv $vg + lvcreate -s $vg/lv -L 10M -n snap # Down-convert (mirror -> linear) under a snapshot @@ -40,5 +42,5 @@ lvconvert --mirrorlog core $vg/lv # Log conversion (core -> disk) lvconvert --mirrorlog disk $vg/lv -# Clean-up -lvremove -ff $vg +## Clean-up +vgremove -f $vg diff --git a/test/t-tags.sh b/test/shell/tags.sh index 906181c..6c35fc3 100755..100644 --- a/test/t-tags.sh +++ b/test/shell/tags.sh @@ -1,4 +1,5 @@ -# Copyright (C) 2008 Red Hat, Inc. All rights reserved. +#!/bin/sh +# Copyright (C) 2008-2012 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions @@ -8,21 +9,20 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test -aux prepare_pvs 5 +aux prepare_pvs 4 # vgcreate with --addtag -vgcreate -c n --addtag firstvg $vg1 $dev1 $dev2 -vgcreate -c n --addtag secondvg $vg2 $dev3 $dev4 -check_vg_field_ $vg1 tags firstvg -check_vg_field_ $vg2 tags secondvg -vgremove -ff $vg1 -vgremove -ff $vg2 +vgcreate -c n --addtag firstvg $vg1 "$dev1" "$dev2" +vgcreate -c n --addtag secondvg $vg2 "$dev3" "$dev4" +check vg_field $vg1 tags "firstvg" +check vg_field $vg2 tags "secondvg" +vgremove -f $vg1 $vg2 # vgchange with --addtag and --deltag -vgcreate -c n $vg1 $dev1 $dev2 -vgcreate -c n $vg2 $dev3 $dev4 +vgcreate -c n $vg1 "$dev1" "$dev2" +vgcreate -c n $vg2 "$dev3" "$dev4" vgchange --addtag firstvgtag1 $vg1 # adding a tag multiple times is not an error vgchange --addtag firstvgtag2 $vg1 @@ -31,28 +31,27 @@ vgchange --addtag firstvgtag3 $vg1 vgchange --addtag secondvgtag1 $vg2 vgchange --addtag secondvgtag2 $vg2 vgchange --addtag secondvgtag3 $vg2 -check_vg_field_ @firstvgtag2 tags "firstvgtag1,firstvgtag2,firstvgtag3" -check_vg_field_ @secondvgtag1 tags "secondvgtag1,secondvgtag2,secondvgtag3" +check vg_field @firstvgtag2 tags "firstvgtag1,firstvgtag2,firstvgtag3" +check vg_field @secondvgtag1 tags "secondvgtag1,secondvgtag2,secondvgtag3" vgchange --deltag firstvgtag2 $vg1 -check_vg_field_ @firstvgtag1 tags "firstvgtag1,firstvgtag3" +check vg_field @firstvgtag1 tags "firstvgtag1,firstvgtag3" # deleting a tag multiple times is not an error vgchange --deltag firstvgtag2 $vg1 vgchange --deltag firstvgtag1 $vg2 -vgremove -ff $vg1 -vgremove -ff $vg2 +vgremove -f $vg1 $vg2 # lvcreate with --addtag -vgcreate -c n $vg1 $dev1 $dev2 +vgcreate -c n $vg1 "$dev1" "$dev2" lvcreate --addtag firstlvtag1 -l 4 -n $lv1 $vg1 lvcreate --addtag secondlvtag1 -l 4 -n $lv2 $vg1 -check_lv_field_ @firstlvtag1 tags "firstlvtag1" -not check_lv_field_ @secondlvtag1 tags "firstlvtag1" -check_lv_field_ $vg1/$lv2 tags "secondlvtag1" -not check_lv_field_ $vg1/$lv1 tags "secondlvtag1" -vgremove -ff $vg1 +check lv_field @firstlvtag1 tags "firstlvtag1" +not check lv_field @secondlvtag1 tags "firstlvtag1" +check lv_field $vg1/$lv2 tags "secondlvtag1" +not check lv_field $vg1/$lv1 tags "secondlvtag1" +vgremove -f $vg1 # lvchange with --addtag and --deltag -vgcreate -c n $vg1 $dev1 $dev2 +vgcreate -c n $vg1 "$dev1" "$dev2" lvcreate -l 4 -n $lv1 $vg1 lvcreate -l 4 -n $lv2 $vg1 lvchange --addtag firstlvtag1 $vg1/$lv1 @@ -63,12 +62,12 @@ lvchange --addtag firstlvtag3 $vg1/$lv1 lvchange --addtag secondlvtag1 $vg1/$lv2 lvchange --addtag secondlvtag2 $vg1/$lv2 lvchange --addtag secondlvtag3 $vg1/$lv2 -check_lv_field_ $vg1/$lv1 tags "firstlvtag1,firstlvtag2,firstlvtag3" -not $(check_lv_field_ $vg1/$lv1 tags "secondlvtag1") -check_lv_field_ $vg1/$lv2 tags "secondlvtag1,secondlvtag2,secondlvtag3" -not $(check_lv_field_ $vg1/$lv1 tags "secondlvtag1") +check lv_field $vg1/$lv1 tags "firstlvtag1,firstlvtag2,firstlvtag3" +not check lv_field $vg1/$lv1 tags "secondlvtag1" +check lv_field $vg1/$lv2 tags "secondlvtag1,secondlvtag2,secondlvtag3" +not check lv_field $vg1/$lv1 tags "secondlvtag1" # deleting a tag multiple times is not an error lvchange --deltag firstlvtag2 $vg1/$lv1 lvchange --deltag firstlvtag2 $vg1/$lv1 -check_lv_field_ $vg1/$lv1 tags "firstlvtag1,firstlvtag3" -check_lv_field_ $vg1/$lv2 tags "secondlvtag1,secondlvtag2,secondlvtag3" +check lv_field $vg1/$lv1 tags "firstlvtag1,firstlvtag3" +check lv_field $vg1/$lv2 tags "secondlvtag1,secondlvtag2,secondlvtag3" diff --git a/test/t-test-partition.sh b/test/shell/test-partition.sh index 45a0aba..f7e91b8 100644 --- a/test/t-test-partition.sh +++ b/test/shell/test-partition.sh @@ -14,17 +14,18 @@ # excercises partition table scanning code path # -which sfdisk || exit 200 LVM_TEST_CONFIG_DEVICES="types = [\"device-mapper\", 142]" -. ./test-utils.sh +. lib/test + +which sfdisk || skip aux prepare_pvs 1 30 -pvs +pvs "$dev1" # create small partition table -echo "1 2" | sfdisk $dev1 +echo "1 2" | sfdisk "$dev1" -pvs +pvs "$dev1" diff --git a/test/shell/thin-autoumount-dmeventd.sh b/test/shell/thin-autoumount-dmeventd.sh new file mode 100644 index 0000000..bbffe8a --- /dev/null +++ b/test/shell/thin-autoumount-dmeventd.sh @@ -0,0 +1,70 @@ +#!/bin/bash +# Copyright (C) 2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# no automatic extensions, just umount + +is_dir_mounted_() +{ + cat /proc/mounts | sed 's:\\040: :g' | grep "$1" +} + +. lib/test + +# +# Main +# +which mkfs.ext2 || skip + +aux have_thin 1 0 0 || skip + +aux prepare_dmeventd + +aux lvmconf "activation/thin_pool_autoextend_percent = 0" \ + "activation/thin_pool_autoextend_threshold = 70" + +aux prepare_vg 2 + +mntdir="${PREFIX}mnt with space" +mntusedir="${PREFIX}mntuse" + +lvcreate -L8M -V8M -n $lv1 -T $vg/pool +lvcreate -V8M -n $lv2 -T $vg/pool + +mkfs.ext2 "$DM_DEV_DIR/$vg/$lv1" +mkfs.ext2 "$DM_DEV_DIR/$vg/$lv2" + +lvchange --monitor y $vg/pool + +mkdir "$mntdir" "$mntusedir" +mount "$DM_DEV_DIR/mapper/$vg-$lv1" "$mntdir" +mount "$DM_DEV_DIR/mapper/$vg-$lv2" "$mntusedir" + +is_dir_mounted_ "$mntdir" + +# fill above 70% +dd if=/dev/zero of="$mntdir/file$$" bs=1M count=6 +touch "$mntusedir/file$$" +tail -f "$mntusedir/file$$" & +PID_TAIL=$! +sync +lvs -a $vg +sleep 12 # dmeventd only checks every 10 seconds :( + +lvs -a $vg +# both dirs should be unmounted +not is_dir_mounted "$mntdir" +not is_dir_mounted "$mntusedir" + +# running tail keeps the block device still in use +kill $PID_TAIL +lvs -a $vg + +vgremove -f $vg diff --git a/test/t-topology-support.sh b/test/shell/topology-support.sh index b25ed7e..e952dc0 100644 --- a/test/t-topology-support.sh +++ b/test/shell/topology-support.sh @@ -1,3 +1,4 @@ +#!/bin/sh # Copyright (C) 2010 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -8,45 +9,36 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -which mkfs.ext3 || exit 200 +. lib/test -# Get linux minor version -linux_minor=$(echo `uname -r` | cut -d'.' -f3 | cut -d'-' -f1) +which mkfs.ext3 || skip -test $linux_minor -ge 31 || exit 200 - -. ./test-utils.sh - -check_logical_block_size() -{ - local DEV_=$1 - local LOGICAL_BS=$2 +check_logical_block_size() { + local DEV_=$(cat SCSI_DEBUG_DEV) # Verify logical_block_size - requires Linux >= 2.6.31 - SYSFS_LOGICAL_BLOCK_SIZE=`echo /sys/block/$(basename $DEV_)/queue/logical_block_size` + SYSFS_LOGICAL_BLOCK_SIZE=$(echo /sys/block/$(basename $DEV_)/queue/logical_block_size) if [ -f "$SYSFS_LOGICAL_BLOCK_SIZE" ] ; then - ACTUAL_LOGICAL_BLOCK_SIZE=`cat $SYSFS_LOGICAL_BLOCK_SIZE` - test $ACTUAL_LOGICAL_BLOCK_SIZE = $LOGICAL_BS + ACTUAL_LOGICAL_BLOCK_SIZE=$(cat $SYSFS_LOGICAL_BLOCK_SIZE) + test $ACTUAL_LOGICAL_BLOCK_SIZE = $1 fi } -lvdev_() -{ +lvdev_() { echo "$DM_DEV_DIR/$1/$2" } -test_snapshot_mount() -{ - lvcreate -L 16M -n $lv1 $vg $dev1 +test_snapshot_mount() { + lvcreate -L 16M -n $lv1 $vg "$dev1" mkfs.ext3 $(lvdev_ $vg $lv1) mkdir test_mnt - mount $(lvdev_ $vg $lv1) test_mnt + mount "$(lvdev_ $vg $lv1)" test_mnt lvcreate -L 16M -n $lv2 -s $vg/$lv1 umount test_mnt # mount the origin - mount $(lvdev_ $vg $lv1) test_mnt + mount "$(lvdev_ $vg $lv1)" test_mnt umount test_mnt # mount the snapshot - mount $(lvdev_ $vg $lv2) test_mnt + mount "$(lvdev_ $vg $lv2)" test_mnt umount test_mnt rm -r test_mnt vgchange -an $vg @@ -60,45 +52,54 @@ NUM_DEVS=1 PER_DEV_SIZE=34 DEV_SIZE=$(($NUM_DEVS*$PER_DEV_SIZE)) +# Test that kernel supports topology +aux prepare_scsi_debug_dev $DEV_SIZE || skip + +if [ ! -e /sys/block/$(basename $(cat SCSI_DEBUG_DEV))/alignment_offset ] ; then + aux cleanup_scsi_debug_dev + skip +fi +aux cleanup_scsi_debug_dev + # --------------------------------------------- # Create "desktop-class" 4K drive # (logical_block_size=512, physical_block_size=4096, alignment_offset=0): LOGICAL_BLOCK_SIZE=512 -prepare_scsi_debug_dev $DEV_SIZE \ +aux prepare_scsi_debug_dev $DEV_SIZE \ sector_size=$LOGICAL_BLOCK_SIZE physblk_exp=3 -check_logical_block_size $SCSI_DEBUG_DEV $LOGICAL_BLOCK_SIZE +check_logical_block_size $LOGICAL_BLOCK_SIZE aux prepare_pvs $NUM_DEVS $PER_DEV_SIZE -vgcreate -c n $vg $devs +vgcreate -c n $vg $(cat DEVICES) test_snapshot_mount vgremove $vg -cleanup_scsi_debug_dev +aux cleanup_scsi_debug_dev # --------------------------------------------- # Create "desktop-class" 4K drive w/ 63-sector DOS partition compensation # (logical_block_size=512, physical_block_size=4096, alignment_offset=3584): LOGICAL_BLOCK_SIZE=512 -prepare_scsi_debug_dev $DEV_SIZE \ +aux prepare_scsi_debug_dev $DEV_SIZE \ sector_size=$LOGICAL_BLOCK_SIZE physblk_exp=3 lowest_aligned=7 -check_logical_block_size $SCSI_DEBUG_DEV $LOGICAL_BLOCK_SIZE +check_logical_block_size $LOGICAL_BLOCK_SIZE aux prepare_pvs $NUM_DEVS $PER_DEV_SIZE -vgcreate -c n $vg $devs +vgcreate -c n $vg $(cat DEVICES) test_snapshot_mount vgremove $vg -cleanup_scsi_debug_dev +aux cleanup_scsi_debug_dev # --------------------------------------------- # Create "enterprise-class" 4K drive # (logical_block_size=4096, physical_block_size=4096, alignment_offset=0): LOGICAL_BLOCK_SIZE=4096 -prepare_scsi_debug_dev $DEV_SIZE \ +aux prepare_scsi_debug_dev $DEV_SIZE \ sector_size=$LOGICAL_BLOCK_SIZE -check_logical_block_size $SCSI_DEBUG_DEV $LOGICAL_BLOCK_SIZE +check_logical_block_size $LOGICAL_BLOCK_SIZE aux prepare_pvs $NUM_DEVS $PER_DEV_SIZE -vgcreate -c n $vg $devs +vgcreate -c n $vg $(cat DEVICES) test_snapshot_mount vgremove $vg diff --git a/test/t-unknown-segment.sh b/test/shell/unknown-segment.sh index 74a2710..d6071a1 100644 --- a/test/t-unknown-segment.sh +++ b/test/shell/unknown-segment.sh @@ -9,7 +9,7 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test aux prepare_vg 4 diff --git a/test/t-unlost-pv.sh b/test/shell/unlost-pv.sh index 7a120fb..962fe22 100644 --- a/test/t-unlost-pv.sh +++ b/test/shell/unlost-pv.sh @@ -9,30 +9,36 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test + +check_() { + # vgscan needs --cache option for direct scan if lvmetad is used + test -e LOCAL_LVMETAD && cache="--cache" + vgscan $cache 2>&1 | tee vgscan.out + $1 grep "Inconsistent metadata found for VG $vg" vgscan.out +} aux prepare_vg 3 lvcreate -m 1 -l 1 -n mirror $vg -lvchange -a n $vg/mirror - -check() { -vgscan 2>&1 | tee vgscan.out -grep "Inconsistent metadata found for VG $vg" vgscan.out -vgscan 2>&1 | tee vgscan.out -not grep "Inconsistent metadata found for VG $vg" vgscan.out -} +lvchange -a n $vg # try orphaning a missing PV (bz45867) -disable_dev $dev1 +aux disable_dev "$dev1" vgreduce --removemissing --force $vg -enable_dev $dev1 -check +aux enable_dev "$dev1" + +check_ +test -e LOCAL_LVMETAD && pvcreate -f "$dev1" +check_ not # try to just change metadata; we expect the new version (with MISSING_PV set # on the reappeared volume) to be written out to the previously missing PV -vgextend $vg $dev1 -disable_dev $dev1 +vgextend $vg "$dev1" +lvcreate -l 1 -n boo -a n --zero n $vg +aux disable_dev "$dev1" lvremove $vg/mirror -enable_dev $dev1 -check +aux enable_dev "$dev1" +check_ +test -e LOCAL_LVMETAD && lvremove $vg/boo # FIXME trigger a write :-( +check_ not diff --git a/test/t-vgcfgbackup-usage.sh b/test/shell/vgcfgbackup-usage.sh index 72b37bb..c8245b0 100644 --- a/test/t-vgcfgbackup-usage.sh +++ b/test/shell/vgcfgbackup-usage.sh @@ -9,36 +9,35 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test aux prepare_pvs 4 # vgcfgbackup handles similar VG names (bz458941) vg1=${PREFIX}vg00 vg2=${PREFIX}vg01 -vgcreate $vg1 $dev1 -vgcreate $vg2 $dev2 +vgcreate $vg1 "$dev1" +vgcreate $vg2 "$dev2" vgcfgbackup -f $TESTDIR/bak-%s >out grep "Volume group \"$vg1\" successfully backed up." out grep "Volume group \"$vg2\" successfully backed up." out -vgremove -ff $vg1 -vgremove -ff $vg2 +vgremove -ff $vg1 $vg2 # vgcfgbackup correctly stores metadata with missing PVs # and vgcfgrestore able to restore them when device reappears -pv1_uuid=$(pvs --noheadings -o pv_uuid $dev1) -pv2_uuid=$(pvs --noheadings -o pv_uuid $dev2) -vgcreate $vg $devs -lvcreate -l1 -n $lv1 $vg $dev1 -lvcreate -l1 -n $lv2 $vg $dev2 -lvcreate -l1 -n $lv3 $vg $dev3 +pv1_uuid=$(get pv_field "$dev1" pv_uuid) +pv2_uuid=$(get pv_field "$dev2" pv_uuid) +vgcreate $vg $(cat DEVICES) +lvcreate -l1 -n $lv1 $vg "$dev1" +lvcreate -l1 -n $lv2 $vg "$dev2" +lvcreate -l1 -n $lv3 $vg "$dev3" vgchange -a n $vg -pvcreate -ff -y $dev1 -pvcreate -ff -y $dev2 +pvcreate -ff -y "$dev1" +pvcreate -ff -y "$dev2" vgcfgbackup -f "$(pwd)/backup.$$" $vg sed 's/flags = \[\"MISSING\"\]/flags = \[\]/' "$(pwd)/backup.$$" > "$(pwd)/backup.$$1" -pvcreate -ff -y --norestorefile -u $pv1_uuid $dev1 -pvcreate -ff -y --norestorefile -u $pv2_uuid $dev2 +pvcreate -ff -y --norestorefile -u $pv1_uuid "$dev1" +pvcreate -ff -y --norestorefile -u $pv2_uuid "$dev2" vgcfgrestore -f "$(pwd)/backup.$$1" $vg vgremove -ff $vg @@ -46,9 +45,9 @@ vgremove -ff $vg # FIXME: clvmd seems to have problem with metadata format change here # fix it and remove this vgscan vgscan -pvcreate -M1 $devs -vgcreate -M1 -c n $vg $devs -lvcreate -l1 -n $lv1 $vg $dev1 -pvremove -ff -y $dev2 -not lvcreate -l1 -n $lv1 $vg $dev3 +pvcreate -M1 $(cat DEVICES) +vgcreate -M1 -c n $vg $(cat DEVICES) +lvcreate -l1 -n $lv1 $vg "$dev1" +pvremove -ff -y "$dev2" +not lvcreate -l1 -n $lv1 $vg "$dev3" vgcfgbackup -f "$(pwd)/backup.$$" $vg diff --git a/test/t-vgchange-maxlv.sh b/test/shell/vgchange-maxlv.sh index 0148315..413fef9 100644 --- a/test/t-vgchange-maxlv.sh +++ b/test/shell/vgchange-maxlv.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Copyright (C) 2010 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -9,19 +9,18 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test -prepare_dmeventd +aux prepare_dmeventd aux prepare_pvs 3 -vgcreate -c n -l 2 $vg $dev1 $dev2 $dev3 +vgcreate -c n -l 2 $vg $(cat DEVICES) lvcreate -n one -l 1 $vg lvcreate -n two -l 1 $vg not lvcreate -n three -l 1 $vg -vgchange -an $vg vgremove -ff $vg -vgcreate -c n -l 3 $vg $dev1 $dev2 $dev3 +vgcreate -c n -l 3 $vg $(cat DEVICES) lvcreate -n one -l 1 $vg lvcreate -n snap -s -l 1 $vg/one lvcreate -n two -l 1 $vg diff --git a/test/shell/vgchange-partial.sh b/test/shell/vgchange-partial.sh new file mode 100644 index 0000000..5b21a40 --- /dev/null +++ b/test/shell/vgchange-partial.sh @@ -0,0 +1,52 @@ +#!/bin/bash +# Copyright (C) 2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +aux prepare_vg 2 + +aux disable_dev "$dev1" + +# +# Test for allowable metadata changes +# addtag_ARG +# deltag_ARG +vgchange --addtag foo $vg +vgchange --deltag foo $vg + +# +# Test for disallowed metadata changes +# +# maxphysicalvolumes_ARG +not vgchange -p 10 $vg + +# resizeable_ARG +not vgchange -x n $vg + +# uuid_ARG +not vgchange -u $vg + +# physicalextentsize_ARG +not vgchange -s 2M $vg + +# clustered_ARG +not vgchange -c y $vg + +# alloc_ARG +not vgchange --alloc anywhere $vg + +# vgmetadatacopies_ARG +not vgchange --vgmetadatacopies 2 $vg + +# +# Ensure that allowed args don't cause disallowed args to get through +# +not vgchange -p 10 --addtag foo $vg diff --git a/test/shell/vgchange-sysinit.sh b/test/shell/vgchange-sysinit.sh new file mode 100644 index 0000000..d7a166c --- /dev/null +++ b/test/shell/vgchange-sysinit.sh @@ -0,0 +1,51 @@ +#!/bin/sh +# Copyright (C) 2011 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +which mkfs.ext3 || skip + +aux prepare_pvs 2 8 +test -e LOCAL_CLVMD && skip + +var_lock="$DM_DEV_DIR/$vg1/$lv1" +# keep in sync with aux configured lockingdir +mount_dir="var/lock/lvm" + +cleanup_mounted_and_teardown() +{ + umount "$mount_dir" || true + aux teardown +} + +vgcreate -c n $vg1 "$dev1" +vgcreate -c n $vg2 "$dev2" + +lvcreate -l 1 -n $lv2 $vg2 +vgchange -an $vg2 + +lvcreate -n $lv1 -l 100%FREE $vg1 +mkfs.ext3 -b4096 -j "$var_lock" + +trap 'cleanup_mounted_and_teardown' EXIT +mount -n -r "$var_lock" "$mount_dir" + +# locking must fail on read-only filesystem +not vgchange -ay $vg2 + +# no-locking with --sysinit +vgchange --sysinit -ay $vg2 +test -b "$DM_DEV_DIR/$vg2/$lv2" + +vgchange --sysinit -an $vg2 +test ! -b "$DM_DEV_DIR/$vg2/$lv2" + +vgchange --ignorelockingfailure -ay $vg2 diff --git a/test/t-vgchange-usage.sh b/test/shell/vgchange-usage.sh index 4baaab3..a7bd488 100644 --- a/test/t-vgchange-usage.sh +++ b/test/shell/vgchange-usage.sh @@ -11,34 +11,34 @@ test_description='Exercise some vgchange diagnostics' -. ./test-utils.sh +. lib/test aux prepare_pvs 3 -pvcreate --metadatacopies 0 $dev1 -vgcreate $vg $devs +pvcreate --metadatacopies 0 "$dev1" +vgcreate $vg $(cat DEVICES) vgdisplay $vg # vgchange -p MaxPhysicalVolumes (bz202232) -aux check_vg_field_ $vg max_pv 0 +aux check vg_field $vg max_pv 0 vgchange -p 128 $vg -aux check_vg_field_ $vg max_pv 128 +aux check vg_field $vg max_pv 128 -pv_count=$(get_vg_field $vg pv_count) +pv_count=$(get vg_field $vg pv_count) not vgchange -p 2 $vg 2>err grep "MaxPhysicalVolumes is less than the current number $pv_count of PVs for" err -aux check_vg_field_ $vg max_pv 128 +aux check vg_field $vg max_pv 128 # vgchange -l MaxLogicalVolumes -aux check_vg_field_ $vg max_lv 0 +aux check vg_field $vg max_lv 0 vgchange -l 128 $vg -aux check_vg_field_ $vg max_lv 128 +aux check vg_field $vg max_lv 128 -lvcreate -l4 -n$lv1 $vg -lvcreate -l4 -n$lv2 $vg +lvcreate -l4 -n $lv1 $vg +lvcreate -l4 -n $lv2 $vg -lv_count=$(get_vg_field $vg lv_count) +lv_count=$(get vg_field $vg lv_count) not vgchange -l 1 $vg 2>err grep "MaxLogicalVolume is less than the current number $lv_count of LVs for" err -aux check_vg_field_ $vg max_lv 128 +aux check vg_field $vg max_lv 128 diff --git a/test/shell/vgcreate-usage.sh b/test/shell/vgcreate-usage.sh new file mode 100644 index 0000000..db80f0f --- /dev/null +++ b/test/shell/vgcreate-usage.sh @@ -0,0 +1,163 @@ +#!/bin/sh +# Copyright (C) 2008-2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +test_description='Exercise some vgcreate diagnostics' + +. lib/test + +aux prepare_devs 3 +pvcreate "$dev1" "$dev2" +pvcreate --metadatacopies 0 "$dev3" + +vg=${PREFIX}vg + +#COMM 'vgcreate accepts 8.00m physicalextentsize for VG' +vgcreate -c n $vg --physicalextentsize 8.00m "$dev1" "$dev2" +check vg_field $vg vg_extent_size 8.00m +vgremove $vg +# try vgck and to remove it again - should fail (but not segfault) +not vgremove $vg +not vgck $vg + +#COMM 'vgcreate accepts smaller (128) maxlogicalvolumes for VG' +vgcreate -c n $vg --maxlogicalvolumes 128 "$dev1" "$dev2" +check vg_field $vg max_lv 128 +vgremove $vg + +#COMM 'vgcreate accepts smaller (128) maxphysicalvolumes for VG' +vgcreate -c n $vg --maxphysicalvolumes 128 "$dev1" "$dev2" +check vg_field $vg max_pv 128 +vgremove $vg + +#COMM 'vgcreate rejects a zero physical extent size' +not vgcreate -c n --physicalextentsize 0 $vg "$dev1" "$dev2" 2>err +grep "Physical extent size may not be zero" err + +#COMM 'vgcreate rejects "inherit" allocation policy' +not vgcreate -c n --alloc inherit $vg "$dev1" "$dev2" 2>err +grep "Volume Group allocation policy cannot inherit from anything" err + +#COMM 'vgcreate rejects vgname "."' +vginvalid=.; +not vgcreate -c n $vginvalid "$dev1" "$dev2" 2>err +grep "New volume group name \"$vginvalid\" is invalid" err + +#COMM 'vgcreate rejects vgname greater than 128 characters' +vginvalid=thisnameisridiculouslylongtotestvalidationcodecheckingmaximumsizethisiswhathappenswhenprogrammersgetboredandorarenotcreativedonttrythisathome +not vgcreate -c n $vginvalid "$dev1" "$dev2" 2>err +grep "New volume group name \"$vginvalid\" is invalid" err + +#COMM 'vgcreate rejects already existing vgname "/tmp/$vg"' +#touch /tmp/$vg +#not vgcreate $vg "$dev1" "$dev2" 2>err +#grep "New volume group name \"$vg\" is invalid\$" err + +#COMM "vgcreate rejects repeated invocation (run 2 times) (bz178216)" +vgcreate -c n $vg "$dev1" "$dev2" +not vgcreate -c n $vg "$dev1" "$dev2" +vgremove -ff $vg + +#COMM 'vgcreate rejects MaxLogicalVolumes > 255' +not vgcreate -c n --metadatatype 1 --maxlogicalvolumes 1024 $vg "$dev1" "$dev2" 2>err +grep "Number of volumes may not exceed 255" err + +#COMM "vgcreate fails when the only pv has --metadatacopies 0" +not vgcreate -c n $vg "$dev3" + +# Test default (4MB) vg_extent_size as well as limits of extent_size +not vgcreate -c n --physicalextentsize 0k $vg "$dev1" "$dev2" +vgcreate -c n --physicalextentsize 1k $vg "$dev1" "$dev2" +check vg_field $vg vg_extent_size 1.00k +vgremove -ff $vg +not vgcreate -c n --physicalextentsize 3K $vg "$dev1" "$dev2" +not vgcreate -c n --physicalextentsize 1024t $vg "$dev1" "$dev2" +#not vgcreate --physicalextentsize 1T $vg "$dev1" "$dev2" +# FIXME: vgcreate allows physicalextentsize larger than pv size! + +# Test default max_lv, max_pv, extent_size, alloc_policy, clustered +vgcreate -c n $vg "$dev1" "$dev2" +check vg_field $vg vg_extent_size 4.00m +check vg_field $vg max_lv 0 +check vg_field $vg max_pv 0 +check vg_field $vg vg_attr "wz--n-" +vgremove -ff $vg + +# Implicit pvcreate tests, test pvcreate options on vgcreate +# --force, --yes, --metadata{size|copies|type}, --zero +# --dataalignment[offset] +pvremove "$dev1" "$dev2" +vgcreate -c n --force --yes --zero y $vg "$dev1" "$dev2" +vgremove -f $vg +pvremove -f "$dev1" + +for i in 0 1 2 3 +do +# vgcreate (lvm2) succeeds writing LVM label at sector $i + vgcreate -c n --labelsector $i $vg "$dev1" + dd if="$dev1" bs=512 skip=$i count=1 2>/dev/null | strings | grep LABELONE >/dev/null + vgremove -f $vg + pvremove -f "$dev1" +done + +# pvmetadatacopies +for i in 1 2 +do + vgcreate -c n --pvmetadatacopies $i $vg "$dev1" + check pv_field "$dev1" pv_mda_count $i + vgremove -f $vg + pvremove -f "$dev1" +done +not vgcreate -c n --pvmetadatacopies 0 $vg "$dev1" +pvcreate --metadatacopies 1 "$dev2" +vgcreate -c n --pvmetadatacopies 0 $vg "$dev1" "$dev2" +check pv_field "$dev1" pv_mda_count 0 +check pv_field "$dev2" pv_mda_count 1 +vgremove -f $vg +pvremove -f "$dev1" + +# metadatasize, dataalignment, dataalignmentoffset +#COMM 'pvcreate sets data offset next to mda area' +vgcreate -c n --metadatasize 100k --dataalignment 100k $vg "$dev1" +check pv_field "$dev1" pe_start 200.00k +vgremove -f $vg +pvremove -f "$dev1" + +# data area is aligned to 1M by default, +# data area start is shifted by the specified alignment_offset +pv_align=1052160 # 1048576 + (7*512) +vgcreate -c n --metadatasize 128k --dataalignmentoffset 7s $vg "$dev1" +check pv_field "$dev1" pe_start ${pv_align}B --units b +vgremove -f $vg +pvremove -f "$dev1" + +# metadatatype +for i in 1 2 +do + vgcreate -c n -M $i $vg "$dev1" + check vg_field $vg vg_fmt lvm$i + vgremove -f $vg + pvremove -f "$dev1" +done + +# vgcreate fails if pv belongs to existing vg +vgcreate -c n $vg1 "$dev1" "$dev2" +not vgcreate $vg2 "$dev2" +vgremove -f $vg1 +pvremove -f "$dev1" "$dev2" + +# all PVs exist in the VG after created +pvcreate "$dev1" +vgcreate -c n $vg1 "$dev1" "$dev2" "$dev3" +check pv_field "$dev1" vg_name $vg1 +check pv_field "$dev2" vg_name $vg1 +check pv_field "$dev3" vg_name $vg1 +vgremove -f $vg1 +pvremove -f "$dev1" "$dev2" "$dev3" diff --git a/test/t-vgextend-restoremissing.sh b/test/shell/vgextend-restoremissing.sh index 87ff954..fae68e4 100644 --- a/test/t-vgextend-restoremissing.sh +++ b/test/shell/vgextend-restoremissing.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Copyright (C) 2010 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -9,22 +9,22 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh - +. lib/test aux prepare_vg 3 + lvcreate -m 1 -l 1 -n mirror $vg lvchange -a n $vg/mirror -lvcreate -l 1 -n lv1 $vg $dev1 +lvcreate -l 1 -n lv1 $vg "$dev1" # try to just change metadata; we expect the new version (with MISSING_PV set # on the reappeared volume) to be written out to the previously missing PV -disable_dev $dev1 +aux disable_dev "$dev1" lvremove $vg/mirror -enable_dev $dev1 +aux enable_dev "$dev1" not vgck $vg 2>&1 | tee log grep "missing 1 physical volume" log not lvcreate -m 1 -l 1 -n mirror $vg # write operations fail -vgextend --restore $vg $dev1 # restore the missing device +vgextend --restore $vg "$dev1" # restore the missing device vgck $vg lvcreate -m 1 -l 1 -n mirror $vg diff --git a/test/shell/vgextend-usage.sh b/test/shell/vgextend-usage.sh new file mode 100644 index 0000000..0e347c3 --- /dev/null +++ b/test/shell/vgextend-usage.sh @@ -0,0 +1,130 @@ +#!/bin/sh +# Copyright (C) 2008 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# +# Exercise various vgextend commands +# + +. lib/test + +aux prepare_devs 5 + +for mdatype in 1 2 +do + +# Explicit pvcreate +pvcreate -M$mdatype "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" +vgcreate -M$mdatype $vg1 "$dev1" "$dev2" +vgextend $vg1 "$dev3" "$dev4" "$dev5" +vgremove -ff $vg1 + +# Implicit pvcreate +pvremove "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" +vgcreate -M$mdatype $vg1 "$dev1" "$dev2" +vgextend -M$mdatype $vg1 "$dev3" "$dev4" "$dev5" +vgremove -ff $vg1 +pvremove "$dev1" "$dev2" "$dev3" "$dev4" "$dev5" + +done + +# Implicit pvcreate tests, test pvcreate options on vgcreate +# --force, --yes, --metadata{size|copies|type}, --zero +# --dataalignment[offset] +vgcreate $vg "$dev2" +vgextend --force --yes --zero y $vg "$dev1" +vgreduce $vg "$dev1" +pvremove -f "$dev1" + +for i in 0 1 2 3 +do +# vgcreate (lvm2) succeeds writing LVM label at sector $i + vgextend --labelsector $i $vg "$dev1" + dd if="$dev1" bs=512 skip=$i count=1 2>/dev/null | strings | grep LABELONE >/dev/null + vgreduce $vg "$dev1" + pvremove -f "$dev1" +done + +# pvmetadatacopies +for i in 0 1 2 +do + vgextend --pvmetadatacopies $i $vg "$dev1" + check pv_field "$dev1" pv_mda_count $i + vgreduce $vg "$dev1" + pvremove -f "$dev1" +done + +# metadatasize, dataalignment, dataalignmentoffset +#COMM 'pvcreate sets data offset next to mda area' +vgextend --metadatasize 100k --dataalignment 100k $vg "$dev1" +check pv_field "$dev1" pe_start 200.00k +vgreduce $vg "$dev1" +pvremove -f "$dev1" + +# data area is aligned to 1M by default, +# data area start is shifted by the specified alignment_offset +pv_align=1052160B # 1048576 + (7*512) +vgextend --metadatasize 128k --dataalignmentoffset 7s $vg "$dev1" +check pv_field "$dev1" pe_start $pv_align --units b +vgremove -f $vg +pvremove -f "$dev1" + +# vgextend fails if pv belongs to existing vg +vgcreate $vg1 "$dev1" "$dev3" +vgcreate $vg2 "$dev2" +not vgextend $vg2 "$dev3" +vgremove -f $vg1 +vgremove -f $vg2 +pvremove -f "$dev1" "$dev2" "$dev3" + +#vgextend fails if vg is not resizeable +vgcreate $vg1 "$dev1" "$dev2" +vgchange --resizeable n $vg1 +not vgextend $vg1 "$dev3" +vgremove -f $vg1 +pvremove -f "$dev1" "$dev2" + +# all PVs exist in the VG after extended +pvcreate "$dev1" +vgcreate $vg1 "$dev2" +vgextend $vg1 "$dev1" "$dev3" +check pv_field "$dev1" vg_name $vg1 +check pv_field "$dev2" vg_name $vg1 +check pv_field "$dev3" vg_name $vg1 +vgremove -f $vg1 +pvremove -f "$dev1" "$dev2" "$dev3" + +echo test vgextend --metadataignore +for mdacp in 1 2; do +for ignore in y n; do + echo vgextend --metadataignore has proper mda_count and mda_used_count + vgcreate $vg "$dev3" + vgextend --metadataignore $ignore --pvmetadatacopies $mdacp $vg "$dev1" "$dev2" + check pv_field "$dev1" pv_mda_count $mdacp + check pv_field "$dev2" pv_mda_count $mdacp + if [ $ignore = y ]; then + check pv_field "$dev1" pv_mda_used_count 0 + check pv_field "$dev2" pv_mda_used_count 0 + else + check pv_field "$dev1" pv_mda_used_count $mdacp + check pv_field "$dev2" pv_mda_used_count $mdacp + fi + echo vg has proper vg_mda_count and vg_mda_used_count + check vg_field $vg vg_mda_count $(($mdacp * 2 + 1)) + if [ $ignore = y ]; then + check vg_field $vg vg_mda_used_count 1 + else + check vg_field $vg vg_mda_used_count $(($mdacp * 2 + 1)) + fi + check vg_field $vg vg_mda_copies unmanaged + vgremove $vg + pvremove -ff "$dev1" "$dev2" "$dev3" +done +done diff --git a/test/shell/vgimportclone.sh b/test/shell/vgimportclone.sh new file mode 100644 index 0000000..9b1c121 --- /dev/null +++ b/test/shell/vgimportclone.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# Copyright (C) 2010-2011 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +aux prepare_devs 2 + +vgcreate -c n --metadatasize 128k $vg1 "$dev1" +lvcreate -l100%FREE -n $lv1 $vg1 + +# Clone the LUN +dd if="$dev1" of="$dev2" bs=256K count=1 +aux notify_lvmetad "$dev2" + +# Verify pvs works on each device to give us vgname +check pv_field "$dev1" vg_name $vg1 +check pv_field "$dev2" vg_name $vg1 + +# Import the cloned PV to a new VG +vgimportclone --basevgname $vg2 "$dev2" + +# We need to re-scan *both* $dev1 and $dev2 since a PV, as far as lvmetad is +# concerned, can only live on a single device. With the last pvscan, we told it +# that PV from $dev1 now lives on $dev2, but in fact this is not true anymore, +# since we wrote a different PV over $dev2. +aux notify_lvmetad "$dev2" +aux notify_lvmetad "$dev1" + +# Verify we can activate / deactivate the LV from both VGs +lvchange -ay $vg1/$lv1 $vg2/$lv1 +vgchange -an $vg1 $vg2 diff --git a/test/shell/vgmerge-operation.sh b/test/shell/vgmerge-operation.sh new file mode 100644 index 0000000..bdd5000 --- /dev/null +++ b/test/shell/vgmerge-operation.sh @@ -0,0 +1,79 @@ +#!/bin/sh +# Copyright (C) 2007-2012 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +test_description='Test vgmerge operation' + +. lib/test + +aux prepare_pvs 4 64 + +# 'vgmerge succeeds with single linear LV in source VG' +vgcreate -c n $vg1 "$dev1" "$dev2" +vgcreate -c n $vg2 "$dev3" "$dev4" +lvcreate -l 4 -n $lv1 $vg1 "$dev1" +vgchange -an $vg1 +check pvlv_counts $vg1 2 1 0 +check pvlv_counts $vg2 2 0 0 +vgmerge $vg2 $vg1 +check pvlv_counts $vg2 4 1 0 +vgremove -f $vg2 + +# 'vgmerge succeeds with single linear LV in source and destination VG' +vgcreate -c n $vg1 "$dev1" "$dev2" +vgcreate -c n $vg2 "$dev3" "$dev4" +lvcreate -l 4 -n $lv1 $vg1 +lvcreate -l 4 -n $lv2 $vg2 +vgchange -an $vg1 +vgchange -an $vg2 +check pvlv_counts $vg1 2 1 0 +check pvlv_counts $vg2 2 1 0 +vgmerge $vg2 $vg1 +check pvlv_counts $vg2 4 2 0 +vgremove -f $vg2 + +# 'vgmerge succeeds with linear LV + snapshots in source VG' +vgcreate -c n $vg1 "$dev1" "$dev2" +vgcreate -c n $vg2 "$dev3" "$dev4" +lvcreate -l 16 -n $lv1 $vg1 +lvcreate -l 4 -s -n $lv2 $vg1/$lv1 +vgchange -an $vg1 +check pvlv_counts $vg1 2 2 1 +check pvlv_counts $vg2 2 0 0 +vgmerge $vg2 $vg1 +check pvlv_counts $vg2 4 2 1 +lvremove -f $vg2/$lv2 +vgremove -f $vg2 + +# 'vgmerge succeeds with mirrored LV in source VG' +vgcreate -c n $vg1 "$dev1" "$dev2" "$dev3" +vgcreate -c n $vg2 "$dev4" +lvcreate -l 4 -n $lv1 -m1 $vg1 +vgchange -an $vg1 +check pvlv_counts $vg1 3 1 0 +check pvlv_counts $vg2 1 0 0 +vgmerge $vg2 $vg1 +check pvlv_counts $vg2 4 1 0 +lvremove -f $vg2/$lv1 +vgremove -f $vg2 + +# 'vgmerge rejects LV name collision' +vgcreate -c n $vg1 "$dev1" "$dev2" +vgcreate -c n $vg2 "$dev3" "$dev4" +lvcreate -l 4 -n $lv1 $vg1 +lvcreate -l 4 -n $lv1 $vg2 +vgchange -an $vg1 +check pvlv_counts $vg1 2 1 0 +check pvlv_counts $vg2 2 1 0 +not vgmerge $vg2 $vg1 2>err +grep "Duplicate logical volume name \"$lv1\" in \"$vg2\" and \"$vg1" err +check pvlv_counts $vg1 2 1 0 +check pvlv_counts $vg2 2 1 0 +vgremove -f $vg1 $vg2 diff --git a/test/shell/vgmerge-usage.sh b/test/shell/vgmerge-usage.sh new file mode 100644 index 0000000..17779b5 --- /dev/null +++ b/test/shell/vgmerge-usage.sh @@ -0,0 +1,67 @@ +#!/bin/sh +# Copyright (C) 2008-2011 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# 'Test vgmerge command options for validity' + +. lib/test + +aux prepare_pvs 4 + +# 'vgmerge normal operation' +# ensure ordering does not matter +vgcreate $vg1 "$dev1" "$dev2" +vgcreate $vg2 "$dev3" "$dev4" +vgmerge $vg1 $vg2 +vgremove $vg1 +vgcreate -c n $vg2 "$dev1" "$dev2" +vgcreate -c n $vg1 "$dev3" "$dev4" +vgmerge $vg2 $vg1 +vgremove $vg2 + +# 'vgmerge rejects duplicate vg name' +vgcreate $vg1 "$dev1" "$dev2" +vgcreate $vg2 "$dev3" "$dev4" +not vgmerge $vg1 $vg1 2>err +grep "Duplicate volume group name \"$vg1\"\$" err +vgremove $vg1 $vg2 + +# 'vgmerge rejects vgs with incompatible extent_size' +vgcreate --physicalextentsize 4M $vg1 "$dev1" "$dev2" +vgcreate --physicalextentsize 8M $vg2 "$dev3" "$dev4" +not vgmerge $vg1 $vg2 2>err +grep "Extent sizes differ" err +vgremove $vg1 $vg2 + +# 'vgmerge rejects vgmerge because max_pv is exceeded' +vgcreate --maxphysicalvolumes 2 $vg1 "$dev1" "$dev2" +vgcreate --maxphysicalvolumes 2 $vg2 "$dev3" "$dev4" +not vgmerge $vg1 $vg2 2>err +grep "Maximum number of physical volumes (2) exceeded" err +vgremove $vg1 $vg2 + +# 'vgmerge rejects vg with active lv' +vgcreate $vg1 "$dev1" "$dev2" +vgcreate $vg2 "$dev3" "$dev4" +lvcreate -l 4 -n lv1 $vg2 +not vgmerge $vg1 $vg2 2>err +grep "Logical volumes in \"$vg2\" must be inactive" err +vgremove -f $vg1 $vg2 + +# 'vgmerge rejects vgmerge because max_lv is exceeded' +vgcreate --maxlogicalvolumes 2 $vg1 "$dev1" "$dev2" +vgcreate --maxlogicalvolumes 2 $vg2 "$dev3" "$dev4" +lvcreate -l 4 -n lv1 $vg1 +lvcreate -l 4 -n lv2 $vg1 +lvcreate -l 4 -n lv3 $vg2 +vgchange -an $vg1 $vg2 +not vgmerge $vg1 $vg2 2>err +grep "Maximum number of logical volumes (2) exceeded" err +vgremove -f $vg1 $vg2 diff --git a/test/shell/vgreduce-removemissing-snapshot.sh b/test/shell/vgreduce-removemissing-snapshot.sh new file mode 100644 index 0000000..488d8fe --- /dev/null +++ b/test/shell/vgreduce-removemissing-snapshot.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# Copyright (C) 2011 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +. lib/test + +exit 0 + +# +# Snapshots of 'mirrors' are not supported. They can no longer be created. +# This file could be used to test some aspect of vgreduce, snapshot, and +# RAID at some point though... +# + +aux prepare_vg 5 + +lvcreate -m 3 --ig -L 2M -n 4way $vg "$dev1" "$dev2" "$dev3" "$dev4" "$dev5":0 +lvcreate -s $vg/4way -L 2M -n snap +lvcreate -i 2 -L 2M $vg "$dev1" "$dev2" -n stripe + +aux disable_dev "$dev2" "$dev4" +echo n | lvconvert --repair $vg/4way +aux enable_dev "$dev2" "$dev4" +#not vgreduce --removemissing $vg +vgreduce -v --removemissing --force $vg # "$dev2" "$dev4" +lvs -a -o +devices $vg | not grep unknown +lvs -a -o +devices $vg +check mirror $vg 4way "$dev5" diff --git a/test/t-vgreduce-usage.sh b/test/shell/vgreduce-usage.sh index 6a09cfa..9a55d3c 100755..100644 --- a/test/t-vgreduce-usage.sh +++ b/test/shell/vgreduce-usage.sh @@ -9,77 +9,81 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test aux prepare_devs 4 for mdatype in 1 2 do # setup PVs - pvcreate -M$mdatype $dev1 $dev2 + pvcreate -M$mdatype "$dev1" "$dev2" # (lvm$mdatype) vgreduce removes only the specified pv from vg (bz427382)" ' - vgcreate -c n -M$mdatype $vg1 $dev1 $dev2 - vgreduce $vg1 $dev1 - check_pv_field_ $dev2 vg_name $vg1 + vgcreate -c n -M$mdatype $vg1 "$dev1" "$dev2" + vgreduce $vg1 "$dev1" + check pv_field "$dev2" vg_name $vg1 vgremove -f $vg1 # (lvm$mdatype) vgreduce rejects removing the last pv (--all) - vgcreate -c n -M$mdatype $vg1 $dev1 $dev2 + vgcreate -c n -M$mdatype $vg1 "$dev1" "$dev2" not vgreduce --all $vg1 vgremove -f $vg1 # (lvm$mdatype) vgreduce rejects removing the last pv - vgcreate -c n -M$mdatype $vg1 $dev1 $dev2 - not vgreduce $vg1 $dev1 $dev2 + vgcreate -c n -M$mdatype $vg1 "$dev1" "$dev2" + not vgreduce $vg1 "$dev1" "$dev2" vgremove -f $vg1 - pvremove -ff $dev1 $dev2 + pvremove -ff "$dev1" "$dev2" done mdatype=2 # we only expect the following to work for lvm2 metadata # (lvm$mdatype) setup PVs (--metadatacopies 0) -pvcreate -M$mdatype $dev1 $dev2 -pvcreate --metadatacopies 0 -M$mdatype $dev3 $dev4 +pvcreate -M$mdatype "$dev1" "$dev2" +pvcreate --metadatacopies 0 -M$mdatype "$dev3" "$dev4" # (lvm$mdatype) vgreduce rejects removing pv with the last mda copy (bz247448) -vgcreate -c n -M$mdatype $vg1 $dev1 $dev3 -not vgreduce $vg1 $dev1 +vgcreate -c n -M$mdatype $vg1 "$dev1" "$dev3" +not vgreduce $vg1 "$dev1" vgremove -f $vg1 #COMM "(lvm$mdatype) vgreduce --removemissing --force repares to linear (bz221921)" # (lvm$mdatype) setup: create mirror & damage one pv -vgcreate -c n -M$mdatype $vg1 $dev1 $dev2 $dev3 +vgcreate -c n -M$mdatype $vg1 "$dev1" "$dev2" "$dev3" lvcreate -n $lv1 -m1 -l 4 $vg1 -lvcreate -n $lv2 -l 4 $vg1 $dev2 -lvcreate -n $lv3 -l 4 $vg1 $dev3 +lvcreate -n $lv2 -l 4 $vg1 "$dev2" +lvcreate -n $lv3 -l 4 $vg1 "$dev3" vgchange -an $vg1 -aux disable_dev $dev1 +aux disable_dev "$dev1" # (lvm$mdatype) vgreduce --removemissing --force repares to linear vgreduce --removemissing --force $vg1 -check_lv_field_ $vg1/$lv1 segtype linear -vg_validate_pvlv_counts_ $vg1 2 3 0 +check lv_field $vg1/$lv1 segtype linear +check pvlv_counts $vg1 2 3 0 # cleanup -aux enable_dev $dev1 -vgremove -ff $vg1 +aux enable_dev "$dev1" +pvscan +vgremove -f $vg1 +not vgs $vg1 # just double-check it's really gone #COMM "vgreduce rejects --removemissing --mirrorsonly --force when nonmirror lv lost too" # (lvm$mdatype) setup: create mirror + linear lvs -vgcreate -c n -M$mdatype $vg1 $devs +vgcreate -c n -M$mdatype $vg1 $(cat DEVICES) lvcreate -n $lv2 -l 4 $vg1 -lvcreate -m1 -n $lv1 -l 4 $vg1 $dev1 $dev2 $dev3 -lvcreate -n $lv3 -l 4 $vg1 $dev3 -pvs --segments -o +lv_name # for record only +lvcreate -m1 -n $lv1 -l 4 $vg1 "$dev1" "$dev2" "$dev3" +lvcreate -n $lv3 -l 4 $vg1 "$dev3" +pvs --segments -o +lv_name $(cat DEVICES) # for record only # (lvm$mdatype) setup: damage one pv -vgchange -an $vg1 -aux disable_dev $dev1 -#pvcreate -ff -y $dev1 +vgchange -an $vg1 +aux disable_dev "$dev1" +#pvcreate -ff -y "$dev1" # vgreduce rejects --removemissing --mirrorsonly --force when nonmirror lv lost too -not vgreduce -c n --removemissing --mirrorsonly --force $vg1 +#not vgreduce -c n --removemissing --mirrorsonly --force $vg1 +# CHECKME - command above was rejected becuase of '-c n' +vgreduce --removemissing --mirrorsonly --force $vg1 -aux enable_dev $dev1 +aux enable_dev "$dev1" -pvs -P # for record -lvs -P # for record -vgs -P # for record +pvs -P $(cat DEVICES) # for record +lvs -P $vg1 # for record +vgs -P $vg1 # for record diff --git a/test/t-vgrename-usage.sh b/test/shell/vgrename-usage.sh index 61e861c..2b8ac5a 100755..100644 --- a/test/t-vgrename-usage.sh +++ b/test/shell/vgrename-usage.sh @@ -1,3 +1,4 @@ +#!/bin/sh # Copyright (C) 2008 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -8,34 +9,32 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test aux prepare_devs 4 -pvcreate $dev1 $dev2 -pvcreate --metadatacopies 0 $dev3 $dev4 +pvcreate "$dev1" "$dev2" +pvcreate --metadatacopies 0 "$dev3" "$dev4" # vgrename normal operation - rename vg1 to vg2 # vgrename normal operation - rename vg2 to vg1 # ensure name ordering does not matter -vgcreate $vg1 $dev1 $dev2 +vgcreate $vg1 "$dev1" "$dev2" vgrename $vg1 $vg2 -check_vg_field_ $vg2 vg_name $vg2 +check vg_field $vg2 vg_name $vg2 vgrename $vg2 $vg1 -check_vg_field_ $vg1 vg_name $vg1 +check vg_field $vg1 vg_name $vg1 vgremove $vg1 # vgrename by uuid (bz231187) -vgcreate $vg1 $dev1 $dev3 +vgcreate $vg1 "$dev1" "$dev3" UUID=$(vgs --noheading -o vg_uuid $vg1) -check_vg_field_ $vg1 vg_uuid $UUID +check vg_field $vg1 vg_uuid $UUID vgrename $UUID $vg2 -check_vg_field_ $vg2 vg_name $vg2 +check vg_field $vg2 vg_name $vg2 vgremove $vg2 # vgrename fails - new vg already exists -vgcreate $vg1 $dev1 -vgcreate $vg2 $dev2 +vgcreate $vg1 "$dev1" +vgcreate $vg2 "$dev2" not vgrename $vg1 $vg2 -vgremove $vg1 -vgremove $vg2 - +vgremove $vg1 $vg2 diff --git a/test/shell/vgsplit-operation.sh b/test/shell/vgsplit-operation.sh new file mode 100644 index 0000000..c9cc04a --- /dev/null +++ b/test/shell/vgsplit-operation.sh @@ -0,0 +1,294 @@ +#!/bin/sh +# Copyright (C) 2007 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# Test vgsplit operation, including different LV types + +. lib/test + +COMM() { + LAST_TEST="$@" +} + +create_vg_() { + vgcreate -c n -s 64k "$@" +} + +aux prepare_pvs 5 10 +# FIXME: paramaterize lvm1 vs lvm2 metadata; most of these tests should run +# fine with lvm1 metadata as well; for now, just add disks 5 and 6 as lvm1 +# metadata + +# +# vgsplit can be done into a new or existing VG +# +for i in new existing +do + # + # We can have PVs or LVs on the cmdline + # + for j in PV LV + do +COMM "vgsplit correctly splits single linear LV into $i VG ($j args)" + create_vg_ $vg1 "$dev1" "$dev2" + test $i = existing && create_vg_ $vg2 "$dev3" "$dev4" + + lvcreate -l 4 -n $lv1 $vg1 "$dev1" + vgchange -an $vg1 + if [ $j = PV ]; then + vgsplit $vg1 $vg2 "$dev1" + else + vgsplit -n $lv1 $vg1 $vg2 + fi + check pvlv_counts $vg1 1 0 0 + if [ $i = existing ]; then + check pvlv_counts $vg2 3 1 0 + else + check pvlv_counts $vg2 1 1 0 + fi + lvremove -f $vg2/$lv1 + vgremove -f $vg2 $vg1 + +COMM "vgsplit correctly splits single striped LV into $i VG ($j args)" + create_vg_ $vg1 "$dev1" "$dev2" + test $i = existing && create_vg_ $vg2 "$dev3" "$dev4" + + lvcreate -l 4 -i 2 -n $lv1 $vg1 "$dev1" "$dev2" + vgchange -an $vg1 + if [ $j = PV ]; then + vgsplit $vg1 $vg2 "$dev1" "$dev2" + else + vgsplit -n $lv1 $vg1 $vg2 + fi + if [ $i = existing ]; then + check pvlv_counts $vg2 4 1 0 + else + check pvlv_counts $vg2 2 1 0 + fi + lvremove -f $vg2/$lv1 + vgremove -f $vg2 + +COMM "vgsplit correctly splits mirror LV into $i VG ($j args)" + create_vg_ $vg1 "$dev1" "$dev2" "$dev3" + test $i = existing && create_vg_ $vg2 "$dev4" + + lvcreate -l 64 -m1 -n $lv1 $vg1 "$dev1" "$dev2" "$dev3" + vgchange -an $vg1 + if [ $j = PV ]; then + vgsplit $vg1 $vg2 "$dev1" "$dev2" "$dev3" + else + vgsplit -n $lv1 $vg1 $vg2 + fi + if [ $i = existing ]; then + check pvlv_counts $vg2 4 1 0 + else + check pvlv_counts $vg2 3 1 0 + fi + lvremove -f $vg2/$lv1 + vgremove -f $vg2 +# FIXME: ensure split /doesn't/ work when not all devs of mirror specified + +COMM "vgsplit correctly splits mirror LV with mirrored log into $i VG ($j args)" + create_vg_ $vg1 "$dev1" "$dev2" "$dev3" "$dev4" + test $i = existing && create_vg_ $vg2 "$dev5" + + lvcreate -l 64 --mirrorlog mirrored -m1 -n $lv1 $vg1 \ + "$dev1" "$dev2" "$dev3" "$dev4" + + vgchange -an $vg1 + if [ $j = PV ]; then + vgsplit $vg1 $vg2 "$dev1" "$dev2" "$dev3" "$dev4" + else + vgsplit -n $lv1 $vg1 $vg2 + fi + if [ $i = existing ]; then + check pvlv_counts $vg2 5 1 0 + else + check pvlv_counts $vg2 4 1 0 + fi + lvremove -f $vg2/$lv1 + vgremove -f $vg2 +# FIXME: ensure split /doesn't/ work when not all devs of mirror specified + +COMM "vgsplit correctly splits origin and snapshot LV into $i VG ($j args)" + create_vg_ $vg1 "$dev1" "$dev2" + test $i = existing && create_vg_ $vg2 "$dev3" "$dev4" + + lvcreate -l 64 -i 2 -n $lv1 $vg1 "$dev1" "$dev2" + lvcreate -l 4 -i 2 -s -n $lv2 $vg1/$lv1 + vgchange -an $vg1 + if [ $j = PV ]; then + vgsplit $vg1 $vg2 "$dev1" "$dev2" + else + vgsplit -n $lv1 $vg1 $vg2 + fi + if [ $i = existing ]; then + check pvlv_counts $vg2 4 2 1 + else + check pvlv_counts $vg2 2 2 1 + fi + lvremove -f $vg2/$lv2 + lvremove -f $vg2/$lv1 + vgremove -f $vg2 + +COMM "vgsplit correctly splits linear LV but not snap+origin LV into $i VG ($j args)" + create_vg_ $vg1 "$dev1" "$dev2" + test $i = existing && create_vg_ $vg2 "$dev3" + + lvcreate -l 64 -i 2 -n $lv1 $vg1 + lvcreate -l 4 -i 2 -s -n $lv2 $vg1/$lv1 + vgextend $vg1 "$dev4" + lvcreate -l 64 -n $lv3 $vg1 "$dev4" + vgchange -an $vg1 + if [ $j = PV ]; then + vgsplit $vg1 $vg2 "$dev4" + else + vgsplit -n $lv3 $vg1 $vg2 + fi + if [ $i = existing ]; then + check pvlv_counts $vg2 2 1 0 + check pvlv_counts $vg1 2 2 1 + else + check pvlv_counts $vg2 1 1 0 + check pvlv_counts $vg1 2 2 1 + fi + lvremove -f $vg1/$lv2 + lvremove -f $vg1/$lv1 $vg2/$lv3 + vgremove -f $vg1 $vg2 + +COMM "vgsplit correctly splits linear LV but not mirror LV into $i VG ($j args)" + create_vg_ $vg1 "$dev1" "$dev2" "$dev3" + test $i = existing && create_vg_ $vg2 "$dev5" + + lvcreate -l 64 -m1 -n $lv1 $vg1 "$dev1" "$dev2" "$dev3" + vgextend $vg1 "$dev4" + lvcreate -l 64 -n $lv2 $vg1 "$dev4" + vgchange -an $vg1 + if [ $j = PV ]; then + vgsplit $vg1 $vg2 "$dev4" + else + vgsplit -n $lv2 $vg1 $vg2 + fi + if [ $i = existing ]; then + check pvlv_counts $vg1 3 1 0 + check pvlv_counts $vg2 2 1 0 + else + check pvlv_counts $vg1 3 1 0 + check pvlv_counts $vg2 1 1 0 + fi + vgremove -f $vg1 $vg2 + + done +done + +# +# Test more complex setups where the code has to find associated PVs and +# LVs to split the VG correctly +# +COMM "vgsplit fails splitting 3 striped LVs into VG when only 1 LV specified" +create_vg_ $vg1 "$dev1" "$dev2" "$dev3" "$dev4" +lvcreate -l 4 -n $lv1 -i 2 $vg1 "$dev1" "$dev2" +lvcreate -l 4 -n $lv2 -i 2 $vg1 "$dev2" "$dev3" +lvcreate -l 4 -n $lv3 -i 2 $vg1 "$dev3" "$dev4" +vgchange -an $vg1 +not vgsplit -n $lv1 $vg1 $vg2 +vgremove -f $vg1 + +COMM "vgsplit fails splitting one LV with 2 snapshots, only origin LV specified" +create_vg_ $vg1 "$dev1" "$dev2" "$dev3" "$dev4" +lvcreate -l 16 -n $lv1 $vg1 "$dev1" "$dev2" +lvcreate -l 4 -n $lv2 -s $vg1/$lv1 "$dev3" +lvcreate -l 4 -n $lv3 -s $vg1/$lv1 "$dev4" +check pvlv_counts $vg1 4 3 2 +vgchange -an $vg1 +not vgsplit -n $lv1 $vg1 $vg2; +lvremove -f $vg1/$lv2 $vg1/$lv3 +lvremove -f $vg1/$lv1 +vgremove -f $vg1 + +COMM "vgsplit fails splitting one LV with 2 snapshots, only snapshot LV specified" +create_vg_ $vg1 "$dev1" "$dev2" "$dev3" "$dev4" +lvcreate -l 16 -n $lv1 $vg1 "$dev1" "$dev2" +lvcreate -l 4 -n $lv2 -s $vg1/$lv1 "$dev3" +lvcreate -l 4 -n $lv3 -s $vg1/$lv1 "$dev4" +check pvlv_counts $vg1 4 3 2 +vgchange -an $vg1 +not vgsplit -n $lv2 $vg1 $vg2 +lvremove -f $vg1/$lv2 $vg1/$lv3 +lvremove -f $vg1/$lv1 +vgremove -f $vg1 + +COMM "vgsplit fails splitting one mirror LV, only one PV specified" +create_vg_ $vg1 "$dev1" "$dev2" "$dev3" "$dev4" +lvcreate -l 16 -n $lv1 -m1 $vg1 "$dev1" "$dev2" "$dev3" +check pvlv_counts $vg1 4 1 0 +vgchange -an $vg1 +not vgsplit $vg1 $vg2 "$dev2" +vgremove -ff $vg1 + +COMM "vgsplit fails splitting 1 mirror + 1 striped LV, only striped LV specified" +create_vg_ $vg1 "$dev1" "$dev2" "$dev3" "$dev4" +lvcreate -l 16 -n $lv1 -m1 $vg1 "$dev1" "$dev2" "$dev3" +lvcreate -l 16 -n $lv2 -i 2 $vg1 "$dev3" "$dev4" +check pvlv_counts $vg1 4 2 0 +vgchange -an $vg1 +not vgsplit -n $lv2 $vg1 $vg2 2>err +vgremove -f $vg1 + +# +# Verify vgsplit rejects active LVs only when active LVs involved in split +# +COMM "vgsplit fails, active mirror involved in split" +create_vg_ $vg1 "$dev1" "$dev2" "$dev3" "$dev4" +lvcreate -l 16 -n $lv1 -m1 $vg1 "$dev1" "$dev2" "$dev3" +lvcreate -l 16 -n $lv2 $vg1 "$dev4" +lvchange -an $vg1/$lv2 +check pvlv_counts $vg1 4 2 0 +not vgsplit -n $lv1 $vg1 $vg2; +check pvlv_counts $vg1 4 2 0 +vgremove -f $vg1 + +COMM "vgsplit succeeds, active mirror not involved in split" +create_vg_ $vg1 "$dev1" "$dev2" "$dev3" "$dev4" +lvcreate -l 16 -n $lv1 -m1 $vg1 "$dev1" "$dev2" "$dev3" +lvcreate -l 16 -n $lv2 $vg1 "$dev4" +lvchange -an $vg1/$lv2 +check pvlv_counts $vg1 4 2 0 +vgsplit -n $lv2 $vg1 $vg2 +check pvlv_counts $vg1 3 1 0 +check pvlv_counts $vg2 1 1 0 +vgremove -f $vg1 $vg2 + +COMM "vgsplit fails, active snapshot involved in split" +create_vg_ $vg1 "$dev1" "$dev2" "$dev3" "$dev4" +lvcreate -l 64 -i 2 -n $lv1 $vg1 "$dev1" "$dev2" +lvcreate -l 4 -i 2 -s -n $lv2 $vg1/$lv1 +lvcreate -l 64 -i 2 -n $lv3 $vg1 "$dev3" "$dev4" +lvchange -an $vg1/$lv3 +check pvlv_counts $vg1 4 3 1 +not vgsplit -n $lv2 $vg1 $vg2; +check pvlv_counts $vg1 4 3 1 +lvremove -f $vg1/$lv2 +vgremove -f $vg1 + +COMM "vgsplit succeeds, active snapshot not involved in split" +create_vg_ $vg1 "$dev1" "$dev2" "$dev3" +lvcreate -l 64 -i 2 -n $lv1 $vg1 "$dev1" "$dev2" +lvcreate -l 4 -s -n $lv2 $vg1/$lv1 +vgextend $vg1 "$dev4" +lvcreate -l 64 -n $lv3 $vg1 "$dev4" +lvchange -an $vg1/$lv3 +check pvlv_counts $vg1 4 3 1 +vgsplit -n $lv3 $vg1 $vg2 +check pvlv_counts $vg1 3 2 1 +check pvlv_counts $vg2 1 1 0 +vgchange -an $vg1 +lvremove -f $vg1/$lv2 +vgremove -f $vg1 $vg2 diff --git a/test/t-vgsplit-stacked.sh b/test/shell/vgsplit-stacked.sh index 424156f..62a5304 100644 --- a/test/t-vgsplit-stacked.sh +++ b/test/shell/vgsplit-stacked.sh @@ -1,3 +1,4 @@ +#!/bin/sh # Copyright (C) 2010 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, @@ -8,21 +9,19 @@ # along with this program; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -. ./test-utils.sh +. lib/test -prepare_lvmconf '[ "a/dev\/mirror/", "a/dev\/mapper\/.*$/", "a/dev\/LVMTEST/", "r/.*/" ]' -aux prepare_devs 3 +aux lvmconf 'devices/filter = [ "a/dev\/mirror/", "a/dev\/mapper\/.*$/", "a/dev\/LVMTEST/", "r/.*/" ]' +aux prepare_pvs 3 -pvcreate $devs -vgcreate $vg1 $dev1 $dev2 +vgcreate $vg1 "$dev1" "$dev2" lvcreate -n $lv1 -l 100%FREE $vg1 #top VG pvcreate $DM_DEV_DIR/$vg1/$lv1 -vgcreate $vg $DM_DEV_DIR/$vg1/$lv1 $dev3 +vgcreate $vg $DM_DEV_DIR/$vg1/$lv1 "$dev3" -vgchange -a n $vg -vgchange -a n $vg1 +vgchange -a n $vg $vg1 # this should fail but not segfault, RHBZ 481793. -not vgsplit $vg $vg1 $dev3 +not vgsplit $vg $vg1 "$dev3" diff --git a/test/shell/vgsplit-usage.sh b/test/shell/vgsplit-usage.sh new file mode 100644 index 0000000..10167d7 --- /dev/null +++ b/test/shell/vgsplit-usage.sh @@ -0,0 +1,168 @@ +#!/bin/sh +# Copyright (C) 2007-2011 Red Hat, Inc. All rights reserved. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +# Test vgsplit command options for validity + +. lib/test + +aux prepare_devs 5 + +for mdatype in 1 2 +do + +pvcreate -M$mdatype $(cat DEVICES) + +# ensure name order does not matter +# NOTE: if we're using lvm1, we must use -M on vgsplit +vgcreate -M$mdatype $vg1 $(cat DEVICES) +vgsplit -M$mdatype $vg1 $vg2 "$dev1" +vgremove $vg1 $vg2 + +vgcreate -M$mdatype $vg2 $(cat DEVICES) +vgsplit -M$mdatype $vg2 $vg1 "$dev1" +vgremove $vg1 $vg2 + +# vgsplit accepts new vg as destination of split +# lvm1 -- bz244792 +vgcreate -M$mdatype $vg1 $(cat DEVICES) +vgsplit $vg1 $vg2 "$dev1" 1>err +grep "New volume group \"$vg2\" successfully split from \"$vg1\"" err +vgremove $vg1 $vg2 + +# vgsplit accepts existing vg as destination of split +vgcreate -M$mdatype $vg1 "$dev1" "$dev2" +vgcreate -M$mdatype $vg2 "$dev3" "$dev4" +vgsplit $vg1 $vg2 "$dev1" 1>err +grep "Existing volume group \"$vg2\" successfully split from \"$vg1\"" err +vgremove $vg1 $vg2 + +# vgsplit accepts --maxphysicalvolumes 128 on new VG +vgcreate -M$mdatype $vg1 "$dev1" "$dev2" +vgsplit --maxphysicalvolumes 128 $vg1 $vg2 "$dev1" +check vg_field $vg2 max_pv 128 +vgremove $vg1 $vg2 + +# vgsplit accepts --maxlogicalvolumes 128 on new VG +vgcreate -M$mdatype $vg1 "$dev1" "$dev2" +vgsplit --maxlogicalvolumes 128 $vg1 $vg2 "$dev1" +check vg_field $vg2 max_lv 128 +vgremove $vg1 $vg2 + +# vgsplit rejects split because max_pv of destination would be exceeded +vgcreate -M$mdatype --maxphysicalvolumes 2 $vg1 "$dev1" "$dev2" +vgcreate -M$mdatype --maxphysicalvolumes 2 $vg2 "$dev3" "$dev4" +not vgsplit $vg1 $vg2 "$dev1" 2>err; +grep "Maximum number of physical volumes (2) exceeded" err +vgremove $vg1 $vg2 + +# vgsplit rejects split because maxphysicalvolumes given with existing vg +vgcreate -M$mdatype --maxphysicalvolumes 2 $vg1 "$dev1" "$dev2" +vgcreate -M$mdatype --maxphysicalvolumes 2 $vg2 "$dev3" "$dev4" +not vgsplit --maxphysicalvolumes 2 $vg1 $vg2 "$dev1" 2>err; +grep "Volume group \"$vg2\" exists, but new VG option specified" err +vgremove $vg1 $vg2 + +# vgsplit rejects split because maxlogicalvolumes given with existing vg +vgcreate -M$mdatype --maxlogicalvolumes 2 $vg1 "$dev1" "$dev2" +vgcreate -M$mdatype --maxlogicalvolumes 2 $vg2 "$dev3" "$dev4" +not vgsplit --maxlogicalvolumes 2 $vg1 $vg2 "$dev1" 2>err +grep "Volume group \"$vg2\" exists, but new VG option specified" err +vgremove $vg1 $vg2 + +# vgsplit rejects split because alloc given with existing vg +vgcreate -M$mdatype --alloc cling $vg1 "$dev1" "$dev2" +vgcreate -M$mdatype --alloc cling $vg2 "$dev3" "$dev4" +not vgsplit --alloc cling $vg1 $vg2 "$dev1" 2>err; +grep "Volume group \"$vg2\" exists, but new VG option specified" err +vgremove $vg1 $vg2 + +# vgsplit rejects split because clustered given with existing vg +vgcreate -M$mdatype --clustered n $vg1 "$dev1" "$dev2" +vgcreate -M$mdatype --clustered n $vg2 "$dev3" "$dev4" +not vgsplit --clustered n $vg1 $vg2 "$dev1" 2>err +grep "Volume group \"$vg2\" exists, but new VG option specified" err +vgremove $vg1 $vg2 + +# vgsplit rejects vg with active lv +pvcreate -M$mdatype -ff "$dev3" "$dev4" +vgcreate -M$mdatype $vg1 "$dev1" "$dev2" +vgcreate -M$mdatype $vg2 "$dev3" "$dev4" +lvcreate -l 4 -n $lv1 $vg1 +not vgsplit $vg1 $vg2 "$dev1" 2>err; +grep "Logical volumes in \"$vg1\" must be inactive\$" err +vgremove -f $vg1 $vg2 + +# vgsplit rejects split because max_lv is exceeded +vgcreate -M$mdatype --maxlogicalvolumes 2 $vg1 "$dev1" "$dev2" +vgcreate -M$mdatype --maxlogicalvolumes 2 $vg2 "$dev3" "$dev4" +lvcreate -l 4 -n $lv1 $vg1 +lvcreate -l 4 -n $lv2 $vg1 +lvcreate -l 4 -n $lv3 $vg2 +vgchange -an $vg1 $vg2 +not vgsplit $vg1 $vg2 "$dev1" 2>err; +grep "Maximum number of logical volumes (2) exceeded" err +vgremove -f $vg1 $vg2 + +# vgsplit verify default - max_lv attribute from new VG is same as source VG" \ +vgcreate -M$mdatype $vg1 "$dev1" "$dev2" +lvcreate -l 4 -n $lv1 $vg1 +vgchange -an $vg1 +vgsplit $vg1 $vg2 "$dev1" +check compare_vg_field $vg1 $vg2 max_lv +vgremove -f $vg1 $vg2 + +# vgsplit verify default - max_pv attribute from new VG is same as source VG" \ +vgcreate -M$mdatype $vg1 "$dev1" "$dev2" +lvcreate -l 4 -n $lv1 $vg1 +vgchange -an $vg1 +vgsplit $vg1 $vg2 "$dev1" +check compare_vg_field $vg1 $vg2 max_pv +vgremove -f $vg1 $vg2 + +# vgsplit verify default - vg_fmt attribute from new VG is same as source VG" \ +vgcreate -M$mdatype $vg1 "$dev1" "$dev2" +lvcreate -l 4 -n $lv1 $vg1 +vgchange -an $vg1 +vgsplit $vg1 $vg2 "$dev1" +check compare_vg_field $vg1 $vg2 vg_fmt +vgremove -f $vg2 $vg1 + +# vgsplit rejects split because PV not in VG +vgcreate -M$mdatype $vg1 "$dev1" "$dev2" +vgcreate -M$mdatype $vg2 "$dev3" "$dev4" +lvcreate -l 4 -n $lv1 $vg1 +lvcreate -l 4 -n $lv2 $vg1 +vgchange -an $vg1 +not vgsplit $vg1 $vg2 "$dev3" 2>err; +vgremove -f $vg2 $vg1 +done + +# ONLY LVM2 metadata +# setup PVs" ' +pvcreate --metadatacopies 0 "$dev5" + +# vgsplit rejects to give away pv with the last mda copy +vgcreate $vg1 "$dev5" "$dev2" +lvcreate -l 10 -n $lv1 $vg1 +lvchange -an $vg1/$lv1 +check pvlv_counts $vg1 2 1 0 +not vgsplit $vg1 $vg2 "$dev5"; +check pvlv_counts $vg1 2 1 0 +vgremove -f $vg1 + +# vgsplit rejects split because metadata types differ +pvcreate -ff -M1 "$dev3" "$dev4" +pvcreate -ff "$dev1" "$dev2" +vgcreate -M1 $vg1 "$dev3" "$dev4" +vgcreate $vg2 "$dev1" "$dev2" +not vgsplit $vg1 $vg2 "$dev3" 2>err; +grep "Metadata types differ" err +vgremove -f $vg1 $vg2 diff --git a/test/t-covercmd.sh b/test/t-covercmd.sh deleted file mode 100755 index 358a93e..0000000 --- a/test/t-covercmd.sh +++ /dev/null @@ -1,82 +0,0 @@ -# Copyright (C) 2008 Red Hat, Inc. All rights reserved. -# -# 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. -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -# -# tests basic functionality of read-ahead and ra regressions -# - -. ./test-utils.sh - -TEST_UUID="aaaaaa-aaaa-aaaa-aaaa-aaaa-aaaa-aaaaaa" - -get_lvs_() -{ - case $(lvs --units s --nosuffix --noheadings -o $1_read_ahead "$vg"/"$lv") in - *$2) true ;; - *) false ;; - esac -} - -aux prepare_devs 5 - -pvcreate $dev1 -pvcreate --metadatacopies 0 $dev2 -pvcreate --metadatacopies 0 $dev3 -pvcreate $dev4 -pvcreate --norestorefile -u $TEST_UUID --metadatacopies 0 $dev5 -vgcreate -c n $vg $devs -lvcreate -n $lv -l 5 -i5 -I256 $vg - -# test *scan and *display tools -pvscan -vgscan -lvscan -lvmdiskscan -vgdisplay --units k -lvdisplay --units g -for i in h b s k m g t p e H B S K M G T P E ; do - pvdisplay --units "$i" "$dev1" -done - -# test vgexport vgimport tools -vgchange -an $vg -vgexport $vg -vgimport $vg -vgchange -ay $vg - -# "-persistent y --major 254 --minor 20" -# "-persistent n" -# test various lvm utils -for i in dumpconfig formats segtypes; do - lvm "$i" -done - -for i in pr "p rw" an ay "-monitor y" "-monitor n" \ - -resync -refresh "-addtag MYTAG" "-deltag MYETAG"; do - lvchange -$i "$vg"/"$lv" -done - -pvck "$dev1" -vgck "$vg" -lvrename "$vg" "$lv" "$lv-rename" -vgcfgbackup -f "$(pwd)/backup.$$" "$vg" -vgchange -an "$vg" -vgcfgrestore -f "$(pwd)/backup.$$" "$vg" -pvremove -y -ff $dev5 -not vgcfgrestore -f "$(pwd)/backup.$$" "$vg" -pvcreate -u $TEST_UUID --restorefile "$(pwd)/backup.$$" $dev5 -vgremove -f "$vg" -pvresize --setphysicalvolumesize 10M "$dev1" - -# test various errors and obsoleted tools -not lvmchange -not lvrename "$vg" -not lvrename "$vg-xxx" -not lvrename "$vg" "$vg"/"$lv-rename" "$vg"/"$lv" diff --git a/test/t-fsadm.sh b/test/t-fsadm.sh deleted file mode 100644 index 17d2090..0000000 --- a/test/t-fsadm.sh +++ /dev/null @@ -1,123 +0,0 @@ -#!/bin/bash -# Copyright (C) 2008-2010 Red Hat, Inc. All rights reserved. -# -# 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. -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -test_description='Exercise fsadm filesystem resize' -exit 200 - -. ./test-utils.sh - -aux prepare_vg 1 100 - -# set to "skip" to avoid testing given fs and test warning result -# i.e. check_reiserfs=skip -check_ext3= -check_xfs= -check_reiserfs= - -which mkfs.ext3 || check_ext3=${check_ext3:=mkfs.ext3} -which fsck.ext3 || check_ext3=${check_ext3:=fsck.ext3} -which mkfs.xfs || check_xfs=${check_xfs:=mkfs.xfs} -which xfs_check || check_xfs=${check_xfs:=xfs_check} -which mkfs.reiserfs || check_reiserfs=${check_reiserfs:=mkfs.reiserfs} -which reiserfsck || check_reiserfs=${check_reiserfs:=reiserfsck} - -vg_lv="$vg/$lv1" -dev_vg_lv="$DM_DEV_DIR/$vg_lv" -mount_dir="$TESTDIR/mnt" - -test ! -d $mount_dir && mkdir $mount_dir - -cleanup_mounted_and_teardown() -{ - umount $mount_dir || true - teardown -} - -fscheck_ext3() -{ - fsck.ext3 -p -F -f $dev_vg_lv -} - -fscheck_xfs() -{ - xfs_check $dev_vg_lv -} - -fscheck_reiserfs() -{ - reiserfsck --check -p -f $dev_vg_lv </dev/null -} - -check_missing() -{ - eval local t=$\check_$1 - test -z "$t" && return 0 - test "$t" = skip && return 1 - # trick for warning test - echo "TEST ""WARNING: fsadm skips $1 tests, $t tool is missing" - return 1 -} - -# Test for block sizes != 1024 (rhbz #480022) -lvcreate -n $lv1 -L20M $vg -trap 'aux cleanup_mounted_and_teardown' EXIT - -if check_missing ext3; then - mkfs.ext3 -b4096 -j $dev_vg_lv - - fsadm --lvresize resize $vg_lv 30M - # Fails - not enough space for 4M fs - not fsadm --lvresize resize $dev_vg_lv 4M - lvresize -L+10M -r $vg_lv - lvreduce -L10M -r $vg_lv - - fscheck_ext3 - mount $dev_vg_lv $mount_dir - not fsadm --lvresize resize $vg_lv 9M - lvresize -L+20M -r -n $vg_lv - umount $mount_dir - fscheck_ext3 - - lvresize -f -L20M $vg_lv -fi - -if check_missing xfs; then - mkfs.xfs -l internal,size=1000b -f $dev_vg_lv - - fsadm --lvresize resize $vg_lv 30M - # Fails - not enough space for 4M fs - lvresize -L+10M -r $vg_lv - not lvreduce -L10M -r $vg_lv - - fscheck_xfs - mount $dev_vg_lv $mount_dir - lvresize -L+10M -r -n $vg_lv - umount $mount_dir - fscheck_xfs - - lvresize -f -L20M $vg_lv -fi - -if check_missing reiserfs; then - mkfs.reiserfs -s 513 -f $dev_vg_lv - - fsadm --lvresize resize $vg_lv 30M - lvresize -L+10M -r $vg_lv - fsadm --lvresize -y resize $vg_lv 10M - - fscheck_reiserfs - mount $dev_vg_lv $mount_dir - - not fsadm -y --lvresize resize $vg_lv 20M - umount $mount_dir - - lvresize -f -L20M $vg_lv -fi diff --git a/test/t-inconsistent-metadata.sh b/test/t-inconsistent-metadata.sh deleted file mode 100644 index 310dde5..0000000 --- a/test/t-inconsistent-metadata.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/bash -# Copyright (C) 2008 Red Hat, Inc. All rights reserved. -# -# 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. -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -. ./test-utils.sh - -aux prepare_vg 3 - -lvcreate -m 1 -l 1 -n mirror $vg -lvcreate -l 1 -n resized $vg -lvchange -a n $vg/mirror - -backup_dev $devs - -init() { - restore_dev $devs - lvs -o lv_name,lv_size --units k $vg | tee lvs.out - grep resized lvs.out | not grep 8192 - lvresize -L 8192K $vg/resized - restore_dev $dev1 -} - -check() { - lvs -o lv_name,lv_size --units k $vg | tee lvs.out - grep resized lvs.out | grep 8192 -} - -# vgscan fixes up metadata -init -vgscan 2>&1 | tee cmd.out -grep "Inconsistent metadata found for VG $vg" cmd.out -vgscan 2>&1 | tee cmd.out -not grep "Inconsistent metadata found for VG $vg" cmd.out -check - -# vgdisplay fixes -init -vgdisplay 2>&1 | tee cmd.out -grep "Inconsistent metadata found for VG $vg" cmd.out -vgdisplay 2>&1 | tee cmd.out -not grep "Inconsistent metadata found for VG $vg" cmd.out -check - -# lvs fixes up -init -lvs 2>&1 | tee cmd.out -grep "Inconsistent metadata found for VG $vg" cmd.out -vgdisplay 2>&1 | tee cmd.out -not grep "Inconsistent metadata found for VG $vg" cmd.out -check - -# vgs fixes up as well -init -vgs 2>&1 | tee cmd.out -grep "Inconsistent metadata found for VG $vg" cmd.out -vgs 2>&1 | tee cmd.out -not grep "Inconsistent metadata found for VG $vg" cmd.out -check - -echo Check auto-repair of failed vgextend - metadata written to original pv but not new pv -vgremove -f $vg -pvremove -ff $devs -pvcreate $devs -backup_dev $dev2 -vgcreate $vg $dev1 -vgextend $vg $dev2 -restore_dev $dev2 -should compare_two_fields_ vgs $vg vg_mda_count pvs $dev2 vg_mda_count diff --git a/test/t-lvconvert-mirror.sh b/test/t-lvconvert-mirror.sh deleted file mode 100644 index c33196c..0000000 --- a/test/t-lvconvert-mirror.sh +++ /dev/null @@ -1,242 +0,0 @@ -#!/bin/sh -# Copyright (C) 2010 Red Hat, Inc. All rights reserved. -# -# 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. -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -. ./test-utils.sh - -# convert from linear to 2-way mirror -aux prepare_vg 5 -lvcreate -l2 -n $lv1 $vg $dev1 -lvconvert -i1 -m+1 $vg/$lv1 $dev2 $dev3:0-1 -check mirror $vg $lv1 $dev3 - -# convert from 2-way mirror to linear -aux prepare_vg 5 -lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0-1 -lvconvert -m-1 $vg/$lv1 -check linear $vg $lv1 -lvremove -ff $vg -# and now try removing a specific leg (bz453643) -lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0-1 -lvconvert -m0 $vg/$lv1 $dev2 -check lv_on $vg $lv1 $dev1 -lvremove -ff $vg - -# convert from disklog to corelog, active -aux prepare_vg 5 -lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0-1 -lvconvert -f --mirrorlog core $vg/$lv1 -check mirror $vg $lv1 core -lvremove -ff $vg - -# convert from corelog to disklog, active -aux prepare_vg 5 -lvcreate -l2 -m1 --mirrorlog core -n $lv1 $vg $dev1 $dev2 -lvconvert --mirrorlog disk $vg/$lv1 $dev3:0-1 -check mirror $vg $lv1 $dev3 -lvremove -ff $vg - -# bz192865: lvconvert log of an inactive mirror lv -# convert from disklog to corelog, inactive -aux prepare_vg 5 -lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0-1 -lvchange -an $vg/$lv1 -echo y | lvconvert -f --mirrorlog core $vg/$lv1 -check mirror $vg $lv1 core -lvremove -ff $vg - -# convert from corelog to disklog, inactive -aux prepare_vg 5 -lvcreate -l2 -m1 --mirrorlog core -n $lv1 $vg $dev1 $dev2 -lvchange -an $vg/$lv1 -lvconvert --mirrorlog disk $vg/$lv1 $dev3:0-1 -check mirror $vg $lv1 $dev3 -lvremove -ff $vg - -# convert linear to 2-way mirror with 1 PV -aux prepare_vg 5 -lvcreate -l2 -n $lv1 $vg $dev1 -not lvconvert -m+1 --mirrorlog core $vg/$lv1 $dev1 -lvremove -ff $vg - -# Start w/ 3-way mirror -# Test pulling primary image before mirror in-sync (should fail) -# Test pulling primary image after mirror in-sync (should work) -# Test that the correct devices remain in the mirror -lvcreate -l2 -m2 -n $lv1 $vg $dev1 $dev2 $dev4 $dev3:0 -# FIXME: -# This is somewhat timing dependent - sync /could/ finish before -# we get a chance to have this command fail -should not lvconvert -m-1 $vg/$lv1 $dev1 - -lvconvert $vg/$lv1 # wait -lvconvert -m2 $vg/$lv1 $dev1 $dev2 $dev4 $dev3:0 # If the above "should" failed... - -lvconvert -m-1 $vg/$lv1 $dev1 -check mirror_images_on $lv1 $dev2 $dev4 -lvconvert -m-1 $vg/$lv1 $dev2 -check linear $vg $lv1 -check lv_on $vg $lv1 $dev4 - -# No parallel lvconverts on a single LV please - -aux prepare_vg 5 -lvcreate -l5 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0 -check mirror $vg $lv1 -check mirror_legs $vg $lv1 2 -lvconvert -m+1 -b $vg/$lv1 $dev4 - -# Next convert should fail b/c we can't have 2 at once -should not lvconvert -m+1 $vg/$lv1 $dev5 -lvconvert $vg/$lv1 # wait -lvconvert -m2 $vg/$lv1 # In case the above "should" actually failed - -check mirror $vg $lv1 $dev3 -check mirror_no_temporaries $vg $lv1 -check mirror_legs $vg $lv1 3 - -# add 1 mirror to core log mirror, but -# implicitly keep log as 'core' -aux prepare_vg 5 -lvcreate -l2 -m1 --mirrorlog core -n $lv1 $vg $dev1 $dev2 -lvconvert -m +1 -i1 $vg/$lv1 - -check mirror $vg $lv1 core -check mirror_no_temporaries $vg $lv1 -check mirror_legs $vg $lv1 3 - -# remove 1 mirror from corelog'ed mirror; should retain 'core' log type -aux prepare_vg 5 -lvcreate -l2 -m2 --corelog -n $lv1 $vg -lvconvert -m -1 -i1 $vg/$lv1 - -check mirror $vg $lv1 core -check mirror_no_temporaries $vg $lv1 -check mirror_legs $vg $lv1 2 - -# add 1 mirror then add 1 more mirror during conversion -# FIXME this has been explicitly forbidden? -#aux prepare_vg 5 -#lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0 -#lvconvert -m+1 -b $vg/$lv1 $dev4 -#lvconvert -m+1 $vg/$lv1 $dev5 -# -#check mirror $vg $lv1 $dev3 -#check mirror_no_temporaries $vg $lv1 -#check mirror_legs $vg $lv1 4 - -# Linear to mirror with mirrored log using --alloc anywhere -aux prepare_vg 5 -lvcreate -l2 -n $lv1 $vg $dev1 -lvconvert -m +1 --mirrorlog mirrored $vg/$lv1 $dev1 $dev2 --alloc anywhere -should check mirror $vg $lv1 - -# convert inactive mirror and start polling -aux prepare_vg 5 -lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0 -lvchange -an $vg/$lv1 -lvconvert -m+1 $vg/$lv1 $dev4 -lvchange -ay $vg/$lv1 -lvconvert $vg/$lv1 # wait -check mirror $vg $lv1 $dev3 -check mirror_no_temporaries $vg $lv1 - -# --------------------------------------------------------------------- -# removal during conversion - -# "remove newly added mirror" -aux prepare_vg 5 -lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0 -lvconvert -m+1 -b $vg/$lv1 $dev4 -lvconvert -m-1 $vg/$lv1 $dev4 -lvconvert $vg/$lv1 # wait - -check mirror $vg $lv1 $dev3 -check mirror_no_temporaries $vg $lv1 -check mirror_legs $vg $lv1 2 - -# "remove one of newly added mirrors" -aux prepare_vg 5 -lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0 -lvconvert -m+2 -b $vg/$lv1 $dev4 $dev5 -lvconvert -m-1 $vg/$lv1 $dev4 -lvconvert $vg/$lv1 # wait - -check mirror $vg $lv1 $dev3 -check mirror_no_temporaries $vg $lv1 -check mirror_legs $vg $lv1 3 - -# "remove from original mirror (the original is still mirror)" -aux prepare_vg 5 -lvcreate -l2 -m2 -n $lv1 $vg $dev1 $dev2 $dev5 $dev3:0 -lvconvert -m+1 -b $vg/$lv1 $dev4 -lvconvert -m-1 $vg/$lv1 $dev2 -lvconvert $vg/$lv1 - -check mirror $vg $lv1 $dev3 -check mirror_no_temporaries $vg $lv1 -check mirror_legs $vg $lv1 3 - -# "remove from original mirror (the original becomes linear)" -aux prepare_vg 5 -lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0 -lvconvert -m+1 -b $vg/$lv1 $dev4 -lvconvert -m-1 $vg/$lv1 $dev2 -lvconvert $vg/$lv1 - -check mirror $vg $lv1 $dev3 -check mirror_no_temporaries $vg $lv1 -check mirror_legs $vg $lv1 2 - -# --------------------------------------------------------------------- - -# "rhbz440405: lvconvert -m0 incorrectly fails if all PEs allocated" -aux prepare_vg 5 -lvcreate -l`pvs --noheadings -ope_count $dev1` -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0 -while [ `lvs --noheadings -o copy_percent $vg/$lv1` != "100.00" ]; do sleep 1; done -lvconvert -m0 $vg/$lv1 $dev1 -check linear $vg $lv1 - -# "rhbz264241: lvm mirror doesn't lose it's "M" --nosync attribute after being down and the up converted" -aux prepare_vg 5 -lvcreate -l2 -m1 -n$lv1 --nosync $vg -lvconvert -m0 $vg/$lv1 -lvconvert -m1 $vg/$lv1 -lvs --noheadings -o attr $vg/$lv1 | grep '^ *m' - -# lvconvert from linear (on multiple PVs) to mirror -aux prepare_vg 5 -lvcreate -l 8 -n $lv1 $vg $dev1:0-3 $dev2:0-3 -lvconvert -m1 $vg/$lv1 - -should check mirror $vg $lv1 -check mirror_legs $vg $lv1 2 - -# BZ 463272: disk log mirror convert option is lost if downconvert option is also given -aux prepare_vg 5 -lvcreate -l1 -m2 --corelog -n $lv1 $vg $dev1 $dev2 $dev3 -while [ `lvs --noheadings -o copy_percent $vg/$lv1` != "100.00" ]; do sleep 1; done -lvconvert -m1 --mirrorlog disk $vg/$lv1 -check mirror $vg $lv1 -not check mirror $vg $lv1 core - -# --- -# add mirror and disk log - -# "add 1 mirror and disk log" -aux prepare_vg 5 -lvcreate -l2 -m1 --mirrorlog core -n $lv1 $vg $dev1 $dev2 - -# FIXME on next line, specifying $dev3:0 $dev4 (i.e log device first) fails (!) -lvconvert -m+1 --mirrorlog disk -i1 $vg/$lv1 $dev4 $dev3:0 - -check mirror $vg $lv1 $dev3 -check mirror_no_temporaries $vg $lv1 -check mirror_legs $vg $lv1 3 diff --git a/test/t-lvconvert-repair-replace.sh b/test/t-lvconvert-repair-replace.sh deleted file mode 100644 index 7315a0e..0000000 --- a/test/t-lvconvert-repair-replace.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/bash -# Copyright (C) 2008 Red Hat, Inc. All rights reserved. -# -# 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. -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -. ./test-utils.sh - -prepare_vg 6 - -# multiple failures, full replace -lvcreate --mirrorlog disk -m 2 --ig -L 1 -n 3way $vg $dev1 $dev2 $dev3 $dev4:0-1 -disable_dev $dev1 $dev2 -echo y | lvconvert --repair $vg/3way 2>&1 | tee 3way.out -lvs -a -o +devices | not grep unknown -not grep "WARNING: Failed" 3way.out -vgreduce --removemissing $vg -check mirror $vg 3way -enable_dev $dev1 $dev2 - -vgremove -ff $vg; vgcreate -c n $vg $dev1 $dev2 $dev3 $dev4 $dev5 - -# multiple failures, partial replace -lvcreate --mirrorlog disk -m 2 --ig -L 1 -n 3way $vg $dev1 $dev2 $dev3 $dev4 -disable_dev $dev1 $dev2 -echo y | lvconvert --repair $vg/3way 2>&1 | tee 3way.out -grep "WARNING: Failed" 3way.out -lvs -a -o +devices | not grep unknown -vgreduce --removemissing $vg -check mirror $vg 3way -enable_dev $dev1 $dev2 -lvchange -a n $vg/3way - -vgremove -ff $vg; vgcreate -c n $vg $dev1 $dev2 $dev3 - -lvcreate --mirrorlog disk -m 1 --ig -L 1 -n 2way $vg $dev1 $dev2 $dev3 -disable_dev $dev1 -echo y | lvconvert --repair $vg/2way 2>&1 | tee 2way.out -grep "WARNING: Failed" 2way.out -lvs -a -o +devices | not grep unknown -vgreduce --removemissing $vg -check mirror $vg 2way -enable_dev $dev1 $dev2 -lvchange -a n $vg/2way - -vgremove -ff $vg; vgcreate -c n $vg $dev1 $dev2 $dev3 $dev4 - -# Test repair of inactive mirror with log failure -# Replacement should fail, but covert should succeed (switch to corelog) -lvcreate -m 2 --ig -l 2 -n mirror2 $vg $dev1 $dev2 $dev3 $dev4:0 -vgchange -a n $vg -pvremove -ff -y $dev4 -echo 'y' | lvconvert -y --repair $vg/mirror2 -check mirror $vg mirror2 -vgs - diff --git a/test/t-lvconvert-repair.sh b/test/t-lvconvert-repair.sh deleted file mode 100644 index bce8b53..0000000 --- a/test/t-lvconvert-repair.sh +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/bash -# Copyright (C) 2008 Red Hat, Inc. All rights reserved. -# -# 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. -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -. ./test-utils.sh - - -# fail multiple devices - -aux prepare_vg 5 -lvcreate -m 3 --ig -L 1 -n 4way $vg $dev1 $dev2 $dev3 $dev4 $dev5:0 -disable_dev $dev2 $dev4 -echo n | lvconvert --repair $vg/4way 2>&1 | tee 4way.out -lvs -a -o +devices | not grep unknown -vgreduce --removemissing $vg -enable_dev $dev2 $dev4 -check mirror $vg 4way $dev5 - -aux prepare_vg 5 -lvcreate -m 2 --ig -L 1 -n 3way $vg -disable_dev $dev1 $dev2 -echo n | lvconvert --repair $vg/3way -check linear $vg 3way -lvs -a -o +devices | not grep unknown -lvs -a -o +devices | not grep mlog -dmsetup ls | grep $PREFIX | not grep mlog -vgreduce --removemissing $vg -enable_dev $dev1 $dev2 -check linear $vg 3way - -# fail just log and get it removed - -aux prepare_vg 5 -lvcreate -m 2 --ig -L 1 -n 3way $vg $dev1 $dev2 $dev3 $dev4:0 -disable_dev $dev4 -echo n | lvconvert --repair $vg/3way -check mirror $vg 3way core -lvs -a -o +devices | not grep unknown -lvs -a -o +devices | not grep mlog -dmsetup ls | grep $PREFIX | not grep mlog -vgreduce --removemissing $vg -enable_dev $dev4 - -aux prepare_vg 5 -lvcreate -m 1 --ig -L 1 -n 2way $vg $dev1 $dev2 $dev3:0 -disable_dev $dev3 -echo n | lvconvert --repair $vg/2way -check mirror $vg 2way core -lvs -a -o +devices | not grep unknown -lvs -a -o +devices | not grep mlog -vgreduce --removemissing $vg -enable_dev $dev3 - -# fail single devices - -aux prepare_vg 5 -vgreduce $vg $dev4 - -lvcreate -m 1 --ig -L 1 -n mirror $vg -lvchange -a n $vg/mirror -vgextend $vg $dev4 -disable_dev $dev1 -lvchange --partial -a y $vg/mirror - -not vgreduce -v --removemissing $vg -lvconvert -y --repair $vg/mirror -vgreduce --removemissing $vg - -enable_dev $dev1 -vgextend $vg $dev1 -disable_dev $dev2 -lvconvert -y --repair $vg/mirror -vgreduce --removemissing $vg - -enable_dev $dev2 -vgextend $vg $dev2 -disable_dev $dev3 -lvconvert -y --repair $vg/mirror -vgreduce --removemissing $vg -enable_dev $dev3 -vgextend $vg $dev3 -lvremove -ff $vg diff --git a/test/t-lvextend-snapshot-dmeventd.sh b/test/t-lvextend-snapshot-dmeventd.sh deleted file mode 100644 index f1ed72f..0000000 --- a/test/t-lvextend-snapshot-dmeventd.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash -# Copyright (C) 2010 Red Hat, Inc. All rights reserved. -# -# 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. -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -. ./test-utils.sh - -extend() { - lvextend --use-policies --config "activation { snapshot_extend_threshold = $1 }" $vg/snap -} - -write() { - mount $DM_DEV_DIR/$vg/snap mnt - dd if=/dev/zero of=mnt/file$1 bs=1k count=$2 - umount mnt -} - -percent() { - lvs $vg/snap -o snap_percent --noheadings | cut -c4- | cut -d. -f1 -} - -which mkfs.ext2 || exit 200 - -aux prepare_vg 2 -aux prepare_dmeventd - -lvcreate -l 8 -n base $vg -mkfs.ext2 $DM_DEV_DIR/$vg/base - -lvcreate -s -l 4 -n snap $vg/base -lvchange --monitor y $vg/snap - -mkdir mnt - -write 1 4096 -pre=`percent` -sleep 10 # dmeventd only checks every 10 seconds :( -post=`percent` - -test $pre = $post -write 2 5000 -pre=`percent` -sleep 10 # dmeventd only checks every 10 seconds :( -post=`percent` -test $pre -gt $post diff --git a/test/t-mdata-strings.sh b/test/t-mdata-strings.sh deleted file mode 100755 index 66d472a..0000000 --- a/test/t-mdata-strings.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# Copyright (C) 2008 Red Hat, Inc. All rights reserved. -# -# 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. -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -# 'Test for proper escaping of strings in metadata (bz431474)' - -. ./test-utils.sh - -aux prepare_devs 1 - -pv_ugly="__\"!@#\$%^&*,()|@||'\\\"__pv1" - -# 'set up temp files, loopback devices' -name=$(basename "$dev1") -dmsetup rename "$name" "$PREFIX$pv_ugly" -dev1=$(dirname "$dev1")/$PREFIX$pv_ugly - -# 'pvcreate, vgcreate on filename with backslashed chars' -pvcreate "$dev1" -vgcreate $vg "$dev1" - -# 'no parse errors and VG really exists' -vgs 2>err -not grep "Parse error" err; -vgs $vg - diff --git a/test/t-metadata-balance.sh b/test/t-metadata-balance.sh deleted file mode 100755 index 79570d9..0000000 --- a/test/t-metadata-balance.sh +++ /dev/null @@ -1,232 +0,0 @@ -# Copyright (C) 2008 Red Hat, Inc. All rights reserved. -# -# 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. -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -. ./test-utils.sh - -aux prepare_devs 6 - -echo Make sure we can ignore / un-ignore mdas on a per-PV basis -for pv_in_vg in 1 0; do -for mdacp in 1 2; do - pvcreate --metadatacopies $mdacp $dev1 $dev2 - pvcreate --metadatacopies 0 $dev3 - if [ $pv_in_vg = 1 ]; then - vgcreate -c n "$vg" $dev1 $dev2 $dev3 - fi - pvchange --metadataignore y $dev1 - check_pv_field_ $dev1 pv_mda_count $mdacp - check_pv_field_ $dev1 pv_mda_used_count 0 - check_pv_field_ $dev2 pv_mda_count $mdacp - check_pv_field_ $dev2 pv_mda_used_count $mdacp - if [ $pv_in_vg = 1 ]; then - check_vg_field_ $vg vg_mda_count $(($mdacp * 2)) - check_vg_field_ $vg vg_mda_used_count $mdacp - check_vg_field_ $vg vg_mda_copies unmanaged - fi - pvchange --metadataignore n $dev1 - check_pv_field_ $dev1 pv_mda_count $mdacp - check_pv_field_ $dev1 pv_mda_used_count $mdacp - if [ $pv_in_vg = 1 ]; then - check_vg_field_ $vg vg_mda_count $(($mdacp * 2)) - check_vg_field_ $vg vg_mda_used_count $(($mdacp * 2)) - check_vg_field_ $vg vg_mda_copies unmanaged - vgremove -f $vg - fi -done -done - -# Check if a PV has unignored (used) mdas, and if so, ignore -pvignore_ () { - pv_mda_used_count=$(get_pv_field "$1" pv_mda_used_count) - if [ $pv_mda_used_count -ne 0 ]; then - pvchange --metadataignore y $1 - fi -} - -# Check if a PV has ignored mdas, and if so, unignore (make used) -pvunignore_ () { - pv_mda_count=$(get_pv_field "$1" pv_mda_count) - pv_mda_used_count=$(get_pv_field "$1" pv_mda_used_count) - if [ $pv_mda_count -gt $pv_mda_used_count ]; then - pvchange --metadataignore n $1 - fi -} - -echo Test of vgmetadatacopies with vgcreate and vgchange -for mdacp in 1 2; do - pvcreate --metadatacopies $mdacp $dev1 $dev2 $dev4 $dev5 - check_pv_field_ $dev1 pv_mda_used_count $mdacp - check_pv_field_ $dev2 pv_mda_used_count $mdacp - check_pv_field_ $dev4 pv_mda_used_count $mdacp - check_pv_field_ $dev5 pv_mda_used_count $mdacp - pvcreate --metadatacopies 0 $dev3 - vgcreate -c n "$vg" $dev1 $dev2 $dev3 - check_vg_field_ $vg vg_mda_copies unmanaged - echo ensure both --vgmetadatacopies and --metadatacopies accepted - vgchange --metadatacopies $(($mdacp * 1)) $vg - echo --vgmetadatacopies is persistent on disk - echo --vgmetadatacopies affects underlying pv mda ignore - check_vg_field_ $vg vg_mda_copies $(($mdacp * 1)) - check_vg_field_ $vg vg_mda_used_count $(($mdacp * 1)) - vgchange --vgmetadatacopies $(($mdacp * 2)) $vg - check_vg_field_ $vg vg_mda_copies $(($mdacp * 2)) - check_vg_field_ $vg vg_mda_used_count $(($mdacp * 2)) - echo allow setting metadatacopies larger than number of PVs - vgchange --vgmetadatacopies $(($mdacp * 5)) $vg - check_vg_field_ $vg vg_mda_copies $(($mdacp * 5)) - check_vg_field_ $vg vg_mda_used_count $(($mdacp * 2)) - echo setting to 0 disables automatic balancing - vgchange --vgmetadatacopies unmanaged $vg - check_vg_field_ $vg vg_mda_copies unmanaged - vgremove -f $vg - echo vgcreate succeeds even when creating a VG w/all ignored mdas - pvchange --metadataignore y $dev1 $dev2 - check_pv_field_ $dev1 pv_mda_count $mdacp - check_pv_field_ $dev2 pv_mda_used_count 0 - vgcreate -c n "$vg" $dev1 $dev2 - check_vg_field_ $vg vg_mda_copies unmanaged - vgremove -f $vg - echo vgcreate succeeds with a specific number of metadata copies - vgcreate -c n --vgmetadatacopies $(($mdacp * 2)) "$vg" $dev1 $dev2 - check_vg_field_ $vg vg_mda_copies $(($mdacp * 2)) - vgremove -f $vg - vgcreate -c n --vgmetadatacopies $(($mdacp * 1)) "$vg" $dev1 $dev2 - check_vg_field_ $vg vg_mda_copies $(($mdacp * 1)) - vgremove -f $vg - echo vgcreate succeeds with a larger value than total metadatacopies - vgcreate -c n --vgmetadatacopies $(($mdacp * 5)) "$vg" $dev1 $dev2 - check_vg_field_ $vg vg_mda_copies $(($mdacp * 5)) - vgremove -f $vg - echo vgcreate succeeds with --vgmetadatacopies unmanaged - vgcreate -c n --vgmetadatacopies unmanaged "$vg" $dev1 $dev2 - check_vg_field_ $vg vg_mda_copies unmanaged - vgremove -f $vg - pvunignore_ $dev1 - pvunignore_ $dev2 - pvunignore_ $dev4 - pvunignore_ $dev5 - echo vgcreate succeds with small value of --metadatacopies, ignores mdas - vgcreate -c n --vgmetadatacopies 1 "$vg" $dev1 $dev2 $dev4 $dev5 - check_vg_field_ $vg vg_mda_copies 1 - check_vg_field_ $vg vg_mda_count $(($mdacp * 4)) - check_vg_field_ $vg vg_mda_used_count 1 - echo Setting a larger value should trigger non-ignore of mdas - vgchange --metadatacopies 3 $vg - check_vg_field_ $vg vg_mda_copies 3 - check_vg_field_ $vg vg_mda_used_count 3 - echo Setting all should trigger unignore of all mdas - vgchange --vgmetadatacopies all $vg - check_vg_field_ $vg vg_mda_count $(($mdacp * 4)) - check_vg_field_ $vg vg_mda_copies unmanaged - check_vg_field_ $vg vg_mda_used_count $(($mdacp * 4)) - echo --vgmetadatacopies 0 should be unmanaged for vgchange and vgcreate - vgchange --vgmetadatacopies 0 $vg - check_vg_field_ $vg vg_mda_copies unmanaged - vgremove -f $vg - vgcreate -c n --vgmetadatacopies 0 "$vg" $dev1 $dev2 $dev4 $dev5 - check_vg_field_ $vg vg_mda_copies unmanaged - vgremove -f $vg -done - -echo Test vgextend / vgreduce with vgmetadatacopies -for mdacp in 1 2; do - pvcreate --metadatacopies $mdacp $dev1 $dev2 $dev4 $dev5 - pvcreate --metadatacopies 0 $dev3 - echo Set a large value of vgmetadatacopies - vgcreate -c n --vgmetadatacopies $(($mdacp * 5)) "$vg" $dev1 $dev2 $dev3 - check_vg_field_ $vg vg_mda_copies $(($mdacp * 5)) - echo Ignore mdas on devices to be used for vgextend - echo Large value of vgetadatacopies should automatically un-ignore mdas - pvchange --metadataignore y $dev4 $dev5 - check_pv_field_ $dev4 pv_mda_used_count 0 - vgextend $vg $dev4 $dev5 - check_pv_field_ $dev4 pv_mda_used_count $mdacp - check_pv_field_ $dev5 pv_mda_used_count $mdacp - vgremove -f $vg - echo Set a small value of vgmetadatacopies - vgcreate -c n --vgmetadatacopies $(($mdacp * 1)) "$vg" $dev1 $dev2 $dev3 - check_vg_field_ $vg vg_mda_copies $(($mdacp * 1)) - echo Ignore mdas on devices to be used for vgextend - echo Small value of vgetadatacopies should leave mdas as ignored - pvchange --metadataignore y $dev4 $dev5 - check_pv_field_ $dev4 pv_mda_used_count 0 - vgextend $vg $dev4 $dev5 - check_pv_field_ $dev4 pv_mda_used_count 0 - check_pv_field_ $dev5 pv_mda_used_count 0 - echo vgreduce of ignored pv w/mda should not trigger any change to ignore bits - vgreduce $vg $dev4 - check_pv_field_ $dev4 pv_mda_used_count 0 - check_pv_field_ $dev5 pv_mda_used_count 0 - echo vgreduce of un-ignored pv w/mda should trigger un-ignore on an mda - vgreduce $vg $dev1 $dev2 $dev3 - check_pv_field_ $dev5 pv_mda_used_count $mdacp - check_vg_field_ $vg vg_mda_copies $(($mdacp * 1)) - pvunignore_ $dev1 - pvunignore_ $dev2 - echo setting vgmetadatacopies to unmanaged should allow vgextend to add w/out balancing - vgchange --vgmetadatacopies unmanaged $vg - vgextend $vg $dev1 $dev2 - check_vg_field_ $vg vg_mda_copies unmanaged - check_vg_field_ $vg vg_mda_count $(($mdacp * 3)) - check_vg_field_ $vg vg_mda_used_count $((mdacp * 3)) - check_pv_field_ $dev1 pv_mda_used_count $mdacp - check_pv_field_ $dev2 pv_mda_used_count $mdacp - vgremove -f $vg -done - -echo Test special situations, vgsplit, vgmerge, etc -for mdacp in 1 2; do - pvcreate --metadatacopies $mdacp $dev1 $dev2 $dev3 $dev4 $dev5 - vgcreate -c n --vgmetadatacopies 2 $vg1 $dev1 $dev2 $dev3 - vgcreate -c n --vgmetadatacopies $(($mdacp * 1)) $vg2 $dev4 $dev5 - echo vgsplit/vgmerge preserves value of metadata copies - check_vg_field_ $vg1 vg_mda_copies 2 - check_vg_field_ $vg2 vg_mda_copies $(($mdacp * 1)) - vgsplit $vg1 $vg2 $dev1 - check_vg_field_ $vg2 vg_mda_copies $(($mdacp * 1)) - vgmerge $vg1 $vg2 - check_vg_field_ $vg1 vg_mda_copies 2 - check_vg_field_ $vg1 vg_mda_count $(($mdacp * 5)) - echo vgsplit into new vg sets proper value of vgmetadatacopies - vgsplit --vgmetadatacopies $(($mdacp * 2)) $vg1 $vg2 $dev1 $dev2 - check_vg_field_ $vg2 vg_mda_copies $(($mdacp * 2)) - echo vgchange fails if given both vgmetadatacopies and metadatacopies - not vgchange --vgmetadatacopies 5 --metadatacopies 7 $vg2 - vgremove -f $vg1 - vgremove -f $vg2 -done - -echo Test combination of --vgmetadatacopies and pvchange --metadataignore -for mdacp in 1 2; do - pvcreate --metadatacopies $mdacp $dev1 $dev2 $dev3 $dev4 $dev5 - vgcreate -c n --vgmetadatacopies $(($mdacp * 1)) $vg1 $dev1 $dev2 - check_vg_field_ $vg1 vg_mda_copies $(($mdacp * 1)) - check_vg_field_ $vg1 vg_mda_used_count $(($mdacp * 1)) - pvignore_ $dev3 - echo Ensure vgextend of PVs with ignored MDAs does not add to vg_mda_used_count - vgextend $vg1 $dev3 - check_vg_field_ $vg1 vg_mda_used_count $(($mdacp * 1)) - echo Using pvchange to unignore should update vg_mda_used_count - pvchange -f --metadataignore n $dev3 - check_pv_field_ $dev3 pv_mda_used_count $mdacp - check_vg_field_ $vg1 vg_mda_used_count $(($mdacp * 2)) - echo Set unmanaged on the vg should keep ignore bits the same during vgextend - vgchange --vgmetadatacopies unmanaged $vg1 - check_vg_field_ $vg1 vg_mda_used_count $(($mdacp * 2)) - pvunignore_ $dev4 - vgextend $vg1 $dev4 - check_pv_field_ $dev4 pv_mda_used_count $mdacp - check_vg_field_ $vg1 vg_mda_used_count $(($mdacp * 3)) - echo Using pvchange to ignore should update vg_mda_used_count - pvchange -f --metadataignore y $dev4 - check_pv_field_ $dev4 pv_mda_used_count 0 - check_vg_field_ $vg1 vg_mda_used_count $(($mdacp * 2)) - vgremove -f $vg1 -done diff --git a/test/t-mirror-names.sh b/test/t-mirror-names.sh deleted file mode 100644 index be6045f..0000000 --- a/test/t-mirror-names.sh +++ /dev/null @@ -1,156 +0,0 @@ -#!/bin/sh -# Copyright (C) 2007-2008 Red Hat, Inc. All rights reserved. -# Copyright (C) 2007-2008 NEC Corporation -# -# 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. -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -test_description="check namings of mirrored LV" - -. ./test-utils.sh - -# --------------------------------------------------------------------- -# Utilities - -lv_devices_() { - local d - local lv=$1 - shift - local devices=$* - - local devs=$(lvs -a -odevices --noheadings $lv | sed 's/([0-9]*)//g' | - sed 's/ //g' | sed 's/,/ /g') - - for d in $devs; do - (echo $devices | grep -q $d) || return 1 - devices=$(echo $devices | sed "s/$d//") - done - - [ "$(echo $devices | sed 's/ //g')" = "" ] -} - -lv_mirror_log_() { - local lv=$1 - - echo $(lvs -a -omirror_log --noheadings $lv | sed 's/ //g') -} - -lv_convert_lv_() { - local lv=$1 - - echo $(lvs -a -oconvert_lv --noheadings $lv | sed 's/ //g') -} - -# --------------------------------------------------------------------- -# Initialize PVs and VGs - -aux prepare_vg 5 80 - -# --------------------------------------------------------------------- -# Common environment setup/cleanup for each sub testcases - -prepare_lvs_() { - lvremove -ff $vg - if dmsetup table|grep $vg; then - echo "ERROR: lvremove did leave some some mappings in DM behind!" - return 1 - fi - : -} - -check_and_cleanup_lvs_() { - lvs -a -o+devices $vg - lvremove -ff $vg - if dmsetup table|grep $vg; then - echo "ERROR: lvremove did leave some some mappings in DM behind!" - return 1 - fi -} - -prepare_lvs_ -check_and_cleanup_lvs_ - -# --------------------------------------------------------------------- -# basic - -#COMM "init: lvcreate" -prepare_lvs_ - -#COMM "mirror images are ${lv1}_mimage_x" -lvcreate -l2 -m1 -n $lv1 $vg -lv_devices_ $vg/$lv1 "$lv1"_mimage_0 "$lv1"_mimage_1 - -#COMM "mirror log is ${lv1}_mlog" -lv_mirror_log_ $vg/$lv1 "$lv1"_mlog - -# "cleanup" -check_and_cleanup_lvs_ - -#COMM "mirror with name longer than 22 characters (bz221322)" -name="LVwithanamelogerthan22characters_butidontwonttocounthem" -lvcreate -m1 -l2 -n"$name" $vg -lvs $vg/"$name" -check_and_cleanup_lvs_ - -# --------------------------------------------------------------------- -# lvrename - -#COMM "init: lvrename" -prepare_lvs_ - -#COMM "renamed mirror names: $lv1 to $lv2" -lvcreate -l2 -m1 -n $lv1 $vg -lvrename $vg/$lv1 $vg/$lv2 -lv_devices_ $vg/$lv2 "$lv2"_mimage_0 "$lv2"_mimage_1 -lv_mirror_log_ $vg/$lv2 "$lv2"_mlog - -#COMM "cleanup" -check_and_cleanup_lvs_ - -# --------------------------------------------------------------------- -# lvconvert - -#COMM "init: lvconvert" -prepare_lvs_ - -#COMM "converting mirror names is ${lv1}_mimagetmp_2" -lvcreate -l2 -m1 -n $lv1 $vg -lvconvert -m+1 -i+10 -b $vg/$lv1 -convlv=$(lv_convert_lv_ "$vg/$lv1") -test "$convlv" = "$lv1"_mimagetmp_2 -lv_devices_ $vg/$lv1 "$convlv" "$lv1"_mimage_2 -lv_devices_ "$vg/$convlv" "$lv1"_mimage_0 "$lv1"_mimage_1 -loglv=$(lv_mirror_log_ "$vg/$convlv") -test "$loglv" = "$lv1"_mlog - -#COMM "mirror log name after re-adding is ${lv1}_mlog" \ -lvconvert --mirrorlog core $vg/$lv1 -lvconvert --mirrorlog disk $vg/$lv1 -convlv=$(lv_convert_lv_ "$vg/$lv1") -lv_devices_ $vg/$lv1 "$convlv" "$lv1"_mimage_2 -lv_devices_ "$vg/$convlv" "$lv1"_mimage_0 "$lv1"_mimage_1 -loglv=$(lv_mirror_log_ "$vg/$convlv") -test "$loglv" = "$lv1"_mlog - -#COMM "renamed converting mirror names: $lv1 to $lv2" \ -lvrename $vg/$lv1 $vg/$lv2 -convlv=$(lv_convert_lv_ "$vg/$lv2") -lv_devices_ $vg/$lv2 "$convlv" "$lv2"_mimage_2 -lv_devices_ "$vg/$convlv" "$lv2"_mimage_0 "$lv2"_mimage_1 -loglv=$(lv_mirror_log_ "$vg/$convlv") -test "$loglv" = "$lv2"_mlog - -#COMM "cleanup" -check_and_cleanup_lvs_ - -# Temporary mirror log should have "_mlogtmp_<n>" suffix -# but currently lvconvert doesn't have an option to add the log. -# If such feature is added in future, a test for that should -# be added. - -# --------------------------------------------------------------------- diff --git a/test/t-pvchange-usage.sh b/test/t-pvchange-usage.sh deleted file mode 100755 index 0f69249..0000000 --- a/test/t-pvchange-usage.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/sh -# Copyright (C) 2008 Red Hat, Inc. All rights reserved. -# -# 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. -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -# 'Test pvchange option values' - -. ./test-utils.sh - -aux prepare_devs 4 - -for mda in 0 1 2 -do -# "setup pv with metadatacopies = $mda" - pvcreate $dev4 - pvcreate --metadatacopies $mda $dev1 - vgcreate $vg1 $dev1 $dev4 - -# "pvchange adds/dels tag to pvs with metadatacopies = $mda " - pvchange $dev1 --addtag test$mda - check_pv_field_ $dev1 pv_tags test$mda - pvchange $dev1 --deltag test$mda - check_pv_field_ $dev1 pv_tags "" - -# "vgchange disable/enable allocation for pvs with metadatacopies = $mda (bz452982)" - pvchange $dev1 -x n - check_pv_field_ $dev1 pv_attr -- - pvchange $dev1 -x y - check_pv_field_ $dev1 pv_attr a- - -# 'remove pv' - vgremove $vg1 - pvremove $dev1 $dev4 -done - -# "pvchange uuid" -pvcreate --metadatacopies 0 $dev1 -pvcreate --metadatacopies 2 $dev2 -vgcreate $vg1 $dev1 $dev2 -pvchange -u $dev1 -pvchange -u $dev2 -vg_validate_pvlv_counts_ $vg1 2 0 0 -pvchange -u --all -vg_validate_pvlv_counts_ $vg1 2 0 0 - -# "pvchange rejects uuid change under an active lv" -lvcreate -l 16 -i 2 -n $lv --alloc anywhere $vg1 -vg_validate_pvlv_counts_ $vg1 2 1 0 -not pvchange -u $dev1 -lvchange -an "$vg1"/"$lv" -pvchange -u $dev1 - -# "cleanup" -lvremove -f "$vg1"/"$lv" -vgremove $vg1 - -# "pvchange reject --addtag to lvm1 pv" -pvcreate -M1 $dev1 -not pvchange $dev1 --addtag test - diff --git a/test/t-pvcreate-operation.sh b/test/t-pvcreate-operation.sh deleted file mode 100755 index 2c94696..0000000 --- a/test/t-pvcreate-operation.sh +++ /dev/null @@ -1,121 +0,0 @@ -# Copyright (C) 2008 Red Hat, Inc. All rights reserved. -# -# 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. -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -. ./test-utils.sh - -aux prepare_devs 4 - -for mdatype in 1 2 -do -# pvcreate (lvm$mdatype) refuses to overwrite an mounted filesystem (bz168330) - test ! -d $TESTDIR/mnt && mkdir $TESTDIR/mnt - if mke2fs $dev1; then - mount $dev1 $TESTDIR/mnt - not pvcreate -M$mdatype $dev1 2>err - grep "Can't open $dev1 exclusively. Mounted filesystem?" err - umount $dev1 - fi - -# pvcreate (lvm$mdatype) succeeds when run repeatedly (pv not in a vg) (bz178216) - pvcreate -M$mdatype $dev1 - pvcreate -M$mdatype $dev1 - pvremove -f $dev1 - -# pvcreate (lvm$mdatype) fails when PV belongs to VG" \ - pvcreate -M$mdatype $dev1 - vgcreate -M$mdatype $vg1 $dev1 - not pvcreate -M$mdatype $dev1 - - vgremove -f $vg1 - pvremove -f $dev1 - -# pvcreate (lvm$mdatype) fails when PV1 does and PV2 does not belong to VG - pvcreate -M$mdatype $dev1 - pvcreate -M$mdatype $dev2 - vgcreate -M$mdatype $vg1 $dev1 - -# pvcreate a second time on $dev2 and $dev1 - not pvcreate -M$mdatype $dev2 $dev1 - - vgremove -f $vg1 - pvremove -f $dev2 - pvremove -f $dev1 - -# NOTE: Force pvcreate after test completion to ensure clean device -#test_expect_success \ -# "pvcreate (lvm$mdatype) fails on md component device" \ -# 'mdadm -C -l raid0 -n 2 /dev/md0 $dev1 $dev2 && -# pvcreate -M$mdatype $dev1; -# status=$?; echo status=$status; test $status != 0 && -# mdadm --stop /dev/md0 && -# pvcreate -ff -y -M$mdatype $dev1 $dev2 && -# pvremove -f $dev1 $dev2' -done - -# pvcreate (lvm2) fails without -ff when PV with metadatacopies=0 belongs to VG -pvcreate --metadatacopies 0 $dev1 -pvcreate --metadatacopies 1 $dev2 -vgcreate $vg1 $dev1 $dev2 -not pvcreate $dev1 -vgremove -f $vg1 -pvremove -f $dev2 -pvremove -f $dev1 - -# pvcreate (lvm2) succeeds with -ff when PV with metadatacopies=0 belongs to VG -pvcreate --metadatacopies 0 $dev1 -pvcreate --metadatacopies 1 $dev2 -vgcreate $vg1 $dev1 $dev2 -pvcreate -ff -y $dev1 -vgreduce --removemissing $vg1 -vgremove -ff $vg1 -pvremove -f $dev2 -pvremove -f $dev1 - -for i in 0 1 2 3 -do -# pvcreate (lvm2) succeeds writing LVM label at sector $i - pvcreate --labelsector $i $dev1 - dd if=$dev1 bs=512 skip=$i count=1 2>/dev/null | strings | grep -q LABELONE; - pvremove -f $dev1 -done - -# pvcreate (lvm2) fails writing LVM label at sector 4 -not pvcreate --labelsector 4 $dev1 - -backupfile=$PREFIX.mybackupfile -uuid1=freddy-fred-fred-fred-fred-fred-freddy -uuid2=freddy-fred-fred-fred-fred-fred-fredie -bogusuuid=fred - -# pvcreate rejects uuid option with less than 32 characters -not pvcreate --norestorefile --uuid $bogusuuid $dev1 - -# pvcreate rejects uuid option without restorefile -not pvcreate --uuid $uuid1 $dev1 - -# pvcreate rejects uuid already in use -pvcreate --norestorefile --uuid $uuid1 $dev1 -not pvcreate --norestorefile --uuid $uuid1 $dev2 - -# pvcreate rejects non-existent file given with restorefile -not pvcreate --uuid $uuid1 --restorefile $backupfile $dev1 - -# pvcreate rejects restorefile with uuid not found in file -pvcreate --norestorefile --uuid $uuid1 $dev1 -vgcfgbackup -f $backupfile -not pvcreate --uuid $uuid2 --restorefile $backupfile $dev2 - -# pvcreate wipes swap signature when forced -dd if=/dev/zero of=$dev1 bs=1024 count=64 -mkswap $dev1 -blkid -c /dev/null $dev1 | grep "swap" -pvcreate -f $dev1 -# blkid cannot make up its mind whether not finding anything it knows is a failure or not -(blkid -c /dev/null $dev1 || true) | not grep "swap" diff --git a/test/t-pvmove-basic.sh b/test/t-pvmove-basic.sh deleted file mode 100755 index 44b533c..0000000 --- a/test/t-pvmove-basic.sh +++ /dev/null @@ -1,374 +0,0 @@ -#!/bin/sh -# Copyright (C) 2008 Red Hat, Inc. All rights reserved. -# Copyright (C) 2007 NEC Corporation -# -# 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. -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -test_description="ensure that pvmove works with basic options" - -. ./test-utils.sh - -# --------------------------------------------------------------------- -# Utilities - -lvdev_() { - echo "$DM_DEV_DIR/$1/$2" -} - -lv_is_on_() { - local lv=$1 #allready vg/lv - shift 1 - lvs -a -odevices --noheadings $lv | sed 's/,/\n/g' > out -#is on all specified devs - for d in $*; do grep "$d(" out; done -#isn't on any other dev (we are set -e remember) - for d in $*; do ! grep -v "$d(" out; done - return 0 -} - -save_dev_sum_() { - mkfs.ext3 $1 > /dev/null && md5sum $1 > md5.$(basename $1) -} - -check_dev_sum_() { - md5sum $1 > md5.tmp && cmp md5.$(basename $1) md5.tmp -} - -# --------------------------------------------------------------------- -# Initialize PVs and VGs - -aux prepare_vg 5 80 - -# --------------------------------------------------------------------- -# Common environment setup/cleanup for each sub testcases - -prepare_lvs_() { - lvcreate -l2 -n $lv1 $vg $dev1 - lv_is_on_ $vg/$lv1 $dev1 - lvcreate -l9 -i3 -n $lv2 $vg $dev2 $dev3 $dev4 - lv_is_on_ $vg/$lv2 $dev2 $dev3 $dev4 - lvextend -l+2 $vg/$lv1 $dev2 - lv_is_on_ $vg/$lv1 $dev1 $dev2 - lvextend -l+2 $vg/$lv1 $dev3 - lv_is_on_ $vg/$lv1 $dev1 $dev2 $dev3 - lvextend -l+2 $vg/$lv1 $dev1 - lv_is_on_ $vg/$lv1 $dev1 $dev2 $dev3 $dev1 - lvcreate -l1 -n $lv3 $vg $dev2 - lv_is_on_ $vg/$lv3 $dev2 - save_dev_sum_ $(lvdev_ $vg $lv1) - save_dev_sum_ $(lvdev_ $vg $lv2) - save_dev_sum_ $(lvdev_ $vg $lv3) - lvs -a -o devices --noheadings $vg/$lv1 > ${lv1}_devs - lvs -a -o devices --noheadings $vg/$lv2 > ${lv2}_devs - lvs -a -o devices --noheadings $vg/$lv3 > ${lv3}_devs -} - -lv_not_changed_() { - lvs -a -o devices --noheadings $1 > out - diff $(basename $1)_devs out -} - -check_and_cleanup_lvs_() { - lvs -a -o+devices $vg - check_dev_sum_ $(lvdev_ $vg $lv1) - check_dev_sum_ $(lvdev_ $vg $lv2) - check_dev_sum_ $(lvdev_ $vg $lv3) - lvs -a -o name $vg > out && ! grep ^pvmove out - lvremove -ff $vg - if ! dmsetup table|not grep $vg; then - echo "ERROR: lvremove did leave some some mappings in DM behind!" && \ - return 1 - fi - : -} - -#COMM "check environment setup/cleanup" -prepare_lvs_ -check_and_cleanup_lvs_ - -# --------------------------------------------------------------------- -# pvmove tests - -# --- -# filter by LV - -#COMM "only specified LV is moved: from pv2 to pv5 only for lv1" -prepare_lvs_ -pvmove -i1 -n $vg/$lv1 $dev2 $dev5 -lv_is_on_ $vg/$lv1 $dev1 $dev5 $dev3 $dev1 -lv_not_changed_ $vg/$lv2 -lv_not_changed_ $vg/$lv3 -check_and_cleanup_lvs_ - -# --- -# segments in a LV - -#COMM "the 1st seg of 3-segs LV is moved: from pv1 of lv1 to pv4" -prepare_lvs_ -pvmove -i1 -n $vg/$lv1 $dev1 $dev4 -lv_is_on_ $vg/$lv1 $dev4 $dev2 $dev3 $dev4 -lv_not_changed_ $vg/$lv2 -lv_not_changed_ $vg/$lv3 -check_and_cleanup_lvs_ - -#COMM "the 2nd seg of 3-segs LV is moved: from pv2 of lv1 to pv4" -prepare_lvs_ -pvmove -i1 -n $vg/$lv1 $dev2 $dev4 -lv_is_on_ $vg/$lv1 $dev1 $dev4 $dev3 $dev1 -lv_not_changed_ $vg/$lv2 -lv_not_changed_ $vg/$lv3 -check_and_cleanup_lvs_ - -#COMM "the 3rd seg of 3-segs LV is moved: from pv3 of lv1 to pv4" -prepare_lvs_ -pvmove -i1 -n $vg/$lv1 $dev3 $dev4 -lv_is_on_ $vg/$lv1 $dev1 $dev2 $dev4 $dev1 -lv_not_changed_ $vg/$lv2 -lv_not_changed_ $vg/$lv3 -check_and_cleanup_lvs_ - -# --- -# multiple LVs matching - -#COMM "1 out of 3 LVs is moved: from pv4 to pv5" -prepare_lvs_ -pvmove -i1 $dev4 $dev5 -lv_not_changed_ $vg/$lv1 -lv_is_on_ $vg/$lv2 $dev2 $dev3 $dev5 -lv_not_changed_ $vg/$lv3 -check_and_cleanup_lvs_ - -#COMM "2 out of 3 LVs are moved: from pv3 to pv5" -prepare_lvs_ -pvmove -i1 $dev3 $dev5 -lv_is_on_ $vg/$lv1 $dev1 $dev2 $dev5 $dev1 -lv_is_on_ $vg/$lv2 $dev2 $dev5 $dev4 -lv_not_changed_ $vg/$lv3 -check_and_cleanup_lvs_ - -#COMM "3 out of 3 LVs are moved: from pv2 to pv5" -prepare_lvs_ -pvmove -i1 $dev2 $dev5 -lv_is_on_ $vg/$lv1 $dev1 $dev5 $dev3 $dev1 -lv_is_on_ $vg/$lv2 $dev5 $dev3 $dev4 -lv_is_on_ $vg/$lv3 $dev5 -check_and_cleanup_lvs_ - -# --- -# areas of striping - -#COMM "move the 1st stripe: from pv2 of lv2 to pv1" -prepare_lvs_ -pvmove -i1 -n $vg/$lv2 $dev2 $dev1 -lv_not_changed_ $vg/$lv1 -lv_is_on_ $vg/$lv2 $dev1 $dev3 $dev4 -lv_not_changed_ $vg/$lv3 -check_and_cleanup_lvs_ - -#COMM "move the 2nd stripe: from pv3 of lv2 to pv1" -prepare_lvs_ -pvmove -i1 -n $vg/$lv2 $dev3 $dev1 -lv_not_changed_ $vg/$lv1 -lv_is_on_ $vg/$lv2 $dev2 $dev1 $dev4 -lv_not_changed_ $vg/$lv3 -check_and_cleanup_lvs_ - -#COMM "move the 3rd stripe: from pv4 of lv2 to pv1" -prepare_lvs_ -pvmove -i1 -n $vg/$lv2 $dev4 $dev1 -lv_not_changed_ $vg/$lv1 -lv_is_on_ $vg/$lv2 $dev2 $dev3 $dev1 -lv_not_changed_ $vg/$lv3 -check_and_cleanup_lvs_ - -# --- -# partial segment match (source segment splitted) - -#COMM "match to the start of segment:from pv2:0-0 to pv5" -prepare_lvs_ -pvmove -i1 $dev2:0-0 $dev5 -lv_not_changed_ $vg/$lv1 -lv_is_on_ $vg/$lv2 $dev5 $dev2 $dev3 $dev4 -lv_not_changed_ $vg/$lv3 -check_and_cleanup_lvs_ - -#COMM "match to the middle of segment: from pv2:1-1 to pv5" -prepare_lvs_ -pvmove -i1 $dev2:1-1 $dev5 -lv_not_changed_ $vg/$lv1 -lv_is_on_ $vg/$lv2 $dev2 $dev5 $dev2 $dev3 $dev4 -lv_not_changed_ $vg/$lv3 -check_and_cleanup_lvs_ - -#COMM "match to the end of segment: from pv2:2-2 to pv5" -prepare_lvs_ -pvmove -i1 $dev2:2-2 $dev5 -lv_not_changed_ $vg/$lv1 -lv_is_on_ $vg/$lv2 $dev2 $dev5 $dev3 $dev4 -lv_not_changed_ $vg/$lv3 -check_and_cleanup_lvs_ - -# --- -# destination segment splitted - -#COMM "no destination split: from pv2:0-2 to pv5" -prepare_lvs_ -pvmove -i1 $dev2:0-2 $dev5 -lv_not_changed_ $vg/$lv1 -lv_is_on_ $vg/$lv2 $dev5 $dev3 $dev4 -lv_not_changed_ $vg/$lv3 -check_and_cleanup_lvs_ - -#COMM "destination split into 2: from pv2:0-2 to pv5:5-5 and pv4:5-6" -prepare_lvs_ -pvmove -i1 --alloc anywhere $dev2:0-2 $dev5:5-5 $dev4:5-6 -lv_not_changed_ $vg/$lv1 -lv_is_on_ $vg/$lv2 $dev5 $dev4 $dev3 $dev4 -lv_not_changed_ $vg/$lv3 -check_and_cleanup_lvs_ - -#COMM "destination split into 3: from pv2:0-2 to {pv3,4,5}:5-5" -prepare_lvs_ -pvmove -i1 --alloc anywhere $dev2:0-2 $dev3:5-5 $dev4:5-5 $dev5:5-5 -lv_not_changed_ $vg/$lv1 -lv_is_on_ $vg/$lv2 $dev3 $dev4 $dev5 $dev3 $dev4 -lv_not_changed_ $vg/$lv3 -check_and_cleanup_lvs_ - -# --- -# alloc policy (anywhere, contiguous) with both success and failure cases - -#COMM "alloc normal on same PV for source and destination: from pv3:0-2 to pv3:5-7" -prepare_lvs_ -not pvmove -i1 $dev3:0-2 $dev3:5-7 -# "(cleanup previous test)" -lv_not_changed_ $vg/$lv1 -lv_not_changed_ $vg/$lv2 -lv_not_changed_ $vg/$lv3 -check_and_cleanup_lvs_ - -#COMM "alloc anywhere on same PV for source and destination: from pv3:0-2 to pv3:5-7" -prepare_lvs_ -pvmove -i1 --alloc anywhere $dev3:0-2 $dev3:5-7 -lv_not_changed_ $vg/$lv1 -lv_is_on_ $vg/$lv2 $dev2 $dev3 $dev4 -lv_not_changed_ $vg/$lv3 -check_and_cleanup_lvs_ - -#COMM "alloc anywhere but better area available: from pv3:0-2 to pv3:5-7 or pv5:5-6,pv4:5-5" -prepare_lvs_ -pvmove -i1 --alloc anywhere $dev3:0-2 $dev3:5-7 $dev5:5-6 $dev4:5-5 -lv_not_changed_ $vg/$lv1 -#lv_is_on_ $vg/$lv2 $dev2 $dev5 $dev4 $dev4 -lv_not_changed_ $vg/$lv3 -check_and_cleanup_lvs_ - -#COMM "alloc contiguous but area not available: from pv2:0-2 to pv5:5-5 and pv4:5-6" -prepare_lvs_ -not pvmove -i1 --alloc contiguous $dev2:0-2 $dev5:5-5 $dev4:5-6 -# "(cleanup previous test)" -lv_not_changed_ $vg/$lv1 -lv_not_changed_ $vg/$lv2 -lv_not_changed_ $vg/$lv3 -check_and_cleanup_lvs_ - -#COMM "alloc contiguous and contiguous area available: from pv2:0-2 to pv5:0-0,pv5:3-5 and pv4:5-6" -prepare_lvs_ -pvmove -i1 --alloc contiguous $dev2:0-2 $dev5:0-0 $dev5:3-5 $dev4:5-6 -lv_not_changed_ $vg/$lv1 -lv_is_on_ $vg/$lv2 $dev5 $dev3 $dev4 -lv_not_changed_ $vg/$lv3 -check_and_cleanup_lvs_ - -# --- -# multiple segments in a LV - -#COMM "multiple source LVs: from pv3 to pv5" -prepare_lvs_ -pvmove -i1 $dev3 $dev5 -lv_is_on_ $vg/$lv1 $dev1 $dev2 $dev5 -lv_is_on_ $vg/$lv2 $dev2 $dev5 $dev4 -lv_not_changed_ $vg/$lv3 -check_and_cleanup_lvs_ - -# --- -# move inactive LV - -#COMM "move inactive LV: from pv2 to pv5" -prepare_lvs_ -lvchange -an $vg/$lv1 -lvchange -an $vg/$lv3 -pvmove -i1 $dev2 $dev5 -lv_is_on_ $vg/$lv1 $dev1 $dev5 $dev3 -lv_is_on_ $vg/$lv2 $dev5 $dev3 $dev4 -lv_is_on_ $vg/$lv3 $dev5 -check_and_cleanup_lvs_ - -# --- -# other failure cases - -#COMM "no PEs to move: from pv3 to pv1" -prepare_lvs_ -pvmove -i1 $dev3 $dev1 -not pvmove -i1 $dev3 $dev1 -# "(cleanup previous test)" -lv_is_on_ $vg/$lv1 $dev1 $dev2 $dev1 -lv_is_on_ $vg/$lv2 $dev2 $dev1 $dev4 -lv_not_changed_ $vg/$lv3 -check_and_cleanup_lvs_ - -#COMM "no space available: from pv2:0-0 to pv1:0-0" -prepare_lvs_ -not pvmove -i1 $dev2:0-0 $dev1:0-0 -# "(cleanup previous test)" -lv_not_changed_ $vg/$lv1 -lv_not_changed_ $vg/$lv2 -lv_not_changed_ $vg/$lv3 -check_and_cleanup_lvs_ - -#COMM 'same source and destination: from pv1 to pv1' -prepare_lvs_ -not pvmove -i1 $dev1 $dev1 -#"(cleanup previous test)" -lv_not_changed_ $vg/$lv1 -lv_not_changed_ $vg/$lv2 -lv_not_changed_ $vg/$lv3 -check_and_cleanup_lvs_ - -#COMM "sum of specified destination PEs is large enough, but it includes source PEs and the free PEs are not enough" -prepare_lvs_ -not pvmove --alloc anywhere $dev1:0-2 $dev1:0-2 $dev5:0-0 2> err -#"(cleanup previous test)" -grep "Insufficient free space" err -lv_not_changed_ $vg/$lv1 -lv_not_changed_ $vg/$lv2 -lv_not_changed_ $vg/$lv3 -check_and_cleanup_lvs_ - -# --------------------------------------------------------------------- - -#COMM "pvmove abort" -prepare_lvs_ -pvmove -i100 -b $dev1 $dev3 -pvmove --abort -check_and_cleanup_lvs_ - -#COMM "pvmove out of --metadatacopies 0 PV (bz252150)" -vgremove -ff $vg -pvcreate $devs -pvcreate --metadatacopies 0 $dev1 $dev2 -vgcreate -c n $vg $devs -lvcreate -l4 -n $lv1 $vg $dev1 -pvmove $dev1 - -#COMM "pvmove fails activating mirror, properly restores state before pvmove" -dmsetup create "$vg-pvmove0" --notable -not pvmove -i 1 $dev2 -test $(dmsetup info --noheadings -c -o suspended "$vg-$lv1") = "Active" -dmsetup remove "$vg-pvmove0" diff --git a/test/t-snapshot-autoumount-dmeventd.sh b/test/t-snapshot-autoumount-dmeventd.sh deleted file mode 100644 index 32659af..0000000 --- a/test/t-snapshot-autoumount-dmeventd.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -# Copyright (C) 2010 Red Hat, Inc. All rights reserved. -# -# 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. -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -# no automatic extensions please -LVM_TEST_CONFIG_SNAPSHOT_AUTOEXTEND=" - snapshot_autoextend_percent = 0 - snapshot_autoextend_threshold = 100" - -. ./test-utils.sh - -which mkfs.ext2 || exit 200 - -prepare_lvmconf - -aux prepare_vg 2 -aux prepare_dmeventd - -lvcreate -l 8 -n base $vg -mkfs.ext2 $DM_DEV_DIR/$vg/base - -lvcreate -s -l 4 -n snap $vg/base -lvchange --monitor y $vg/snap - -mkdir mnt -mount $DM_DEV_DIR/$vg/snap mnt -mount -cat /proc/mounts | grep $vg-snap - -dd if=/dev/zero of=mnt/file$1 bs=1M count=17 -sync -sleep 10 # dmeventd only checks every 10 seconds :( - -cat /proc/mounts | not grep $vg-snap diff --git a/test/t-vgcreate-usage.sh b/test/t-vgcreate-usage.sh deleted file mode 100755 index 9f1cd82..0000000 --- a/test/t-vgcreate-usage.sh +++ /dev/null @@ -1,163 +0,0 @@ -#!/bin/sh -# Copyright (C) 2008 Red Hat, Inc. All rights reserved. -# -# 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. -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -test_description='Exercise some vgcreate diagnostics' - -. ./test-utils.sh - -aux prepare_devs 3 -pvcreate $dev1 $dev2 -pvcreate --metadatacopies 0 $dev3 - -vg=${PREFIX}vg - -#COMM 'vgcreate accepts 8.00m physicalextentsize for VG' -vgcreate -c n $vg --physicalextentsize 8.00m $dev1 $dev2 -check_vg_field_ $vg vg_extent_size 8.00m -vgremove $vg -# try vgck and to remove it again - should fail (but not segfault) -not vgremove $vg -not vgck $vg - -#COMM 'vgcreate accepts smaller (128) maxlogicalvolumes for VG' -vgcreate -c n $vg --maxlogicalvolumes 128 $dev1 $dev2 -check_vg_field_ $vg max_lv 128 -vgremove $vg - -#COMM 'vgcreate accepts smaller (128) maxphysicalvolumes for VG' -vgcreate -c n $vg --maxphysicalvolumes 128 $dev1 $dev2 -check_vg_field_ $vg max_pv 128 -vgremove $vg - -#COMM 'vgcreate rejects a zero physical extent size' -not vgcreate -c n --physicalextentsize 0 $vg $dev1 $dev2 2>err -grep "^ Physical extent size may not be zero\$" err - -#COMM 'vgcreate rejects "inherit" allocation policy' -not vgcreate -c n --alloc inherit $vg $dev1 $dev2 2>err -grep "^ Volume Group allocation policy cannot inherit from anything\$" err - -#COMM 'vgcreate rejects vgname "."' -vginvalid=.; -not vgcreate -c n $vginvalid $dev1 $dev2 2>err -grep "New volume group name \"$vginvalid\" is invalid\$" err - -#COMM 'vgcreate rejects vgname greater than 128 characters' -vginvalid=thisnameisridiculouslylongtotestvalidationcodecheckingmaximumsizethisiswhathappenswhenprogrammersgetboredandorarenotcreativedonttrythisathome -not vgcreate -c n $vginvalid $dev1 $dev2 2>err -grep "New volume group name \"$vginvalid\" is invalid\$" err - -#COMM 'vgcreate rejects already existing vgname "/tmp/$vg"' -#touch /tmp/$vg -#not vgcreate $vg $dev1 $dev2 2>err -#grep "New volume group name \"$vg\" is invalid\$" err - -#COMM "vgcreate rejects repeated invocation (run 2 times) (bz178216)" -vgcreate -c n $vg $dev1 $dev2 -not vgcreate -c n $vg $dev1 $dev2 -vgremove -ff $vg - -#COMM 'vgcreate rejects MaxLogicalVolumes > 255' -not vgcreate -c n --metadatatype 1 --maxlogicalvolumes 1024 $vg $dev1 $dev2 2>err -grep "^ Number of volumes may not exceed 255\$" err - -#COMM "vgcreate fails when the only pv has --metadatacopies 0" -not vgcreate -c n $vg $dev3 - -# Test default (4MB) vg_extent_size as well as limits of extent_size -not vgcreate -c n --physicalextentsize 0k $vg $dev1 $dev2 -vgcreate -c n --physicalextentsize 1k $vg $dev1 $dev2 -check_vg_field_ $vg vg_extent_size 1.00k -vgremove -ff $vg -not vgcreate -c n --physicalextentsize 3K $vg $dev1 $dev2 -not vgcreate -c n --physicalextentsize 1024t $vg $dev1 $dev2 -#not vgcreate --physicalextentsize 1T $vg $dev1 $dev2 -# FIXME: vgcreate allows physicalextentsize larger than pv size! - -# Test default max_lv, max_pv, extent_size, alloc_policy, clustered -vgcreate -c n $vg $dev1 $dev2 -check_vg_field_ $vg vg_extent_size 4.00m -check_vg_field_ $vg max_lv 0 -check_vg_field_ $vg max_pv 0 -check_vg_field_ $vg vg_attr "wz--n-" -vgremove -ff $vg - -# Implicit pvcreate tests, test pvcreate options on vgcreate -# --force, --yes, --metadata{size|copies|type}, --zero -# --dataalignment[offset] -pvremove $dev1 $dev2 -vgcreate -c n --force --yes --zero y $vg $dev1 $dev2 -vgremove -f $vg -pvremove -f $dev1 - -for i in 0 1 2 3 -do -# vgcreate (lvm2) succeeds writing LVM label at sector $i - vgcreate -c n --labelsector $i $vg $dev1 - dd if=$dev1 bs=512 skip=$i count=1 2>/dev/null | strings | grep -q LABELONE; - vgremove -f $vg - pvremove -f $dev1 -done - -# pvmetadatacopies -for i in 1 2 -do - vgcreate -c n --pvmetadatacopies $i $vg $dev1 - check_pv_field_ $dev1 pv_mda_count $i - vgremove -f $vg - pvremove -f $dev1 -done -not vgcreate -c n --pvmetadatacopies 0 $vg $dev1 -pvcreate --metadatacopies 1 $dev2 -vgcreate -c n --pvmetadatacopies 0 $vg $dev1 $dev2 -check_pv_field_ $dev1 pv_mda_count 0 -check_pv_field_ $dev2 pv_mda_count 1 -vgremove -f $vg -pvremove -f $dev1 - -# metadatasize, dataalignment, dataalignmentoffset -#COMM 'pvcreate sets data offset next to mda area' -vgcreate -c n --metadatasize 100k --dataalignment 100k $vg $dev1 -check_pv_field_ $dev1 pe_start 200.00k -vgremove -f $vg -pvremove -f $dev1 - -# data area is aligned to 1M by default, -# data area start is shifted by the specified alignment_offset -pv_align="1052160B" # 1048576 + (7*512) -vgcreate -c n --metadatasize 128k --dataalignmentoffset 7s $vg $dev1 -check_pv_field_ $dev1 pe_start $pv_align "--units b" -vgremove -f $vg -pvremove -f $dev1 - -# metadatatype -for i in 1 2 -do - vgcreate -c n -M $i $vg $dev1 - check_vg_field_ $vg vg_fmt lvm$i - vgremove -f $vg - pvremove -f $dev1 -done - -# vgcreate fails if pv belongs to existing vg -vgcreate -c n $vg1 $dev1 $dev2 -not vgcreate $vg2 $dev2 -vgremove -f $vg1 -pvremove -f $dev1 $dev2 - -# all PVs exist in the VG after created -pvcreate $dev1 -vgcreate -c n $vg1 $dev1 $dev2 $dev3 -check_pv_field_ $dev1 vg_name $vg1 -check_pv_field_ $dev2 vg_name $vg1 -check_pv_field_ $dev3 vg_name $vg1 -vgremove -f $vg1 -pvremove -f $dev1 $dev2 $dev3 diff --git a/test/t-vgextend-usage.sh b/test/t-vgextend-usage.sh deleted file mode 100644 index eda8904..0000000 --- a/test/t-vgextend-usage.sh +++ /dev/null @@ -1,129 +0,0 @@ -# Copyright (C) 2008 Red Hat, Inc. All rights reserved. -# -# 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. -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -# -# Exercise various vgextend commands -# - -. ./test-utils.sh - -aux prepare_devs 5 - -for mdatype in 1 2 -do - -# Explicit pvcreate -pvcreate -M$mdatype $dev1 $dev2 $dev3 $dev4 $dev5 -vgcreate -M$mdatype $vg1 $dev1 $dev2 -vgextend $vg1 $dev3 $dev4 $dev5 -vgremove -ff $vg1 - -# Implicit pvcreate -pvremove $dev1 $dev2 $dev3 $dev4 $dev5 -vgcreate -M$mdatype $vg1 $dev1 $dev2 -vgextend -M$mdatype $vg1 $dev3 $dev4 $dev5 -vgremove -ff $vg1 -pvremove $dev1 $dev2 $dev3 $dev4 $dev5 - -done - -# Implicit pvcreate tests, test pvcreate options on vgcreate -# --force, --yes, --metadata{size|copies|type}, --zero -# --dataalignment[offset] -vgcreate $vg $dev2 -vgextend --force --yes --zero y $vg $dev1 -vgreduce $vg $dev1 -pvremove -f $dev1 - -for i in 0 1 2 3 -do -# vgcreate (lvm2) succeeds writing LVM label at sector $i - vgextend --labelsector $i $vg $dev1 - dd if=$dev1 bs=512 skip=$i count=1 2>/dev/null | strings | grep -q LABELONE; - vgreduce $vg $dev1 - pvremove -f $dev1 -done - -# pvmetadatacopies -for i in 0 1 2 -do - vgextend --pvmetadatacopies $i $vg $dev1 - check_pv_field_ $dev1 pv_mda_count $i - vgreduce $vg $dev1 - pvremove -f $dev1 -done - -# metadatasize, dataalignment, dataalignmentoffset -#COMM 'pvcreate sets data offset next to mda area' -vgextend --metadatasize 100k --dataalignment 100k $vg $dev1 -check_pv_field_ $dev1 pe_start 200.00k -vgreduce $vg $dev1 -pvremove -f $dev1 - -# data area is aligned to 1M by default, -# data area start is shifted by the specified alignment_offset -pv_align="1052160B" # 1048576 + (7*512) -vgextend --metadatasize 128k --dataalignmentoffset 7s $vg $dev1 -check_pv_field_ $dev1 pe_start $pv_align "--units b" -vgremove -f $vg -pvremove -f $dev1 - -# vgextend fails if pv belongs to existing vg -vgcreate $vg1 $dev1 $dev3 -vgcreate $vg2 $dev2 -not vgextend $vg2 $dev3 -vgremove -f $vg1 -vgremove -f $vg2 -pvremove -f $dev1 $dev2 $dev3 - -#vgextend fails if vg is not resizeable -vgcreate $vg1 $dev1 $dev2 -vgchange --resizeable n $vg1 -not vgextend $vg1 $dev3 -vgremove -f $vg1 -pvremove -f $dev1 $dev2 - -# all PVs exist in the VG after extended -pvcreate $dev1 -vgcreate $vg1 $dev2 -vgextend $vg1 $dev1 $dev3 -check_pv_field_ $dev1 vg_name $vg1 -check_pv_field_ $dev2 vg_name $vg1 -check_pv_field_ $dev3 vg_name $vg1 -vgremove -f $vg1 -pvremove -f $dev1 $dev2 $dev3 - -echo test vgextend --metadataignore -for mdacp in 1 2; do -for ignore in y n; do - echo vgextend --metadataignore has proper mda_count and mda_used_count - vgcreate $vg $dev3 - vgextend --metadataignore $ignore --pvmetadatacopies $mdacp $vg $dev1 $dev2 - check_pv_field_ $dev1 pv_mda_count $mdacp - check_pv_field_ $dev2 pv_mda_count $mdacp - if [ $ignore = y ]; then - check_pv_field_ $dev1 pv_mda_used_count 0 - check_pv_field_ $dev2 pv_mda_used_count 0 - else - check_pv_field_ $dev1 pv_mda_used_count $mdacp - check_pv_field_ $dev2 pv_mda_used_count $mdacp - fi - echo vg has proper vg_mda_count and vg_mda_used_count - check_vg_field_ $vg vg_mda_count $(($mdacp * 2 + 1)) - if [ $ignore = y ]; then - check_vg_field_ $vg vg_mda_used_count 1 - else - check_vg_field_ $vg vg_mda_used_count $(($mdacp * 2 + 1)) - fi - check_vg_field_ $vg vg_mda_copies unmanaged - vgremove $vg - pvremove -ff $dev1 $dev2 $dev3 -done -done diff --git a/test/t-vgmerge-operation.sh b/test/t-vgmerge-operation.sh deleted file mode 100755 index 3c7121b..0000000 --- a/test/t-vgmerge-operation.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/sh -# Copyright (C) 2007-2008 Red Hat, Inc. All rights reserved. -# -# 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. -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -test_description='Test vgmerge operation' - -. ./test-utils.sh - -aux prepare_pvs 4 64 - -# 'vgmerge succeeds with single linear LV in source VG' -vgcreate -c n $vg1 $dev1 $dev2 -vgcreate -c n $vg2 $dev3 $dev4 -lvcreate -l 4 -n $lv1 $vg1 $dev1 -vgchange -an $vg1 -vg_validate_pvlv_counts_ $vg1 2 1 0 -vg_validate_pvlv_counts_ $vg2 2 0 0 -vgmerge $vg2 $vg1 -vg_validate_pvlv_counts_ $vg2 4 1 0 -vgremove -f $vg2 - -# 'vgmerge succeeds with single linear LV in source and destination VG' -vgcreate -c n $vg1 $dev1 $dev2 -vgcreate -c n $vg2 $dev3 $dev4 -lvcreate -l 4 -n $lv1 $vg1 -lvcreate -l 4 -n $lv2 $vg2 -vgchange -an $vg1 -vgchange -an $vg2 -vg_validate_pvlv_counts_ $vg1 2 1 0 -vg_validate_pvlv_counts_ $vg2 2 1 0 -vgmerge $vg2 $vg1 -vg_validate_pvlv_counts_ $vg2 4 2 0 -vgremove -f $vg2 - -# 'vgmerge succeeds with linear LV + snapshots in source VG' -vgcreate -c n $vg1 $dev1 $dev2 -vgcreate -c n $vg2 $dev3 $dev4 -lvcreate -l 16 -n $lv1 $vg1 -lvcreate -l 4 -s -n $lv2 $vg1/$lv1 -vgchange -an $vg1 -vg_validate_pvlv_counts_ $vg1 2 2 1 -vg_validate_pvlv_counts_ $vg2 2 0 0 -vgmerge $vg2 $vg1 -vg_validate_pvlv_counts_ $vg2 4 2 1 -lvremove -f $vg2/$lv2 -vgremove -f $vg2 - -# 'vgmerge succeeds with mirrored LV in source VG' -vgcreate -c n $vg1 $dev1 $dev2 $dev3 -vgcreate -c n $vg2 $dev4 -lvcreate -l 4 -n $lv1 -m1 $vg1 -vgchange -an $vg1 -vg_validate_pvlv_counts_ $vg1 3 1 0 -vg_validate_pvlv_counts_ $vg2 1 0 0 -vgmerge $vg2 $vg1 -vg_validate_pvlv_counts_ $vg2 4 1 0 -lvremove -f $vg2/$lv1 -vgremove -f $vg2 - -# 'vgmerge rejects LV name collision' -vgcreate -c n $vg1 $dev1 $dev2 -vgcreate -c n $vg2 $dev3 $dev4 -lvcreate -l 4 -n $lv1 $vg1 -lvcreate -l 4 -n $lv1 $vg2 -vgchange -an $vg1 -aux vg_validate_pvlv_counts_ $vg1 2 1 0 -aux vg_validate_pvlv_counts_ $vg2 2 1 0 -not vgmerge $vg2 $vg1 2>err -grep "Duplicate logical volume name \"$lv1\" in \"$vg2\" and \"$vg1" err -aux vg_validate_pvlv_counts_ $vg1 2 1 0 -aux vg_validate_pvlv_counts_ $vg2 2 1 0 -vgremove -f $vg1 -vgremove -f $vg2 - diff --git a/test/t-vgmerge-usage.sh b/test/t-vgmerge-usage.sh deleted file mode 100755 index 4be9e1e..0000000 --- a/test/t-vgmerge-usage.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/sh -# Copyright (C) 2008 Red Hat, Inc. All rights reserved. -# -# 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. -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -# 'Test vgmerge command options for validity' - -. ./test-utils.sh - -aux prepare_pvs 4 - -# 'vgmerge normal operation' -# ensure ordering does not matter -vgcreate $vg1 $dev1 $dev2 -vgcreate $vg2 $dev3 $dev4 -vgmerge $vg1 $vg2 -vgremove $vg1 -vgcreate -c n $vg2 $dev1 $dev2 -vgcreate -c n $vg1 $dev3 $dev4 -vgmerge $vg2 $vg1 -vgremove $vg2 - -# 'vgmerge rejects duplicate vg name' -vgcreate $vg1 $dev1 $dev2 -vgcreate $vg2 $dev3 $dev4 -not vgmerge $vg1 $vg1 2>err -grep "^ Duplicate volume group name \"$vg1\"\$" err -vgremove $vg2 -vgremove $vg1 - -# 'vgmerge rejects vgs with incompatible extent_size' -vgcreate --physicalextentsize 4M $vg1 $dev1 $dev2 -vgcreate --physicalextentsize 8M $vg2 $dev3 $dev4 -not vgmerge $vg1 $vg2 2>err -grep "^ Extent sizes differ" err -vgremove $vg2 -vgremove $vg1 - -# 'vgmerge rejects vgmerge because max_pv is exceeded' -vgcreate --maxphysicalvolumes 2 $vg1 $dev1 $dev2 -vgcreate --maxphysicalvolumes 2 $vg2 $dev3 $dev4 -not vgmerge $vg1 $vg2 2>err -grep "^ Maximum number of physical volumes (2) exceeded" err -vgremove $vg2 -vgremove $vg1 - -# 'vgmerge rejects vg with active lv' -vgcreate $vg1 $dev1 $dev2 -vgcreate $vg2 $dev3 $dev4 -lvcreate -l 4 -n lv1 $vg2 -not vgmerge $vg1 $vg2 2>err -grep "^ Logical volumes in \"$vg2\" must be inactive\$" err -vgremove -f $vg2 -vgremove -f $vg1 - -# 'vgmerge rejects vgmerge because max_lv is exceeded' -vgcreate --maxlogicalvolumes 2 $vg1 $dev1 $dev2 -vgcreate --maxlogicalvolumes 2 $vg2 $dev3 $dev4 -lvcreate -l 4 -n lv1 $vg1 -lvcreate -l 4 -n lv2 $vg1 -lvcreate -l 4 -n lv3 $vg2 -vgchange -an $vg1 -vgchange -an $vg2 -not vgmerge $vg1 $vg2 2>err -grep "^ Maximum number of logical volumes (2) exceeded" err -vgremove -f $vg2 -vgremove -f $vg1 diff --git a/test/t-vgsplit-operation.sh b/test/t-vgsplit-operation.sh deleted file mode 100755 index 9a46a8e..0000000 --- a/test/t-vgsplit-operation.sh +++ /dev/null @@ -1,290 +0,0 @@ -#!/bin/sh -# Copyright (C) 2007 Red Hat, Inc. All rights reserved. -# -# 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. -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -# Test vgsplit operation, including different LV types - -. ./test-utils.sh - -COMM() { - LAST_TEST="$@" -} - -prepare_pvs 5 258 -# FIXME: paramaterize lvm1 vs lvm2 metadata; most of these tests should run -# fine with lvm1 metadata as well; for now, just add disks 5 and 6 as lvm1 -# metadata - -# -# vgsplit can be done into a new or existing VG -# -for i in new existing -do - # - # We can have PVs or LVs on the cmdline - # - for j in PV LV - do -COMM "vgsplit correctly splits single linear LV into $i VG ($j args)" - vgcreate $vg1 $dev1 $dev2 - if [ $i = existing ]; then - vgcreate $vg2 $dev3 $dev4 - fi - lvcreate -l 4 -n $lv1 $vg1 $dev1 - vgchange -an $vg1 - if [ $j = PV ]; then - vgsplit $vg1 $vg2 $dev1 - else - vgsplit -n $lv1 $vg1 $vg2 - fi - vg_validate_pvlv_counts_ $vg1 1 0 0 - if [ $i = existing ]; then - aux vg_validate_pvlv_counts_ $vg2 3 1 0 - else - aux vg_validate_pvlv_counts_ $vg2 1 1 0 - fi - lvremove -f $vg2/$lv1 - vgremove -f $vg2 - vgremove -f $vg1 - -COMM "vgsplit correctly splits single striped LV into $i VG ($j args)" - vgcreate $vg1 $dev1 $dev2 - if [ $i = existing ]; then - vgcreate $vg2 $dev3 $dev4 - fi - lvcreate -l 4 -i 2 -n $lv1 $vg1 $dev1 $dev2 - vgchange -an $vg1 - if [ $j = PV ]; then - vgsplit $vg1 $vg2 $dev1 $dev2 - else - vgsplit -n $lv1 $vg1 $vg2 - fi - if [ $i = existing ]; then - aux vg_validate_pvlv_counts_ $vg2 4 1 0 - else - aux vg_validate_pvlv_counts_ $vg2 2 1 0 - fi - lvremove -f $vg2/$lv1 - vgremove -f $vg2 - -COMM "vgsplit correctly splits mirror LV into $i VG ($j args)" - vgcreate -c n $vg1 $dev1 $dev2 $dev3 - if [ $i = existing ]; then - vgcreate -c n $vg2 $dev4 - fi - lvcreate -l 64 -m1 -n $lv1 $vg1 $dev1 $dev2 $dev3 - vgchange -an $vg1 - if [ $j = PV ]; then - vgsplit $vg1 $vg2 $dev1 $dev2 $dev3 - else - vgsplit -n $lv1 $vg1 $vg2 - fi - if [ $i = existing ]; then - aux vg_validate_pvlv_counts_ $vg2 4 1 0 - else - aux vg_validate_pvlv_counts_ $vg2 3 1 0 - fi - lvremove -f $vg2/$lv1 - vgremove -f $vg2 - -COMM "vgsplit correctly splits origin and snapshot LV into $i VG ($j args)" - vgcreate -c n $vg1 $dev1 $dev2 - if [ $i = existing ]; then - vgcreate -c n $vg2 $dev3 $dev4 - fi - lvcreate -l 64 -i 2 -n $lv1 $vg1 $dev1 $dev2 - lvcreate -l 4 -i 2 -s -n $lv2 $vg1/$lv1 - vgchange -an $vg1 - if [ $j = PV ]; then - vgsplit $vg1 $vg2 $dev1 $dev2 - else - vgsplit -n $lv1 $vg1 $vg2 - fi - if [ $i = existing ]; then - aux vg_validate_pvlv_counts_ $vg2 4 2 1 - else - aux vg_validate_pvlv_counts_ $vg2 2 2 1 - fi - lvremove -f $vg2/$lv2 - lvremove -f $vg2/$lv1 - vgremove -f $vg2 - -COMM "vgsplit correctly splits linear LV but not snap+origin LV into $i VG ($j args)" - vgcreate -c n $vg1 $dev1 $dev2 - if [ $i = existing ]; then - vgcreate -c n $vg2 $dev3 - fi - lvcreate -l 64 -i 2 -n $lv1 $vg1 - lvcreate -l 4 -i 2 -s -n $lv2 $vg1/$lv1 - vgextend $vg1 $dev4 - lvcreate -l 64 -n $lv3 $vg1 $dev4 - vgchange -an $vg1 - if [ $j = PV ]; then - vgsplit $vg1 $vg2 $dev4 - else - vgsplit -n $lv3 $vg1 $vg2 - fi - if [ $i = existing ]; then - aux vg_validate_pvlv_counts_ $vg2 2 1 0 - aux vg_validate_pvlv_counts_ $vg1 2 2 1 - else - aux vg_validate_pvlv_counts_ $vg2 1 1 0 - aux vg_validate_pvlv_counts_ $vg1 2 2 1 - fi - lvremove -f $vg1/$lv2 - lvremove -f $vg1/$lv1 - lvremove -f $vg2/$lv3 - vgremove -f $vg1 - vgremove -f $vg2 - -COMM "vgsplit correctly splits linear LV but not mirror LV into $i VG ($j args)" - vgcreate -c n $vg1 $dev1 $dev2 $dev3 - if [ $i = existing ]; then - vgcreate -c n $vg2 $dev5 - fi - lvcreate -l 64 -m1 -n $lv1 $vg1 $dev1 $dev2 $dev3 - vgextend $vg1 $dev4 - lvcreate -l 64 -n $lv2 $vg1 $dev4 - vgchange -an $vg1 - vgs - lvs - pvs - if [ $j = PV ]; then - vgsplit $vg1 $vg2 $dev4 - else - vgsplit -n $lv2 $vg1 $vg2 - fi - if [ $i = existing ]; then - aux vg_validate_pvlv_counts_ $vg1 3 1 0 - aux vg_validate_pvlv_counts_ $vg2 2 1 0 - else - vgs - lvs - pvs - aux vg_validate_pvlv_counts_ $vg1 3 1 0 - aux vg_validate_pvlv_counts_ $vg2 1 1 0 - fi - lvremove -f $vg1/$lv1 - lvremove -f $vg2/$lv2 - vgremove -f $vg1 - vgremove -f $vg2 - - done -done - -# -# Test more complex setups where the code has to find associated PVs and -# LVs to split the VG correctly -# -COMM "vgsplit fails splitting 3 striped LVs into VG when only 1 LV specified" -vgcreate $vg1 $dev1 $dev2 $dev3 $dev4 -lvcreate -l 4 -n $lv1 -i 2 $vg1 $dev1 $dev2 -lvcreate -l 4 -n $lv2 -i 2 $vg1 $dev2 $dev3 -lvcreate -l 4 -n $lv3 -i 2 $vg1 $dev3 $dev4 -vgchange -an $vg1 -not vgsplit -n $lv1 $vg1 $vg2 -vgremove -ff $vg1 - -COMM "vgsplit fails splitting one LV with 2 snapshots, only origin LV specified" -vgcreate -c n $vg1 $dev1 $dev2 $dev3 $dev4 -lvcreate -l 16 -n $lv1 $vg1 $dev1 $dev2 -lvcreate -l 4 -n $lv2 -s $vg1/$lv1 $dev3 -lvcreate -l 4 -n $lv3 -s $vg1/$lv1 $dev4 -vg_validate_pvlv_counts_ $vg1 4 3 2 -vgchange -an $vg1 -not vgsplit -n $lv1 $vg1 $vg2; -lvremove -f $vg1/$lv2 -lvremove -f $vg1/$lv3 -lvremove -f $vg1/$lv1 -vgremove -ff $vg1 - -COMM "vgsplit fails splitting one LV with 2 snapshots, only snapshot LV specified" -vgcreate -c n $vg1 $dev1 $dev2 $dev3 $dev4 -lvcreate -l 16 -n $lv1 $vg1 $dev1 $dev2 -lvcreate -l 4 -n $lv2 -s $vg1/$lv1 $dev3 -lvcreate -l 4 -n $lv3 -s $vg1/$lv1 $dev4 -vg_validate_pvlv_counts_ $vg1 4 3 2 -vgchange -an $vg1 -not vgsplit -n $lv2 $vg1 $vg2 -lvremove -f $vg1/$lv2 -lvremove -f $vg1/$lv3 -lvremove -f $vg1/$lv1 -vgremove -ff $vg1 - -COMM "vgsplit fails splitting one mirror LV, only one PV specified" -vgcreate -c n $vg1 $dev1 $dev2 $dev3 $dev4 -lvcreate -l 16 -n $lv1 -m1 $vg1 $dev1 $dev2 $dev3 -vg_validate_pvlv_counts_ $vg1 4 1 0 -vgchange -an $vg1 -not vgsplit $vg1 $vg2 $dev2 -vgremove -ff $vg1 - -COMM "vgsplit fails splitting 1 mirror + 1 striped LV, only striped LV specified" -vgcreate -c n $vg1 $dev1 $dev2 $dev3 $dev4 -lvcreate -l 16 -n $lv1 -m1 $vg1 $dev1 $dev2 $dev3 -lvcreate -l 16 -n $lv2 -i 2 $vg1 $dev3 $dev4 -vg_validate_pvlv_counts_ $vg1 4 2 0 -vgchange -an $vg1 -not vgsplit -n $lv2 $vg1 $vg2 2>err -vgremove -ff $vg1 - -# -# Verify vgsplit rejects active LVs only when active LVs involved in split -# -COMM "vgsplit fails, active mirror involved in split" -vgcreate -c n $vg1 $dev1 $dev2 $dev3 $dev4 -lvcreate -l 16 -n $lv1 -m1 $vg1 $dev1 $dev2 $dev3 -lvcreate -l 16 -n $lv2 $vg1 $dev4 -lvchange -an $vg1/$lv2 -vg_validate_pvlv_counts_ $vg1 4 2 0 -not vgsplit -n $lv1 $vg1 $vg2; -vg_validate_pvlv_counts_ $vg1 4 2 0 -vgremove -ff $vg1 - -COMM "vgsplit succeeds, active mirror not involved in split" -vgcreate -c n $vg1 $dev1 $dev2 $dev3 $dev4 -lvcreate -l 16 -n $lv1 -m1 $vg1 $dev1 $dev2 $dev3 -lvcreate -l 16 -n $lv2 $vg1 $dev4 -lvchange -an $vg1/$lv2 -vg_validate_pvlv_counts_ $vg1 4 2 0 -vgsplit -n $lv2 $vg1 $vg2 -vg_validate_pvlv_counts_ $vg1 3 1 0 -vg_validate_pvlv_counts_ $vg2 1 1 0 -vgremove -ff $vg1 -vgremove -ff $vg2 - -COMM "vgsplit fails, active snapshot involved in split" -vgcreate -c n $vg1 $dev1 $dev2 $dev3 $dev4 -lvcreate -l 64 -i 2 -n $lv1 $vg1 $dev1 $dev2 -lvcreate -l 4 -i 2 -s -n $lv2 $vg1/$lv1 -lvcreate -l 64 -i 2 -n $lv3 $vg1 $dev3 $dev4 -lvchange -an $vg1/$lv3 -vg_validate_pvlv_counts_ $vg1 4 3 1 -not vgsplit -n $lv2 $vg1 $vg2; -vg_validate_pvlv_counts_ $vg1 4 3 1 -lvremove -f $vg1/$lv2 -vgremove -ff $vg1 - -COMM "vgsplit succeeds, active snapshot not involved in split" -vgcreate -c n $vg1 $dev1 $dev2 $dev3 -lvcreate -l 64 -i 2 -n $lv1 $vg1 $dev1 $dev2 -lvcreate -l 4 -s -n $lv2 $vg1/$lv1 -vgextend $vg1 $dev4 -lvcreate -l 64 -n $lv3 $vg1 $dev4 -lvchange -an $vg1/$lv3 -vg_validate_pvlv_counts_ $vg1 4 3 1 -vgsplit -n $lv3 $vg1 $vg2 -vg_validate_pvlv_counts_ $vg1 3 2 1 -vg_validate_pvlv_counts_ $vg2 1 1 0 -vgchange -an $vg1 -lvremove -f $vg1/$lv2 -vgremove -ff $vg1 -vgremove -ff $vg2 - diff --git a/test/t-vgsplit-usage.sh b/test/t-vgsplit-usage.sh deleted file mode 100755 index ade39d8..0000000 --- a/test/t-vgsplit-usage.sh +++ /dev/null @@ -1,187 +0,0 @@ -#!/bin/sh -# Copyright (C) 2007-2008 Red Hat, Inc. All rights reserved. -# -# 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. -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -# Test vgsplit command options for validity - -. ./test-utils.sh - -aux prepare_devs 5 - -for mdatype in 1 2 -do - -pvcreate -M$mdatype $devs - -# ensure name order does not matter -# NOTE: if we're using lvm1, we must use -M on vgsplit -vgcreate -M$mdatype $vg1 $devs -vgsplit -M$mdatype $vg1 $vg2 $dev1 -vgremove $vg1 -vgremove $vg2 -vgcreate -M$mdatype $vg2 $devs -vgsplit -M$mdatype $vg2 $vg1 $dev1 -vgremove $vg1 -vgremove $vg2 - -# vgsplit accepts new vg as destination of split -# lvm1 -- bz244792 -vgcreate -M$mdatype $vg1 $devs -vgsplit $vg1 $vg2 $dev1 1>err -grep "New volume group \"$vg2\" successfully split from \"$vg1\"" err -vgremove $vg1 -vgremove $vg2 - -# vgsplit accepts existing vg as destination of split -vgcreate -M$mdatype $vg1 $dev1 $dev2 -vgcreate -M$mdatype $vg2 $dev3 $dev4 -vgsplit $vg1 $vg2 $dev1 1>err -grep "Existing volume group \"$vg2\" successfully split from \"$vg1\"" err -vgremove $vg1 -vgremove $vg2 - -# vgsplit accepts --maxphysicalvolumes 128 on new VG -vgcreate -M$mdatype $vg1 $dev1 $dev2 -vgsplit --maxphysicalvolumes 128 $vg1 $vg2 $dev1 -check_vg_field_ $vg2 max_pv 128 -vgremove $vg1 -vgremove $vg2 - -# vgsplit accepts --maxlogicalvolumes 128 on new VG -vgcreate -M$mdatype $vg1 $dev1 $dev2 -vgsplit --maxlogicalvolumes 128 $vg1 $vg2 $dev1 -check_vg_field_ $vg2 max_lv 128 -vgremove $vg1 -vgremove $vg2 - -# vgsplit rejects split because max_pv of destination would be exceeded -vgcreate -M$mdatype --maxphysicalvolumes 2 $vg1 $dev1 $dev2 -vgcreate -M$mdatype --maxphysicalvolumes 2 $vg2 $dev3 $dev4 -not vgsplit $vg1 $vg2 $dev1 2>err; -grep "^ Maximum number of physical volumes (2) exceeded" err -vgremove $vg2 -vgremove $vg1 - -# vgsplit rejects split because maxphysicalvolumes given with existing vg -vgcreate -M$mdatype --maxphysicalvolumes 2 $vg1 $dev1 $dev2 -vgcreate -M$mdatype --maxphysicalvolumes 2 $vg2 $dev3 $dev4 -not vgsplit --maxphysicalvolumes 2 $vg1 $vg2 $dev1 2>err; -grep "^ Volume group \"$vg2\" exists, but new VG option specified" err -vgremove $vg2 -vgremove $vg1 - -# vgsplit rejects split because maxlogicalvolumes given with existing vg -vgcreate -M$mdatype --maxlogicalvolumes 2 $vg1 $dev1 $dev2 -vgcreate -M$mdatype --maxlogicalvolumes 2 $vg2 $dev3 $dev4 -not vgsplit --maxlogicalvolumes 2 $vg1 $vg2 $dev1 2>err -grep "^ Volume group \"$vg2\" exists, but new VG option specified" err -vgremove $vg2 -vgremove $vg1 - -# vgsplit rejects split because alloc given with existing vg -vgcreate -M$mdatype --alloc cling $vg1 $dev1 $dev2 -vgcreate -M$mdatype --alloc cling $vg2 $dev3 $dev4 -not vgsplit --alloc cling $vg1 $vg2 $dev1 2>err; -grep "^ Volume group \"$vg2\" exists, but new VG option specified" err -vgremove $vg2 -vgremove $vg1 - -# vgsplit rejects split because clustered given with existing vg -vgcreate -M$mdatype --clustered n $vg1 $dev1 $dev2 -vgcreate -M$mdatype --clustered n $vg2 $dev3 $dev4 -not vgsplit --clustered n $vg1 $vg2 $dev1 2>err -grep "^ Volume group \"$vg2\" exists, but new VG option specified" err -vgremove $vg2 -vgremove $vg1 - -# vgsplit rejects vg with active lv -pvcreate -M$mdatype -ff $dev3 $dev4 -vgcreate -M$mdatype $vg1 $dev1 $dev2 -vgcreate -M$mdatype $vg2 $dev3 $dev4 -lvcreate -l 4 -n $lv1 $vg1 -not vgsplit $vg1 $vg2 $dev1 2>err; -grep "^ Logical volumes in \"$vg1\" must be inactive\$" err -vgremove -f $vg2 -vgremove -f $vg1 - -# vgsplit rejects split because max_lv is exceeded -vgcreate -M$mdatype --maxlogicalvolumes 2 $vg1 $dev1 $dev2 -vgcreate -M$mdatype --maxlogicalvolumes 2 $vg2 $dev3 $dev4 -lvcreate -l 4 -n $lv1 $vg1 -lvcreate -l 4 -n $lv2 $vg1 -lvcreate -l 4 -n $lv3 $vg2 -vgchange -an $vg1 -vgchange -an $vg2 -not vgsplit $vg1 $vg2 $dev1 2>err; -grep "^ Maximum number of logical volumes (2) exceeded" err -vgremove -f $vg2 -vgremove -f $vg1 - -# vgsplit verify default - max_lv attribute from new VG is same as source VG" \ -vgcreate -M$mdatype $vg1 $dev1 $dev2 -lvcreate -l 4 -n $lv1 $vg1 -vgchange -an $vg1 -vgsplit $vg1 $vg2 $dev1 -compare_vg_field_ $vg1 $vg2 max_lv -vgremove -f $vg2 -vgremove -f $vg1 - -# vgsplit verify default - max_pv attribute from new VG is same as source VG" \ -vgcreate -M$mdatype $vg1 $dev1 $dev2 -lvcreate -l 4 -n $lv1 $vg1 -vgchange -an $vg1 -vgsplit $vg1 $vg2 $dev1 -compare_vg_field_ $vg1 $vg2 max_pv -vgremove -f $vg2 -vgremove -f $vg1 - -# vgsplit verify default - vg_fmt attribute from new VG is same as source VG" \ -vgcreate -M$mdatype $vg1 $dev1 $dev2 -lvcreate -l 4 -n $lv1 $vg1 -vgchange -an $vg1 -vgsplit $vg1 $vg2 $dev1 -compare_vg_field_ $vg1 $vg2 vg_fmt -vgremove -f $vg2 -vgremove -f $vg1 - -# vgsplit rejects split because PV not in VG -vgcreate -M$mdatype $vg1 $dev1 $dev2 -vgcreate -M$mdatype $vg2 $dev3 $dev4 -lvcreate -l 4 -n $lv1 $vg1 -lvcreate -l 4 -n $lv2 $vg1 -vgchange -an $vg1 -not vgsplit $vg1 $vg2 $dev3 2>err; -vgremove -f $vg2 -vgremove -f $vg1 -done - -# ONLY LVM2 metadata -# setup PVs" ' -pvcreate --metadatacopies 0 $dev5 - -# vgsplit rejects to give away pv with the last mda copy -vgcreate $vg1 $dev5 $dev2 -lvcreate -l 10 -n $lv1 $vg1 -lvchange -an $vg1/$lv1 -vg_validate_pvlv_counts_ $vg1 2 1 0 -not vgsplit $vg1 $vg2 $dev5; -vg_validate_pvlv_counts_ $vg1 2 1 0 -vgremove -ff $vg1 - -# vgsplit rejects split because metadata types differ -pvcreate -ff -M1 $dev3 $dev4 -pvcreate -ff $dev1 $dev2 -vgcreate -M1 $vg1 $dev3 $dev4 -vgcreate $vg2 $dev1 $dev2 -not vgsplit $vg1 $vg2 $dev3 2>err; -grep "^ Metadata types differ" err -vgremove $vg2 -vgremove $vg1 - diff --git a/test/test-utils.sh b/test/test-utils.sh deleted file mode 100644 index e1aea8a..0000000 --- a/test/test-utils.sh +++ /dev/null @@ -1,457 +0,0 @@ -# Copyright (C) 2008 Red Hat, Inc. All rights reserved. -# -# 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. -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -aux() { - # use just "$@" for verbose operation - "$@" > /dev/null 2> /dev/null - #"$@" -} - -STACKTRACE() { - trap - ERR; - i=0; - - while FUNC=${FUNCNAME[$i]}; test "$FUNC" != "main"; do - echo "$i ${FUNC}() called from ${BASH_SOURCE[$i]}:${BASH_LINENO[$i]}" - i=$(($i + 1)); - done - - # Get backtraces from coredumps - if which gdb >& /dev/null; then - echo bt full > gdb_commands.txt - echo l >> gdb_commands.txt - echo quit >> gdb_commands.txt - for core in `ls core* 2>/dev/null`; do - bin=$(gdb -batch -c $core 2>&1 | grep "generated by" | \ - sed -e "s,.*generated by \`\([^ ']*\).*,\1,") - gdb -batch -c $core -x gdb_commands.txt `which $bin` - done - fi - - test -f debug.log && { - sed -e "s,^,## DEBUG: ,;s,$top_srcdir/\?,," < debug.log - } -} - -init_udev_transaction() { - if test "$DM_UDEV_SYNCHRONISATION" = 1; then - COOKIE=$(dmsetup udevcreatecookie) - # Cookie is not generated if udev is not running! - if test -n "$COOKIE"; then - export DM_UDEV_COOKIE=$COOKIE - fi - fi -} - -finish_udev_transaction() { - if test "$DM_UDEV_SYNCHRONISATION" = 1 -a -n "$DM_UDEV_COOKIE"; then - dmsetup udevreleasecookie - unset DM_UDEV_COOKIE - fi -} - -prepare_clvmd() { - if test -z "$LVM_TEST_LOCKING" || test "$LVM_TEST_LOCKING" -ne 3 ; then - return 0 # not needed - fi - - if pgrep clvmd ; then - echo "Cannot use fake cluster locking with real clvmd ($(pgrep clvmd)) running." - exit 200 - fi - - # skip if we don't have our own clvmd... - (which clvmd | grep $abs_builddir) || exit 200 - - # skip if we singlenode is not compiled in - (clvmd --help 2>&1 | grep "Available cluster managers" | grep singlenode) || exit 200 - - trap_teardown - - clvmd -Isinglenode -d 1 & - LOCAL_CLVMD="$!" - - # check that it is really running now - sleep .1 - ps $LOCAL_CLVMD || exit 200 -} - -prepare_dmeventd() { - if pgrep dmeventd ; then - echo "Cannot test dmeventd with real dmeventd ($(pgrep dmeventd)) running." - exit 200 - fi - - # skip if we don't have our own dmeventd... - (which dmeventd | grep $abs_builddir) || exit 200 - - trap_teardown - - dmeventd -f & - LOCAL_DMEVENTD="$!" -} - -prepare_testroot() { - OLDPWD="`pwd`" - PREFIX="LVMTEST$$" - - trap_teardown - TESTDIR=$($abs_srcdir/mkdtemp ${LVM_TEST_DIR-$(pwd)} $PREFIX.XXXXXXXXXX) \ - || { echo "failed to create temporary directory in ${LVM_TEST_DIR-$(pwd)}"; exit 1; } - - export LVM_SYSTEM_DIR=$TESTDIR/etc - export DM_DEV_DIR=$TESTDIR/dev - mkdir $LVM_SYSTEM_DIR $DM_DEV_DIR $DM_DEV_DIR/mapper $TESTDIR/lib - - cd $TESTDIR - - for i in `find $abs_top_builddir/daemons/dmeventd/plugins/ -name \*.so`; do - echo Setting up symlink from $i to $TESTDIR/lib - ln -s $i $TESTDIR/lib - done -} - -teardown_devs() { - test -n "$PREFIX" && { - rm -rf $TESTDIR/dev/$PREFIX* - - init_udev_transaction - while dmsetup table | grep -q ^$PREFIX; do - for s in `dmsetup info -c -o name --noheading | grep ^$PREFIX`; do - umount -fl $DM_DEV_DIR/mapper/$s || true - dmsetup remove $s >& /dev/null || true - done - done - finish_udev_transaction - - } - - # NOTE: SCSI_DEBUG_DEV test must come before the LOOP test because - # prepare_scsi_debug_dev() also sets LOOP to short-circuit prepare_loop() - if [ -n "$SCSI_DEBUG_DEV" ] ; then - modprobe -r scsi_debug - else - test -n "$LOOP" && losetup -d $LOOP - test -n "$LOOPFILE" && rm -f $LOOPFILE - fi - unset devs # devs is set in prepare_devs() - unset LOOP -} - -teardown() { - echo $LOOP - echo $PREFIX - - test -n "$LOCAL_CLVMD" && { - kill "$LOCAL_CLVMD" - sleep .1 - kill -9 "$LOCAL_CLVMD" || true - } - - test -n "$LOCAL_DMEVENTD" && kill -9 "$LOCAL_DMEVENTD" - - teardown_devs - - test -n "$TESTDIR" && { - cd $OLDPWD - rm -rf $TESTDIR || echo BLA - } -} - -trap_teardown() { - trap 'set +vx; STACKTRACE; set -vx' ERR - trap 'aux teardown' EXIT # don't forget to clean up -} - -make_ioerror() { - echo 0 10000000 error | dmsetup create ioerror - ln -s $DM_DEV_DIR/mapper/ioerror $DM_DEV_DIR/ioerror -} - -prepare_loop() { - size=$1 - test -n "$size" || size=32 - - # skip if prepare_scsi_debug_dev() was used - if [ -n "$SCSI_DEBUG_DEV" -a -n "$LOOP" ]; then - return 0 - fi - - test -z "$LOOP" - test -n "$DM_DEV_DIR" - - trap_teardown - - for i in 0 1 2 3 4 5 6 7; do - test -e $DM_DEV_DIR/loop$i || mknod $DM_DEV_DIR/loop$i b 7 $i - done - - LOOPFILE="$PWD/test.img" - dd if=/dev/zero of="$LOOPFILE" bs=$((1024*1024)) count=0 seek=$(($size-1)) - if LOOP=`losetup -s -f "$LOOPFILE" 2>/dev/null`; then - return 0 - elif LOOP=`losetup -f` && losetup $LOOP "$LOOPFILE"; then - # no -s support - return 0 - else - # no -f support - # Iterate through $DM_DEV_DIR/loop{,/}{0,1,2,3,4,5,6,7} - for slash in '' /; do - for i in 0 1 2 3 4 5 6 7; do - local dev=$DM_DEV_DIR/loop$slash$i - ! losetup $dev >/dev/null 2>&1 || continue - # got a free - losetup "$dev" "$LOOPFILE" - LOOP=$dev - break - done - if [ -n "$LOOP" ]; then - break - fi - done - test -n "$LOOP" # confirm or fail - return 0 - fi - exit 1 # should not happen -} - -# A drop-in replacement for prepare_loop() that uses scsi_debug to create -# a ramdisk-based SCSI device upon which all LVM devices will be created -# - scripts must take care not to use a DEV_SIZE that will enduce OOM-killer -prepare_scsi_debug_dev() -{ - local DEV_SIZE="$1" - shift - local SCSI_DEBUG_PARAMS="$@" - - test -n "$SCSI_DEBUG_DEV" && return 0 - test -z "$LOOP" - test -n "$DM_DEV_DIR" - - trap_teardown - - # Skip test if awk isn't available (required for get_sd_devs_) - which awk || exit 200 - - # Skip test if scsi_debug module is unavailable or is already in use - modprobe --dry-run scsi_debug || exit 200 - lsmod | grep -q scsi_debug && exit 200 - - # Create the scsi_debug device and determine the new scsi device's name - # NOTE: it will _never_ make sense to pass num_tgts param; - # last param wins.. so num_tgts=1 is imposed - modprobe scsi_debug dev_size_mb=$DEV_SIZE $SCSI_DEBUG_PARAMS num_tgts=1 || exit 200 - sleep 2 # allow for async Linux SCSI device registration - - local DEBUG_DEV=/dev/$(grep -H scsi_debug /sys/block/*/device/model | cut -f4 -d /) - [ -b $DEBUG_DEV ] || exit 1 # should not happen - - # Create symlink to scsi_debug device in $DM_DEV_DIR - SCSI_DEBUG_DEV=$DM_DEV_DIR/$(basename $DEBUG_DEV) - # Setting $LOOP provides means for prepare_devs() override - LOOP=$SCSI_DEBUG_DEV - ln -snf $DEBUG_DEV $SCSI_DEBUG_DEV - return 0 -} - -cleanup_scsi_debug_dev() -{ - aux teardown_devs - unset SCSI_DEBUG_DEV - unset LOOP -} - -prepare_devs() { - local n="$1" - test -z "$n" && n=3 - local devsize="$2" - test -z "$devsize" && devsize=34 - local pvname="$3" - test -z "$pvname" && pvname="pv" - - prepare_loop $(($n*$devsize)) - - if ! loopsz=`blockdev --getsz $LOOP 2>/dev/null`; then - loopsz=`blockdev --getsize $LOOP 2>/dev/null` - fi - - local size=$(($loopsz/$n)) - - init_udev_transaction - for i in `seq 1 $n`; do - local name="${PREFIX}$pvname$i" - local dev="$DM_DEV_DIR/mapper/$name" - eval "dev$i=$dev" - devs="$devs $dev" - echo 0 $size linear $LOOP $((($i-1)*$size)) > $name.table - dmsetup create $name $name.table - done - finish_udev_transaction - - for i in `seq 1 $n`; do - local name="${PREFIX}$pvname$i" - dmsetup info -c $name - done - for i in `seq 1 $n`; do - local name="${PREFIX}$pvname$i" - dmsetup table $name - done -} - -disable_dev() { - - init_udev_transaction - for dev in "$@"; do - # first we make the device inaccessible - echo 0 10000000 error | dmsetup load $dev - dmsetup resume $dev - # now let's try to get rid of it if it's unused - #dmsetup remove $dev - done - finish_udev_transaction - -} - -enable_dev() { - - init_udev_transaction - for dev in "$@"; do - local name=`echo "$dev" | sed -e 's,.*/,,'` - dmsetup create $name $name.table || dmsetup load $name $name.table - dmsetup resume $dev - done - finish_udev_transaction -} - -backup_dev() { - for dev in "$@"; do - dd if=$dev of=$dev.backup bs=1024 - done -} - -restore_dev() { - for dev in "$@"; do - test -e $dev.backup || { - echo "Internal error: $dev not backed up, can't restore!" - exit 1 - } - dd of=$dev if=$dev.backup bs=1024 - done -} - -prepare_pvs() { - prepare_devs "$@" - pvcreate -ff $devs -} - -prepare_vg() { - vgremove -ff $vg || true - teardown_devs - - prepare_pvs "$@" - vgcreate -c n $vg $devs - pvs -v -} - -prepare_lvmconf() { - local filter="$1" - test -z "$filter" && \ - filter='[ "a/dev\/mirror/", "a/dev\/mapper\/.*pv[0-9_]*$/", "r/.*/" ]' - locktype= - if test -z "$LVM_TEST_CONFIG_SNAPSHOT_AUTOEXTEND"; then - LVM_TEST_CONFIG_SNAPSHOT_AUTOEXTEND=" - snapshot_autoextend_percent = 50 - snapshot_autoextend_threshold = 50" - fi - if test -n "$LVM_TEST_LOCKING"; then locktype="locking_type = $LVM_TEST_LOCKING"; fi - cat > $TESTDIR/etc/lvm.conf.new <<-EOF - $LVM_TEST_CONFIG - devices { - dir = "$DM_DEV_DIR" - scan = "$DM_DEV_DIR" - filter = $filter - cache_dir = "$TESTDIR/etc" - sysfs_scan = 0 - default_data_alignment = 1 - $LVM_TEST_CONFIG_DEVICES - } - log { - syslog = 0 - indent = 1 - level = 9 - file = "$TESTDIR/debug.log" - overwrite = 1 - activation = 1 - } - backup { - backup = 0 - archive = 0 - } - global { - abort_on_internal_errors = 1 - library_dir = "$TESTDIR/lib" - locking_dir = "$TESTDIR/var/lock/lvm" - $locktype - si_unit_consistency = 1 - fallback_to_local_locking = 0 - } - activation { - udev_sync = 1 - udev_rules = 1 - polling_interval = 0 - $LVM_TEST_CONFIG_SNAPSHOT_AUTOEXTEND - } -EOF - # FIXME remove this workaround after mmap & truncating file problems solved - mv -f $TESTDIR/etc/lvm.conf.new $TESTDIR/etc/lvm.conf - cat $TESTDIR/etc/lvm.conf -} - -prepare() { - ulimit -c unlimited - # FIXME any way to set this just for our children? - # echo 1 > /proc/sys/kernel/core_uses_pid - prepare_testroot - prepare_lvmconf - prepare_clvmd - - # set up some default names - vg=${PREFIX}vg - vg1=${PREFIX}vg1 - vg2=${PREFIX}vg2 - lv=LV - lv1=LV1 - lv2=LV2 - lv3=LV3 - lv4=LV4 -} - -apitest() { - t=$1 - shift - test -x $abs_top_builddir/test/api/$t.t || exit 200 - $abs_top_builddir/test/api/$t.t "$@" -} - -api() { - test -x $abs_top_builddir/test/api/wrapper || exit 200 - $abs_top_builddir/test/api/wrapper "$@" -} - -LANG=C -LC_ALL=C -TZ=UTC -unset CDPATH - -. ./init.sh || { echo >&2 you must run make first; exit 1; } -. ./lvm-utils.sh - -set -vexE -o pipefail -aux prepare diff --git a/test/unit/Makefile.in b/test/unit/Makefile.in new file mode 100644 index 0000000..740eb14 --- /dev/null +++ b/test/unit/Makefile.in @@ -0,0 +1,33 @@ +# Copyright (C) 2011-2012 Red Hat, Inc. All rights reserved. +# +# This file is part of LVM2. +# +# 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. +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +top_builddir = @top_builddir@ + +VPATH = $(srcdir) +ifeq ("@TESTING@", "yes") +SOURCES = bitset_t.c matcher_t.c config_t.c string_t.c run.c +TARGETS = run +endif + +include $(top_builddir)/make.tmpl +ifeq ("$(TESTING)", "yes") +LDLIBS += -ldevmapper @CUNIT_LIBS@ +CFLAGS += @CUNIT_CFLAGS@ + +check: unit + +unit: $(TARGETS) + @echo Running unit tests + LD_LIBRARY_PATH=$(top_builddir)/libdm ./$(TARGETS) +endif diff --git a/test/unit/bitset_t.c b/test/unit/bitset_t.c new file mode 100644 index 0000000..499de32 --- /dev/null +++ b/test/unit/bitset_t.c @@ -0,0 +1,133 @@ +/* + * Copyright (C) 2010 Red Hat, Inc. All rights reserved. + * + * This file is part of LVM2. + * + * 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. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "libdevmapper.h" +#include <CUnit/CUnit.h> + +int bitset_init(void); +int bitset_fini(void); + +enum { + NR_BITS = 137 +}; + +static struct dm_pool *mem; + +int bitset_init(void) { + mem = dm_pool_create("bitset test", 1024); + return mem == NULL; +} + +int bitset_fini(void) { + dm_pool_destroy(mem); + return 0; +} + +static void test_get_next(void) +{ + int i, j, last = 0, first; + dm_bitset_t bs = dm_bitset_create(mem, NR_BITS); + + for (i = 0; i < NR_BITS; i++) + CU_ASSERT(!dm_bit(bs, i)); + + for (i = 0, j = 1; i < NR_BITS; i += j, j++) + dm_bit_set(bs, i); + + first = 1; + for (i = 0, j = 1; i < NR_BITS; i += j, j++) { + if (first) { + last = dm_bit_get_first(bs); + first = 0; + } else + last = dm_bit_get_next(bs, last); + + CU_ASSERT(last == i); + } + + CU_ASSERT(dm_bit_get_next(bs, last) == -1); +} + +static void bit_flip(dm_bitset_t bs, int bit) +{ + int old = dm_bit(bs, bit); + if (old) + dm_bit_clear(bs, bit); + else + dm_bit_set(bs, bit); +} + +static void test_equal(void) +{ + dm_bitset_t bs1 = dm_bitset_create(mem, NR_BITS); + dm_bitset_t bs2 = dm_bitset_create(mem, NR_BITS); + + int i, j; + for (i = 0, j = 1; i < NR_BITS; i += j, j++) { + dm_bit_set(bs1, i); + dm_bit_set(bs2, i); + } + + CU_ASSERT(dm_bitset_equal(bs1, bs2)); + CU_ASSERT(dm_bitset_equal(bs2, bs1)); + + for (i = 0; i < NR_BITS; i++) { + bit_flip(bs1, i); + CU_ASSERT(!dm_bitset_equal(bs1, bs2)); + CU_ASSERT(!dm_bitset_equal(bs2, bs1)); + + CU_ASSERT(dm_bitset_equal(bs1, bs1)); /* comparing with self */ + bit_flip(bs1, i); + } +} + +static void test_and(void) +{ + dm_bitset_t bs1 = dm_bitset_create(mem, NR_BITS); + dm_bitset_t bs2 = dm_bitset_create(mem, NR_BITS); + dm_bitset_t bs3 = dm_bitset_create(mem, NR_BITS); + + int i, j; + for (i = 0, j = 1; i < NR_BITS; i += j, j++) { + dm_bit_set(bs1, i); + dm_bit_set(bs2, i); + } + + dm_bit_and(bs3, bs1, bs2); + + CU_ASSERT(dm_bitset_equal(bs1, bs2)); + CU_ASSERT(dm_bitset_equal(bs1, bs3)); + CU_ASSERT(dm_bitset_equal(bs2, bs3)); + + dm_bit_clear_all(bs1); + dm_bit_clear_all(bs2); + + for (i = 0; i < NR_BITS; i++) { + if (i % 2) + dm_bit_set(bs1, i); + else + dm_bit_set(bs2, i); + } + + dm_bit_and(bs3, bs1, bs2); + for (i = 0; i < NR_BITS; i++) + CU_ASSERT(!dm_bit(bs3, i)); +} + +CU_TestInfo bitset_list[] = { + { (char*)"get_next", test_get_next }, + { (char*)"equal", test_equal }, + { (char*)"and", test_and }, + CU_TEST_INFO_NULL +}; diff --git a/test/unit/config_t.c b/test/unit/config_t.c new file mode 100644 index 0000000..9a8b693 --- /dev/null +++ b/test/unit/config_t.c @@ -0,0 +1,156 @@ +/* + * Copyright (C) 2010 Red Hat, Inc. All rights reserved. + * + * This file is part of LVM2. + * + * 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. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "libdevmapper.h" +#include <CUnit/CUnit.h> + +int config_init(void); +int config_fini(void); + +static struct dm_pool *mem; + +int config_init(void) { + mem = dm_pool_create("config test", 1024); + return mem == NULL; +} + +int config_fini(void) { + dm_pool_destroy(mem); + return 0; +} + +static const char *conf = + "id = \"yada-yada\"\n" + "seqno = 15\n" + "status = [\"READ\", \"WRITE\"]\n" + "flags = []\n" + "extent_size = 8192\n" + "physical_volumes {\n" + " pv0 {\n" + " id = \"abcd-efgh\"\n" + " }\n" + " pv1 {\n" + " id = \"bbcd-efgh\"\n" + " }\n" + " pv2 {\n" + " id = \"cbcd-efgh\"\n" + " }\n" + "}\n"; + +static const char *overlay = + "id = \"yoda-soda\"\n" + "flags = [\"FOO\"]\n" + "physical_volumes {\n" + " pv1 {\n" + " id = \"hgfe-dcba\"\n" + " }\n" + " pv3 {\n" + " id = \"dbcd-efgh\"\n" + " }\n" + "}\n"; + +static void test_parse(void) +{ + struct dm_config_tree *tree = dm_config_from_string(conf); + const struct dm_config_value *value; + + CU_ASSERT((long) tree); + CU_ASSERT(dm_config_has_node(tree->root, "id")); + CU_ASSERT(dm_config_has_node(tree->root, "physical_volumes")); + CU_ASSERT(dm_config_has_node(tree->root, "physical_volumes/pv0")); + CU_ASSERT(dm_config_has_node(tree->root, "physical_volumes/pv0/id")); + + CU_ASSERT(!strcmp(dm_config_find_str(tree->root, "id", "foo"), "yada-yada")); + CU_ASSERT(!strcmp(dm_config_find_str(tree->root, "idt", "foo"), "foo")); + + CU_ASSERT(!strcmp(dm_config_find_str(tree->root, "physical_volumes/pv0/bb", "foo"), "foo")); + CU_ASSERT(!strcmp(dm_config_find_str(tree->root, "physical_volumes/pv0/id", "foo"), "abcd-efgh")); + + CU_ASSERT(!dm_config_get_uint32(tree->root, "id", NULL)); + CU_ASSERT(dm_config_get_uint32(tree->root, "extent_size", NULL)); + + /* FIXME: Currently everything parses as a list, even if it's not */ + // CU_ASSERT(!dm_config_get_list(tree->root, "id", NULL)); + // CU_ASSERT(!dm_config_get_list(tree->root, "extent_size", NULL)); + + CU_ASSERT(dm_config_get_list(tree->root, "flags", &value)); + CU_ASSERT(value->next == NULL); /* an empty list */ + CU_ASSERT(dm_config_get_list(tree->root, "status", &value)); + CU_ASSERT(value->next != NULL); /* a non-empty list */ + + dm_config_destroy(tree); +} + +static void test_clone(void) +{ + struct dm_config_tree *tree = dm_config_from_string(conf); + struct dm_config_node *n = dm_config_clone_node(tree, tree->root, 1); + const struct dm_config_value *value; + + /* Check that the nodes are actually distinct. */ + CU_ASSERT(n != tree->root); + CU_ASSERT(n->sib != tree->root->sib); + CU_ASSERT(dm_config_find_node(n, "physical_volumes") != NULL); + CU_ASSERT(dm_config_find_node(tree->root, "physical_volumes") != NULL); + CU_ASSERT(dm_config_find_node(n, "physical_volumes") != dm_config_find_node(tree->root, "physical_volumes")); + + CU_ASSERT(dm_config_has_node(n, "id")); + CU_ASSERT(dm_config_has_node(n, "physical_volumes")); + CU_ASSERT(dm_config_has_node(n, "physical_volumes/pv0")); + CU_ASSERT(dm_config_has_node(n, "physical_volumes/pv0/id")); + + CU_ASSERT(!strcmp(dm_config_find_str(n, "id", "foo"), "yada-yada")); + CU_ASSERT(!strcmp(dm_config_find_str(n, "idt", "foo"), "foo")); + + CU_ASSERT(!strcmp(dm_config_find_str(n, "physical_volumes/pv0/bb", "foo"), "foo")); + CU_ASSERT(!strcmp(dm_config_find_str(n, "physical_volumes/pv0/id", "foo"), "abcd-efgh")); + + CU_ASSERT(!dm_config_get_uint32(n, "id", NULL)); + CU_ASSERT(dm_config_get_uint32(n, "extent_size", NULL)); + + /* FIXME: Currently everything parses as a list, even if it's not */ + // CU_ASSERT(!dm_config_get_list(tree->root, "id", NULL)); + // CU_ASSERT(!dm_config_get_list(tree->root, "extent_size", NULL)); + + CU_ASSERT(dm_config_get_list(n, "flags", &value)); + CU_ASSERT(value->next == NULL); /* an empty list */ + CU_ASSERT(dm_config_get_list(n, "status", &value)); + CU_ASSERT(value->next != NULL); /* a non-empty list */ + + dm_config_destroy(tree); +} + +static void test_cascade(void) +{ + struct dm_config_tree *t1 = dm_config_from_string(conf), + *t2 = dm_config_from_string(overlay), + *tree = dm_config_insert_cascaded_tree(t2, t1); + + CU_ASSERT(!strcmp(dm_config_tree_find_str(tree, "id", "foo"), "yoda-soda")); + CU_ASSERT(!strcmp(dm_config_tree_find_str(tree, "idt", "foo"), "foo")); + + CU_ASSERT(!strcmp(dm_config_tree_find_str(tree, "physical_volumes/pv0/bb", "foo"), "foo")); + CU_ASSERT(!strcmp(dm_config_tree_find_str(tree, "physical_volumes/pv1/id", "foo"), "hgfe-dcba")); + CU_ASSERT(!strcmp(dm_config_tree_find_str(tree, "physical_volumes/pv3/id", "foo"), "dbcd-efgh")); + + dm_config_destroy(t1); + dm_config_destroy(t2); +} + +CU_TestInfo config_list[] = { + { (char*)"parse", test_parse }, + { (char*)"clone", test_clone }, + { (char*)"cascade", test_cascade }, + CU_TEST_INFO_NULL +}; diff --git a/test/unit/matcher_data.h b/test/unit/matcher_data.h new file mode 100644 index 0000000..97dbbfe --- /dev/null +++ b/test/unit/matcher_data.h @@ -0,0 +1,1013 @@ +struct check_item { + const char *str; + int expected; +}; + +static const char *dev_patterns[] = { + "loop/[0-9]+", + "hd[a-d][0-5]+", + NULL +}; + +static const char *nonprint_patterns[] = { + "foo\x80" "bar", + "foo\xc2" "b", + "\x80", + NULL +}; + +static const struct check_item nonprint[] = { + { "foo\x2e" "bar", 0 }, + { "foo\x80" "bar", 3 }, + { "foo\xc2" "b", 2 }, + { "\x80", 3 }, + { NULL, 0 } +}; + +static const char *random_patterns[] = { + "(((a?)(([Ub]*)|z))((([qr]|X)+)([Qn]*)))+", + "[HZejtuw]*", + "((B|s)*)|(((([Fv]l)(N+))(([el]|C)(tJ)))?)", + "((([Ma]?)|(t*))*)|((([cm]E)|(M?))|(([BE][EV])|([Qj][Mh])))", + "(((([bw]*)|([IO]*))((zK)*))|(((pU)|(i|q))|((z?)|([HL]?))))*", + "((([Pt]?)|[Tr])?)((Hq)*)", + "[HOXcfgikosvwxz]", + "[BCEFGHNPTUWfjlprsy]", + "((((aD)*)|([Xo]+))+)(([HKn](([Eq]|[JQ])(I*)))*)", + "([LNWYeghv]|e)*", + "(((y(L*))*)|((([EP]+)(W+))*))*", + "U*", + "((((R+)(W|[Qr]))|([py]+))+)([LM]*)", + "(([DOjx](D(b?)))|([Ke]*))*", + "((([ls](c|[FT]))*)([JS]*))*", + "((l?)|(([Gz]+)|(D*)))*", + "[ABgjn]", + "(((q|[dg])?)|([Uk]*))((([Fl]?)|([Ry]+))|(([IR]|c)|(T?)))", + "((([an]|P)|[Jw])((a*)|(m*)))*", + "((((R[ht])(h+))?)|(([pz](n?))+))+", + "(((([Dc]b)([Sp][Ii]))|((k|F)*))|[Uiovz])*", + "[Res]*", + "[Zl]|a", + "^[ANZdf]$", + "[En]|(((Q+)(U+))([pt]*))", + "[ADEIMQUWXZhklrsvz]", + "(((S(y*))*)|(j*))*", + "n*", + "[NUau]*", + "((((Z*)(D|[Nd]))|(([np]|B)+))|(([Xy][Fi])*))+", + "((([EZ]?)|(d[HR]))*)((([Hg]|q)(P+))*)", + "q", + "((m*)|(p|B))|((((x?)|(t+))(([Sb][PX])(O|[HM])))+)", + "((((A*)(z[RS]))*)|(((z+)(Q*))+))*", + "(((M*)([Uu]*))+)|[Uk]", + "[imv]", + "[GLSchtw](([Yw]((F[Dd])|([Tw]+)))?)", + "([MOZj]*)(S|[Wknr])", + "((G|q)*)[BHKN]", + "((((NW)|([Ao]?))|((l|[UV])+))+)|((i|(z*))*)", + "((((Z+)|([IR]?))|(L*))|([JKQ]+))+", + "([Bdin](S*))+", + "[HLNSTp]*", + "(((J*)([Bq]|[Yu]))*)|([Kv]*)", + "(((([BJ]|[Zy])(wI))*)(y*))+", + "(((hF)+)|(H*))*", + "((([QU][Pj])([GQ]?))+)|[PWo]", + "(((([cq][BX])?)|((f[DI])*))*)(([GM]*)[SVYr])", + "(([Zt]*)|((qx)|(([BV]+)(f?))))*", + "[ILWYhsx]*", + "(([Uy]*)|[sv])|([NSc]*)", + "((c*)|([JUfhy]?))+", + "(((q*)([So]*))(((g[jq])(j?))+))*", + "((b+)|(((T+)([fw]T))?))*", + "((([DS]?)|([Th]|u))(Q*))*", + "[FKLX]|((([fw](L?))(([gq]*)|(O?)))?)", + "((([HZ]+)u)*)|[APWijn]", + "(e*)|(((v?)|((J+)(Hb)))?)", + "(e|((w+)f))*", + "[BEHKPQVdelnqy]", + "((((B|N)(s*))|[Rr])(((g?)|([rv]+))+))+", + "(((s*)|(K*))([AP]G))*", + "[CELTp]", + "(([Fq]?)|([Al]+))*", + "((((r?)|(y[jx]))|([mp]*))+)|((B(S*))*)", + "((([Eq]+)|(Y[ds]))|(x|(i|[Ku])))[IJNrvy]", + "((([NO]*)[Ix])+)([Jenq]+)", + "(((([HP]*)(j|y))*)[Ylqvy])*", + "[PTv]+", + "[AINSZhpx]|([EOYZ]*)", + "([ABCFQv]*)((([Zx]|h)+)|([ej]*))", + "((([pr]*)|(([Dq]|p)|(H?)))?)([NRUXmoq]*)", + "(([er]*)|([mx]*))(((nV)([am]?))+)", + "[BHPRlpu]", + "(((([Ah]|[tx])|(e|[uy]))?)((([fl]+)([Vz]|v))*))*", + "[AGdm]", + "(((K*)^(O*)$)|(B?))*", + "((([Ks]|[Ka])*)|([FSTab]?))?", + "(([kw]+)[ei])(([Hy]*)(([Mc]*)|(G|f)))", + "((((e*)|(Zf))|(R|[nq]))((([Jz]v)([Rj]+))+))*", + "(((a?)|(e?))(([Uc]*)(S+)))*", + "((((E+)([MZ]?))+)|(((s|[Az])|z)*))?", + "((((i[MO])*)|((LH)*))|(((BA)|([AI]+))|[Ug]))*", + "[EGHILcho]*", + "(((Z[vw])?)((z|g)+))(((H|U)([iv]Q))|([qw]?))", + "(([ehmr]|((L[Uw])*))+)((a+)I)", + "[EKNSWYagj](((v|[TX])|([Uk]+))*)", + "(((R[Mo])|(O*))|([Fm]|([qw]*)))((m*)|((S|[Ki])?))", + "((((kP)|c)?)((([do]+)|([Gi]?))*))*", + "((^(B|W)$|([Ww]+))([no]*))|((([iv]?)|(M*))|((x|L)?))", + "[AEGPRSbcfhsy]", + "[Wbcf]|((([MO]?)|([NT]|m))(([Oo]?)([Wg]*)))", + "(((YZ)*)[PQVei])*", + "[GJKYt][AEGWdegmnt]", + "^[CDEGJKNUVYZagkv]$", + "([DPWbx]*)|(((q|B)|(P|u))((M[Bq])*))", + "[FHIJRTVYZdiorsuvz]*", + "([MWoqvz]*)|^(l*)", + "(((I|[Rx])*)((X[Mf])([Xa]L)))([Ha]|([HY]*))", + "(((l|[Sd])*)((([Ix]+)|([XY]?))(Z*)))+", + NULL +}; + +struct check_item devices[] = { + { "/dev", 0 }, + { "/dev/.devfsd", 0 }, + { "/dev/cpu", 0 }, + { "/dev/cpu/mtrr", 0 }, + { "/dev/netlink", 0 }, + { "/dev/netlink/route", 0 }, + { "/dev/netlink/skip", 0 }, + { "/dev/netlink/USERSOCK", 0 }, + { "/dev/netlink/fwmonitor", 0 }, + { "/dev/netlink/ARPD", 0 }, + { "/dev/netlink/ROUTE6", 0 }, + { "/dev/netlink/IP6_FW", 0 }, + { "/dev/netlink/tap0", 0 }, + { "/dev/netlink/tap1", 0 }, + { "/dev/netlink/tap2", 0 }, + { "/dev/netlink/tap3", 0 }, + { "/dev/netlink/tap4", 0 }, + { "/dev/netlink/tap5", 0 }, + { "/dev/netlink/tap6", 0 }, + { "/dev/netlink/tap7", 0 }, + { "/dev/netlink/tap8", 0 }, + { "/dev/netlink/tap9", 0 }, + { "/dev/netlink/tap10", 0 }, + { "/dev/netlink/tap11", 0 }, + { "/dev/netlink/tap12", 0 }, + { "/dev/netlink/tap13", 0 }, + { "/dev/netlink/tap14", 0 }, + { "/dev/netlink/tap15", 0 }, + { "/dev/shm", 0 }, + { "/dev/mem", 0 }, + { "/dev/kmem", 0 }, + { "/dev/null", 0 }, + { "/dev/port", 0 }, + { "/dev/zero", 0 }, + { "/dev/full", 0 }, + { "/dev/random", 0 }, + { "/dev/urandom", 0 }, + { "/dev/tty", 0 }, + { "/dev/console", 0 }, + { "/dev/vc", 0 }, + { "/dev/vc/1", 0 }, + { "/dev/vc/2", 0 }, + { "/dev/vc/3", 0 }, + { "/dev/vc/4", 0 }, + { "/dev/vc/5", 0 }, + { "/dev/vc/6", 0 }, + { "/dev/vc/7", 0 }, + { "/dev/vc/8", 0 }, + { "/dev/vc/9", 0 }, + { "/dev/vc/10", 0 }, + { "/dev/vc/11", 0 }, + { "/dev/vc/12", 0 }, + { "/dev/vc/13", 0 }, + { "/dev/vc/14", 0 }, + { "/dev/vc/15", 0 }, + { "/dev/vc/16", 0 }, + { "/dev/vc/17", 0 }, + { "/dev/vc/18", 0 }, + { "/dev/vc/19", 0 }, + { "/dev/vc/20", 0 }, + { "/dev/vc/21", 0 }, + { "/dev/vc/22", 0 }, + { "/dev/vc/23", 0 }, + { "/dev/vc/24", 0 }, + { "/dev/vc/25", 0 }, + { "/dev/vc/26", 0 }, + { "/dev/vc/27", 0 }, + { "/dev/vc/28", 0 }, + { "/dev/vc/29", 0 }, + { "/dev/vc/30", 0 }, + { "/dev/vc/31", 0 }, + { "/dev/vc/32", 0 }, + { "/dev/vc/33", 0 }, + { "/dev/vc/34", 0 }, + { "/dev/vc/35", 0 }, + { "/dev/vc/36", 0 }, + { "/dev/vc/37", 0 }, + { "/dev/vc/38", 0 }, + { "/dev/vc/39", 0 }, + { "/dev/vc/40", 0 }, + { "/dev/vc/41", 0 }, + { "/dev/vc/42", 0 }, + { "/dev/vc/43", 0 }, + { "/dev/vc/44", 0 }, + { "/dev/vc/45", 0 }, + { "/dev/vc/46", 0 }, + { "/dev/vc/47", 0 }, + { "/dev/vc/48", 0 }, + { "/dev/vc/49", 0 }, + { "/dev/vc/50", 0 }, + { "/dev/vc/51", 0 }, + { "/dev/vc/52", 0 }, + { "/dev/vc/53", 0 }, + { "/dev/vc/54", 0 }, + { "/dev/vc/55", 0 }, + { "/dev/vc/56", 0 }, + { "/dev/vc/57", 0 }, + { "/dev/vc/58", 0 }, + { "/dev/vc/59", 0 }, + { "/dev/vc/60", 0 }, + { "/dev/vc/61", 0 }, + { "/dev/vc/62", 0 }, + { "/dev/vc/63", 0 }, + { "/dev/vc/0", 0 }, + { "/dev/ptmx", 0 }, + { "/dev/misc", 0 }, + { "/dev/misc/psaux", 0 }, + { "/dev/pty", 0 }, + { "/dev/pty/m0", 0 }, + { "/dev/pty/m1", 0 }, + { "/dev/pty/m2", 0 }, + { "/dev/pty/m3", 0 }, + { "/dev/pty/m4", 0 }, + { "/dev/pty/m5", 0 }, + { "/dev/pty/m6", 0 }, + { "/dev/pty/m7", 0 }, + { "/dev/pty/m8", 0 }, + { "/dev/pty/m9", 0 }, + { "/dev/pty/m10", 0 }, + { "/dev/pty/m11", 0 }, + { "/dev/pty/m12", 0 }, + { "/dev/pty/m13", 0 }, + { "/dev/pty/m14", 0 }, + { "/dev/pty/m15", 0 }, + { "/dev/pty/m16", 0 }, + { "/dev/pty/m17", 0 }, + { "/dev/pty/m18", 0 }, + { "/dev/pty/m19", 0 }, + { "/dev/pty/m20", 0 }, + { "/dev/pty/m21", 0 }, + { "/dev/pty/m22", 0 }, + { "/dev/pty/m23", 0 }, + { "/dev/pty/m24", 0 }, + { "/dev/pty/m25", 0 }, + { "/dev/pty/m26", 0 }, + { "/dev/pty/m27", 0 }, + { "/dev/pty/m28", 0 }, + { "/dev/pty/m29", 0 }, + { "/dev/pty/m30", 0 }, + { "/dev/pty/m31", 0 }, + { "/dev/pty/m32", 0 }, + { "/dev/pty/m33", 0 }, + { "/dev/pty/m34", 0 }, + { "/dev/pty/m35", 0 }, + { "/dev/pty/m36", 0 }, + { "/dev/pty/m37", 0 }, + { "/dev/pty/m38", 0 }, + { "/dev/pty/m39", 0 }, + { "/dev/pty/m40", 0 }, + { "/dev/pty/m41", 0 }, + { "/dev/pty/m42", 0 }, + { "/dev/pty/m43", 0 }, + { "/dev/pty/m44", 0 }, + { "/dev/pty/m45", 0 }, + { "/dev/pty/m46", 0 }, + { "/dev/pty/m47", 0 }, + { "/dev/pty/m48", 0 }, + { "/dev/pty/m49", 0 }, + { "/dev/pty/m50", 0 }, + { "/dev/pty/m51", 0 }, + { "/dev/pty/m52", 0 }, + { "/dev/pty/m53", 0 }, + { "/dev/pty/m54", 0 }, + { "/dev/pty/m55", 0 }, + { "/dev/pty/m56", 0 }, + { "/dev/pty/m57", 0 }, + { "/dev/pty/m58", 0 }, + { "/dev/pty/m59", 0 }, + { "/dev/pty/m60", 0 }, + { "/dev/pty/m61", 0 }, + { "/dev/pty/m62", 0 }, + { "/dev/pty/m63", 0 }, + { "/dev/pty/m64", 0 }, + { "/dev/pty/m65", 0 }, + { "/dev/pty/m66", 0 }, + { "/dev/pty/m67", 0 }, + { "/dev/pty/m68", 0 }, + { "/dev/pty/m69", 0 }, + { "/dev/pty/m70", 0 }, + { "/dev/pty/m71", 0 }, + { "/dev/pty/m72", 0 }, + { "/dev/pty/m73", 0 }, + { "/dev/pty/m74", 0 }, + { "/dev/pty/m75", 0 }, + { "/dev/pty/m76", 0 }, + { "/dev/pty/m77", 0 }, + { "/dev/pty/m78", 0 }, + { "/dev/pty/m79", 0 }, + { "/dev/pty/m80", 0 }, + { "/dev/pty/m81", 0 }, + { "/dev/pty/m82", 0 }, + { "/dev/pty/m83", 0 }, + { "/dev/pty/m84", 0 }, + { "/dev/pty/m85", 0 }, + { "/dev/pty/m86", 0 }, + { "/dev/pty/m87", 0 }, + { "/dev/pty/m88", 0 }, + { "/dev/pty/m89", 0 }, + { "/dev/pty/m90", 0 }, + { "/dev/pty/m91", 0 }, + { "/dev/pty/m92", 0 }, + { "/dev/pty/m93", 0 }, + { "/dev/pty/m94", 0 }, + { "/dev/pty/m95", 0 }, + { "/dev/pty/m96", 0 }, + { "/dev/pty/m97", 0 }, + { "/dev/pty/m98", 0 }, + { "/dev/pty/m99", 0 }, + { "/dev/pty/m100", 0 }, + { "/dev/pty/m101", 0 }, + { "/dev/pty/m102", 0 }, + { "/dev/pty/m103", 0 }, + { "/dev/pty/m104", 0 }, + { "/dev/pty/m105", 0 }, + { "/dev/pty/m106", 0 }, + { "/dev/pty/m107", 0 }, + { "/dev/pty/m108", 0 }, + { "/dev/pty/m109", 0 }, + { "/dev/pty/m110", 0 }, + { "/dev/pty/m111", 0 }, + { "/dev/pty/m112", 0 }, + { "/dev/pty/m113", 0 }, + { "/dev/pty/m114", 0 }, + { "/dev/pty/m115", 0 }, + { "/dev/pty/m116", 0 }, + { "/dev/pty/m117", 0 }, + { "/dev/pty/m118", 0 }, + { "/dev/pty/m119", 0 }, + { "/dev/pty/m120", 0 }, + { "/dev/pty/m121", 0 }, + { "/dev/pty/m122", 0 }, + { "/dev/pty/m123", 0 }, + { "/dev/pty/m124", 0 }, + { "/dev/pty/m125", 0 }, + { "/dev/pty/m126", 0 }, + { "/dev/pty/m127", 0 }, + { "/dev/pty/m128", 0 }, + { "/dev/pty/m129", 0 }, + { "/dev/pty/m130", 0 }, + { "/dev/pty/m131", 0 }, + { "/dev/pty/m132", 0 }, + { "/dev/pty/m133", 0 }, + { "/dev/pty/m134", 0 }, + { "/dev/pty/m135", 0 }, + { "/dev/pty/m136", 0 }, + { "/dev/pty/m137", 0 }, + { "/dev/pty/m138", 0 }, + { "/dev/pty/m139", 0 }, + { "/dev/pty/m140", 0 }, + { "/dev/pty/m141", 0 }, + { "/dev/pty/m142", 0 }, + { "/dev/pty/m143", 0 }, + { "/dev/pty/m144", 0 }, + { "/dev/pty/m145", 0 }, + { "/dev/pty/m146", 0 }, + { "/dev/pty/m147", 0 }, + { "/dev/pty/m148", 0 }, + { "/dev/pty/m149", 0 }, + { "/dev/pty/m150", 0 }, + { "/dev/pty/m151", 0 }, + { "/dev/pty/m152", 0 }, + { "/dev/pty/m153", 0 }, + { "/dev/pty/m154", 0 }, + { "/dev/pty/m155", 0 }, + { "/dev/pty/m156", 0 }, + { "/dev/pty/m157", 0 }, + { "/dev/pty/m158", 0 }, + { "/dev/pty/m159", 0 }, + { "/dev/pty/m160", 0 }, + { "/dev/pty/m161", 0 }, + { "/dev/pty/m162", 0 }, + { "/dev/pty/m163", 0 }, + { "/dev/pty/m164", 0 }, + { "/dev/pty/m165", 0 }, + { "/dev/pty/m166", 0 }, + { "/dev/pty/m167", 0 }, + { "/dev/pty/m168", 0 }, + { "/dev/pty/m169", 0 }, + { "/dev/pty/m170", 0 }, + { "/dev/pty/m171", 0 }, + { "/dev/pty/m172", 0 }, + { "/dev/pty/m173", 0 }, + { "/dev/pty/m174", 0 }, + { "/dev/pty/m175", 0 }, + { "/dev/pty/m176", 0 }, + { "/dev/pty/m177", 0 }, + { "/dev/pty/m178", 0 }, + { "/dev/pty/m179", 0 }, + { "/dev/pty/m180", 0 }, + { "/dev/pty/m181", 0 }, + { "/dev/pty/m182", 0 }, + { "/dev/pty/m183", 0 }, + { "/dev/pty/m184", 0 }, + { "/dev/pty/m185", 0 }, + { "/dev/pty/m186", 0 }, + { "/dev/pty/m187", 0 }, + { "/dev/pty/m188", 0 }, + { "/dev/pty/m189", 0 }, + { "/dev/pty/m190", 0 }, + { "/dev/pty/m191", 0 }, + { "/dev/pty/m192", 0 }, + { "/dev/pty/m193", 0 }, + { "/dev/pty/m194", 0 }, + { "/dev/pty/m195", 0 }, + { "/dev/pty/m196", 0 }, + { "/dev/pty/m197", 0 }, + { "/dev/pty/m198", 0 }, + { "/dev/pty/m199", 0 }, + { "/dev/pty/m200", 0 }, + { "/dev/pty/m201", 0 }, + { "/dev/pty/m202", 0 }, + { "/dev/pty/m203", 0 }, + { "/dev/pty/m204", 0 }, + { "/dev/pty/m205", 0 }, + { "/dev/pty/m206", 0 }, + { "/dev/pty/m207", 0 }, + { "/dev/pty/m208", 0 }, + { "/dev/pty/m209", 0 }, + { "/dev/pty/m210", 0 }, + { "/dev/pty/m211", 0 }, + { "/dev/pty/m212", 0 }, + { "/dev/pty/m213", 0 }, + { "/dev/pty/m214", 0 }, + { "/dev/pty/m215", 0 }, + { "/dev/pty/m216", 0 }, + { "/dev/pty/m217", 0 }, + { "/dev/pty/m218", 0 }, + { "/dev/pty/m219", 0 }, + { "/dev/pty/m220", 0 }, + { "/dev/pty/m221", 0 }, + { "/dev/pty/m222", 0 }, + { "/dev/pty/m223", 0 }, + { "/dev/pty/m224", 0 }, + { "/dev/pty/m225", 0 }, + { "/dev/pty/m226", 0 }, + { "/dev/pty/m227", 0 }, + { "/dev/pty/m228", 0 }, + { "/dev/pty/m229", 0 }, + { "/dev/pty/m230", 0 }, + { "/dev/pty/m231", 0 }, + { "/dev/pty/m232", 0 }, + { "/dev/pty/m233", 0 }, + { "/dev/pty/m234", 0 }, + { "/dev/pty/m235", 0 }, + { "/dev/pty/m236", 0 }, + { "/dev/pty/m237", 0 }, + { "/dev/pty/m238", 0 }, + { "/dev/pty/m239", 0 }, + { "/dev/pty/m240", 0 }, + { "/dev/pty/m241", 0 }, + { "/dev/pty/m242", 0 }, + { "/dev/pty/m243", 0 }, + { "/dev/pty/m244", 0 }, + { "/dev/pty/m245", 0 }, + { "/dev/pty/m246", 0 }, + { "/dev/pty/m247", 0 }, + { "/dev/pty/m248", 0 }, + { "/dev/pty/m249", 0 }, + { "/dev/pty/m250", 0 }, + { "/dev/pty/m251", 0 }, + { "/dev/pty/m252", 0 }, + { "/dev/pty/m253", 0 }, + { "/dev/pty/m254", 0 }, + { "/dev/pty/m255", 0 }, + { "/dev/pts", 0 }, + { "/dev/pts/0", 0 }, + { "/dev/pts/1", 0 }, + { "/dev/pts/2", 0 }, + { "/dev/pts/3", 0 }, + { "/dev/pts/4", 0 }, + { "/dev/pts/5", 0 }, + { "/dev/pts/6", 0 }, + { "/dev/pts/7", 0 }, + { "/dev/vcc", 0 }, + { "/dev/vcc/0", 0 }, + { "/dev/vcc/a", 0 }, + { "/dev/vcc/1", 0 }, + { "/dev/vcc/a1", 0 }, + { "/dev/vcc/2", 0 }, + { "/dev/vcc/a2", 0 }, + { "/dev/vcc/3", 0 }, + { "/dev/vcc/a3", 0 }, + { "/dev/vcc/5", 0 }, + { "/dev/vcc/a5", 0 }, + { "/dev/vcc/4", 0 }, + { "/dev/vcc/a4", 0 }, + { "/dev/vcc/6", 0 }, + { "/dev/vcc/a6", 0 }, + { "/dev/vcc/7", 0 }, + { "/dev/vcc/a7", 0 }, + { "/dev/tts", 0 }, + { "/dev/tts/0", 0 }, + { "/dev/cua", 0 }, + { "/dev/cua/0", 0 }, + { "/dev/ide", 0 }, + { "/dev/ide/host0", 0 }, + { "/dev/ide/host0/bus0", 0 }, + { "/dev/ide/host0/bus0/target0", 0 }, + { "/dev/ide/host0/bus0/target0/lun0", 0 }, + { "/dev/ide/host0/bus0/target0/lun0/disc", 0 }, + { "/dev/ide/host0/bus0/target0/lun0/part1", 0 }, + { "/dev/ide/host0/bus0/target0/lun0/part2", 0 }, + { "/dev/ide/host0/bus0/target0/lun0/part3", 0 }, + { "/dev/ide/host0/bus0/target0/lun0/part4", 0 }, + { "/dev/ide/host0/bus0/target0/lun0/part5", 0 }, + { "/dev/ide/host0/bus0/target0/lun0/part6", 0 }, + { "/dev/ide/host0/bus0/target0/lun0/part7", 0 }, + { "/dev/ide/host0/bus0/target0/lun0/part8", 0 }, + { "/dev/ide/host0/bus0/target1", 0 }, + { "/dev/ide/host0/bus0/target1/lun0", 0 }, + { "/dev/ide/host0/bus0/target1/lun0/disc", 0 }, + { "/dev/ide/host0/bus0/target1/lun0/part1", 0 }, + { "/dev/ide/host0/bus1", 0 }, + { "/dev/ide/host0/bus1/target0", 0 }, + { "/dev/ide/host0/bus1/target0/lun0", 0 }, + { "/dev/ide/host0/bus1/target0/lun0/disc", 0 }, + { "/dev/ide/host0/bus1/target0/lun0/part1", 0 }, + { "/dev/ide/host0/bus1/target1", 0 }, + { "/dev/ide/host0/bus1/target1/lun0", 0 }, + { "/dev/discs", 0 }, + { "/dev/discs/disc0", 0 }, + { "/dev/discs/disc1", 0 }, + { "/dev/discs/disc2", 0 }, + { "/dev/floppy", 0 }, + { "/dev/floppy/0u1440", 0 }, + { "/dev/floppy/0u1680", 0 }, + { "/dev/floppy/0u1722", 0 }, + { "/dev/floppy/0u1743", 0 }, + { "/dev/floppy/0u1760", 0 }, + { "/dev/floppy/0u1920", 0 }, + { "/dev/floppy/0u1840", 0 }, + { "/dev/floppy/0u1600", 0 }, + { "/dev/floppy/0u360", 0 }, + { "/dev/floppy/0u720", 0 }, + { "/dev/floppy/0u820", 0 }, + { "/dev/floppy/0u830", 0 }, + { "/dev/floppy/0u1040", 0 }, + { "/dev/floppy/0u1120", 0 }, + { "/dev/floppy/0u800", 0 }, + { "/dev/floppy/0", 0 }, + { "/dev/loop", 0 }, + { "/dev/loop/0", 1 }, + { "/dev/loop/1", 1 }, + { "/dev/loop/2", 1 }, + { "/dev/loop/3", 1 }, + { "/dev/loop/4", 1 }, + { "/dev/loop/5", 1 }, + { "/dev/loop/6", 1 }, + { "/dev/loop/7", 1 }, + { "/dev/cdroms", 0 }, + { "/dev/sound", 0 }, + { "/dev/sound/dsp", 0 }, + { "/dev/sound/dsp1", 0 }, + { "/dev/sound/mixer", 0 }, + { "/dev/sound/midi", 0 }, + { "/dev/usb", 0 }, + { "/dev/root", 0 }, + { "/dev/initctl", 0 }, + { "/dev/xconsole", 0 }, + { "/dev/fd", 0 }, + { "/dev/stdin", 0 }, + { "/dev/stdout", 0 }, + { "/dev/stderr", 0 }, + { "/dev/route", 0 }, + { "/dev/skip", 0 }, + { "/dev/USERSOCK", 0 }, + { "/dev/fwmonitor", 0 }, + { "/dev/ARPD", 0 }, + { "/dev/ROUTE6", 0 }, + { "/dev/IP6_FW", 0 }, + { "/dev/tap0", 0 }, + { "/dev/tap1", 0 }, + { "/dev/tap2", 0 }, + { "/dev/tap3", 0 }, + { "/dev/tap4", 0 }, + { "/dev/tap5", 0 }, + { "/dev/tap6", 0 }, + { "/dev/tap7", 0 }, + { "/dev/tap8", 0 }, + { "/dev/tap9", 0 }, + { "/dev/tap10", 0 }, + { "/dev/tap11", 0 }, + { "/dev/tap12", 0 }, + { "/dev/tap13", 0 }, + { "/dev/tap14", 0 }, + { "/dev/tap15", 0 }, + { "/dev/tty1", 0 }, + { "/dev/tty2", 0 }, + { "/dev/tty3", 0 }, + { "/dev/tty4", 0 }, + { "/dev/tty5", 0 }, + { "/dev/tty6", 0 }, + { "/dev/tty7", 0 }, + { "/dev/tty8", 0 }, + { "/dev/tty9", 0 }, + { "/dev/tty10", 0 }, + { "/dev/tty11", 0 }, + { "/dev/tty12", 0 }, + { "/dev/tty13", 0 }, + { "/dev/tty14", 0 }, + { "/dev/tty15", 0 }, + { "/dev/tty16", 0 }, + { "/dev/tty17", 0 }, + { "/dev/tty18", 0 }, + { "/dev/tty19", 0 }, + { "/dev/tty20", 0 }, + { "/dev/tty21", 0 }, + { "/dev/tty22", 0 }, + { "/dev/tty23", 0 }, + { "/dev/tty24", 0 }, + { "/dev/tty25", 0 }, + { "/dev/tty26", 0 }, + { "/dev/tty27", 0 }, + { "/dev/tty28", 0 }, + { "/dev/tty29", 0 }, + { "/dev/tty30", 0 }, + { "/dev/tty31", 0 }, + { "/dev/tty32", 0 }, + { "/dev/tty33", 0 }, + { "/dev/tty34", 0 }, + { "/dev/tty35", 0 }, + { "/dev/tty36", 0 }, + { "/dev/tty37", 0 }, + { "/dev/tty38", 0 }, + { "/dev/tty39", 0 }, + { "/dev/tty40", 0 }, + { "/dev/tty41", 0 }, + { "/dev/tty42", 0 }, + { "/dev/tty43", 0 }, + { "/dev/tty44", 0 }, + { "/dev/tty45", 0 }, + { "/dev/tty46", 0 }, + { "/dev/tty47", 0 }, + { "/dev/tty48", 0 }, + { "/dev/tty49", 0 }, + { "/dev/tty50", 0 }, + { "/dev/tty51", 0 }, + { "/dev/tty52", 0 }, + { "/dev/tty53", 0 }, + { "/dev/tty54", 0 }, + { "/dev/tty55", 0 }, + { "/dev/tty56", 0 }, + { "/dev/tty57", 0 }, + { "/dev/tty58", 0 }, + { "/dev/tty59", 0 }, + { "/dev/tty60", 0 }, + { "/dev/tty61", 0 }, + { "/dev/tty62", 0 }, + { "/dev/tty63", 0 }, + { "/dev/tty0", 0 }, + { "/dev/psaux", 0 }, + { "/dev/ptyp0", 0 }, + { "/dev/ptyp1", 0 }, + { "/dev/ptyp2", 0 }, + { "/dev/ptyp3", 0 }, + { "/dev/ptyp4", 0 }, + { "/dev/ptyp5", 0 }, + { "/dev/ptyp6", 0 }, + { "/dev/ptyp7", 0 }, + { "/dev/ptyp8", 0 }, + { "/dev/ptyp9", 0 }, + { "/dev/ptypa", 0 }, + { "/dev/ptypb", 0 }, + { "/dev/ptypc", 0 }, + { "/dev/ptypd", 0 }, + { "/dev/ptype", 0 }, + { "/dev/ptypf", 0 }, + { "/dev/ptyq0", 0 }, + { "/dev/ptyq1", 0 }, + { "/dev/ptyq2", 0 }, + { "/dev/ptyq3", 0 }, + { "/dev/ptyq4", 0 }, + { "/dev/ptyq5", 0 }, + { "/dev/ptyq6", 0 }, + { "/dev/ptyq7", 0 }, + { "/dev/ptyq8", 0 }, + { "/dev/ptyq9", 0 }, + { "/dev/ptyqa", 0 }, + { "/dev/ptyqb", 0 }, + { "/dev/ptyqc", 0 }, + { "/dev/ptyqd", 0 }, + { "/dev/ptyqe", 0 }, + { "/dev/ptyqf", 0 }, + { "/dev/ptyr0", 0 }, + { "/dev/ptyr1", 0 }, + { "/dev/ptyr2", 0 }, + { "/dev/ptyr3", 0 }, + { "/dev/ptyr4", 0 }, + { "/dev/ptyr5", 0 }, + { "/dev/ptyr6", 0 }, + { "/dev/ptyr7", 0 }, + { "/dev/ptyr8", 0 }, + { "/dev/ptyr9", 0 }, + { "/dev/ptyra", 0 }, + { "/dev/ptyrb", 0 }, + { "/dev/ptyrc", 0 }, + { "/dev/ptyrd", 0 }, + { "/dev/ptyre", 0 }, + { "/dev/ptyrf", 0 }, + { "/dev/ptys0", 0 }, + { "/dev/ptys1", 0 }, + { "/dev/ptys2", 0 }, + { "/dev/ptys3", 0 }, + { "/dev/ptys4", 0 }, + { "/dev/ptys5", 0 }, + { "/dev/ptys6", 0 }, + { "/dev/ptys7", 0 }, + { "/dev/ptys8", 0 }, + { "/dev/ptys9", 0 }, + { "/dev/ptysa", 0 }, + { "/dev/ptysb", 0 }, + { "/dev/ptysc", 0 }, + { "/dev/ptysd", 0 }, + { "/dev/ptyse", 0 }, + { "/dev/ptysf", 0 }, + { "/dev/ptyt0", 0 }, + { "/dev/ptyt1", 0 }, + { "/dev/ptyt2", 0 }, + { "/dev/ptyt3", 0 }, + { "/dev/ptyt4", 0 }, + { "/dev/ptyt5", 0 }, + { "/dev/ptyt6", 0 }, + { "/dev/ptyt7", 0 }, + { "/dev/ptyt8", 0 }, + { "/dev/ptyt9", 0 }, + { "/dev/ptyta", 0 }, + { "/dev/ptytb", 0 }, + { "/dev/ptytc", 0 }, + { "/dev/ptytd", 0 }, + { "/dev/ptyte", 0 }, + { "/dev/ptytf", 0 }, + { "/dev/ptyu0", 0 }, + { "/dev/ptyu1", 0 }, + { "/dev/ptyu2", 0 }, + { "/dev/ptyu3", 0 }, + { "/dev/ptyu4", 0 }, + { "/dev/ptyu5", 0 }, + { "/dev/ptyu6", 0 }, + { "/dev/ptyu7", 0 }, + { "/dev/ptyu8", 0 }, + { "/dev/ptyu9", 0 }, + { "/dev/ptyua", 0 }, + { "/dev/ptyub", 0 }, + { "/dev/ptyuc", 0 }, + { "/dev/ptyud", 0 }, + { "/dev/ptyue", 0 }, + { "/dev/ptyuf", 0 }, + { "/dev/ptyv0", 0 }, + { "/dev/ptyv1", 0 }, + { "/dev/ptyv2", 0 }, + { "/dev/ptyv3", 0 }, + { "/dev/ptyv4", 0 }, + { "/dev/ptyv5", 0 }, + { "/dev/ptyv6", 0 }, + { "/dev/ptyv7", 0 }, + { "/dev/ptyv8", 0 }, + { "/dev/ptyv9", 0 }, + { "/dev/ptyva", 0 }, + { "/dev/ptyvb", 0 }, + { "/dev/ptyvc", 0 }, + { "/dev/ptyvd", 0 }, + { "/dev/ptyve", 0 }, + { "/dev/ptyvf", 0 }, + { "/dev/ptyw0", 0 }, + { "/dev/ptyw1", 0 }, + { "/dev/ptyw2", 0 }, + { "/dev/ptyw3", 0 }, + { "/dev/ptyw4", 0 }, + { "/dev/ptyw5", 0 }, + { "/dev/ptyw6", 0 }, + { "/dev/ptyw7", 0 }, + { "/dev/ptyw8", 0 }, + { "/dev/ptyw9", 0 }, + { "/dev/ptywa", 0 }, + { "/dev/ptywb", 0 }, + { "/dev/ptywc", 0 }, + { "/dev/ptywd", 0 }, + { "/dev/ptywe", 0 }, + { "/dev/ptywf", 0 }, + { "/dev/ptyx0", 0 }, + { "/dev/ptyx1", 0 }, + { "/dev/ptyx2", 0 }, + { "/dev/ptyx3", 0 }, + { "/dev/ptyx4", 0 }, + { "/dev/ptyx5", 0 }, + { "/dev/ptyx6", 0 }, + { "/dev/ptyx7", 0 }, + { "/dev/ptyx8", 0 }, + { "/dev/ptyx9", 0 }, + { "/dev/ptyxa", 0 }, + { "/dev/ptyxb", 0 }, + { "/dev/ptyxc", 0 }, + { "/dev/ptyxd", 0 }, + { "/dev/ptyxe", 0 }, + { "/dev/ptyxf", 0 }, + { "/dev/ptyy0", 0 }, + { "/dev/ptyy1", 0 }, + { "/dev/ptyy2", 0 }, + { "/dev/ptyy3", 0 }, + { "/dev/ptyy4", 0 }, + { "/dev/ptyy5", 0 }, + { "/dev/ptyy6", 0 }, + { "/dev/ptyy7", 0 }, + { "/dev/ptyy8", 0 }, + { "/dev/ptyy9", 0 }, + { "/dev/ptyya", 0 }, + { "/dev/ptyyb", 0 }, + { "/dev/ptyyc", 0 }, + { "/dev/ptyyd", 0 }, + { "/dev/ptyye", 0 }, + { "/dev/ptyyf", 0 }, + { "/dev/ptyz0", 0 }, + { "/dev/ptyz1", 0 }, + { "/dev/ptyz2", 0 }, + { "/dev/ptyz3", 0 }, + { "/dev/ptyz4", 0 }, + { "/dev/ptyz5", 0 }, + { "/dev/ptyz6", 0 }, + { "/dev/ptyz7", 0 }, + { "/dev/ptyz8", 0 }, + { "/dev/ptyz9", 0 }, + { "/dev/ptyza", 0 }, + { "/dev/ptyzb", 0 }, + { "/dev/ptyzc", 0 }, + { "/dev/ptyzd", 0 }, + { "/dev/ptyze", 0 }, + { "/dev/ptyzf", 0 }, + { "/dev/ptya0", 0 }, + { "/dev/ptya1", 0 }, + { "/dev/ptya2", 0 }, + { "/dev/ptya3", 0 }, + { "/dev/ptya4", 0 }, + { "/dev/ptya5", 0 }, + { "/dev/ptya6", 0 }, + { "/dev/ptya7", 0 }, + { "/dev/ptya8", 0 }, + { "/dev/ptya9", 0 }, + { "/dev/ptyaa", 0 }, + { "/dev/ptyab", 0 }, + { "/dev/ptyac", 0 }, + { "/dev/ptyad", 0 }, + { "/dev/ptyae", 0 }, + { "/dev/ptyaf", 0 }, + { "/dev/ptyb0", 0 }, + { "/dev/ptyb1", 0 }, + { "/dev/ptyb2", 0 }, + { "/dev/ptyb3", 0 }, + { "/dev/ptyb4", 0 }, + { "/dev/ptyb5", 0 }, + { "/dev/ptyb6", 0 }, + { "/dev/ptyb7", 0 }, + { "/dev/ptyb8", 0 }, + { "/dev/ptyb9", 0 }, + { "/dev/ptyba", 0 }, + { "/dev/ptybb", 0 }, + { "/dev/ptybc", 0 }, + { "/dev/ptybd", 0 }, + { "/dev/ptybe", 0 }, + { "/dev/ptybf", 0 }, + { "/dev/ptyc0", 0 }, + { "/dev/ptyc1", 0 }, + { "/dev/ptyc2", 0 }, + { "/dev/ptyc3", 0 }, + { "/dev/ptyc4", 0 }, + { "/dev/ptyc5", 0 }, + { "/dev/ptyc6", 0 }, + { "/dev/ptyc7", 0 }, + { "/dev/ptyc8", 0 }, + { "/dev/ptyc9", 0 }, + { "/dev/ptyca", 0 }, + { "/dev/ptycb", 0 }, + { "/dev/ptycc", 0 }, + { "/dev/ptycd", 0 }, + { "/dev/ptyce", 0 }, + { "/dev/ptycf", 0 }, + { "/dev/ptyd0", 0 }, + { "/dev/ptyd1", 0 }, + { "/dev/ptyd2", 0 }, + { "/dev/ptyd3", 0 }, + { "/dev/ptyd4", 0 }, + { "/dev/ptyd5", 0 }, + { "/dev/ptyd6", 0 }, + { "/dev/ptyd7", 0 }, + { "/dev/ptyd8", 0 }, + { "/dev/ptyd9", 0 }, + { "/dev/ptyda", 0 }, + { "/dev/ptydb", 0 }, + { "/dev/ptydc", 0 }, + { "/dev/ptydd", 0 }, + { "/dev/ptyde", 0 }, + { "/dev/ptydf", 0 }, + { "/dev/ptye0", 0 }, + { "/dev/ptye1", 0 }, + { "/dev/ptye2", 0 }, + { "/dev/ptye3", 0 }, + { "/dev/ptye4", 0 }, + { "/dev/ptye5", 0 }, + { "/dev/ptye6", 0 }, + { "/dev/ptye7", 0 }, + { "/dev/ptye8", 0 }, + { "/dev/ptye9", 0 }, + { "/dev/ptyea", 0 }, + { "/dev/ptyeb", 0 }, + { "/dev/ptyec", 0 }, + { "/dev/ptyed", 0 }, + { "/dev/ptyee", 0 }, + { "/dev/ptyef", 0 }, + { "/dev/vcs", 0 }, + { "/dev/vcsa", 0 }, + { "/dev/vcs1", 0 }, + { "/dev/vcsa1", 0 }, + { "/dev/ttyS0", 0 }, + { "/dev/cua0", 0 }, + { "/dev/hda", 0 }, + { "/dev/hda1", 2 }, + { "/dev/hda2", 2 }, + { "/dev/hda3", 2 }, + { "/dev/hda4", 2 }, + { "/dev/hda5", 2 }, + { "/dev/hda6", 0 }, + { "/dev/hda7", 0 }, + { "/dev/hda8", 0 }, + { "/dev/hdb", 0 }, + { "/dev/hdb1", 2 }, + { "/dev/hdc", 0 }, + { "/dev/hdc1", 2 }, + { "/dev/fd0u1440", 0 }, + { "/dev/fd0u1680", 0 }, + { "/dev/fd0u1722", 0 }, + { "/dev/fd0u1743", 0 }, + { "/dev/fd0u1760", 0 }, + { "/dev/fd0u1920", 0 }, + { "/dev/fd0u1840", 0 }, + { "/dev/fd0u1600", 0 }, + { "/dev/fd0u360", 0 }, + { "/dev/fd0u720", 0 }, + { "/dev/fd0u820", 0 }, + { "/dev/fd0u830", 0 }, + { "/dev/fd0u1040", 0 }, + { "/dev/fd0u1120", 0 }, + { "/dev/fd0u800", 0 }, + { "/dev/fd0", 0 }, + { "/dev/loop0", 0 }, + { "/dev/loop1", 0 }, + { "/dev/loop2", 0 }, + { "/dev/loop3", 0 }, + { "/dev/loop4", 0 }, + { "/dev/loop5", 0 }, + { "/dev/loop6", 0 }, + { "/dev/loop7", 0 }, + { "/dev/dsp", 0 }, + { "/dev/dsp1", 0 }, + { "/dev/mixer", 0 }, + { "/dev/midi", 0 }, + { "/dev/lvm", 0 }, + { "/dev/vg0", 0 }, + { "/dev/vg0/group", 0 }, + { "/dev/vg0/packages", 0 }, + { "/dev/vg0/photos", 0 }, + { "/dev/vg0/music", 0 }, + { "/dev/log", 0 }, + { "/dev/MAKEDEV", 0 }, + { "/dev/printer", 0 }, + { "/dev/vcs2", 0 }, + { "/dev/vcsa2", 0 }, + { "/dev/vcs3", 0 }, + { "/dev/vcsa3", 0 }, + { "/dev/vcs5", 0 }, + { "/dev/vcsa5", 0 }, + { "/dev/vcs4", 0 }, + { "/dev/vcsa4", 0 }, + { "/dev/vcs6", 0 }, + { "/dev/vcsa6", 0 }, + { "/dev/nvidia0", 0 }, + { "/dev/nvidia1", 0 }, + { "/dev/nvidia2", 0 }, + { "/dev/nvidia3", 0 }, + { "/dev/nvidiactl", 0 }, + { "/dev/vcs7", 0 }, + { "/dev/vcsa7", 0 }, + { NULL, 0 } +}; diff --git a/test/unit/matcher_t.c b/test/unit/matcher_t.c new file mode 100644 index 0000000..7331a82 --- /dev/null +++ b/test/unit/matcher_t.c @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. + * Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved. + * + * This file is part of LVM2. + * + * 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. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "libdevmapper.h" +#include "log.h" + +#include <stdio.h> +#include <ctype.h> +#include <string.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <fcntl.h> +#include <sys/mman.h> + +#include <CUnit/CUnit.h> +#include "matcher_data.h" + +int regex_init(void); +int regex_fini(void); + +static struct dm_pool *mem = NULL; + +int regex_init(void) { + mem = dm_pool_create("bitset test", 1024); + return mem == NULL; +} + +int regex_fini(void) { + dm_pool_destroy(mem); + return 0; +} + +static struct dm_regex *make_scanner(const char **rx) +{ + struct dm_regex *scanner; + int nrx = 0; + for (; rx[nrx]; ++nrx); + + scanner = dm_regex_create(mem, rx, nrx); + CU_ASSERT_FATAL(scanner != NULL); + return scanner; +} + +static void test_fingerprints(void) { + struct dm_regex *scanner; + + scanner = make_scanner(dev_patterns); + CU_ASSERT_EQUAL(dm_regex_fingerprint(scanner), 0x7f556c09); + + scanner = make_scanner(random_patterns); + CU_ASSERT_EQUAL(dm_regex_fingerprint(scanner), 0x9f11076c); +} + +static void test_matching(void) { + struct dm_regex *scanner; + int i; + + scanner = make_scanner(dev_patterns); + for (i = 0; devices[i].str; ++i) + CU_ASSERT_EQUAL(dm_regex_match(scanner, devices[i].str), devices[i].expected - 1); + + scanner = make_scanner(nonprint_patterns); + for (i = 0; nonprint[i].str; ++i) + CU_ASSERT_EQUAL(dm_regex_match(scanner, nonprint[i].str), nonprint[i].expected - 1); +} + +CU_TestInfo regex_list[] = { + { (char*)"fingerprints", test_fingerprints }, + { (char*)"matching", test_matching }, + CU_TEST_INFO_NULL +}; + diff --git a/test/unit/run.c b/test/unit/run.c new file mode 100644 index 0000000..482498a --- /dev/null +++ b/test/unit/run.c @@ -0,0 +1,29 @@ +#include <CUnit/CUnit.h> +#include <CUnit/Basic.h> + +#define DECL(n) \ + extern CU_TestInfo n ## _list[]; \ + int n ## _init(void); \ + int n ## _fini(void); +#define USE(n) { (char*) #n, n##_init, n##_fini, n##_list } + +DECL(bitset); +DECL(regex); +DECL(config); +DECL(string); + +CU_SuiteInfo suites[] = { + USE(bitset), + USE(regex), + USE(config), + USE(string), + CU_SUITE_INFO_NULL +}; + +int main(int argc, char **argv) { + CU_initialize_registry(); + CU_register_suites(suites); + CU_basic_set_mode(CU_BRM_VERBOSE); + CU_basic_run_tests(); + return CU_get_number_of_failures() != 0; +} diff --git a/test/unit/string_t.c b/test/unit/string_t.c new file mode 100644 index 0000000..df72505 --- /dev/null +++ b/test/unit/string_t.c @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2012 Red Hat, Inc. All rights reserved. + * + * This file is part of LVM2. + * + * 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. + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "libdevmapper.h" + +#include <stdio.h> +#include <string.h> + +#include <CUnit/CUnit.h> + +int string_init(void); +int string_fini(void); + +static struct dm_pool *mem = NULL; + +int string_init(void) +{ + mem = dm_pool_create("string test", 1024); + + return (mem == NULL); +} + +int string_fini(void) +{ + dm_pool_destroy(mem); + + return 0; +} + +/* TODO: Add more string unit tests here */ + +static void test_strncpy(void) +{ + const char st[] = "1234567890"; + char buf[sizeof(st)]; + + CU_ASSERT_EQUAL(dm_strncpy(buf, st, sizeof(buf)), 1); + CU_ASSERT_EQUAL(strcmp(buf, st), 0); + + CU_ASSERT_EQUAL(dm_strncpy(buf, st, sizeof(buf) - 1), 0); + CU_ASSERT_EQUAL(strlen(buf) + 1, sizeof(buf) - 1); +} + +static void test_asprint(void) +{ + const char st0[] = ""; + const char st1[] = "12345678901"; + const char st2[] = "1234567890123456789012345678901234567890123456789012345678901234567"; + char *buf; + int a; + + a = dm_asprintf(&buf, "%s", st0); + CU_ASSERT_EQUAL(strcmp(buf, st0), 0); + CU_ASSERT_EQUAL(a, sizeof(st0)); + free(buf); + + a = dm_asprintf(&buf, "%s", st1); + CU_ASSERT_EQUAL(strcmp(buf, st1), 0); + CU_ASSERT_EQUAL(a, sizeof(st1)); + free(buf); + + a = dm_asprintf(&buf, "%s", st2); + CU_ASSERT_EQUAL(a, sizeof(st2)); + CU_ASSERT_EQUAL(strcmp(buf, st2), 0); + free(buf); +} + +CU_TestInfo string_list[] = { + { (char*)"asprint", test_asprint }, + { (char*)"strncpy", test_strncpy }, + CU_TEST_INFO_NULL +}; |