diff --git a/mantle/kola/tests/ignition/qemufailure.go b/mantle/kola/tests/ignition/qemufailure.go index ced2320ce7..d829d7b5fa 100644 --- a/mantle/kola/tests/ignition/qemufailure.go +++ b/mantle/kola/tests/ignition/qemufailure.go @@ -19,6 +19,7 @@ import ( "fmt" "os" "os/exec" + "path/filepath" "time" "github.com/pkg/errors" @@ -34,16 +35,19 @@ func init() { register.RegisterTest(®ister.Test{ Name: "coreos.ignition.failure", Description: "Verify ignition will fail with unsupported action.", - Run: runIgnitionTestGroup, + Run: runIgnitionFailure, + ClusterSize: 0, + Platforms: []string{"qemu"}, + Tags: []string{"ignition"}, + }) + register.RegisterTest(®ister.Test{ + Name: "coreos.ignition.uniquebootfs", + Description: "Verify there is only one bootfs.", + Run: runBootfsFailure, ClusterSize: 0, Platforms: []string{"qemu"}, Tags: []string{"ignition"}, }) -} - -func runIgnitionTestGroup(c cluster.TestCluster) { - c.Run("ignition", runIgnitionFailure) - c.Run("bootfs", runBootfsFailure) } func runIgnitionFailure(c cluster.TestCluster) { @@ -115,6 +119,16 @@ func ignitionFailure(c cluster.TestCluster) error { } } +// get current path and create tmp dir +func GetTempdir(dirname string) (string, error) { + dir, err := os.Getwd() + if err != nil { + return "", err + } + path := filepath.Join(dir, dirname) + return path, nil +} + func bootfsFailure(c cluster.TestCluster) error { // We can't create files in / due to the immutable bit OSTree creates, so // this is a convenient way to test Ignition failure. @@ -122,7 +136,13 @@ func bootfsFailure(c cluster.TestCluster) error { if err != nil { return errors.Wrapf(err, "creating empty config") } - cmd := exec.Command("/bin/bash", "-c", fmt.Sprintf(`set -euo pipefail; + + tempDir, err := GetTempdir("tmp") + if err != nil { + fmt.Println("Error getting temp directory:", err) + } + fmt.Println("Temp directory:", tempDir) + cmd := exec.Command(tempDir, "-c", fmt.Sprintf(`set -euo pipefail; truncate -s 1G fakeboot mkfs.ext4 -L boot fakeboot `)) @@ -136,9 +156,11 @@ func bootfsFailure(c cluster.TestCluster) error { builder := platform.NewQemuBuilder() defer builder.Close() builder.SetConfig(failConfig) + err = builder.AddBootDisk(&platform.Disk{ BackingFile: kola.QEMUOptions.DiskImage, }) + if err != nil { return err }