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