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

Determine fuzziness of bleve indexer by keyword length #29706

Merged
merged 18 commits into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
queue is sync in tests
  • Loading branch information
6543 committed Mar 16, 2024
commit f26480c060df972d6f4facd0547992ba3c94c58a
8 changes: 0 additions & 8 deletions modules/indexer/code/indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,3 @@ func populateRepoIndexer(ctx context.Context) {
}
log.Info("Done (re)populating the repo indexer with existing repositories")
}

// GetQueueItemNumber is used in integration tests
func GetQueueItemNumber() int {
if indexerQueue != nil {
return indexerQueue.GetQueueItemNumber()
}
return -1
}
20 changes: 2 additions & 18 deletions tests/integration/repo_search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ package integration
import (
"net/http"
"testing"
"time"

"code.gitea.io/gitea/models/db"
repo_model "code.gitea.io/gitea/models/repo"
Expand All @@ -33,7 +32,7 @@ func TestSearchRepo(t *testing.T) {
repo, err := repo_model.GetRepositoryByOwnerAndName(db.DefaultContext, "user2", "repo1")
assert.NoError(t, err)

executeIndexer(t, repo)
code_indexer.UpdateRepoIndexer(repo)
6543 marked this conversation as resolved.
Show resolved Hide resolved

testSearch(t, "/user2/repo1/search?q=Description&page=1", []string{"README.md"})

Expand All @@ -43,7 +42,7 @@ func TestSearchRepo(t *testing.T) {
repo, err = repo_model.GetRepositoryByOwnerAndName(db.DefaultContext, "user2", "glob")
assert.NoError(t, err)

executeIndexer(t, repo)
code_indexer.UpdateRepoIndexer(repo)
6543 marked this conversation as resolved.
Show resolved Hide resolved

testSearch(t, "/user2/glob/search?q=loren&page=1", []string{"a.txt"})
testSearch(t, "/user2/glob/search?q=loren&page=1&t=match", []string{"a.txt"})
Expand All @@ -60,18 +59,3 @@ func testSearch(t *testing.T, url string, expected []string) {
filenames := resultFilenames(t, NewHTMLParser(t, resp.Body))
assert.EqualValues(t, expected, filenames)
}

func executeIndexer(t *testing.T, repo *repo_model.Repository) {
code_indexer.UpdateRepoIndexer(repo)

for {
number := code_indexer.GetQueueItemNumber()
if number == 0 {
return
}
if number == -1 {
t.Fatal("Indexing failed")
}
time.Sleep(10 * time.Millisecond)
}
}
Loading