Skip to content
This repository has been archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
Fixed issues with getting correct deploy status with functional tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfowl committed Feb 6, 2012
1 parent 2a88bf8 commit 2d1a585
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 16 deletions.
3 changes: 0 additions & 3 deletions Kudu.Client/Deployment/RemoteDeploymentManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,7 @@ public void Stop()
{
if (_connection != null)
{
_connection.Received -= OnReceived;
_connection.Error -= OnError;
_connection.Stop();
_connection = null;
}
}

Expand Down
39 changes: 26 additions & 13 deletions Kudu.FunctionalTests/Infrastructure/ApplicationManagerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
using System.Threading;
using System.Threading.Tasks;
using Kudu.Client.Deployment;
using Kudu.Core.Deployment;
using Xunit;

namespace Kudu.FunctionalTests.Infrastructure
{
public static class ApplicationManagerExtensions
{
private static readonly TimeSpan _defaultTimeOut = TimeSpan.FromMinutes(3);
private static bool _errorCallbackInitialized;
private static readonly TimeSpan _defaultTimeOut = TimeSpan.FromMinutes(5);
private static int _errorCallbackInitialized;

public static void GitDeploy(this ApplicationManager appManager, string repositoryName)
{
Expand All @@ -35,22 +36,30 @@ public static void WaitForDeployment(this RemoteDeploymentManager deploymentMana
{
var deployEvent = new ManualResetEvent(false);

if (!_errorCallbackInitialized)
Action<DeployResult> handler = null;

handler = status =>
{
if (status.Complete)
{
if (Interlocked.Exchange(ref handler, null) != null)
{
deploymentManager.Stop();
deploymentManager.StatusChanged -= handler;
deployEvent.Set();
}
}
};

if (Interlocked.Exchange(ref _errorCallbackInitialized, 1) == 0)
{
_errorCallbackInitialized = true;
TaskScheduler.UnobservedTaskException += OnUnobservedTaskException;
}

try
{
// Create deployment manager and wait for the deployment to finish
deploymentManager.StatusChanged += status =>
{
if (status.Complete)
{
deployEvent.Set();
}
};
deploymentManager.StatusChanged += handler;

// Start listenting for events
deploymentManager.Start();
Expand All @@ -67,8 +76,12 @@ public static void WaitForDeployment(this RemoteDeploymentManager deploymentMana
}
finally
{
// Stop listenting
deploymentManager.Stop();
if (Interlocked.Exchange(ref handler, null) != null)
{
deploymentManager.StatusChanged -= handler;
// Stop listenting
deploymentManager.Stop();
}
}
}

Expand Down

0 comments on commit 2d1a585

Please sign in to comment.