-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: middleware removing netapps in use (#232)
* fix: middleware removing netapps in use * chore: release 0.7.2 Release-As: 0.7.2 * chore: release 0.7.2 Release-As: 0.7.2 * fix: test compilation * test: skip unused test
- Loading branch information
Showing
6 changed files
with
180 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// In SDK-style projects such as this one, several assembly attributes that were historically | ||
// defined in this file are now automatically added during build and populated with | ||
// values defined in project properties. For details of which attributes are included | ||
// and how to customise this process see: https://aka.ms/assembly-info-properties | ||
|
||
|
||
// Setting ComVisible to false makes the types in this assembly not visible to COM | ||
// components. If you need to access a type in this assembly from COM, set the ComVisible | ||
// attribute to true on that type. | ||
|
||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM. | ||
|
||
[assembly: Guid("64ae49d8-8cba-42ed-8c3a-289c67918464")] | ||
|
||
[assembly: InternalsVisibleTo("Orchestrator.Tests.Unit")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
test/Orchestrator.Tests.Unit/Deployment/DeploymentServiceTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
using System; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using k8s; | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.Extensions.Options; | ||
using Middleware.Common.Config; | ||
using Middleware.Models.Domain; | ||
using Middleware.Orchestrator.Deployment; | ||
using Middleware.Orchestrator.Publishers; | ||
using Middleware.RedisInterface.Sdk; | ||
using NSubstitute; | ||
using Xunit; | ||
|
||
namespace Orchestrator.Tests.Unit.Deployment; | ||
|
||
public class DeploymentServiceTests | ||
{ | ||
private readonly IKubernetes _kube = Substitute.For<IKubernetes>(); | ||
private readonly IKubernetesBuilder _kubeBuilder = Substitute.For<IKubernetesBuilder>(); | ||
private readonly IKubernetesObjectBuilder _kubernetesObjectBuilder = Substitute.For<IKubernetesObjectBuilder>(); | ||
private readonly ILogger<DeploymentService> _logger = Substitute.For<ILogger<DeploymentService>>(); | ||
|
||
private readonly IOptions<MiddlewareConfig> _mwConfig = Options.Create(new MiddlewareConfig | ||
{ | ||
InstanceName = "test-MW", | ||
InstanceType = "Edge", | ||
Organization = "5G-ERA-TST" | ||
}); | ||
|
||
private readonly IPublishingService _publishingService = Substitute.For<IPublishingService>(); | ||
private readonly IRedisInterfaceClient _redisInterface = Substitute.For<IRedisInterfaceClient>(); | ||
private readonly IRosConnectionBuilderFactory _rosConnection = Substitute.For<IRosConnectionBuilderFactory>(); | ||
|
||
private readonly DeploymentService _sut; | ||
|
||
public DeploymentServiceTests() | ||
{ | ||
_kubeBuilder.CreateKubernetesClient().Returns(_kube); | ||
_sut = new(_kubeBuilder, _logger, _redisInterface, _mwConfig, _kubernetesObjectBuilder, | ||
_rosConnection, _publishingService); | ||
} | ||
|
||
[Fact(Skip = "Test not ready due to the complexity of the used functionalities")] | ||
public async Task DeletePlanAsync_ShouldAlwaysDeleteActionPlan_WhenCalled() | ||
{ | ||
//arrange | ||
var actionPlan = CreateActionPlan(); | ||
var instanceId = actionPlan.ActionSequence!.First().Services.First().ServiceInstanceId; | ||
//_kube.AppsV1 | ||
// .ListNamespacedDeploymentAsync("middleware", | ||
// labelSelector: KubernetesObjectExtensions.GetNetAppLabelSelector(instanceId)) | ||
// .Returns(new V1DeploymentList()); | ||
//act | ||
|
||
//assert | ||
await _redisInterface.Received(1).ActionPlanDeleteAsync(actionPlan.Id); | ||
} | ||
|
||
private ActionPlanModel CreateActionPlan() | ||
{ | ||
return new() | ||
{ | ||
Id = Guid.NewGuid(), | ||
Name = "TST", | ||
RobotId = Guid.NewGuid(), | ||
TaskId = Guid.NewGuid(), | ||
TaskStartedAt = DateTime.Now, | ||
ActionSequence = new() | ||
{ | ||
new() | ||
{ | ||
Name = "Action1", | ||
Id = Guid.NewGuid(), | ||
Placement = "test-MW", | ||
PlacementType = "Edge", | ||
SingleNetAppEntryPoint = true, | ||
Services = new() | ||
{ | ||
new() | ||
{ | ||
Id = Guid.NewGuid(), | ||
Name = "Instance1", | ||
RosDistro = RosDistro.Foxy.ToString(), | ||
IsReusable = true, | ||
ServiceInstanceId = Guid.NewGuid() | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
} | ||
} |