Skip to content
This repository has been archived by the owner on Dec 19, 2018. It is now read-only.

Add test logging helpers to Hosting #1005

Merged
merged 16 commits into from Apr 6, 2017
Merged

Add test logging helpers to Hosting #1005

merged 16 commits into from Apr 6, 2017

Conversation

analogrelay
Copy link
Contributor

@analogrelay analogrelay commented Apr 4, 2017

These are based off the ones in ServerTests. Now that I've seen them at work, I want to add these to Entropy because we're seeing some hanging tests, but I don't want copy-pasta so I figured I'd make it common in Hosting.

I do plan to make this even more low-impact by adding some xunit extensibility to make it "magic", but I don't want to do that until I've worked out the logging process on a few tests.

There's a particular spot in here I'm not so proud of, but very open to suggestions ;). See if you can spot it!

Note: At some point I plan to pull this to somewhere even more common (Common?) in order to be able to use it in all our tests. Also, I plan to use some xunit hooks to avoid some of the boilerplate.

<PackageReference Include="Microsoft.Extensions.PlatformAbstractions" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.Extensions.Process.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.RuntimeEnvironment.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
<PackageReference Include="Microsoft.NETCore.Windows.ApiSets" Version="$(WindowsApiSetsVersion)" />
<PackageReference Include="Serilog.Extensions.Logging" Version="1.4.0" />
<PackageReference Include="Serilog.Sinks.File" Version="3.2.0" />
Copy link
Member

Choose a reason for hiding this comment

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

Does @Eilon know you're using these versions

Copy link
Member

Choose a reason for hiding this comment

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

Even these dependency versions go in the dependencies.props

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, they were in the original ServerTests code that this is ported from.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Eilon sorry if they need to be re-submitted when moved like this.

Copy link
Member

Choose a reason for hiding this comment

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

From an OSS perspective if it's the same version it's fine.

From a product perspective, make sure the lead/PM.architect for this area agrees that adding these dependencies makes sense (because it affects everyone using the package, of course).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes total sense. This is an internal (noship) package, so the impact should be minimal.

@@ -5,7 +5,7 @@
<PropertyGroup>
<Description>ASP.NET Core helpers to deploy applications to IIS Express, IIS, WebListener and Kestrel for testing.</Description>
<VersionPrefix>0.4.0</VersionPrefix>
<TargetFrameworks>net46;netstandard1.3</TargetFrameworks>
<TargetFrameworks>net46;netstandard1.5</TargetFrameworks>
Copy link
Member

Choose a reason for hiding this comment

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

What did you need from 1.5?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Assembly.GetEntryAssembly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And since these are only used in tests which target netcoreapp1.1 and we don't ship the package, this is a fully compatible change (though I will be confirming that before merging)

@@ -0,0 +1,153 @@
using System;
Copy link
Contributor

Choose a reason for hiding this comment

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

Copyright

@analogrelay
Copy link
Contributor Author

analogrelay commented Apr 6, 2017

🆙 📅 (and one that adds new reviewable code) - ServerTests also had an HttpClient handler that logged requests which seemed very useful for testing. I moved it to this repo and added a way to ensure that tests can always get an HttpClient with LoggingHandler, pointed at the deployed site.

These changes came up as I was testing ServerTests with this new package. They aren't necessary to merge, but remove more duplicate code :)

analogrelay added a commit to aspnet/ServerTests that referenced this pull request Apr 6, 2017
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
_logger.LogDebug("Sending {method} {url}", request.Method, request.RequestUri);
var response = await base.SendAsync(request, cancellationToken);
Copy link
Member

Choose a reason for hiding this comment

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

try/catch/logexception/throw?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, not a bad idea at all :)

analogrelay added a commit to aspnet/IISIntegration that referenced this pull request Apr 6, 2017
analogrelay added a commit to aspnet/Entropy that referenced this pull request Apr 6, 2017
analogrelay added a commit to aspnet/MusicStore that referenced this pull request Apr 6, 2017
@analogrelay analogrelay merged commit 1ae1ff0 into dev Apr 6, 2017
analogrelay added a commit to aspnet/ServerTests that referenced this pull request Apr 6, 2017
analogrelay added a commit to aspnet/IISIntegration that referenced this pull request Apr 6, 2017
analogrelay added a commit to aspnet/Entropy that referenced this pull request Apr 6, 2017
analogrelay added a commit to aspnet/MusicStore that referenced this pull request Apr 6, 2017
@analogrelay analogrelay deleted the anurse/test-logging branch April 6, 2017 22:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants