Skip to content
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

Set BridgeResourceFolder at Bridge startup #337

Merged
merged 2 commits into from
Sep 16, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Improved Bridge.exe console output to aid debugging
  • Loading branch information
roncain committed Sep 16, 2015
commit 26c08b12b67924ff771bd390b2da8eb491d1fe23
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ setlocal

echo BridgeKeepRunning=%BridgeKeepRunning%
if '%BridgeKeepRunning%' neq 'true' (
echo Stopping the Bridge...
echo Releasing Bridge resources and stopping it if running locally.
pushd %~dp0..\..\..\..\bin\wcf\tools\Bridge
echo Invoking Bridge.exe -stopIfLocal -reset %* ...
call Bridge.exe -stopIfLocal -reset %*
popd
) else (
echo Releasing Bridge resources but leaving it running...
echo Releasing Bridge resources but leaving it running.
pushd %~dp0..\..\..\..\bin\wcf\tools\Bridge
echo Invoking Bridge.exe -reset %* ...
call Bridge.exe -reset %*
popd
echo The Bridge was left running because BridgeKeepRunning is true
Copy link
Member

Choose a reason for hiding this comment

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

IIRC, CleanupWcfTestService.cmd is called immediately after a run happens. Do we necessarily want to get rid of all resources that the bridge is holding?

My flow of work is typically the following:

  • run startBridge.cmd
  • run build.cmd to look at what's wrong
  • make changes
  • rebuild.

Sometimes, in the "rebuild" step I run build.cmd, other times I build the project and test directly.
My suspicion is that if someone has left the bridge running, we should probably leave any resources opened alone, and rely on the developer to either exit the Bridge or call reset manually

Copy link
Contributor Author

Choose a reason for hiding this comment

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

CleanupWcfTestService.cmd is the script called to clean up all resources -- that's its purpose. In this case, cleanup means remove all certs and firewall rules created, shutdown the AppDomains, and continue running. The Bridge will reacquire resources the next time it receives requests.

I think it is fairly critical that after a run all DLL's loaded from the BridgeResourceFolder be released, otherwise the build will fail because it cannot write the new DLL's into the BridgeResourceFolder. I think asking the developer to do an explicit 'reset' is just going to lead to confusing build failures.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
using WcfTestBridgeCommon;

namespace Bridge
Expand All @@ -21,8 +22,8 @@ private static void Main(string[] args)
{
CommandLineArguments commandLineArgs = new CommandLineArguments(args);

Console.WriteLine("Specified BridgeConfiguration is:{0}{1}",
Environment.NewLine, commandLineArgs.BridgeConfiguration.ToString());
Console.WriteLine("Bridge.exe was launched with:{0}{1}",
Environment.NewLine, commandLineArgs.ToString());

// If asked to ping (not the default), just ping and return an exit code indicating its state
if (commandLineArgs.Ping)
Expand Down Expand Up @@ -72,7 +73,7 @@ private static bool PingBridge(string host, int port, out string errorMessage)

using (HttpClient httpClient = new HttpClient())
{
Console.WriteLine("Testing Bridge at {0}", bridgeUrl);
Console.WriteLine("Pinging the Bridge by issuing GET request to {0}", bridgeUrl);
try
{
var response = httpClient.GetAsync(bridgeUrl).GetAwaiter().GetResult();
Expand Down Expand Up @@ -137,7 +138,7 @@ private static void StopBridge(CommandLineArguments commandLineArgs)
// in a different process on this machine.
using (HttpClient httpClient = new HttpClient())
{
Console.WriteLine("Stopping Bridge at {0}", bridgeUrl);
Console.WriteLine("Stopping the Bridge by issuing DELETE request to {0}", bridgeUrl);
try
{
var response = httpClient.DeleteAsync(bridgeUrl).GetAwaiter().GetResult();
Expand Down Expand Up @@ -195,10 +196,11 @@ private static void ResetBridge(CommandLineArguments commandLineArgs)
string bridgeUrl = String.Format("http://{0}:{1}/Resource", commandLineArgs.BridgeConfiguration.BridgeHost, commandLineArgs.BridgeConfiguration.BridgePort);
string problem = null;

Console.WriteLine("Resetting the Bridge by sending DELETE request to {0}", bridgeUrl);

// We reset the Bridge using a DELETE request to the /resource endpoint.
using (HttpClient httpClient = new HttpClient())
{
Console.WriteLine("Stopping Bridge at {0}", bridgeUrl);
try
{
var response = httpClient.DeleteAsync(bridgeUrl).GetAwaiter().GetResult();
Expand Down Expand Up @@ -372,6 +374,21 @@ public CommandLineArguments(string[] args)
public bool StopIfLocal { get; private set; }
public bool Reset { get; private set; }

public override string ToString()
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("Options are:")
.AppendLine(String.Format(" -allowRemote = {0}", AllowRemote))
.AppendLine(String.Format(" -remoteAddresses = {0}", RemoteAddresses))
.AppendLine(String.Format(" -ping = {0}", Ping))
.AppendLine(String.Format(" -stop = {0}", Stop))
.AppendLine(String.Format(" -stopIfLocal = {0}", StopIfLocal))
.AppendLine(String.Format(" -reset = {0}", Reset))
.AppendLine(String.Format("BridgeConfiguration is:{0}{1}",
Environment.NewLine, BridgeConfiguration.ToString()));
return sb.ToString();
}

private bool Parse(string[] args)
{
// Build a dictionary of all command line arguments.
Expand Down