-
Couldn't load subscription status.
- Fork 881
tests: fix when $HOME is only accessible by current user #3559
Conversation
|
It looks like the flakes are related to #3477. |
|
It looks like there are some more cases not covered here, so deferring review to next iteration. |
4e7d548 to
e9993b0
Compare
|
Fixes #1737 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fedora24 failure is a known flake, this LGTM, thanks 🎉!
Leaving the last word to @lucab
tests/testutils/ctx.go
Outdated
| } | ||
|
|
||
| func (ctx *RktRunCtx) GetUidGidRktBinOwnerNotRoot() (int, int) { | ||
| s, _ := os.Stat(ctx.rktBin()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may error out for some reason, in which case we implicitly panic here below. Better to check for error and fallback to GetUnprivilegedUidGid() in that case.
Previously tested by executing rkt binary with user "nobody". This fails when the $HOME folder of the user is only accessible by the user itself. Now the tests first choose the owner of the rkt binary file and if that is root they use the "nobody" user as a fallback.
This fixes that test for me: diff --git a/tests/rkt_non_root_test.go b/tests/rkt_non_root_test.go
index 5794424..98546f9 100644
--- a/tests/rkt_non_root_test.go
+++ b/tests/rkt_non_root_test.go
@@ -38,7 +38,9 @@ func TestNonRootReadInfo(t *testing.T) {
ctx := testutils.NewRktRunCtx()
defer ctx.Cleanup()
- gid, err := common.LookupGid(common.RktGroup)
+ uid, _ := ctx.GetUidGidRktBinOwnerNotRoot()
+
+ rktGid, err := common.LookupGid(common.RktGroup)
if err != nil {
t.Skipf("Skipping the test because there's no %q group", common.RktGroup)
}
@@ -82,7 +84,7 @@ func TestNonRootReadInfo(t *testing.T) {
imgListCmd := fmt.Sprintf("%s image list", ctx.Cmd())
t.Logf("Running %s", imgListCmd)
- runRktAsGidAndCheckOutput(t, imgListCmd, "inspect-", false, gid)
+ runRktAsUidGidAndCheckOutput(t, imgListCmd, "inspect-", false, uid, rktGid)
} |
|
Fix is waiting in #3580 |
Previously CommandsNeedRoot tested by executing rkt binary with user
"nobody". This fails when the ~/ folder of the user is only accessible
by the user itself. Now the test first chooses the owner of the rkt
binary file and if that is root it uses the "nobody" user as a fallback.
Fixes #1737