diff --git a/kola/tests/ignition/partitions.go b/kola/tests/ignition/partitions.go new file mode 100644 index 000000000..0c7b3fcc3 --- /dev/null +++ b/kola/tests/ignition/partitions.go @@ -0,0 +1,78 @@ +// Copyright The Mantle Authors +// SPDX-License-Identifier: Apache-2.0 +package ignition + +import ( + "github.com/flatcar/mantle/kola/cluster" + "github.com/flatcar/mantle/kola/register" + "github.com/flatcar/mantle/kola/tests/util" + "github.com/flatcar/mantle/platform/conf" +) + +const ( + userdata = `{ + "ignition": { "version": "2.3.0" }, + "storage": { + "disks": [ + { + "device": "/dev/disk/by-id/virtio-primary-disk", + "partitions": [ + { + "label": "VAR", + "number": 10, + "startMiB": 9216 + } + ] + } + ], + "files": [ + { + "filesystem": "root", + "path": "/etc/fstab", + "contents": { + "source": "data:,%2Fdev%2Fdisk%2Fby-label%2Fvar%20%2Fvar%20xfs%20defaults%200%200%0A", + "verification": {} + }, + "mode": 420 + } + ], + "filesystems": [ + { + "mount": { + "device": "/dev/disk/by-partlabel/VAR", + "format": "xfs", + "label": "var" + }, + "name": "var" + } + ] + }, + "systemd": {} +}` +) + +func init() { + register.Register(®ister.Test{ + Name: "cl.ignition.partitions", + Run: checkPartitions, + ClusterSize: 0, + Distros: []string{"cl"}, + Platforms: []string{"qemu", "qemu-unpriv"}, + }) +} + +func checkPartitions(c cluster.TestCluster) { + m, err := util.NewMachineWithLargeDisk(c, "10G", conf.Ignition(userdata)) + if err != nil { + c.Fatal(err) + } + out := c.MustSSH(m, "lsblk -f") + c.Logf("lsblk -f:\n%s", out) + out = c.MustSSH(m, "findmnt") + c.Logf("findmnt:\n%s", out) + + c.MustSSH(m, "mountpoint /var") + c.MustSSH(m, "ls -la /dev/disk/by-partlabel/VAR") + c.MustSSH(m, "ls -la /dev/disk/by-label/var") + c.AssertCmdOutputContains(m, "findmnt /var", "xfs") +}