Skip to content

Conversation

@maxdml
Copy link
Collaborator

@maxdml maxdml commented Aug 11, 2025

This PR adds

  • many tests (listed below)
  • ability to register a workflow with a custom name.
  • returns an error (instead of a emitting a warning) when a workflow is enqueued in a different queue.

Custom name registration: we don't have custom interfaces / struct for workflows and at runtime have only access to the reflection-found workflow full qualified name. So we leverage the existing mechanism to retrieve registration-time workflow parameters (the registry is indexed by reflection names). This should be consistent within application versions, but remember that reflection names can change if the code changes.

Added Tests:

  1. Queue Conflicting Workflows: Tests that workflows with the same ID on different queues trigger ConflictingWorkflowError
  2. Workflow Registration: Tests for double registration scenarios (with/without custom names)
  3. Dynamic Registration: Tests that registering queues/workflows after launch panics
  4. Child Workflow Recovery: Tests polling handles for recovered child workflows
  5. concurrency tests: 3 new tests with 500 concurrent simple workflow, sender/receiver, setter/getter
  6. Verify step IDs and names for Send, Receive, SetEvent, GetEvent

_, err2 := handle.GetResult()
if err2 == nil {
t.Fatal("Second call to GetResult should return an error")
return nil, fmt.Errorf("Second call to GetResult should return an error")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t.Fatal terminates the goroutine, but this is an inner goroutine ran by the test goroutine itself. The resulting error is quite hard to parse and the test goroutine will move on to its cleanup actions, potentially deadlocking w/o much information. So, as a rule, we should only call t.Fatal in the "top level" test goroutine.

@maxdml maxdml marked this pull request as ready for review August 11, 2025 17:47
}

var typeErasedStepNameToStepName = make(map[string]string)
var typeErasedStepNameToStepName sync.Map
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This map should be read-mostly. The first invocation of a step will store the reflection name.


// Register adds a workflow function to the registry (thread-safe, only once per name)
func registerWorkflow(ctx DBOSContext, workflowName string, fn WrappedWorkflowFunc, maxRetries int) {
func registerWorkflow(ctx DBOSContext, workflowFQN string, fn WrappedWorkflowFunc, maxRetries int, customName string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's going on here? What's the difference between FQN and customName?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the tests seem to use neither?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The FQN is the reflection name, which we get with runtime.FuncForPC(reflect.ValueOf(fn).Pointer()).Name().

The FQN is the only information we get at runtime when a user calls RunAsWorkflow.

A user can set a custom name when registering a workflow. There are now tests exercising this path.

The custom name is stored in the registry, alongside other registration-time parameters like maxRetries.

RunAsWorkflow resolve the workflow name at runtime when looking up registration options (from the registry.)

@maxdml maxdml merged commit 13a3aac into main Aug 11, 2025
2 checks passed
@maxdml maxdml deleted the more-tests branch August 11, 2025 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants