feat(garage): configuration Docker Compose et tests de fumée S3
This commit is contained in:
@@ -83,3 +83,6 @@ infra/proxy/acme/
|
|||||||
*.swp
|
*.swp
|
||||||
.DS_Store
|
.DS_Store
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
|
||||||
|
# Docker garage
|
||||||
|
garage/garage.toml
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
services:
|
||||||
|
garage:
|
||||||
|
image: dxflrs/garage:v1.0.1
|
||||||
|
container_name: enervision-garage
|
||||||
|
ports:
|
||||||
|
- "127.0.0.1:3900:3900"
|
||||||
|
- "127.0.0.1:3901:3901"
|
||||||
|
- "127.0.0.1:3903:3903"
|
||||||
|
volumes:
|
||||||
|
- ./garage.toml:/etc/garage.toml:ro
|
||||||
|
- garage-meta:/var/lib/garage/meta
|
||||||
|
- garage-data:/var/lib/garage/data
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
garage-meta:
|
||||||
|
garage-data:
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
metadata_dir = "/var/lib/garage/meta"
|
||||||
|
data_dir = "/var/lib/garage/data"
|
||||||
|
db_engine = "sqlite"
|
||||||
|
|
||||||
|
replication_factor = 1
|
||||||
|
|
||||||
|
rpc_bind_addr = "[::]:3901"
|
||||||
|
rpc_public_addr = "127.0.0.1:3901"
|
||||||
|
# Générer la vôtre : python -c "import secrets; print(secrets.token_hex(32))"
|
||||||
|
rpc_secret = "change_me"
|
||||||
|
|
||||||
|
[s3_api]
|
||||||
|
s3_region = "garage"
|
||||||
|
api_bind_addr = "[::]:3900"
|
||||||
|
root_domain = ".s3.garage.localhost"
|
||||||
|
|
||||||
|
[admin]
|
||||||
|
api_bind_addr = "[::]:3903"
|
||||||
|
# Générer la vôtre avec la même commande que rpc_secret
|
||||||
|
admin_token = "change_me"
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
"""
|
||||||
|
Tests de fumée pour Garage — vérifie que le cluster local accepte
|
||||||
|
vraiment des écritures et les rend intactes, pas juste qu'il démarre.
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
import uuid
|
||||||
|
|
||||||
|
import boto3
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
ENDPOINT_URL = "http://127.0.0.1:3900"
|
||||||
|
ACCESS_KEY = os.environ["GARAGE_ACCESS_KEY"]
|
||||||
|
SECRET_KEY = os.environ["GARAGE_SECRET_KEY"]
|
||||||
|
BUCKET = "enervision-raw-test"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def client():
|
||||||
|
return boto3.client(
|
||||||
|
"s3",
|
||||||
|
endpoint_url=ENDPOINT_URL,
|
||||||
|
aws_access_key_id=ACCESS_KEY,
|
||||||
|
aws_secret_access_key=SECRET_KEY,
|
||||||
|
region_name="garage",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_bucket_exists(client):
|
||||||
|
response = client.list_buckets()
|
||||||
|
noms = [b["Name"] for b in response["Buckets"]]
|
||||||
|
assert BUCKET in noms
|
||||||
|
|
||||||
|
|
||||||
|
def test_upload_and_download_roundtrip(client):
|
||||||
|
cle = f"test-{uuid.uuid4()}.txt"
|
||||||
|
contenu = b"contenu de test EnerVision"
|
||||||
|
|
||||||
|
client.put_object(Bucket=BUCKET, Key=cle, Body=contenu)
|
||||||
|
|
||||||
|
reponse = client.get_object(Bucket=BUCKET, Key=cle)
|
||||||
|
recupere = reponse["Body"].read()
|
||||||
|
|
||||||
|
assert recupere == contenu
|
||||||
|
|
||||||
|
client.delete_object(Bucket=BUCKET, Key=cle)
|
||||||
|
|
||||||
|
|
||||||
|
def test_deleted_object_is_really_gone(client):
|
||||||
|
cle = f"test-suppression-{uuid.uuid4()}.txt"
|
||||||
|
client.put_object(Bucket=BUCKET, Key=cle, Body=b"a supprimer")
|
||||||
|
|
||||||
|
client.delete_object(Bucket=BUCKET, Key=cle)
|
||||||
|
|
||||||
|
with pytest.raises(client.exceptions.NoSuchKey):
|
||||||
|
client.get_object(Bucket=BUCKET, Key=cle)
|
||||||
Reference in New Issue
Block a user