Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ SignalWithStartWorkflowExecutionRequest.Builder newSignalWithStartWorkflowExecut
request.setVersioningOverride(startParameters.getVersioningOverride());
}

if (startParameters.hasPriority()) {
request.setPriority(startParameters.getPriority());
}
return request;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
import io.temporal.activity.ActivityInterface;
import io.temporal.activity.ActivityOptions;
import io.temporal.client.WorkflowOptions;
import io.temporal.client.WorkflowStub;
import io.temporal.common.Priority;
import io.temporal.testing.internal.SDKTestWorkflowRule;
import io.temporal.workflow.shared.TestWorkflows;
import io.temporal.workflow.shared.TestWorkflows.TestWorkflow1;
import java.time.Duration;
import java.util.UUID;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
Expand All @@ -20,7 +22,10 @@ public class PriorityInfoTest {
@Rule
public SDKTestWorkflowRule testWorkflowRule =
SDKTestWorkflowRule.newBuilder()
.setWorkflowTypes(TestPriority.class, TestPriorityChildWorkflow.class)
.setWorkflowTypes(
TestPriority.class,
TestPriorityChildWorkflow.class,
TestSignalWithStartPriorityWorkflowImpl.class)
.setActivityImplementations(new PriorityActivitiesImpl())
.build();

Expand All @@ -44,6 +49,24 @@ public void testPriority() {
assertEquals("5:tenant-123:2.5", result);
}

@Test
public void testPriorityWithSignalWithStart() {
WorkflowStub stub =
testWorkflowRule
.getWorkflowClient()
.newUntypedWorkflowStub(
"TestSignalWithStartPriorityWorkflow",
WorkflowOptions.newBuilder()
.setWorkflowId("test-signal-with-start-priority-" + UUID.randomUUID())
.setTaskQueue(testWorkflowRule.getTaskQueue())
.setPriority(Priority.newBuilder().setPriorityKey(2).build())
.build());
stub.signalWithStart(
"mySignal", new Object[] {"signalArg"}, new Object[] {testWorkflowRule.getTaskQueue()});
String result = stub.getResult(String.class);
assertEquals("2:null:0.0", result);
}

@ActivityInterface
public interface PriorityActivities {
String activity1(String a1);
Expand Down Expand Up @@ -131,4 +154,32 @@ public String execute(String taskQueue) {
+ workflowPriority.getFairnessWeight();
}
}

@WorkflowInterface
public interface TestSignalWithStartPriorityWorkflow {
@WorkflowMethod
String execute(String taskQueue);

@SignalMethod
void mySignal(String arg);
}

public static class TestSignalWithStartPriorityWorkflowImpl
implements TestSignalWithStartPriorityWorkflow {

private boolean received = false;

@Override
public String execute(String taskQueue) {
Workflow.await(() -> received);
Priority priority = Workflow.getInfo().getPriority();
String key = priority.getFairnessKey() != null ? priority.getFairnessKey() : "null";
return priority.getPriorityKey() + ":" + key + ":" + priority.getFairnessWeight();
}

@Override
public void mySignal(String arg) {
received = true;
}
}
}