From 8d9966bbefe40b7dbd7a8b2b85f49b21b046523e Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Fri, 5 Feb 2021 17:45:37 +0100 Subject: [PATCH] feat(tests): add architecture detection --- .../Functions/FunctionsCustomServerTest.php | 129 +++++++----------- 1 file changed, 52 insertions(+), 77 deletions(-) diff --git a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php index b41fa12f1c..bb5dd65f52 100644 --- a/tests/e2e/Services/Functions/FunctionsCustomServerTest.php +++ b/tests/e2e/Services/Functions/FunctionsCustomServerTest.php @@ -454,110 +454,85 @@ class FunctionsCustomServerTest extends Scope public function testENVS():array { - $functions = realpath(__DIR__ . '/../../../resources/functions'); + $functionsDir = realpath(__DIR__ . '/../../../resources/functions'); + $envs = require('app/config/environments.php'); + /** * Command for rebuilding code packages: * bash tests/resources/functions/package-*.sh */ - $envs = [ - [ - 'language' => 'PHP', - 'version' => '7.4', - 'name' => 'php-7.4', - 'code' => $functions.'/php.tar.gz', + $functions = [ + 'node-14.5' => [ + 'code' => $functionsDir.'/node.tar.gz', + 'command' => 'node index.js', + 'timeout' => 15, + ], + 'node-15.5' => [ + 'code' => $functionsDir.'/node.tar.gz', + 'command' => 'node index.js', + 'timeout' => 15, + ], + 'php-7.4' => [ + 'code' => $functionsDir.'/php.tar.gz', 'command' => 'php index.php', 'timeout' => 15, ], - [ - 'language' => 'PHP', - 'version' => '8.0', - 'name' => 'php-8.0', - 'code' => $functions.'/php.tar.gz', + 'php-8.0' => [ + 'code' => $functionsDir.'/php.tar.gz', 'command' => 'php index.php', 'timeout' => 15, ], - [ - 'language' => 'Python', - 'version' => '3.8', - 'name' => 'python-3.8', - 'code' => $functions.'/python.tar.gz', + 'ruby-2.7' => [ + 'code' => $functionsDir.'/ruby.tar.gz', + 'command' => 'ruby app.rb', + 'timeout' => 15, + ], + 'ruby-3.0' => [ + 'code' => $functionsDir.'/ruby.tar.gz', + 'command' => 'ruby app.rb', + 'timeout' => 15, + ], + 'python-3.8' => [ + 'code' => $functionsDir.'/python.tar.gz', 'command' => 'python main.py', 'timeout' => 15, ], - [ - 'language' => 'Node.js', - 'version' => '14.5', - 'name' => 'node-14.5', - 'code' => $functions.'/node.tar.gz', - 'command' => 'node index.js', - 'timeout' => 15, - ], - [ - 'language' => 'Node.js', - 'version' => '15.5', - 'name' => 'node-15.5', - 'code' => $functions.'/node.tar.gz', - 'command' => 'node index.js', - 'timeout' => 15, - ], - [ - 'language' => 'Ruby', - 'version' => '2.7', - 'name' => 'ruby-2.7', - 'code' => $functions.'/ruby.tar.gz', - 'command' => 'ruby app.rb', - 'timeout' => 15, - ], - [ - 'language' => 'Ruby', - 'version' => '3.0', - 'name' => 'ruby-3.0', - 'code' => $functions.'/ruby.tar.gz', - 'command' => 'ruby app.rb', - 'timeout' => 15, - ], - [ - 'language' => 'Deno', - 'version' => '1.5', - 'name' => 'deno-1.5', - 'code' => $functions.'/deno.tar.gz', + 'deno-1.2' => [ + 'code' => $functionsDir.'/deno.tar.gz', 'command' => 'deno run --allow-env index.ts', 'timeout' => 15, ], - [ - 'language' => 'Deno', - 'version' => '1.6', - 'name' => 'deno-1.6', - 'code' => $functions.'/deno.tar.gz', + 'deno-1.5' => [ + 'code' => $functionsDir.'/deno.tar.gz', 'command' => 'deno run --allow-env index.ts', 'timeout' => 15, ], - [ - 'language' => 'Dart', - 'version' => '2.10', - 'name' => 'dart-2.10', - 'code' => $functions.'/dart.tar.gz', + 'deno-1.6' => [ + 'code' => $functionsDir.'/deno.tar.gz', + 'command' => 'deno run --allow-env index.ts', + 'timeout' => 15, + ], + 'dart-2.10' => [ + 'code' => $functionsDir.'/dart.tar.gz', 'command' => 'dart main.dart', 'timeout' => 15, ], - [ - 'language' => '.NET', - 'version' => '3.1', - 'name' => 'dotnet-3.1', - 'code' => $functions.'/dotnet-3.1.tar.gz', + 'dotnet-3.1' => [ + 'code' => $functionsDir.'/dotnet-3.1.tar.gz', 'command' => 'dotnet dotnet.dll', 'timeout' => 15, ], - [ - 'language' => '.NET', - 'version' => '5.0', - 'name' => 'dotnet-5.0', - 'code' => $functions.'/dotnet-5.0.tar.gz', + 'dotnet-5.0' => [ + 'code' => $functionsDir.'/dotnet-5.0.tar.gz', 'command' => 'dotnet dotnet.dll', 'timeout' => 15, - ], + ] ]; + + foreach ($envs as $key => $env) { + $envs[$key] = array_merge($env, $functions[$key]); + } sleep(count($envs) * 15); fwrite(STDERR, "."); @@ -581,9 +556,9 @@ class FunctionsCustomServerTest extends Scope $fileId = $file['body']['$id'] ?? ''; foreach ($envs as $key => $env) { - $language = $env['language'] ?? ''; + $name = $key ?? ''; + $language = $env['name'] ?? ''; $version = $env['version'] ?? ''; - $name = $env['name'] ?? ''; $code = $env['code'] ?? ''; $command = $env['command'] ?? ''; $timeout = $env['timeout'] ?? 15;