Skip to content

Commit

Permalink
Merge pull request #118 from Jithesh-poojary/main
Browse files Browse the repository at this point in the history
Fix for TimeOut issue
  • Loading branch information
v1r3n authored May 9, 2024
2 parents f15ab16 + 9c13a41 commit 97fdb17
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
10 changes: 4 additions & 6 deletions Conductor/Client/ApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private RestRequest PrepareRequest(

/// <summary>
/// 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
/// </summary>
/// <param name="path">URL path.</param>
/// <param name="method">HTTP method.</param>
Expand Down Expand Up @@ -200,12 +200,10 @@ private RestResponse RetryRestClientCallApi(String path, Method method, List<Key
string refreshToken = configuration.GetRefreshToken();
headerParams["X-Authorization"] = refreshToken;
retryCount++;
continue;
}
}
else
{
break;
}
break;
}
return response;
}
Expand Down Expand Up @@ -551,7 +549,7 @@ public static string SanitizeFilename(string filename)
}

/// <summary>
/// Convert params to key/value pairs.
/// Convert params to key/value pairs.
/// Use collectionFormat to properly format lists and collections.
/// </summary>
/// <param name="name">Key name.</param>
Expand Down
13 changes: 8 additions & 5 deletions Tests/Worker/AnnotatedWorkerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -24,12 +25,14 @@ public class AnnotatedWorkerTest
public AnnotatedWorkerTest()
{
_metaDataClient = ApiExtensions.GetClient<MetadataResourceApi>();
_workflowClient = ApiExtensions.GetClient<WorkflowResourceApi>();
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<MetadataResourceApi>();
//_workflowClient = _orkesApiClient.GetClient<WorkflowResourceApi>();
}

[Fact]
Expand Down Expand Up @@ -115,17 +118,17 @@ private ConductorWorkflow GetConductorWorkflow()
}

/// <summary>
/// Registers and starts a workflow
/// Registers and starts a workflow
/// </summary>
/// <param name="workflow"></param>
/// <param name="taskDefs"></param>
/// <param name="inputData"></param>
private void RegisterAndStartWorkflow(ConductorWorkflow workflow, List<TaskDef> taskDefs, Dictionary<string, object> inputData = default)
{
_metaDataClient.RegisterTaskDef(taskDefs);
_workflowExecutor.RegisterWorkflow(workflow, true);
_metaDataClient.UpdateWorkflowDefinitions(new List<WorkflowDef>(1) { workflow });

StartWorkflowRequest startWorkflow = new StartWorkflowRequest()
StartWorkflowRequest startWorkflowRequest = new StartWorkflowRequest()
{
Name = workflow.Name,
Input = inputData,
Expand All @@ -134,7 +137,7 @@ private void RegisterAndStartWorkflow(ConductorWorkflow workflow, List<TaskDef>
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();
Expand Down
8 changes: 4 additions & 4 deletions Tests/Worker/TestWorkflows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<WorkflowResourceApi>();
_metaDataClient = ApiExtensions.GetClient<MetadataResourceApi>();
_logger = ApplicationLogging.CreateLogger<TestWorkflows>();

//For local testing
//_orkesApiClient = new OrkesApiClient(config, new OrkesAuthenticationSettings(Constants.KEY_ID, Constants.KEY_SECRET));
//workflowClient = _orkesApiClient.GetClient<WorkflowResourceApi>();
// _metaDataClient = _orkesApiClient.GetClient<MetadataResourceApi>();
}

[Fact]
Expand Down Expand Up @@ -71,7 +71,7 @@ public void TestWorkflowExecution()
new TaskMock{ ExecutionTime= 1, Status = TaskMock.StatusEnum.COMPLETED, QueueWaitTime= 10, Output = new Dictionary<string, Object> {{"key", "http.output"}}}
};

_workflowExecutor.RegisterWorkflow(workflow, true);
_metaDataClient.UpdateWorkflowDefinitions(new List<WorkflowDef>(1) { workflow });

var testRequest = new WorkflowTestRequest(name: workflow.Name, version: workflow.Version, taskRefToMockOutput: taskRefToMockOutput, workflowDef: workflow);
var run = workflowClient.TestWorkflow(testRequest);
Expand Down

0 comments on commit 97fdb17

Please sign in to comment.