Failing test fixes

This commit is contained in:
Matej Bačo
2025-03-07 21:04:24 +01:00
parent 6a584c83c1
commit c1ee2f2b41
11 changed files with 65 additions and 59 deletions
+30 -3
View File
@@ -1240,7 +1240,7 @@ return [
'$id' => ID::custom('type'),
'type' => Database::VAR_STRING,
'format' => '',
'size' => 2048,
'size' => 32,
'signed' => true,
'required' => true,
'default' => null,
@@ -1607,9 +1607,23 @@ return [
'orders' => [],
],
[
'$id' => ID::custom('_key_size'),
'$id' => ID::custom('_key_sourceSize'),
'type' => Database::INDEX_KEY,
'attributes' => ['size'],
'attributes' => ['sourceSize'],
'lengths' => [],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_buildSize'),
'type' => Database::INDEX_KEY,
'attributes' => ['buildSize'],
'lengths' => [],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_buildDuration'),
'type' => Database::INDEX_KEY,
'attributes' => ['buildDuration'],
'lengths' => [],
'orders' => [Database::ORDER_ASC],
],
@@ -1620,6 +1634,19 @@ return [
'lengths' => [],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_type'),
'type' => Database::INDEX_KEY,
'attributes' => ['type'],
'lengths' => [32],
'orders' => [Database::ORDER_ASC],
], [
'$id' => ID::custom('_key_status'),
'type' => Database::INDEX_KEY,
'attributes' => ['status'],
'lengths' => [16],
'orders' => [Database::ORDER_ASC],
],
],
],
@@ -83,8 +83,8 @@ class Delete extends Action
throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Failed to remove deployment from DB');
}
if (!empty($deployment->getAttribute('path', ''))) {
if (!($deviceForFunctions->delete($deployment->getAttribute('path', '')))) {
if (!empty($deployment->getAttribute('sourcePath', ''))) {
if (!($deviceForFunctions->delete($deployment->getAttribute('sourcePath', '')))) {
throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Failed to remove deployment from storage');
}
}
@@ -85,7 +85,7 @@ class Get extends Action
$device = $deviceForBuilds;
break;
case 'source':
$path = $deployment->getAttribute('path', '');
$path = $deployment->getAttribute('sourcePath', '');
$device = $deviceForFunctions;
break;
}
@@ -77,7 +77,7 @@ class Create extends Action
throw new Exception(Exception::DEPLOYMENT_NOT_FOUND);
}
$path = $deployment->getAttribute('path');
$path = $deployment->getAttribute('sourcePath');
if (empty($path) || !$deviceForFunctions->exists($path)) {
throw new Exception(Exception::DEPLOYMENT_NOT_FOUND);
}
@@ -224,7 +224,7 @@ class Create extends Action
'resourceInternalId' => $site->getInternalId(),
'resourceId' => $site->getId(),
'resourceType' => 'sites',
'buildCommands' => $commands,
'buildCommands' => \implode(' && ', $commands),
'buildOutput' => $outputDirectory,
'sourcePath' => $path,
'sourceSize' => $fileSize,
@@ -271,7 +271,7 @@ class Create extends Action
'resourceInternalId' => $site->getInternalId(),
'resourceId' => $site->getId(),
'resourceType' => 'sites',
'buildCommands' => $commands,
'buildCommands' => \implode(' && ', $commands),
'buildOutput' => $outputDirectory,
'sourcePath' => $path,
'sourceSize' => $fileSize,
@@ -83,8 +83,8 @@ class Delete extends Action
throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Failed to remove deployment from DB');
}
if (!empty($deployment->getAttribute('path', ''))) {
if (!($deviceForSites->delete($deployment->getAttribute('path', '')))) {
if (!empty($deployment->getAttribute('sourcePath', ''))) {
if (!($deviceForSites->delete($deployment->getAttribute('sourcePath', '')))) {
throw new Exception(Exception::GENERAL_SERVER_ERROR, 'Failed to remove deployment from storage');
}
}
@@ -84,7 +84,7 @@ class Get extends Action
$device = $deviceForBuilds;
break;
case 'source':
$path = $deployment->getAttribute('path', '');
$path = $deployment->getAttribute('sourcePath', '');
$device = $deviceForSites;
break;
}
@@ -78,7 +78,7 @@ class Create extends Action
throw new Exception(Exception::DEPLOYMENT_NOT_FOUND);
}
$path = $deployment->getAttribute('path');
$path = $deployment->getAttribute('sourcePath');
if (empty($path) || !$deviceForSites->exists($path)) {
throw new Exception(Exception::DEPLOYMENT_NOT_FOUND);
}
+1 -1
View File
@@ -976,7 +976,7 @@ class Deletes extends Action
private function deleteDeploymentFiles(Device $device, Document $deployment): void
{
$deploymentId = $deployment->getId();
$deploymentPath = $deployment->getAttribute('path', '');
$deploymentPath = $deployment->getAttribute('sourcePath', '');
if (empty($deploymentPath)) {
Console::info("No deployment files for deployment " . $deploymentId);
@@ -382,7 +382,7 @@ class FunctionsCustomServerTest extends Scope
$lastDeployment = $deployments['body']['deployments'][0];
$this->assertNotEmpty($lastDeployment['$id']);
$this->assertEquals(0, $lastDeployment['size']);
$this->assertEquals(0, $lastDeployment['sourceSize']);
$deploymentId = $lastDeployment['$id'];
@@ -598,10 +598,10 @@ class FunctionsCustomServerTest extends Scope
$this->assertNotEmpty($largeTag['body']['$id']);
$this->assertEquals(true, (new DatetimeValidator())->isValid($largeTag['body']['$createdAt']));
$this->assertEquals('index.php', $largeTag['body']['entrypoint']);
$this->assertGreaterThan(1024 * 1024 * 5, $largeTag['body']['size']); // ~7MB video file
$this->assertLessThan(1024 * 1024 * 10, $largeTag['body']['size']); // ~7MB video file
$this->assertGreaterThan(1024 * 1024 * 5, $largeTag['body']['sourceSize']); // ~7MB video file
$this->assertLessThan(1024 * 1024 * 10, $largeTag['body']['sourceSize']); // ~7MB video file
$deploymentSize = $largeTag['body']['size'];
$deploymentSize = $largeTag['body']['sourceSize'];
$deploymentId = $largeTag['body']['$id'];
$this->assertEventually(function () use ($functionId, $deploymentId, $deploymentSize) {
@@ -609,7 +609,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(200, $deployment['headers']['status-code']);
$this->assertEquals('ready', $deployment['body']['status']);
$this->assertEquals($deploymentSize, $deployment['body']['size']);
$this->assertEquals($deploymentSize, $deployment['body']['sourceSize']);
$this->assertGreaterThan(1024 * 1024 * 10, $deployment['body']['buildSize']); // ~7MB video file + 10MB sample file
}, 500000, 1000);
@@ -655,7 +655,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals($deployments['body']['total'], 3);
$this->assertIsArray($deployments['body']['deployments']);
$this->assertCount(3, $deployments['body']['deployments']);
$this->assertArrayHasKey('size', $deployments['body']['deployments'][0]);
$this->assertArrayHasKey('sourceSize', $deployments['body']['deployments'][0]);
$this->assertArrayHasKey('buildSize', $deployments['body']['deployments'][0]);
$deployments = $this->listDeployments($functionId, [
@@ -676,24 +676,6 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals($deployments['headers']['status-code'], 200);
$this->assertCount(2, $deployments['body']['deployments']);
$deployments = $this->listDeployments($functionId, [
'queries' => [
Query::equal('entrypoint', ['index.php'])->toString(),
],
]);
$this->assertEquals($deployments['headers']['status-code'], 200);
$this->assertCount(3, $deployments['body']['deployments']);
$deployments = $this->listDeployments($functionId, [
'queries' => [
Query::equal('entrypoint', ['index.js'])->toString(),
],
]);
$this->assertEquals($deployments['headers']['status-code'], 200);
$this->assertCount(0, $deployments['body']['deployments']);
$deployments = $this->listDeployments($functionId, [
'search' => 'php-8.0'
]);
@@ -744,7 +726,7 @@ class FunctionsCustomServerTest extends Scope
$functionId,
[
'queries' => [
Query::greaterThan('size', 10000)->toString(),
Query::greaterThan('sourceSize', 10000)->toString(),
],
]
);
@@ -756,7 +738,7 @@ class FunctionsCustomServerTest extends Scope
$functionId,
[
'queries' => [
Query::greaterThan('size', 0)->toString(),
Query::greaterThan('sourceSize', 0)->toString(),
],
]
);
@@ -768,7 +750,7 @@ class FunctionsCustomServerTest extends Scope
$functionId,
[
'queries' => [
Query::greaterThan('size', -100)->toString(),
Query::greaterThan('sourceSize', -100)->toString(),
],
]
);
@@ -789,16 +771,16 @@ class FunctionsCustomServerTest extends Scope
$this->assertEquals(200, $deployments['headers']['status-code']);
$this->assertGreaterThanOrEqual(1, $deployments['body']['total']);
$this->assertNotEmpty($deployments['body']['deployments'][0]['$id']);
$this->assertNotEmpty($deployments['body']['deployments'][0]['size']);
$this->assertNotEmpty($deployments['body']['deployments'][0]['sourceSize']);
$deploymentId = $deployments['body']['deployments'][0]['$id'];
$deploymentSize = $deployments['body']['deployments'][0]['size'];
$deploymentSize = $deployments['body']['deployments'][0]['sourceSize'];
$deployments = $this->listDeployments(
$functionId,
[
'queries' => [
Query::equal('size', [$deploymentSize])->toString(),
Query::equal('sourceSize', [$deploymentSize])->toString(),
],
]
);
@@ -815,7 +797,7 @@ class FunctionsCustomServerTest extends Scope
if (!empty($matchingDeployment)) {
$deployment = reset($matchingDeployment);
$this->assertEquals($deploymentSize, $deployment['size']);
$this->assertEquals($deploymentSize, $deployment['sourceSize']);
}
return $data;
@@ -835,7 +817,7 @@ class FunctionsCustomServerTest extends Scope
$this->assertGreaterThan(0, $deployment['body']['buildDuration']);
$this->assertNotEmpty($deployment['body']['status']);
$this->assertNotEmpty($deployment['body']['buildLogs']);
$this->assertArrayHasKey('size', $deployment['body']);
$this->assertArrayHasKey('sourceSize', $deployment['body']);
$this->assertArrayHasKey('buildSize', $deployment['body']);
/**
@@ -598,7 +598,7 @@ class SitesCustomServerTest extends Scope
$lastDeployment = $deployments['body']['deployments'][0];
$this->assertNotEmpty($lastDeployment['$id']);
$this->assertEquals(0, $lastDeployment['size']);
$this->assertEquals(0, $lastDeployment['sourceSize']);
$deploymentId = $lastDeployment['$id'];
@@ -709,9 +709,6 @@ class SitesCustomServerTest extends Scope
}, 100000, 250);
$deployment = $this->cancelDeployment($siteId, $deploymentId);
\var_dump($siteId);
\var_dump($deploymentId);
\var_dump($deployment);
$this->assertEquals(200, $deployment['headers']['status-code']);
$this->assertEquals('canceled', $deployment['body']['status']);
@@ -815,7 +812,7 @@ class SitesCustomServerTest extends Scope
$this->assertEquals($deployments['body']['total'], 2);
$this->assertIsArray($deployments['body']['deployments']);
$this->assertCount(2, $deployments['body']['deployments']);
$this->assertArrayHasKey('size', $deployments['body']['deployments'][0]);
$this->assertArrayHasKey('sourceSize', $deployments['body']['deployments'][0]);
$this->assertArrayHasKey('buildSize', $deployments['body']['deployments'][0]);
$deployments = $this->listDeployments($siteId, [
@@ -876,7 +873,7 @@ class SitesCustomServerTest extends Scope
$siteId,
[
'queries' => [
Query::greaterThan('size', 10000)->toString(),
Query::greaterThan('sourceSize', 10000)->toString(),
],
]
);
@@ -888,7 +885,7 @@ class SitesCustomServerTest extends Scope
$siteId,
[
'queries' => [
Query::greaterThan('size', 0)->toString(),
Query::greaterThan('sourceSize', 0)->toString(),
],
]
);
@@ -900,7 +897,7 @@ class SitesCustomServerTest extends Scope
$siteId,
[
'queries' => [
Query::greaterThan('size', -100)->toString(),
Query::greaterThan('sourceSize', -100)->toString(),
],
]
);
@@ -921,16 +918,16 @@ class SitesCustomServerTest extends Scope
$this->assertEquals(200, $deployments['headers']['status-code']);
$this->assertGreaterThanOrEqual(1, $deployments['body']['total']);
$this->assertNotEmpty($deployments['body']['deployments'][0]['$id']);
$this->assertNotEmpty($deployments['body']['deployments'][0]['size']);
$this->assertNotEmpty($deployments['body']['deployments'][0]['sourceSize']);
$deploymentId = $deployments['body']['deployments'][0]['$id'];
$deploymentSize = $deployments['body']['deployments'][0]['size'];
$deploymentSize = $deployments['body']['deployments'][0]['sourceSize'];
$deployments = $this->listDeployments(
$siteId,
[
'queries' => [
Query::equal('size', [$deploymentSize])->toString(),
Query::equal('sourceSize', [$deploymentSize])->toString(),
],
]
);
@@ -947,7 +944,7 @@ class SitesCustomServerTest extends Scope
if (!empty($matchingDeployment)) {
$deployment = reset($matchingDeployment);
$this->assertEquals($deploymentSize, $deployment['size']);
$this->assertEquals($deploymentSize, $deployment['sourceSize']);
}
$this->cleanupDeployment($siteId, $deploymentIdActive);
@@ -992,7 +989,7 @@ class SitesCustomServerTest extends Scope
$this->assertGreaterThan(0, $deployment['body']['buildDuration']);
$this->assertNotEmpty($deployment['body']['status']);
$this->assertNotEmpty($deployment['body']['buildLogs']);
$this->assertArrayHasKey('size', $deployment['body']);
$this->assertArrayHasKey('sourceSize', $deployment['body']);
$this->assertArrayHasKey('buildSize', $deployment['body']);
/**