From 83d84a831862c774b9bc2adc2e11e00bf2a79912 Mon Sep 17 00:00:00 2001 From: Noel Georgi Date: Thu, 2 Jan 2025 20:11:01 +0530 Subject: [PATCH] chore(ci): better zfs checks Part of: https://github.com/siderolabs/extensions/issues/572 Signed-off-by: Noel Georgi --- internal/app/syslogd/internal/parser/parse_test.go | 14 +++++++++----- internal/integration/api/extensions_qemu.go | 14 ++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/internal/app/syslogd/internal/parser/parse_test.go b/internal/app/syslogd/internal/parser/parse_test.go index 6ae6ccad83..1aceca1047 100644 --- a/internal/app/syslogd/internal/parser/parse_test.go +++ b/internal/app/syslogd/internal/parser/parse_test.go @@ -6,7 +6,9 @@ package parser_test import ( + "fmt" "testing" + "time" "github.com/stretchr/testify/require" @@ -14,6 +16,8 @@ import ( ) func TestParser(t *testing.T) { + year := time.Now().Year() + for _, tc := range []struct { name string input []byte @@ -22,27 +26,27 @@ func TestParser(t *testing.T) { { name: "RFC3164 without tag and hostname", input: []byte(`<4>Feb 16 17:54:19 time="2024-02-16T17:54:19.857755073Z" level=warning msg="Could not add /dev/mshv to the devices cgroup`), - expected: `{"content":"time=\"2024-02-16T17:54:19.857755073Z\" level=warning msg=\"Could not add /dev/mshv to the devices cgroup","facility":0,"hostname":"localhost","priority":4,"severity":4,"tag":"unknown","timestamp":"2024-02-16T17:54:19Z"}`, //nolint:lll + expected: fmt.Sprintf(`{"content":"time=\"2024-02-16T17:54:19.857755073Z\" level=warning msg=\"Could not add /dev/mshv to the devices cgroup","facility":0,"hostname":"localhost","priority":4,"severity":4,"tag":"unknown","timestamp":"%d-02-16T17:54:19Z"}`, year), //nolint:lll }, { name: "RFC3164 timestamp contains single digit day", input: []byte(`<6>Mar 3 12:55:18 syslogd_test[834097]: Hello, syslogd!`), - expected: `{"content":"Hello, syslogd!","facility":0,"hostname":"localhost","priority":6,"severity":6,"tag":"syslogd_test","timestamp":"2024-03-03T12:55:18Z"}`, + expected: fmt.Sprintf(`{"content":"Hello, syslogd!","facility":0,"hostname":"localhost","priority":6,"severity":6,"tag":"syslogd_test","timestamp":"%d-03-03T12:55:18Z"}`, year), }, { name: "RFC3164 timestamp contains single digit day & without tag and hostname", input: []byte(`<6>Mar 3 12:55:18 Hello, syslogd!`), - expected: `{"content":"Hello, syslogd!","facility":0,"hostname":"localhost","priority":6,"severity":6,"tag":"unknown","timestamp":"2024-03-03T12:55:18Z"}`, + expected: fmt.Sprintf(`{"content":"Hello, syslogd!","facility":0,"hostname":"localhost","priority":6,"severity":6,"tag":"unknown","timestamp":"%d-03-03T12:55:18Z"}`, year), }, { name: "RFC3164 without hostname", input: []byte(`<4>Feb 16 17:54:19 kata[2569]: time="2024-02-16T17:54:19.857755073Z" level=warning msg="Could not add /dev/mshv to the devices cgroup`), - expected: `{"content":"time=\"2024-02-16T17:54:19.857755073Z\" level=warning msg=\"Could not add /dev/mshv to the devices cgroup","facility":0,"hostname":"localhost","priority":4,"severity":4,"tag":"kata","timestamp":"2024-02-16T17:54:19Z"}`, //nolint:lll + expected: fmt.Sprintf(`{"content":"time=\"2024-02-16T17:54:19.857755073Z\" level=warning msg=\"Could not add /dev/mshv to the devices cgroup","facility":0,"hostname":"localhost","priority":4,"severity":4,"tag":"kata","timestamp":"%d-02-16T17:54:19Z"}`, year), //nolint:lll }, { name: "RFC3164 with hostname", input: []byte(`<4>Feb 16 17:54:19 hostname kata[2569]: time="2024-02-16T17:54:19.857755073Z" level=warning msg="Could not add /dev/mshv to the devices cgroup`), - expected: `{"content":"time=\"2024-02-16T17:54:19.857755073Z\" level=warning msg=\"Could not add /dev/mshv to the devices cgroup","facility":0,"hostname":"hostname","priority":4,"severity":4,"tag":"kata","timestamp":"2024-02-16T17:54:19Z"}`, //nolint:lll + expected: fmt.Sprintf(`{"content":"time=\"2024-02-16T17:54:19.857755073Z\" level=warning msg=\"Could not add /dev/mshv to the devices cgroup","facility":0,"hostname":"hostname","priority":4,"severity":4,"tag":"kata","timestamp":"%d-02-16T17:54:19Z"}`, year), //nolint:lll }, { name: "RFC5424", diff --git a/internal/integration/api/extensions_qemu.go b/internal/integration/api/extensions_qemu.go index d48f737ac8..d13f57640b 100644 --- a/internal/integration/api/extensions_qemu.go +++ b/internal/integration/api/extensions_qemu.go @@ -594,6 +594,20 @@ func (suite *ExtensionsSuiteQEMU) checkZFSPoolMounted() bool { ctx := client.WithNode(suite.ctx, node) + stream, err := suite.Client.LS(ctx, &machineapi.ListRequest{ + Root: "/dev/zvol/tank/vol", + Types: []machineapi.ListRequest_Type{machineapi.ListRequest_REGULAR}, + }) + + suite.Require().NoError(err) + + suite.Require().NoError(helpers.ReadGRPCStream(stream, func(info *machineapi.FileInfo, node string, multipleNodes bool) error { + suite.Require().Equal("/dev/zvol/tank/vol", info.Name, "expected /dev/zvol/tank/vol to exist") + suite.Require().Equal("zd0", info.Link, "expected /dev/zvol/tank/vol to be linked to zd0") + + return nil + })) + disks, err := safe.StateListAll[*block.Disk](ctx, suite.Client.COSI) suite.Require().NoError(err)