Skip to content
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

[Network] Fix HopLink format error issue when resourceId return "" #38876

Merged
merged 21 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sdk/network/Azure.ResourceManager.Network/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

### Bugs Fixed

- Add the new property `ResourceIdString` to replace `ResourceId` which fixed the formatting issue when `resourceId` returns an empty string.

### Other Changes

## 1.5.0 (2023-09-16)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6759,7 +6759,9 @@ public static partial class ArmNetworkModelFactory
public static Azure.ResourceManager.Network.Models.GatewayRoute GatewayRoute(string localAddress = null, string network = null, string nextHop = null, string sourcePeer = null, string origin = null, string asPath = null, int? weight = default(int?)) { throw null; }
public static Azure.ResourceManager.Network.Models.GatewayRouteListResult GatewayRouteListResult(System.Collections.Generic.IEnumerable<Azure.ResourceManager.Network.Models.GatewayRoute> value = null) { throw null; }
public static Azure.ResourceManager.Network.Models.GenerateExpressRoutePortsLoaResult GenerateExpressRoutePortsLoaResult(string encodedContent = null) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public static Azure.ResourceManager.Network.Models.HopLink HopLink(string nextHopId = null, string linkType = null, System.Collections.Generic.IEnumerable<Azure.ResourceManager.Network.Models.ConnectivityIssueInfo> issues = null, System.Collections.Generic.IReadOnlyDictionary<string, string> context = null, Azure.Core.ResourceIdentifier resourceId = null, long? roundTripTimeMin = default(long?), long? roundTripTimeAvg = default(long?), long? roundTripTimeMax = default(long?)) { throw null; }
public static Azure.ResourceManager.Network.Models.HopLink HopLink(string nextHopId = null, string linkType = null, System.Collections.Generic.IEnumerable<Azure.ResourceManager.Network.Models.ConnectivityIssueInfo> issues = null, System.Collections.Generic.IReadOnlyDictionary<string, string> context = null, string resourceIdString = null, long? roundTripTimeMin = default(long?), long? roundTripTimeAvg = default(long?), long? roundTripTimeMax = default(long?)) { throw null; }
public static Azure.ResourceManager.Network.HubIPConfigurationData HubIPConfigurationData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType? resourceType = default(Azure.Core.ResourceType?), Azure.ETag? etag = default(Azure.ETag?), string privateIPAddress = null, Azure.ResourceManager.Network.Models.NetworkIPAllocationMethod? privateIPAllocationMethod = default(Azure.ResourceManager.Network.Models.NetworkIPAllocationMethod?), Azure.ResourceManager.Network.SubnetData subnet = null, Azure.ResourceManager.Network.PublicIPAddressData publicIPAddress = null, Azure.ResourceManager.Network.Models.NetworkProvisioningState? provisioningState = default(Azure.ResourceManager.Network.Models.NetworkProvisioningState?)) { throw null; }
public static Azure.ResourceManager.Network.HubRouteTableData HubRouteTableData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType? resourceType = default(Azure.Core.ResourceType?), Azure.ETag? etag = default(Azure.ETag?), System.Collections.Generic.IEnumerable<Azure.ResourceManager.Network.Models.HubRoute> routes = null, System.Collections.Generic.IEnumerable<string> labels = null, System.Collections.Generic.IEnumerable<string> associatedConnections = null, System.Collections.Generic.IEnumerable<string> propagatingConnections = null, Azure.ResourceManager.Network.Models.NetworkProvisioningState? provisioningState = default(Azure.ResourceManager.Network.Models.NetworkProvisioningState?)) { throw null; }
public static Azure.ResourceManager.Network.HubVirtualNetworkConnectionData HubVirtualNetworkConnectionData(Azure.Core.ResourceIdentifier id = null, string name = null, Azure.Core.ResourceType? resourceType = default(Azure.Core.ResourceType?), Azure.ETag? etag = default(Azure.ETag?), Azure.Core.ResourceIdentifier remoteVirtualNetworkId = null, bool? allowHubToRemoteVnetTransit = default(bool?), bool? allowRemoteVnetToUseHubVnetGateways = default(bool?), bool? enableInternetSecurity = default(bool?), Azure.ResourceManager.Network.Models.RoutingConfiguration routingConfiguration = null, Azure.ResourceManager.Network.Models.NetworkProvisioningState? provisioningState = default(Azure.ResourceManager.Network.Models.NetworkProvisioningState?)) { throw null; }
Expand Down Expand Up @@ -9258,7 +9260,10 @@ internal HopLink() { }
public System.Collections.Generic.IReadOnlyList<Azure.ResourceManager.Network.Models.ConnectivityIssueInfo> Issues { get { throw null; } }
public string LinkType { get { throw null; } }
public string NextHopId { get { throw null; } }
public Azure.Core.ResourceIdentifier ResourceId { get { throw null; } }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
[System.ObsoleteAttribute("This property has been replaced by ResourceIdString", false)]
public Azure.Core.ResourceIdentifier ResourceId { get { throw null; } set { } }
public string ResourceIdString { get { throw null; } }
public long? RoundTripTimeAvg { get { throw null; } }
public long? RoundTripTimeMax { get { throw null; } }
public long? RoundTripTimeMin { get { throw null; } }
Expand Down
2 changes: 1 addition & 1 deletion sdk/network/Azure.ResourceManager.Network/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "net",
"TagPrefix": "net/network/Azure.ResourceManager.Network",
"Tag": "net/network/Azure.ResourceManager.Network_0050b4dbf5"
"Tag": "net/network/Azure.ResourceManager.Network_a56842b55c"
}
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,19 @@ public static SubnetData SubnetData(ResourceIdentifier id, string name, Resource
[EditorBrowsable(EditorBrowsableState.Never)]
public static VirtualNetworkGatewayData VirtualNetworkGatewayData(ResourceIdentifier id, string name, ResourceType? resourceType, AzureLocation? location, IDictionary<string, string> tags, ExtendedLocation extendedLocation, ETag? etag, IEnumerable<VirtualNetworkGatewayIPConfiguration> ipConfigurations, VirtualNetworkGatewayType? gatewayType, VpnType? vpnType, VpnGatewayGeneration? vpnGatewayGeneration, bool? enableBgp, bool? enablePrivateIPAddress, bool? active, bool? disableIPSecReplayProtection, ResourceIdentifier gatewayDefaultSiteId, VirtualNetworkGatewaySku sku, VpnClientConfiguration vpnClientConfiguration, IEnumerable<VirtualNetworkGatewayPolicyGroup> virtualNetworkGatewayPolicyGroups, BgpSettings bgpSettings, IEnumerable<string> customRoutesAddressPrefixes, Guid? resourceGuid, NetworkProvisioningState? provisioningState, bool? enableDnsForwarding, string inboundDnsForwardingEndpoint, ResourceIdentifier vNetExtendedLocationResourceId, IEnumerable<VirtualNetworkGatewayNatRuleData> natRules, bool? enableBgpRouteTranslationForNat, bool? allowVirtualWanTraffic, bool? allowRemoteVnetTraffic, ExpressRouteGatewayAdminState? adminState)
=> VirtualNetworkGatewayData(id, name, resourceType, location, tags, extendedLocation, etag, null, ipConfigurations, gatewayType, vpnType, vpnGatewayGeneration, enableBgp, enablePrivateIPAddress, active, disableIPSecReplayProtection, gatewayDefaultSiteId, sku, vpnClientConfiguration, virtualNetworkGatewayPolicyGroups, bgpSettings, customRoutesAddressPrefixes, resourceGuid, provisioningState, enableDnsForwarding, inboundDnsForwardingEndpoint, vNetExtendedLocationResourceId, natRules, enableBgpRouteTranslationForNat, allowVirtualWanTraffic, allowRemoteVnetTraffic, adminState);

/// <summary> Initializes a new instance of HopLink. </summary>
/// <param name="nextHopId"> The ID of the next hop. </param>
/// <param name="linkType"> Link type. </param>
/// <param name="issues"> List of issues. </param>
/// <param name="context"> Provides additional context on links. </param>
/// <param name="resourceId"> Resource ID. </param>
/// <param name="roundTripTimeMin"> Minimum roundtrip time in milliseconds. </param>
/// <param name="roundTripTimeAvg"> Average roundtrip time in milliseconds. </param>
/// <param name="roundTripTimeMax"> Maximum roundtrip time in milliseconds. </param>
/// <returns> A new <see cref="Models.HopLink"/> instance for mocking. </returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public static HopLink HopLink(string nextHopId = null, string linkType = null, IEnumerable<ConnectivityIssueInfo> issues = null, IReadOnlyDictionary<string, string> context = null, ResourceIdentifier resourceId = null, long? roundTripTimeMin = null, long? roundTripTimeAvg = null, long? roundTripTimeMax = null)
dvbb marked this conversation as resolved.
Show resolved Hide resolved
=> HopLink(nextHopId, linkType, issues, context, null, roundTripTimeMin, roundTripTimeAvg, roundTripTimeMax);
dvbb marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using Azure.Core;

namespace Azure.ResourceManager.Network.Models
{
/// <summary> Hop link. </summary>
public partial class HopLink
{
/// <summary> Resource ID. </summary>
[EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("This property has been replaced by ResourceIdString", false)]
public ResourceIdentifier ResourceId {
get => ResourceId;
dvbb marked this conversation as resolved.
Show resolved Hide resolved
set
{
ResourceId = value;
dvbb marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ rename-mapping:
SyncMode: BackendAddressSyncMode
MigratedPools: MigrateLoadBalancerToIPBasedResult
IPRule: BastionHostIPRule
HopLink.resourceId: ResourceIdString

keep-plural-resource-data:
- PolicySignaturesOverridesForIdps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected async Task<ResourceGroupResource> CreateResourceGroup(string name)
SubscriptionResource subscription = await ArmClient.GetDefaultSubscriptionAsync();
return (await subscription.GetResourceGroups().CreateOrUpdateAsync(WaitUntil.Completed, name, new ResourceGroupData(TestEnvironment.Location))).Value;
}
protected async Task<ResourceGroupResource> CreateResourceGroup(string name,string location)
protected async Task<ResourceGroupResource> CreateResourceGroup(string name, string location)
{
SubscriptionResource subscription = await ArmClient.GetDefaultSubscriptionAsync();
return (await subscription.GetResourceGroups().CreateOrUpdateAsync(WaitUntil.Completed, name, new ResourceGroupData(location))).Value;
Expand Down Expand Up @@ -261,7 +261,7 @@ public async Task<GenericResource> CreateWindowsVM(string vmName, string network

var vmId = new ResourceIdentifier($"{resourceGroup.Id}/providers/Microsoft.Compute/virtualMachines/{vmName}");
SubscriptionResource subscription = await ArmClient.GetDefaultSubscriptionAsync();
var genericResouces = subscription.GetGenericResources();
var genericResouces = subscription.GetGenericResourcesAsync();
GenericResourceData data = new GenericResourceData(location)
{
Properties = BinaryData.FromObjectAsJson(new Dictionary<string, object>
Expand Down Expand Up @@ -299,7 +299,7 @@ public async Task<GenericResource> CreateWindowsVM(string vmName, string network
{ "osProfile", new Dictionary<string, object>
{
{ "adminUsername", Recording.GenerateAssetName("admin") },
{ "adminPassword", Recording.GenerateAlphaNumericId("adminPass") },
{ "adminPassword", Recording.GenerateAlphaNumericId("adminPass!") },
{ "computerName", vmName }
}
},
Expand Down Expand Up @@ -632,7 +632,7 @@ public async Task<NetworkInterfaceResource> CreateNetworkInterface(string name,
return getNicResponse;
}

public async Task<NetworkInterfaceResource> CreateNetworkInterface(string name, string publicIpAddressId, string subnetId,
public async Task<NetworkInterfaceResource> CreateNetworkInterface(string name, string publicIpAddressId, string subnetId,
string location, string ipConfigName, NetworkInterfaceCollection networkInterfaceCollection)
{
var nicParameters = new NetworkInterfaceData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Azure.ResourceManager.Network.Models;
using Azure.ResourceManager.Network.Tests.Helpers;
using NUnit.Framework;
using Azure.Core;

namespace Azure.ResourceManager.Network.Tests
{
Expand Down Expand Up @@ -111,5 +112,35 @@ public async Task NetworkWatcherApiTest()
Assert.AreEqual(countBeforeTest, listAllAfterDeletingResponse.Count);
Assert.False(listAllAfterDeletingResponse.Any(w => w.Data.Name == networkWatcherName));
}

[Test]
[RecordedTest]
public async Task NetworkWatcherCheckConnectivityTest()
{
var location = AzureLocation.EastUS2;

string rgName = Recording.GenerateAssetName("networkRG");
var resourceGroup = await CreateResourceGroup(rgName, location);

// Create Network Watcher in the resource group
string networkWatcherName = Recording.GenerateAssetName("azsmnet");
var properties = new NetworkWatcherData { Location = location };
var networkWatcherLro = await resourceGroup.GetNetworkWatchers().CreateOrUpdateAsync(WaitUntil.Completed, networkWatcherName, properties);
NetworkWatcherResource networkWatcher = networkWatcherLro.Value;

// Create two VMs for test vm connectivity
var vm1 = await CreateWindowsVM(Recording.GenerateAssetName("vm"), Recording.GenerateAssetName("nic"), location, resourceGroup);
var vm2 = await CreateWindowsVM(Recording.GenerateAssetName("vm"), Recording.GenerateAssetName("nic"), location, resourceGroup);
await deployWindowsNetworkAgent(vm1.Data.Name, location, resourceGroup);
await deployWindowsNetworkAgent(vm2.Data.Name, location, resourceGroup);

// Test connectivity
ConnectivityContent content = new ConnectivityContent(
new ConnectivitySource(vm1.Id),
new ConnectivityDestination() { Port = 22, ResourceId = vm2.Id });
var connectivityResult = await networkWatcher.CheckConnectivityAsync(WaitUntil.Completed, content);
Assert.IsNotNull(connectivityResult.Value.NetworkConnectionStatus);
Assert.IsEmpty(connectivityResult.Value.Hops.First().Links.First().ResourceIdString);
}
}
}