feat(ServiceDatabase): add support for TimescaleDB detection and database type identification
This commit is contained in:
parent
033433f553
commit
ec30426a2f
3 changed files with 86 additions and 0 deletions
|
|
@ -84,6 +84,10 @@ public function databaseType()
|
|||
$image = str($this->image)->before(':');
|
||||
if ($image->contains('supabase/postgres')) {
|
||||
$finalImage = 'supabase/postgres';
|
||||
} elseif ($image->contains('timescale')) {
|
||||
$finalImage = 'postgresql';
|
||||
} elseif ($image->contains('pgvector')) {
|
||||
$finalImage = 'postgresql';
|
||||
} elseif ($image->contains('postgres') || $image->contains('postgis')) {
|
||||
$finalImage = 'postgresql';
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -47,6 +47,8 @@
|
|||
'neo4j',
|
||||
'influxdb',
|
||||
'clickhouse/clickhouse-server',
|
||||
'timescaledb/timescaledb',
|
||||
'pgvector/pgvector',
|
||||
];
|
||||
const SPECIFIC_SERVICES = [
|
||||
'quay.io/minio/minio',
|
||||
|
|
|
|||
80
tests/Unit/TimescaleDbDetectionTest.php
Normal file
80
tests/Unit/TimescaleDbDetectionTest.php
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
<?php
|
||||
|
||||
use App\Models\ServiceDatabase;
|
||||
|
||||
use function PHPUnit\Framework\assertTrue;
|
||||
|
||||
test('timescaledb is detected as database with postgres environment variables', function () {
|
||||
$image = 'timescale/timescaledb';
|
||||
$serviceConfig = [
|
||||
'image' => 'timescale/timescaledb',
|
||||
'environment' => [
|
||||
'POSTGRES_DB=$POSTGRES_DB',
|
||||
'POSTGRES_USER=$SERVICE_USER_POSTGRES',
|
||||
'POSTGRES_PASSWORD=$SERVICE_PASSWORD_POSTGRES',
|
||||
],
|
||||
'volumes' => [
|
||||
'timescaledb-data:/var/lib/postgresql/data',
|
||||
],
|
||||
];
|
||||
|
||||
$isDatabase = isDatabaseImage($image, $serviceConfig);
|
||||
|
||||
assertTrue($isDatabase, 'TimescaleDB with POSTGRES_PASSWORD should be detected as database');
|
||||
});
|
||||
|
||||
test('timescaledb is detected as database without service config', function () {
|
||||
$image = 'timescale/timescaledb';
|
||||
|
||||
$isDatabase = isDatabaseImage($image);
|
||||
|
||||
assertTrue($isDatabase, 'TimescaleDB image should be in DATABASE_DOCKER_IMAGES constant');
|
||||
});
|
||||
|
||||
test('timescaledb-ha is detected as database', function () {
|
||||
$image = 'timescale/timescaledb-ha';
|
||||
|
||||
$isDatabase = isDatabaseImage($image);
|
||||
|
||||
assertTrue($isDatabase, 'TimescaleDB HA image should be in DATABASE_DOCKER_IMAGES constant');
|
||||
});
|
||||
|
||||
test('timescaledb databaseType returns postgresql', function () {
|
||||
$database = new ServiceDatabase;
|
||||
$database->setRawAttributes(['image' => 'timescale/timescaledb:latest', 'custom_type' => null]);
|
||||
$database->syncOriginal();
|
||||
|
||||
$type = $database->databaseType();
|
||||
|
||||
expect($type)->toBe('standalone-postgresql');
|
||||
});
|
||||
|
||||
test('timescaledb-ha databaseType returns postgresql', function () {
|
||||
$database = new ServiceDatabase;
|
||||
$database->setRawAttributes(['image' => 'timescale/timescaledb-ha:pg17', 'custom_type' => null]);
|
||||
$database->syncOriginal();
|
||||
|
||||
$type = $database->databaseType();
|
||||
|
||||
expect($type)->toBe('standalone-postgresql');
|
||||
});
|
||||
|
||||
test('timescaledb backup solution is available', function () {
|
||||
$database = new ServiceDatabase;
|
||||
$database->setRawAttributes(['image' => 'timescale/timescaledb:latest', 'custom_type' => null]);
|
||||
$database->syncOriginal();
|
||||
|
||||
$isAvailable = $database->isBackupSolutionAvailable();
|
||||
|
||||
assertTrue($isAvailable, 'TimescaleDB should have backup solution available');
|
||||
});
|
||||
|
||||
test('timescaledb-ha backup solution is available', function () {
|
||||
$database = new ServiceDatabase;
|
||||
$database->setRawAttributes(['image' => 'timescale/timescaledb-ha:pg17', 'custom_type' => null]);
|
||||
$database->syncOriginal();
|
||||
|
||||
$isAvailable = $database->isBackupSolutionAvailable();
|
||||
|
||||
assertTrue($isAvailable, 'TimescaleDB HA should have backup solution available');
|
||||
});
|
||||
Loading…
Reference in a new issue