Update Tests
This commit is contained in:
parent
eb3db0ddae
commit
bd537e6992
|
@ -16,7 +16,7 @@ use Utopia\Config\Config;
|
||||||
use Utopia\Orchestration\Orchestration;
|
use Utopia\Orchestration\Orchestration;
|
||||||
use Utopia\Orchestration\Adapter\DockerAPI;
|
use Utopia\Orchestration\Adapter\DockerAPI;
|
||||||
use Utopia\Orchestration\Container;
|
use Utopia\Orchestration\Container;
|
||||||
use Utopia\Orchestration\Exceptions\TimeoutException;
|
use Utopia\Orchestration\Exception\Timeout as TimeoutException;
|
||||||
|
|
||||||
require_once __DIR__.'/../workers.php';
|
require_once __DIR__.'/../workers.php';
|
||||||
|
|
||||||
|
@ -29,7 +29,8 @@ $runtimes = Config::getParam('runtimes');
|
||||||
|
|
||||||
$dockerUser = App::getEnv('DOCKERHUB_PULL_USERNAME', null);
|
$dockerUser = App::getEnv('DOCKERHUB_PULL_USERNAME', null);
|
||||||
$dockerPass = App::getEnv('DOCKERHUB_PULL_PASSWORD', 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
|
* Warmup Docker Images
|
||||||
|
@ -67,7 +68,7 @@ $response = $orchestration->list(['label' => 'appwrite-type=function']);
|
||||||
|
|
||||||
$list = [];
|
$list = [];
|
||||||
|
|
||||||
foreach ($response as &$value) {
|
foreach ($response as $value) {
|
||||||
$list[$value->getName()] = $value;
|
$list[$value->getName()] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,13 +369,10 @@ class FunctionsV1 extends Worker
|
||||||
|
|
||||||
$executionStart = \microtime(true);
|
$executionStart = \microtime(true);
|
||||||
$executionTime = \time();
|
$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->setCpus(App::getEnv('_APP_FUNCTIONS_CPUS', ''));
|
||||||
$orchestration->setMemory($memory);
|
$orchestration->setMemory(App::getEnv('_APP_FUNCTIONS_MEMORY', ''));
|
||||||
$orchestration->setSwap($swap);
|
$orchestration->setSwap(App::getEnv('_APP_FUNCTIONS_MEMORY_SWAP', ''));
|
||||||
|
|
||||||
foreach($vars as &$value) {
|
foreach($vars as &$value) {
|
||||||
$value = strval($value);
|
$value = strval($value);
|
||||||
|
@ -397,8 +395,8 @@ class FunctionsV1 extends Worker
|
||||||
'appwrite-created' => strval($executionTime)
|
'appwrite-created' => strval($executionTime)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$tarStdout = '';
|
$untarStdout = '';
|
||||||
$tarStderr = '';
|
$untarStderr = '';
|
||||||
|
|
||||||
$untarSuccess = $orchestration->execute(
|
$untarSuccess = $orchestration->execute(
|
||||||
name: $container,
|
name: $container,
|
||||||
|
@ -407,20 +405,18 @@ class FunctionsV1 extends Worker
|
||||||
'-c',
|
'-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'
|
'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,
|
stdout: $untarStdout,
|
||||||
stderr: $tarStderr,
|
stderr: $untarStderr,
|
||||||
vars: $vars,
|
vars: $vars,
|
||||||
timeout: 60);
|
timeout: 60);
|
||||||
|
|
||||||
if (!$untarSuccess) {
|
if (!$untarSuccess) {
|
||||||
throw new Exception('Failed to extract tar: '.$stderr);
|
throw new Exception('Failed to extract tar: '.$untarStderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
$executionEnd = \microtime(true);
|
$executionEnd = \microtime(true);
|
||||||
|
|
||||||
$list[$container] = new Container($container,
|
$list[$container] = new Container($container, $id, 'Up',
|
||||||
$id,
|
|
||||||
'Up',
|
|
||||||
[
|
[
|
||||||
'appwrite-type' => 'function',
|
'appwrite-type' => 'function',
|
||||||
'appwrite-created' => strval($executionTime),
|
'appwrite-created' => strval($executionTime),
|
||||||
|
@ -462,7 +458,7 @@ class FunctionsV1 extends Worker
|
||||||
$execution = $database->updateDocument(array_merge($execution->getArrayCopy(), [
|
$execution = $database->updateDocument(array_merge($execution->getArrayCopy(), [
|
||||||
'tagId' => $tag->getId(),
|
'tagId' => $tag->getId(),
|
||||||
'status' => $functionStatus,
|
'status' => $functionStatus,
|
||||||
'exitCode' => ($exitCode === 0 ? 0 : 1),
|
'exitCode' => $exitCode,
|
||||||
'stdout' => \mb_substr($stdout, -4000), // log last 4000 chars output
|
'stdout' => \mb_substr($stdout, -4000), // log last 4000 chars output
|
||||||
'stderr' => \mb_substr($stderr, -4000), // log last 4000 chars output
|
'stderr' => \mb_substr($stderr, -4000), // log last 4000 chars output
|
||||||
'time' => $executionTime
|
'time' => $executionTime
|
||||||
|
|
8
composer.lock
generated
8
composer.lock
generated
|
@ -1913,12 +1913,12 @@
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/PineappleIOnic/orchestration.git",
|
"url": "https://github.com/PineappleIOnic/orchestration.git",
|
||||||
"reference": "213d8796cd3b4a23b8d3728227b0e8ab1ceb4aea"
|
"reference": "f8f31b043b8f4bbd423cb365f84e89364e9a349a"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/PineappleIOnic/orchestration/zipball/213d8796cd3b4a23b8d3728227b0e8ab1ceb4aea",
|
"url": "https://api.github.com/repos/PineappleIOnic/orchestration/zipball/f8f31b043b8f4bbd423cb365f84e89364e9a349a",
|
||||||
"reference": "213d8796cd3b4a23b8d3728227b0e8ab1ceb4aea",
|
"reference": "f8f31b043b8f4bbd423cb365f84e89364e9a349a",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -1963,7 +1963,7 @@
|
||||||
"support": {
|
"support": {
|
||||||
"source": "https://github.com/PineappleIOnic/orchestration/tree/dev"
|
"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",
|
"name": "utopia-php/preloader",
|
||||||
|
|
Loading…
Reference in a new issue