Skip to content

Commit

Permalink
tests and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
v1r3n committed Jan 29, 2024
1 parent 2d72688 commit 2b8e595
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ext {
versions = [
awaitility : '4.2.0',
commonsLang : '3.12.0',
conductor : '3.9.24-orkes',
conductor : '3.9.30-orkes',
jackson : '2.11.4!!',
junit : '5.9.0',
slf4j : '1.7.36',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.netflix.conductor.common.run.WorkflowSummary;
import com.netflix.conductor.common.run.WorkflowTestRequest;
import com.netflix.conductor.common.utils.ExternalPayloadStorage;

import io.orkes.conductor.client.http.ConflictException;

public abstract class WorkflowClient {
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/orkes/conductor/client/ApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,15 @@

import javax.net.ssl.*;

import com.netflix.conductor.common.validation.ErrorResponse;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.threeten.bp.LocalDate;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.format.DateTimeFormatter;

import com.netflix.conductor.common.validation.ErrorResponse;

import io.orkes.conductor.client.http.*;
import io.orkes.conductor.client.http.api.TokenResourceApi;
import io.orkes.conductor.client.http.auth.ApiKeyAuth;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public abstract Map<String, List<Workflow>> getWorkflowsByNamesAndCorrelationIds
* the call will return with the current status of the workflow
* @param updateRequest Payload for updating state of workflow.
*
* @return
* @return Returns updated workflow execution
*/
public abstract WorkflowRun updateWorkflow(String workflowId, List<String> waitUntilTaskRefNames, Integer waitForSeconds,
WorkflowStateUpdate updateRequest);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
*/
package io.orkes.conductor.client.http;

import io.orkes.conductor.client.OrkesClientException;
import org.apache.commons.lang3.StringUtils;

import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;

import io.orkes.conductor.client.OrkesClientException;

public class ConflictException extends OrkesClientException {

private int code;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
import java.util.UUID;
import java.util.concurrent.*;

import com.netflix.conductor.common.metadata.workflow.*;
import org.apache.commons.lang.StringUtils;

import com.netflix.conductor.common.metadata.workflow.*;
import com.netflix.conductor.common.model.BulkResponse;
import com.netflix.conductor.common.run.SearchResult;
import com.netflix.conductor.common.run.Workflow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.orkes.conductor.client.util.ApiUtil;

public abstract class ClientTest {

protected static OrkesClients orkesClients;

static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ public void testSkipTaskFromWorkflow() throws Exception {
() -> workflowClient.terminateWorkflowsWithFailure(List.of(workflowId), null, false));
}

@Test
public void testUpdateVariables() {
ConductorWorkflow<Object> workflow = new ConductorWorkflow<>(workflowExecutor);
workflow.add(new SimpleTask("simple_task", "simple_task_ref"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

Expand All @@ -23,16 +24,19 @@

import com.netflix.conductor.common.metadata.tasks.Task;
import com.netflix.conductor.common.metadata.tasks.TaskResult;
import com.netflix.conductor.common.metadata.workflow.IdempotencyStrategy;
import com.netflix.conductor.common.metadata.workflow.StartWorkflowRequest;
import com.netflix.conductor.common.run.Workflow;

import io.orkes.conductor.client.WorkflowClient;
import io.orkes.conductor.client.http.ConflictException;
import io.orkes.conductor.client.model.WorkflowStateUpdate;
import io.orkes.conductor.common.model.WorkflowRun;

import lombok.SneakyThrows;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class WorkflowStateUpdateTests extends ClientTest {

Expand Down Expand Up @@ -96,4 +100,29 @@ public void test() {
.collect(Collectors.toList()));

}

@Test
public void testIdempotency() {
StartWorkflowRequest startWorkflowRequest = new StartWorkflowRequest();
startWorkflowRequest.setName("sync_task_variable_updates");
startWorkflowRequest.setVersion(1);
String idempotencyKey = UUID.randomUUID().toString();
startWorkflowRequest.setIdempotencyKey(idempotencyKey);
startWorkflowRequest.setIdempotencyStrategy(IdempotencyStrategy.FAIL);
String workflowId = workflowClient.startWorkflow(startWorkflowRequest);


startWorkflowRequest.setIdempotencyStrategy(IdempotencyStrategy.RETURN_EXISTING);
String workflowId2 = workflowClient.startWorkflow(startWorkflowRequest);
assertEquals(workflowId, workflowId2);

startWorkflowRequest.setIdempotencyStrategy(IdempotencyStrategy.FAIL);
boolean conflict = false;
try {
workflowClient.startWorkflow(startWorkflowRequest);
} catch (ConflictException ce) {
conflict = true;
}
assertTrue(conflict);
}
}

0 comments on commit 2b8e595

Please sign in to comment.