@@ -19,6 +19,7 @@ import (
19
19
"fmt"
20
20
"os"
21
21
"os/exec"
22
+ "path/filepath"
22
23
"time"
23
24
24
25
"github.com/pkg/errors"
@@ -34,16 +35,19 @@ func init() {
34
35
register .RegisterTest (& register.Test {
35
36
Name : "coreos.ignition.failure" ,
36
37
Description : "Verify ignition will fail with unsupported action." ,
37
- Run : runIgnitionTestGroup ,
38
+ Run : runIgnitionFailure ,
39
+ ClusterSize : 0 ,
40
+ Platforms : []string {"qemu" },
41
+ Tags : []string {"ignition" },
42
+ })
43
+ register .RegisterTest (& register.Test {
44
+ Name : "coreos.ignition.uniquebootfs" ,
45
+ Description : "Verify there is only one bootfs." ,
46
+ Run : runBootfsFailure ,
38
47
ClusterSize : 0 ,
39
48
Platforms : []string {"qemu" },
40
49
Tags : []string {"ignition" },
41
50
})
42
- }
43
-
44
- func runIgnitionTestGroup (c cluster.TestCluster ) {
45
- c .Run ("ignition" , runIgnitionFailure )
46
- c .Run ("bootfs" , runBootfsFailure )
47
51
}
48
52
49
53
func runIgnitionFailure (c cluster.TestCluster ) {
@@ -115,14 +119,30 @@ func ignitionFailure(c cluster.TestCluster) error {
115
119
}
116
120
}
117
121
122
+ // get current path and create tmp dir
123
+ func GetTempdir (dirname string ) (string , error ) {
124
+ dir , err := os .Getwd ()
125
+ if err != nil {
126
+ return "" , err
127
+ }
128
+ path := filepath .Join (dir , dirname )
129
+ return path , nil
130
+ }
131
+
118
132
func bootfsFailure (c cluster.TestCluster ) error {
119
133
// We can't create files in / due to the immutable bit OSTree creates, so
120
134
// this is a convenient way to test Ignition failure.
121
135
failConfig , err := conf .EmptyIgnition ().Render (conf .FailWarnings )
122
136
if err != nil {
123
137
return errors .Wrapf (err , "creating empty config" )
124
138
}
125
- cmd := exec .Command ("/bin/bash" , "-c" , fmt .Sprintf (`set -euo pipefail;
139
+
140
+ tempDir , err := GetTempdir ("tmp" )
141
+ if err != nil {
142
+ fmt .Println ("Error getting temp directory:" , err )
143
+ }
144
+ fmt .Println ("Temp directory:" , tempDir )
145
+ cmd := exec .Command (tempDir , "-c" , fmt .Sprintf (`set -euo pipefail;
126
146
truncate -s 1G fakeboot
127
147
mkfs.ext4 -L boot fakeboot
128
148
` ))
@@ -136,9 +156,11 @@ func bootfsFailure(c cluster.TestCluster) error {
136
156
builder := platform .NewQemuBuilder ()
137
157
defer builder .Close ()
138
158
builder .SetConfig (failConfig )
159
+
139
160
err = builder .AddBootDisk (& platform.Disk {
140
161
BackingFile : kola .QEMUOptions .DiskImage ,
141
162
})
163
+
142
164
if err != nil {
143
165
return err
144
166
}
0 commit comments