Merge pull request #13507 from appwrite/fix/proxy-e2e-flake

test(proxy): isolate deployment archives in parallel tests
This commit is contained in:
Chirag Aggarwal authored and GitHub committed 2026-09-06 12:41:01 -07:00
commit 4729c7ba45
1 file changed
+30 -6
+30 -6
View File
@@ -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');
}
}