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

remove netcoreapp2.1 from source #2350

Merged
merged 3 commits into from
Aug 4, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,7 @@ public async Task SendAsyncLogsIngestionReponseTimeEventCounter()
Assert.AreEqual("IngestionEndpoint-ResponseTimeMsec", payload["Name"].ToString());
Assert.IsTrue((int)payload["Count"] >= 5);
// Max should be more than 30 ms, as we introduced a delay of 30ms in SendAsync.
#if NETCOREAPP2_1
Assert.IsTrue((float)payload["Max"] >= 30);
#elif NETCOREAPP3_1
#if NETCOREAPP
Copy link
Member

Choose a reason for hiding this comment

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

If we are planning to cover .NET 5.0, .NET 6.0+, then better to include NET along with NETCOREAPP. Ref: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives#conditional-compilation

Copy link
Member Author

Choose a reason for hiding this comment

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

NET and NETCOREAPP both cover the same frameworks.

In my opinion, NET sounds ambiguous between the older NetFrameworks (4.5 - 4.8).
I would prefer to use NETCOREAPP to differentiate.

Copy link
Contributor

Choose a reason for hiding this comment

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

since NETCOREAPP covers NET5.0 and higher, this is fine i think.

Assert.IsTrue((double)payload["Max"] >= 30);
#endif
}
Expand Down Expand Up @@ -470,9 +468,7 @@ public async Task SendAsyncLogsIngestionReponseTimeOnFailureEventCounter()
Assert.AreEqual("IngestionEndpoint-ResponseTimeMsec", payload["Name"].ToString());
Assert.IsTrue((int)payload["Count"] >= 5);
// Mean should be more than 30 ms, as we introduced a delay of 30ms in SendAsync.
#if NETCOREAPP2_1
Assert.IsTrue((float)payload["Mean"] >= 30);
#elif NETCOREAPP3_1
#if NETCOREAPP
Assert.IsTrue((double)payload["Mean"] >= 30);
#endif
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NET461 || NETCOREAPP2_1 || NETCOREAPP3_1 || NET5_0
#if NET461 || NETCOREAPP
namespace Microsoft.ApplicationInsights.TestFramework.Extensibility.Implementation.Authentication
{
using System;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ public void TestNullMethodInfoInStack()
Assert.AreEqual(0, stackFrame.line);
}

#if !NETCOREAPP2_0

[TestMethod]
public void CheckThatFileNameAndLineAreCorrectIfAvailable()
{
Expand All @@ -110,25 +108,6 @@ public void CheckThatFileNameAndLineAreCorrectIfAvailable()
Assert.IsNull(stack[0].fileName);
}
}
#endif

#if NETCOREAPP2_0

[TestMethod]
public void CheckThatAssemblyNameHasCorrectValue()
{
var exp = this.CreateException(2);

ExceptionDetails expDetails = ExceptionConverter.ConvertToExceptionDetails(exp, null);

string assemblyFullName = Assembly.GetExecutingAssembly().FullName;

foreach (var stackFrame in expDetails.parsedStack)
{
Assert.AreEqual(assemblyFullName.ToLowerInvariant(), stackFrame.assembly.ToLowerInvariant());
}
}
#endif

[TestMethod]
public void CheckLevelCorrespondsToFrameForLongStack()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
namespace Microsoft.ApplicationInsights.Extensibility.Implementation.Tracing
{
#if !NETCOREAPP2_0
using System;
using System.Globalization;
using System.Threading;
Expand Down Expand Up @@ -45,5 +44,4 @@ public void RestoresOriginalUICultureToPreserveGlobalStateOfApplication()
}
}
}
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ public void LoadInstanceSetsInstancePropertiesOfTimeSpanTypeFromChildElementValu
}

[TestMethod]
#if NETCOREAPP3_1 || NET5_0
#if NETCOREAPP
[ExpectedExceptionWithMessage(typeof(ArgumentException), "Failed to parse configuration value. Property: 'TimeSpanProperty' Reason: String 'TestValue' was not recognized as a valid TimeSpan.")]
#else
[ExpectedExceptionWithMessage(typeof(ArgumentException), "Failed to parse configuration value. Property: 'TimeSpanProperty' Reason: String was not recognized as a valid TimeSpan.")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void Cleanup()
Directory.Delete(this.tempPath, true);
}

#if NETCOREAPP2_1 || NETCOREAPP3_1
#if NETCOREAPP3_1
TimothyMothra marked this conversation as resolved.
Show resolved Hide resolved
[Ignore("Missing netstandard dependencies.")]
#endif
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NETCOREAPP2_1
#if NETCOREAPP
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using System;
Expand Down Expand Up @@ -47,6 +47,5 @@ public void Dispose()
}
}
}

}
#endif
#endif
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NET461 || NETCOREAPP2_1 || NETCOREAPP3_1 || NET5_0
#if NET461 || NETCOREAPP
namespace Microsoft.ApplicationInsights.TestFramework.Helpers
{
using System;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public void InitializeThrowsArgumentNullExceptionToPreventUsageErrors()
// [TestMethod]
public void IsThreadSafe()
{
#if !NETCOREAPP2_1
const int NumberOfThreads = 16;
const int NumberOfFilesPerThread = 64;
var storage = new TransmissionStorage();
Expand Down Expand Up @@ -94,7 +93,6 @@ public void IsThreadSafe()
{
}
}
#endif
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if NETCOREAPP2_1
#if NETCOREAPP
namespace Microsoft.ApplicationInsights.WindowsServer.Channel
{
using System.Collections.Generic;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Azure.Core" Version="1.14.0" />

<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.2.0" />
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest using the 2.1*

Copy link
Member Author

Choose a reason for hiding this comment

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

why 2.1 here as opposed to latest?
I have no problem with the downgrade, just trying to understand :)

Copy link
Contributor

Choose a reason for hiding this comment

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

if its testing, yes you can use latest.

<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.2.0" />
</ItemGroup>

<Import Project="..\..\..\Test\TestFramework\Shared\TestFramework.Shared.projitems" Label="TestFramework.Shared" />
Expand Down
2 changes: 0 additions & 2 deletions IntegrationTests.sln
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
NETCORE\src\Shared\Shared.projitems*{079e8118-28b3-4567-a384-ea337a0ed9fb}*SharedItemsImports = 5
BASE\src\Common\Common\Common.projitems*{07f570e4-3a43-44d4-99a0-1d961b8e2a70}*SharedItemsImports = 5
WEB\Src\Common\Common.projitems*{33478fb4-05fc-4cbd-a04d-17d0d6ba5b13}*SharedItemsImports = 5
WEB\Src\Common\Common.projitems*{56c361c2-724c-4688-b4e1-f94c0681ec33}*SharedItemsImports = 5
BASE\src\Common\Common\Common.projitems*{893dfa71-0f4f-4bbf-ae8f-72208be237ba}*SharedItemsImports = 5
WEB\Src\Common\Common.projitems*{a8d39e66-af60-4f51-aedc-2464a2d86dea}*SharedItemsImports = 5
WEB\Src\PerformanceCollector\Perf.Shared.NetFull\Perf.Shared.NetFull.projitems*{a8d39e66-af60-4f51-aedc-2464a2d86dea}*SharedItemsImports = 5
LOGGING\src\CommonShared\CommonShared.projitems*{dd8682e9-bdcf-459b-b1a6-97966c3e9b6a}*SharedItemsImports = 5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,29 @@ public CorrelationMvcTests(ITestOutputHelper output) : base(output)
[Fact]
public void CorrelationInfoIsPropagatedToDependendedService()
{
#if netcoreapp2_0 // Correlation works on .Net core.
using (var server = new InProcessServer(assemblyName, this.output))
{
using (var httpClient = new HttpClient())
{
var task = httpClient.GetAsync(server.BaseHost + "/");
task.Wait(TestTimeoutMs);
}

var actual = server.Execute<Envelope>(() => server.Listener.ReceiveItems(2, TestListenerTimeoutInMs));
this.DebugTelemetryItems(actual);

var dependencyTelemetry = actual.OfType<TelemetryItem<RemoteDependencyData>>().FirstOrDefault();
Assert.NotNull(dependencyTelemetry);

var requestTelemetry = actual.OfType<TelemetryItem<RequestData>>().FirstOrDefault();
Assert.NotNull(requestTelemetry);

Assert.Equal(requestTelemetry.tags["ai.operation.id"], dependencyTelemetry.tags["ai.operation.id"]);
Assert.Contains(dependencyTelemetry.tags["ai.operation.id"], requestTelemetry.tags["ai.operation.parentId"]);
}
#endif
// TODO: THIS IS A TESTING GAP
//#if NETCOREAPP // Correlation works on .Net core.
// using (var server = new InProcessServer(assemblyName, this.output))
// {
// using (var httpClient = new HttpClient())
// {
// var task = httpClient.GetAsync(server.BaseHost + "/");
// task.Wait(TestTimeoutMs);
// }

// var actual = server.Execute<Envelope>(() => server.Listener.ReceiveItems(2, TestListenerTimeoutInMs));
// this.DebugTelemetryItems(actual);

// var dependencyTelemetry = actual.OfType<TelemetryItem<RemoteDependencyData>>().FirstOrDefault();
// Assert.NotNull(dependencyTelemetry);

// var requestTelemetry = actual.OfType<TelemetryItem<RequestData>>().FirstOrDefault();
// Assert.NotNull(requestTelemetry);

// Assert.Equal(requestTelemetry.tags["ai.operation.id"], dependencyTelemetry.tags["ai.operation.id"]);
// Assert.Contains(dependencyTelemetry.tags["ai.operation.id"], requestTelemetry.tags["ai.operation.parentId"]);
// }
//#endif
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,38 +26,39 @@ public DependencyTelemetryMvcTests(ITestOutputHelper output) : base(output)
[Fact]
public void CorrelationInfoIsNotAddedToRequestHeaderIfUserAddDomainToExcludedList()
{
#if netcoreapp2_0 // Correlation is supported on .Net core.
using (var server = new InProcessServer(assemblyName, this.output))
{
var dependencyCollectorModule = server.ApplicationServices.GetServices<ITelemetryModule>().OfType<DependencyTrackingTelemetryModule>().Single();
dependencyCollectorModule.ExcludeComponentCorrelationHttpHeadersOnDomains.Add(server.BaseHost);

using (var httpClient = new HttpClient())
{
var task = httpClient.GetAsync(server.BaseHost + "/");
task.Wait(TestTimeoutMs);
}

var actual = server.Execute<Envelope>(() => server.Listener.ReceiveItems(TestListenerTimeoutInMs));
this.DebugTelemetryItems(actual);

try
{
var dependencyTelemetry = actual.OfType<TelemetryItem<RemoteDependencyData>>().FirstOrDefault();
Assert.NotNull(dependencyTelemetry);

var requestTelemetry = actual.OfType<TelemetryItem<RequestData>>().FirstOrDefault();
Assert.NotNull(requestTelemetry);

Assert.NotEqual(requestTelemetry.tags["ai.operation.id"], dependencyTelemetry.tags["ai.operation.id"]);
}
catch (Exception e)
{
string data = DebugTelemetryItems(actual);
throw new Exception(data, e);
}
}
#endif
// TODO: THIS IS A TESTING GAP
//#if NETCOREAPP // Correlation is supported on .Net core.
// using (var server = new InProcessServer(assemblyName, this.output))
// {
// var dependencyCollectorModule = server.ApplicationServices.GetServices<ITelemetryModule>().OfType<DependencyTrackingTelemetryModule>().Single();
// dependencyCollectorModule.ExcludeComponentCorrelationHttpHeadersOnDomains.Add(server.BaseHost);

// using (var httpClient = new HttpClient())
// {
// var task = httpClient.GetAsync(server.BaseHost + "/");
// task.Wait(TestTimeoutMs);
// }

// var actual = server.Execute<Envelope>(() => server.Listener.ReceiveItems(TestListenerTimeoutInMs));
// this.DebugTelemetryItems(actual);

// try
// {
// var dependencyTelemetry = actual.OfType<TelemetryItem<RemoteDependencyData>>().FirstOrDefault();
// Assert.NotNull(dependencyTelemetry);

// var requestTelemetry = actual.OfType<TelemetryItem<RequestData>>().FirstOrDefault();
// Assert.NotNull(requestTelemetry);

// Assert.NotEqual(requestTelemetry.tags["ai.operation.id"], dependencyTelemetry.tags["ai.operation.id"]);
// }
// catch (Exception e)
// {
// string data = DebugTelemetryItems(actual);
// throw new Exception(data, e);
// }
// }
//#endif
}

[Fact]
Expand Down
11 changes: 1 addition & 10 deletions NETCORE/test/IntegrationTests.WebApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,7 @@ namespace IntegrationTests.WebApp
{
public class Program
{
#if NETCOREAPP2_1
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}

public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup_netcoreapp_2_1>();
#elif NET5_0
#if NET5_0
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
Expand Down
60 changes: 0 additions & 60 deletions NETCORE/test/IntegrationTests.WebApp/Startup.netcoreapp2.1.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ private void ValidateTelemetryForDiagnosticSource(
}
else
{
// TODO: THIS IS A TESTING GAP
#if NETCOREAPP2_1
// even though we don't inject back-compatible request-id, .NET Core 2.0 will inject one that will look like traceparent
Assert.AreEqual(expectedTraceParentHeader, request.Headers.GetValues(RequestResponseHeaders.RequestIdHeader).Single());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ private static PerformanceCollectorModule CreatePerformanceCollectionModule(IPer
[TestMethod]
public void PerformanceCollectorModuleDefaultContainsExpectedCountersNonWindows()
{
#if NETCOREAPP2_1 || NETCOREAPP3_1
#if NETCOREAPP
PerformanceCounterUtility.isAzureWebApp = null;
var original = PerformanceCounterUtility.IsWindows;
PerformanceCounterUtility.IsWindows = false;
Expand Down Expand Up @@ -458,7 +458,7 @@ public void PerformanceCollectorModuleDefaultContainsExpectedCountersWindows()
{
PerformanceCounterUtility.isAzureWebApp = null;
var module = new PerformanceCollectorModule();
#if NETCOREAPP2_1 || NETCOREAPP3_1
#if NETCOREAPP
var original = PerformanceCounterUtility.IsWindows;
PerformanceCounterUtility.IsWindows = true;
#endif
Expand Down Expand Up @@ -490,7 +490,7 @@ public void PerformanceCollectorModuleDefaultContainsExpectedCountersWindows()
finally
{
module.Dispose();
#if NETCOREAPP2_1 || NETCOREAPP3_1
#if NETCOREAPP
PerformanceCounterUtility.IsWindows = original;
#endif
}
Expand Down
Loading