sets up test starter tool
This commit is contained in:
parent
bfdbebb36e
commit
c348ca9849
|
@ -0,0 +1,42 @@
|
|||
using KubernetesWorkflow;
|
||||
|
||||
namespace TestClusterStarter
|
||||
{
|
||||
public class ClusterTestSetup
|
||||
{
|
||||
public ClusterTestSetup(ClusterTestSpec[] specs)
|
||||
{
|
||||
Specs = specs;
|
||||
}
|
||||
|
||||
public ClusterTestSpec[] Specs { get; }
|
||||
}
|
||||
|
||||
public class ClusterTestSpec
|
||||
{
|
||||
public ClusterTestSpec(string name, string filter, int replication, int durationSeconds, string? codexImageOverride)
|
||||
{
|
||||
Name = name;
|
||||
Filter = filter;
|
||||
Replication = replication;
|
||||
DurationSeconds = durationSeconds;
|
||||
CodexImageOverride = codexImageOverride;
|
||||
}
|
||||
|
||||
public string Name { get; }
|
||||
public string Filter { get; }
|
||||
public int Replication { get; }
|
||||
public int DurationSeconds { get; }
|
||||
public string? CodexImageOverride { get; }
|
||||
}
|
||||
|
||||
public class ClusterTestDeployment
|
||||
{
|
||||
public ClusterTestDeployment(RunningContainer[] containers)
|
||||
{
|
||||
Containers = containers;
|
||||
}
|
||||
|
||||
public RunningContainer[] Containers { get; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
using ArgsUniform;
|
||||
|
||||
namespace TestClusterStarter
|
||||
{
|
||||
public class Configuration
|
||||
{
|
||||
[Uniform("kube-config", "kc", "KUBECONFIG", true, "Path to Kubeconfig file. Use 'null' (default) to use local cluster.")]
|
||||
public string KubeConfigFile { get; set; } = "null";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
using ArgsUniform;
|
||||
using Core;
|
||||
using DeployAndRunPlugin;
|
||||
using KubernetesWorkflow;
|
||||
using Logging;
|
||||
using Newtonsoft.Json;
|
||||
using TestClusterStarter;
|
||||
|
||||
public class Program
|
||||
{
|
||||
private const string SpecsFile = "TestSpecs.json";
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var argsUniform = new ArgsUniform<TestClusterStarter.Configuration>(() => { }, args);
|
||||
var config = argsUniform.Parse();
|
||||
|
||||
ProjectPlugin.Load<DeployAndRunPlugin.DeployAndRunPlugin>();
|
||||
|
||||
if (!File.Exists(SpecsFile))
|
||||
{
|
||||
File.WriteAllText(SpecsFile, JsonConvert.SerializeObject(new ClusterTestSetup(new[]
|
||||
{
|
||||
new ClusterTestSpec("example", "peer", 2, Convert.ToInt32(TimeSpan.FromDays(2).TotalSeconds), "imageoverride")
|
||||
})));
|
||||
return;
|
||||
}
|
||||
var specs = JsonConvert.DeserializeObject<ClusterTestSetup>(File.ReadAllText(SpecsFile))!;
|
||||
|
||||
var kConfig = new KubernetesWorkflow.Configuration(config.KubeConfigFile, TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(10), "codex-continuous-test-runners");
|
||||
var entryPoint = new EntryPoint(new ConsoleLog(), kConfig, "datafolder");
|
||||
var ci = entryPoint.CreateInterface();
|
||||
|
||||
var rcs = new List<RunningContainer>();
|
||||
foreach (var spec in specs.Specs)
|
||||
{
|
||||
var rc = ci.DeployAndRunContinuousTests(new RunConfig(
|
||||
name: spec.Name,
|
||||
filter: spec.Filter,
|
||||
duration: TimeSpan.FromSeconds(spec.DurationSeconds),
|
||||
replications: spec.Replication,
|
||||
codexImageOverride: spec.CodexImageOverride));
|
||||
|
||||
rcs.Add(rc);
|
||||
}
|
||||
|
||||
var deployment = new ClusterTestDeployment(rcs.ToArray());
|
||||
File.WriteAllText("clustertest-deployment.json", JsonConvert.SerializeObject(deployment, Formatting.Indented));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Framework\ArgsUniform\ArgsUniform.csproj" />
|
||||
<ProjectReference Include="..\..\Framework\Core\Core.csproj" />
|
||||
<ProjectReference Include="..\..\Framework\KubernetesWorkflow\KubernetesWorkflow.csproj" />
|
||||
<ProjectReference Include="..\..\ProjectPlugins\DeployAndRunPlugin\DeployAndRunPlugin.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -47,6 +47,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BiblioTech", "Tools\BiblioT
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodexDiscordBotPlugin", "ProjectPlugins\CodexDiscordBotPlugin\CodexDiscordBotPlugin.csproj", "{FB96A58B-F7F0-490A-9A85-72A96A018042}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestClusterStarter", "Tools\TestClusterStarter\TestClusterStarter.csproj", "{3E38A906-C2FC-43DC-8CA2-FC07C79CF3CA}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DeployAndRunPlugin", "ProjectPlugins\DeployAndRunPlugin\DeployAndRunPlugin.csproj", "{1CC5AF82-8924-4C7E-BFF1-3125D86E53FB}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -125,6 +129,14 @@ Global
|
|||
{FB96A58B-F7F0-490A-9A85-72A96A018042}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FB96A58B-F7F0-490A-9A85-72A96A018042}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FB96A58B-F7F0-490A-9A85-72A96A018042}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{3E38A906-C2FC-43DC-8CA2-FC07C79CF3CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{3E38A906-C2FC-43DC-8CA2-FC07C79CF3CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{3E38A906-C2FC-43DC-8CA2-FC07C79CF3CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{3E38A906-C2FC-43DC-8CA2-FC07C79CF3CA}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1CC5AF82-8924-4C7E-BFF1-3125D86E53FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1CC5AF82-8924-4C7E-BFF1-3125D86E53FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1CC5AF82-8924-4C7E-BFF1-3125D86E53FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1CC5AF82-8924-4C7E-BFF1-3125D86E53FB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -148,6 +160,8 @@ Global
|
|||
{3417D508-E2F4-4974-8988-BB124046D9E2} = {7591C5B3-D86E-4AE4-8ED2-B272D17FE7E3}
|
||||
{078ABA6D-A04E-4F62-A44C-EA66F1B66548} = {7591C5B3-D86E-4AE4-8ED2-B272D17FE7E3}
|
||||
{FB96A58B-F7F0-490A-9A85-72A96A018042} = {8F1F1C2A-E313-4E0C-BE40-58FB0BA91124}
|
||||
{3E38A906-C2FC-43DC-8CA2-FC07C79CF3CA} = {7591C5B3-D86E-4AE4-8ED2-B272D17FE7E3}
|
||||
{1CC5AF82-8924-4C7E-BFF1-3125D86E53FB} = {8F1F1C2A-E313-4E0C-BE40-58FB0BA91124}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {237BF0AA-9EC4-4659-AD9A-65DEB974250C}
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
docker build -f deployandrun.Dockerfile -t thatbenbierens/dist-tests-deployandrun:initial ..
|
||||
docker push thatbenbierens/dist-tests-deployandrun:initial
|
Loading…
Reference in New Issue