File tree 2 files changed +41
-10
lines changed
2 files changed +41
-10
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ test_lvm_sig() {
7
7
local test_status=1
8
8
local testname=` basename " $0 " `
9
9
local vg_name=" css-test-foo"
10
+ local tmplog=${WORKDIR} /tmplog
11
+ local errmsg=" Wipe signatures using wipefs or use WIPE_SIGNATURES=true and retry."
10
12
11
13
# Error out if any pre-existing volume group vg named css-test-foo
12
14
if vg_exists " $vg_name " ; then
25
27
done
26
28
27
29
# Run container-storage-setup
28
- $CSSBIN >> $LOGS 2>&1
29
-
30
- # Css should fail. If it did not, then test failed. This is very crude
31
- # check though as css can fail for so many reasons. A more precise check
32
- # would be too check for exact error message.
33
- [ $? -ne 0 ] && test_status=0
30
+ $CSSBIN > $tmplog 2>&1
31
+ rc=$?
32
+ cat $tmplog >> $LOGS 2>&1
33
+
34
+ # Test failed.
35
+ if [ $rc -ne 0 ]; then
36
+ if grep --no-messages -q " $errmsg " $tmplog ; then
37
+ test_status=0
38
+ else
39
+ echo " ERROR: $testname : $CSSBIN Failed for a reason other then \" $errmsg \" " >> $LOGS
40
+ fi
41
+ else
42
+ echo " ERROR: $testname : $CSSBIN Succeeded. Should have failed since LVM2_member signature exists on devices $devs " >> $LOGS
43
+ fi
34
44
35
- cleanup $vg_name " $devs "
45
+ cleanup " $vg_name " " $devs "
36
46
return $test_status
37
47
}
38
48
Original file line number Diff line number Diff line change @@ -50,6 +50,19 @@ vg_exists() {
50
50
return 1
51
51
}
52
52
53
+ # Tests if the physical volume pv_name exists
54
+ pv_exists () {
55
+ local pv pv_name=" $1 "
56
+
57
+ for pv in $( pvs --noheadings -o pv_name) ; do
58
+ if [ " $pv " == " $pv_name " ]; then
59
+ return 0
60
+ fi
61
+ done
62
+ return 1
63
+ }
64
+
65
+
53
66
# Tests if the logical volume lv_name exists
54
67
lv_exists () {
55
68
local vg_name=$1
@@ -76,7 +89,14 @@ remove_pvs() {
76
89
local dev devs=$1 pv
77
90
for dev in $devs ; do
78
91
pv=$( lsblk -npl -o NAME " $dev " | tail -n +2 | head -1)
79
- pvremove -y ${pv} >> $LOGS 2>&1
92
+ # If lsblk output physical volume (pv) name, pv exists on partition.
93
+ if [ -n " $pv " ]; then
94
+ pvremove -y ${pv} >> $LOGS 2>&1
95
+ # If lsblk output nothing, there might be a pv on block device.
96
+ # pv name would be same as block device name in this case.
97
+ elif pv_exists " $dev " ; then
98
+ pvremove -y ${dev} >> $LOGS 2>&1
99
+ fi
80
100
done
81
101
}
82
102
@@ -125,8 +145,9 @@ cleanup() {
125
145
outfile=$4
126
146
fi
127
147
128
-
129
- vgremove -y $vg_name >> $LOGS 2>&1
148
+ if vg_exists " $vg_name " ; then
149
+ vgremove -y $vg_name >> $LOGS 2>&1
150
+ fi
130
151
remove_pvs " $devs "
131
152
remove_partitions " $devs "
132
153
# After removing partitions let udev settle down. In some
You can’t perform that action at this time.
0 commit comments