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

[Internal] Tests : Fixes enable "warning-as-error" build errors #4588

Merged
merged 10 commits into from
Oct 3, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,9 @@ private sealed class Document

private static class DebugTraceHelpers
{
#pragma warning disable CS0162, CS0649 // Unreachable code detected
private const bool Enabled = false;

#pragma warning disable CS0162 // Unreachable code detected
public static void TraceSupportedFeaturesString(string supportedQueryFeatures)
{
if (Enabled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public async Task EtagPassesContinuation()

Mock<ContainerInternal> containerMock = new Mock<ContainerInternal>();
Mock<CosmosClientContext> mockContext = new Mock<CosmosClientContext>();
#pragma warning disable CA1416 // 'ResourceType' is only supported on: 'windows'
mockContext.Setup(x => x.OperationHelperAsync<ResponseMessage>(
It.Is<string>(str => str.Contains("Change Feed Processor")),
It.IsAny<string>(),
Expand All @@ -59,6 +60,7 @@ public async Task EtagPassesContinuation()
return func(trace);
}
});
#pragma warning restore CA1416

mockContext.Setup(c => c.ProcessResourceOperationStreamAsync(
It.IsAny<string>(),
Expand Down Expand Up @@ -121,6 +123,7 @@ public async Task NextReadHasUpdatedContinuation()

Mock<ContainerInternal> containerMock = new Mock<ContainerInternal>();
Mock<CosmosClientContext> mockContext = new Mock<CosmosClientContext>();
#pragma warning disable CA1416 // 'ResourceType' is only supported on: 'windows'
mockContext.Setup(x => x.OperationHelperAsync<ResponseMessage>(
It.Is<string>(str => str.Contains("Change Feed Processor")),
It.IsAny<string>(),
Expand All @@ -140,6 +143,7 @@ public async Task NextReadHasUpdatedContinuation()
return func(trace);
}
});
#pragma warning restore CA1416

mockContext.SetupSequence(c => c.ProcessResourceOperationStreamAsync(
It.IsAny<string>(),
Expand Down Expand Up @@ -192,6 +196,7 @@ public async Task ShouldSetFeedRangePartitionKeyRange()

Mock<ContainerInternal> containerMock = new Mock<ContainerInternal>();
Mock<CosmosClientContext> mockContext = new Mock<CosmosClientContext>();
#pragma warning disable CA1416 // 'ResourceType' is only supported on: 'windows'
mockContext.Setup(x => x.OperationHelperAsync<ResponseMessage>(
It.Is<string>(str => str.Contains("Change Feed Processor")),
It.IsAny<string>(),
Expand All @@ -211,6 +216,7 @@ public async Task ShouldSetFeedRangePartitionKeyRange()
return func(trace);
}
});
#pragma warning restore CA1416

mockContext.Setup(c => c.ProcessResourceOperationStreamAsync(
It.IsAny<string>(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,51 +270,51 @@ public void HttpRequestExceptionHandelingTests(
}

[TestMethod]
public Task ClientRetryPolicy_Retry_SingleMaster_Read_PreferredLocations()
public async Task ClientRetryPolicy_Retry_SingleMaster_Read_PreferredLocationsAsync()
{
return this.ValidateConnectTimeoutTriggersClientRetryPolicy(isReadRequest: true, useMultipleWriteLocations: false, usesPreferredLocations: true, shouldHaveRetried: true);
await this.ValidateConnectTimeoutTriggersClientRetryPolicy(isReadRequest: true, useMultipleWriteLocations: false, usesPreferredLocations: true, shouldHaveRetried: true);
}

[TestMethod]
public Task ClientRetryPolicy_Retry_MultiMaster_Read_PreferredLocations()
public async Task ClientRetryPolicy_Retry_MultiMaster_Read_PreferredLocationsAsync()
{
return this.ValidateConnectTimeoutTriggersClientRetryPolicy(isReadRequest: true, useMultipleWriteLocations: true, usesPreferredLocations: true, shouldHaveRetried: true);
await this.ValidateConnectTimeoutTriggersClientRetryPolicy(isReadRequest: true, useMultipleWriteLocations: true, usesPreferredLocations: true, shouldHaveRetried: true);
}

[TestMethod]
public Task ClientRetryPolicy_Retry_MultiMaster_Write_PreferredLocations()
public async Task ClientRetryPolicy_Retry_MultiMaster_Write_PreferredLocationsAsync()
{
return this.ValidateConnectTimeoutTriggersClientRetryPolicy(isReadRequest: false, useMultipleWriteLocations: true, usesPreferredLocations: true, shouldHaveRetried: true);
await this.ValidateConnectTimeoutTriggersClientRetryPolicy(isReadRequest: false, useMultipleWriteLocations: true, usesPreferredLocations: true, shouldHaveRetried: true);
}

[TestMethod]
public Task ClientRetryPolicy_NoRetry_SingleMaster_Write_PreferredLocations()
public async Task ClientRetryPolicy_NoRetry_SingleMaster_Write_PreferredLocationsAsync()
{
return this.ValidateConnectTimeoutTriggersClientRetryPolicy(isReadRequest: false, useMultipleWriteLocations: false, usesPreferredLocations: true, shouldHaveRetried: false);
await this.ValidateConnectTimeoutTriggersClientRetryPolicy(isReadRequest: false, useMultipleWriteLocations: false, usesPreferredLocations: true, shouldHaveRetried: false);
}

[TestMethod]
public Task ClientRetryPolicy_NoRetry_SingleMaster_Read_NoPreferredLocations()
public async Task ClientRetryPolicy_NoRetry_SingleMaster_Read_NoPreferredLocationsAsync()
{
return this.ValidateConnectTimeoutTriggersClientRetryPolicy(isReadRequest: true, useMultipleWriteLocations: false, usesPreferredLocations: false, shouldHaveRetried: false);
await this.ValidateConnectTimeoutTriggersClientRetryPolicy(isReadRequest: true, useMultipleWriteLocations: false, usesPreferredLocations: false, shouldHaveRetried: false);
}

[TestMethod]
public Task ClientRetryPolicy_NoRetry_SingleMaster_Write_NoPreferredLocations()
public async Task ClientRetryPolicy_NoRetry_SingleMaster_Write_NoPreferredLocationsAsync()
{
return this.ValidateConnectTimeoutTriggersClientRetryPolicy(isReadRequest: false, useMultipleWriteLocations: false, usesPreferredLocations: false, shouldHaveRetried: false);
await this.ValidateConnectTimeoutTriggersClientRetryPolicy(isReadRequest: false, useMultipleWriteLocations: false, usesPreferredLocations: false, shouldHaveRetried: false);
}

[TestMethod]
public Task ClientRetryPolicy_NoRetry_MultiMaster_Read_NoPreferredLocations()
public async Task ClientRetryPolicy_NoRetry_MultiMaster_Read_NoPreferredLocationsAsync()
{
return this.ValidateConnectTimeoutTriggersClientRetryPolicy(isReadRequest: true, useMultipleWriteLocations: true, usesPreferredLocations: false, false);
await this.ValidateConnectTimeoutTriggersClientRetryPolicy(isReadRequest: true, useMultipleWriteLocations: true, usesPreferredLocations: false, false);
}

[TestMethod]
public Task ClientRetryPolicy_NoRetry_MultiMaster_Write_NoPreferredLocations()
public async Task ClientRetryPolicy_NoRetry_MultiMaster_Write_NoPreferredLocationsAsync()
{
return this.ValidateConnectTimeoutTriggersClientRetryPolicy(isReadRequest: false, useMultipleWriteLocations: true, usesPreferredLocations: false, false);
await this.ValidateConnectTimeoutTriggersClientRetryPolicy(isReadRequest: false, useMultipleWriteLocations: true, usesPreferredLocations: false, false);
}

private async Task ValidateConnectTimeoutTriggersClientRetryPolicy(
kirankumarkolli marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1110,8 +1110,10 @@ public void TestServerCertificatesValidationWithDisableSSLFlagTrue(string connSt
CosmosHttpClient httpClient = cosmosClient.DocumentClient.httpClient;
SocketsHttpHandler socketsHttpHandler = (SocketsHttpHandler)httpClient.HttpMessageHandler;

#nullable enable
RemoteCertificateValidationCallback? httpClientRemoreCertValidationCallback = socketsHttpHandler.SslOptions.RemoteCertificateValidationCallback;
Assert.IsNotNull(httpClientRemoreCertValidationCallback);
#nullable disable
}

private class TestWebProxy : IWebProxy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<RootNamespace>Microsoft.Azure.Cosmos.Tests</RootNamespace>
<LangVersion>$(LangVersion)</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -727,8 +727,8 @@ private async Task SplitMergeAsync()

private static class DebugTraceHelpers
{
private const bool Enabled = false;
#pragma warning disable CS0162 // Unreachable code detected
#pragma warning disable CS0162, CS0649 // Unreachable code detected
private static readonly bool Enabled;

[Conditional("DEBUG")]
public static void TraceSplit(FeedRangeInternal feedRange)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ public override bool Equals(object obj)
return false;
}

#pragma warning disable CA2013 // value boxing, also this check seems redundant (future todo)
if (object.ReferenceEquals(this, obj))
{
return true;
}
#pragma warning restore CA2013

return this.Equals(effectivePartitionKey);
}
Expand Down
Loading