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

WIP 1.13: Support sharding #600

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
WIP: Add support for testing proxies
ellnix committed Jan 24, 2025
commit 00ea4ec36caabc4143bf91e32ecdc1209281bfb0
11 changes: 10 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -34,10 +34,14 @@ First of all, thank you for contributing to Meilisearch! The goal of this docume

You can set up your local environment natively or using `docker`, check out the [`docker-compose.yml`](/docker-compose.yml).

#### With Docker <!-- omit in toc -->
Example of running all the checks with docker:
```bash
docker-compose run --rm package bash -c "bundle install && bundle exec rspec && bundle exec rubocop"
```
<!-- need to run multiple instances of meilisearch for proxy tests -->

#### Locally <!-- omit in toc -->

To install dependencies:
```bash
@@ -51,7 +55,12 @@ Each PR should pass the tests to be accepted.
```bash
# Tests
curl -L https://install.meilisearch.com | sh # download Meilisearch
./meilisearch --master-key=masterKey --no-analytics # run Meilisearch

# run Meilisearch
./meilisearch --master-key=masterKey --no-analytics
# run a second instance of Meilisearch to act as proxy
./meilisearch --master-key=masterKey --no-analytics --http-addr localhost:7701

bundle exec rspec
```

38 changes: 36 additions & 2 deletions spec/meilisearch/client/proxy_spec.rb
Original file line number Diff line number Diff line change
@@ -8,8 +8,8 @@
let(:sample_remote) do
{
uid: 'ms-2',
url: 'localhost:7701',
search_api_key: 'masterKey'
url: PROXY_URL,
search_api_key: MASTER_KEY
}
end

@@ -92,4 +92,38 @@
expect(client.remotes).to eq(default_remotes)
end
end

describe 'searching multiple remotes' do
# this of course means we need to support federated search,
# which has not been merged yet.
it 'federated search searches multiple remotes' do
three_body_problem = { id: 1, title: 'The Three Body Problem' }
the_dark_forest = { id: 2, title: 'The Dark Forest' }
proxy_client.index('books').add_documents([three_body_problem, the_dark_forest])

sherwood_forest = { id: 50, name: 'Sherwood Forest' }
forbidden_forest = { id: 200, name: 'Forbidden Forest' }
client.index('parks').add_documents([sherwood_forest, forbidden_forest])

client.add_remote(sample_remote)

response = client.multi_search(
federation: {},
queries: [
{
q: 'Forest',
index_uid: 'parks'
},
{
q: 'Body',
index_uid: 'books',
remote: 'ms-2'
}
]
)

expect(response['hits']).to include(three_body_problem, sherwood_forest, forbidden_forest)
expect(response['hits']).not_to include(the_dark_forest)
end
end
end
4 changes: 4 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -42,6 +42,10 @@
# Globals for all tests
URL = format('http://%<host>s:%<port>s',
host: ENV.fetch('MEILISEARCH_URL', 'localhost'), port: ENV.fetch('MEILISEARCH_PORT', '7700'))

PROXY_URL = format('http://%<host>s:%<port>s',
host: ENV.fetch('MEILISEARCH_URL_PROXY', 'localhost'), port: ENV.fetch('MEILISEARCH_PORT_PROXY', '7701'))

MASTER_KEY = 'masterKey'
DEFAULT_SEARCH_RESPONSE_KEYS = [
'hits',
1 change: 1 addition & 0 deletions spec/support/default_shared_context.rb
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

RSpec.shared_context 'test defaults' do
let(:client) { Meilisearch::Client.new(URL, MASTER_KEY, { timeout: 2, max_retries: 1 }) }
let(:proxy_client) { Meilisearch::Client.new(PROXY_URL, MASTER_KEY, { timeout: 2, max_retries: 1 }) }

before do
clear_all_indexes(client)