Skip to content

Conversation

@alzimmermsft
Copy link
Contributor

What does this PR do?

Migrates Cosmos to recorded live tests.

GitHub issue number?

Resolves #1282

Pre-merge Checklist

  • Required for All PRs
    • Read contribution guidelines
    • PR title clearly describes the change
    • Commit history is clean with descriptive messages (cleanup guide)
    • Added comprehensive tests for new/modified functionality
    • Updated servers/Azure.Mcp.Server/CHANGELOG.md and/or servers/Fabric.Mcp.Server/CHANGELOG.md for product changes (features, bug fixes, UI/UX, updated dependencies)
  • For MCP tool changes:
    • One tool per PR: This PR adds or modifies only one MCP tool for faster review cycles
    • Updated servers/Azure.Mcp.Server/README.md and/or servers/Fabric.Mcp.Server/README.md documentation
    • Validate README.md changes using script at eng/scripts/Process-PackageReadMe.ps1. See Package README
    • Updated command list in /servers/Azure.Mcp.Server/docs/azmcp-commands.md and/or /docs/fabric-commands.md
    • Run .\eng\scripts\Update-AzCommandsMetadata.ps1 to update tool metadata in azmcp-commands.md (required for CI)
    • For new or modified tool descriptions, ran ToolDescriptionEvaluator and obtained a score of 0.4 or more and a top 3 ranking for all related test prompts
    • For tools with new names, including new tools or renamed tools, update consolidated-tools.json
    • For new tools associated with Azure services or publicly available tools/APIs/products, add URL to documentation in the PR description
  • Extra steps for Azure MCP Server tool changes:
    • Updated test prompts in /servers/Azure.Mcp.Server/docs/e2eTestPrompts.md
    • 👉 For Community (non-Microsoft team member) PRs:
      • Security review: Reviewed code for security vulnerabilities, malicious code, or suspicious activities before running tests (crypto mining, spam, data exfiltration, etc.)
      • Manual tests run: added comment /azp run mcp - pullrequest - live to run Live Test Pipeline

@scbedd
Copy link
Contributor

scbedd commented Dec 18, 2025

/azp run mcp - pullrequest

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@scbedd scbedd marked this pull request as ready for review December 19, 2025 23:20
@scbedd scbedd requested a review from xiangyan99 as a code owner December 19, 2025 23:20
Copilot AI review requested due to automatic review settings December 19, 2025 23:20
@scbedd scbedd requested review from a team as code owners December 19, 2025 23:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates Cosmos tool tests from live-only tests to recorded tests, enabling faster test execution during playback and reducing dependency on live Azure resources.

  • Migrated CosmosCommandTests to inherit from RecordedCommandTestsBase instead of CommandTestsBase
  • Injected IHttpClientFactory into CosmosService to enable HTTP request recording/playback
  • Added RecordingOptions support to the base test infrastructure for configuring test proxy behavior

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tools/Azure.Mcp.Tools.Cosmos/tests/Azure.Mcp.Tools.Cosmos.LiveTests/assets.json New assets.json file created for test proxy configuration with the appropriate TagPrefix for Cosmos LiveTests
tools/Azure.Mcp.Tools.Cosmos/tests/Azure.Mcp.Tools.Cosmos.LiveTests/CosmosDbFixture.cs Removed the fixture class as it's no longer needed with recorded tests - test data will come from recordings
tools/Azure.Mcp.Tools.Cosmos/tests/Azure.Mcp.Tools.Cosmos.LiveTests/CosmosCommandTests.cs Migrated to RecordedCommandTestsBase, added sanitizers and matcher configuration, implemented variable registration for deterministic playback
tools/Azure.Mcp.Tools.Cosmos/src/Services/CosmosService.cs Injected IHttpClientFactory and configured CosmosClient to use it for HTTP requests, enabling recording/playback
core/Azure.Mcp.Core/tests/Azure.Mcp.Tests/Client/RecordedCommandTestsBase.cs Added RecordingOptions property and SetRecordingOptions method to support per-test recording configuration; simplified sanitizer initialization

Comment on lines +21 to +23
/// 3493 = $..name
/// </summary>
public override List<string> DisabledDefaultSanitizers => [.. base.DisabledDefaultSanitizers, "3493"];
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sanitizer ID should be "AZSDK3493" instead of "3493". All other tools in the codebase consistently use the "AZSDK" prefix for this sanitizer (e.g., AcrCommandTests, AppConfigCommandTests, QuotaCommandTests, SearchCommandTests, SqlCommandTests, SignalRCommandTests).

Suggested change
/// 3493 = $..name
/// </summary>
public override List<string> DisabledDefaultSanitizers => [.. base.DisabledDefaultSanitizers, "3493"];
/// AZSDK3493 = $..name
/// </summary>
public override List<string> DisabledDefaultSanitizers => [.. base.DisabledDefaultSanitizers, "AZSDK3493"];

Copilot uses AI. Check for mistakes.
{ "database", dbName! },
{ "account", resourceBaseName },
{ "database", dbName },
{ "container", containerName! }
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The null-forgiving operator (!) is unnecessary here. The variable 'containerName' is declared as a non-nullable string, and there's an assertion on line 152 that verifies it's not null or empty. The null-forgiving operator should be removed for cleaner code.

Suggested change
{ "container", containerName! }
{ "container", containerName }

Copilot uses AI. Check for mistakes.
Comment on lines +21 to +23
/// 3493 = $..name
/// </summary>
public override List<string> DisabledDefaultSanitizers => [.. base.DisabledDefaultSanitizers, "3493"];
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment should reference "AZSDK3493" instead of "3493" to match the correct sanitizer ID. This is consistent with how other tools document this sanitizer (e.g., "AZSDK3493 = $..name" in AcrCommandTests, AppConfigCommandTests, QuotaCommandTests, etc.).

Suggested change
/// 3493 = $..name
/// </summary>
public override List<string> DisabledDefaultSanitizers => [.. base.DisabledDefaultSanitizers, "3493"];
/// AZSDK3493 = $..name
/// </summary>
public override List<string> DisabledDefaultSanitizers => [.. base.DisabledDefaultSanitizers, "AZSDK3493"];

Copilot uses AI. Check for mistakes.
@scbedd
Copy link
Contributor

scbedd commented Dec 19, 2025

Followup filed #1421

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

Migrate Azure.Mcp.Tools.Cosmos.LiveTests LiveTests to Recorded Tests

2 participants