Skip to content

Skip ResourceHealth tests that depend on Azure CLI profile absence#2560

Merged
chidozieononiwu merged 2 commits into
microsoft:mainfrom
chidozieononiwu:SkipResourceHealthTests
May 11, 2026
Merged

Skip ResourceHealth tests that depend on Azure CLI profile absence#2560
chidozieononiwu merged 2 commits into
microsoft:mainfrom
chidozieononiwu:SkipResourceHealthTests

Conversation

@chidozieononiwu
Copy link
Copy Markdown
Member

@chidozieononiwu chidozieononiwu commented May 1, 2026

What does this PR do?

Skip ResourceHealth tests that depend on Azure CLI profile absence when the profile is present

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
    • Created a changelog entry if the change falls among the following: new feature, bug fix, UI/UX update, breaking change, or updated dependencies. Follow the changelog entry guide
  • 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 running the script ./eng/scripts/Process-PackageReadMe.ps1. See Package README
    • 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 renamed tools, follow the Tool Rename Checklist and tag the PR with the breaking-change label
    • 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 command list in servers/Azure.Mcp.Server/docs/azmcp-commands.md
    • Ran ./eng/scripts/Update-AzCommandsMetadata.ps1 to update tool metadata in azmcp-commands.md (required for CI)
    • 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

Copy link
Copy Markdown
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 updates Azure ResourceHealth unit tests to avoid failing in environments where an Azure CLI default subscription (or other default subscription source) is available, by conditionally skipping validation cases that expect missing --subscription to fail.

Changes:

  • Added conditional Assert.SkipWhen(...) logic to subscription-missing validation scenarios.
  • Introduced CommandHelper.GetDefaultSubscription() checks in ResourceHealth unit tests to detect presence of a default subscription.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tools/Azure.Mcp.Tools.ResourceHealth/tests/Azure.Mcp.Tools.ResourceHealth.UnitTests/ServiceHealthEvents/ServiceHealthEventsListCommandTests.cs Skips the “missing subscription” validation when a default subscription is available.
tools/Azure.Mcp.Tools.ResourceHealth/tests/Azure.Mcp.Tools.ResourceHealth.UnitTests/AvailabilityStatus/AvailabilityStatusGetCommandTests.cs Skips the “missing subscription” validation when a default subscription is available; adds related usings.
Comments suppressed due to low confidence (1)

tools/Azure.Mcp.Tools.ResourceHealth/tests/Azure.Mcp.Tools.ResourceHealth.UnitTests/AvailabilityStatus/AvailabilityStatusGetCommandTests.cs:11

  • using Microsoft.Mcp.Tests.Helpers; is not used anywhere in this test file. With warnings treated as errors in this repo, this will fail the build—please remove the unused using (or use the type you intended to reference).
using Microsoft.Mcp.Core.Helpers;
using Microsoft.Mcp.Core.Options;
using Microsoft.Mcp.Tests.Client;
using NSubstitute;
using NSubstitute.ExceptionExtensions;

Copy link
Copy Markdown
Contributor

@jongio jongio left a comment

Choose a reason for hiding this comment

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

Straightforward fix. The Assert.SkipWhen usage aligns with existing test patterns in the repo. The skip condition correctly fires only when CommandHelper.GetDefaultSubscription() returns a value, meaning the missing-subscription validation path is unreachable.

In ServiceHealthEventsListCommandTests, the !shouldSucceed && string.IsNullOrWhiteSpace(args) guard correctly targets only the empty-args case - the ("--subscription sub123", false) path tests missing --filter, not missing subscription, so it isn't affected.

No issues found. CI is still running.

Copy link
Copy Markdown
Contributor

@alzimmermsft alzimmermsft left a comment

Choose a reason for hiding this comment

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

Not the biggest fan of this change as it's just hiding a larger problem where we can't inject and substitute environment subscription retrieval in tests.

If we are going to make a change to skip these in this circumstance for now, can we make this a shared method in Microsot.Mcp.Tests so that when we do fix the larger problem we can delete / update the handling in one central spot.

@chidozieononiwu chidozieononiwu force-pushed the SkipResourceHealthTests branch from a328258 to 4d3dd0c Compare May 4, 2026 21:48
@chidozieononiwu chidozieononiwu requested a review from a team as a code owner May 4, 2026 21:48
Copy link
Copy Markdown
Contributor

@jongio jongio left a comment

Choose a reason for hiding this comment

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

Rebased cleanly. The refactoring to TestEnvironment.SkipIfDefaultSubscriptionConfigured() is a good improvement over inline Assert.SkipWhen - centralizes the logic and provides a clear skip message. No issues.

@chidozieononiwu chidozieononiwu self-assigned this May 7, 2026
@chidozieononiwu chidozieononiwu moved this from 🤔 Triage to 🔬 Dev in PR in Azure SDK EngSys 🚀🌒🧑‍🚀 May 7, 2026
@chidozieononiwu chidozieononiwu merged commit 7bad19a into microsoft:main May 11, 2026
16 checks passed
@github-project-automation github-project-automation Bot moved this from Untriaged to Done in Azure MCP Server May 11, 2026
@kurtzeborn kurtzeborn moved this from 🔬 Dev in PR to 🎊 Closed in Azure SDK EngSys 🚀🌒🧑‍🚀 May 12, 2026
srinuthati78 pushed a commit to srinuthati78/mcp that referenced this pull request May 18, 2026
…icrosoft#2560)

* Skip ResourceHealth tests that depend on Azure CLI profile absence when the profile is present

* Move SkipIfDefaultSubscriptionConfigured to shared location TestEnvironment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants