Skip to content

Commit

Permalink
Test for Worm Mode Introduced
Browse files Browse the repository at this point in the history
Test cases are added to check the worm mode of the Server
  • Loading branch information
sinhaashish committed May 18, 2018
1 parent 554f65b commit 127f510
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 11 deletions.
5 changes: 4 additions & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,13 @@ RUN /mint/build/minio-dotnet/install.sh
COPY build/security /mint/build/security
RUN build/security/install.sh

COPY build/worm /mint/build/worm
RUN build/worm/install.sh

COPY remove-packages.list /mint
COPY postinstall.sh /mint
RUN /mint/postinstall.sh

COPY mint.sh /mint/mint.sh
COPY entrypoint.sh /mint/entrypoint.sh
ENTRYPOINT ["/mint/entrypoint.sh"]
ENTRYPOINT ["/mint/entrypoint.sh"]
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Mint is a testing framework for Minio object server, available as a docker image
- minio-py
- minio-dotnet
- s3cmd
- worm

## Running Mint

Expand All @@ -25,6 +26,12 @@ To run Mint with Minio Play server as test target,
$ docker run -e SERVER_ENDPOINT=play.minio.io:9000 -e ACCESS_KEY=Q3AM3UQ867SPQQA43P2F \
-e SECRET_KEY=zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG -e ENABLE_HTTPS=1 minio/mint
```
In case of Worm mode

```sh
$ docker run -e SERVER_ENDPOINT=play.minio.io:9000 -e ACCESS_KEY=Q3AM3UQ867SPQQA43P2F \
-e SECRET_KEY=zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG -e ENABLE_HTTPS=1 -e MINT_MODE=worm minio/mint
```

After the tests are run, output is stored in `/mint/log` directory inside the container. To get these logs, use `docker cp` command. For example
```sh
Expand All @@ -41,7 +48,7 @@ Below environment variables are required to be passed to the docker container. S
| `ACCESS_KEY` | Access key of access `SERVER_ENDPOINT` | `Q3AM3UQ867SPQQA43P2F` |
| `SECRET_KEY` | Secret Key of access `SERVER_ENDPOINT` | `zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG` |
| `ENABLE_HTTPS` | (Optional) Set `1` to indicate to use HTTPS to access `SERVER_ENDPOINT`. Defaults to `0` (HTTP) | `1` |
| `MINT_MODE` | (Optional) Set mode indicating what category of tests to be run by values `core` or `full`. Defaults to `core` | `full` |
| `MINT_MODE` | (Optional) Set mode indicating what category of tests to be run by values `core`, `full` or `worm`. Defaults to `core` | `full` |

### Mint log format

Expand Down Expand Up @@ -70,7 +77,14 @@ $ docker run -e SERVER_ENDPOINT=play.minio.io:9000 -e ACCESS_KEY=Q3AM3UQ867SPQQA
-e SECRET_KEY=zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG \
-e ENABLE_HTTPS=1 -e MINT_MODE=full minio/mint:latest
```
In case of Worm Mode

```sh
$ docker build -t minio/mint . -f Dockerfile.dev
$ docker run -e SERVER_ENDPOINT=play.minio.io:9000 -e ACCESS_KEY=Q3AM3UQ867SPQQA43P2F \
-e SECRET_KEY=zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG \
-e ENABLE_HTTPS=1 -e MINT_MODE=worm minio/mint:latest
```
### Adding tests with new tool/SDK

Below are the steps need to be followed
Expand Down
24 changes: 24 additions & 0 deletions build/worm/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash -e
#
# Mint (C) 2017 Minio, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

test_run_dir="$MINT_RUN_CORE_DIR/worm"
go get -u github.com/aws/aws-sdk-go/aws/...
go get -u github.com/aws/aws-sdk-go/aws/credentials/...
go get -u github.com/aws/aws-sdk-go/aws/session/...
go get -u github.com/aws/aws-sdk-go/service/s3/...
go get -u github.com/sirupsen/logrus/...
go build -o "$test_run_dir/worm" "$test_run_dir/quick-worm-tests.go"
55 changes: 46 additions & 9 deletions mint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ MINT_MODE=${MINT_MODE:-core}
SERVER_REGION=${SERVER_REGION:-us-east-1}
ENABLE_HTTPS=${ENABLE_HTTPS:-0}


if [ -z "$SERVER_ENDPOINT" ]; then
SERVER_ENDPOINT="play.minio.io:9000"
ACCESS_KEY="Q3AM3UQ867SPQQA43P2F"
Expand Down Expand Up @@ -60,9 +61,10 @@ function run_test()
start=$(date +%s)

mkdir -p "$BASE_LOG_DIR/$sdk_name"

echo "BASE_LOG_DIR :$BASE_LOG_DIR"
(cd "$sdk_dir" && ./run.sh "$BASE_LOG_DIR/$LOG_FILE" "$BASE_LOG_DIR/$sdk_name/$ERROR_FILE")
rv=$?
echo " ev $rv"
end=$(date +%s)
duration=$(humanize_time $(( end - start )))

Expand Down Expand Up @@ -97,6 +99,7 @@ function main()
export SECRET_KEY
export ENABLE_HTTPS
export SERVER_REGION


echo "Running with"
echo "SERVER_ENDPOINT: $SERVER_ENDPOINT"
Expand All @@ -119,13 +122,36 @@ function main()
## On empty command line argument, populate all SDK names from $TESTS_DIR
if [ "${#run_list[@]}" -eq 0 ]; then
run_list=( "$TESTS_DIR"/* )
fi
fi

## Run Worm test Only when worm mode is on
sdk_dir="$TESTS_DIR/worm"
worm_test_status=true
if [ "$MINT_MODE" = "worm" ];
then
sdk_name=$(basename "$sdk_dir")
if [ ! -d "$sdk_dir" ]; then
echo "Test $sdk_name not found. Exiting Mint."
exit 1
fi
echo -n " Running $sdk_name tests ... "
if ! run_test "$sdk_dir"; then
worm_test_status=false
fi
else
# Remove worm test case
for i in "${!run_list[@]}"; do
if [[ ${run_list[i]} = "${sdk_dir}" ]]; then
unset 'run_list[i]'
fi
done

count="${#run_list[@]}"
i=0

for sdk_dir in "${run_list[@]}"; do
sdk_name=$(basename "$sdk_dir")
(( i++ ))
(( i++ ))
if [ ! -d "$sdk_dir" ]; then
echo "Test $sdk_name not found. Exiting Mint."
exit 1
Expand All @@ -136,14 +162,25 @@ function main()
break
fi
done
fi

## Report when all tests in run_list are run
if [ $i -eq "$count" ]; then
echo -e "\nAll tests ran successfully"
else
echo -e "\nExecuted $i out of $count tests successfully."
exit 1
fi

if [ "$MINT_MODE" = "worm" ];then
if [ "$worm_test_status" = true ]; then
echo -e "\\nWORM tests ran successfully"
else
echo -e "\\nWORM tests ran failed"
exit 1
fi
else
if [ $i -eq "$count" ]; then
echo -e "\\nAll tests ran successfully"
else
echo -e "\\nExecuted $i out of $count tests successfully."
exit 1
fi
fi
}

main "$@"
28 changes: 28 additions & 0 deletions run/core/worm/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
#
# Mint (C) 2017 Minio, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# handle command line arguments
if [ $# -ne 2 ]; then
echo "usage: run.sh <OUTPUT-LOG-FILE> <ERROR-LOG-FILE>"
exit -1
fi

output_log_file="$1"
error_log_file="$2"

# run tests
/mint/run/core/worm/worm 1>>"$output_log_file" 2>"$error_log_file"

0 comments on commit 127f510

Please sign in to comment.