Skip to content

Adding L1 tests for host node selection#5456

Open
rishabhmalikMS wants to merge 7 commits intomasterfrom
users/rishabhmalik/L1Tests
Open

Adding L1 tests for host node selection#5456
rishabhmalikMS wants to merge 7 commits intomasterfrom
users/rishabhmalik/L1Tests

Conversation

@rishabhmalikMS
Copy link
Copy Markdown
Contributor

@rishabhmalikMS rishabhmalikMS commented Jan 21, 2026

Context

This PR addresses L1 testing for Azure Pipelines Agent host-based node version selection. The existing test infrastructure was lacked to validate both strategy mode (new) and legacy mode node selection behaviors for Node.js task execution.


Description

  • Enhanced Host Node Selection L1 Tests: Fixed and improved NodeSelectionL1Tests.cs to support both strategy mode and legacy mode validation with proper logging pattern detection
  • Dual-Mode Testing Support: Tests now properly validate both AGENT_USE_NODE_STRATEGY=true (strategy mode) and false (legacy mode) behaviors
  • Cross-Platform Compatibility: Tests handle Windows (PowerShell), Linux, and macOS execution environments with appropriate platform-specific test skipping
  • Robust Logging Validation: Improved test helpers to detect different logging patterns between strategy and legacy modes
  • Comprehensive Test Coverage: 6 test scenarios covering environment knobs, default behavior, conflicting knobs, and glibc compatibility

Risk Assessment (Low)

Low Risk - This PR only adds and enhances test infrastructure without modifying production agent logic. The changes are isolated to the test suite (src/Test/L1/Worker/) and improve validation coverage of existing node selection functionality. No runtime behavior changes for end users.


Unit Tests Added or Updated (Yes / No)

Unit tests (L0 tests) were already added in previous PR.


Additional Testing Performed

List manual or automated tests performed beyond unit tests (e.g., integration, scenario, regression).


Change Behind Feature Flag (Yes / No)

No - These are test infrastructure improvements only.


Tech Design / Approach

  • Design has been written and reviewed.
  • Any architectural decisions, trade-offs, and alternatives are captured.

Documentation Changes Required (Yes/No)

Indicate whether related documentation needs to be updated.

  • User guides, API specs, system diagrams, or runbooks are updated.

Logging Added/Updated (Yes/No)

  • Appropriate log statements are added with meaningful messages.
  • Logging does not expose sensitive data.
  • Log levels are used correctly (e.g., info, warn, error).

Telemetry Added/Updated (Yes/No)

  • Custom telemetry (e.g., counters, timers, error tracking) is added as needed.
  • Events are tagged with proper metadata for filtering and analysis.
  • Telemetry is validated in staging or test environments.

Rollback Scenario and Process (Yes/No)

  • Rollback plan is documented.

Dependency Impact Assessed and Regression Tested (Yes/No)

  • All impacted internal modules, APIs, services, and third-party libraries are analyzed.
  • Results are reviewed and confirmed to not break existing functionality.

@rishabhmalikMS
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@rishabhmalikMS rishabhmalikMS marked this pull request as ready for review January 22, 2026 04:18
@rishabhmalikMS rishabhmalikMS requested review from a team as code owners January 22, 2026 04:18
@rishabhmalikMS
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@rishabhmalikMS
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

…ives

- Remove AssertTaskResult method that incorrectly allowed strategy mode failures
- Update both legacy and strategy modes to expect success with proper error handling
- Simplify assertions by removing unnecessary TaskResult.Succeeded conditions
- Make test validation straightforward without conditional logic weaknesses
- Address PR feedback on log-based testing approach and assertion reliability
Both modes now properly assert success, making tests meaningful validation
of actual node selection behavior in L1 integration scenarios.
@rishabhmalikMS
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@rishabhmalikMS
Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

if (useStrategy)
{
// Strategy mode: Verify orchestrator was invoked
hasNodeSelection = log.Any(x => x.Contains("[Host] Selected Node version:") && x.Contains("(Strategy:")) ||
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this approach relies on log based testing, for new strategy patterns we are sending telemetry and that is already mocked in L1

public class FakeCustomerIntelligenceServer : AgentService, ICustomerIntelligenceServer

we can check moving strategy based test cases to telemetry testing as logs are brittle and can break test in future

hasNodeSelection = log.Any(x => x.Contains(NODE_SELECTION_LOG_PATTERN));
}

Assert.True(hasNodeSelection, $"Node selection process should be initiated: {modeDescription}");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The strategy branch accepts 4 patterns with || — if the orchestrator emits only the legacy pattern "Using node path:", the test still passes, silently masking a regression where strategy mode fell back to legacy

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants