Enable S3 mock tests with moto (#545)
This commit is contained in:
23
.github/workflows/commit.yml
vendored
23
.github/workflows/commit.yml
vendored
@@ -91,6 +91,29 @@ jobs:
|
|||||||
# - run: go install ./cmd/litestream
|
# - run: go install ./cmd/litestream
|
||||||
# - run: go test -v -run=TestCmd_Replicate_LongRunning ./integration -long-running-duration 1m
|
# - run: go test -v -run=TestCmd_Replicate_LongRunning ./integration -long-running-duration 1m
|
||||||
|
|
||||||
|
s3-mock-test:
|
||||||
|
name: Run S3 Mock Tests
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
needs: build
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: '3.12'
|
||||||
|
# cache: 'pip'
|
||||||
|
- run: pip install moto[s3,server]
|
||||||
|
|
||||||
|
- uses: actions/setup-go@v4
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
|
||||||
|
- run: go env
|
||||||
|
|
||||||
|
- run: go install ./cmd/litestream
|
||||||
|
|
||||||
|
- run: ./etc/s3_mock.py go test -v ./replica_client_test.go -integration s3
|
||||||
|
|
||||||
# s3-integration-test:
|
# s3-integration-test:
|
||||||
# name: Run S3 Integration Tests
|
# name: Run S3 Integration Tests
|
||||||
# runs-on: ubuntu-latest
|
# runs-on: ubuntu-latest
|
||||||
|
|||||||
35
etc/s3_mock.py
Executable file
35
etc/s3_mock.py
Executable file
@@ -0,0 +1,35 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import time
|
||||||
|
from moto.server import ThreadedMotoServer
|
||||||
|
import boto3
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
cmd = sys.argv[1:]
|
||||||
|
if len(cmd) == 0:
|
||||||
|
print(f"usage: {sys.argv[0]} <command> [arguments]", file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
env = os.environ.copy() | {
|
||||||
|
"LITESTREAM_S3_ACCESS_KEY_ID": "lite",
|
||||||
|
"LITESTREAM_S3_SECRET_ACCESS_KEY": "stream",
|
||||||
|
"LITESTREAM_S3_BUCKET": f"test{int(time.time())}",
|
||||||
|
"LITESTREAM_S3_ENDPOINT": "http://127.0.0.1:5000",
|
||||||
|
"LITESTREAM_S3_FORCE_PATH_STYLE": "true",
|
||||||
|
}
|
||||||
|
|
||||||
|
server = ThreadedMotoServer()
|
||||||
|
server.start()
|
||||||
|
|
||||||
|
s3 = boto3.client(
|
||||||
|
"s3",
|
||||||
|
aws_access_key_id=env["LITESTREAM_S3_ACCESS_KEY_ID"],
|
||||||
|
aws_secret_access_key=["LITESTREAM_S3_SECRET_ACCESS_KEY"],
|
||||||
|
endpoint_url=env["LITESTREAM_S3_ENDPOINT"]
|
||||||
|
).create_bucket(Bucket=env["LITESTREAM_S3_BUCKET"])
|
||||||
|
|
||||||
|
proc = subprocess.run(cmd, env=env)
|
||||||
|
|
||||||
|
server.stop()
|
||||||
|
sys.exit(proc.returncode)
|
||||||
Reference in New Issue
Block a user