Skip to content

Commit

Permalink
Further PR improvements
Browse files Browse the repository at this point in the history
- file-scoped namespaces
- Remove unneeded .gitignore lines
- using statements for HTTP objects where applicable
- small readme improvements
  • Loading branch information
andystaples committed Jan 11, 2025
1 parent d3f3328 commit eea3761
Show file tree
Hide file tree
Showing 12 changed files with 407 additions and 453 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,5 @@ functions-extensions/
/src/WebJobs.Extensions.DurableTask/Microsoft.Azure.WebJobs.Extensions.DurableTask.xml

# E2E Tests build output
/test/DotnetIsolatedE2ETests/Azure.Functions.Cli/*
/src/Worker.Extensions.DurableTask/out/*
/src/WebJobs.Extensions.DurableTask/out/*
/test/DotnetIsolatedE2ETests/azurite/*
13 changes: 6 additions & 7 deletions test/e2e/Tests/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@

using Microsoft.Extensions.Configuration;

namespace Microsoft.Azure.Durable.Tests.DotnetIsolatedE2E
namespace Microsoft.Azure.Durable.Tests.DotnetIsolatedE2E;

internal class Constants
{
internal class Constants
{
public static IConfiguration Configuration = TestUtility.GetTestConfiguration();
public static readonly IConfiguration Configuration = TestUtility.GetTestConfiguration();

internal static readonly string FunctionsHostUrl = Configuration["FunctionAppUrl"] ?? "http://localhost:7071";
internal static readonly string FunctionsHostUrl = Configuration["FunctionAppUrl"] ?? "http://localhost:7071";

internal const string FunctionAppCollectionName = "DurableTestsCollection";
}
internal const string FunctionAppCollectionName = "DurableTestsCollection";
}
98 changes: 48 additions & 50 deletions test/e2e/Tests/Fixtures/FixtureHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,72 +8,70 @@
using System.Runtime.InteropServices;
using Microsoft.Extensions.Logging;

namespace Microsoft.Azure.Durable.Tests.DotnetIsolatedE2E
namespace Microsoft.Azure.Durable.Tests.DotnetIsolatedE2E;

public static class FixtureHelpers
{
public static class FixtureHelpers
public static Process GetFuncHostProcess(string appPath, bool enableAuth = false)
{
public static Process GetFuncHostProcess(string appPath, bool enableAuth = false)
{
var cliPath = Path.Combine(Path.GetTempPath(), @"DurableTaskExtensionE2ETests/Azure.Functions.Cli/func");

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
cliPath += ".exe";
}
var cliPath = Path.Combine(Path.GetTempPath(), @"DurableTaskExtensionE2ETests/Azure.Functions.Cli/func");

if (!File.Exists(cliPath))
{
throw new InvalidOperationException($"Could not find '{cliPath}'. Try running '{Path.Combine("build-e2e-test.ps1")}' to install it.");
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
cliPath += ".exe";
}

var funcProcess = new Process();
if (!File.Exists(cliPath))
{
throw new InvalidOperationException($"Could not find '{cliPath}'. Try running '{Path.Combine("build-e2e-test.ps1")}' to install it.");
}

funcProcess.StartInfo.UseShellExecute = false;
funcProcess.StartInfo.RedirectStandardError = true;
funcProcess.StartInfo.RedirectStandardOutput = true;
funcProcess.StartInfo.CreateNoWindow = true;
funcProcess.StartInfo.WorkingDirectory = appPath;
funcProcess.StartInfo.FileName = cliPath;
funcProcess.StartInfo.ArgumentList.Add("host");
funcProcess.StartInfo.ArgumentList.Add("start");
funcProcess.StartInfo.ArgumentList.Add("--csharp");
funcProcess.StartInfo.ArgumentList.Add("--verbose");
var funcProcess = new Process();

if (enableAuth)
{
funcProcess.StartInfo.ArgumentList.Add("--enableAuth");
}
funcProcess.StartInfo.UseShellExecute = false;
funcProcess.StartInfo.RedirectStandardError = true;
funcProcess.StartInfo.RedirectStandardOutput = true;
funcProcess.StartInfo.CreateNoWindow = true;
funcProcess.StartInfo.WorkingDirectory = appPath;
funcProcess.StartInfo.FileName = cliPath;
funcProcess.StartInfo.ArgumentList.Add("host");
funcProcess.StartInfo.ArgumentList.Add("start");
funcProcess.StartInfo.ArgumentList.Add("--csharp");
funcProcess.StartInfo.ArgumentList.Add("--verbose");

return funcProcess;
if (enableAuth)
{
funcProcess.StartInfo.ArgumentList.Add("--enableAuth");
}

public static void StartProcessWithLogging(Process funcProcess, ILogger logger)
{
funcProcess.ErrorDataReceived += (sender, e) => logger.LogError(e?.Data);
funcProcess.OutputDataReceived += (sender, e) => logger.LogInformation(e?.Data);
return funcProcess;
}

funcProcess.Start();
public static void StartProcessWithLogging(Process funcProcess, ILogger logger)
{
funcProcess.ErrorDataReceived += (sender, e) => logger.LogError(e?.Data);
funcProcess.OutputDataReceived += (sender, e) => logger.LogInformation(e?.Data);

logger.LogInformation($"Started '{funcProcess.StartInfo.FileName}'");
funcProcess.Start();

funcProcess.BeginErrorReadLine();
funcProcess.BeginOutputReadLine();
}
logger.LogInformation($"Started '{funcProcess.StartInfo.FileName}'");

public static void KillExistingProcessesMatchingName(string processName)
funcProcess.BeginErrorReadLine();
funcProcess.BeginOutputReadLine();
}

public static void KillExistingProcessesMatchingName(string processName)
{
foreach (var process in Process.GetProcessesByName(processName))
{
foreach (var process in Process.GetProcessesByName(processName))
try
{
process.Kill();
}
catch
{
try
{
process.Kill();
}
catch
{
// Best effort
}
// Best effort
}
}
}
}
}
Loading

0 comments on commit eea3761

Please sign in to comment.