Skip to content

Commit 01176ac

Browse files
committed
added test for imagepullsecrets
Signed-off-by: Neil South <[email protected]>
1 parent c097d86 commit 01176ac

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

tests/UnitTests/TaskManager.Argo.Tests/ArgoPluginTest.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using System;
1818
using System.Collections.Generic;
1919
using System.IO;
20+
using System.IO.Abstractions;
2021
using System.Linq;
2122
using System.Net.Http;
2223
using System.Threading;
@@ -586,6 +587,46 @@ public async Task ArgoPlugin_GetStatus_ReturnsExecutionStatusOnFailure()
586587
_argoClient.Verify(p => p.WorkflowService_GetWorkflowAsync(It.Is<string>(p => p.Equals("namespace", StringComparison.OrdinalIgnoreCase)), It.Is<string>(p => p.Equals("identity", StringComparison.OrdinalIgnoreCase)), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<CancellationToken>()), Times.Once());
587588
}
588589

590+
[Fact(DisplayName = "ImagePullSecrets - get copied accross")]
591+
public async Task ArgoPlugin_Copies_ImagePullSecrets()
592+
{
593+
var argoTemplate = LoadArgoTemplate("SimpleTemplate.yml");
594+
595+
Assert.NotNull(argoTemplate);
596+
var secret = new LocalObjectReference() { Name = "ImagePullSecret" };
597+
argoTemplate.Spec.ImagePullSecrets = new List<LocalObjectReference>() { secret };
598+
599+
var message = GenerateTaskDispatchEventWithValidArguments();
600+
message.TaskPluginArguments["resources"] = "{\"memory_reservation\": \"string\",\"cpu_reservation\": \"string\",\"gpu_limit\": 1,\"memory_limit\": \"string\",\"cpu_limit\": \"string\"}";
601+
message.TaskPluginArguments["priorityClass"] = "Helo";
602+
Workflow? submittedArgoTemplate = null;
603+
604+
_argoClient.Setup(p => p.WorkflowTemplateService_GetWorkflowTemplateAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>()))
605+
.ReturnsAsync(argoTemplate);
606+
_argoClient.Setup(p => p.WorkflowService_CreateWorkflowAsync(It.IsAny<string>(), It.IsAny<WorkflowCreateRequest>(), It.IsAny<CancellationToken>()))
607+
.Callback((string ns, WorkflowCreateRequest body, CancellationToken cancellationToken) =>
608+
{
609+
submittedArgoTemplate = body.Workflow;
610+
})
611+
.ReturnsAsync((string ns, WorkflowCreateRequest body, CancellationToken cancellationToken) =>
612+
{
613+
return new Workflow { Metadata = new ObjectMeta { Name = "workflow" } };
614+
});
615+
616+
SetupKubbernetesSecrets()
617+
.ReturnsAsync((V1Secret body, string ns, string dr, string fm, string fv, bool? pretty, IReadOnlyDictionary<string, IReadOnlyList<string>> headers, CancellationToken ct) =>
618+
{
619+
return new HttpOperationResponse<V1Secret> { Body = body, Response = new HttpResponseMessage { } };
620+
});
621+
SetupKubernetesDeleteSecret();
622+
623+
var runner = new ArgoPlugin(_serviceScopeFactory.Object, _logger.Object, message);
624+
var result = await runner.ExecuteTask(CancellationToken.None).ConfigureAwait(false);
625+
626+
Assert.Equal(TaskExecutionStatus.Accepted, result.Status);
627+
Assert.Equal(secret, submittedArgoTemplate?.Spec.ImagePullSecrets.First());
628+
}
629+
589630
private static TaskDispatchEvent GenerateTaskDispatchEventWithValidArguments()
590631
{
591632
var message = GenerateTaskDispatchEvent();

0 commit comments

Comments
 (0)