1
0
Fork 0
mirror of synced 2024-06-14 08:44:49 +12:00
appwrite/tests/e2e/Services/Health/HealthCustomServerTest.php

516 lines
19 KiB
PHP
Raw Normal View History

2020-01-13 04:20:51 +13:00
<?php
namespace Tests\E2E\Services\Health;
2020-05-01 22:43:31 +12:00
use Tests\E2E\Client;
2020-01-13 04:20:51 +13:00
use Tests\E2E\Scopes\Scope;
use Tests\E2E\Scopes\ProjectCustom;
use Tests\E2E\Scopes\SideClient;
2020-06-07 18:00:14 +12:00
use Tests\E2E\Scopes\SideServer;
2020-01-13 04:20:51 +13:00
2020-12-27 01:10:14 +13:00
class HealthCustomServerTest extends Scope
2020-01-13 04:20:51 +13:00
{
use HealthBase;
use ProjectCustom;
2020-06-07 18:00:14 +12:00
use SideServer;
2020-05-01 22:43:31 +12:00
2021-10-27 02:19:28 +13:00
public function testHTTPSuccess(): array
2020-05-01 22:43:31 +12:00
{
/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/health', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
2021-12-17 01:19:04 +13:00
$this->assertEquals('pass', $response['body']['status']);
$this->assertIsInt($response['body']['ping']);
$this->assertLessThan(100, $response['body']['ping']);
2020-05-01 22:43:31 +12:00
return [];
}
2021-10-27 02:19:28 +13:00
public function testDBSuccess(): array
2020-05-01 22:43:31 +12:00
{
/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/health/db', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals('pass', $response['body']['statuses'][0]['status']);
$this->assertIsInt($response['body']['statuses'][0]['ping']);
$this->assertLessThan(100, $response['body']['statuses'][0]['ping']);
2020-05-01 22:43:31 +12:00
return [];
}
2021-10-27 02:19:28 +13:00
public function testCacheSuccess(): array
2020-05-01 22:43:31 +12:00
{
/**
* Test for SUCCESS
*/
2020-12-27 04:10:45 +13:00
$response = $this->client->call(Client::METHOD_GET, '/health/cache', array_merge([
2020-05-01 22:43:31 +12:00
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals('pass', $response['body']['statuses'][0]['status']);
$this->assertIsInt($response['body']['statuses'][0]['ping']);
$this->assertLessThan(100, $response['body']['statuses'][0]['ping']);
return [];
}
public function testQueueSuccess(): array
{
/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/health/queue', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals('pass', $response['body']['statuses'][0]['status']);
$this->assertIsInt($response['body']['statuses'][0]['ping']);
$this->assertLessThan(100, $response['body']['statuses'][0]['ping']);
return [];
}
public function testPubSubSuccess(): array
{
/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/health/pubsub', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals('pass', $response['body']['statuses'][0]['status']);
$this->assertIsInt($response['body']['statuses'][0]['ping']);
$this->assertLessThan(100, $response['body']['statuses'][0]['ping']);
2020-05-01 22:43:31 +12:00
return [];
}
2021-10-27 02:19:28 +13:00
public function testTimeSuccess(): array
2020-05-01 22:43:31 +12:00
{
/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/health/time', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
2021-12-17 01:19:04 +13:00
$this->assertIsInt($response['body']['remoteTime']);
$this->assertIsInt($response['body']['localTime']);
$this->assertNotEmpty($response['body']['remoteTime']);
$this->assertNotEmpty($response['body']['localTime']);
2020-05-01 22:43:31 +12:00
$this->assertLessThan(10, $response['body']['diff']);
2023-10-16 06:41:09 +13:00
return [];
}
public function testWebhooksSuccess(): array
{
2020-05-01 22:43:31 +12:00
/**
2023-10-16 06:41:09 +13:00
* Test for SUCCESS
2020-05-01 22:43:31 +12:00
*/
2023-10-16 06:41:09 +13:00
$response = $this->client->call(Client::METHOD_GET, '/health/queue/webhooks', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertIsInt($response['body']['size']);
$this->assertLessThan(100, $response['body']['size']);
2020-05-01 22:43:31 +12:00
2023-11-14 02:07:11 +13:00
/**
* Test for FAILURE
*/
2023-11-14 02:39:33 +13:00
$response = $this->client->call(Client::METHOD_GET, '/health/queue/webhooks?threshold=0', array_merge([
2023-11-14 02:07:11 +13:00
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
2023-11-17 07:49:43 +13:00
$this->assertEquals(503, $response['headers']['status-code']);
2023-11-14 02:07:11 +13:00
2023-10-03 21:40:34 +13:00
return [];
}
2023-10-16 06:41:09 +13:00
public function testLogsSuccess(): array
2023-10-03 21:40:34 +13:00
{
2020-05-01 22:43:31 +12:00
/**
2023-10-03 21:40:34 +13:00
* Test for SUCCESS
2020-05-01 22:43:31 +12:00
*/
2023-10-16 06:41:09 +13:00
$response = $this->client->call(Client::METHOD_GET, '/health/queue/logs', array_merge([
2023-10-03 21:40:34 +13:00
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertIsInt($response['body']['size']);
$this->assertLessThan(100, $response['body']['size']);
2021-10-27 02:19:28 +13:00
2023-11-14 02:07:11 +13:00
/**
* Test for FAILURE
*/
2023-11-14 02:39:33 +13:00
$response = $this->client->call(Client::METHOD_GET, '/health/queue/logs?threshold=0', array_merge([
2023-11-14 02:07:11 +13:00
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
2023-11-17 07:49:43 +13:00
$this->assertEquals(503, $response['headers']['status-code']);
2023-11-14 02:07:11 +13:00
2023-10-16 06:41:09 +13:00
return [];
}
public function testCertificatesSuccess(): array
{
2020-05-01 22:43:31 +12:00
/**
2023-10-16 06:41:09 +13:00
* Test for SUCCESS
2020-05-01 22:43:31 +12:00
*/
2023-10-16 06:41:09 +13:00
$response = $this->client->call(Client::METHOD_GET, '/health/queue/certificates', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertIsInt($response['body']['size']);
$this->assertLessThan(100, $response['body']['size']);
2020-05-01 22:43:31 +12:00
2023-11-14 02:07:11 +13:00
/**
* Test for FAILURE
*/
2023-11-14 02:39:33 +13:00
$response = $this->client->call(Client::METHOD_GET, '/health/queue/certificates?threshold=0', array_merge([
2023-11-14 02:07:11 +13:00
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
2023-11-17 07:49:43 +13:00
$this->assertEquals(503, $response['headers']['status-code']);
2023-11-14 02:07:11 +13:00
2023-10-03 21:40:34 +13:00
return [];
}
2023-10-16 06:41:09 +13:00
public function testFunctionsSuccess(): array
2023-10-03 21:40:34 +13:00
{
/**
* Test for SUCCESS
*/
2023-10-16 06:41:09 +13:00
$response = $this->client->call(Client::METHOD_GET, '/health/queue/functions', array_merge([
2023-10-03 21:40:34 +13:00
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertIsInt($response['body']['size']);
$this->assertLessThan(100, $response['body']['size']);
2023-11-14 02:07:11 +13:00
/**
* Test for FAILURE
*/
2023-11-14 02:39:33 +13:00
$response = $this->client->call(Client::METHOD_GET, '/health/queue/functions?threshold=0', array_merge([
2023-11-14 02:07:11 +13:00
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
2023-11-17 07:49:43 +13:00
$this->assertEquals(503, $response['headers']['status-code']);
2023-11-14 02:07:11 +13:00
2023-10-16 06:41:09 +13:00
return [];
}
public function testBuildsSuccess(): array
{
2020-05-01 22:43:31 +12:00
/**
2023-10-16 06:41:09 +13:00
* Test for SUCCESS
2020-05-01 22:43:31 +12:00
*/
2023-10-16 06:41:09 +13:00
$response = $this->client->call(Client::METHOD_GET, '/health/queue/builds', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertIsInt($response['body']['size']);
$this->assertLessThan(100, $response['body']['size']);
2023-10-03 21:40:34 +13:00
2023-11-14 02:07:11 +13:00
/**
* Test for FAILURE
*/
2023-11-14 02:39:33 +13:00
$response = $this->client->call(Client::METHOD_GET, '/health/queue/builds?threshold=0', array_merge([
2023-11-14 02:07:11 +13:00
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
2023-11-17 07:49:43 +13:00
$this->assertEquals(503, $response['headers']['status-code']);
2023-11-14 02:07:11 +13:00
2023-10-03 21:40:34 +13:00
return [];
}
2023-10-16 06:41:09 +13:00
public function testDatabasesSuccess(): array
2023-10-03 21:40:34 +13:00
{
/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/health/queue/databases', array_merge([
2023-10-03 21:40:34 +13:00
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
2023-10-19 22:25:38 +13:00
'name' => 'database_db_main',
]);
2023-10-03 21:40:34 +13:00
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertIsInt($response['body']['size']);
$this->assertLessThan(100, $response['body']['size']);
2023-11-14 02:07:11 +13:00
/**
* Test for FAILURE
*/
$response = $this->client->call(Client::METHOD_GET, '/health/queue/databases', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'name' => 'database_db_main',
2023-11-14 02:39:33 +13:00
'threshold' => '0'
2023-11-14 02:07:11 +13:00
]);
2023-11-17 07:49:43 +13:00
$this->assertEquals(503, $response['headers']['status-code']);
2023-11-14 02:07:11 +13:00
2023-10-16 06:41:09 +13:00
return [];
}
public function testDeletesSuccess(): array
{
/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/health/queue/deletes', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertIsInt($response['body']['size']);
$this->assertLessThan(100, $response['body']['size']);
2023-11-14 02:07:11 +13:00
/**
* Test for FAILURE
*/
2023-11-14 02:39:33 +13:00
$response = $this->client->call(Client::METHOD_GET, '/health/queue/deletes?threshold=0', array_merge([
2023-11-14 02:07:11 +13:00
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
2023-11-17 07:49:43 +13:00
$this->assertEquals(503, $response['headers']['status-code']);
2023-11-14 02:07:11 +13:00
2023-10-16 06:41:09 +13:00
return [];
}
public function testMailsSuccess(): array
{
2023-10-03 21:40:34 +13:00
/**
2023-10-16 06:41:09 +13:00
* Test for SUCCESS
2023-10-03 21:40:34 +13:00
*/
2023-10-16 06:41:09 +13:00
$response = $this->client->call(Client::METHOD_GET, '/health/queue/mails', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertIsInt($response['body']['size']);
$this->assertLessThan(100, $response['body']['size']);
2023-11-14 02:07:11 +13:00
/**
* Test for FAILURE
*/
2023-11-14 02:39:33 +13:00
$response = $this->client->call(Client::METHOD_GET, '/health/queue/mails?threshold=0', array_merge([
2023-11-14 02:07:11 +13:00
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
2023-11-17 07:49:43 +13:00
$this->assertEquals(503, $response['headers']['status-code']);
2023-11-14 02:07:11 +13:00
2023-10-16 06:41:09 +13:00
return [];
}
public function testMessagingSuccess(): array
{
/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/health/queue/messaging', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertIsInt($response['body']['size']);
$this->assertLessThan(100, $response['body']['size']);
2023-11-14 02:07:11 +13:00
/**
* Test for FAILURE
*/
2023-11-14 02:39:33 +13:00
$response = $this->client->call(Client::METHOD_GET, '/health/queue/messaging?threshold=0', array_merge([
2023-11-14 02:07:11 +13:00
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
2023-11-17 07:49:43 +13:00
$this->assertEquals(503, $response['headers']['status-code']);
2023-11-14 02:07:11 +13:00
2023-10-16 06:41:09 +13:00
return [];
}
public function testMigrationsSuccess(): array
{
/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/health/queue/migrations', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertIsInt($response['body']['size']);
$this->assertLessThan(100, $response['body']['size']);
2021-10-27 02:19:28 +13:00
2023-11-14 02:07:11 +13:00
/**
* Test for FAILURE
*/
2023-11-14 02:39:33 +13:00
$response = $this->client->call(Client::METHOD_GET, '/health/queue/migrations?threshold=0', array_merge([
2023-11-14 02:07:11 +13:00
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
2023-11-17 07:49:43 +13:00
$this->assertEquals(503, $response['headers']['status-code']);
2023-11-14 02:07:11 +13:00
2020-05-01 22:43:31 +12:00
return [];
}
2021-10-27 02:19:28 +13:00
public function testStorageLocalSuccess(): array
2020-05-01 22:43:31 +12:00
{
/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/health/storage/local', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
2021-12-17 01:19:04 +13:00
$this->assertEquals('pass', $response['body']['status']);
$this->assertIsInt($response['body']['ping']);
2024-02-15 19:27:24 +13:00
$this->assertLessThan(100, $response['body']['ping']);
return [];
}
public function testStorageSuccess(): array
{
/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/health/storage', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
2020-05-01 22:43:31 +12:00
$this->assertEquals(200, $response['headers']['status-code']);
2021-12-17 01:19:04 +13:00
$this->assertEquals('pass', $response['body']['status']);
$this->assertIsInt($response['body']['ping']);
$this->assertLessThan(100, $response['body']['ping']);
2020-05-01 22:43:31 +12:00
return [];
}
2021-10-27 02:19:28 +13:00
public function testStorageAntiVirusSuccess(): array
2020-05-01 22:43:31 +12:00
{
/**
* Test for SUCCESS
*/
2020-05-19 00:34:28 +12:00
$response = $this->client->call(Client::METHOD_GET, '/health/anti-virus', array_merge([
2020-05-01 22:43:31 +12:00
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
2021-03-20 21:50:30 +13:00
$this->assertNotEmpty($response['body']['status']);
$this->assertIsString($response['body']['status']);
$this->assertIsString($response['body']['version']);
2020-05-01 22:43:31 +12:00
return [];
}
public function testCertificateValidity(): array
{
/**
* Test for SUCCESS
*/
$response = $this->client->call(Client::METHOD_GET, '/health/certificate?domain=www.google.com', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals('/CN=www.google.com', $response['body']['name']);
$this->assertEquals('www.google.com', $response['body']['subjectSN']);
$this->assertEquals('Google Trust Services LLC', $response['body']['issuerOrganisation']);
$this->assertIsInt($response['body']['validFrom']);
$this->assertIsInt($response['body']['validTo']);
$response = $this->client->call(Client::METHOD_GET, '/health/certificate?domain=appwrite.io', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals('/CN=appwrite.io', $response['body']['name']);
$this->assertEquals('appwrite.io', $response['body']['subjectSN']);
$this->assertEquals("Let's Encrypt", $response['body']['issuerOrganisation']);
$this->assertIsInt($response['body']['validFrom']);
$this->assertIsInt($response['body']['validTo']);
$response = $this->client->call(Client::METHOD_GET, '/health/certificate?domain=https://google.com', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(200, $response['headers']['status-code']);
/**
* Test for FAILURE
*/
$response = $this->client->call(Client::METHOD_GET, '/health/certificate?domain=localhost', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(400, $response['headers']['status-code']);
$response = $this->client->call(Client::METHOD_GET, '/health/certificate?domain=doesnotexist.com', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(404, $response['headers']['status-code']);
$response = $this->client->call(Client::METHOD_GET, '/health/certificate?domain=www.google.com/usr/src/local', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(400, $response['headers']['status-code']);
2024-02-06 23:34:58 +13:00
$response = $this->client->call(Client::METHOD_GET, '/health/certificate?domain=', array_merge([
'content-type' => 'application/json',
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), []);
$this->assertEquals(400, $response['headers']['status-code']);
return [];
}
2021-10-27 02:19:28 +13:00
}