Skip to content

Commit

Permalink
Integrationtest for Verify Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Johannes Bengtsson committed May 18, 2021
1 parent 2c3db8d commit dcc8f95
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 0 deletions.
3 changes: 3 additions & 0 deletions AsimovDeploy.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
******************************************************************************/</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"WebPort": %AGENT_PORT%,
"DataFolder": "%DATA_FOLDER%",
"HeartbeatIntervalSeconds": 10,
"NodeFrontUrl": "%NODE_FRONT_URL%",
"Environment": "dev",
"ConfigVersion": 1,

"PackageSources": {
"Test": { "Type": "FileSystem", "Uri": "%PACKAGES_URI%" }
},

"Units": [
{
"Name": "VerifyTest",
"Type": "PowerShell",

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

"Url": "http://localhost:2121",

"DeployParameters": {
"Tasks": { "Type": "Text", "Default": "Deploy-Everything" }
},

"Actions": {
"verify1": { "Type": "VerifyCommand", "ZipPath": "verify.zip", "Command": "script.ps1" },
"verify2": { "Type": "VerifyCommand", "ZipPath": "verify.folder", "Command": "script.ps1" }
}
}
]
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
using System.Collections.Generic;
using System.IO;
using System.Threading;
using AsimovDeploy.WinAgent.Framework.Common;
using AsimovDeploy.WinAgent.Framework.Configuration;
using AsimovDeploy.WinAgent.Web.Commands;
using AsimovDeploy.WinAgent.Web.Contracts;
using NUnit.Framework;
using Shouldly;

namespace AsimovDeploy.WinAgent.IntegrationTests.Scenarios.VerifyScenario
{
[TestFixture]
public class PowershellScenario : WinAgentSystemTest
{
public override void Given()
{
GivenFoldersForScenario();
GivenRunningAgent();
}

[Test]
public void can_get_deploy_unit_info()
{
var units = Agent.Get<List<DeployUnitInfoDTO>>("/units/list");
units.Count.ShouldBe(1);
units[0].name.ShouldBe("VerifyTest");
units[0].status.ShouldBe("NA");
units[0].url.ShouldBe(string.Format("http://{0}:2121", HostNameUtil.GetFullHostName()));
units[0].hasDeployParameters.ShouldBe(true);
units[0].type.ShouldBe(DeployUnitTypes.PowerShell);
}

[Test]
public void can_get_deploy_parameters()
{
var parameters = Agent.Get<List<dynamic>>("/units/deploy-parameters/VerifyTest");
parameters.Count.ShouldBe(1);
((string)parameters[0].name).ShouldBe("Tasks");
((string)parameters[0].type).ShouldBe("text");
((string)parameters[0].@default).ShouldBe("Deploy-Everything");
}

[Test]
public void can_deploy_powershell_unit()
{
var versions = Agent.Get<List<DeployUnitVersionDTO>>("/versions/VerifyTest");
versions.Count.ShouldBe(1);

var parameters = new Dictionary<string, object>();
parameters["Tasks"] = "some text value";

Agent.Post("/deploy/deploy", NodeFront.ApiKey, new DeployCommand
{
unitName = "VerifyTest",
versionId = versions[0].id,
parameters = parameters
});

Thread.Sleep(2000);

// File.Exists(Path.Combine(TempDir, "some.txt")).ShouldBe(true);
// File.Exists(Path.Combine(TempDir, "text.txt")).ShouldBe(true);
// File.Exists(Path.Combine(TempDir, "value.txt")).ShouldBe(true);

var units = Agent.Get<List<DeployUnitInfoDTO>>("/units/list");;
units[0].version.ShouldBe("1.0.0.0");
units[0].branch.ShouldBe("master");

var deployLog = Agent.Get<List<dynamic>>("/deploylog/list/VerifyTest");
deployLog.Count.ShouldBe(1);
((string)deployLog[0].version).ShouldBe("1.0.0.0");
((string)deployLog[0].status).ShouldBe("Success");
((string)deployLog[0].branch).ShouldBe("master");
((int)deployLog[0].position).ShouldBe(0);
}
}
}

0 comments on commit dcc8f95

Please sign in to comment.