From 7d50b35610f1a83cf2406471cb2bddb90735df7b Mon Sep 17 00:00:00 2001 From: Jithesh Poojary Date: Wed, 8 May 2024 18:16:33 +0530 Subject: [PATCH 1/2] Fix for Timeout issue --- Conductor/Client/ApiClient.cs | 12 +++++------- Tests/Worker/AnnotatedWorkerTest.cs | 13 ++++++++----- Tests/Worker/TestWorkflows.cs | 8 ++++---- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Conductor/Client/ApiClient.cs b/Conductor/Client/ApiClient.cs index e6bbe06..253d108 100644 --- a/Conductor/Client/ApiClient.cs +++ b/Conductor/Client/ApiClient.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +.using Newtonsoft.Json; using Newtonsoft.Json.Linq; using RestSharp; using System; @@ -149,7 +149,7 @@ private RestRequest PrepareRequest( /// /// Makes the HTTP request (Sync). - /// If the token is expired then retrying the api call with refreshed Token + /// If the token is expired then retrying the api call with refreshed Token /// /// URL path. /// HTTP method. @@ -200,12 +200,10 @@ private RestResponse RetryRestClientCallApi(String path, Method method, List - /// Convert params to key/value pairs. + /// Convert params to key/value pairs. /// Use collectionFormat to properly format lists and collections. /// /// Key name. diff --git a/Tests/Worker/AnnotatedWorkerTest.cs b/Tests/Worker/AnnotatedWorkerTest.cs index 43581b2..9fba260 100644 --- a/Tests/Worker/AnnotatedWorkerTest.cs +++ b/Tests/Worker/AnnotatedWorkerTest.cs @@ -15,6 +15,7 @@ namespace Tests.Worker public class AnnotatedWorkerTest { private readonly MetadataResourceApi _metaDataClient; + private readonly WorkflowResourceApi _workflowClient; private readonly WorkflowExecutor _workflowExecutor; private const string WORKFLOW_NAME = "test-annotation"; @@ -24,12 +25,14 @@ public class AnnotatedWorkerTest public AnnotatedWorkerTest() { _metaDataClient = ApiExtensions.GetClient(); + _workflowClient = ApiExtensions.GetClient(); var config = new Configuration(); _workflowExecutor = new WorkflowExecutor(config); //dev local testing - //var _orkesApiClient = new OrkesApiClient(config, new OrkesAuthenticationSettings(Constants.KEY_ID, Constants.KEY_SECRET)); + // var _orkesApiClient = new OrkesApiClient(config, new OrkesAuthenticationSettings(Constants.KEY_ID, Constants.KEY_SECRET)); //_metaDataClient = _orkesApiClient.GetClient(); + //_workflowClient = _orkesApiClient.GetClient(); } [Fact] @@ -115,7 +118,7 @@ private ConductorWorkflow GetConductorWorkflow() } /// - /// Registers and starts a workflow + /// Registers and starts a workflow /// /// /// @@ -123,9 +126,9 @@ private ConductorWorkflow GetConductorWorkflow() private void RegisterAndStartWorkflow(ConductorWorkflow workflow, List taskDefs, Dictionary inputData = default) { _metaDataClient.RegisterTaskDef(taskDefs); - _workflowExecutor.RegisterWorkflow(workflow, true); + _metaDataClient.UpdateWorkflowDefinitions(new List(1) { workflow }); - StartWorkflowRequest startWorkflow = new StartWorkflowRequest() + StartWorkflowRequest startWorkflowRequest = new StartWorkflowRequest() { Name = workflow.Name, Input = inputData, @@ -134,7 +137,7 @@ private void RegisterAndStartWorkflow(ConductorWorkflow workflow, List CreatedBy = Constants.OWNER_EMAIL }; - _workflowExecutor.StartWorkflow(startWorkflow); + _workflowClient.StartWorkflow(startWorkflowRequest); var waitHandle = new ManualResetEvent(false); var backgroundTask = System.Threading.Tasks.Task.Run(async () => await Conductor.Examples.Utils.WorkerUtil.StartBackGroundTask(waitHandle)); waitHandle.WaitOne(); diff --git a/Tests/Worker/TestWorkflows.cs b/Tests/Worker/TestWorkflows.cs index afdc6e5..66692af 100644 --- a/Tests/Worker/TestWorkflows.cs +++ b/Tests/Worker/TestWorkflows.cs @@ -5,7 +5,6 @@ using Conductor.Client.Models; using Conductor.Definition; using Conductor.Definition.TaskType; -using Conductor.Executor; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; @@ -17,19 +16,20 @@ public class TestWorkflows { private readonly OrkesApiClient _orkesApiClient; private readonly WorkflowResourceApi workflowClient; - private readonly WorkflowExecutor _workflowExecutor; + private readonly MetadataResourceApi _metaDataClient; private ILogger _logger; public TestWorkflows() { var config = new Configuration(); - _workflowExecutor = new WorkflowExecutor(config); workflowClient = ApiExtensions.GetClient(); + _metaDataClient = ApiExtensions.GetClient(); _logger = ApplicationLogging.CreateLogger(); //For local testing //_orkesApiClient = new OrkesApiClient(config, new OrkesAuthenticationSettings(Constants.KEY_ID, Constants.KEY_SECRET)); //workflowClient = _orkesApiClient.GetClient(); + // _metaDataClient = _orkesApiClient.GetClient(); } [Fact] @@ -71,7 +71,7 @@ public void TestWorkflowExecution() new TaskMock{ ExecutionTime= 1, Status = TaskMock.StatusEnum.COMPLETED, QueueWaitTime= 10, Output = new Dictionary {{"key", "http.output"}}} }; - _workflowExecutor.RegisterWorkflow(workflow, true); + _metaDataClient.UpdateWorkflowDefinitions(new List(1) { workflow }); var testRequest = new WorkflowTestRequest(name: workflow.Name, version: workflow.Version, taskRefToMockOutput: taskRefToMockOutput, workflowDef: workflow); var run = workflowClient.TestWorkflow(testRequest); From 9c13a41ea1979d2f2ff319ffec5d9ad3dd5d0c6a Mon Sep 17 00:00:00 2001 From: Jithesh <92319982+Jithesh-poojary@users.noreply.github.com> Date: Wed, 8 May 2024 18:37:32 +0530 Subject: [PATCH 2/2] Fix for Timeout issue --- Conductor/Client/ApiClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Conductor/Client/ApiClient.cs b/Conductor/Client/ApiClient.cs index 253d108..55ae679 100644 --- a/Conductor/Client/ApiClient.cs +++ b/Conductor/Client/ApiClient.cs @@ -1,4 +1,4 @@ -.using Newtonsoft.Json; +using Newtonsoft.Json; using Newtonsoft.Json.Linq; using RestSharp; using System;