-
Notifications
You must be signed in to change notification settings - Fork 103
Add support for export api #1171
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
base: main
Are you sure you want to change the base?
Changes from all commits
f19c736
279f109
d1f84c1
5175ae8
b5e78ea
0942859
9fb8f82
c9cfc23
c208bc2
6392933
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import os | ||
| import time | ||
|
|
||
| import pytest | ||
|
|
||
| from tests import common | ||
|
|
||
| pytestmark = pytest.mark.skipif( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think these tests are being skipped since this ENV variable isnt present in the actions
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we need two meilisearch servers to check export status, I tried to change workflow but tests were taking too much time. Therefore I made them skip. |
||
| not os.getenv("MEILISEARCH_URL_2"), | ||
| reason="Export API tests run only when second server is configured", | ||
| ) | ||
|
|
||
|
|
||
| def test_export_creation( | ||
| client, client2, index_with_documents, enable_vector_search | ||
| ): # pylint: disable=unused-argument | ||
| """Tests the creation of a Meilisearch export.""" | ||
| index = index_with_documents() | ||
| export_task = client.export(common.BASE_URL_2, api_key=common.MASTER_KEY) | ||
| task_result = client.wait_for_task(export_task.task_uid) | ||
| assert task_result.status == "succeeded" | ||
|
|
||
| index2 = client2.get_index(index.uid) | ||
| assert index2.uid == index.uid | ||
| assert index2.primary_key == index.get_primary_key() | ||
| assert_exported_count(index2, index.get_documents().total) | ||
|
|
||
|
|
||
| def test_export_creation_with_index_filter( | ||
| client, client2, index_with_documents, enable_vector_search | ||
| ): # pylint: disable=unused-argument | ||
| """Tests the creation of a Meilisearch export with specific index UIDs.""" | ||
| index = index_with_documents() | ||
|
|
||
| indexes = {index.uid: {"filter": None}} | ||
| export_task = client.export(common.BASE_URL_2, api_key=common.MASTER_KEY, indexes=indexes) | ||
| task_result = client.wait_for_task(export_task.task_uid) | ||
| assert task_result.status == "succeeded" | ||
|
|
||
| response = client2.get_indexes() | ||
| assert response["total"] == 1 | ||
| index2 = client2.get_index(index.uid) | ||
| assert index2.uid == index.uid | ||
| assert index2.primary_key == index.get_primary_key() | ||
| assert_exported_count(index2, index.get_documents().total) | ||
|
|
||
|
|
||
| def assert_exported_count(index, expected_count): | ||
| # Wait up to 20 seconds for documents to be imported | ||
| max_attempts = 20 | ||
| for attempt in range(max_attempts): | ||
| doc_count = index.get_documents().total | ||
| if doc_count == expected_count: | ||
| return | ||
| if attempt < max_attempts - 1: | ||
| time.sleep(1) | ||
|
|
||
| # Final check with clear failure message | ||
| actual_count = index.get_documents().total | ||
| assert actual_count == expected_count | ||
Uh oh!
There was an error while loading. Please reload this page.