Skip to content

Commit

Permalink
Release 1.19 bugfixes (#573)
Browse files Browse the repository at this point in the history
* Fixed null ref exception in WebApps.

* Fixing other bool cast issues in WebApps.

* Fixed CosmosDB internal mapping issue.

* Fixed build breaks and upgraded CR to the latest.
  • Loading branch information
hovsepm authored Jan 22, 2019
1 parent 5517338 commit b07f68c
Show file tree
Hide file tree
Showing 10 changed files with 5,163 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Samples/Samples.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.KeyVault" Version="3.0.1" />
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.17" />
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.18" />
<PackageReference Include="CoreFTP" Version="1.2.0" />
<PackageReference Include="Microsoft.Azure.ServiceBus" Version="0.0.2-preview" />
<PackageReference Include="SSH.NET" Version="2016.0.0" />
Expand Down
5 changes: 4 additions & 1 deletion Tests/AzSdk.test.reference.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetPathOfFileAbove('test.props'))" />
<ItemGroup>
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication" Version="2.3.4" />
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication" Version="2.3.6" />
<PackageReference Include="Microsoft.Azure.Test.HttpRecorder" Version="1.12.0" />
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure.TestFramework" Version="1.7.4" />
<PackageReference Include="SSH.NET" Version="2016.0.0" />
Expand All @@ -11,4 +11,7 @@
<!-- This is needed for discovering tests in test explorer -->
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
</ItemGroup>
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0</TargetFrameworks>
</PropertyGroup>
</Project>
59 changes: 59 additions & 0 deletions Tests/Fluent.Tests/CosmosDB/CosmosDBTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Fluent.Tests.Common;
using Microsoft.Azure.Management.CosmosDB.Fluent;
using Microsoft.Azure.Management.CosmosDB.Fluent.Models;
using Microsoft.Azure.Management.Network.Fluent.Models;
using Microsoft.Azure.Management.ResourceManager.Fluent.Core;
using Microsoft.Rest.ClientRuntime.Azure.TestFramework;
using Xunit;
Expand Down Expand Up @@ -70,5 +71,63 @@ public void CosmosDBCRUD()

}
}


[Fact]
public void CosmosDBBugfix()
{
using (var context = FluentMockContext.Start(GetType().FullName))
{
var dbName = TestUtilities.GenerateName("db");
var saName = TestUtilities.GenerateName("dbsa");
var rgName = TestUtilities.GenerateName("ddbRg");
var manager = TestHelper.CreateCosmosDB();
var resourceManager = TestHelper.CreateResourceManager();
ICosmosDBAccount databaseAccount = null;
var azure = TestHelper.CreateRollupClient();

try
{
databaseAccount = manager.CosmosDBAccounts.Define(dbName)
.WithRegion(Region.USWest)
.WithNewResourceGroup(rgName)
.WithKind(DatabaseAccountKind.GlobalDocumentDB)
.WithSessionConsistency()
.WithWriteReplication(Region.USWest)
.WithReadReplication(Region.USCentral)
.WithIpRangeFilter("")
.Create();

// BUGFIX
var vn = azure.Networks.Define(dbName)
.WithRegion(Region.USWest)
.WithNewResourceGroup(rgName)
.WithAddressSpace("192.168.0.0/16")
.DefineSubnet("subnet1")
.WithAddressPrefix("192.168.1.0/24")
.WithAccessFromService(ServiceEndpointType.MicrosoftAzureCosmosDB)
.Attach()
.DefineSubnet("subnet2")
.WithAddressPrefix("192.168.2.0/24")
.WithAccessFromService(ServiceEndpointType.MicrosoftAzureCosmosDB)
.Attach()
.Create();


databaseAccount.Update().WithVirtualNetwork(vn.Id, "Subnet1").Apply();
databaseAccount.Update().WithVirtualNetwork(vn.Id, "Subnet1").Apply();
databaseAccount.Update().WithVirtualNetwork(vn.Id, "Subnet1").Apply();
// END of BUGFIX
}
finally
{
try
{
resourceManager.ResourceGroups.BeginDeleteByName(rgName);
}
catch { }
}
}
}
}
}
5,066 changes: 5,066 additions & 0 deletions Tests/Fluent.Tests/SessionRecords/Fluent.Tests.CosmosDB/CosmosDBBugfix.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/AzSdk.reference.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$([MSBuild]::GetPathOfFileAbove('AzSdk.props'))" />
<ItemGroup>
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="[2.3.17, 3.0.0)" />
<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="[2.3.18, 3.0.0)" />
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure" Version="[3.3.18, 4.0.0)" />
</ItemGroup>

Expand Down
6 changes: 3 additions & 3 deletions src/ResourceManagement/AppService/WebAppBaseImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ internal SiteConfigResourceInner SiteConfig
}
}

public bool HttpsOnly => (bool) Inner.HttpsOnly;
public bool HttpsOnly => Inner.HttpsOnly ?? false;

public FtpsState FtpsState => SiteConfig?.FtpsState;

public IList<VirtualApplication> VirtualApplications => SiteConfig?.VirtualApplications;

public bool Http20Enabled => (bool)SiteConfig?.Http20Enabled;
public bool Http20Enabled => (SiteConfig == null || SiteConfig.Http20Enabled == null) ? false : SiteConfig.Http20Enabled.Value;

public bool LocalMySqlEnabled => (bool)SiteConfig?.LocalMySqlEnabled;
public bool LocalMySqlEnabled => (SiteConfig == null || SiteConfig.LocalMySqlEnabled == null) ? false : SiteConfig.LocalMySqlEnabled.Value;

public ScmType ScmType => SiteConfig?.ScmType;

Expand Down
14 changes: 7 additions & 7 deletions src/ResourceManagement/AppService/WebAppDiagnosticLogsImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ public FluentImplT Attach()
///GENMHASH:A6C3024A0F426DA6CF8B71DEF91E0C7E:9FE8762C1B9FACF15AB88DA1BF9597EC
public bool DetailedErrorMessages()
{
return Inner.DetailedErrorMessages != null && (bool) Inner.DetailedErrorMessages.Enabled;
return Inner.DetailedErrorMessages != null && Inner.DetailedErrorMessages.Enabled.HasValue && Inner.DetailedErrorMessages.Enabled.Value;
}

///GENMHASH:34AF806990F25131F59A6070440823E0:A95CC561E4445BE3E7269A572A6BFCB2
public bool FailedRequestsTracing()
{
return Inner.FailedRequestsTracing != null && (bool) Inner.FailedRequestsTracing.Enabled;
return Inner.FailedRequestsTracing != null && Inner.FailedRequestsTracing.Enabled.HasValue && Inner.FailedRequestsTracing.Enabled.Value;
}

///GENMHASH:ADA7023132C677B8E810845941E988DA:1964CEE67CCBAFF2114B8BBEF6D87DFA
Expand Down Expand Up @@ -235,11 +235,11 @@ public WebAppDiagnosticLogsImpl<FluentT, FluentImplT, DefAfterRegionT, DefAfterG
///GENMHASH:27B58505EB32F2C2A1069A5602161EB9:31DDB75D31D02F6E8C830CE7A9E778D3
public WebAppDiagnosticLogsImpl<FluentT, FluentImplT, DefAfterRegionT, DefAfterGroupT, UpdateT> WithLogRetentionDays(int retentionDays)
{
if (Inner.HttpLogs != null && Inner.HttpLogs.FileSystem != null && (bool) Inner.HttpLogs.FileSystem.Enabled)
if (Inner.HttpLogs != null && Inner.HttpLogs.FileSystem != null && Inner.HttpLogs.FileSystem.Enabled.HasValue && Inner.HttpLogs.FileSystem.Enabled.Value)
{
Inner.HttpLogs.FileSystem.RetentionInDays = retentionDays;
}
if (Inner.HttpLogs != null && Inner.HttpLogs.AzureBlobStorage != null && (bool)Inner.HttpLogs.AzureBlobStorage.Enabled)
if (Inner.HttpLogs != null && Inner.HttpLogs.AzureBlobStorage != null && Inner.HttpLogs.AzureBlobStorage.Enabled.HasValue && Inner.HttpLogs.AzureBlobStorage.Enabled.Value)
{
Inner.HttpLogs.AzureBlobStorage.RetentionInDays = retentionDays;
}
Expand Down Expand Up @@ -305,11 +305,11 @@ public WebAppDiagnosticLogsImpl<FluentT, FluentImplT, DefAfterRegionT, DefAfterG
///GENMHASH:0AA703FD4D7171D9DD761057420590D4:57E8D27F0D0112D8FDF8632C55262083
public WebAppDiagnosticLogsImpl<FluentT, FluentImplT, DefAfterRegionT, DefAfterGroupT, UpdateT> WithUnlimitedLogRetentionDays()
{
if (Inner.HttpLogs != null && Inner.HttpLogs.FileSystem != null && (bool) Inner.HttpLogs.FileSystem.Enabled)
if (Inner.HttpLogs != null && Inner.HttpLogs.FileSystem != null && Inner.HttpLogs.FileSystem.Enabled.HasValue && Inner.HttpLogs.FileSystem.Enabled.Value)
{
Inner.HttpLogs.FileSystem.RetentionInDays = 0;
}
if (Inner.HttpLogs != null && Inner.HttpLogs.AzureBlobStorage != null && (bool) Inner.HttpLogs.FileSystem.Enabled)
if (Inner.HttpLogs != null && Inner.HttpLogs.AzureBlobStorage != null && Inner.HttpLogs.FileSystem.Enabled.HasValue && Inner.HttpLogs.FileSystem.Enabled.Value)
{
Inner.HttpLogs.AzureBlobStorage.RetentionInDays = 0;
}
Expand All @@ -319,7 +319,7 @@ public WebAppDiagnosticLogsImpl<FluentT, FluentImplT, DefAfterRegionT, DefAfterG
///GENMHASH:6779E4B38BCBB810944CA68774B310C3:072E24F1A9FC72304BBE1ED245652D70
public WebAppDiagnosticLogsImpl<FluentT, FluentImplT, DefAfterRegionT, DefAfterGroupT, UpdateT> WithWebServerFileSystemQuotaInMB(int quotaInMB)
{
if (Inner.HttpLogs != null && Inner.HttpLogs.FileSystem != null && (bool) Inner.HttpLogs.FileSystem.Enabled)
if (Inner.HttpLogs != null && Inner.HttpLogs.FileSystem != null && Inner.HttpLogs.FileSystem.Enabled.HasValue && Inner.HttpLogs.FileSystem.Enabled.Value)
{
Inner.HttpLogs.FileSystem.RetentionInMb = quotaInMB;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ internal WebAppSourceControlImpl(
{
return null;
}
return (bool) Inner.IsMercurial ? Fluent.RepositoryType.Mercurial : Fluent.RepositoryType.Git;
return (Inner.IsMercurial.HasValue && Inner.IsMercurial .Value) ? Fluent.RepositoryType.Mercurial : Fluent.RepositoryType.Git;
}

///GENMHASH:AF58AEB1DD43D38B7FEDF266F4F40886:63F15AB00FF6315055DD4FFBCA6BE2EC
Expand Down
27 changes: 20 additions & 7 deletions src/ResourceManagement/CosmosDB/CosmosDBAccountImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public partial class CosmosDBAccountImpl :
private IList<Microsoft.Azure.Management.CosmosDB.Fluent.Models.FailoverPolicyInner> failoverPolicies;
private bool hasFailoverPolicyChanges;
private const int maxDelayDueToMissingFailovers = 5000 * 12 * 10;
private Dictionary<string,Models.VirtualNetworkRule> virtualNetworkRulesMap;
private Dictionary<string,List<Models.VirtualNetworkRule>> virtualNetworkRulesMap;

public CosmosDBAccountImpl WithReadReplication(Region region)
{
Expand Down Expand Up @@ -108,7 +108,7 @@ private Models.DatabaseAccountCreateUpdateParametersInner CreateUpdateParameters
createUpdateParametersInner.IsVirtualNetworkFilterEnabled = inner.IsVirtualNetworkFilterEnabled;
if (virtualNetworkRulesMap != null)
{
createUpdateParametersInner.VirtualNetworkRules = virtualNetworkRulesMap.Values.ToList();
createUpdateParametersInner.VirtualNetworkRules = virtualNetworkRulesMap.Values.SelectMany(l => l).ToList();
virtualNetworkRulesMap = null;
}
this.AddLocationsForCreateUpdateParameters(createUpdateParametersInner, this.failoverPolicies);
Expand Down Expand Up @@ -470,7 +470,12 @@ public CosmosDBAccountImpl WithVirtualNetwork(string virtualNetworkId, string su
{
this.Inner.IsVirtualNetworkFilterEnabled = true;
string vnetId = virtualNetworkId + "/subnets/" + subnetName;
EnsureVirtualNetworkRules().Add(vnetId, new VirtualNetworkRule() { Id = vnetId });
var internalMap = EnsureVirtualNetworkRules();
if(!internalMap.ContainsKey(vnetId))
{
internalMap.Add(vnetId, new List<VirtualNetworkRule>());
}
internalMap[vnetId].Add(new VirtualNetworkRule() { Id = vnetId });
return this;
}

Expand All @@ -488,7 +493,11 @@ public CosmosDBAccountImpl WithVirtualNetworkRules(IList<Models.VirtualNetworkRu
this.Inner.IsVirtualNetworkFilterEnabled = true;
foreach (var vnetRule in virtualNetworkRules)
{
this.virtualNetworkRulesMap.Add(vnetRule.Id, vnetRule);
if(!this.virtualNetworkRulesMap.ContainsKey(vnetRule.Id))
{
this.virtualNetworkRulesMap.Add(vnetRule.Id, new List<VirtualNetworkRule>());
}
this.virtualNetworkRulesMap[vnetRule.Id].Add(vnetRule);
}
}
return this;
Expand All @@ -514,16 +523,20 @@ public CosmosDBAccountImpl WithoutVirtualNetwork(string virtualNetworkId, string
}

///GENMHASH:9DD08936D3B4E402E37AEF19676FBBE5:B75CF3B3BDA8D4D5A2337A51BF9E22A0
private Dictionary<string,Models.VirtualNetworkRule> EnsureVirtualNetworkRules()
private Dictionary<string, List<Models.VirtualNetworkRule>> EnsureVirtualNetworkRules()
{
if (this.virtualNetworkRulesMap == null)
{
this.virtualNetworkRulesMap = new Dictionary<string, VirtualNetworkRule>();
this.virtualNetworkRulesMap = new Dictionary<string, List<VirtualNetworkRule>>();
if (this.Inner != null && this.Inner.VirtualNetworkRules != null)
{
foreach (var item in this.Inner.VirtualNetworkRules)
{
this.virtualNetworkRulesMap.Add(item.Id, item);
if(!this.virtualNetworkRulesMap.ContainsKey(item.Id))
{
this.virtualNetworkRulesMap.Add(item.Id, new List<VirtualNetworkRule>());
}
this.virtualNetworkRulesMap[item.Id].Add(item);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication" Version="2.3.4" />
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication" Version="2.3.6" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.4' ">
Expand Down

0 comments on commit b07f68c

Please sign in to comment.