Fix gRPC interop tests (#24824)

This commit is contained in:
James Newton-King 2020-08-13 17:48:26 +12:00 committed by GitHub
parent ca1505ba3b
commit 82324bf357
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 19 additions and 11 deletions

View File

@ -3,9 +3,6 @@
<PropertyGroup> <PropertyGroup>
<ContainsFunctionalTestAssets>true</ContainsFunctionalTestAssets> <ContainsFunctionalTestAssets>true</ContainsFunctionalTestAssets>
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework> <TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
<!-- https://github.com/dotnet/aspnetcore/issues/24182 -->
<BuildHelixPayload>false</BuildHelixPayload>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -29,7 +29,6 @@ using Google.Apis.Auth.OAuth2;
using Google.Protobuf; using Google.Protobuf;
using Grpc.Auth; using Grpc.Auth;
using Grpc.Core; using Grpc.Core;
using Grpc.Core.Utils;
using Grpc.Net.Client; using Grpc.Net.Client;
using Grpc.Testing; using Grpc.Testing;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@ -96,11 +95,12 @@ namespace InteropTestsClient
var services = new ServiceCollection(); var services = new ServiceCollection();
services.AddLogging(configure => services.AddLogging(configure =>
{ {
configure.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace); configure.SetMinimumLevel(LogLevel.Trace);
configure.AddSimpleConsole(loggerOptions => configure.AddConsole(loggerOptions =>
{ {
#pragma warning disable CS0618 // Type or member is obsolete
loggerOptions.IncludeScopes = true; loggerOptions.IncludeScopes = true;
loggerOptions.DisableColors = true; #pragma warning restore CS0618 // Type or member is obsolete
}); });
}); });

View File

@ -17,6 +17,7 @@
#endregion #endregion
using System; using System;
using System.Reflection;
namespace InteropTestsClient namespace InteropTestsClient
{ {
@ -26,6 +27,9 @@ namespace InteropTestsClient
{ {
Console.WriteLine("Application started."); Console.WriteLine("Application started.");
var runtimeVersion = typeof(object).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? "Unknown";
Console.WriteLine($"NetCoreAppVersion: {runtimeVersion}");
InteropClient.Run(args); InteropClient.Run(args);
} }
} }

View File

@ -37,7 +37,7 @@ namespace InteropTestsWebsite
Host.CreateDefaultBuilder(args) Host.CreateDefaultBuilder(args)
.ConfigureLogging(builder => .ConfigureLogging(builder =>
{ {
builder.AddSimpleConsole(o => o.DisableColors = true); builder.AddConsole();
builder.SetMinimumLevel(LogLevel.Trace); builder.SetMinimumLevel(LogLevel.Trace);
}) })
.ConfigureWebHostDefaults(webBuilder => .ConfigureWebHostDefaults(webBuilder =>

View File

@ -17,6 +17,7 @@
#endregion #endregion
using System; using System;
using System.Reflection;
using Grpc.Testing; using Grpc.Testing;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@ -37,7 +38,13 @@ namespace InteropTestsWebsite
public void Configure(IApplicationBuilder app, IHostApplicationLifetime applicationLifetime) public void Configure(IApplicationBuilder app, IHostApplicationLifetime applicationLifetime)
{ {
// Required to notify test infrastructure that it can begin tests // Required to notify test infrastructure that it can begin tests
applicationLifetime.ApplicationStarted.Register(() => Console.WriteLine("Application started.")); applicationLifetime.ApplicationStarted.Register(() =>
{
Console.WriteLine("Application started.");
var runtimeVersion = typeof(object).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? "Unknown";
Console.WriteLine($"NetCoreAppVersion: {runtimeVersion}");
});
app.UseRouting(); app.UseRouting();
app.UseEndpoints(endpoints => app.UseEndpoints(endpoints =>

View File

@ -218,8 +218,8 @@ namespace Microsoft.AspNetCore.Internal
private static string GetNugetPackagesRestorePath() => (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("NUGET_RESTORE"))) private static string GetNugetPackagesRestorePath() => (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("NUGET_RESTORE")))
? typeof(ProcessEx).Assembly ? typeof(ProcessEx).Assembly
.GetCustomAttributes<AssemblyMetadataAttribute>() .GetCustomAttributes<AssemblyMetadataAttribute>()
.First(attribute => attribute.Key == "TestPackageRestorePath") .FirstOrDefault(attribute => attribute.Key == "TestPackageRestorePath")
.Value ?.Value
: Environment.GetEnvironmentVariable("NUGET_RESTORE"); : Environment.GetEnvironmentVariable("NUGET_RESTORE");
public void Dispose() public void Dispose()