1
0
Fork 0
mirror of synced 2024-06-26 18:20:43 +12:00

Update Tests

This commit is contained in:
Bradley Schofield 2021-08-13 09:32:27 +01:00
parent eb3db0ddae
commit bd537e6992
2 changed files with 18 additions and 22 deletions

View file

@ -16,7 +16,7 @@ use Utopia\Config\Config;
use Utopia\Orchestration\Orchestration;
use Utopia\Orchestration\Adapter\DockerAPI;
use Utopia\Orchestration\Container;
use Utopia\Orchestration\Exceptions\TimeoutException;
use Utopia\Orchestration\Exception\Timeout as TimeoutException;
require_once __DIR__.'/../workers.php';
@ -29,7 +29,8 @@ $runtimes = Config::getParam('runtimes');
$dockerUser = App::getEnv('DOCKERHUB_PULL_USERNAME', null);
$dockerPass = App::getEnv('DOCKERHUB_PULL_PASSWORD', null);
$orchestration = new Orchestration(new DockerAPI($dockerUser, $dockerPass));
$dockerEmail = App::getEnv('DOCKERHUB_PULL_EMAIL', null);
$orchestration = new Orchestration(new DockerAPI($dockerUser, $dockerPass, $dockerEmail));
/**
* Warmup Docker Images
@ -67,7 +68,7 @@ $response = $orchestration->list(['label' => 'appwrite-type=function']);
$list = [];
foreach ($response as &$value) {
foreach ($response as $value) {
$list[$value->getName()] = $value;
}
@ -368,13 +369,10 @@ class FunctionsV1 extends Worker
$executionStart = \microtime(true);
$executionTime = \time();
$cpus = App::getEnv('_APP_FUNCTIONS_CPUS', '');
$memory = App::getEnv('_APP_FUNCTIONS_MEMORY', '');
$swap = App::getEnv('_APP_FUNCTIONS_MEMORY_SWAP', '');
$orchestration->setCpus($cpus);
$orchestration->setMemory($memory);
$orchestration->setSwap($swap);
$orchestration->setCpus(App::getEnv('_APP_FUNCTIONS_CPUS', ''));
$orchestration->setMemory(App::getEnv('_APP_FUNCTIONS_MEMORY', ''));
$orchestration->setSwap(App::getEnv('_APP_FUNCTIONS_MEMORY_SWAP', ''));
foreach($vars as &$value) {
$value = strval($value);
@ -397,8 +395,8 @@ class FunctionsV1 extends Worker
'appwrite-created' => strval($executionTime)
]);
$tarStdout = '';
$tarStderr = '';
$untarStdout = '';
$untarStderr = '';
$untarSuccess = $orchestration->execute(
name: $container,
@ -407,20 +405,18 @@ class FunctionsV1 extends Worker
'-c',
'mv /tmp/code.tar.gz /usr/local/src/code.tar.gz && tar -zxf /usr/local/src/code.tar.gz --strip 1 && rm /usr/local/src/code.tar.gz'
],
stdout: $tarStdout,
stderr: $tarStderr,
stdout: $untarStdout,
stderr: $untarStderr,
vars: $vars,
timeout: 60);
if (!$untarSuccess) {
throw new Exception('Failed to extract tar: '.$stderr);
throw new Exception('Failed to extract tar: '.$untarStderr);
}
$executionEnd = \microtime(true);
$list[$container] = new Container($container,
$id,
'Up',
$list[$container] = new Container($container, $id, 'Up',
[
'appwrite-type' => 'function',
'appwrite-created' => strval($executionTime),
@ -462,7 +458,7 @@ class FunctionsV1 extends Worker
$execution = $database->updateDocument(array_merge($execution->getArrayCopy(), [
'tagId' => $tag->getId(),
'status' => $functionStatus,
'exitCode' => ($exitCode === 0 ? 0 : 1),
'exitCode' => $exitCode,
'stdout' => \mb_substr($stdout, -4000), // log last 4000 chars output
'stderr' => \mb_substr($stderr, -4000), // log last 4000 chars output
'time' => $executionTime

8
composer.lock generated
View file

@ -1913,12 +1913,12 @@
"source": {
"type": "git",
"url": "https://github.com/PineappleIOnic/orchestration.git",
"reference": "213d8796cd3b4a23b8d3728227b0e8ab1ceb4aea"
"reference": "f8f31b043b8f4bbd423cb365f84e89364e9a349a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PineappleIOnic/orchestration/zipball/213d8796cd3b4a23b8d3728227b0e8ab1ceb4aea",
"reference": "213d8796cd3b4a23b8d3728227b0e8ab1ceb4aea",
"url": "https://api.github.com/repos/PineappleIOnic/orchestration/zipball/f8f31b043b8f4bbd423cb365f84e89364e9a349a",
"reference": "f8f31b043b8f4bbd423cb365f84e89364e9a349a",
"shasum": ""
},
"require": {
@ -1963,7 +1963,7 @@
"support": {
"source": "https://github.com/PineappleIOnic/orchestration/tree/dev"
},
"time": "2021-08-11T12:45:16+00:00"
"time": "2021-08-13T08:21:13+00:00"
},
{
"name": "utopia-php/preloader",