@@ -2,13 +2,15 @@ package ignition
2
2
3
3
import (
4
4
"fmt"
5
+ "os"
5
6
"time"
6
7
7
8
coreosarch "github.com/coreos/stream-metadata-go/arch"
8
9
9
10
"github.com/coreos/coreos-assembler/mantle/kola"
10
11
"github.com/coreos/coreos-assembler/mantle/kola/cluster"
11
12
"github.com/coreos/coreos-assembler/mantle/kola/register"
13
+ "github.com/coreos/coreos-assembler/mantle/kola/tests/coretest"
12
14
ut "github.com/coreos/coreos-assembler/mantle/kola/tests/util"
13
15
"github.com/coreos/coreos-assembler/mantle/platform"
14
16
"github.com/coreos/coreos-assembler/mantle/platform/conf"
@@ -50,6 +52,20 @@ func init() {
50
52
ExcludeArchitectures : []string {"s390x" }, // no TPM backend support for s390x
51
53
Tags : []string {"luks" , "tpm" , "tang" , "sss" , kola .NeedsInternetTag , "reprovision" },
52
54
})
55
+ register .RegisterTest (& register.Test {
56
+ Run : runCexTest ,
57
+ ClusterSize : 0 ,
58
+ Name : `luks.cex` ,
59
+ Description : "Verify that CEX-based rootfs encryption works." ,
60
+ Flags : []register.Flag {},
61
+ Platforms : []string {"qemu" },
62
+ Architectures : []string {"s390x" },
63
+ Tags : []string {"luks" , "cex" , "reprovision" },
64
+ NativeFuncs : map [string ]register.NativeFuncWrap {
65
+ "RHCOSGrowpart" : register .CreateNativeFuncWrap (coretest .TestRHCOSGrowfs , []string {"fcos" }... ),
66
+ "FCOSGrowpart" : register .CreateNativeFuncWrap (coretest .TestFCOSGrowfs , []string {"rhcos" }... ),
67
+ },
68
+ })
53
69
}
54
70
55
71
func setupTangMachine (c cluster.TestCluster ) ut.TangServer {
@@ -176,6 +192,74 @@ func runTest(c cluster.TestCluster, tpm2 bool, threshold int, killTangAfterFirst
176
192
ut .LUKSSanityTest (c , tangd , m , tpm2 , killTangAfterFirstBoot , rootPart )
177
193
}
178
194
195
+ func runCexTest (c cluster.TestCluster ) {
196
+ var err error
197
+ var m platform.Machine
198
+
199
+ // To prevent the test to fail the whole run on s390x machine that does not have Cex Device
200
+ cex_uuid := os .Getenv ("KOLA_CEX_UUID" )
201
+ if cex_uuid == "" {
202
+ c .Skip ("No CEX device found in KOLA_CEX_UUID env var" )
203
+ }
204
+
205
+ ignition := conf .Ignition (`{
206
+ "ignition": {
207
+ "version": "3.5.0-experimental"
208
+ },
209
+ "kernelArguments": {
210
+ "shouldExist": [
211
+ "rd.luks.key=/etc/luks/cex.key"
212
+ ]
213
+ },
214
+ "storage": {
215
+ "luks": [
216
+ {
217
+ "name": "root",
218
+ "device": "/dev/disk/by-label/root",
219
+ "cex": {
220
+ "enabled": true
221
+ },
222
+ "label": "root",
223
+ "wipeVolume": true
224
+ }
225
+ ],
226
+ "filesystems": [
227
+ {
228
+ "device": "/dev/mapper/root",
229
+ "format": "xfs",
230
+ "wipeFilesystem": true,
231
+ "label": "root"
232
+ }
233
+ ]
234
+ }
235
+ }` )
236
+
237
+ opts := platform.QemuMachineOptions {
238
+ Cex : true ,
239
+ }
240
+ opts .MinMemory = 8192
241
+
242
+ switch pc := c .Cluster .(type ) {
243
+ case * qemu.Cluster :
244
+ m , err = pc .NewMachineWithQemuOptions (ignition , opts )
245
+ default :
246
+ panic ("Unsupported cluster type" )
247
+ }
248
+
249
+ // copy over kolet into the machine
250
+ if err := kola .ScpKolet ([]platform.Machine {m }); err != nil {
251
+ c .Fatal (err )
252
+ }
253
+ coretest .LocalTests (c )
254
+
255
+ if err != nil {
256
+ c .Fatalf ("Unable to create test machine: %v" , err )
257
+ }
258
+ rootPart := "/dev/disk/by-partlabel/root"
259
+
260
+ ut .LUKSSanityCEXTest (c , m , rootPart )
261
+ }
262
+
179
263
// Verify that the rootfs is encrypted with Tang
180
264
func luksTangTest (c cluster.TestCluster ) {
181
265
runTest (c , false , 1 , false )
0 commit comments