Skip to content

Commit 4e5ff8f

Browse files
committed
fix(ci): zfs test
Expect the zvol file to be present eventually. Signed-off-by: Noel Georgi <git@frezbo.dev>
1 parent 14abe51 commit 4e5ff8f

1 file changed

Lines changed: 27 additions & 13 deletions

File tree

internal/integration/api/extensions_qemu.go

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,9 @@ func (suite *ExtensionsSuiteQEMU) TestExtensionsZFS() {
469469
}
470470
}()
471471

472-
suite.Require().True(suite.checkZFSPoolMounted(node), "expected zfs pool to be mounted")
472+
suite.EventuallyWithT(func(t *assert.CollectT) {
473+
suite.checkZFSPoolMounted(t, node)
474+
}, 2*time.Minute, time.Second, "expected zfs pool to be mounted")
473475

474476
// now we want to reboot the node and make sure the pool is still mounted
475477
suite.AssertRebooted(
@@ -479,36 +481,48 @@ func (suite *ExtensionsSuiteQEMU) TestExtensionsZFS() {
479481
suite.CleanupFailedPods,
480482
)
481483

482-
suite.Require().True(suite.checkZFSPoolMounted(node), "expected zfs pool to be mounted")
484+
suite.EventuallyWithT(func(t *assert.CollectT) {
485+
suite.checkZFSPoolMounted(t, node)
486+
}, 30*time.Second, time.Second, "expected zfs pool to be mounted after reboot")
483487
}
484488

485-
func (suite *ExtensionsSuiteQEMU) checkZFSPoolMounted(node string) bool {
489+
func (suite *ExtensionsSuiteQEMU) checkZFSPoolMounted(t *assert.CollectT, node string) {
486490
ctx := client.WithNode(suite.ctx, node)
487491

488492
stream, err := suite.Client.LS(ctx, &machineapi.ListRequest{
489-
Root: "/dev/zvol/tank/vol",
490-
Types: []machineapi.ListRequest_Type{machineapi.ListRequest_REGULAR},
493+
Root: "/dev/zvol/tank/",
494+
Types: []machineapi.ListRequest_Type{machineapi.ListRequest_SYMLINK},
491495
})
496+
if !assert.NoError(t, err, "LS /dev/zvol/tank/") {
497+
return
498+
}
492499

493-
suite.Require().NoError(err)
500+
found := false
494501

495-
suite.Require().NoError(helpers.ReadGRPCStream(stream, func(info *machineapi.FileInfo, node string, multipleNodes bool) error {
496-
suite.Require().Equal("/dev/zvol/tank/vol", info.Name, "expected /dev/zvol/tank/vol to exist")
497-
suite.Require().Equal("zd0", info.Link, "expected /dev/zvol/tank/vol to be linked to zd0")
502+
if !assert.NoError(t, helpers.ReadGRPCStream(stream, func(info *machineapi.FileInfo, node string, multipleNodes bool) error {
503+
if info.Name == "/dev/zvol/tank/vol" && strings.HasPrefix(filepath.Base(info.Link), "zd") {
504+
found = true
505+
}
498506

499507
return nil
500-
}))
508+
}), "reading LS stream") {
509+
return
510+
}
511+
512+
assert.True(t, found, "expected /dev/zvol/tank/vol symlink pointing to a zd* device")
501513

502514
disks, err := safe.StateListAll[*block.Disk](ctx, suite.Client.COSI)
503-
suite.Require().NoError(err)
515+
if !assert.NoError(t, err, "StateListAll disks") {
516+
return
517+
}
504518

505519
for disk := range disks.All() {
506520
if strings.HasPrefix(disk.TypedSpec().DevPath, "/dev/zd") {
507-
return true
521+
return
508522
}
509523
}
510524

511-
return false
525+
assert.Fail(t, "no /dev/zd* disk found in block resources")
512526
}
513527

514528
// TestExtensionsUtilLinuxTools verifies util-linux-tools are working.

0 commit comments

Comments
 (0)