From f197eafe5d679faa76f1c1c923173088daf0cd06 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Fri, 31 Mar 2023 11:03:33 +0100 Subject: [PATCH 1/3] CI: Add compliance test to CI --- .github/workflows/pull-request.yml | 69 ++++++++++++++++++++++++++++++ Makefile | 6 ++- scripts/minio-run | 18 -------- scripts/minio-start | 4 ++ scripts/minio-stop | 3 ++ 5 files changed, 81 insertions(+), 19 deletions(-) delete mode 100755 scripts/minio-run create mode 100755 scripts/minio-start create mode 100755 scripts/minio-stop diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 55b3470..a9db598 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -20,3 +20,72 @@ jobs: - name: Test run: make test + compliance-test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Build + run: make build + + - name: Checkout compliance test suite + uses: actions/checkout@v3 + with: + repository: stackhpc/s3-active-storage-compliance-suite + path: compliance + + - name: Setup python + uses: actions/setup-python@v4 + + - name: Install compliance test suite dependencies + run: pip install -r requirements.txt + working-directory: compliance + + - name: Configure compliance test suite + run: | + echo 'PROXY_URL = "http://localhost:8080"' >> compliance/config.py + working-directory: compliance + + - name: Start minio object storage + run: scripts/minio-start + + - name: Wait for minio object storage to start + run: | + until curl -if http://localhost:9001; do + sleep 1; + done + + - name: Run active storage container + run: make run + + - name: Wait for active storage server to start + run: | + until curl -if http://localhost:8080/.well-known/s3-active-storage-schema; do + sleep 1; + done + + - name: Create artifacts directory + run: mkdir artifacts + + - name: Run compliance test suite + run: pytest -s > artifacts/pytest.log + + - name: Get active storage logs + run: docker logs s3-active-storage > artifacts/s3-active-storage.log + if: always() + + - name: Upload artifacts + uses: actions/upload-artifact@v3 + with: + name: compliance-test + path: artifacts + if: always() + + - name: Stop minio object storage + run: scripts/minio-stop + if: always() + + - name: Stop active storage container + run: make stop + if: always() diff --git a/Makefile b/Makefile index 13a8ab1..f747890 100644 --- a/Makefile +++ b/Makefile @@ -10,4 +10,8 @@ test: .PHONY: run run: - @docker run -it --rm --net=host --name s3-active-storage s3-active-storage + @docker run -it --detach --rm --net=host --name s3-active-storage s3-active-storage + +.PHONY: stop +stop: + @docker stop s3-active-storage diff --git a/scripts/minio-run b/scripts/minio-run deleted file mode 100755 index 53aeb6b..0000000 --- a/scripts/minio-run +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -# REPO_ROOT="$(dirname $(dirname $(realpath ${BASH_SOURCE[0]:-${(%):-%x}})))" #Doesn't work on MacOS / zsh shell -# REPO_ROOT="$(pwd)" #Use this instead then upload data to minio manually if needed -# echo "Data directory for minio instance: $REPO_ROOT/testdata" - -# exec docker run \ -# --rm \ -# -p 9000:9000 \ -# -p 9001:9001 \ -# -v "$REPO_ROOT/testdata:/data" \ -# minio/minio \ -# server \ -# /data \ -# --console-address ":9001" - -# Use anon storage volume so that test data is removed when container is stopped -exec docker run --rm -p 9000:9000 -p 9001:9001 -v :/data minio/minio server data --console-address ":9001" diff --git a/scripts/minio-start b/scripts/minio-start new file mode 100755 index 0000000..16aecaa --- /dev/null +++ b/scripts/minio-start @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +# Use anon storage volume so that test data is removed when container is stopped +exec docker run --detach --rm -p 9000:9000 -p 9001:9001 -v :/data --name minio minio/minio server data --console-address ":9001" diff --git a/scripts/minio-stop b/scripts/minio-stop new file mode 100755 index 0000000..663b8b4 --- /dev/null +++ b/scripts/minio-stop @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +exec docker stop minio From b80124788c7cabdeeae2758df7f9944bb5e9bbd8 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Mon, 3 Apr 2023 09:25:51 +0100 Subject: [PATCH 2/3] Dockerfile: Add CA certificates for AWS SDK --- Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Dockerfile b/Dockerfile index a72b8df..420345d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,5 +10,9 @@ RUN cargo install --path . # Stage 2: final image FROM debian:bullseye-slim +# AWS SDK requires CA certificates to be present. +RUN apt update \ + && apt install -y --no-install-recommends ca-certificates \ + && update-ca-certificates COPY --from=builder /usr/local/cargo/bin/s3-active-storage /usr/local/bin/s3-active-storage CMD ["s3-active-storage"] From 866a22d2cb054231e52464aa2ef8637ff58c3444 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Mon, 3 Apr 2023 10:06:29 +0100 Subject: [PATCH 3/3] CI: Only run tests on pushes to main --- .github/workflows/pull-request.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index a9db598..f74e0f4 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -1,8 +1,10 @@ --- name: Pull request on: - - push - - pull_request + push: + branches: + - main + pull_request: jobs: build: runs-on: ubuntu-latest