-
Notifications
You must be signed in to change notification settings - Fork 0
/
e2e-test
executable file
·66 lines (55 loc) · 3.22 KB
/
e2e-test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env bash
# poor man's end-to-end test for s3
export AWS_ACCESS_KEY_ID="${RANDOM}"
export AWS_SECRET_ACCESS_KEY="${RANDOM}${RANDOM}"
export MINIO_ACCESS_KEY="${AWS_ACCESS_KEY_ID}"
export MINIO_SECRET_KEY="${AWS_SECRET_ACCESS_KEY}"
NORMAL=$(tput sgr0)
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
e2e_path="/tmp/.aws-micro_e2etest_tmp"
storage_path="${e2e_path}/storage-for-minio"
fail_and_exit() {
echo "${RED}Test failed!${NORMAL}"
exit 1
}
# cleanup previous failed runs
pkill -f "minio --quiet server --address :19999 ${storage_path}"
rm -rf "${storage_path}"
# init
mkdir -p "${storage_path}"
./build-single-executable "${e2e_path}/aws-micro"
nix-shell -p minio --run "minio --quiet server --address :19999 ${storage_path} > /dev/null" &
sleep 3 # minio needs some time to start up
# s3api create-bucket
"${e2e_path}/aws-micro" s3api create-bucket --endpoint-url http://127.0.0.1:19999 --bucket test-bucket || fail_and_exit
# s3 cp <LocalPath> <S3Uri>
"${e2e_path}/aws-micro" s3 --endpoint-url http://127.0.0.1:19999 cp aws-micro s3://test-bucket/ > /dev/null || fail_and_exit
"${e2e_path}/aws-micro" s3 --endpoint-url http://127.0.0.1:19999 cp aws-micro s3://test-bucket/ --content-type foo/bar > /dev/null || fail_and_exit
"${e2e_path}/aws-micro" s3 --endpoint-url http://127.0.0.1:19999 cp aws-micro s3://test-bucket/ --no-guess-mime-type > /dev/null || fail_and_exit
"${e2e_path}/aws-micro" s3 --endpoint-url http://127.0.0.1:19999 cp aws-micro s3://test-bucket/ --acl private > /dev/null || fail_and_exit
"${e2e_path}/aws-micro" s3 --endpoint-url http://127.0.0.1:19999 cp aws-micro s3://test-bucket/ --storage-class STANDARD > /dev/null || fail_and_exit
# s3 cp <S3Uri> <LocalPath>
"${e2e_path}/aws-micro" s3 --endpoint-url http://127.0.0.1:19999 cp s3://test-bucket/aws-micro ${e2e_path}/.aws-micro > /dev/null || fail_and_exit
cmp --silent aws-micro ${e2e_path}/.aws-micro || fail_and_exit
"${e2e_path}/aws-micro" s3 cp --no-sign-request s3://landsat-pds/robots.txt "${e2e_path}/robots.txt" | grep -q 'download: s3://landsat-pds/robots.txt to /tmp/.aws-micro_e2etest_tmp/robots.txt' || fail_and_exit
# s3 ls - diff with aws cli with minio
default_options='s3 ls --endpoint-url http://127.0.0.1:19999'
for options in "" "s3://test-bucket/" "test-bucket/" ; do
diff <(TZ=0 aws ${default_options} ${options}) <("${e2e_path}/aws-micro" ${default_options} ${options}) || fail_and_exit
done
# s3 ls - diff with aws cli with public s3 buckets
diff <(TZ=0 aws s3 ls --no-sign-request landsat-pds) <("${e2e_path}/aws-micro" s3 ls --no-sign-request landsat-pds) || fail_and_exit
# test folders and keys
# "" <- bucket, ls should return all top level objects
# "/" <- bucket with / added, ls should return all top level objects
# "/human" <- folder, ls should return only "/human"
# "/human/" <- folder with / added, ls should return objects of the folder
for key in "" "/" "/human" "/human/" ; do
url="s3://fah-public-data-covid19-cryptic-pockets${key}"
diff <(TZ=0 aws s3 ls --no-sign-request ${url} --region us-east-2) <("${e2e_path}/aws-micro" s3 ls --no-sign-request ${url} --region us-east-2) || fail_and_exit
done
# cleanup
pkill -f "minio --quiet server --address :19999 ${storage_path}"
rm -r "${storage_path}"
echo "${GREEN}Tests run successfully!${NORMAL}"