Skip to content

Commit

Permalink
Vibankwa/azure.monitor.otel.exporter/fixbreakingtests (Azure#23063)
Browse files Browse the repository at this point in the history
* fix breaking test after otel reference upgrade

* minor fix

* separate netcore and net461 classes

* add empty line before eof

* fix version for testing package
  • Loading branch information
vishweshbankwar authored Aug 3, 2021
1 parent 4e13b43 commit 4abd599
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk.Web">
<!-- https://docs.microsoft.com/aspnet/core/test/integration-tests -->

<PropertyGroup>
Expand All @@ -12,7 +12,9 @@

<ItemGroup>
<PackageReference Include="System.Text.Encodings.Web" VersionOverride="4.5.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<!--We would prefer to use the meta package "Microsoft.AspNetCore.App" here.
But this package targets NetCoreApp2.1, while all the dependent packages target NetStandard2.0.
To support net461 so we must reference the dependent packages.-->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#if NET461
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;

namespace Azure.Monitor.OpenTelemetry.Exporter.Integration.Tests.AspNetCoreWebApp
{
public class Program
public partial class Program
{
public static void Main(string[] args) => CreateWebHostBuilder(args).Build().Run();

public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args).UseStartup<Startup>();
}
}
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#if NETCOREAPP
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;

namespace Azure.Monitor.OpenTelemetry.Exporter.Integration.Tests.AspNetCoreWebApp
{
public partial class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
}
#endif
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

#if NET461
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
Expand All @@ -9,7 +9,7 @@

namespace Azure.Monitor.OpenTelemetry.Exporter.Integration.Tests.AspNetCoreWebApp
{
public class Startup
public partial class Startup
{
public Startup(IConfiguration configuration)
{
Expand Down Expand Up @@ -48,3 +48,4 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
}
}
}
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#if NETCOREAPP
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace Azure.Monitor.OpenTelemetry.Exporter.Integration.Tests.AspNetCoreWebApp
{
public partial class Startup
{
public Startup(IConfiguration configuration)
{
this.Configuration = configuration;
}

public IConfiguration Configuration { get; }

// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

app.UseRouting();

app.UseAuthorization();

app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
});
}
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" VersionOverride="2.1.1" />
<PackageReference Include="Microsoft.Azure.ApplicationInsights.Query" />
<PackageReference Include="Microsoft.Rest.ClientRuntime.Azure.Authentication" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
Expand All @@ -18,20 +17,25 @@
<PackageReference Include="xunit.runner.visualstudio" />
</ItemGroup>

<!--<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>-->

<ItemGroup Condition=" '$(TargetFramework)' == 'net461' OR '$(TargetFramework)' == 'netcoreapp3.1'">
<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
<!--We would prefer to use the meta package "Microsoft.AspNetCore.App" here.
But this package targets NetCoreApp3.1, while all the dependent packages target NetStandard2.0.
To support net461 so we must reference the dependent packages.-->
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" VersionOverride="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore" VersionOverride="[2.1.1,2.2)" />
<PackageReference Include="Microsoft.AspNetCore.Hosting" VersionOverride="[2.1.1,2.2)" />
<PackageReference Include="Microsoft.AspNetCore.HttpsPolicy" VersionOverride="[2.1.1,2.2)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" VersionOverride="[2.1.1,2.2)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" VersionOverride="3.1.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" VersionOverride="5.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="$(AzureCoreTestFramework)" />
<ProjectReference Include="..\..\src\Azure.Monitor.OpenTelemetry.Exporter.csproj" />
Expand Down

0 comments on commit 4abd599

Please sign in to comment.