-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bats test dockerfile, test refactoring, file compare updates
- Loading branch information
Showing
14 changed files
with
144 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
FROM --platform=linux/arm64 ubuntu:latest | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends \ | ||
git \ | ||
make \ | ||
wget \ | ||
curl \ | ||
unzip \ | ||
jq \ | ||
ca-certificates && \ | ||
update-ca-certificates && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Set working directory | ||
WORKDIR /tmp | ||
|
||
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-aarch64.zip" -o "awscliv2.zip" && unzip awscliv2.zip && ./aws/install | ||
|
||
# Download Go 1.21 (adjust the version and platform as needed) | ||
RUN wget https://golang.org/dl/go1.21.7.linux-arm64.tar.gz | ||
|
||
# Extract the downloaded archive | ||
RUN tar -xvf go1.21.7.linux-arm64.tar.gz -C /usr/local | ||
|
||
# Set Go environment variables | ||
ENV PATH="/usr/local/go/bin:${PATH}" | ||
ENV GOPATH="/go" | ||
ENV GOBIN="$GOPATH/bin" | ||
|
||
# Make the directory for Go packages | ||
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH" | ||
|
||
# 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 | ||
|
||
RUN git clone https://github.com/bats-core/bats-core.git && \ | ||
cd bats-core && \ | ||
./install.sh /home/tester | ||
|
||
USER tester | ||
COPY . /home/tester | ||
|
||
WORKDIR /home/tester | ||
RUN make | ||
|
||
RUN . tests/.secrets && \ | ||
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 | ||
|
||
ENV WORKSPACE=. | ||
|
||
CMD ["tests/run_all.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
AWS_REGION=us-east-1 | ||
AWS_PROFILE=versity | ||
AWS_ENDPOINT_URL=http://127.0.0.1:7070 | ||
VERSITY_EXE=./versitygw | ||
BACKEND=posix | ||
LOCAL_FOLDER=/tmp/gw | ||
AWS_ENDPOINT_URL=http://127.0.0.1:7070 | ||
BUCKET_ONE_NAME=versity-gwtest-bucket-one | ||
BUCKET_TWO_NAME=versity-gwtest-bucket-two | ||
RECREATE_BUCKETS=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
AWS_REGION=us-east-1 | ||
AWS_PROFILE=versity | ||
AWS_ENDPOINT_URL=http://127.0.0.1:7070 | ||
VERSITY_EXE=./versitygw | ||
BACKEND=posix | ||
LOCAL_FOLDER=/tmp/gw | ||
AWS_ENDPOINT_URL=http://127.0.0.1:7070 | ||
BUCKET_ONE_NAME=versity-gwtest-bucket-one-static | ||
BUCKET_TWO_NAME=versity-gwtest-bucket-two-static | ||
RECREATE_BUCKETS=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
AWS_REGION=us-east-1 | ||
AWS_PROFILE=versity | ||
AWS_ENDPOINT_URL=http://127.0.0.1:7070 | ||
VERSITY_EXE=./versitygw | ||
BACKEND=posix | ||
LOCAL_FOLDER=/tmp/gw | ||
AWS_ENDPOINT_URL=http://127.0.0.1:7070 | ||
BUCKET_ONE_NAME=versity-gwtest-bucket-one | ||
BUCKET_TWO_NAME=versity-gwtest-bucket-two | ||
RECREATE_BUCKETS=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,25 @@ | ||
# Command-Line Tests | ||
|
||
Instructions: | ||
## Instructions - Running Locally | ||
|
||
1. Build the `versitygw` binary. | ||
2. Create a local AWS profile for connection to S3, and add the `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` values above to the profile. | ||
3. Create an environment file (`.env`) similar to the ones in this folder, setting the `AWS_PROFILE` parameter to the name of the profile you created. | ||
4. In the root repo folder, run with `VERSITYGW_TEST_ENV=<env file> tests/s3_bucket_tests.sh`. | ||
5. If running/testing the GitHub workflow locally, create a `.secrets` file, and set the `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` parameters here to the values of your AWS S3 IAM account. | ||
2. Install the aws command-line interface if unavailable on your machine. Instructions are [here](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html). | ||
3. Install BATS. Instructions are [here](https://bats-core.readthedocs.io/en/stable/installation.html). | ||
4. Create a `.secrets` file in the `tests` folder, and add the `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` values to the file. | ||
5. Create a local AWS profile for connection to S3, and add the `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_REGION` values for your account to the profile. Example: | ||
``` | ||
AWS_ACCESS_KEY_ID=<key_id> | ||
AWS_SECRET_ACCESS_KEY=<secret_key> | ||
export AWS_PROFILE=versity-test | ||
export AWS_ACCESS_KEY_ID=<your account ID> | ||
export AWS_SECRET_ACCESS_KEY=<your account key> | ||
export AWS_REGION=<your account region> | ||
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 | ||
``` | ||
6. To run the workflow locally, install **act** and run with `act -W .github/workflows/system.yml`. | ||
6. Create an environment file (`.env`) similar to the ones in this folder, setting the `AWS_PROFILE` parameter to the name of the profile you created. | ||
7. In the root repo folder, run with `VERSITYGW_TEST_ENV=<env file> tests/run_all.sh`. | ||
|
||
## Instructions - Running With Docker | ||
|
||
1. Create a `.secrets` file in the `tests` folder, and add the `AWS_PROFILE`, `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and the `AWS_PROFILE` fields. | ||
2. Build and run the `Dockerfile_test_bats` file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,12 @@ | ||
#!/bin/bash | ||
|
||
VERSITYGW_TEST_ENV=$WORKSPACE/tests/.env.default "$HOME"/bin/bats ./tests/s3_bucket_tests.sh | ||
VERSITYGW_TEST_ENV=$WORKSPACE/tests/.env.default "$HOME"/bin/bats ./tests/posix_tests.sh | ||
export VERSITYGW_TEST_ENV=$WORKSPACE/tests/.env.default | ||
# shellcheck source=./.env.default | ||
source "$VERSITYGW_TEST_ENV" | ||
export AWS_PROFILE BUCKET_ONE_NAME BUCKET_TWO_NAME AWS_ENDPOINT_URL | ||
if ! "$HOME"/bin/bats ./tests/s3_bucket_tests.sh; then | ||
exit 1 | ||
fi | ||
if ! "$HOME"/bin/bats ./tests/posix_tests.sh; then | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/bash | ||
|
||
if ! ./tests/run.sh; then | ||
exit 1 | ||
fi | ||
if ! ./tests/run_static.sh; then | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters