Skip to content

Skip unit test when prjquota not supported#51083

Open
oggstr wants to merge 1 commit intomoby:masterfrom
oggstr:skip-tests-unsupported-quota
Open

Skip unit test when prjquota not supported#51083
oggstr wants to merge 1 commit intomoby:masterfrom
oggstr:skip-tests-unsupported-quota

Conversation

@oggstr
Copy link

@oggstr oggstr commented Oct 2, 2025

Closes #51065.

- What I did

Added an additional prerequisite check before running daemon/internal/quota units tests. This fixes an issue where the tests could run in environments where they could never succeed.

In particular, I extended the CanTestQuota to also attempt a mount using the prjquota option. This ensures that XFS actually supports the quota option before running tests.

- How I did it

Added a function called supportsQuota that attempts a mount. It reuses some existing logic to prepare the XFS image (PrepareQuotaTestImage).

- How to verify it

Run the quota unit tests

TESTDIRS='./daemon/internal/quota/' ./hack/test/unit

The outcome depends on what the backing filesystem supports

  • No XFS support: tests skipped (old check)
  • XFS support, but missing quota support: tests skipped (new check)
  • XFS support and quota support: tests run

Unfortunately I don't have easy access to a system where XFS support quotas, so I've been unable to verify the last scenario.

- Human readable description for the release notes

- A picture of a cute animal (not mandatory but encouraged)

image

Baby moose

// CanTestQuota - checks if xfs prjquota can be tested
// returns a reason if not
func CanTestQuota() (string, bool) {
func CanTestQuota(t *testing.T) (string, bool) {
Copy link
Member

@AkihiroSuda AkihiroSuda Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't seem necessary to pass t *testing.T just for t.TempDir()

Suggested change
func CanTestQuota(t *testing.T) (string, bool) {
func CanTestQuota() (string, bool) {

Alternatively you can just omit return values and call t.Skip() from this function

Suggested change
func CanTestQuota(t *testing.T) (string, bool) {
func RequireSupported(t *testing.T) {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a quick blurb / thinking out loud; I haven't checked exactly how we set things up for tests, but I think the location used for daemons to run tests is configurable; in that case, we may need to pass the location to test, as it could be on a different filesystem.

(I recall we had some checks in graph-drivers that created a tempDir to test if they were supported, but didn't account for (e.g. /var/lib/docker/XXX to be a different storage / mount attached to the machine)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay – I've been under the weather for a few days.

@thaJeztah

I'm not sure I understand your comment fully.

I found this issue (that you submitted to GO) linked in a comment (daemon/daemon_test.go:345). Seems like there's some trickiness with temp directories in MacOS. Is this related to what you're talking about?

The code at this particular comment resolves symlinks using filepath.EvalSymlinks(t.TempDir()). However, this seems to be the only case where this is done. As far as I can tell, there seems to be no special handling of t.TempDir() anywhere else.

Would you mind expanding on your point?

@AkihiroSuda

My thinking was that it simplifies clean-up. Calling t.Skip() from inside the helper would be hiding control flow in my eyes, but I think with a re-name to RequireSupported (or something similar) it's fine enough.

I'll go ahead and change it once I hear back from @thaJeztah

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went ahead and updated the PR. Function now skips the test directly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a quick blurb / thinking out loud; I haven't checked exactly how we set things up for tests, but I think the location used for daemons to run tests is configurable; in that case, we may need to pass the location to test, as it could be on a different filesystem.

@thaJeztah - maybe you're thinking of $DOCKER_INTEGRATION_DAEMON_DEST? If so, it's probably ok .. the temp dir here is only used as a mount point, to check the kernel can mount a filesystem with the prjquota option. The filesystem it's mounted in to isn't important?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hope you don't mind be pinging you @thaJeztah, but would you mind having a look at Rob's comment above?

I'd be happy to look in to your question, but I would need some more info to go on.

@oggstr oggstr force-pushed the skip-tests-unsupported-quota branch from fd4118c to 0fba10d Compare October 12, 2025 16:25
@github-actions github-actions bot added area/volumes Volumes area/daemon Core Engine labels Oct 12, 2025
@oggstr oggstr force-pushed the skip-tests-unsupported-quota branch 2 times, most recently from 0e43768 to 2a019c1 Compare October 12, 2025 16:43
Signed-off-by: Oskar Arensmeier <oskar.arensmeier@outlook.com>
@oggstr oggstr force-pushed the skip-tests-unsupported-quota branch from 2a019c1 to 66f7a48 Compare October 13, 2025 17:50
Copy link
Contributor

@robmry robmry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - but will wait to see if @thaJeztah's question is answered before merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/daemon Core Engine area/volumes Volumes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Quota unit tests not skipped when pquota not supported

4 participants