Skip to content

Commit

Permalink
Test Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
raquelsa committed Feb 6, 2012
1 parent 4e852fe commit 7c07762
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 358 deletions.
396 changes: 44 additions & 352 deletions Kudu.FunctionalTests/GitDeploymentTests.cs

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Kudu.FunctionalTests/Infrastructure/ApplicationManager.cs
Expand Up @@ -91,9 +91,9 @@ public static ApplicationManager CreateApplication(string applicationName)
{
siteManager.DeleteSite(applicationName);
}
catch (Exception ex)
catch (System.ServiceModel.EndpointNotFoundException ex)
{
Debug.WriteLine(ex.Message);

}

Site site = siteManager.CreateSite(applicationName);
Expand Down
Expand Up @@ -4,12 +4,15 @@
using System.Threading.Tasks;
using Kudu.Client.Deployment;
using Xunit;
using System.Net.Http;
using System.Net;
using System.Configuration;

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

public static void GitDeploy(this ApplicationManager appManager, string repositoryName)
Expand All @@ -21,6 +24,8 @@ public static void GitDeploy(this ApplicationManager appManager, string reposito
{
appManager.DeploymentManager.WaitForDeployment(() =>
{
WaitForRepositorySite(appManager);
Git.Push(repositoryName, appManager.GitUrl);
},
waitTimeout);
Expand Down Expand Up @@ -72,6 +77,40 @@ public static void WaitForDeployment(this RemoteDeploymentManager deploymentMana
}
}

private static void WaitForRepositorySite(ApplicationManager appManager, int retries = 3, int delayBeforeRetry = 250)
{
HttpClientHandler handler = new HttpClientHandler();
if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings["antares.basedomain"]))
{
string userName = ConfigurationManager.AppSettings["antares.username"];
handler.UseDefaultCredentials = false;
handler.Credentials = new NetworkCredential(userName, userName);
}

HttpClient client = new HttpClient(handler);

while (retries > 0)
{
try
{
var response = client.GetAsync(appManager.ServiceUrl).Result;
if (response.StatusCode == HttpStatusCode.OK)
{
break;
}
}
catch
{
if (retries == 0)
{
throw;
}
}
retries--;
Thread.Sleep(delayBeforeRetry);
}
}

private static void OnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
{
Debug.WriteLine(e.Exception.GetBaseException().ToString());
Expand Down
1 change: 1 addition & 0 deletions Kudu.FunctionalTests/Infrastructure/PathHelper.cs
Expand Up @@ -14,6 +14,7 @@ internal static class PathHelper
internal static readonly string LocalRepositoriesDir = Path.GetFullPath(Path.Combine(TestsRootPath, "TestRepositories"));
internal static readonly string TestResultsPath = Path.GetFullPath(Path.Combine(Directory.GetCurrentDirectory(), "TestResults"));
internal static readonly string ZippedRepositoriesDir = Path.Combine(@"..\..\ZippedRepositories");
internal static readonly string GitDeploymentTestsFile = Path.Combine(@"..\..\GitDeploymentTests.csv");

}
}
12 changes: 11 additions & 1 deletion Kudu.FunctionalTests/Kudu.FunctionalTests.csproj
Expand Up @@ -33,6 +33,9 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="CsvHelper">
<HintPath>..\packages\CsvHelper.1.1.2\lib\net20\CsvHelper.dll</HintPath>
</Reference>
<Reference Include="Ionic.Zip">
<HintPath>..\packages\DotNetZip.1.9.1.8\lib\net20\Ionic.Zip.dll</HintPath>
</Reference>
Expand All @@ -54,6 +57,7 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Data.Entity" />
<Reference Include="System.Net.Http">
Expand All @@ -73,8 +77,13 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\xunit.1.9.0.1566\lib\xunit.dll</HintPath>
</Reference>
<Reference Include="xunit.extensions">
<HintPath>..\packages\xunit.extensions.1.9.0.1566\lib\xunit.extensions.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="GitRepositoryManagementTests.cs" />
<Compile Include="Infrastructure\GitTestConfig.cs" />
<Compile Include="Infrastructure\ApplicationManager.cs" />
<Compile Include="Infrastructure\ApplicationManagerExtensions.cs" />
<Compile Include="Infrastructure\Git.cs" />
Expand All @@ -86,10 +95,11 @@
<Compile Include="GitDeploymentTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="GitDeploymentTests.csv" />
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
<None Include="ZippedRepositories\Bakery2.zip" />
<None Include="ZippedRepositories\Bakery10.zip" />
<None Include="ZippedRepositories\Mvc3Application.zip" />
<None Include="ZippedRepositories\Mvc3Application_NoSolution.zip" />
</ItemGroup>
Expand Down
Binary file removed Kudu.FunctionalTests/ZippedRepositories/Bakery2.zip
Binary file not shown.
2 changes: 2 additions & 0 deletions Kudu.FunctionalTests/packages.config
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CsvHelper" version="1.1.2" />
<package id="DotNetZip" version="1.9.1.8" />
<package id="HttpClient" version="0.6.0" />
<package id="JsonValue" version="0.6.0" />
<package id="xunit" version="1.9.0.1566" />
<package id="xunit.extensions" version="1.9.0.1566" />
</packages>
15 changes: 13 additions & 2 deletions Kudu.Performance/app.config
@@ -1,3 +1,14 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="xunit" publicKeyToken="8d05b1bb7a6fdb6c" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.8.0.1549" newVersion="1.8.0.1549" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

0 comments on commit 7c07762

Please sign in to comment.