From 590295c3d16c8d10bda9636022b8325c25b20d92 Mon Sep 17 00:00:00 2001 From: Ben McClelland Date: Fri, 13 Sep 2024 11:49:07 -0700 Subject: [PATCH] test: separate out direct tests dockerfile for easier use The direct tests don't need the gateway or any go compilers. This separates out the dockerfile to minimize it a bit more from the other tests. --- tests/Dockerfile_direct | 73 +++++++++++++++++++++++++++++++++++ tests/docker-compose-bats.yml | 9 +++-- tests/run_all.sh | 3 ++ 3 files changed, 81 insertions(+), 4 deletions(-) create mode 100644 tests/Dockerfile_direct diff --git a/tests/Dockerfile_direct b/tests/Dockerfile_direct new file mode 100644 index 0000000..25af863 --- /dev/null +++ b/tests/Dockerfile_direct @@ -0,0 +1,73 @@ +FROM ubuntu:latest + +ARG DEBIAN_FRONTEND=noninteractive +ARG SECRETS_FILE=tests/.secrets.direct +ARG CONFIG_FILE=tests/.env.direct +ARG AWS_CLI=awscli-exe-linux-aarch64.zip +ARG MC_FOLDER=linux-arm64 + +ENV TZ=Etc/UTC +RUN apt-get update && \ + apt-get install -y --no-install-recommends \ + git \ + wget \ + curl \ + unzip \ + tzdata \ + s3cmd \ + jq \ + bc \ + libxml2-utils \ + ca-certificates && \ + update-ca-certificates && \ + rm -rf /var/lib/apt/lists/* + +# Set working directory +WORKDIR /tmp + +# Install AWS cli +RUN curl "https://awscli.amazonaws.com/${AWS_CLI}" -o "awscliv2.zip" && unzip awscliv2.zip && ./aws/install + +# Install mc +RUN curl https://dl.min.io/client/mc/release/${MC_FOLDER}/mc \ + --create-dirs \ + -o /usr/local/minio-binaries/mc && \ +chmod -R 755 /usr/local/minio-binaries +ENV PATH=/usr/local/minio-binaries:${PATH} + +# Create tester user +RUN groupadd -r tester && useradd -r -g tester tester +RUN mkdir /home/tester && chown tester:tester /home/tester +ENV HOME=/home/tester + +# install bats +RUN git clone https://github.com/bats-core/bats-core.git && \ + cd bats-core && \ + ./install.sh /home/tester + +USER tester +RUN mkdir -p /home/tester/tests +COPY --chown=tester:tester . /home/tester/tests + +# add bats support libraries +RUN git clone https://github.com/bats-core/bats-support.git && rm -rf /home/tester/tests/bats-support && mv bats-support /home/tester/tests +RUN git clone https://github.com/ztombol/bats-assert.git && rm -rf /home/tester/tests/bats-assert && mv bats-assert /home/tester/tests + +WORKDIR /home/tester + +RUN . $SECRETS_FILE && \ + export AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY AWS_REGION AWS_PROFILE && \ + aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID --profile $AWS_PROFILE && \ + aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY --profile $AWS_PROFILE && \ + aws configure set aws_region $AWS_REGION --profile $AWS_PROFILE + +RUN mkdir /tmp/gw + +RUN openssl genpkey -algorithm RSA -out versitygw-docker.pem -pkeyopt rsa_keygen_bits:2048 && \ + openssl req -new -x509 -key versitygw-docker.pem -out cert-docker.pem -days 365 \ + -subj "/C=US/ST=California/L=San Francisco/O=Versity/OU=Software/CN=versity.com" + +ENV WORKSPACE=. +ENV VERSITYGW_TEST_ENV=$CONFIG_FILE + +CMD ["tests/run_all.sh"] diff --git a/tests/docker-compose-bats.yml b/tests/docker-compose-bats.yml index b57cd25..58ad6fd 100644 --- a/tests/docker-compose-bats.yml +++ b/tests/docker-compose-bats.yml @@ -28,7 +28,8 @@ services: direct: build: context: . - dockerfile: Dockerfile_test_bats - args: - - CONFIG_FILE=tests/.env.direct - - SECRETS_FILE=tests/.secrets.direct + dockerfile: Dockerfile_direct + volumes: + - ./.env.direct:/home/tester/tests/.env.direct + - ./.secrets.direct:/home/tester/tests/.secrets.direct + diff --git a/tests/run_all.sh b/tests/run_all.sh index 0f447f2..45ead44 100755 --- a/tests/run_all.sh +++ b/tests/run_all.sh @@ -19,6 +19,9 @@ if [[ -z "$VERSITYGW_TEST_ENV" ]] && [[ $BYPASS_ENV_FILE != "true" ]]; then exit 1 fi +# print config for test results info +grep -v ^# "$VERSITYGW_TEST_ENV" + status=0 for cmd in s3api s3 s3cmd mc rest; do