From 2e00acc17b6a856a0ce2d5bf61909536c700c8e9 Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Mon, 21 Mar 2022 11:25:08 +0000 Subject: [PATCH 1/6] Increase Execution output limit to 1MB --- app/config/collections.php | 8 ++++---- app/executor.php | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/config/collections.php b/app/config/collections.php index 98f41e8833..fc7af6b7c7 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -2007,7 +2007,7 @@ $collections = [ '$id' => 'stderr', 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 16384, + 'size' => 1048576, 'signed' => true, 'required' => false, 'default' => '', @@ -2018,7 +2018,7 @@ $collections = [ '$id' => 'stdout', 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 16384, + 'size' => 1048576, 'signed' => true, 'required' => false, 'default' => '', @@ -2124,7 +2124,7 @@ $collections = [ '$id' => 'stdout', 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 16384, + 'size' => 1048576, 'signed' => true, 'required' => false, 'default' => null, @@ -2135,7 +2135,7 @@ $collections = [ '$id' => 'stderr', 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 16384, + 'size' => 1048576, 'signed' => true, 'required' => false, 'default' => null, diff --git a/app/executor.php b/app/executor.php index f882164d16..0585ca7287 100644 --- a/app/executor.php +++ b/app/executor.php @@ -283,8 +283,8 @@ App::post('/v1/runtimes') $endTime = \time(); $container = array_merge($container, [ 'status' => 'ready', - 'stdout' => \utf8_encode($stdout), - 'stderr' => \utf8_encode($stderr), + 'stdout' => \mb_substr(\utf8_encode($stdout), 0, 1048576), // Limit to 1MB + 'stderr' => \mb_substr(\utf8_encode($stderr), 0, 1048576), // Limit to 1MB 'startTime' => $startTime, 'endTime' => $endTime, 'duration' => $endTime - $startTime, @@ -501,8 +501,8 @@ App::post('/v1/execution') $execution = [ 'status' => $functionStatus, 'statusCode' => $statusCode, - 'stdout' => \utf8_encode(\mb_substr($stdout, -16384)), - 'stderr' => \utf8_encode(\mb_substr($stderr, -16384)), + 'stdout' => \mb_substr(\utf8_encode($stdout), 0, 1048576), // Limit to 1MB + 'stderr' => \mb_substr(\utf8_encode($stderr), 0, 1048576), // Limit to 1MB 'time' => $executionTime, ]; From 5dc4a9039f3432b6b7685643bd2e1789a2fabe42 Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Mon, 21 Mar 2022 11:52:10 +0000 Subject: [PATCH 2/6] Update DB to use 1MB --- app/config/collections.php | 8 ++++---- app/executor.php | 8 ++++---- open-runtimes | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) create mode 160000 open-runtimes diff --git a/app/config/collections.php b/app/config/collections.php index fc7af6b7c7..6c4388db9a 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -2007,7 +2007,7 @@ $collections = [ '$id' => 'stderr', 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 1048576, + 'size' => 1000000, 'signed' => true, 'required' => false, 'default' => '', @@ -2018,7 +2018,7 @@ $collections = [ '$id' => 'stdout', 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 1048576, + 'size' => 1000000, 'signed' => true, 'required' => false, 'default' => '', @@ -2124,7 +2124,7 @@ $collections = [ '$id' => 'stdout', 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 1048576, + 'size' => 1000000, 'signed' => true, 'required' => false, 'default' => null, @@ -2135,7 +2135,7 @@ $collections = [ '$id' => 'stderr', 'type' => Database::VAR_STRING, 'format' => '', - 'size' => 1048576, + 'size' => 1000000, 'signed' => true, 'required' => false, 'default' => null, diff --git a/app/executor.php b/app/executor.php index 0585ca7287..31f1738f53 100644 --- a/app/executor.php +++ b/app/executor.php @@ -283,8 +283,8 @@ App::post('/v1/runtimes') $endTime = \time(); $container = array_merge($container, [ 'status' => 'ready', - 'stdout' => \mb_substr(\utf8_encode($stdout), 0, 1048576), // Limit to 1MB - 'stderr' => \mb_substr(\utf8_encode($stderr), 0, 1048576), // Limit to 1MB + 'stdout' => \mb_strcut(\utf8_encode($stdout), 0, 1000000), // Limit to 1MB + 'stderr' => \mb_strcut(\utf8_encode($stderr), 0, 1000000), // Limit to 1MB 'startTime' => $startTime, 'endTime' => $endTime, 'duration' => $endTime - $startTime, @@ -501,8 +501,8 @@ App::post('/v1/execution') $execution = [ 'status' => $functionStatus, 'statusCode' => $statusCode, - 'stdout' => \mb_substr(\utf8_encode($stdout), 0, 1048576), // Limit to 1MB - 'stderr' => \mb_substr(\utf8_encode($stderr), 0, 1048576), // Limit to 1MB + 'stdout' => \mb_strcut(\utf8_encode($stdout), 0, 1000000), // Limit to 1MB + 'stderr' => \mb_strcut(\utf8_encode($stderr), 0, 1000000), // Limit to 1MB 'time' => $executionTime, ]; diff --git a/open-runtimes b/open-runtimes new file mode 160000 index 0000000000..c4f2c21404 --- /dev/null +++ b/open-runtimes @@ -0,0 +1 @@ +Subproject commit c4f2c21404011a5a75dc891ff892695534b2df76 From a18e9c401778f98910720b97265d6a68521fd669 Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Mon, 21 Mar 2022 14:40:22 +0000 Subject: [PATCH 3/6] Delete open-runtimes --- open-runtimes | 1 - 1 file changed, 1 deletion(-) delete mode 160000 open-runtimes diff --git a/open-runtimes b/open-runtimes deleted file mode 160000 index c4f2c21404..0000000000 --- a/open-runtimes +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c4f2c21404011a5a75dc891ff892695534b2df76 From e694eb3b5c271b7d836d76fd86df6cceaf08ae6a Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Wed, 27 Apr 2022 13:57:03 +0000 Subject: [PATCH 4/6] Fix unicode support and reenable tests --- app/executor.php | 6 +++--- composer.lock | 12 ++++++------ .../Services/Functions/FunctionsCustomServerTest.php | 4 ++-- tests/resources/functions/php-large/index.php | 2 +- tests/resources/functions/php/index.php | 2 +- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/executor.php b/app/executor.php index 31f1738f53..a38837bb19 100644 --- a/app/executor.php +++ b/app/executor.php @@ -497,12 +497,12 @@ App::post('/v1/execution') $functionStatus = ($statusCode >= 200 && $statusCode < 300) ? 'completed' : 'failed'; Console::success('Function executed in ' . $executionTime . ' seconds, status: ' . $functionStatus); - + $execution = [ 'status' => $functionStatus, 'statusCode' => $statusCode, - 'stdout' => \mb_strcut(\utf8_encode($stdout), 0, 1000000), // Limit to 1MB - 'stderr' => \mb_strcut(\utf8_encode($stderr), 0, 1000000), // Limit to 1MB + 'stdout' => \mb_strcut($stdout, 0, 1000000), // Limit to 1MB + 'stderr' => \mb_strcut($stderr, 0, 1000000), // Limit to 1MB 'time' => $executionTime, ]; diff --git a/composer.lock b/composer.lock index 291b391b3e..6d0f8a2f45 100644 --- a/composer.lock +++ b/composer.lock @@ -2247,16 +2247,16 @@ }, { "name": "utopia-php/framework", - "version": "0.19.7", + "version": "0.19.20", "source": { "type": "git", "url": "https://github.com/utopia-php/framework.git", - "reference": "f17afe77a21873b9be18ebc05283813468b4283a" + "reference": "65ced168db8f6e188ceeb0d101f57552c3d8b2af" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/framework/zipball/f17afe77a21873b9be18ebc05283813468b4283a", - "reference": "f17afe77a21873b9be18ebc05283813468b4283a", + "url": "https://api.github.com/repos/utopia-php/framework/zipball/65ced168db8f6e188ceeb0d101f57552c3d8b2af", + "reference": "65ced168db8f6e188ceeb0d101f57552c3d8b2af", "shasum": "" }, "require": { @@ -2290,9 +2290,9 @@ ], "support": { "issues": "https://github.com/utopia-php/framework/issues", - "source": "https://github.com/utopia-php/framework/tree/0.19.7" + "source": "https://github.com/utopia-php/framework/tree/0.19.20" }, - "time": "2022-02-18T00:04:49+00:00" + "time": "2022-04-14T15:42:37+00:00" }, { "name": "utopia-php/image", diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index e26f93ad34..6e3c09d23e 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -513,7 +513,7 @@ class FunctionsCustomServerTest extends Scope $this->assertStringContainsString('http', $execution['body']['stdout']); $this->assertStringContainsString('PHP', $execution['body']['stdout']); $this->assertStringContainsString('8.0', $execution['body']['stdout']); - // $this->assertStringContainsString('êä', $execution['body']['stdout']); // tests unknown utf-8 chars + $this->assertStringContainsString('êä', $execution['body']['stdout']); // tests unknown utf-8 chars $this->assertEquals('', $execution['body']['stderr']); $this->assertLessThan(0.500, $execution['body']['time']); @@ -601,7 +601,7 @@ class FunctionsCustomServerTest extends Scope $this->assertStringContainsString('http', $execution['body']['stdout']); $this->assertStringContainsString('PHP', $execution['body']['stdout']); $this->assertStringContainsString('8.0', $execution['body']['stdout']); - // $this->assertStringContainsString('êä', $execution['body']['sdtout']); // tests unknown utf-8 chars + $this->assertStringContainsString('êä', $execution['body']['sdtout']); // tests unknown utf-8 chars $this->assertLessThan(0.500, $execution['body']['time']); return $data; diff --git a/tests/resources/functions/php-large/index.php b/tests/resources/functions/php-large/index.php index dd111af766..8bd0de5e60 100644 --- a/tests/resources/functions/php-large/index.php +++ b/tests/resources/functions/php-large/index.php @@ -10,6 +10,6 @@ return function ($request, $response) { 'APPWRITE_FUNCTION_RUNTIME_VERSION' => $request['env']['APPWRITE_FUNCTION_RUNTIME_VERSION'], 'APPWRITE_FUNCTION_EVENT' => $request['env']['APPWRITE_FUNCTION_EVENT'], 'APPWRITE_FUNCTION_EVENT_DATA' => $request['env']['APPWRITE_FUNCTION_EVENT_DATA'], - 'UNICODE_TEST' => "êä" // TODO: Re-add unicode test to FunctionsCustomServerTest.php + 'UNICODE_TEST' => "êä" ]); }; diff --git a/tests/resources/functions/php/index.php b/tests/resources/functions/php/index.php index dd111af766..8bd0de5e60 100644 --- a/tests/resources/functions/php/index.php +++ b/tests/resources/functions/php/index.php @@ -10,6 +10,6 @@ return function ($request, $response) { 'APPWRITE_FUNCTION_RUNTIME_VERSION' => $request['env']['APPWRITE_FUNCTION_RUNTIME_VERSION'], 'APPWRITE_FUNCTION_EVENT' => $request['env']['APPWRITE_FUNCTION_EVENT'], 'APPWRITE_FUNCTION_EVENT_DATA' => $request['env']['APPWRITE_FUNCTION_EVENT_DATA'], - 'UNICODE_TEST' => "êä" // TODO: Re-add unicode test to FunctionsCustomServerTest.php + 'UNICODE_TEST' => "êä" ]); }; From 228e6a1b6c68bceeac05d1529137c5f52d83fa4c Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Thu, 5 May 2022 10:01:08 +0100 Subject: [PATCH 5/6] Remove other utf8_encode --- app/executor.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/executor.php b/app/executor.php index a38837bb19..bf99aea0db 100644 --- a/app/executor.php +++ b/app/executor.php @@ -283,8 +283,8 @@ App::post('/v1/runtimes') $endTime = \time(); $container = array_merge($container, [ 'status' => 'ready', - 'stdout' => \mb_strcut(\utf8_encode($stdout), 0, 1000000), // Limit to 1MB - 'stderr' => \mb_strcut(\utf8_encode($stderr), 0, 1000000), // Limit to 1MB + 'stdout' => \mb_strcut($stdout, 0, 1000000), // Limit to 1MB + 'stderr' => \mb_strcut($stderr, 0, 1000000), // Limit to 1MB 'startTime' => $startTime, 'endTime' => $endTime, 'duration' => $endTime - $startTime, @@ -722,4 +722,4 @@ $http->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swo } }); -$http->start(); \ No newline at end of file +$http->start(); From 92d16374065a5d9cd9a5c880637eb366a55c9aa0 Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Mon, 9 May 2022 11:26:07 +0100 Subject: [PATCH 6/6] Update FunctionsCustomServerTest.php --- tests/e2e/Services/Functions/FunctionsCustomServerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index 6e3c09d23e..9ae65e0771 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -601,7 +601,7 @@ class FunctionsCustomServerTest extends Scope $this->assertStringContainsString('http', $execution['body']['stdout']); $this->assertStringContainsString('PHP', $execution['body']['stdout']); $this->assertStringContainsString('8.0', $execution['body']['stdout']); - $this->assertStringContainsString('êä', $execution['body']['sdtout']); // tests unknown utf-8 chars + $this->assertStringContainsString('êä', $execution['body']['stdout']); // tests unknown utf-8 chars $this->assertLessThan(0.500, $execution['body']['time']); return $data;