Skip to content

Commit 12c4c18

Browse files
committed
Merge pull request #17 from MRCollective/suffix-and-delete-tentacle-config
Suffix and delete tentacle config
2 parents f02adcd + c929923 commit 12c4c18

22 files changed

+165
-15
lines changed

AzureWebFarm.OctopusDeploy.Example/ServiceConfiguration.Cloud.cscfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<Setting name="OctopusApiKey" value="API-OCTOPUSAPIKEY" />
1414
<Setting name="TentacleEnvironment" value="ENVIRONMENT" />
1515
<Setting name="TentacleRole" value="ROLE" />
16+
<Setting name="TentacleMachineNameSuffix" value="" />
1617
</ConfigurationSettings>
1718
<Certificates>
1819
<Certificate name="Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption" thumbprint="5BFCF449A37F73EF3875A1682BE5AE5CCB1B553F" thumbprintAlgorithm="sha1" />

AzureWebFarm.OctopusDeploy.Example/ServiceConfiguration.Local.cscfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<Setting name="OctopusApiKey" value="API-OCTOPUSAPIKEY" />
1414
<Setting name="TentacleEnvironment" value="ENVIRONMENT" />
1515
<Setting name="TentacleRole" value="ROLE" />
16+
<Setting name="TentacleMachineNameSuffix" value="" />
1617
</ConfigurationSettings>
1718
<Certificates>
1819
<Certificate name="Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption" thumbprint="5BFCF449A37F73EF3875A1682BE5AE5CCB1B553F" thumbprintAlgorithm="sha1" />

AzureWebFarm.OctopusDeploy.Example/ServiceDefinition.csdef

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<Setting name="OctopusApiKey" />
4242
<Setting name="TentacleEnvironment" />
4343
<Setting name="TentacleRole" />
44+
<Setting name="TentacleMachineNameSuffix" />
4445
</ConfigurationSettings>
4546
</WebRole>
4647
</ServiceDefinition>

AzureWebFarm.OctopusDeploy.Tests/AzureWebFarm.OctopusDeploy.Tests.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@
9090
</Reference>
9191
</ItemGroup>
9292
<ItemGroup>
93+
<Compile Include="Infrastructure\AzureEnvironmentTests.cs" />
94+
<Compile Include="Infrastructure\ConfigSettingsTests.cs" />
9395
<Compile Include="Infrastructure\OctopusDeployTests.cs" />
9496
<Compile Include="Infrastructure\RegistryEditorTests.cs" />
9597
<Compile Include="Properties\AssemblyInfo.cs" />
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using System;
2+
using AzureWebFarm.OctopusDeploy.Infrastructure;
3+
using Shouldly;
4+
using Xunit;
5+
6+
namespace AzureWebFarm.OctopusDeploy.Tests.Infrastructure
7+
{
8+
public class AzureEnvironmentTests
9+
{
10+
private readonly TestConfigSettings _config = new TestConfigSettings();
11+
12+
[Fact]
13+
public void GivenSuffixIsEmpty_WhenGeneratingFarmName_ThenUseMachineNameAndEnvironment()
14+
{
15+
AzureRoleEnvironment.IsAvailable = () => false;
16+
AzureRoleEnvironment.IsEmulated = () => false;
17+
var machineName = Environment.MachineName;
18+
_config.TentacleMachineNameSuffix = "";
19+
_config.TentacleEnvironment = "Production";
20+
21+
var name = AzureEnvironment.GetMachineName(_config);
22+
23+
name.ShouldBe(machineName + "_" + _config.TentacleEnvironment);
24+
}
25+
26+
[Fact]
27+
public void GivenSuffixIsNotEmpty_WhenGeneratingFarmName_ThenUseMachineNameAndEnvironmentAndSuffix()
28+
{
29+
AzureRoleEnvironment.IsAvailable = () => false;
30+
AzureRoleEnvironment.IsEmulated = () => false;
31+
var machineName = Environment.MachineName;
32+
_config.TentacleMachineNameSuffix = "Suffix";
33+
_config.TentacleEnvironment = "Production";
34+
35+
var name = AzureEnvironment.GetMachineName(_config);
36+
37+
name.ShouldBe(machineName + "_" + _config.TentacleEnvironment + "_" + _config.TentacleMachineNameSuffix);
38+
}
39+
}
40+
41+
public class TestConfigSettings : IConfigSettings
42+
{
43+
public string OctopusServer { get; set; }
44+
public string OctopusApiKey { get; set; }
45+
public string TentacleEnvironment { get; set; }
46+
public string TentacleRole { get; set; }
47+
public string TentacleMachineNameSuffix { get; set; }
48+
public string TentacleDeploymentsPath { get; set; }
49+
public string TentacleInstallPath { get; set; }
50+
}
51+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using AzureWebFarm.OctopusDeploy.Infrastructure;
3+
using Shouldly;
4+
using Xunit;
5+
6+
namespace AzureWebFarm.OctopusDeploy.Tests.Infrastructure
7+
{
8+
public class ConfigSettingsTests
9+
{
10+
[Fact]
11+
public void GivenExceptionWhenGettingConfigSetting_WhenConstructingConfigSettings_ThenThrowNiceException()
12+
{
13+
var e = new Exception("Error");
14+
Func<string, string> getter = _ => { throw e; };
15+
16+
var ex = Assert.Throws<UnableToGetConfigSettingException>(() => new ConfigSettings(getter, getter));
17+
18+
ex.Message.ShouldBe("Unable to get config setting: OctopusServer");
19+
ex.InnerException.ShouldBe(e);
20+
}
21+
}
22+
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
c:\Install\Tentacle\Tentacle.exe service --instance "Tentacle" --stop --uninstall --console
22
c:\Install\Tentacle\Tentacle.exe delete-instance --instance "Tentacle" --console
33
msiexec /uninstall "c:\InstallOctopus.Tentacle.msi" /quiet
4+
cmd.exe /c del "c:\InstallTentacle.config"

AzureWebFarm.OctopusDeploy.Tests/Tools/ExampleFiles/ServiceConfiguration.transformed.cscfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<Setting name="OctopusApiKey" value="API-CZYCNXCPAMBWFMDUTPUQUC0O2ZY" />
1313
<Setting name="TentacleEnvironment" value="Production" />
1414
<Setting name="TentacleRole" value="webserver" />
15+
<Setting name="TentacleMachineNameSuffix" value="" />
1516
</ConfigurationSettings>
1617
<Certificates>
1718
<Certificate name="Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption" thumbprint="5BFCF449A37F73EF3875A1682BE5AE5CCB1B553F" thumbprintAlgorithm="sha1" />

AzureWebFarm.OctopusDeploy.Tests/Tools/ExampleFiles/ServiceDefinition.transformed.csdef

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
<Setting name="OctopusApiKey" />
4141
<Setting name="TentacleEnvironment" />
4242
<Setting name="TentacleRole" />
43+
<Setting name="TentacleMachineNameSuffix" />
4344
</ConfigurationSettings>
4445
</WebRole>
4546
</ServiceDefinition>

AzureWebFarm.OctopusDeploy.Tests/Tools/XdtTests.WhenExecutingServiceConfigurationTransform_ThenCorrectlyTransformExampleFile.approved.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<Setting name="OctopusApiKey" value="API-CZYCNXCPAMBWFMDUTPUQUC0O2ZY" />
1313
<Setting name="TentacleEnvironment" value="Production" />
1414
<Setting name="TentacleRole" value="webserver" />
15+
<Setting name="TentacleMachineNameSuffix" value="" />
1516
</ConfigurationSettings>
1617
<Certificates>
1718
<Certificate name="Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption" thumbprint="5BFCF449A37F73EF3875A1682BE5AE5CCB1B553F" thumbprintAlgorithm="sha1" />

0 commit comments

Comments
 (0)