From 61cffbd71179c05a176e44ff19b24ad92ca76713 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Wed, 12 Aug 2020 14:46:13 +1200 Subject: [PATCH 1/6] Fix gRPC interop tests --- src/Grpc/test/testassets/InteropClient/InteropClient.cs | 5 +++-- src/Grpc/test/testassets/InteropWebsite/Program.cs | 3 ++- src/Shared/Process/ProcessEx.cs | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/Grpc/test/testassets/InteropClient/InteropClient.cs b/src/Grpc/test/testassets/InteropClient/InteropClient.cs index d6b47ab24139..5d5794094801 100644 --- a/src/Grpc/test/testassets/InteropClient/InteropClient.cs +++ b/src/Grpc/test/testassets/InteropClient/InteropClient.cs @@ -34,6 +34,7 @@ using Grpc.Testing; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Console; using Newtonsoft.Json.Linq; namespace InteropTestsClient @@ -96,11 +97,11 @@ private InteropClient(ClientOptions options) var services = new ServiceCollection(); services.AddLogging(configure => { - configure.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace); + configure.SetMinimumLevel(LogLevel.Trace); configure.AddSimpleConsole(loggerOptions => { loggerOptions.IncludeScopes = true; - loggerOptions.DisableColors = true; + loggerOptions.ColorBehavior = LoggerColorBehavior.Disabled; }); }); diff --git a/src/Grpc/test/testassets/InteropWebsite/Program.cs b/src/Grpc/test/testassets/InteropWebsite/Program.cs index 3efd0d647c91..262034add8ae 100644 --- a/src/Grpc/test/testassets/InteropWebsite/Program.cs +++ b/src/Grpc/test/testassets/InteropWebsite/Program.cs @@ -23,6 +23,7 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Logging.Console; namespace InteropTestsWebsite { @@ -37,7 +38,7 @@ public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureLogging(builder => { - builder.AddSimpleConsole(o => o.DisableColors = true); + builder.AddSimpleConsole(o => o.ColorBehavior = LoggerColorBehavior.Disabled); builder.SetMinimumLevel(LogLevel.Trace); }) .ConfigureWebHostDefaults(webBuilder => diff --git a/src/Shared/Process/ProcessEx.cs b/src/Shared/Process/ProcessEx.cs index ad7d06b1ede3..e263abb6a295 100644 --- a/src/Shared/Process/ProcessEx.cs +++ b/src/Shared/Process/ProcessEx.cs @@ -218,8 +218,8 @@ public void WaitForExit(bool assertSuccess, TimeSpan? timeSpan = null) private static string GetNugetPackagesRestorePath() => (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("NUGET_RESTORE"))) ? typeof(ProcessEx).Assembly .GetCustomAttributes() - .First(attribute => attribute.Key == "TestPackageRestorePath") - .Value + .FirstOrDefault(attribute => attribute.Key == "TestPackageRestorePath") + ?.Value : Environment.GetEnvironmentVariable("NUGET_RESTORE"); public void Dispose() From f6a22bfc024a1592da6004455a5548e75ac83616 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Thu, 13 Aug 2020 08:06:00 +1200 Subject: [PATCH 2/6] Enable on helix --- src/Grpc/test/InteropTests/InteropTests.csproj | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Grpc/test/InteropTests/InteropTests.csproj b/src/Grpc/test/InteropTests/InteropTests.csproj index 24d479432b09..9f9c4e67523e 100644 --- a/src/Grpc/test/InteropTests/InteropTests.csproj +++ b/src/Grpc/test/InteropTests/InteropTests.csproj @@ -4,8 +4,7 @@ true $(DefaultNetCoreTargetFramework) - - false + true From f0e645cfc41b98ccd1d67e6507d326f7ae982632 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Thu, 13 Aug 2020 08:25:10 +1200 Subject: [PATCH 3/6] PR feedback --- src/Grpc/test/InteropTests/InteropTests.csproj | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Grpc/test/InteropTests/InteropTests.csproj b/src/Grpc/test/InteropTests/InteropTests.csproj index 9f9c4e67523e..bcbd1fc4b6ab 100644 --- a/src/Grpc/test/InteropTests/InteropTests.csproj +++ b/src/Grpc/test/InteropTests/InteropTests.csproj @@ -3,8 +3,6 @@ true $(DefaultNetCoreTargetFramework) - - true From dcd65b02ea67a1a9f33d11c606e6469e8a3f15cf Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Thu, 13 Aug 2020 10:09:25 +1200 Subject: [PATCH 4/6] Don't disable colors. Report runtime version --- src/Grpc/test/testassets/InteropClient/InteropClient.cs | 3 --- src/Grpc/test/testassets/InteropClient/Program.cs | 4 ++++ src/Grpc/test/testassets/InteropWebsite/Program.cs | 3 +-- src/Grpc/test/testassets/InteropWebsite/Startup.cs | 9 ++++++++- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Grpc/test/testassets/InteropClient/InteropClient.cs b/src/Grpc/test/testassets/InteropClient/InteropClient.cs index 5d5794094801..7ec2a4079142 100644 --- a/src/Grpc/test/testassets/InteropClient/InteropClient.cs +++ b/src/Grpc/test/testassets/InteropClient/InteropClient.cs @@ -29,12 +29,10 @@ using Google.Protobuf; using Grpc.Auth; using Grpc.Core; -using Grpc.Core.Utils; using Grpc.Net.Client; using Grpc.Testing; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Console; using Newtonsoft.Json.Linq; namespace InteropTestsClient @@ -101,7 +99,6 @@ private InteropClient(ClientOptions options) configure.AddSimpleConsole(loggerOptions => { loggerOptions.IncludeScopes = true; - loggerOptions.ColorBehavior = LoggerColorBehavior.Disabled; }); }); diff --git a/src/Grpc/test/testassets/InteropClient/Program.cs b/src/Grpc/test/testassets/InteropClient/Program.cs index 3fc3d9d9757d..52eee5640a3a 100644 --- a/src/Grpc/test/testassets/InteropClient/Program.cs +++ b/src/Grpc/test/testassets/InteropClient/Program.cs @@ -17,6 +17,7 @@ #endregion using System; +using System.Reflection; namespace InteropTestsClient { @@ -26,6 +27,9 @@ public static void Main(string[] args) { Console.WriteLine("Application started."); + var runtimeVersion = typeof(object).GetTypeInfo().Assembly.GetCustomAttribute()?.InformationalVersion ?? "Unknown"; + Console.WriteLine($"NetCoreAppVersion: {runtimeVersion}"); + InteropClient.Run(args); } } diff --git a/src/Grpc/test/testassets/InteropWebsite/Program.cs b/src/Grpc/test/testassets/InteropWebsite/Program.cs index 262034add8ae..81a23ede9f58 100644 --- a/src/Grpc/test/testassets/InteropWebsite/Program.cs +++ b/src/Grpc/test/testassets/InteropWebsite/Program.cs @@ -23,7 +23,6 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Console; namespace InteropTestsWebsite { @@ -38,7 +37,7 @@ public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureLogging(builder => { - builder.AddSimpleConsole(o => o.ColorBehavior = LoggerColorBehavior.Disabled); + builder.AddSimpleConsole(); builder.SetMinimumLevel(LogLevel.Trace); }) .ConfigureWebHostDefaults(webBuilder => diff --git a/src/Grpc/test/testassets/InteropWebsite/Startup.cs b/src/Grpc/test/testassets/InteropWebsite/Startup.cs index 4715d1fbbca4..6f335d6c0590 100644 --- a/src/Grpc/test/testassets/InteropWebsite/Startup.cs +++ b/src/Grpc/test/testassets/InteropWebsite/Startup.cs @@ -17,6 +17,7 @@ #endregion using System; +using System.Reflection; using Grpc.Testing; using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.DependencyInjection; @@ -37,7 +38,13 @@ public void ConfigureServices(IServiceCollection services) public void Configure(IApplicationBuilder app, IHostApplicationLifetime applicationLifetime) { // 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()?.InformationalVersion ?? "Unknown"; + Console.WriteLine($"NetCoreAppVersion: {runtimeVersion}"); + }); app.UseRouting(); app.UseEndpoints(endpoints => From 25d6851c2976cebdad14bc2821586b31f8cfc2e5 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Thu, 13 Aug 2020 13:42:58 +1200 Subject: [PATCH 5/6] Just use regular console --- src/Grpc/test/testassets/InteropClient/InteropClient.cs | 2 +- src/Grpc/test/testassets/InteropWebsite/Program.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Grpc/test/testassets/InteropClient/InteropClient.cs b/src/Grpc/test/testassets/InteropClient/InteropClient.cs index 7ec2a4079142..774a487992df 100644 --- a/src/Grpc/test/testassets/InteropClient/InteropClient.cs +++ b/src/Grpc/test/testassets/InteropClient/InteropClient.cs @@ -96,7 +96,7 @@ private InteropClient(ClientOptions options) services.AddLogging(configure => { configure.SetMinimumLevel(LogLevel.Trace); - configure.AddSimpleConsole(loggerOptions => + configure.AddConsole(loggerOptions => { loggerOptions.IncludeScopes = true; }); diff --git a/src/Grpc/test/testassets/InteropWebsite/Program.cs b/src/Grpc/test/testassets/InteropWebsite/Program.cs index 81a23ede9f58..e160254f5d7f 100644 --- a/src/Grpc/test/testassets/InteropWebsite/Program.cs +++ b/src/Grpc/test/testassets/InteropWebsite/Program.cs @@ -37,7 +37,7 @@ public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureLogging(builder => { - builder.AddSimpleConsole(); + builder.AddConsole(); builder.SetMinimumLevel(LogLevel.Trace); }) .ConfigureWebHostDefaults(webBuilder => From 7c5f3605d04db9c1afcacd88f71edaa80f5a0489 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Thu, 13 Aug 2020 15:25:03 +1200 Subject: [PATCH 6/6] Blah --- src/Grpc/test/testassets/InteropClient/InteropClient.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Grpc/test/testassets/InteropClient/InteropClient.cs b/src/Grpc/test/testassets/InteropClient/InteropClient.cs index 774a487992df..91ce76153820 100644 --- a/src/Grpc/test/testassets/InteropClient/InteropClient.cs +++ b/src/Grpc/test/testassets/InteropClient/InteropClient.cs @@ -98,7 +98,9 @@ private InteropClient(ClientOptions options) configure.SetMinimumLevel(LogLevel.Trace); configure.AddConsole(loggerOptions => { +#pragma warning disable CS0618 // Type or member is obsolete loggerOptions.IncludeScopes = true; +#pragma warning restore CS0618 // Type or member is obsolete }); });