Skip to content

Conversation

Copy link
Contributor

Copilot AI commented May 29, 2025

This PR adds comprehensive end-to-end tests to validate that customHeaders in TrafficManagerProfile specifications are properly propagated to Azure Traffic Manager profiles.

Changes Made

1. Updated buildDesiredATMProfile helper function

Added support for customHeaders in the test helper function to mirror the controller implementation:

// Add custom headers if specified
if len(monitorConfig.CustomHeaders) > 0 {
    customHeaders := make([]*armtrafficmanager.MonitorConfigCustomHeadersItem, 0, len(monitorConfig.CustomHeaders))
    for _, header := range monitorConfig.CustomHeaders {
        customHeaders = append(customHeaders, &armtrafficmanager.MonitorConfigCustomHeadersItem{
            Name:  ptr.To(header.Name),
            Value: ptr.To(header.Value),
        })
    }
    res.Properties.MonitorConfig.CustomHeaders = customHeaders
}

2. Added new e2e test case

Added a comprehensive test case "Updating the trafficManagerProfile with customHeaders" that validates:

  • Setting customHeaders: Tests adding custom headers to a TrafficManagerProfile and verifying they appear in the Azure Traffic Manager profile
  • Updating customHeaders: Tests modifying existing custom headers and validating the changes
  • Removing customHeaders: Tests removing all custom headers and ensuring they're cleared from the Azure profile

Test Coverage

The new test covers the complete lifecycle of customHeaders:

// Test 1: Add customHeaders
profile.Spec.MonitorConfig.CustomHeaders = []fleetnetv1beta1.MonitorConfigCustomHeader{
    {Name: "X-Custom-Header-1", Value: "custom-value-1"},
    {Name: "X-Custom-Header-2", Value: "custom-value-2"},
}
// Validate propagation to Azure Traffic Manager

// Test 2: Update customHeaders  
profile.Spec.MonitorConfig.CustomHeaders = []fleetnetv1beta1.MonitorConfigCustomHeader{
    {Name: "X-Modified-Header", Value: "modified-value"},
}
// Validate changes are applied

// Test 3: Remove customHeaders
profile.Spec.MonitorConfig.CustomHeaders = nil
// Validate headers are removed

Implementation Details

  • Follows existing test patterns and integrates seamlessly with the "Test updating trafficManagerProfile" context
  • Uses the same validation framework (atmValidator.ValidateProfile) as other tests
  • Implementation exactly mirrors the controller logic in generateAzureTrafficManagerProfile
  • Only adds 59 lines with no deletions - surgical, minimal changes

This ensures that the customHeaders feature is thoroughly tested end-to-end, validating proper propagation from Kubernetes TrafficManagerProfile resources to actual Azure Traffic Manager profiles.

Fixes #313.


E2E tests

https://github.com/Azure/fleet-networking/actions/runs/15344659627 are green

Copilot AI changed the title [WIP] add e2e tests to validate the customHeaders of the trafficManagerProfile Add e2e tests to validate customHeaders of trafficManagerProfile May 29, 2025
Copilot AI requested a review from zhiying-lin May 29, 2025 03:30
@zhiying-lin zhiying-lin changed the title Add e2e tests to validate customHeaders of trafficManagerProfile test: add e2e tests to validate customHeaders of trafficManagerProfile May 30, 2025
@zhiying-lin zhiying-lin marked this pull request as ready for review June 3, 2025 03:24
@codecov
Copy link

codecov bot commented Jun 3, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 80.58%. Comparing base (b804959) to head (9837420).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #314      +/-   ##
==========================================
- Coverage   80.61%   80.58%   -0.04%     
==========================================
  Files          29       29              
  Lines        4153     4161       +8     
==========================================
+ Hits         3348     3353       +5     
- Misses        641      643       +2     
- Partials      164      165       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor Author

Copilot AI commented Jun 3, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • http://168.63.129.16:80/machine/
    • Triggering command: /usr/bin/python3 -u bin/WALinuxAgent-2.13.1.1-py3.9.egg -collect-logs (http block)

If you need me to access, download, or install something from one of these locations, you can either:

@zhiying-lin zhiying-lin merged commit 5646fe1 into main Jun 5, 2025
20 of 25 checks passed
@zhiying-lin zhiying-lin deleted the copilot/fix-313 branch June 5, 2025 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add e2e tests to validate the customHeaders of the trafficManagerProfile

3 participants