[Bug] Can't run the tests of UpdateMethod
Hello, I want to test UpdateMethod in workflow. But I get an error:
AssertionError: assert($result !== null)
/var/www/html/vendor/temporal/sdk/src/Client/Update/UpdateHandle.php:128
/var/www/html/vendor/temporal/sdk/src/Client/Update/UpdateHandle.php:89
/var/www/html/vendor/temporal/sdk/src/Client/Update/UpdateHandle.php:75
/var/www/html/vendor/temporal/sdk/src/Internal/Client/WorkflowProxy.php:112
/var/www/html/tests/Workflows/UploadFileWorkflowTest.php:83
At the same time, the signal and jquery tests are working fine.
Here is the test code:
public function testCanSaveFileData(): void
{
$this->testService->lockTimeSkipping();
$arguments = [
'path' => $this->faker()->filePath(),
'original_name' => $this->faker()->word(),
'extension' => $this->faker()->fileExtension(),
'size' => $this->faker()->numberBetween(),
'is_image' => $this->faker()->boolean(),
];
$file = File::factory()->make($arguments);
$workflow = $this->workflowClient->newWorkflowStub(UploadFileWorkflow::class);
$run = $this->workflowClient->start($workflow);
$this->assertEquals(WorkflowExecutionStatus::Running, $run->describe()->info->status);
$result = $workflow->saveTempFileData(new SaveFileDataArguments($arguments));
$this->assertEquals($file->id, $run->describe()->info->searchAttributes->getValue('FileId'));
$this->assertEquals($file->toArray(), $result['data']);
$this->testService->unlockTimeSkipping();
}
I tried calling UpdateMethod via update and startUpdate. the result is exactly the same
Related with https://github.com/temporalio/sdk-php/pull/526
This situation can occur when the Workflow neither accepts nor rejects the Update due to:
- No available workers
- Workflow Task fails in the same tick
Unfortunately, I've already checked this. The workers are running, and workflow is not crashing.
Here is the config:
version: "3"
rpc:
listen: ${TEMPORAL_TESTING_HOST:-tcp://127.0.0.1:6001}
server:
command: "php worker.php"
temporal:
address: ${TEMPORAL_ADDRESS:-127.0.0.1:7233}
activities:
num_workers: 2
logs:
level: info
channels:
server:
mode: debug
output: worker.log
kv:
testing:
driver: memory
config:
interval: 10
Here is the worker's code:
require 'vendor/autoload.php';
$app = require 'bootstrap/app.php';
$app->make(Kernel::class)->bootstrap();
$factory = WorkerFactory::create(
rpc: new Goridge(Relay::create(config('testing.temporal.host'))),
activityCache: RoadRunnerActivityInvocationCache::create()
);
$worker = $factory->newWorker(
taskQueue: config('testing.temporal.queue'),
interceptorProvider: new SimplePipelineProvider(
app(InterceptorCollection::class)->toArray(),
),
);
$worker->registerWorkflowTypes(...config('orchestrator.temporal.workflows'));
foreach (config("orchestrator.temporal.activities", []) as $activityType) {
$worker->registerActivity($activityType, fn(ReflectionClass $class) => app($class->getName()));
}
$factory->run();
error_log('stop worker');
$this->testService->lockTimeSkipping();
Are you using the Test Server? Does it already support updates?
I use the TestService in the base TestCase class
$temporalAddress = getenv('TEMPORAL_ADDRESS') ?: '127.0.0.1:7233';
$this->testService = TestService::create($temporalAddress);
I'm running the test server through Environment
use Temporal\Testing\Environment;
require getcwd().'/vendor/autoload.php';
if (env('TEMPORAL_TESTING_ENABLED') === true) {
$environment = Environment::create();
$environment->start(
rrCommand: './rr serve -d -c '.__DIR__.'/.rr.yaml -w '.__DIR__
);
register_shutdown_function(fn() => $environment->stop());
}
And how can I find out that the test server supports updates? I didn't find it in the documentation.
And how can I find out that the test server supports updates? I didn't find it in the documentation.
This is not in the documentation. The temporal-test-server is taken from the release artifacts of the JAVA SDK. You can track release notes and issues.
Try the dev-server. There is no timeskipping but it works with the most Temporal features
I'm also hitting the same (or similar) problem when trying to write some tests for updates on a workflow.
Looks like "test-server" has support for update: https://github.com/temporalio/sdk-java/issues/1742
I either hit a Temporal\Exception\DestructMemorizedInstanceException exception or if i disable the DestroyWorkflow process than I get a timeout.
I've added debug code to the Workflow update method which shows its working nicely, it just never gets returned.