-
Notifications
You must be signed in to change notification settings - Fork 36
kola: add sysext.bcachefs tests #883
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ananthb
wants to merge
2
commits into
flatcar:main
Choose a base branch
from
ananthb:add-bcachefs-sysext-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,176 @@ | ||
| // Copyright The Mantle Authors. | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| package sysext | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "github.com/coreos/go-semver/semver" | ||
| "github.com/flatcar/mantle/kola" | ||
| "github.com/flatcar/mantle/kola/cluster" | ||
| "github.com/flatcar/mantle/kola/register" | ||
| "github.com/flatcar/mantle/kola/tests/util" | ||
| "github.com/flatcar/mantle/platform" | ||
| "github.com/flatcar/mantle/platform/conf" | ||
| ) | ||
|
|
||
| // The bcachefs-setup.service unit runs on every boot and is idempotent: | ||
| // it only formats the disk if it isn't already bcachefs, and only mounts | ||
| // /var/lib/bcachefs if it isn't already a mount point. This mirrors what the | ||
| // zfs test relies on zpool import + zfs-mount.service for, but bcachefs has | ||
| // no equivalent auto-import service so we drive mkfs+mount from a unit. | ||
| // | ||
| // The bcachefs.ko kernel module ships in the base image (built in-tree with | ||
| // coreos-modules), so it is available regardless of whether the sysext is | ||
| // merged. The sysext only provides the mkfs.bcachefs / mount.bcachefs | ||
| // userspace tools. | ||
| var bcachefsUserData = conf.Butane(` | ||
| variant: flatcar | ||
| version: 1.0.0 | ||
| storage: | ||
| files: | ||
| - path: /etc/flatcar/enabled-sysext.conf | ||
| contents: | ||
| inline: | | ||
| bcachefs | ||
| systemd: | ||
| units: | ||
| - name: bcachefs-setup.service | ||
| enabled: true | ||
| contents: | | ||
| [Unit] | ||
| Description=Format and mount bcachefs test volume | ||
| After=systemd-sysext.service ensure-sysext.service | ||
| ConditionPathIsMountPoint=!/var/lib/bcachefs | ||
|
|
||
| [Service] | ||
| Type=oneshot | ||
| RemainAfterExit=yes | ||
| ExecStart=/bin/sh -c 'blkid -t TYPE=bcachefs /dev/disk/by-id/virtio-bcachefs || mkfs.bcachefs -f /dev/disk/by-id/virtio-bcachefs' | ||
| ExecStart=/bin/mkdir -p /var/lib/bcachefs | ||
| ExecStart=/bin/mount -t bcachefs /dev/disk/by-id/virtio-bcachefs /var/lib/bcachefs | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target | ||
| `) | ||
|
|
||
| var bcachefsNfsUserData = conf.Butane(` | ||
| variant: flatcar | ||
| version: 1.0.0 | ||
| storage: | ||
| files: | ||
| - path: /etc/flatcar/enabled-sysext.conf | ||
| contents: | ||
| inline: | | ||
| bcachefs | ||
| - path: /etc/exports | ||
| mode: 0644 | ||
| contents: | ||
| inline: | | ||
| /var/lib/bcachefs *(rw,no_root_squash,no_subtree_check,fsid=0) | ||
| systemd: | ||
| units: | ||
| - name: nfs-server.service | ||
| enabled: true | ||
| dropins: | ||
| - name: bcachefs.conf | ||
| contents: | | ||
| [Unit] | ||
| After=bcachefs-setup.service | ||
| Requires=bcachefs-setup.service | ||
| - name: bcachefs-setup.service | ||
| enabled: true | ||
| contents: | | ||
| [Unit] | ||
| Description=Format and mount bcachefs test volume | ||
| After=systemd-sysext.service ensure-sysext.service | ||
| ConditionPathIsMountPoint=!/var/lib/bcachefs | ||
|
|
||
| [Service] | ||
| Type=oneshot | ||
| RemainAfterExit=yes | ||
| ExecStart=/bin/sh -c 'blkid -t TYPE=bcachefs /dev/disk/by-id/virtio-bcachefs || mkfs.bcachefs -f /dev/disk/by-id/virtio-bcachefs' | ||
| ExecStart=/bin/mkdir -p /var/lib/bcachefs | ||
| ExecStart=/bin/mount -t bcachefs /dev/disk/by-id/virtio-bcachefs /var/lib/bcachefs | ||
|
|
||
| [Install] | ||
| WantedBy=multi-user.target | ||
| `) | ||
|
|
||
| func init() { | ||
| register.Register(®ister.Test{ | ||
| Name: "sysext.bcachefs.reboot", | ||
| Run: checkSysextBcachefs, | ||
| ClusterSize: 0, | ||
| Distros: []string{"cl"}, | ||
| // This test is normally not related to the cloud environment | ||
| Platforms: []string{"qemu", "qemu-unpriv", "azure"}, | ||
| // Bump to the first Flatcar release that carries the bcachefs sysext | ||
| // and the in-tree bcachefs.ko kernel module. | ||
| MinVersion: semver.Version{Major: 4374}, | ||
| SkipFunc: skipBcachefs, | ||
| }) | ||
|
|
||
| register.Register(®ister.Test{ | ||
| Name: "sysext.bcachefs.nfs", | ||
| Run: checkBcachefsNfs, | ||
| ClusterSize: 0, | ||
| Distros: []string{"cl"}, | ||
| // This test is normally not related to the cloud environment | ||
| Platforms: []string{"qemu", "qemu-unpriv", "azure"}, | ||
| MinVersion: semver.Version{Major: 4374}, | ||
| SkipFunc: skipBcachefs, | ||
| }) | ||
| } | ||
|
|
||
| func skipBcachefs(version semver.Version, channel, arch, platform string) bool { | ||
| // The initial bcachefs sysext ships amd64-only; skip arm64 until the | ||
| // sysext is published for arm64 too. | ||
| if arch == "arm64" { | ||
| return true | ||
| } | ||
| return kola.SkipSecureboot(version, channel, arch, platform) || skipOnGha(version, channel, arch, platform) | ||
| } | ||
|
|
||
| func createBcachefsMachine(c cluster.TestCluster, userdata *conf.UserData) platform.Machine { | ||
| options := platform.MachineOptions{ | ||
| AdditionalDisks: []platform.Disk{ | ||
| {Size: "1G", DeviceOpts: []string{"serial=bcachefs"}}, | ||
| }, | ||
| } | ||
| m, err := util.NewMachineWithOptions(c, userdata, options) | ||
| if err != nil { | ||
| c.Fatalf("creating a machine failed: %v", err) | ||
| } | ||
| return m | ||
| } | ||
|
|
||
| func checkSysextBcachefs(c cluster.TestCluster) { | ||
| m := createBcachefsMachine(c, bcachefsUserData) | ||
| c.AssertCmdOutputContains(m, "findmnt /var/lib/bcachefs", "bcachefs") | ||
|
ananthb marked this conversation as resolved.
Outdated
|
||
| c.AssertCmdOutputContains(m, "lsmod", "bcachefs") | ||
|
Comment on lines
+150
to
+155
|
||
| c.AssertCmdOutputContains(m, "grep bcachefs /proc/filesystems", "bcachefs") | ||
| c.MustSSH(m, "sudo chown core /var/lib/bcachefs/ && echo world >/var/lib/bcachefs/hello") | ||
| err := m.Reboot() | ||
| if err != nil { | ||
| c.Fatalf("could not reboot: %v", err) | ||
| } | ||
| c.AssertCmdOutputContains(m, "lsmod", "bcachefs") | ||
| c.AssertCmdOutputContains(m, "findmnt /var/lib/bcachefs", "bcachefs") | ||
|
ananthb marked this conversation as resolved.
Outdated
|
||
| c.AssertCmdOutputContains(m, "grep --with-filename . /var/lib/bcachefs/hello", "hello:world") | ||
| } | ||
|
|
||
| func checkBcachefsNfs(c cluster.TestCluster) { | ||
| m := createBcachefsMachine(c, bcachefsNfsUserData) | ||
| c.AssertCmdOutputContains(m, "findmnt /var/lib/bcachefs", "bcachefs") | ||
|
ananthb marked this conversation as resolved.
Outdated
|
||
| c.MustSSH(m, "sudo chown core /var/lib/bcachefs/") | ||
|
Comment on lines
+168
to
+170
|
||
| c.MustSSH(m, "echo world >/var/lib/bcachefs/hello") | ||
| m2, err := c.NewMachine(nfsClientUserData) | ||
| if err != nil { | ||
| c.Fatalf("Cluster.NewMachine: %s", err) | ||
| } | ||
| c.MustSSH(m2, "sudo mkdir /mnt/nfs") | ||
| c.MustSSH(m2, fmt.Sprintf("sudo mount -t nfs -o nfsvers=4 %s:/var/lib/bcachefs /mnt/nfs", m.PrivateIP())) | ||
|
|
||
| c.AssertCmdOutputContains(m2, "cat /mnt/nfs/hello", "world") | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.