Skip to content

Commit 40e3372

Browse files
committed
➕ Add S3 connections test
1 parent 3ba0803 commit 40e3372

File tree

2 files changed

+43
-21
lines changed

2 files changed

+43
-21
lines changed

src/common/test_s3_connection.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
require '/laravel/vendor/autoload.php';
4+
5+
use Illuminate\Support\Facades\Storage;
6+
7+
$app = require_once '/laravel/bootstrap/app.php';
8+
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
9+
$kernel->bootstrap();
10+
11+
try {
12+
$disk = Storage::disk('s3');
13+
14+
$testFileName = 's3_connection_test_' . time() . '.txt';
15+
16+
$disk->put($testFileName, 's3_test_value');
17+
18+
if ('s3_test_value' === $disk->get($testFileName)) {
19+
$disk->delete($testFileName);
20+
exit(0);
21+
}
22+
23+
echo 'S3 store is not working properly: Test value mismatch.';
24+
exit(1);
25+
26+
} catch (Exception $e) {
27+
echo 'S3 connection error: ' . $e->getMessage();
28+
exit(1);
29+
}

src/entrypoint.sh

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ trap 'echo "Error on line $LINENO"' ERR
1010
: "${CONTAINER_WORKER_SLEEP:=5}"
1111
: "${CONTAINER_WORKER_TIMEOUT:=300}"
1212
: "${CONTAINER_WORKER_TRIES:=3}"
13-
14-
: "${TEST_DB_CONNECTION:=true}"
15-
: "${TEST_CACHE_CONNECTION:=true}"
16-
: "${TEST_SMTP_CONNECTION:=false}"
1713
: "${TEST_CONNECTION_TIMEOUT:=10}"
1814

1915
: "${APP_ENV:=production}"
@@ -47,23 +43,20 @@ _test_connection() {
4743
}
4844

4945
_test_connections() {
50-
if [ "$TEST_DB_CONNECTION" != "true" ]; then
51-
echo "⏭ Skipping database connection test..."
52-
else
53-
_test_connection "database"
54-
fi
55-
56-
if [ "$TEST_CACHE_CONNECTION" != "true" ]; then
57-
echo "⏭ Skipping cache connection test..."
58-
else
59-
_test_connection "cache"
60-
fi
61-
62-
if [ "$TEST_SMTP_CONNECTION" != "true" ]; then
63-
echo "⏭ Skipping SMTP connection test..."
64-
else
65-
_test_connection "smtp"
66-
fi
46+
declare -A connections=(
47+
[database]="${TEST_DB_CONNECTION:-true}"
48+
[cache]="${TEST_CACHE_CONNECTION:-true}"
49+
[s3]="${TEST_S3_CONNECTION:-false}"
50+
[smtp]="${TEST_SMTP_CONNECTION:-false}"
51+
)
52+
53+
for service in "${!connections[@]}"; do
54+
if [ "${connections[$service]}" != "true" ]; then
55+
echo "⏭ Skipping $service connection test..."
56+
else
57+
_test_connection "$service"
58+
fi
59+
done
6760
}
6861

6962
_migrate() {

0 commit comments

Comments
 (0)