-
Notifications
You must be signed in to change notification settings - Fork 3.8k
test: migrate string insert cases and refactor async insert tests #47110
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: master
Are you sure you want to change the base?
test: migrate string insert cases and refactor async insert tests #47110
Conversation
Signed-off-by: zilliz <[email protected]>
Summary of ChangesHello @jiamingli-maker, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request improves the test suite's organization and consistency by migrating string insertion tests to the client v2 framework and isolating asynchronous insert tests into their own module. This refactoring enhances maintainability and aligns the tests with the current client architecture. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
|
[ci-v2-notice] To rerun ci-v2 checks, comment with:
If you have any questions or requests, please contact @zhikunyao. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: jiamingli-maker The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
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.
Code Review
This pull request successfully migrates string insertion test cases to the v2 client and refactors asynchronous insertion tests into a dedicated file. The changes are well-organized and improve the test structure. I have identified a few areas for improvement, including a redundant conditional check, the use of a magic number that could be defined as a constant, and a test case with a potentially incorrect assertion regarding primary key uniqueness that requires clarification.
| self.flush(client, collection_name) | ||
| num_entities = self.get_collection_stats(client, collection_name)[0] | ||
| assert num_entities.get("row_count", None) == nb |
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.
This test asserts that after inserting nb rows with the same primary key (str_field_value), the number of entities in the collection is nb. This seems incorrect, as a primary key should be unique. After inserting multiple entities with the same primary key, only one entity (the last one) should remain, and the row count should be 1.
If this is the intended behavior of Milvus, it's quite surprising and should be documented. If not, this test might be incorrect or masking a bug in Milvus's primary key enforcement. Please verify the expected behavior for duplicate primary keys in a single insert batch.
| if field.dtype == DataType.VARCHAR: | ||
| string_values = cf.gen_string(default_nb) | ||
| for i, row in enumerate(rows): | ||
| row[field.name] = string_values[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.
The if field.dtype == DataType.VARCHAR: check is redundant because the string_fields parameter is always populated with VARCHAR fields from cf.gen_string_field. You can remove this check and un-indent the inner block to simplify the code.
string_values = cf.gen_string(default_nb)
for i, row in enumerate(rows):
row[field.name] = string_values[i]| schema = self.create_schema(client, enable_dynamic_field=False)[0] | ||
| schema.add_field(default_primary_key_field_name, DataType.INT64, is_primary=True, auto_id=False) | ||
| schema.add_field(default_vector_field_name, DataType.FLOAT_VECTOR, dim=default_dim) | ||
| schema.add_field(default_float_field_name, DataType.FLOAT) | ||
| schema.add_field(default_string_field_name, DataType.VARCHAR, max_length=65535) | ||
| self.create_collection(client, collection_name, dimension=default_dim, schema=schema) | ||
|
|
||
| # 2. Generate row data with string field exceeding max length (65535) | ||
| max_length = 65535 | ||
| rng = np.random.default_rng(seed=19530) | ||
| rows = [{default_primary_key_field_name: i, default_vector_field_name: list(rng.random((1, default_dim))[0]), | ||
| default_float_field_name: i * 1.0, default_string_field_name: str(i)} for i in range(nb)] | ||
| # Generate a string that exceeds max length | ||
| long_string = cf.gen_str_by_length(length=max_length + 1) |
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.
The value 65535 is used as a magic number in multiple places. It's better to define it as a constant variable max_length at the beginning of the test and use it throughout. This improves readability and maintainability by avoiding hardcoded values.
max_length = 65535
schema = self.create_schema(client, enable_dynamic_field=False)[0]
schema.add_field(default_primary_key_field_name, DataType.INT64, is_primary=True, auto_id=False)
schema.add_field(default_vector_field_name, DataType.FLOAT_VECTOR, dim=default_dim)
schema.add_field(default_float_field_name, DataType.FLOAT)
schema.add_field(default_string_field_name, DataType.VARCHAR, max_length=max_length)
self.create_collection(client, collection_name, dimension=default_dim, schema=schema)
# 2. Generate row data with string field exceeding max length (65535)
rng = np.random.default_rng(seed=19530)
# Generate a string that exceeds max length
long_string = cf.gen_str_by_length(length=max_length + 1)|
@jiamingli-maker go-sdk check failed, comment |
|
rerun go-sdk |
|
/ci-rerun-e2e-arm |
/kind improvement
/assign @yanliang567
PR Summary
test_milvus_client_insert_string_field_is_primarytest_milvus_client_insert_multi_string_fieldstest_milvus_client_insert_string_field_length_exceedtest_milvus_client_insert_string_field_space_emptytest_milvus_client_insert_string_field_is_pk_and_empty