@@ -16,6 +16,7 @@ package misc
1616
1717import (
1818 "fmt"
19+ "strconv"
1920 "strings"
2021 "time"
2122
@@ -103,6 +104,13 @@ systemd:
103104
104105 [Install]
105106 WantedBy=multi-user.target` )
107+
108+ mpath_single_disk = conf .Butane (`
109+ variant: fcos
110+ version: 1.6.0
111+ kernel_arguments:
112+ should_exist:
113+ - rd.multipath=default` )
106114)
107115
108116func init () {
@@ -132,6 +140,16 @@ func init() {
132140 UserData : mpath_on_var_lib_containers ,
133141 AdditionalDisks : []string {"1G:mpath,wwn=1" },
134142 })
143+ // See https://issues.redhat.com/browse/OCPBUGS-56597
144+ register .RegisterTest (& register.Test {
145+ Name : "multipath.single-disk" ,
146+ Description : "Verify that multipath can be reduced to one path" ,
147+ Run : runMultipathReduceDisk ,
148+ ClusterSize : 1 ,
149+ Platforms : []string {"qemu" },
150+ UserData : mpath_single_disk ,
151+ MultiPathDisk : true ,
152+ })
135153}
136154
137155func verifyMultipathBoot (c cluster.TestCluster , m platform.Machine ) {
@@ -223,3 +241,37 @@ func waitForCompleteFirstboot(c cluster.TestCluster) {
223241 c .Fatalf ("Timed out while waiting for first-boot-complete.target to be ready: %v" , err )
224242 }
225243}
244+
245+ func verifyMultipathDisks (c cluster.TestCluster , m platform.Machine , expect int ) {
246+ device := strings .TrimSpace (string (c .MustSSH (m , "sudo multipath -l -v 1" )))
247+ if device == "" {
248+ c .Fatalf ("Failed to find multipath device" )
249+ }
250+ output := string (c .MustSSHf (m , "lsblk --pairs --paths --inverse --output NAME /dev/mapper/%s | grep -v /dev/mapper | wc -l" , device ))
251+ count , err := strconv .Atoi (strings .TrimSpace (output ))
252+ if err != nil {
253+ c .Fatalf ("Failed to parse device count: %v" , err )
254+ }
255+
256+ if count != expect {
257+ c .Fatalf ("Expected %d multipath devices, but found %d" , expect , count )
258+ }
259+ }
260+
261+ func runMultipathReduceDisk (c cluster.TestCluster ) {
262+ m := c .Machines ()[0 ]
263+ verifyMultipathBoot (c , m )
264+ // wait until first-boot-complete.target is reached
265+ waitForCompleteFirstboot (c )
266+ verifyMultipathDisks (c , m , 2 )
267+
268+ if err := m .(platform.QEMUMachine ).RemoveBlockDeviceForMultipath ("mpath11" ); err != nil {
269+ c .Fatalf ("failed to reduce multipath disk: %v" , err )
270+ }
271+
272+ if err := m .Reboot (); err != nil {
273+ c .Fatalf ("Failed to reboot the machine: %v" , err )
274+ }
275+ verifyMultipathDisks (c , m , 1 )
276+ c .RunCmdSync (m , "grep mpath.wwid= /proc/cmdline" )
277+ }
0 commit comments