-
Notifications
You must be signed in to change notification settings - Fork 58
test: add verification for filtering mcp server by source label #1285
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
tests/model_registry/mcp_servers/config/test_source_label.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| from typing import Self | ||
|
|
||
| import pytest | ||
| from simple_logger.logger import get_logger | ||
|
|
||
| from tests.model_registry.mcp_servers.constants import ( | ||
| MCP_CATALOG_SOURCE2_NAME, | ||
| MCP_CATALOG_SOURCE_NAME, | ||
| ) | ||
| from tests.model_registry.utils import execute_get_command | ||
|
|
||
| LOGGER = get_logger(name=__name__) | ||
|
|
||
|
|
||
| @pytest.mark.usefixtures("mcp_source_label_configmap_patch") | ||
| class TestMCPServerSourceLabel: | ||
| """Tests for MCP server sourceLabel filtering (TC-API-036 to TC-API-039).""" | ||
|
|
||
| @pytest.mark.smoke | ||
| def test_mcp_server_source_label( | ||
| self: Self, | ||
| mcp_catalog_rest_urls: list[str], | ||
| model_registry_rest_headers: dict[str, str], | ||
| ): | ||
| """ | ||
| Validate MCP server filtering by source label (TC-API-036, TC-API-038, TC-API-039). | ||
| """ | ||
| source1_size = execute_get_command( | ||
| url=f"{mcp_catalog_rest_urls[0]}mcp_servers", | ||
| headers=model_registry_rest_headers, | ||
| params={"sourceLabel": MCP_CATALOG_SOURCE_NAME}, | ||
| )["size"] | ||
| source2_size = execute_get_command( | ||
| url=f"{mcp_catalog_rest_urls[0]}mcp_servers", | ||
| headers=model_registry_rest_headers, | ||
| params={"sourceLabel": MCP_CATALOG_SOURCE2_NAME}, | ||
| )["size"] | ||
| null_label_size = execute_get_command( | ||
| url=f"{mcp_catalog_rest_urls[0]}mcp_servers", | ||
| headers=model_registry_rest_headers, | ||
| params={"sourceLabel": "null"}, | ||
| )["size"] | ||
| no_filtered_size = execute_get_command( | ||
| url=f"{mcp_catalog_rest_urls[0]}mcp_servers", | ||
| headers=model_registry_rest_headers, | ||
| )["size"] | ||
| both_labeled_size = execute_get_command( | ||
| url=f"{mcp_catalog_rest_urls[0]}mcp_servers", | ||
| headers=model_registry_rest_headers, | ||
| params={"sourceLabel": f"{MCP_CATALOG_SOURCE_NAME},{MCP_CATALOG_SOURCE2_NAME}"}, | ||
| )["size"] | ||
| LOGGER.info(f"no_filtered_size: {no_filtered_size}") | ||
| assert no_filtered_size > 0 | ||
| assert null_label_size >= 0 | ||
| assert source1_size + source2_size == both_labeled_size | ||
| assert no_filtered_size == both_labeled_size + null_label_size | ||
|
|
||
fege marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @pytest.mark.tier3 | ||
| def test_mcp_server_invalid_source_label( | ||
| self: Self, | ||
| mcp_catalog_rest_urls: list[str], | ||
| model_registry_rest_headers: dict[str, str], | ||
| ): | ||
| """ | ||
| Validate MCP server filtering by invalid source label (TC-API-037). | ||
| """ | ||
| invalid_size = execute_get_command( | ||
| url=f"{mcp_catalog_rest_urls[0]}mcp_servers", | ||
| headers=model_registry_rest_headers, | ||
| params={"sourceLabel": "invalid"}, | ||
| )["size"] | ||
|
|
||
| assert invalid_size == 0 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.