Skip to content

Commit

Permalink
Merge pull request #1 from akselsson/verify-allow-folder
Browse files Browse the repository at this point in the history
Verify integration tests use web site unit
  • Loading branch information
Korla committed May 19, 2021
2 parents dcc8f95 + 1d88485 commit 441513e
Show file tree
Hide file tree
Showing 11 changed files with 3,699 additions and 270 deletions.

This file was deleted.

Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,33 @@ Remove-WebAppPool -Name \"${SiteName}AppPool\"
"Install": "install-site.ps1 $SiteName $SiteUrl",
"Uninstall": "uninstall-site.ps1 $SiteName"
}
},
{
"Name": "Asimov.Web.Example.With.Verify",
"Type": "WebSite",
"SiteName": "Asimov.Web.Example.With.Verify",
"SiteUrl": "http://localhost:9124",

"PackageInfo": { "Source": "Test" },

"Installable": {
"TargetPath": "%DATA_FOLDER%\\WebTarget",

"Install": "install-site.ps1 $SiteName $SiteUrl",
"Uninstall": "uninstall-site.ps1 $SiteName"
},
"Actions": {
"Verify1": {
"Type": "VerifyCommand",
"ZipPath": "verify.folder",
"Command": "script.bat"
},
"Verify2": {
"Type": "VerifyCommand",
"ZipPath": "verify.zip",
"Command": "script.bat"
}
}
}


Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,14 @@
namespace AsimovDeploy.WinAgent.IntegrationTests.Scenarios.WebScenario
{
[TestFixture]
public class WebFromScriptScenario : WinAgentSystemTest
public class WebFromScriptScenario : WebScenarioBase
{
private const string ServiceName = "Asimov.Web.Example.From.Script";

public override void Given()
{
GivenFoldersForScenario();
GivenRunningAgent();
EnsureServiceIsNotInstalled();
}

[TearDown]
public void AfterEach()
{
EnsureServiceIsNotInstalled();
}

private void EnsureServiceIsNotInstalled()
{
var units = Agent.Get<List<DeployUnitInfoDTO>>("/units/list");
if (units[1].status == "NotFound")
{
return;
}
Agent.Post("/action",NodeFront.ApiKey, new UnitActionCommand()
{
actionName = "Uninstall",
unitName = ServiceName
});
WaitForStatus("NotFound");
while (Process.GetProcesses().Any(x => x.ProcessName == "Asimov.Roundhouse.Example"))
{
Thread.Sleep(TimeSpan.FromSeconds(0.5));
}
}
protected override string ServiceName => "Asimov.Web.Example.From.Script";

[Test]
public void can_get_deploy_units()
{
var units = Agent.Get<List<DeployUnitInfoDTO>>("/units/list");
units.Count.ShouldBe(2);
units[1].name.ShouldBe(ServiceName);
units[1].status.ShouldBe("NotFound");
units[1].type.ShouldBe(DeployUnitTypes.WebSite);
Expand All @@ -65,51 +32,9 @@ public void installs_service_on_deploy()
InstallService();

var units = Agent.Get<List<DeployUnitInfoDTO>>("/units/list");
units.Count.ShouldBe(2);
units[1].name.ShouldBe(ServiceName);
units[1].status.ShouldBe("Running");
units[1].type.ShouldBe(DeployUnitTypes.WebSite);
}

private void InstallService()
{
var versions = Agent.Get<List<DeployUnitVersionDTO>>($"/versions/{ServiceName}");
versions.Count.ShouldBe(1);

Agent.Post("/deploy/deploy", NodeFront.ApiKey, new DeployCommand
{
unitName = ServiceName,
versionId = versions[0].id,
parameters = new Dictionary<string, object>() {
{
"Port", "8145"
} }
});

WaitForStatus("Running");
}

private void WaitForStatus(string expectedStatus)
{
var start = DateTime.Now;
var timeout = TimeSpan.FromSeconds(10);
var duration = DateTime.Now - start;
var status = "";

do
{
duration = DateTime.Now - start;
var units = Agent.Get<List<DeployUnitInfoDTO>>("/units/list");
units.Count.ShouldBe(2);
status = units[1].status;
if (status == expectedStatus)
{
return;
}
} while (duration < timeout);

Assert.Fail($"Failed to go to correct status, was {status} expected {expectedStatus}");

}
}
}
Original file line number Diff line number Diff line change
@@ -1,59 +1,21 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Collections.Generic;
using AsimovDeploy.WinAgent.Framework.Configuration;
using AsimovDeploy.WinAgent.Framework.Models;
using AsimovDeploy.WinAgent.Web.Commands;
using AsimovDeploy.WinAgent.Web.Contracts;
using NUnit.Framework;
using Shouldly;

namespace AsimovDeploy.WinAgent.IntegrationTests.Scenarios.WebScenario
{
[TestFixture]
public class WebScenario : WinAgentSystemTest
public class WebScenario : WebScenarioBase
{
private const string ServiceName = "Asimov.Web.Example";

public override void Given()
{
GivenFoldersForScenario();
GivenRunningAgent();
EnsureServiceIsNotInstalled();
}

[TearDown]
public void AfterEach()
{
EnsureServiceIsNotInstalled();
}

private void EnsureServiceIsNotInstalled()
{
var units = Agent.Get<List<DeployUnitInfoDTO>>("/units/list");
if (units[0].status == "NotFound")
{
return;
}
Agent.Post("/action",NodeFront.ApiKey, new UnitActionCommand()
{
actionName = "Uninstall",
unitName = ServiceName
});
WaitForStatus("NotFound");
while (Process.GetProcesses().Any(x => x.ProcessName == "Asimov.Roundhouse.Example"))
{
Thread.Sleep(TimeSpan.FromSeconds(0.5));
}
}
protected override string ServiceName => "Asimov.Web.Example";

[Test]
public void can_get_deploy_units()
{
var units = Agent.Get<List<DeployUnitInfoDTO>>("/units/list");
units.Count.ShouldBe(2);
units[0].name.ShouldBe(ServiceName);
units[0].status.ShouldBe("NotFound");
units[0].type.ShouldBe(DeployUnitTypes.WebSite);
Expand All @@ -65,30 +27,11 @@ public void installs_service_on_deploy()
InstallService();

var units = Agent.Get<List<DeployUnitInfoDTO>>("/units/list");
units.Count.ShouldBe(2);
units[0].name.ShouldBe(ServiceName);
units[0].status.ShouldBe("Running");
units[0].type.ShouldBe(DeployUnitTypes.WebSite);
}

private void InstallService()
{
var versions = Agent.Get<List<DeployUnitVersionDTO>>($"/versions/{ServiceName}");
versions.Count.ShouldBe(1);

Agent.Post("/deploy/deploy", NodeFront.ApiKey, new DeployCommand
{
unitName = ServiceName,
versionId = versions[0].id,
parameters = new Dictionary<string, object>() {
{
"Port", "8145"
} }
});

WaitForStatus("Running");
}

[Test]
public void when_NotFound_gets_install_parameters()
{
Expand All @@ -109,28 +52,5 @@ public void when_Installed_gets_deploy_parameters()
parameters.Count.ShouldBe(1);
parameters[0].Name.ShouldBe("NotUsed");
}

private void WaitForStatus(string expectedStatus)
{
var start = DateTime.Now;
var timeout = TimeSpan.FromSeconds(10);
var duration = DateTime.Now - start;
var status = "";

do
{
duration = DateTime.Now - start;
var units = Agent.Get<List<DeployUnitInfoDTO>>("/units/list");
units.Count.ShouldBe(2);
status = units[0].status;
if (status == expectedStatus)
{
return;
}
} while (duration < timeout);

Assert.Fail($"Failed to go to correct status, was {status} expected {expectedStatus}");

}
}
}
Loading

0 comments on commit 441513e

Please sign in to comment.