Fix escaping, write tests for stdout/stderr, upgrade runtimes to V2
This commit is contained in:
parent
4fb743e934
commit
7d9f973c62
|
@ -7,7 +7,7 @@
|
|||
use Utopia\App;
|
||||
use Appwrite\Runtimes\Runtimes;
|
||||
|
||||
$runtimes = new Runtimes('v1');
|
||||
$runtimes = new Runtimes('v2');
|
||||
|
||||
$allowList = empty(App::getEnv('_APP_FUNCTIONS_RUNTIMES')) ? [] : \explode(',', App::getEnv('_APP_FUNCTIONS_RUNTIMES'));
|
||||
|
||||
|
|
|
@ -547,7 +547,7 @@ App::post('/v1/execution')
|
|||
$stdout = $executorResponse['stdout'];
|
||||
$res = $executorResponse['response'];
|
||||
if (is_array($res)) {
|
||||
$res = json_encode($res);
|
||||
$res = json_encode($res, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -657,7 +657,7 @@ $http->on('start', function ($http) {
|
|||
/**
|
||||
* Warmup: make sure images are ready to run fast 🚀
|
||||
*/
|
||||
$runtimes = new Runtimes('v1');
|
||||
$runtimes = new Runtimes('v2');
|
||||
$allowList = empty(App::getEnv('_APP_FUNCTIONS_RUNTIMES')) ? [] : \explode(',', App::getEnv('_APP_FUNCTIONS_RUNTIMES'));
|
||||
$runtimes = $runtimes->getAll(true, $allowList);
|
||||
foreach ($runtimes as $runtime) {
|
||||
|
|
|
@ -397,6 +397,9 @@ class FunctionsCustomClientTest extends Scope
|
|||
$this->assertEquals($this->getUser()['$id'], $output['APPWRITE_FUNCTION_USER_ID']);
|
||||
$this->assertNotEmpty($output['APPWRITE_FUNCTION_JWT']);
|
||||
$this->assertEquals($projectId, $output['APPWRITE_FUNCTION_PROJECT_ID']);
|
||||
// Client should never see logs and errors
|
||||
$this->assertEmpty($execution['body']['stdout']);
|
||||
$this->assertEmpty($execution['body']['stderr']);
|
||||
|
||||
// Cleanup : Delete function
|
||||
$response = $this->client->call(Client::METHOD_DELETE, '/functions/' . $functionId, [
|
||||
|
|
|
@ -866,6 +866,7 @@ class FunctionsCustomServerTest extends Scope
|
|||
$this->assertEquals('', $output['APPWRITE_FUNCTION_USER_ID']);
|
||||
$this->assertEmpty($output['APPWRITE_FUNCTION_JWT']);
|
||||
$this->assertEquals($this->getProject()['$id'], $output['APPWRITE_FUNCTION_PROJECT_ID']);
|
||||
$this->assertStringContainsString('Amazing Function Log', $executions['body']['stdout']);
|
||||
|
||||
$executions = $this->client->call(Client::METHOD_GET, '/functions/' . $functionId . '/executions', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
|
@ -893,7 +894,7 @@ class FunctionsCustomServerTest extends Scope
|
|||
|
||||
public function testCreateCustomNodeExecution()
|
||||
{
|
||||
$name = 'node-17.0';
|
||||
$name = 'node-18.0';
|
||||
$folder = 'node';
|
||||
$code = realpath(__DIR__ . '/../../../resources/functions') . "/$folder/code.tar.gz";
|
||||
$this->packageCode($folder);
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
return function ($request, $response) {
|
||||
\var_dump("Amazing Function Log"); // We test logs (stdout) visibility with this
|
||||
|
||||
$response->json([
|
||||
'APPWRITE_FUNCTION_ID' => $request['env']['APPWRITE_FUNCTION_ID'],
|
||||
'APPWRITE_FUNCTION_NAME' => $request['env']['APPWRITE_FUNCTION_NAME'],
|
||||
|
|
Loading…
Reference in a new issue