1#!/bin/sh
2# Copyright (C) 2007-2008 Red Hat, Inc. All rights reserved.
3#
4# This copyrighted material is made available to anyone wishing to use,
5# modify, copy, or redistribute it subject to the terms and conditions
6# of the GNU General Public License v.2.
7#
8# You should have received a copy of the GNU General Public License
9# along with this program; if not, write to the Free Software Foundation,
10# Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
11
12test_description='Test vgmerge operation'
13
14. ./test-utils.sh
15
16aux prepare_pvs 4 64
17
18# 'vgmerge succeeds with single linear LV in source VG'
19vgcreate $vg1 $dev1 $dev2
20vgcreate $vg2 $dev3 $dev4
21lvcreate -l 4 -n $lv1 $vg1 $dev1
22vgchange -an $vg1
23vg_validate_pvlv_counts_ $vg1 2 1 0
24vg_validate_pvlv_counts_ $vg2 2 0 0
25vgmerge $vg2 $vg1
26vg_validate_pvlv_counts_ $vg2 4 1 0
27vgremove -f $vg2
28
29# 'vgmerge succeeds with single linear LV in source and destination VG'
30vgcreate $vg1 $dev1 $dev2
31vgcreate $vg2 $dev3 $dev4
32lvcreate -l 4 -n $lv1 $vg1
33lvcreate -l 4 -n $lv2 $vg2
34vgchange -an $vg1
35vgchange -an $vg2
36vg_validate_pvlv_counts_ $vg1 2 1 0
37vg_validate_pvlv_counts_ $vg2 2 1 0
38vgmerge $vg2 $vg1
39vg_validate_pvlv_counts_ $vg2 4 2 0
40vgremove -f $vg2
41
42# 'vgmerge succeeds with linear LV + snapshots in source VG'
43vgcreate $vg1 $dev1 $dev2
44vgcreate $vg2 $dev3 $dev4
45lvcreate -l 16 -n $lv1 $vg1
46lvcreate -l 4 -s -n $lv2 $vg1/$lv1
47vgchange -an $vg1
48vg_validate_pvlv_counts_ $vg1 2 2 1
49vg_validate_pvlv_counts_ $vg2 2 0 0
50vgmerge $vg2 $vg1
51vg_validate_pvlv_counts_ $vg2 4 2 1
52lvremove -f $vg2/$lv2
53vgremove -f $vg2
54
55# 'vgmerge succeeds with mirrored LV in source VG'
56vgcreate $vg1 $dev1 $dev2 $dev3
57vgcreate $vg2 $dev4
58lvcreate -l 4 -n $lv1 -m1 $vg1
59vgchange -an $vg1
60vg_validate_pvlv_counts_ $vg1 3 1 0
61vg_validate_pvlv_counts_ $vg2 1 0 0
62vgmerge $vg2 $vg1
63vg_validate_pvlv_counts_ $vg2 4 1 0
64lvremove -f $vg2/$lv1
65vgremove -f $vg2
66
67# 'vgmerge rejects LV name collision'
68vgcreate $vg1 $dev1 $dev2
69vgcreate $vg2 $dev3 $dev4
70lvcreate -l 4 -n $lv1 $vg1
71lvcreate -l 4 -n $lv1 $vg2
72vgchange -an $vg1
73aux vg_validate_pvlv_counts_ $vg1 2 1 0
74aux vg_validate_pvlv_counts_ $vg2 2 1 0
75not vgmerge $vg2 $vg1 2>err
76grep "Duplicate logical volume name \"$lv1\" in \"$vg2\" and \"$vg1" err
77aux vg_validate_pvlv_counts_ $vg1 2 1 0
78aux vg_validate_pvlv_counts_ $vg2 2 1 0
79vgremove -f $vg1
80vgremove -f $vg2
81
82