Skip to content

[fix](fe) Stabilize optimize available MV unit test#64636

Open
seawinde wants to merge 1 commit into
apache:branch-4.1from
seawinde:fix-optimize-get-available-mvs-ut
Open

[fix](fe) Stabilize optimize available MV unit test#64636
seawinde wants to merge 1 commit into
apache:branch-4.1from
seawinde:fix-optimize-get-available-mvs-ut

Conversation

@seawinde

Copy link
Copy Markdown
Member

What problem does this PR solve?

Issue Number: N/A

Related PR: N/A

Problem Summary:
OptimizeGetAvailableMvsTest could fail intermittently because TestWithFeService reuses the same FE environment across test methods. If a materialized view survived a failed assertion, a later case could see an extra rewrite candidate. The partition-prune case also depended on asynchronous MTMV refresh state before the materialized view became a rewrite candidate, so the candidate map could be empty.

Root cause: In OptimizeGetAvailableMvsTest, test methods created materialized views with fixed names and only dropped them at the end of the happy path, so failed assertions could leave state behind for later test methods. The partition-prune case also did not mock MTMV.canBeCandidate(), which made the test depend on asynchronous MTMV refresh state.

Change Summary:

File Change Description
OptimizeGetAvailableMvsTest.java Drop test materialized views before and after each test.
OptimizeGetAvailableMvsTest.java Mock MTMV.canBeCandidate() in the partition-prune case.

Release note

None

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

### What problem does this PR solve?

Issue Number: N/A

Related PR: N/A

Problem Summary:
OptimizeGetAvailableMvsTest could fail intermittently because TestWithFeService reuses the same FE environment across test methods. If a materialized view survived a failed assertion, a later case could see an extra rewrite candidate. The partition-prune case also depended on the asynchronous MTMV refresh state before the materialized view became a rewrite candidate, so the candidate map could be empty.

Root cause: In OptimizeGetAvailableMvsTest, test methods created materialized views with fixed names and only dropped them at the end of the happy path, so failed assertions could leave state behind for later test methods. The partition-prune case also did not mock MTMV.canBeCandidate(), which made the test depend on asynchronous MTMV refresh state.

Change Summary:
- OptimizeGetAvailableMvsTest: drop test materialized views before and after each test.
- OptimizeGetAvailableMvsTest: mock MTMV.canBeCandidate() in the partition-prune case.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - git diff --check upstream/branch-4.1...HEAD
    - mvn -pl fe-core -am test -Dcheckstyle.skip=true -DfailIfNoTests=false -Dtest=org.apache.doris.nereids.mv.OptimizeGetAvailableMvsTest -Dskip.clean=true
- Behavior changed: No
- Does this need documentation: No
@seawinde seawinde requested a review from yiguolei as a code owner June 18, 2026 09:02
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@seawinde

Copy link
Copy Markdown
Member Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage `` 🎉
Increment coverage report
Complete coverage report

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants