-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Fix TestSearchRepo by waiting till indexing is done #7004
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
Fix TestSearchRepo by waiting till indexing is done #7004
Conversation
Codecov Report
@@ Coverage Diff @@
## master #7004 +/- ##
=========================================
+ Coverage 41.49% 41.5% +<.01%
=========================================
Files 440 440
Lines 59453 59453
=========================================
+ Hits 24668 24673 +5
+ Misses 31566 31560 -6
- Partials 3219 3220 +1
Continue to review full report at Codecov.
|
LGTM |
integrations/repo_search_test.go
Outdated
log.Printf("Waiting for indexing\n") | ||
|
||
i := 0 | ||
for { |
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.
for { | |
for i < 60 { | |
if (repo.IndexerStatus != nil && len(repo.IndexerStatus.CommitSha) != 0) { |
Might be a bit more readable, but thats just a small nit.
integrations/repo_search_test.go
Outdated
time.Sleep(1 * time.Second) | ||
i++ | ||
} | ||
log.Printf("Indexing took: %d s\n", i) |
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.
What happens if the indexing didn't finish after 60 seconds? Should this check to see if it finished and fail with a message if not?
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.
I'm not sure that's much we can really infer much about indexing - the API is very minimal - if anything inferring that the indexing has finished by checking IndexerStatus,CommitSha is non-zero is probably assuming too much. Yes it appears to work and looking at the source code that appears the only way to check but I don't think we can say much more than that.
If after 60s the IndexerStatus.CommitSha hasn't been set then maybe the "API" of indexer has changed? At present this test would just check and hopefully pass - probably taking too long to do so. If however, you enforce that the IndexerStatus has to be set then we're now forcing an API - one which I would not design this way. I guess it depends on how much you want to enforce an API on UpdateRepoIndexer.
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.
Sure, that all makes sense and I wouldn't want to make any big changes or block this fix -- just to avoid confusion by saying it has finished if really we just hit the time limit. Maybe just:
if i < 60 {
log.Printf("Indexing took: %d s\n", i)
} else {
log.Printf("Waited the limit: %d s for indexing, continuing\n", i)
}
Which keeps the current assumptions from the loop but specifies if we think it finished vs it reached the time limit (since reaching the time limit is probably the only thing we would know for sure here)
…b.com:zeripath/gitea into fix-go-gitea#6977-Force-update-index-and-wait
* Fix TestSearchRepo by waiting till indexing is done * Update integrations/repo_search_test.go * changes as per @mrsdizzie
Fixes #6977 by force waiting till the repository has finished updating the index.