Skip to content

Commit

Permalink
fix: fix e2e test with extensions and SELinux
Browse files Browse the repository at this point in the history
Skip SELinux test when system extensions are active, we'll work on that in a bit. Also elaborate more on SELinux test errors.

Signed-off-by: Dmitry Sharshakov <[email protected]>
  • Loading branch information
dsseng committed Nov 27, 2024
1 parent af91c99 commit 23c8ea9
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions internal/integration/api/selinux.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,11 @@ func (suite *SELinuxSuite) checkFileLabels(nodes []string, expectedLabels map[st
suite.T().Skip("skipping SELinux test since SELinux is disabled")
}

// TODO: do not skip the test if system extensions are enabled
if suite.ExtensionsQEMU || suite.ExtensionsNvidia {
suite.T().Skip("skipping SELinux test since system extensions are enabled")
}

// We should check both folders and their contents for proper labels
for _, dir := range []bool{true, false} {
for path, label := range expectedLabels {
Expand All @@ -173,30 +178,30 @@ func (suite *SELinuxSuite) checkFileLabels(nodes []string, expectedLabels map[st
return nil
}

suite.Require().NotNil(info.Xattrs)
suite.Require().NotNil(info.Xattrs, "no xattrs for %s", info.Name)

found := false

for _, l := range info.Xattrs {
if l.Name == "security.selinux" {
got := string(bytes.Trim(l.Data, "\x00\n"))
suite.Require().Contains(got, label, "expected %s to have label %s, got %s", path, label, got)
suite.Require().Contains(got, label, "expected %s to have label %s, got %s", info.Name, label, got)

found = true

break
}
}

suite.Require().True(found)
suite.Require().True(found, "could not find security.selinux xattr for %s", info.Name)

return nil
})

if allowMissing {
if err != nil {
suite.Require().Contains(err.Error(), "lstat")
suite.Require().Contains(err.Error(), "no such file or directory")
suite.Require().Contains(err.Error(), "lstat", "expected error to be due to missing file %s", path)
suite.Require().Contains(err.Error(), "no such file or directory", "expected error to be due to missing file %s", path)
}
} else {
suite.Require().NoError(err)
Expand Down

0 comments on commit 23c8ea9

Please sign in to comment.