~ubuntu-branches/ubuntu/saucy/lvm2/saucy

« back to all changes in this revision

Viewing changes to test/shell/pvcreate-operation.sh

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs
  • Date: 2013-05-30 11:02:10 UTC
  • mfrom: (3.1.28 sid)
  • Revision ID: package-import@ubuntu.com-20130530110210-q8bou4f333ruwhn0
Tags: 2.02.98-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - debian/patches/avoid-dev-block.patch: Prefer any other device name over
    names in /dev/block/ since lvm.conf won't handle this.
  - debian/rules:
    - copy .po file to .pot file for Rosetta (Ubuntu specific).
  - debian/{dmsetup,lvm2}-udeb.install:
    - install initramfs and udev hooks in udebs (Debian bug 504341).
  - auto-start VGs as their PVs are discovered (Ubuntu specific):
    - add debian/tree/lvm2/lib/udev/rules.d/85-lvm2.rules: use watershed plus
      the sledgehammer of vgscan/vgchange to turn on VGs as they come online.
    - debian/tree/lvm2/usr/share/initramfs-tools/scripts/hooks/lvm2:
      - add 85-lvm2.rules to the list of udev rules to copy.
      - depend on udev.
    - debian/control:
      - add versioned Depend on watershed in lvm2 for udev rules.
      - add Depends on watershed-udeb in lvm2-udeb for udev rules.
      - add versioned Depend/Breaks on udev in dmsetup for udev rules.
      - add Depend on initramfs-tools in dmsetup so system is not potentially
        rendered unbootable by out-of-order dpkg configuration.
      - In libdevmapper-event1.02.1 add Breaks: dmeventd
        (<< 2.02.95-4ubuntu1) due to debian symbol rename
    - debian/rules:
      - do not install local-top scripts since Ubuntu mounts root using udev.
      - do not install init scripts for lvm2, since udev starts LVM.
      - continue to build clvm support.
    - debian/lvm2.postinst: handle missing lvm2 init script.
    - debian/tree/dmsetup/lib/udev/rules.d/60-persistent-storage-dm.rules:
      watch dm devices for changes with inotify
  - add mountroot failure hooks to help fix bad boots (Debian bug 468115):
    - debian/tree/lvm2/usr/share/initramfs-tools/scripts/init-premount/lvm2
  - remaining changes to upstream event manager packages (Debian bug 514706):
    - debian/rules:
      - enable dmeventd during configure.
    - debian/dmeventd.{8,manpages}: install dmeventd files.
  - rename debian/clvm.defaults to debian/clvm.default so it is installed
    correctly.
  - debian/control: add dmsetup-udeb to libdevmapper1.02.1-udeb recommends.
  - debian/rules: make sure dmsetup and lvm2 initramfs-tools scripts are
    executable.  When the Ubuntu-specific ones are added with a patch,
    they may lose their executable bit.
  - Add and install clvmd resource agent
  - Add dependency on libudev-dev to libdevmapper-dev so that the .pc file
    works.
  - debian/{clvmd.ra,clvm.init}:
    - create /run/lvm if it doesn't exist.
  - debian/clvm.init:
    - exit 3 if not running on status action.
  - Call dh_installman so that our dmeventd manpage actually gets installed
  - Install the missing fsadm manpage.
  - Complete libdevmapper-dev multiarch:
    - move .so symlinks and pkgconfig files to multiarched locations.
    - mark libdevmapper-dev M-A: same

* Dropped changes, applied upstream:
  - Update Micron PCIe SSD and other device-types to latest available.
  - Cherry pick from upstream, remove unsupported udev_get_dev_path() call.
  - Move thin check to global section.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 
11
11
. lib/test
12
12
 
 
13
aux lvmconf 'devices/md_component_detection = 1'
 
14
 
13
15
aux prepare_devs 4
14
16
 
15
17
for mdatype in 1 2
16
18
do
17
19
# pvcreate (lvm$mdatype) refuses to overwrite an mounted filesystem (bz168330)
18
 
        test ! -d $TESTDIR/mnt && mkdir $TESTDIR/mnt
19
 
        if mke2fs $dev1; then
20
 
                mount $dev1 $TESTDIR/mnt
21
 
                not pvcreate -M$mdatype $dev1 2>err
22
 
                grep "Can't open $dev1 exclusively.  Mounted filesystem?" err
23
 
                umount $dev1
 
20
        test ! -d mnt && mkdir mnt
 
21
        if mke2fs "$dev1"; then
 
22
                mount "$dev1" mnt
 
23
                not pvcreate -M$mdatype "$dev1" 2>err
 
24
                grep "Can't open "$dev1" exclusively.  Mounted filesystem?" err
 
25
                umount "$dev1"
24
26
        fi
25
27
 
26
28
# pvcreate (lvm$mdatype) succeeds when run repeatedly (pv not in a vg) (bz178216)
27
 
    pvcreate -M$mdatype $dev1
28
 
    pvcreate -M$mdatype $dev1
29
 
    pvremove -f $dev1
 
29
    pvcreate -M$mdatype "$dev1"
 
30
    pvcreate -M$mdatype "$dev1"
 
31
    pvremove -f "$dev1"
30
32
 
31
 
# pvcreate (lvm$mdatype) fails when PV belongs to VG" \
32
 
    pvcreate -M$mdatype $dev1
33
 
    vgcreate -M$mdatype $vg1 $dev1
34
 
    not pvcreate -M$mdatype $dev1
 
33
# pvcreate (lvm$mdatype) fails when PV belongs to VG
 
34
#   pvcreate -M$mdatype "$dev1"
 
35
    vgcreate -M$mdatype $vg1 "$dev1"
 
36
    not pvcreate -M$mdatype "$dev1"
35
37
 
36
38
    vgremove -f $vg1
37
 
    pvremove -f $dev1
 
39
    pvremove -f "$dev1"
38
40
 
39
41
# pvcreate (lvm$mdatype) fails when PV1 does and PV2 does not belong to VG
40
 
    pvcreate -M$mdatype $dev1
41
 
    pvcreate -M$mdatype $dev2
42
 
    vgcreate -M$mdatype $vg1 $dev1
 
42
    pvcreate -M$mdatype "$dev1"
 
43
    pvcreate -M$mdatype "$dev2"
 
44
    vgcreate -M$mdatype $vg1 "$dev1"
43
45
 
44
46
# pvcreate a second time on $dev2 and $dev1
45
 
    not pvcreate -M$mdatype $dev2 $dev1
 
47
    not pvcreate -M$mdatype "$dev2" "$dev1"
46
48
 
47
49
    vgremove -f $vg1
48
 
    pvremove -f $dev2
49
 
    pvremove -f $dev1
 
50
    pvremove -f "$dev2" "$dev1"
50
51
 
51
52
# NOTE: Force pvcreate after test completion to ensure clean device
52
 
#test_expect_success \
53
 
#  "pvcreate (lvm$mdatype) fails on md component device" \
54
 
#  'mdadm -C -l raid0 -n 2 /dev/md0 $dev1 $dev2 &&
55
 
#   pvcreate -M$mdatype $dev1;
 
53
#test_expect_success
 
54
#  "pvcreate (lvm$mdatype) fails on md component device"
 
55
#  'mdadm -C -l raid0 -n 2 /dev/md0 "$dev1" "$dev2" &&
 
56
#   pvcreate -M$mdatype "$dev1";
56
57
#   status=$?; echo status=$status; test $status != 0 &&
57
58
#   mdadm --stop /dev/md0 &&
58
 
#   pvcreate -ff -y -M$mdatype $dev1 $dev2 &&
59
 
#   pvremove -f $dev1 $dev2'
 
59
#   pvcreate -ff -y -M$mdatype "$dev1" "$dev2" &&
 
60
#   pvremove -f "$dev1" "$dev2"'
60
61
done
61
62
 
62
63
# pvcreate (lvm2) fails without -ff when PV with metadatacopies=0 belongs to VG
63
 
pvcreate --metadatacopies 0 $dev1
64
 
pvcreate --metadatacopies 1 $dev2
65
 
vgcreate $vg1 $dev1 $dev2
66
 
not pvcreate $dev1
 
64
pvcreate --metadatacopies 0 "$dev1"
 
65
pvcreate --metadatacopies 1 "$dev2"
 
66
vgcreate $vg1 "$dev1" "$dev2"
 
67
not pvcreate "$dev1"
67
68
vgremove -f $vg1
68
 
pvremove -f $dev2
69
 
pvremove -f $dev1
 
69
pvremove -f "$dev2" "$dev1"
70
70
 
71
71
# pvcreate (lvm2) succeeds with -ff when PV with metadatacopies=0 belongs to VG
72
 
pvcreate --metadatacopies 0 $dev1 
73
 
pvcreate --metadatacopies 1 $dev2
74
 
vgcreate $vg1 $dev1 $dev2 
75
 
pvcreate -ff -y $dev1 
76
 
vgreduce --removemissing $vg1 
77
 
vgremove -ff $vg1 
78
 
pvremove -f $dev2 
79
 
pvremove -f $dev1
 
72
pvcreate --metadatacopies 0 "$dev1"
 
73
pvcreate --metadatacopies 1 "$dev2"
 
74
vgcreate $vg1 "$dev1" "$dev2"
 
75
pvcreate -ff -y "$dev1"
 
76
vgreduce --removemissing $vg1
 
77
vgremove -ff $vg1
 
78
pvremove -f "$dev2" "$dev1"
80
79
 
81
80
for i in 0 1 2 3
82
81
do
83
82
# pvcreate (lvm2) succeeds writing LVM label at sector $i
84
 
    pvcreate --labelsector $i $dev1
85
 
    dd if=$dev1 bs=512 skip=$i count=1 2>/dev/null | strings | grep LABELONE >/dev/null
86
 
    pvremove -f $dev1
 
83
    pvcreate --labelsector $i "$dev1"
 
84
    dd if="$dev1" bs=512 skip=$i count=1 2>/dev/null | strings | grep LABELONE >/dev/null
 
85
    pvremove -f "$dev1"
87
86
done
88
87
 
89
88
# pvcreate (lvm2) fails writing LVM label at sector 4
90
 
not pvcreate --labelsector 4 $dev1
 
89
not pvcreate --labelsector 4 "$dev1"
91
90
 
92
91
backupfile=$PREFIX.mybackupfile
93
92
uuid1=freddy-fred-fred-fred-fred-fred-freddy
95
94
bogusuuid=fred
96
95
 
97
96
# pvcreate rejects uuid option with less than 32 characters
98
 
not pvcreate --norestorefile --uuid $bogusuuid $dev1
 
97
not pvcreate --norestorefile --uuid $bogusuuid "$dev1"
99
98
 
100
99
# pvcreate rejects uuid option without restorefile
101
 
not pvcreate --uuid $uuid1 $dev1
 
100
not pvcreate --uuid $uuid1 "$dev1"
102
101
 
103
102
# pvcreate rejects uuid already in use
104
 
pvcreate --norestorefile --uuid $uuid1 $dev1
105
 
not pvcreate --norestorefile --uuid $uuid1 $dev2
 
103
pvcreate --norestorefile --uuid $uuid1 "$dev1"
 
104
not pvcreate --norestorefile --uuid $uuid1 "$dev2"
106
105
 
107
106
# pvcreate rejects non-existent file given with restorefile
108
 
not pvcreate --uuid $uuid1 --restorefile $backupfile $dev1
 
107
not pvcreate --uuid $uuid1 --restorefile $backupfile "$dev1"
109
108
 
110
109
# pvcreate rejects restorefile with uuid not found in file
111
 
pvcreate --norestorefile --uuid $uuid1 $dev1
112
 
vgcfgbackup -f $backupfile
113
 
not pvcreate --uuid $uuid2 --restorefile $backupfile $dev2
 
110
pvcreate --norestorefile --uuid $uuid1 "$dev1"
 
111
vgcfgbackup -f $backupfile
 
112
not pvcreate --uuid $uuid2 --restorefile $backupfile "$dev2"
 
113
 
 
114
# vgcfgrestore of a VG containing a PV with zero PEs (bz #820116)
 
115
# (use case: one PV in a VG used solely to keep metadata)
 
116
size_mb=$(($(blockdev --getsz $dev1) / 2048))
 
117
pvcreate --metadatasize $size_mb $dev1
 
118
vgcreate $vg1 $dev1
 
119
vgcfgbackup -f $backupfile
 
120
vgcfgrestore -f $backupfile $vg1
 
121
vgremove -f $vg1
 
122
pvremove -f $dev1
114
123
 
115
124
# pvcreate wipes swap signature when forced
116
 
dd if=/dev/zero of=$dev1 bs=1024 count=64
117
 
mkswap $dev1
118
 
blkid -c /dev/null $dev1 | grep "swap"
119
 
pvcreate -f $dev1
 
125
dd if=/dev/zero of="$dev1" bs=1024 count=64
 
126
mkswap "$dev1"
 
127
blkid -c /dev/null "$dev1" | grep "swap"
 
128
pvcreate -f "$dev1"
120
129
# blkid cannot make up its mind whether not finding anything it knows is a failure or not
121
 
(blkid -c /dev/null $dev1 || true) | not grep "swap"
 
130
(blkid -c /dev/null "$dev1" || true) | not grep "swap"