Skip to content
Merged
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
14 changes: 14 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,20 @@ jobs:
QUEUE_CONNECTION: redis
XDEBUG_MODE: off

- name: Run service scheduling and completion contracts
run: >-
vendor/bin/phpunit tests/Unit/V2/DefaultServiceControlPlaneWorkflowBindingTest.php
tests/Unit/V2/ServiceCallEffectIdentityTest.php
tests/Unit/V2/WebhookInputValidationTest.php
tests/Unit/V2/WorkflowExecutorServiceOperationTest.php
tests/Unit/V2/DefaultWorkflowTaskBridgeServiceOperationTest.php
tests/Unit/V2/ServiceCallSchedulerTest.php
--fail-on-warning --log-junit build/test-results/pr-smoke-service-scheduling.xml
env:
DB_CONNECTION: mysql
QUEUE_CONNECTION: redis
XDEBUG_MODE: off

- name: Upload pull-request MySQL smoke timing report
if: ${{ always() && github.server_url == 'https://github.com' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
Expand Down
4 changes: 4 additions & 0 deletions src/V2/Support/DefaultServiceControlPlane.php
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,10 @@ private function dispatchWorkflowUpdate(
$commandOptions['wait_for'] ??= $call->operation_mode === ServiceCallOperationMode::Sync->value
? 'completed'
: 'accepted';
if ($call->getConnection()->transactionLevel() > 0) {
$commandOptions['wait_for'] = UpdateWaitPolicy::WAIT_FOR_ACCEPTED;
unset($commandOptions['wait_timeout_seconds']);
}

try {
$result = $this->workflows()
Expand Down
5 changes: 3 additions & 2 deletions tests/Unit/V2/ServiceCallEffectIdentityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ private function currentClaim(WorkflowStub $caller): array
'handler_target_reference' => 'change',
]);
$control = new DefaultServiceControlPlane(new DefaultWorkflowControlPlane());
DB::transaction(static fn (): array => $control->execute('billing', 'effects', 'apply', [
$options = ServiceCallScheduler::withAfterCommitAuthority([
'namespace' => 'billing',
'caller_namespace' => $run->namespace,
'caller_workflow_instance_id' => $caller->id(),
Expand All @@ -451,7 +451,8 @@ private function currentClaim(WorkflowStub $caller): array
'idempotency_key' => 'effect-identity-' . $caller->id(),
'wait_for' => 'completed',
'wait_timeout_seconds' => 60,
]));
]);
DB::transaction(static fn (): array => $control->execute('billing', 'effects', 'apply', $options));
$claim = ServiceCallScheduler::claim(WorkflowServiceCall::query()->sole()->id);
$this->assertNotNull($claim);
$identity = ServiceCallEffectIdentity::forCurrentClaim($claim);
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/V2/ServiceCallSchedulerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ public function testCallerContextAndIdempotencyTransactionDoNotScheduleAnHttpExe
return $instanceId === 'accepted-target'
&& $name === 'approve'
&& WorkflowServiceCall::query()->getModel()->getConnection()->transactionLevel() === 1
&& $options['wait_for'] === 'completed'
&& $options['wait_timeout_seconds'] === 60;
&& $options['wait_for'] === 'accepted'
&& ! array_key_exists('wait_timeout_seconds', $options);
})
->andReturn([
'accepted' => true,
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/V2/WebhookInputValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ public function testMalformedRequestReportsItsFieldBeforeChangingDurableRecords(
'name' => 'Ada',
], $payload);
}
if (str_ends_with($path, '/complete')) {
$this->withHeader('X-Durable-Workflow-Protocol-Version', '1.20');
}
$before = $this->records();
$writes = [];
DB::listen(static function (QueryExecuted $event) use (&$writes): void {
Expand Down
6 changes: 5 additions & 1 deletion tests/Unit/V2/WorkflowExecutorServiceOperationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use Workflow\V2\Support\RunServiceOperationAuthorizer;
use Workflow\V2\Support\RunTimelineProjector;
use Workflow\V2\Support\ServiceCallPrincipal;
use Workflow\V2\Support\ServiceCallScheduler;
use Workflow\V2\Support\ServiceOperationOptions;
use Workflow\V2\Support\ServiceOperationResult;
use Workflow\V2\Support\WorkerCompatibilityFleet;
Expand Down Expand Up @@ -138,8 +139,11 @@ public function testPublicExecutionRecordsTheBoundaryOutcomeAndReplaysWithoutCal
}
$this->assertInstanceOf(ServiceCallPrincipal::class, $service->executions[0][3]['principal']);
$service->executions[0][3]['principal'] = $service->executions[0][3]['principal']->toAuditArray();
$this->assertTrue(ServiceCallScheduler::hasAfterCommitAuthority($service->executions[0][3]));
$this->assertSame(
$this->ordered(['billing', 'invoices', 'create', $expectedOptions]),
$this->ordered(
['billing', 'invoices', 'create', ServiceCallScheduler::withAfterCommitAuthority($expectedOptions)]
),
$this->ordered($service->executions[0])
);
$event = WorkflowHistoryEvent::query()->where('workflow_run_id', $run->id)->whereIn('event_type', [
Expand Down
Loading