|
17 | 17 | using System; |
18 | 18 | using System.Collections.Generic; |
19 | 19 | using System.IO; |
| 20 | +using System.IO.Abstractions; |
20 | 21 | using System.Linq; |
21 | 22 | using System.Net.Http; |
22 | 23 | using System.Threading; |
@@ -586,6 +587,46 @@ public async Task ArgoPlugin_GetStatus_ReturnsExecutionStatusOnFailure() |
586 | 587 | _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()); |
587 | 588 | } |
588 | 589 |
|
| 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 | + |
589 | 630 | private static TaskDispatchEvent GenerateTaskDispatchEventWithValidArguments() |
590 | 631 | { |
591 | 632 | var message = GenerateTaskDispatchEvent(); |
|
0 commit comments