Adds deploy-and-run plugin
This commit is contained in:
parent
e87f255f48
commit
bfdbebb36e
|
@ -0,0 +1,13 @@
|
|||
using Core;
|
||||
using KubernetesWorkflow;
|
||||
|
||||
namespace DeployAndRunPlugin
|
||||
{
|
||||
public static class CoreInterfaceExtensions
|
||||
{
|
||||
public static RunningContainer DeployAndRunContinuousTests(this CoreInterface ci, RunConfig runConfig)
|
||||
{
|
||||
return ci.GetPlugin<DeployAndRunPlugin>().Run(runConfig);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
using KubernetesWorkflow;
|
||||
|
||||
namespace DeployAndRunPlugin
|
||||
{
|
||||
public class DeployAndRunContainerRecipe : ContainerRecipeFactory
|
||||
{
|
||||
public override string AppName => "deploy-and-run";
|
||||
public override string Image => "thatbenbierens/dist-tests-deployandrun:initial";
|
||||
|
||||
protected override void Initialize(StartupConfig config)
|
||||
{
|
||||
var setup = config.Get<RunConfig>();
|
||||
|
||||
if (setup.CodexImageOverride != null)
|
||||
{
|
||||
AddEnvVar("CODEXDOCKERIMAGE", setup.CodexImageOverride);
|
||||
}
|
||||
|
||||
AddEnvVar("DNR_REP", setup.Replications.ToString());
|
||||
AddEnvVar("DNR_NAME", setup.Name);
|
||||
AddEnvVar("DNR_FILTER", setup.Filter);
|
||||
AddEnvVar("DNR_DURATION", setup.Duration.TotalSeconds.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public class RunConfig
|
||||
{
|
||||
public RunConfig(string name, string filter, TimeSpan duration, int replications, string? codexImageOverride = null)
|
||||
{
|
||||
Name = name;
|
||||
Filter = filter;
|
||||
Duration = duration;
|
||||
Replications = replications;
|
||||
CodexImageOverride = codexImageOverride;
|
||||
}
|
||||
|
||||
public string Name { get; }
|
||||
public string Filter { get; }
|
||||
public TimeSpan Duration { get; }
|
||||
public int Replications { get; }
|
||||
public string? CodexImageOverride { get; }
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
using Core;
|
||||
using KubernetesWorkflow;
|
||||
|
||||
namespace DeployAndRunPlugin
|
||||
{
|
||||
public class DeployAndRunPlugin : IProjectPlugin
|
||||
{
|
||||
private readonly IPluginTools tools;
|
||||
|
||||
public DeployAndRunPlugin(IPluginTools tools)
|
||||
{
|
||||
this.tools = tools;
|
||||
}
|
||||
|
||||
public void Announce()
|
||||
{
|
||||
tools.GetLog().Log("Deploy-and-Run plugin loaded.");
|
||||
}
|
||||
|
||||
public void Decommission()
|
||||
{
|
||||
}
|
||||
|
||||
public RunningContainer Run(RunConfig config)
|
||||
{
|
||||
var workflow = tools.CreateWorkflow();
|
||||
var startupConfig = new StartupConfig();
|
||||
startupConfig.NameOverride = "dnr-" + config.Name;
|
||||
startupConfig.Add(config);
|
||||
|
||||
var containers = workflow.Start(1, new DeployAndRunContainerRecipe(), startupConfig);
|
||||
return containers.Containers.Single();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Framework\Core\Core.csproj" />
|
||||
<ProjectReference Include="..\..\Framework\KubernetesWorkflow\KubernetesWorkflow.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in New Issue