From b8eb8a923deca731f41450d18ea0613bec42fa12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gurhem?= Date: Tue, 26 Sep 2023 17:00:38 +0200 Subject: [PATCH] refactor: Remove usage of gRPC defined ResultStatus in internal interfaces --- Adaptors/Memory/src/ResultTable.cs | 1 - Adaptors/MongoDB/src/ResultTable.cs | 1 - Adaptors/MongoDB/tests/BsonSerializerTest.cs | 1 + Common/src/Storage/Events/NewResult.cs | 2 - .../src/Storage/Events/ResultStatusUpdate.cs | 2 - Common/src/Storage/Result.cs | 4 +- Common/src/Storage/ResultIdStatus.cs | 28 +++++++++++ Common/src/Storage/ResultLifeCycleHelper.cs | 2 - Common/src/Storage/ResultStatus.cs | 33 ++++++++++++ Common/src/Storage/ResultStatusCount.cs | 2 - Common/src/Storage/ResultTableExtensions.cs | 16 +++--- Common/src/gRPC/Convertors/ResultStatusExt.cs | 50 +++++++++++++++++++ Common/src/gRPC/Services/Agent.cs | 6 ++- .../src/gRPC/Services/GrpcResultsService.cs | 2 + .../src/gRPC/Services/GrpcSubmitterService.cs | 12 +++-- Common/src/gRPC/Services/Submitter.cs | 2 +- Common/src/gRPC/Services/WatchToGrpc.cs | 6 +-- Common/tests/Helpers/SimpleResultTable.cs | 1 - Common/tests/Helpers/SimpleResultWatcher.cs | 1 - .../ToResultFieldTest.cs | 1 - .../ToResultFilterTest.cs | 8 +-- Common/tests/Pollster/AgentTest.cs | 1 + Common/tests/Pollster/PollsterTest.cs | 1 + Common/tests/Pollster/TaskHandlerTest.cs | 1 + .../Submitter/GrpcSubmitterServiceTests.cs | 14 +++--- .../IntegrationGrpcSubmitterServiceTest.cs | 4 +- Common/tests/Submitter/SubmitterTests.cs | 1 + Common/tests/TestBase/ResultTableTestBase.cs | 23 +++------ .../tests/TestBase/ResultWatcherTestBase.cs | 1 - 29 files changed, 161 insertions(+), 66 deletions(-) create mode 100644 Common/src/Storage/ResultIdStatus.cs create mode 100644 Common/src/Storage/ResultStatus.cs create mode 100644 Common/src/gRPC/Convertors/ResultStatusExt.cs diff --git a/Adaptors/Memory/src/ResultTable.cs b/Adaptors/Memory/src/ResultTable.cs index 92e67d90b..63e83d831 100644 --- a/Adaptors/Memory/src/ResultTable.cs +++ b/Adaptors/Memory/src/ResultTable.cs @@ -24,7 +24,6 @@ using System.Threading; using System.Threading.Tasks; -using ArmoniK.Api.gRPC.V1; using ArmoniK.Core.Base.DataStructures; using ArmoniK.Core.Common.Exceptions; using ArmoniK.Core.Common.Storage; diff --git a/Adaptors/MongoDB/src/ResultTable.cs b/Adaptors/MongoDB/src/ResultTable.cs index 3c7be0178..bdebdcb13 100644 --- a/Adaptors/MongoDB/src/ResultTable.cs +++ b/Adaptors/MongoDB/src/ResultTable.cs @@ -24,7 +24,6 @@ using System.Threading.Tasks; using ArmoniK.Api.Common.Utils; -using ArmoniK.Api.gRPC.V1; using ArmoniK.Core.Adapters.MongoDB.Common; using ArmoniK.Core.Adapters.MongoDB.Table.DataModel; using ArmoniK.Core.Base.DataStructures; diff --git a/Adaptors/MongoDB/tests/BsonSerializerTest.cs b/Adaptors/MongoDB/tests/BsonSerializerTest.cs index 0ca71088c..4d80c4a34 100644 --- a/Adaptors/MongoDB/tests/BsonSerializerTest.cs +++ b/Adaptors/MongoDB/tests/BsonSerializerTest.cs @@ -31,6 +31,7 @@ using NUnit.Framework; using Output = ArmoniK.Core.Common.Storage.Output; +using ResultStatus = ArmoniK.Core.Common.Storage.ResultStatus; using TaskOptions = ArmoniK.Core.Base.DataStructures.TaskOptions; using TaskStatus = ArmoniK.Core.Common.Storage.TaskStatus; diff --git a/Common/src/Storage/Events/NewResult.cs b/Common/src/Storage/Events/NewResult.cs index 71445e343..75ee9d169 100644 --- a/Common/src/Storage/Events/NewResult.cs +++ b/Common/src/Storage/Events/NewResult.cs @@ -15,8 +15,6 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -using ArmoniK.Api.gRPC.V1; - namespace ArmoniK.Core.Common.Storage.Events; /// diff --git a/Common/src/Storage/Events/ResultStatusUpdate.cs b/Common/src/Storage/Events/ResultStatusUpdate.cs index ae0102b26..71d8a5b06 100644 --- a/Common/src/Storage/Events/ResultStatusUpdate.cs +++ b/Common/src/Storage/Events/ResultStatusUpdate.cs @@ -15,8 +15,6 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -using ArmoniK.Api.gRPC.V1; - namespace ArmoniK.Core.Common.Storage.Events; /// diff --git a/Common/src/Storage/Result.cs b/Common/src/Storage/Result.cs index d4daa0493..e62df6875 100644 --- a/Common/src/Storage/Result.cs +++ b/Common/src/Storage/Result.cs @@ -18,8 +18,8 @@ using System; using System.Collections.Generic; -using ArmoniK.Api.gRPC.V1; using ArmoniK.Api.gRPC.V1.Results; +using ArmoniK.Core.Common.gRPC.Convertors; using static Google.Protobuf.WellKnownTypes.Timestamp; @@ -55,7 +55,7 @@ public static implicit operator ResultRaw(Result result) => new() { SessionId = result.SessionId, - Status = result.Status, + Status = result.Status.ToGrpcStatus(), CreatedAt = FromDateTime(result.CreationDate), Name = result.Name, OwnerTaskId = result.OwnerTaskId, diff --git a/Common/src/Storage/ResultIdStatus.cs b/Common/src/Storage/ResultIdStatus.cs new file mode 100644 index 000000000..8b6afa4ef --- /dev/null +++ b/Common/src/Storage/ResultIdStatus.cs @@ -0,0 +1,28 @@ +// This file is part of the ArmoniK project +// +// Copyright (C) ANEO, 2021-2023. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY, without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +namespace ArmoniK.Core.Common.Storage; + +/// +/// Holds result Id and status +/// +/// Result Id +/// Result status +public record ResultIdStatus(string ResultId, + ResultStatus Status) +{ +} diff --git a/Common/src/Storage/ResultLifeCycleHelper.cs b/Common/src/Storage/ResultLifeCycleHelper.cs index c7e229253..a8f53c6f8 100644 --- a/Common/src/Storage/ResultLifeCycleHelper.cs +++ b/Common/src/Storage/ResultLifeCycleHelper.cs @@ -20,8 +20,6 @@ using System.Threading; using System.Threading.Tasks; -using ArmoniK.Api.gRPC.V1; - using Microsoft.Extensions.Logging; namespace ArmoniK.Core.Common.Storage; diff --git a/Common/src/Storage/ResultStatus.cs b/Common/src/Storage/ResultStatus.cs new file mode 100644 index 000000000..8471aa4e1 --- /dev/null +++ b/Common/src/Storage/ResultStatus.cs @@ -0,0 +1,33 @@ +// This file is part of the ArmoniK project +// +// Copyright (C) ANEO, 2021-2023. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY, without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +namespace ArmoniK.Core.Common.Storage; + +public enum ResultStatus +{ + /// Result is in an unspecified state. + Unspecified, + + /// Result is created and task is created, submitted or dispatched. + Created, + + /// Result is completed with a completed task. + Completed, + + /// Result is aborted. + Aborted, +} diff --git a/Common/src/Storage/ResultStatusCount.cs b/Common/src/Storage/ResultStatusCount.cs index 92411ba61..f8aa411e2 100644 --- a/Common/src/Storage/ResultStatusCount.cs +++ b/Common/src/Storage/ResultStatusCount.cs @@ -15,8 +15,6 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -using ArmoniK.Api.gRPC.V1; - namespace ArmoniK.Core.Common.Storage; public record ResultStatusCount(ResultStatus Status, diff --git a/Common/src/Storage/ResultTableExtensions.cs b/Common/src/Storage/ResultTableExtensions.cs index 5fbc309a8..2299e36e5 100644 --- a/Common/src/Storage/ResultTableExtensions.cs +++ b/Common/src/Storage/ResultTableExtensions.cs @@ -21,7 +21,6 @@ using System.Threading; using System.Threading.Tasks; -using ArmoniK.Api.gRPC.V1.Submitter; using ArmoniK.Core.Common.Exceptions; namespace ArmoniK.Core.Common.Storage; @@ -87,16 +86,13 @@ public static async Task> GetDependents(this IResultTable re /// /// A map between the ids of the results found and their status /// - public static async Task> GetResultStatus(this IResultTable resultTable, - IEnumerable ids, - string sessionId, - CancellationToken cancellationToken = default) + public static async Task> GetResultStatus(this IResultTable resultTable, + IEnumerable ids, + string sessionId, + CancellationToken cancellationToken = default) => await resultTable.GetResults(result => ids.Contains(result.ResultId), - result => new GetResultStatusReply.Types.IdStatus - { - ResultId = result.ResultId, - Status = result.Status, - }, + result => new ResultIdStatus(result.ResultId, + result.Status), cancellationToken) .ToListAsync(cancellationToken) .ConfigureAwait(false); diff --git a/Common/src/gRPC/Convertors/ResultStatusExt.cs b/Common/src/gRPC/Convertors/ResultStatusExt.cs new file mode 100644 index 000000000..9271676eb --- /dev/null +++ b/Common/src/gRPC/Convertors/ResultStatusExt.cs @@ -0,0 +1,50 @@ +// This file is part of the ArmoniK project +// +// Copyright (C) ANEO, 2021-2023. All rights reserved. +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published +// by the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY, without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +using System; + +using ArmoniK.Api.gRPC.V1; + +namespace ArmoniK.Core.Common.gRPC.Convertors; + +public static class ResultStatusExt +{ + public static ResultStatus ToGrpcStatus(this Storage.ResultStatus status) + => status switch + { + Storage.ResultStatus.Unspecified => ResultStatus.Unspecified, + Storage.ResultStatus.Created => ResultStatus.Created, + Storage.ResultStatus.Completed => ResultStatus.Completed, + Storage.ResultStatus.Aborted => ResultStatus.Aborted, + _ => throw new ArgumentOutOfRangeException(nameof(status), + status, + null), + }; + + public static Storage.ResultStatus ToInternalStatus(this ResultStatus status) + => status switch + { + ResultStatus.Unspecified => Storage.ResultStatus.Unspecified, + ResultStatus.Created => Storage.ResultStatus.Created, + ResultStatus.Completed => Storage.ResultStatus.Completed, + ResultStatus.Aborted => Storage.ResultStatus.Aborted, + ResultStatus.Notfound => Storage.ResultStatus.Unspecified, + _ => throw new ArgumentOutOfRangeException(nameof(status), + status, + null), + }; +} diff --git a/Common/src/gRPC/Services/Agent.cs b/Common/src/gRPC/Services/Agent.cs index 2ac15f84c..1f238f956 100644 --- a/Common/src/gRPC/Services/Agent.cs +++ b/Common/src/gRPC/Services/Agent.cs @@ -29,6 +29,7 @@ using ArmoniK.Api.gRPC.V1.Agent; using ArmoniK.Core.Base; using ArmoniK.Core.Common.Exceptions; +using ArmoniK.Core.Common.gRPC.Convertors; using ArmoniK.Core.Common.StateMachines; using ArmoniK.Core.Common.Storage; using ArmoniK.Utils; @@ -39,6 +40,7 @@ using static Google.Protobuf.WellKnownTypes.Timestamp; +using ResultStatus = ArmoniK.Core.Common.Storage.ResultStatus; using TaskOptions = ArmoniK.Core.Base.DataStructures.TaskOptions; namespace ArmoniK.Core.Common.gRPC.Services; @@ -329,7 +331,7 @@ await resultTable_.Create(results, CreatedAt = FromDateTime(result.CreationDate), Name = result.Name, SessionId = result.SessionId, - Status = result.Status, + Status = result.Status.ToGrpcStatus(), ResultId = result.ResultId, }), }, @@ -431,7 +433,7 @@ await resultTable_.Create(results, { results.Select(r => new ResultMetaData { - Status = r.Status, + Status = r.Status.ToGrpcStatus(), CreatedAt = FromDateTime(r.CreationDate), Name = r.Name, ResultId = r.ResultId, diff --git a/Common/src/gRPC/Services/GrpcResultsService.cs b/Common/src/gRPC/Services/GrpcResultsService.cs index 3c62c1f67..1d7be02a5 100644 --- a/Common/src/gRPC/Services/GrpcResultsService.cs +++ b/Common/src/gRPC/Services/GrpcResultsService.cs @@ -38,6 +38,8 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.Extensions.Logging; +using ResultStatus = ArmoniK.Core.Common.Storage.ResultStatus; + namespace ArmoniK.Core.Common.gRPC.Services; [Authorize(AuthenticationSchemes = Authenticator.SchemeName)] diff --git a/Common/src/gRPC/Services/GrpcSubmitterService.cs b/Common/src/gRPC/Services/GrpcSubmitterService.cs index b4e7c95de..b087abdf5 100644 --- a/Common/src/gRPC/Services/GrpcSubmitterService.cs +++ b/Common/src/gRPC/Services/GrpcSubmitterService.cs @@ -598,10 +598,14 @@ public override async Task GetResultStatus(GetResultStatus { IdStatuses = { - await resultTable_.GetResultStatus(request.ResultIds, - request.SessionId, - context.CancellationToken) - .ConfigureAwait(false), + (await resultTable_.GetResultStatus(request.ResultIds, + request.SessionId, + context.CancellationToken) + .ConfigureAwait(false)).Select(status => new GetResultStatusReply.Types.IdStatus + { + ResultId = status.ResultId, + Status = status.Status.ToGrpcStatus(), + }), }, }; } diff --git a/Common/src/gRPC/Services/Submitter.cs b/Common/src/gRPC/Services/Submitter.cs index eb203fdaf..0d809f940 100644 --- a/Common/src/gRPC/Services/Submitter.cs +++ b/Common/src/gRPC/Services/Submitter.cs @@ -41,6 +41,7 @@ using Microsoft.Extensions.Logging; using Output = ArmoniK.Api.gRPC.V1.Output; +using ResultStatus = ArmoniK.Core.Common.Storage.ResultStatus; using TaskOptions = ArmoniK.Core.Base.DataStructures.TaskOptions; using TaskStatus = ArmoniK.Core.Common.Storage.TaskStatus; @@ -474,7 +475,6 @@ public async Task WaitForAvailabilityAsync(ResultRequest }, }; case ResultStatus.Unspecified: - case ResultStatus.Notfound: // TODO: define a specific error type ? default: throw new ArgumentOutOfRangeException(nameof(result.Status)); } diff --git a/Common/src/gRPC/Services/WatchToGrpc.cs b/Common/src/gRPC/Services/WatchToGrpc.cs index aa6eb9cc1..71e282114 100644 --- a/Common/src/gRPC/Services/WatchToGrpc.cs +++ b/Common/src/gRPC/Services/WatchToGrpc.cs @@ -187,7 +187,7 @@ await Task.Factory.StartNew(async () => NewResult = new EventSubscriptionResponse.Types.NewResult { - Status = cur.Status, + Status = cur.Status.ToGrpcStatus(), OwnerId = cur.OwnerId, ResultId = cur.ResultId, }, @@ -221,7 +221,7 @@ await Task.Factory.StartNew(async () => ResultStatusUpdate { ResultId = cur.ResultId, - Status = cur.Status, + Status = cur.Status.ToGrpcStatus(), }, SessionId = cur.SessionId, }); @@ -327,7 +327,7 @@ await Task.Factory.StartNew(async () => { NewResult = new EventSubscriptionResponse.Types.NewResult { - Status = cur.Status, + Status = cur.Status.ToGrpcStatus(), OwnerId = cur.OwnerTaskId, ResultId = cur.ResultId, }, diff --git a/Common/tests/Helpers/SimpleResultTable.cs b/Common/tests/Helpers/SimpleResultTable.cs index c95a89ef7..724867819 100644 --- a/Common/tests/Helpers/SimpleResultTable.cs +++ b/Common/tests/Helpers/SimpleResultTable.cs @@ -22,7 +22,6 @@ using System.Threading; using System.Threading.Tasks; -using ArmoniK.Api.gRPC.V1; using ArmoniK.Core.Base.DataStructures; using ArmoniK.Core.Common.Storage; diff --git a/Common/tests/Helpers/SimpleResultWatcher.cs b/Common/tests/Helpers/SimpleResultWatcher.cs index 55ef3cfe7..0237ca8ed 100644 --- a/Common/tests/Helpers/SimpleResultWatcher.cs +++ b/Common/tests/Helpers/SimpleResultWatcher.cs @@ -22,7 +22,6 @@ using System.Threading; using System.Threading.Tasks; -using ArmoniK.Api.gRPC.V1; using ArmoniK.Core.Base.DataStructures; using ArmoniK.Core.Common.Storage; using ArmoniK.Core.Common.Storage.Events; diff --git a/Common/tests/ListResultsRequestExt/ToResultFieldTest.cs b/Common/tests/ListResultsRequestExt/ToResultFieldTest.cs index 7e7d21e20..d350fd58d 100644 --- a/Common/tests/ListResultsRequestExt/ToResultFieldTest.cs +++ b/Common/tests/ListResultsRequestExt/ToResultFieldTest.cs @@ -18,7 +18,6 @@ using System; using System.Collections.Generic; -using ArmoniK.Api.gRPC.V1; using ArmoniK.Api.gRPC.V1.Results; using ArmoniK.Api.gRPC.V1.SortDirection; using ArmoniK.Core.Common.gRPC; diff --git a/Common/tests/ListResultsRequestExt/ToResultFilterTest.cs b/Common/tests/ListResultsRequestExt/ToResultFilterTest.cs index 7bfd3520a..bec936318 100644 --- a/Common/tests/ListResultsRequestExt/ToResultFilterTest.cs +++ b/Common/tests/ListResultsRequestExt/ToResultFilterTest.cs @@ -26,6 +26,8 @@ using NUnit.Framework; +using ResultStatus = ArmoniK.Core.Common.Storage.ResultStatus; + namespace ArmoniK.Core.Common.Tests.ListResultsRequestExt; [TestFixture(TestOf = typeof(ToResultFilterTest))] @@ -90,13 +92,13 @@ TestCaseData CaseFalse(FilterField filterField) yield return CaseTrue(ListResultsHelper.CreateListResultsFilterStatus(ResultRawEnumField.Status, FilterStatusOperator.Equal, - ResultStatus.Created)); + Api.gRPC.V1.ResultStatus.Created)); yield return CaseFalse(ListResultsHelper.CreateListResultsFilterStatus(ResultRawEnumField.Status, FilterStatusOperator.Equal, - ResultStatus.Aborted)); + Api.gRPC.V1.ResultStatus.Aborted)); yield return CaseTrue(ListResultsHelper.CreateListResultsFilterStatus(ResultRawEnumField.Status, FilterStatusOperator.NotEqual, - ResultStatus.Aborted)); + Api.gRPC.V1.ResultStatus.Aborted)); yield return CaseTrue(ListResultsHelper.CreateListResultsFilterString(ResultRawEnumField.SessionId, FilterStringOperator.Equal, diff --git a/Common/tests/Pollster/AgentTest.cs b/Common/tests/Pollster/AgentTest.cs index d5e32f35d..2595e3303 100644 --- a/Common/tests/Pollster/AgentTest.cs +++ b/Common/tests/Pollster/AgentTest.cs @@ -45,6 +45,7 @@ using NUnit.Framework; using Agent = ArmoniK.Core.Common.gRPC.Services.Agent; +using ResultStatus = ArmoniK.Core.Common.Storage.ResultStatus; using TaskOptions = ArmoniK.Api.gRPC.V1.TaskOptions; using TaskRequest = ArmoniK.Core.Common.gRPC.Services.TaskRequest; using TaskStatus = ArmoniK.Core.Common.Storage.TaskStatus; diff --git a/Common/tests/Pollster/PollsterTest.cs b/Common/tests/Pollster/PollsterTest.cs index e68635872..042dd18d2 100644 --- a/Common/tests/Pollster/PollsterTest.cs +++ b/Common/tests/Pollster/PollsterTest.cs @@ -42,6 +42,7 @@ using NUnit.Framework; using Output = ArmoniK.Api.gRPC.V1.Output; +using ResultStatus = ArmoniK.Core.Common.Storage.ResultStatus; using TaskOptions = ArmoniK.Core.Base.DataStructures.TaskOptions; using TaskRequest = ArmoniK.Core.Common.gRPC.Services.TaskRequest; using TaskStatus = ArmoniK.Core.Common.Storage.TaskStatus; diff --git a/Common/tests/Pollster/TaskHandlerTest.cs b/Common/tests/Pollster/TaskHandlerTest.cs index db92883f7..b5b6cfab3 100644 --- a/Common/tests/Pollster/TaskHandlerTest.cs +++ b/Common/tests/Pollster/TaskHandlerTest.cs @@ -45,6 +45,7 @@ using NUnit.Framework; using Output = ArmoniK.Core.Common.Storage.Output; +using ResultStatus = ArmoniK.Core.Common.Storage.ResultStatus; using TaskOptions = ArmoniK.Core.Base.DataStructures.TaskOptions; using TaskRequest = ArmoniK.Core.Common.gRPC.Services.TaskRequest; using TaskStatus = ArmoniK.Core.Common.Storage.TaskStatus; diff --git a/Common/tests/Submitter/GrpcSubmitterServiceTests.cs b/Common/tests/Submitter/GrpcSubmitterServiceTests.cs index 7b86e8779..c9a8d2b9a 100644 --- a/Common/tests/Submitter/GrpcSubmitterServiceTests.cs +++ b/Common/tests/Submitter/GrpcSubmitterServiceTests.cs @@ -44,6 +44,7 @@ using Empty = ArmoniK.Api.gRPC.V1.Empty; using Output = ArmoniK.Core.Common.Storage.Output; +using ResultStatus = ArmoniK.Core.Common.Storage.ResultStatus; using TaskRequest = ArmoniK.Core.Common.gRPC.Services.TaskRequest; using TaskStatus = ArmoniK.Api.gRPC.V1.TaskStatus; @@ -1811,7 +1812,7 @@ public async Task GetResultStatusAsyncArmoniKNotFoundExceptionShouldThrow() { var mock = new Mock(); mock.Setup(resultTable => resultTable.GetResults(It.IsAny>>(), - It.IsAny>>(), + It.IsAny>>(), It.IsAny())) .Returns(() => throw new TaskNotFoundException()); @@ -1849,15 +1850,12 @@ public async Task GetResultStatusShouldSucceed() { var mock = new Mock(); mock.Setup(resultTable => resultTable.GetResults(It.IsAny>>(), - It.IsAny>>(), + It.IsAny>>(), It.IsAny())) .Returns(() => new[] { - new GetResultStatusReply.Types.IdStatus - { - Status = ResultStatus.Completed, - ResultId = "ResultId", - }, + new ResultIdStatus("ResultId", + ResultStatus.Completed), }.ToAsyncEnumerable()); var service = new GrpcSubmitterService(mockSubmitter_.Object, @@ -1876,7 +1874,7 @@ public async Task GetResultStatusShouldSucceed() TestServerCallContext.Create()) .ConfigureAwait(false); - Assert.AreEqual(ResultStatus.Completed, + Assert.AreEqual(Api.gRPC.V1.ResultStatus.Completed, response.IdStatuses.Single() .Status); } diff --git a/Common/tests/Submitter/IntegrationGrpcSubmitterServiceTest.cs b/Common/tests/Submitter/IntegrationGrpcSubmitterServiceTest.cs index 7180f92c6..6ec54fbbd 100644 --- a/Common/tests/Submitter/IntegrationGrpcSubmitterServiceTest.cs +++ b/Common/tests/Submitter/IntegrationGrpcSubmitterServiceTest.cs @@ -971,11 +971,11 @@ public static IEnumerable TestCasesTaskTableInternal } } - private static IResultTable CreateResultTableMock(Action>> setupAction) + private static IResultTable CreateResultTableMock(Action>> setupAction) { var mock = new Mock(); var setup = mock.Setup(table => table.GetResults(It.IsAny>>(), - It.IsAny>>(), + It.IsAny>>(), It.IsAny())); setupAction.Invoke(setup); return mock.Object; diff --git a/Common/tests/Submitter/SubmitterTests.cs b/Common/tests/Submitter/SubmitterTests.cs index 1be9fa9a8..348174154 100644 --- a/Common/tests/Submitter/SubmitterTests.cs +++ b/Common/tests/Submitter/SubmitterTests.cs @@ -53,6 +53,7 @@ using Empty = ArmoniK.Api.gRPC.V1.Empty; using Output = ArmoniK.Core.Common.Storage.Output; +using ResultStatus = ArmoniK.Core.Common.Storage.ResultStatus; using TaskRequest = ArmoniK.Core.Common.gRPC.Services.TaskRequest; using TaskStatus = ArmoniK.Core.Common.Storage.TaskStatus; diff --git a/Common/tests/TestBase/ResultTableTestBase.cs b/Common/tests/TestBase/ResultTableTestBase.cs index d00a96647..0d5be7955 100644 --- a/Common/tests/TestBase/ResultTableTestBase.cs +++ b/Common/tests/TestBase/ResultTableTestBase.cs @@ -22,8 +22,6 @@ using System.Threading; using System.Threading.Tasks; -using ArmoniK.Api.gRPC.V1; -using ArmoniK.Api.gRPC.V1.Submitter; using ArmoniK.Core.Base.DataStructures; using ArmoniK.Core.Common.Exceptions; using ArmoniK.Core.Common.Storage; @@ -448,25 +446,16 @@ public async Task GetResultStatusShouldSucceed() CancellationToken.None) .ConfigureAwait(false)).ToList(); - Assert.Contains(new GetResultStatusReply.Types.IdStatus - { - Status = ResultStatus.Completed, - ResultId = "ResultIsAvailable", - }, + Assert.Contains(new ResultIdStatus("ResultIsAvailable", + ResultStatus.Completed), result); - Assert.Contains(new GetResultStatusReply.Types.IdStatus - { - Status = ResultStatus.Aborted, - ResultId = "ResultIsNotAvailable", - }, + Assert.Contains(new ResultIdStatus("ResultIsNotAvailable", + ResultStatus.Aborted), result); - Assert.Contains(new GetResultStatusReply.Types.IdStatus - { - Status = ResultStatus.Created, - ResultId = "ResultIsCreated", - }, + Assert.Contains(new ResultIdStatus("ResultIsCreated", + ResultStatus.Created), result); } } diff --git a/Common/tests/TestBase/ResultWatcherTestBase.cs b/Common/tests/TestBase/ResultWatcherTestBase.cs index dcf8d89de..02e1d4cf6 100644 --- a/Common/tests/TestBase/ResultWatcherTestBase.cs +++ b/Common/tests/TestBase/ResultWatcherTestBase.cs @@ -21,7 +21,6 @@ using System.Threading; using System.Threading.Tasks; -using ArmoniK.Api.gRPC.V1; using ArmoniK.Core.Base.DataStructures; using ArmoniK.Core.Common.Storage; using ArmoniK.Core.Common.Storage.Events;