Skip to content

Commit

Permalink
Sync DeduplicationTest with Harness repo
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Jan 20, 2025
1 parent fffcc39 commit f6660c7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
2 changes: 1 addition & 1 deletion tests/Acceptance/Extra/Update/UpdateWithStartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function failWithBadUpdateName(
$this->assertStringContainsString('await1234', $e->getPrevious()->getMessage());
} finally {
try {
$stub->getResult(timeout: 1);
$stub->getResult();
$this->fail('Workflow must fail');
} catch (WorkflowFailedException) {
$this->assertTrue(true);
Expand Down
14 changes: 7 additions & 7 deletions tests/Acceptance/Extra/Workflow/AllHandlersFinishedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function updateHandlersWithOneCall(
$resolver = $stub->startUpdate('resolve', "key", "resolved");

// Should be completed after the previous operation
$result = $stub->getResult(timeout: 1);
$result = $stub->getResult();

$this->assertSame(['key' => 'resolved'], (array) $result, 'Workflow result contains resolved value');
$this->assertFalse($handle->hasResult());
Expand Down Expand Up @@ -58,7 +58,7 @@ public function updateHandlersWithManyCalls(
}

// Should be completed after the previous operation
$result = $stub->getResult(timeout: 1);
$result = $stub->getResult();

$this->assertSame(
[
Expand Down Expand Up @@ -87,7 +87,7 @@ public function signalHandlersWithOneCall(
/** @see TestWorkflow::resolveFromSignal() */
$stub->signal('resolve', "key", "resolved");

$result = $stub->getResult(timeout: 1);
$result = $stub->getResult();

$this->assertSame(['key' => 'resolved'], (array) $result, 'Workflow result contains resolved value');
}
Expand All @@ -106,7 +106,7 @@ public function signalHandlersWithManyCalls(
$stub->signal('resolve', "key-$i", "resolved-$i");
}

$result = $stub->getResult(timeout: 1);
$result = $stub->getResult();

$this->assertSame(
[
Expand Down Expand Up @@ -153,7 +153,7 @@ public function warnUnfinishedSignals(

// Finish the workflow
$stub->signal('exit');
$stub->getResult(timeout: 1);
$stub->getResult();

// todo Check that `await` signal with count was mentioned in the logs
}
Expand All @@ -173,7 +173,7 @@ public function warnUnfinishedUpdates(

// Finish the workflow
$stub->signal('exit');
$stub->getResult(timeout: 1);
$stub->getResult();

// todo Check that `await` updates was mentioned in the logs
}
Expand All @@ -194,7 +194,7 @@ public function warnUnfinishedOnCancel(
$stub->cancel();

try {
$stub->getResult(timeout: 1);
$stub->getResult();
$this->fail('Cancellation exception must be thrown');
} catch (WorkflowFailedException) {
// Expected
Expand Down
12 changes: 3 additions & 9 deletions tests/Acceptance/Harness/Update/DeduplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Temporal\Client\Update\UpdateOptions;
use Temporal\Client\WorkflowClientInterface;
use Temporal\Client\WorkflowStubInterface;
use Temporal\Exception\Client\WorkflowUpdateException;
use Temporal\Tests\Acceptance\App\Attribute\Stub;
use Temporal\Tests\Acceptance\App\TestCase;
use Temporal\Workflow;
Expand Down Expand Up @@ -40,13 +39,8 @@ public function check(
self::assertSame(1, $handle1->getResult(1));
self::assertSame(1, $handle2->getResult(1));

try {
# This only needs to start to unblock the workflow
$stub->startUpdate('my_update');
} catch (WorkflowUpdateException) {
# Workflow Update failed because the Workflow completed before the Update completed
# It's OK in this case
}
# This only needs to start to unblock the workflow
$stub->startUpdate('my_update');

# There should be two accepted updates, and only one of them should be completed with the set id
$totalUpdates = 0;
Expand All @@ -70,7 +64,7 @@ class FeatureWorkflow
#[WorkflowMethod('Harness_Update_Deduplication')]
public function run()
{
yield Workflow::await(fn(): bool => $this->counter >= 2);
yield Workflow::await(fn(): bool => $this->counter >= 2 && Workflow::allHandlersFinished());
return $this->counter;
}

Expand Down

0 comments on commit f6660c7

Please sign in to comment.