mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
test(proxy): isolate deployment archives in parallel tests
This commit is contained in:
1 file changed
+30
-6
@@ -263,15 +263,27 @@ trait ProxyHelpers
|
||||
$stderr = '';
|
||||
|
||||
$folderPath = realpath(__DIR__ . '/../../../resources/sites') . "/$site";
|
||||
$tarPath = "$folderPath/code.tar.gz";
|
||||
// Parallel tests must not truncate an archive another upload is reading.
|
||||
$tarPath = \sys_get_temp_dir() . '/appwrite-site-' . $site . '-' . \getmypid() . '-' . \uniqid('', true) . '.tar.gz';
|
||||
|
||||
Console::execute("cd $folderPath && tar --exclude code.tar.gz --exclude node_modules -czf code.tar.gz .", '', $stdout, $stderr);
|
||||
Console::execute(
|
||||
'tar --exclude code.tar.gz --exclude node_modules -czf ' . \escapeshellarg($tarPath) . ' -C ' . \escapeshellarg($folderPath) . ' .',
|
||||
'',
|
||||
$stdout,
|
||||
$stderr
|
||||
);
|
||||
|
||||
if (filesize($tarPath) > 1024 * 1024 * 5) {
|
||||
throw new \Exception('Code package is too large. Use the chunked upload method instead.');
|
||||
}
|
||||
|
||||
return new CURLFile($tarPath, 'application/x-gzip', \basename($tarPath));
|
||||
register_shutdown_function(static function () use ($tarPath) {
|
||||
if (\is_file($tarPath)) {
|
||||
@\unlink($tarPath);
|
||||
}
|
||||
});
|
||||
|
||||
return new CURLFile($tarPath, 'application/x-gzip', 'code.tar.gz');
|
||||
}
|
||||
|
||||
private function packageFunction(string $function): CURLFile
|
||||
@@ -280,14 +292,26 @@ trait ProxyHelpers
|
||||
$stderr = '';
|
||||
|
||||
$folderPath = realpath(__DIR__ . '/../../../resources/functions') . "/$function";
|
||||
$tarPath = "$folderPath/code.tar.gz";
|
||||
// Parallel tests must not truncate an archive another upload is reading.
|
||||
$tarPath = \sys_get_temp_dir() . '/appwrite-function-' . $function . '-' . \getmypid() . '-' . \uniqid('', true) . '.tar.gz';
|
||||
|
||||
Console::execute("cd $folderPath && tar --exclude code.tar.gz --exclude node_modules -czf code.tar.gz .", '', $stdout, $stderr);
|
||||
Console::execute(
|
||||
'tar --exclude code.tar.gz --exclude node_modules -czf ' . \escapeshellarg($tarPath) . ' -C ' . \escapeshellarg($folderPath) . ' .',
|
||||
'',
|
||||
$stdout,
|
||||
$stderr
|
||||
);
|
||||
|
||||
if (filesize($tarPath) > 1024 * 1024 * 5) {
|
||||
throw new \Exception('Code package is too large. Use the chunked upload method instead.');
|
||||
}
|
||||
|
||||
return new CURLFile($tarPath, 'application/x-gzip', \basename($tarPath));
|
||||
register_shutdown_function(static function () use ($tarPath) {
|
||||
if (\is_file($tarPath)) {
|
||||
@\unlink($tarPath);
|
||||
}
|
||||
});
|
||||
|
||||
return new CURLFile($tarPath, 'application/x-gzip', 'code.tar.gz');
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user