Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 0 additions & 72 deletions build/Build.CalamariTesting.cs

This file was deleted.

47 changes: 42 additions & 5 deletions build/Build.TestCalamariFlavourProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,56 @@ namespace Calamari.Build;

partial class Build
{
[Parameter(Name = "CalamariFlavour")] readonly string? CalamariFlavourToTest;
[Parameter(Name = "VSTest_TestCaseFilter")] readonly string? CalamariFlavourTestCaseFilter;
[Parameter(Name = "ProjectToTest")] readonly string? CalamariProjectToTest;

[PublicAPI]
Target LinuxHostTests =>
target => target
.Executes(async () =>
{
var dotnetPath = await LocateOrInstallDotNetSdk();

var project = CalamariProjectToTest ?? "Calamari";

var dll = $"TestBinaries/{project}.Tests.dll";

CreateTestRun(dll)
.WithDotNetPath(dotnetPath)
.WithFilter("TestCategory != Windows") // Linux is all tests that are non-Windows specific
.Execute();
});

[PublicAPI]
Target TestCalamariFlavourProject =>
Target WindowsHostTests =>
target => target
.Executes(async () =>
{
var dotnetPath = await LocateOrInstallDotNetSdk();

CreateTestRun($"CalamariTests/Calamari.{CalamariFlavourToTest}.Tests.dll")
var project = CalamariProjectToTest ?? "Calamari";

var dll = $"TestBinaries/{project}.Tests.dll";

CreateTestRun(dll)
.WithDotNetPath(dotnetPath)
.WithFilter("TestCategory != Linux & TestCategory != MacOs & TestCategory != Windows2016OrLater") // Windows is all tests that are non-Linux or MacOS specific and not Win 2016 or later
.Execute();
});

[PublicAPI]
Target Windows2016OrLaterHostTests =>
target => target
.Executes(async () =>
{
var dotnetPath = await LocateOrInstallDotNetSdk();

var project = CalamariProjectToTest ?? "Calamari";

var dll = $"TestBinaries/{project}.Tests.dll";

CreateTestRun(dll)
.WithDotNetPath(dotnetPath)
.WithFilter(CalamariFlavourTestCaseFilter)
.WithFilter("TestCategory = Windows2016OrLater") // Windows 2016 or later specific tests
.Execute();
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ await CommandTestBuilder.CreateAsync<DeployAzureResourceGroupCommand, Program>()
}

[Test]
[WindowsTest]
[TestPlatforms(TestPlatforms.Windows)]
[RequiresPowerShell5OrAbove]
public async Task Deploy_Ensure_Tools_Are_Configured()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
namespace Calamari.AzureResourceGroup.Tests
{
[TestFixture]
[WindowsTest] // NOTE: We should look at having the Azure CLI installed on Linux boxes so that these steps can be tested there, particularly if we're moving cloud to a Ubuntu Default Worker.
[Category(TestCategories.Windows2016OrLater)]
[RequiresWindowsServer2016OrAbove("This test requires the az cli, which relies on python 3.10, which doesn't run on windows 2012/2012R2")]
[TestPlatforms(TestPlatforms.Windows)] // NOTE: We should look at having the Azure CLI installed on Linux boxes so that these steps can be tested there, particularly if we're moving cloud to a Ubuntu Default Worker.
class DeployAzureBicepTemplateCommandFixture
{
string clientId;
Expand Down Expand Up @@ -93,7 +95,6 @@ await armClient.GetResourceGroupResource(ResourceGroupResource.CreateResourceIde
}

[Test]
[RequiresWindowsServer2016OrAbove("This test requires the az cli, which relies on python 3.10, which doesn't run on windows 2012/2012R2")]
public async Task DeployAzureBicepTemplate_PackageSource()
{
await CommandTestBuilder.CreateAsync<DeployAzureBicepTemplateCommand, Program>()
Expand All @@ -108,7 +109,6 @@ await CommandTestBuilder.CreateAsync<DeployAzureBicepTemplateCommand, Program>()
}

[Test]
[RequiresWindowsServer2016OrAbove("This test requires the az cli, which relies on python 3.10, which doesn't run on windows 2012/2012R2")]
public async Task DeployAzureBicepTemplate_GitSource()
{
// For the purposes of Bicep templates in Calamari, a template in a Git Repository
Expand All @@ -127,7 +127,6 @@ await CommandTestBuilder.CreateAsync<DeployAzureBicepTemplateCommand, Program>()
}

[Test]
[RequiresWindowsServer2016OrAbove("This test requires the az cli, which relies on python 3.10, which doesn't run on windows 2012/2012R2")]
public async Task DeployAzureBicepTemplate_InlineSource()
{
var templateFileContent = File.ReadAllText(Path.Combine(packagePath, "azure_website_template.bicep"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public async Task Setup()
}

[Test]
[WindowsTest]
[TestPlatforms(TestPlatforms.Windows)]
[RequiresPowerShell5OrAbove]
public async Task ExecuteAnInlineWindowsPowerShellScript()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
namespace Calamari.AzureServiceFabric.Tests
{
[TestFixture]
[WindowsTest]
[TestPlatforms(TestPlatforms.Windows)]
public class DeployAzureServiceFabricAppCommandFixture
{
string clientCertThumbprint;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace Calamari.AzureServiceFabric.Tests
{
[TestFixture]
[WindowsTest]
[TestPlatforms(TestPlatforms.Windows)]
public class HealthCheckCommandFixture
{
string clientCertThumbprint;
Expand Down
22 changes: 0 additions & 22 deletions source/Calamari.Common/Plumbing/Extensions/ScriptingEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,6 @@ public static bool IsRunningOnMono()
var monoRuntime = Type.GetType("Mono.Runtime");
return monoRuntime != null;
}

public static Version GetMonoVersion()
{
// A bit hacky, but this is what Mono community seems to be using:
// http://stackoverflow.com/questions/8413922/programmatically-determining-mono-runtime-version

var monoRuntime = Type.GetType("Mono.Runtime");
if (monoRuntime == null)
throw new MonoVersionCanNotBeDeterminedException("It looks like the code is not running on Mono.");

var dispalayNameMethod = monoRuntime.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static);
if (dispalayNameMethod == null)
throw new MonoVersionCanNotBeDeterminedException("Mono.Runtime.GetDisplayName can not be found.");

var displayName = dispalayNameMethod.Invoke(null, null).ToString();
var match = Regex.Match(displayName, @"^\d+\.\d+.\d+");
if (match == null || !match.Success || string.IsNullOrEmpty(match.Value))
throw new MonoVersionCanNotBeDeterminedException($"Display name does not seem to include version number. Retrieved value: {displayName}.");

return Version.Parse(match.Value);
}

public static Version SafelyGetPowerShellVersion()
{
try
Expand Down
1 change: 1 addition & 0 deletions source/Calamari.Terraform.Tests/CommandsFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ namespace Calamari.Terraform.Tests
{
[TestFixture("0.13.7")]
[TestFixture("1.8.5")]
[Category(TestCategories.Windows2016OrLater)]
public class CommandsFixture
{
string? customTerraformExecutable;
Expand Down
27 changes: 0 additions & 27 deletions source/Calamari.Testing/Helpers/TestCategory.cs

This file was deleted.

This file was deleted.

This file was deleted.

20 changes: 0 additions & 20 deletions source/Calamari.Testing/Requirements/RequiresNonMacAttribute.cs

This file was deleted.

This file was deleted.

Loading