Skip to content

Commit

Permalink
Refactored test
Browse files Browse the repository at this point in the history
  • Loading branch information
droyad committed Jul 18, 2017
1 parent 74204e8 commit d558e2d
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions IntegrationTests/RunTests.csx
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,28 @@ var endpoints = from m in repository.Machines.FindAll()

var sw = Stopwatch.StartNew();

foreach (var e in endpoints)
void TestEndpoint(SshEndpointResource ssh)
{
var url = $"http://{e.Host}:7000/20/50";

while(true)
var url = $"http://{ssh.Host}:7000/20/50";
while (sw.Elapsed < TimeSpan.FromMinutes(1))
try
{
if(sw.Elapsed > TimeSpan.FromMinutes(1))
throw new Exception("Execution timed out");

Console.WriteLine($"Requesting {url}");

using(var response = WebRequest.CreateHttp(url).GetResponse())
using (var response = WebRequest.CreateHttp(url).GetResponse())
using (var s = new StreamReader(response.GetResponseStream()))
Console.WriteLine("Got " + s.ReadToEnd());

return;
}
catch (WebException ex)
{
Console.WriteLine("Error: " + ex.Message);
Thread.Sleep(TimeSpan.FromSeconds(10));
}
throw new Exception("Execution timed out");
}

foreach (var e in endpoints)
TestEndpoint(e);

0 comments on commit d558e2d

Please sign in to comment.