Skip to content

Commit

Permalink
Tilee/add netcore3.0 tests (#1670)
Browse files Browse the repository at this point in the history
* add netcore 3.0 to tests

* fix preprocessors

* testing netcore 3.0 on linux

* test fix for linux tests

* testing fix for linux

* testing linux build

* testing

* change version

* change to specific version of v1.1

* revert to older 1.1 task

* fix compile constants for netstandard v1
  • Loading branch information
TimothyMothra authored Feb 6, 2020
1 parent 1f7feda commit d032dbf
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 35 deletions.
33 changes: 27 additions & 6 deletions BASE/.vsts/linux-build.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
variables:
DotNetVersion: "2.2.101"

pool:
vmImage: 'ubuntu-16.04'
steps:
- task: DotNetCoreInstaller@0


- task: DotNetCoreInstaller@1
displayName: install dotnet core 3.0
inputs:
version: $(DotNetVersion)
version: 3.0.x

- task: DotNetCoreCLI@1
displayName: DotNetCoreCLI - Restore Solution
Expand All @@ -21,16 +21,35 @@ steps:
projects: "BASE/*.sln"
arguments: "--configuration Release"

- task: DotNetCoreCLI@1
displayName: DotNetCoreCLI - Test NetCore 3.0
inputs:
command: "test"
projects: "BASE/Test/**/Microsoft.ApplicationInsights.Tests.csproj"
arguments: "--configuration Release --framework netcoreapp3.0 -l trx --filter TestCategory!=WindowsOnly"


## Install and test NetCore 2.2

- task: DotNetCoreInstaller@1
displayName: install dotnet core 2.2
inputs:
version: 2.2.x

- task: DotNetCoreCLI@1
displayName: DotNetCoreCLI - Test NetCore 2.0
inputs:
command: "test"
projects: "BASE/Test/**/Microsoft.ApplicationInsights.Tests.csproj"
arguments: "--configuration Release --framework netcoreapp2.0 -l trx --filter TestCategory!=WindowsOnly"


## Install and test NetCore 1.1

- task: DotNetCoreInstaller@0
displayName: install dotnet core 1.1
inputs:
version: "1.1.5"
version: 1.1.5

- task: DotNetCoreCLI@1
displayName: DotNetCoreCLI - Test NetCore 1.1
Expand All @@ -39,6 +58,8 @@ steps:
projects: "BASE/Test/**/Microsoft.ApplicationInsights.Tests.csproj"
arguments: "--configuration Release --framework netcoreapp1.1 -l trx --filter TestCategory!=WindowsOnly"

## Publish test results

- task: PublishTestResults@2
condition: always()
inputs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void TelemetryWithNoInstrumentationKeyIsDropped()
}
}

#if (!NETCOREAPP1_1 && !NETCOREAPP2_0)
#if (!NETCOREAPP) // This constant is defined for all versions of NetCore https://docs.microsoft.com/en-us/dotnet/core/tutorials/libraries#how-to-multitarget

[Ignore("This test is failing intermittently and needs to be investigated. ~Timothy")]
[TestMethod]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,11 @@ public void LoadInstanceSetsInstancePropertiesOfTimeSpanTypeFromChildElementValu
}

[TestMethod]
#if NETCOREAPP3_0
[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.")]
#endif
public void LoadInstanceSetsInstancePropertiesOfTimeSpanTypeFromChildElementValuesOfDefinitionWithInvalidFormatThrowsException()
{
var definition = new XElement(
Expand Down Expand Up @@ -641,9 +645,9 @@ public void LoadInstanceCreatesNewInstanceOfExpectedTypeWhenPropertiesAreSpecifi
Assert.AreEqual(42, loaded.Int32Property);
}

#endregion
#endregion

#region TelemetryProcesors
#region TelemetryProcesors

[TestMethod]
public void InitializeTelemetryProcessorsFromConfigurationFile()
Expand Down Expand Up @@ -873,9 +877,9 @@ public void UseAddsProcessorAfterProcessorsDefinedInConfiguration()
AssertEx.IsType<StubTelemetryProcessor2>(configuration.TelemetryProcessors[1]);
}

#endregion
#endregion

#region Modules
#region Modules

[TestMethod]
public void InitializeTelemetryModulesFromConfigurationFile()
Expand Down Expand Up @@ -961,9 +965,9 @@ public void InitializeDoesNotThrowIsModuleInitializationFails()
}
}

#endregion
#endregion

#region TelemetryInitializers
#region TelemetryInitializers
[TestMethod]
public void InitializeAddTelemetryInitializersWithOneInvalid()
{
Expand All @@ -982,9 +986,9 @@ public void InitializeAddTelemetryInitializersWithOneInvalid()
}


#endregion
#endregion

#region LoadInstances<T>
#region LoadInstances<T>

[TestMethod]
public void LoadInstancesPopulatesListWithInstancesOfSpecifiedType()
Expand Down Expand Up @@ -1055,9 +1059,9 @@ public void LoadInstancesIgnoresElementsOtherThanAdd()
AssertEx.AreEqual(new[] { 42 }, instances);
}

#endregion
#endregion

#region LoadProperties
#region LoadProperties

[TestMethod]
public void LoadPropertiesConvertsPropertyValuesFromStringToPropertyType()
Expand Down Expand Up @@ -1215,9 +1219,9 @@ public void DeveloperModePropertyCanLoadEmptyValue()
Assert.IsFalse(instance.TelemetryChannel.DeveloperMode.HasValue);
}

#endregion
#endregion

#region TelemetrySinks
#region TelemetrySinks

[TestMethod]
public void EmptyConfigurationCreatesDefaultSink()
Expand Down Expand Up @@ -1783,7 +1787,7 @@ public void TelemetrySinkInitializesChannelAndAllProcessors()
Assert.IsTrue(processor.Initialized);
}

#endregion
#endregion

[TestMethod]
public void InitializeIsMarkesAsInternalSdkOperation()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ public static void ValidateSdkVersionString(string versionMoniker)
Assert.IsNotNull(versionMoniker);

// Expected result example: "m-agg2:2.6.0-12552"
#if NETCOREAPP1_1 || NETCOREAPP2_0
#if NETCOREAPP // This constant is defined for all versions of NetCore https://docs.microsoft.com/en-us/dotnet/core/tutorials/libraries#how-to-multitarget
const string expectedPrefix = "m-agg2c:";
#else
const string expectedPrefix = "m-agg2:";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>net45;net46;netcoreapp1.1;netcoreapp2.0</TargetFrameworks>
<TargetFrameworks Condition="$(OS) != 'Windows_NT'">netcoreapp1.1;netcoreapp2.0</TargetFrameworks>
<TargetFrameworks>net45;net46;netcoreapp1.1;netcoreapp2.0;netcoreapp3.0</TargetFrameworks>
<TargetFrameworks Condition="$(OS) != 'Windows_NT'">netcoreapp1.1;netcoreapp2.0;netcoreapp3.0</TargetFrameworks>
<DebugType>pdbonly</DebugType>
<DebugSymbols>true</DebugSymbols>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ public void TrackCopiesPropertiesFromClientToTelemetryBeforeInvokingInitializers
Assert.AreEqual(client.Context.Properties[PropertyNameGlobal], globalValueInInitializer);
}

#if (!NETCOREAPP1_1 && !NETCOREAPP2_0)
#if (!NETCOREAPP) // This constant is defined for all versions of NetCore https://docs.microsoft.com/en-us/dotnet/core/tutorials/libraries#how-to-multitarget
[TestMethod]
public void TrackAddsSdkVerionByDefault()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
</PropertyGroup>

<PropertyGroup>
<TargetFrameworks>net45;netcoreapp1.1;netcoreapp2.0</TargetFrameworks>
<TargetFrameworks Condition="$(OS) != 'Windows_NT'">netcoreapp1.1;netcoreapp2.0</TargetFrameworks>
<TargetFrameworks>net45;netcoreapp1.1;netcoreapp2.0;netcoreapp3.0</TargetFrameworks>
<TargetFrameworks Condition="$(OS) != 'Windows_NT'">netcoreapp1.1;netcoreapp2.0;netcoreapp3.0</TargetFrameworks>

<AssemblyName>Microsoft.ApplicationInsights.TelemetryChannel.Tests</AssemblyName>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ internal static void UpdateTagValue(this IDictionary<string, string> tags, strin
{
if (tagValue.HasValue)
{
#if NET45 || NET46 || NETSTANDARD2_0
string value = tagValue.Value.ToString(CultureInfo.InvariantCulture);
#else
#if NETSTANDARD1_3
string value = tagValue.Value.ToString();
#else
string value = tagValue.Value.ToString(CultureInfo.InvariantCulture);
#endif
tags.Add(tagKey, value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal class HeartbeatProvider : IDisposable, IHeartbeatProvider
/// <summary>
/// Value for property indicating 'app insights version' related specifically to heartbeats.
/// </summary>
#if NETSTANDARD1_3 || NETSTANDARD2_0
#if NETSTANDARD // This constant is defined for all versions of NetStandard https://docs.microsoft.com/en-us/dotnet/core/tutorials/libraries#how-to-multitarget
private static string sdkVersionPropertyValue = SdkVersionUtils.GetSdkVersion("hbnetc:");
#else
private static string sdkVersionPropertyValue = SdkVersionUtils.GetSdkVersion("hbnet:");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ public TelemetryConfiguration(string instrumentationKey, ITelemetryChannel chann
/// If the configuration file does not exist, the active configuration instance is initialized with minimum defaults
/// needed to send telemetry to Application Insights.
/// </summary>
#if NETSTANDARD1_3 || NETSTANDARD2_0
#if NETSTANDARD // This constant is defined for all versions of NetStandard https://docs.microsoft.com/en-us/dotnet/core/tutorials/libraries#how-to-multitarget
[Obsolete("We do not recommend using TelemetryConfiguration.Active on .NET Core. See https://github.com/microsoft/ApplicationInsights-dotnet/issues/1152 for more details")]
#endif
#endif
public static TelemetryConfiguration Active
{
get
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ internal static class Util

private const string FallbackParameterName = "specified parameter";

#if NETSTANDARD1_3 || NETSTANDARD2_0
#if NETSTANDARD // This constant is defined for all versions of NetStandard https://docs.microsoft.com/en-us/dotnet/core/tutorials/libraries#how-to-multitarget
private static string sdkVersionMoniker = SdkVersionUtils.GetSdkVersion("m-agg2c:");
#else
private static string sdkVersionMoniker = SdkVersionUtils.GetSdkVersion("m-agg2:");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
<AssemblyName>Microsoft.ApplicationInsights</AssemblyName>
<TargetFrameworks>net45;net46;netstandard1.3;netstandard2.0</TargetFrameworks>
<TargetFrameworks Condition="$(OS) != 'Windows_NT'">netstandard1.3;netstandard2.0</TargetFrameworks>


<!-- this constant is set for all other netcore targets except 1-->
<DefineConstants Condition="'$(TargetFramework)' == 'netstandard1.3'">$(DefineConstants);NETSTANDARD;</DefineConstants>
</PropertyGroup>

<PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions BASE/src/Microsoft.ApplicationInsights/TelemetryClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/// </summary>
public sealed class TelemetryClient
{
#if NETSTANDARD1_3 || NETSTANDARD2_0
#if NETSTANDARD // This constant is defined for all versions of NetStandard https://docs.microsoft.com/en-us/dotnet/core/tutorials/libraries#how-to-multitarget
private const string VersionPrefix = "dotnetc:";
#else
private const string VersionPrefix = "dotnet:";
Expand All @@ -32,7 +32,7 @@ public sealed class TelemetryClient
/// <summary>
/// Initializes a new instance of the <see cref="TelemetryClient" /> class. Send telemetry with the active configuration, usually loaded from ApplicationInsights.config.
/// </summary>
#if NETSTANDARD1_3 || NETSTANDARD2_0
#if NETSTANDARD // This constant is defined for all versions of NetStandard https://docs.microsoft.com/en-us/dotnet/core/tutorials/libraries#how-to-multitarget
[Obsolete("We do not recommend using TelemetryConfiguration.Active on .NET Core. See https://github.com/microsoft/ApplicationInsights-dotnet/issues/1152 for more details")]
#endif
public TelemetryClient() : this(TelemetryConfiguration.Active)
Expand Down
4 changes: 4 additions & 0 deletions BASE/src/ServerTelemetryChannel/TelemetryChannel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
<AssemblyName>Microsoft.AI.ServerTelemetryChannel</AssemblyName>
<TargetFrameworks>net45;netstandard1.3;netstandard2.0</TargetFrameworks>
<TargetFrameworks Condition="$(OS) != 'Windows_NT'">netstandard1.3;netstandard2.0</TargetFrameworks>


<!-- this constant is set for all other netcore targets except 1-->
<DefineConstants Condition="'$(TargetFramework)' == 'netstandard1.3'">$(DefineConstants);NETSTANDARD;</DefineConstants>
</PropertyGroup>

<PropertyGroup>
Expand Down

0 comments on commit d032dbf

Please sign in to comment.