-
Notifications
You must be signed in to change notification settings - Fork 491
fix: fix unit and integ tests hanging #1954
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.IO.Compression; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Amazon.Lambda.TestTool.UnitTests.Utilities; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Amazon.Lambda.TestTool.UnitTests; | ||
|
||
public class PackagingTests | ||
public class PackagingTests : IDisposable | ||
{ | ||
private readonly ITestOutputHelper _output; | ||
private readonly string[] _expectedFrameworks; | ||
private readonly string _workingDirectory; | ||
|
||
public PackagingTests(ITestOutputHelper output) | ||
{ | ||
_output = output; | ||
var solutionRoot = FindSolutionRoot(); | ||
_workingDirectory = DirectoryHelpers.GetTempTestAppDirectory(solutionRoot); | ||
_expectedFrameworks = GetRuntimeSupportTargetFrameworks() | ||
.Split([';'], StringSplitOptions.RemoveEmptyEntries) | ||
.Where(f => f != "netstandard2.0") | ||
|
@@ -25,8 +25,8 @@ public PackagingTests(ITestOutputHelper output) | |
|
||
private string GetRuntimeSupportTargetFrameworks() | ||
{ | ||
var solutionRoot = FindSolutionRoot(); | ||
var runtimeSupportPath = Path.Combine(solutionRoot, "Libraries", "src", "Amazon.Lambda.RuntimeSupport", "Amazon.Lambda.RuntimeSupport.csproj"); | ||
Console.WriteLine("Getting the expected list of target frameworks..."); | ||
var runtimeSupportPath = Path.Combine(_workingDirectory, "Libraries", "src", "Amazon.Lambda.RuntimeSupport", "Amazon.Lambda.RuntimeSupport.csproj"); | ||
|
||
var process = new Process | ||
{ | ||
|
@@ -44,8 +44,10 @@ private string GetRuntimeSupportTargetFrameworks() | |
process.Start(); | ||
var output = process.StandardOutput.ReadToEnd(); | ||
var error = process.StandardError.ReadToEnd(); | ||
process.WaitForExit(); | ||
process.WaitForExit(int.MaxValue); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The int.MaxValue is used to workaround a microsoft bug. We don't actually intend to wait that long. We use it in other repos. Sometimes the process hangs, and when we pass |
||
Console.WriteLine(output); | ||
Console.WriteLine(error); | ||
if (process.ExitCode != 0) | ||
{ | ||
throw new Exception($"Failed to get TargetFrameworks: {error}"); | ||
|
@@ -54,11 +56,14 @@ private string GetRuntimeSupportTargetFrameworks() | |
return output.Trim(); | ||
} | ||
|
||
#if DEBUG | ||
[Fact] | ||
#else | ||
[Fact(Skip = "Skipping this test as it is not working properly.")] | ||
#endif | ||
public void VerifyPackageContentsHasRuntimeSupport() | ||
{ | ||
var solutionRoot = FindSolutionRoot(); | ||
var projectPath = Path.Combine(solutionRoot, "Tools", "LambdaTestTool-v2", "src", "Amazon.Lambda.TestTool", "Amazon.Lambda.TestTool.csproj"); | ||
var projectPath = Path.Combine(_workingDirectory, "Tools", "LambdaTestTool-v2", "src", "Amazon.Lambda.TestTool", "Amazon.Lambda.TestTool.csproj"); | ||
|
||
_output.WriteLine("\nPacking TestTool..."); | ||
var packProcess = new Process | ||
|
@@ -77,7 +82,7 @@ public void VerifyPackageContentsHasRuntimeSupport() | |
packProcess.Start(); | ||
string packOutput = packProcess.StandardOutput.ReadToEnd(); | ||
string packError = packProcess.StandardError.ReadToEnd(); | ||
packProcess.WaitForExit(); | ||
packProcess.WaitForExit(int.MaxValue); | ||
|
||
This conversation was marked as resolved.
Show resolved
Hide resolved
|
||
_output.WriteLine("Pack Output:"); | ||
_output.WriteLine(packOutput); | ||
|
@@ -137,6 +142,7 @@ public void VerifyPackageContentsHasRuntimeSupport() | |
|
||
private string FindSolutionRoot() | ||
{ | ||
Console.WriteLine("Looking for solution root..."); | ||
string currentDirectory = Directory.GetCurrentDirectory(); | ||
while (currentDirectory != null) | ||
{ | ||
|
@@ -149,4 +155,9 @@ private string FindSolutionRoot() | |
} | ||
throw new Exception("Could not find the aws-lambda-dotnet root directory."); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
DirectoryHelpers.CleanUp(_workingDirectory); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +0,0 @@ | ||
|
||
[assembly: Xunit.CollectionBehavior(DisableTestParallelization = true)] | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we update this to something like https://github.com/aws/aws-lambda-dotnet/pull/1955/files#diff-16dac3e7db3ba4a144e7ac3063ba31b74a53037cb85cc1a5e35410efb0d6393dR311? the reason being is depending on the developers machine/codebuild machine, the above ports may not actually be free. I think we should use
TcpListener
for the OS to give us free portsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point of the change I'm making is so we can atomically check what the next port is that other tests are not using. I believe the TcpListener is a bit overkill as these port ranges are always free in the CI. Even on our machines, these ports are usually not used.