Skip to content

fix: skip non-writable directory check in TestPreCheckConfig when running as root#12548

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-flaky-unit-test-precheckconfig
Draft

fix: skip non-writable directory check in TestPreCheckConfig when running as root#12548
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-flaky-unit-test-precheckconfig

Conversation

Copy link

Copilot AI commented Mar 10, 2026

What problem does this PR solve?

Issue Number: close #xxx

TestPreCheckConfig was flaky on CI because the non-writable directory subtest (0o400 perms) expects PreCheckConfig to return an error, but Linux root bypasses DAC permission checks — IsDirReadWritable succeeds unconditionally as root, causing a spurious nil error result.

What is changed and how it works?

  • Wraps the non-writable directory subtest in os.Getuid() != 0 guard so it's skipped when the test process runs as root, where the assumption "can't write to a 0o400 dir" simply doesn't hold.
if os.Getuid() != 0 {
    baseDir = filepath.Join(dir, "not-writable")
    require.NoError(t, os.MkdirAll(baseDir, 0o400))
    err = PreCheckConfig(resModel.LocalFileConfig{BaseDir: baseDir})
    require.Error(t, err)
    require.Regexp(t, ".*ErrLocalFileDirNotWritable.*", err)
}

Check List

Tests

  • Unit test

Questions

Will it cause performance regression or break compatibility?

No.

Do you need to update user documentation, design documentation or monitoring documentation?

No.

Release note

None
Original prompt

This section details on the original issue you should resolve

<issue_title>Flaky unit test: TestPreCheckConfig in engine/pkg/externalresource/internal/local</issue_title>
<issue_description>Summary
TestPreCheckConfig in engine/pkg/externalresource/internal/local is flaky on master. The test intermittently expects an error but receives nil.

Failure Log

=== FAIL: engine/pkg/externalresource/internal/local TestPreCheckConfig (0.00s)
    file_manager_test.go:285:
[2026/03/10 17:43:36.414 +08:00] [INFO] [file_manager.go:70] ["Created directory for local file resource"] [resource-name=resource-1-1] [path=/tmp/TestFileManagerManyWorkers3730084022/001/worker-1/7265736f757263652d312d31]
[2026/03/10 17:43:36.414 +08:00] [INFO] [file_manager.go:221] ["Local resource has been removed"] [resource-id=resource-1]
        Error Trace:    /home/prow/go/src/github.com/pingcap/tiflow/engine/pkg/externalresource/internal/local/file_manager_test.go:285
        Error:          An error is expected but got nil.
        Test:           TestPreCheckConfig
[2026/03/10 17:43:36.414 +08:00] [INFO] [file_manager.go:70] ["Created directory for local file resource"] [resource-name=resource-1-2] [path=/tmp/TestFileManagerManyWorkers3730084022/001/worker-1/7265736f757263652d312d32]
[2026/03/10 17:43:36.415 +08:00] [INFO] [file_manager.go:70] ["Created directory for local file resource"] [resource-name=resource-2-1] [path=/tmp/TestFileManagerManyWorkers3730084022/001/worker-2/7265736f757263652d322d31]

References

Notes

  • Observed on 2026-03-10.
    </issue_description>

<agent_instructions>fix the bug and fix it.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@ti-chi-bot ti-chi-bot bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. contribution This PR is from a community contributor. first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Mar 10, 2026
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Mar 10, 2026

Hi @Copilot. Thanks for your PR.

I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot ti-chi-bot bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Mar 10, 2026
…ning as root

Co-authored-by: wuhuizuo <2574558+wuhuizuo@users.noreply.github.com>
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Mar 10, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign benjamin2037 for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added area/engine Issues or PRs related to Dataflow Engine. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Mar 10, 2026
Copilot AI changed the title [WIP] Fix flaky unit test: TestPreCheckConfig in local package fix: skip non-writable directory check in TestPreCheckConfig when running as root Mar 10, 2026
@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Mar 10, 2026
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Mar 10, 2026

[FORMAT CHECKER NOTIFICATION]

Notice: To remove the do-not-merge/needs-linked-issue label, please provide the linked issue number on one line in the PR body, for example: Issue Number: close #123 or Issue Number: ref #456.

📖 For more info, you can check the "Contribute Code" section in the development guide.

@wuhuizuo
Copy link
Contributor

/test wip-pull-unit-test-engine wip-pull-unit-test-dm

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Mar 10, 2026

@Copilot: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
wip-pull-unit-test-engine 0ed5e0d link true /test wip-pull-unit-test-engine
wip-pull-unit-test-dm 0ed5e0d link true /test wip-pull-unit-test-dm

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

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

Labels

area/engine Issues or PRs related to Dataflow Engine. contribution This PR is from a community contributor. do-not-merge/needs-linked-issue do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky unit test: TestPreCheckConfig in engine/pkg/externalresource/internal/local

2 participants