Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions mantle/kola/tests/misc/multipath.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,17 @@
package misc

import (
"fmt"
"strings"
"time"

coreosarch "github.com/coreos/stream-metadata-go/arch"

"github.com/coreos/coreos-assembler/mantle/kola/cluster"
"github.com/coreos/coreos-assembler/mantle/kola/register"
"github.com/coreos/coreos-assembler/mantle/platform"
"github.com/coreos/coreos-assembler/mantle/platform/conf"
"github.com/coreos/coreos-assembler/mantle/util"
)

var (
Expand Down Expand Up @@ -168,6 +171,8 @@ func verifyMultipath(c cluster.TestCluster, m platform.Machine, path string) {
func runMultipathDay1(c cluster.TestCluster) {
m := c.Machines()[0]
verifyMultipathBoot(c, m)
// wait until first-boot-complete.target is reached
waitForCompleteFirstboot(c)
if err := m.Reboot(); err != nil {
c.Fatalf("Failed to reboot the machine: %v", err)
}
Expand All @@ -188,8 +193,33 @@ func runMultipathDay2(c cluster.TestCluster) {
func runMultipathPartition(c cluster.TestCluster) {
m := c.Machines()[0]
verifyMultipath(c, m, "/var/lib/containers")
// wait until first-boot-complete.target is reached
waitForCompleteFirstboot(c)
if err := m.Reboot(); err != nil {
c.Fatalf("Failed to reboot the machine: %v", err)
}
verifyMultipath(c, m, "/var/lib/containers")
}

func waitForCompleteFirstboot(c cluster.TestCluster) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional:

rather than running a retry here you could possibly run systemd-run --wait and then run that inside a util.WaitUntilReady like is done here.

i.e. rather than worrying about how many times to retry you can just focus on how much time you want to spend waiting.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank for the suggestion. Applied it.

m := c.Machines()[0]
err := util.WaitUntilReady(2*time.Minute, 10*time.Second, func() (bool, error) {

_, err := c.SSH(m, "sudo systemd-run --wait --quiet --property='After=first-boot-complete.target' echo 'firstboot complete'")
if err != nil {
return false, err
}
// get the actual target state to double check
firstbootTargetState, err := c.SSH(m, "systemctl is-active first-boot-complete.target")

if err != nil {
return false, err
} else if string(firstbootTargetState) != "active" {
return false, fmt.Errorf("first-boot-complete.target state: %s.", string(firstbootTargetState))
}
return true, nil
})
if err != nil {
c.Fatalf("Timed out while waiting for first-boot-complete.target to be ready: %v", err)
}
}
Loading