Skip to content

Commit

Permalink
Try running K8S tests using local kind
Browse files Browse the repository at this point in the history
  • Loading branch information
zentron committed Aug 18, 2024
1 parent 5459c1d commit fb025d1
Show file tree
Hide file tree
Showing 13 changed files with 1,026 additions and 113 deletions.
4 changes: 2 additions & 2 deletions source/Calamari.Testing/Helpers/CalamariResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,14 @@ public void AssertNoOutput(string expectedOutput)

public void AssertOutput(string expectedOutput)
{
var allOutput = string.Join(Environment.NewLine, captured.Infos);
var allOutput = string.Join(Environment.NewLine, captured.AllMessages);

Assert.That(allOutput, Does.Contain(expectedOutput));
}

public void AssertOutputContains(string expected)
{
var allOutput = string.Join(Environment.NewLine, captured.Infos);
var allOutput = string.Join(Environment.NewLine, captured.AllMessages);

allOutput.Should().Contain(expected);
}
Expand Down
9 changes: 9 additions & 0 deletions source/Calamari.Tests/Calamari.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<StartupObject />
<RuntimeIdentifiers>win-x64;linux-x64;osx-x64;linux-arm;linux-arm64</RuntimeIdentifiers>
<TargetFrameworks>net462;net6.0</TargetFrameworks>
<LangVersion>8</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<DefineConstants>$(DefineConstants);NETCORE;AWS;AZURE_CORE;JAVA_SUPPORT</DefineConstants>
Expand Down Expand Up @@ -167,6 +168,14 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Compile Remove="Fixtures\StructuredVariables\CalamariFlavourProgramReplacerSelectionFixture.cs" />
<None Remove="KubernetesFixtures\Tools\kind-config.yml" />
<EmbeddedResource Include="KubernetesFixtures\Tools\kind-config.yml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
<None Remove="KubernetesFixtures\Tools\docker-desktop-network-routing.yml" />
<EmbeddedResource Include="KubernetesFixtures\Tools\docker-desktop-network-routing.yml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Remove="TestResults\**" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#if NETCORE
using System;
using System.Threading;
using System.Threading.Tasks;
using Calamari.Tests.KubernetesFixtures.Tools;
using NUnit.Framework;

namespace Calamari.Tests.KubernetesFixtures
{
[SetUpFixture]
public class KubernetesClusterOneTimeSetUp
{
KubernetesClusterInstaller installer;
[OneTimeSetUp]
public async Task OneTimeSetUp()
{
var toolDownloader = new RequiredToolDownloader(KubernetesTestsGlobalContext.Instance.TemporaryDirectory, KubernetesTestsGlobalContext.Instance.Logger);
var (kindExePath, helmExePath, kubeCtlPath) = await toolDownloader.DownloadRequiredTools(CancellationToken.None);

installer = new KubernetesClusterInstaller(KubernetesTestsGlobalContext.Instance.TemporaryDirectory, kindExePath, helmExePath, kubeCtlPath, KubernetesTestsGlobalContext.Instance.Logger);
await installer.Install();

KubernetesTestsGlobalContext.Instance.SetToolExePaths(helmExePath, kubeCtlPath);
KubernetesTestsGlobalContext.Instance.KubeConfigPath = installer.KubeConfigPath;

var details = installer.ExtractLoginDetails();
KubernetesTestsGlobalContext.Instance.ClusterUser = details.ClusterUser;
KubernetesTestsGlobalContext.Instance.ClusterEndpoint = details.ClusterEndpoint;
}

[OneTimeTearDown]
public void OneTimeTearDown()
{
installer.Dispose();
KubernetesTestsGlobalContext.Instance.Dispose();
}
}
}
#endif
Loading

0 comments on commit fb025d1

Please sign in to comment.