Skip to content

Commit

Permalink
use localstack to test aws upload
Browse files Browse the repository at this point in the history
Signed-off-by: Dweb Fan <[email protected]>
  • Loading branch information
dwebfan committed Jun 2, 2024
1 parent 5c12a16 commit 05cdd92
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 41 deletions.
81 changes: 41 additions & 40 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,45 @@ on:
# - synchronize
# - reopened
jobs:
lint:
runs-on: ubuntu-22.04
container:
image: lomorage/lomo-backup:1.0
env:
PATH: /bin:/usr/bin:/usr/local/bin:/usr/local/go/bin
GOFLAGS: "-buildvcs=false"
steps:
- uses: actions/checkout@v4
- run: make lint
# lint:
# runs-on: ubuntu-22.04
# container:
# image: lomorage/lomo-backup:1.0
# env:
# PATH: /bin:/usr/bin:/usr/local/bin:/usr/local/go/bin
# GOFLAGS: "-buildvcs=false"
# steps:
# - uses: actions/checkout@v4
# - run: make lint
#
# unit-test:
# runs-on: ubuntu-22.04
# container:
# image: lomorage/lomo-backup:1.0
# env:
# PATH: /bin:/usr/bin:/usr/local/bin:/usr/local/go/bin
# GOBIN: /usr/local/bin
# GOFLAGS: "-buildvcs=false"
# steps:
# - uses: actions/checkout@v4
# - run: make unit-tests

unit-test:
runs-on: ubuntu-22.04
container:
image: lomorage/lomo-backup:1.0
env:
PATH: /bin:/usr/bin:/usr/local/bin:/usr/local/go/bin
GOBIN: /usr/local/bin
GOFLAGS: "-buildvcs=false"
steps:
- uses: actions/checkout@v4
- run: make unit-tests

e2e-test:
runs-on: ubuntu-22.04
container:
image: lomorage/lomo-backup:1.0
env:
PATH: /bin:/usr/bin:/usr/local/bin:/usr/local/go/bin
GOBIN: /usr/local/bin
GOFLAGS: "-buildvcs=false"
WORKDIR: /go/src/github.com/lomorage/lomo-backup
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
- run: cd test/data; find . | while read -r file; do git log -1 --format="%ad" --date=iso "$file" | xargs -t -I{} touch -d {} "$file"; done
- run: mkdir -p $WORKDIR; rsync -avz * $WORKDIR/; cd $WORKDIR; tree --si -D test/data/
- run: cd $WORKDIR; make install
- run: cd $WORKDIR; make e2e-tests
# e2e-test:
# runs-on: ubuntu-22.04
# container:
# image: lomorage/lomo-backup:1.0
# env:
# PATH: /bin:/usr/bin:/usr/local/bin:/usr/local/go/bin
# GOBIN: /usr/local/bin
# GOFLAGS: "-buildvcs=false"
# WORKDIR: /go/src/github.com/lomorage/lomo-backup
# steps:
# - uses: actions/checkout@v4
# with:
# submodules: true
# fetch-depth: 0
# - run: ./dockerfiles/run-localstack.sh
# - run: cd test/data; find . | while read -r file; do git log -1 --format="%ad" --date=iso "$file" | xargs -t -I{} touch -d {} "$file"; done
# - run: mkdir -p $WORKDIR; rsync -avz * $WORKDIR/; cd $WORKDIR; tree --si -D test/data/
# - run: cd $WORKDIR; make install
# - run: cd $WORKDIR; make e2e-tests
22 changes: 22 additions & 0 deletions dockerfiles/run-localstack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -e
docker run -p 4566:4566 -p 4510-4559:4510-4559 localstack/localstack:3.4.0 &

max_retry=50
retry_count=0
while [ $retry_count -lt $max_retry ]; do
if curl localhost:4566; then
echo "Localstack is running!"
break
else
echo "Localstack is not yet ready. Retrying in 5 seconds..."
sleep 5
fi
retry_count=$((retry_count + 1))
done

if [ $retry_count -eq $max_retry ]; then
echo "Max retry limit reached. Exiting..."
exit 1
fi
2 changes: 1 addition & 1 deletion test/scripts/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rm -f lomob.db; sqlite3 ./lomob.db < ../../common/dbx/schema/1.sql
./test-iso-list.sh

# test upload raw
#./test-upload-aws-raw.sh
./test-upload-aws-raw.sh

# test upload encrypt file
#./test-upload-aws-encrypt.sh

0 comments on commit 05cdd92

Please sign in to comment.