Skip to content

Commit 0cf3b3d

Browse files
Merge pull request #66 from conductor-oss/tests-setup
Ensure test suites provision required resources on fresh clusters
2 parents ce57d1f + e47eff2 commit 0cf3b3d

File tree

2 files changed

+60
-1
lines changed

2 files changed

+60
-1
lines changed

tests/src/test/java/io/orkes/conductor/client/http/AuthorizationClientTests.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,34 @@ public static void setup() {
6363
request.setName("test-" + UUID.randomUUID());
6464
ConductorApplication app = authorizationClient.createApplication(request);
6565
applicationId = app.getId();
66+
67+
// 1) Ensure the external test group exists
68+
UpsertGroupRequest ensureGroup = new UpsertGroupRequest()
69+
.defaultAccess(
70+
Map.of(
71+
TypeEnum.WORKFLOW_DEF.getValue(), List.of("CREATE", "READ", "UPDATE", "EXECUTE", "DELETE"),
72+
TypeEnum.TASK_DEF.getValue(), List.of("CREATE", "READ", "UPDATE", "EXECUTE", "DELETE")))
73+
.description("Group used for SDK testing")
74+
.roles(List.of(RolesEnum.ADMIN));
75+
authorizationClient.upsertGroup(ensureGroup, "worker-test-group31dfe7a4-bd85-4ccc-9571-7c0e018ebc32");
76+
77+
// 2) Ensure the external test user exists
78+
UpsertUserRequest ensureUser = new UpsertUserRequest();
79+
ensureUser.setName("SDK Test User");
80+
ensureUser.setRoles(List.of(UpsertUserRequest.RolesEnum.USER));
81+
authorizationClient.upsertUser(ensureUser, "[email protected]");
82+
83+
// 3) Ensure the task definition used across tests exists
84+
try {
85+
metadataClient.getTaskDef(Commons.TASK_NAME);
86+
} catch (ConductorClientException e) {
87+
// Register when missing; ignore if already present
88+
if (e.getStatus() == 404) {
89+
metadataClient.registerTaskDefs(List.of(Commons.getTaskDef()));
90+
} else {
91+
throw e;
92+
}
93+
}
6694
}
6795

6896
@AfterAll
@@ -218,7 +246,6 @@ void testGrantPermissionsToDomain() {
218246
}
219247

220248
@Test
221-
@DisplayName("tag a workflows and task")
222249
public void tagWorkflowsAndTasks() {
223250
registerWorkflow();
224251
TagObject tagObject = new TagObject();

tests/src/test/java/io/orkes/conductor/client/http/WorkflowStateUpdateTests.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@
2323
import org.junit.jupiter.api.Test;
2424

2525
import com.netflix.conductor.client.exception.ConductorClientException;
26+
import com.netflix.conductor.common.metadata.tasks.TaskType;
2627
import com.netflix.conductor.common.metadata.tasks.Task;
2728
import com.netflix.conductor.common.metadata.tasks.TaskResult;
29+
import com.netflix.conductor.common.metadata.workflow.WorkflowDef;
30+
import com.netflix.conductor.common.metadata.workflow.WorkflowTask;
2831
import com.netflix.conductor.common.metadata.workflow.IdempotencyStrategy;
2932
import com.netflix.conductor.common.metadata.workflow.StartWorkflowRequest;
3033
import com.netflix.conductor.common.run.Workflow;
@@ -42,10 +45,39 @@
4245
public class WorkflowStateUpdateTests {
4346

4447
private static OrkesWorkflowClient workflowClient;
48+
private static OrkesMetadataClient metadataClient;
4549

4650
@BeforeAll
4751
public static void init() {
4852
workflowClient = ClientTestUtil.getOrkesClients().getWorkflowClient();
53+
metadataClient = ClientTestUtil.getOrkesClients().getMetadataClient();
54+
55+
// Ensure required workflow exists on fresh clusters
56+
try {
57+
metadataClient.getWorkflowDef("sync_task_variable_updates", 1);
58+
} catch (ConductorClientException e) {
59+
if (e.getStatus() == 404) {
60+
WorkflowDef def = new WorkflowDef();
61+
def.setName("sync_task_variable_updates");
62+
def.setVersion(1);
63+
def.setOwnerEmail("[email protected]");
64+
65+
WorkflowTask wait1 = new WorkflowTask();
66+
wait1.setName(TaskType.WAIT.name());
67+
wait1.setTaskReferenceName("wait_task_ref");
68+
wait1.setType(TaskType.WAIT.name());
69+
70+
WorkflowTask wait2 = new WorkflowTask();
71+
wait2.setName(TaskType.WAIT.name());
72+
wait2.setTaskReferenceName("wait_task_ref_2");
73+
wait2.setType(TaskType.WAIT.name());
74+
75+
def.setTasks(List.of(wait1, wait2));
76+
metadataClient.registerWorkflowDef(def);
77+
} else {
78+
throw e;
79+
}
80+
}
4981
}
5082

5183
@SneakyThrows

0 commit comments

Comments
 (0)