forked from jedbrown/git-fat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
executable file
·128 lines (115 loc) · 3.08 KB
/
test.sh
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#! /usr/bin/env bash
set -eux
function run_integration_test() {
rm -rf fat-test fat-test2 /tmp/fat-store
git init fat-test
pushd fat-test
{
git fat init
mv ../.gitfat .
echo '*.fat filter=fat -crlf' >.gitattributes
git add .gitattributes .gitfat
git commit -m 'initial fat repository'
ln -s /oe/dss-oe/dss-add-ons-testing-build/deploy/licenses/common-licenses/GPL-3 c
git add c
git commit -m 'add broken symlink'
echo 'fat content a' >a.fat
git add a.fat
git commit -m 'add a.fat'
echo 'fat content b' >b.fat
git add b.fat
git commit -m 'add b.fat'
echo 'revise fat content a' >a.fat
git commit -am 'revise a.fat'
git fat push
}
popd
git clone fat-test fat-test2
pushd fat-test2
{
# checkout and pull should fail in repo not yet init'ed for git-fat
git fat checkout && true
if [ $? -eq 0 ]; then
echo 'ERROR: "git fat checkout" in uninitialized repo should fail'
exit 1
fi
git fat pull -- 'a.fa*' && true
if [ $? -eq 0 ]; then
echo 'ERROR: "git fat pull" in uninitialized repo should fail'
exit 1
fi
git fat init
git fat pull -- 'a.fa*'
cat a.fat
echo 'file which is committed and removed afterwards' >d
git add d
git commit -m 'add d with normal content'
rm d
git fat pull
# Check verify command finds corrupt object
mv .git/fat/objects/6e/cec2e21d3033e7ba53e2db63f69dbd3a011fa8 \
.git/fat/objects/6e/cec2e21d3033e7ba53e2db63f69dbd3a011fa8.bak
echo "Not the right data" >.git/fat/objects/6ecec2e21d3033e7ba53e2db63f69dbd3a011fa8
git fat verify && true
if [ $? -eq 0 ]; then
echo "Verify did not detect invalid object"
exit 1
fi
mv .git/fat/objects/6e/cec2e21d3033e7ba53e2db63f69dbd3a011fa8.bak \
.git/fat/objects/6e/cec2e21d3033e7ba53e2db63f69dbd3a011fa8
}
popd
}
## ________________________________________
## RSYNC integration tests
echo "
[rsync]
remote = /tmp/fat-store
" | tee .gitfat
run_integration_test
rm -rf /tmp/fat-store
## ________________________________________
## RCLONE integration tests
mkdir -p /tmp/fat-store
echo "
[rclone]
remotedir = /tmp/fat-store
type = local
nounc = true
" | tee .gitfat
run_integration_test
rm -rf /tmp/fat-store
## ________________________________________
## AWS S3 integration tests
export AWS_ACCESS_KEY_ID=fat-test
export AWS_SECRET_ACCESS_KEY=fat-test
export AWS_DEFAULT_REGION=us-east-1
export MINIO_ACCESS_KEY=${AWS_ACCESS_KEY_ID}
export MINIO_SECRET_KEY=${AWS_SECRET_ACCESS_KEY}
pidof minio || nohup minio server /tmp/miniodata &
sleep 1
mkdir -p ~/.aws
echo "
[default]
aws_access_key_id = ${AWS_ACCESS_KEY_ID}
aws_secret_access_key = ${AWS_SECRET_ACCESS_KEY}
" | tee ~/.aws/credentials
echo "
[default]
region = us-east-1
s3 =
endpoint_url=http://localhost:9000
signature_version = s3v4
s3api =
endpoint_url=http://localhost:9000
[plugins]
endpoint = awscli_plugin_endpoint
" | tee ~/.aws/config
aws s3 rb --force s3://test-bucket || true
aws s3 mb s3://test-bucket
echo "
[s3]
bucket = test-bucket
" | tee .gitfat
run_integration_test
pkill minio