Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests/api: refine TestPreparingProgress to make test stable #8014

Merged
merged 7 commits into from Apr 11, 2024

Conversation

HuSharp
Copy link
Member

@HuSharp HuSharp commented Apr 2, 2024

What problem does this PR solve?

Issue Number: Ref #7969

What is changed and how does it work?

Because TestPreparingProgress mixes cluster prepare(3s per tick) and checkStores

  • scheduler prepare (3s per tick)

    ticker := time.NewTicker(runSchedulerCheckInterval)
    failpoint.Inject("changeCoordinatorTicker", func() {
    ticker = time.NewTicker(100 * time.Millisecond)
    })
    defer ticker.Stop()
    log.Info("coordinator starts to collect cluster information")
    for {
    if c.ShouldRun(collectWaitTime...) {
    log.Info("coordinator has finished cluster information preparation")
    break
    }
    select {
    case <-ticker.C:
    case <-c.ctx.Done():
    log.Info("coordinator stops running")
    return
    }
    }

  • checkStores(2s per tick)

    func (c *RaftCluster) runNodeStateCheckJob() {
    defer logutil.LogPanic()
    defer c.wg.Done()
    ticker := time.NewTicker(nodeStateCheckJobInterval)
    failpoint.Inject("highFrequencyClusterJobs", func() {
    ticker.Stop()
    ticker = time.NewTicker(2 * time.Second)
    })
    defer ticker.Stop()
    for {
    select {
    case <-c.ctx.Done():
    log.Info("node state check job has been stopped")
    return
    case <-ticker.C:
    c.checkStores()
    }
    }
    }

  • If sleep 2s directly(which wants to wait for checkStores tick maybe mixed cluster prepare & checkStores, which will make test unstable.

    // is not prepared
    time.Sleep(2 * time.Second)
    output = sendRequest(re, leader.GetAddr()+"/pd/api/v1/stores/progress?action=preparing", http.MethodGet, http.StatusNotFound)
    re.Contains((string(output)), "no progress found for the action")
    output = sendRequest(re, leader.GetAddr()+"/pd/api/v1/stores/progress?id=4", http.MethodGet, http.StatusNotFound)
    re.Contains((string(output)), "no progress found for the given store ID")
    // size is not changed.
    leader.GetRaftCluster().SetPrepared()
    time.Sleep(2 * time.Second)

So I have changed to eventually.

Check List

Tests

  • Integration test

Release note

None.

@HuSharp HuSharp requested review from JmPotato and rleungx April 2, 2024 03:35
Copy link
Contributor

ti-chi-bot bot commented Apr 2, 2024

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • lhy1024
  • rleungx

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot bot added release-note-none size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 2, 2024
Copy link

codecov bot commented Apr 2, 2024

Codecov Report

Merging #8014 (f6616a3) into master (67461dd) will decrease coverage by 0.05%.
Report is 1 commits behind head on master.
The diff coverage is n/a.

❗ Current head f6616a3 differs from pull request most recent head 7b3e56c. Consider uploading reports for the commit 7b3e56c to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8014      +/-   ##
==========================================
- Coverage   77.27%   77.23%   -0.05%     
==========================================
  Files         468      468              
  Lines       60890    60869      -21     
==========================================
- Hits        47055    47012      -43     
- Misses      10291    10307      +16     
- Partials     3544     3550       +6     
Flag Coverage Δ
unittests 77.23% <ø> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@HuSharp HuSharp requested a review from nolouch April 2, 2024 05:23
@HuSharp HuSharp force-pushed the refine_progress_test branch 2 times, most recently from 1671e73 to ce51e6b Compare April 2, 2024 07:36
Signed-off-by: husharp <jinhao.hu@pingcap.com>
@HuSharp
Copy link
Member Author

HuSharp commented Apr 2, 2024

/hold

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 2, 2024
@HuSharp
Copy link
Member Author

HuSharp commented Apr 10, 2024

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 10, 2024
@ti-chi-bot ti-chi-bot bot added the status/LGT1 Indicates that a PR has LGTM 1. label Apr 11, 2024
Comment on lines +804 to +806
if !leader.GetRaftCluster().IsPrepared() {
leader.GetRaftCluster().SetPrepared()
return false
Copy link
Member

Choose a reason for hiding this comment

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

Do we need them since line 782 is return true?

Copy link
Member Author

Choose a reason for hiding this comment

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

  • If enter the if judgment at line 782, then return at line 792. Then there's still a chance that we didn't prepare, so we need to wait for prepare to finish.
  • The previous Eventually(line 782-798) is actually a judgment for not preparing.

Copy link
Member

Choose a reason for hiding this comment

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

got

Copy link
Member

@rleungx rleungx left a comment

Choose a reason for hiding this comment

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

The rest LGTM

@ti-chi-bot ti-chi-bot bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Apr 11, 2024
Signed-off-by: husharp <jinhao.hu@pingcap.com>
@HuSharp
Copy link
Member Author

HuSharp commented Apr 11, 2024

/merge

Copy link
Contributor

ti-chi-bot bot commented Apr 11, 2024

@HuSharp: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

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 ti-community-infra/tichi repository.

Copy link
Contributor

ti-chi-bot bot commented Apr 11, 2024

This pull request has been accepted and is ready to merge.

Commit hash: 7b3e56c

@ti-chi-bot ti-chi-bot bot added the status/can-merge Indicates a PR has been approved by a committer. label Apr 11, 2024
@ti-chi-bot ti-chi-bot bot merged commit 39f5712 into tikv:master Apr 11, 2024
22 checks passed
@HuSharp HuSharp deleted the refine_progress_test branch April 11, 2024 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none size/L Denotes a PR that changes 100-499 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants