-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't wait for abandoned child workflow (#202)
* Don't wait for abandoned child workflow * Restore Workflow Test case
- Loading branch information
1 parent
d248301
commit 18bc538
Showing
8 changed files
with
98 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
tests/Fixtures/src/Workflow/AbandonedChildWithTimerWorkflow.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Temporal\Tests\Workflow; | ||
|
||
use Carbon\CarbonInterval; | ||
use Temporal\Activity\ActivityOptions; | ||
use Temporal\Common\RetryOptions; | ||
use Temporal\Workflow; | ||
use Temporal\Workflow\WorkflowInterface; | ||
use Temporal\Workflow\WorkflowMethod; | ||
|
||
#[WorkflowInterface] | ||
class AbandonedChildWithTimerWorkflow | ||
{ | ||
#[WorkflowMethod] | ||
public function wait(int $timeoutInSeconds) | ||
{ | ||
Workflow::timer($timeoutInSeconds); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
tests/Fixtures/src/Workflow/ParentWithAbandonedChildWorkflow.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Temporal\Tests\Workflow; | ||
|
||
use Temporal\Workflow; | ||
use Temporal\Workflow\ChildWorkflowOptions; | ||
use Temporal\Workflow\ParentClosePolicy; | ||
use Temporal\Workflow\WorkflowMethod; | ||
|
||
|
||
#[Workflow\WorkflowInterface] | ||
class ParentWithAbandonedChildWorkflow | ||
{ | ||
#[WorkflowMethod] | ||
public function start(int $childTimeoutInSeconds) | ||
{ | ||
$child = Workflow::newChildWorkflowStub( | ||
AbandonedChildWithTimerWorkflow::class, | ||
ChildWorkflowOptions::new() | ||
->withParentClosePolicy(ParentClosePolicy::POLICY_ABANDON) | ||
); | ||
|
||
$child->wait($childTimeoutInSeconds); | ||
|
||
return 'Welcome from parent'; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
tests/Functional/Client/AbandonedChildWorkflowTestCase.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Temporal\Tests\Functional\Client; | ||
|
||
use Temporal\Testing\WithoutTimeSkipping; | ||
use Temporal\Testing\WorkflowTestCase; | ||
use Temporal\Tests\Workflow\ParentWithAbandonedChildWorkflow; | ||
|
||
final class AbandonedChildWorkflowTestCase extends WorkflowTestCase | ||
{ | ||
use WithoutTimeSkipping; | ||
|
||
public function testParentEndsWithoutWaitingForChild(): void | ||
{ | ||
$timeBeforeStart = $this->testingService->getCurrentTime(); | ||
/** @var ParentWithAbandonedChildWorkflow $parentWorkflow */ | ||
$parentWorkflow = $this->workflowClient->newWorkflowStub(ParentWithAbandonedChildWorkflow::class); | ||
$parentWorkflow->start(10); | ||
$timeAfterStart = $this->testingService->getCurrentTime(); | ||
static::assertTrue($timeAfterStart->diffInSeconds($timeBeforeStart) < 2); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters