-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·136 lines (110 loc) · 2.91 KB
/
Copy pathtest.sh
File metadata and controls
executable file
·136 lines (110 loc) · 2.91 KB
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
129
130
131
132
133
134
135
#!/bin/bash
. swiftlib.sh
. ~/.swiftbash.sh
DEBUG=yes
if authenticate $STORAGE_USER $STORAGE_KEY ; then
echo "+ AUTH Passed"
else
echo "+ AUTH Failed"
exit -1
fi
acc_meta=$(get_acct_meta)
debug "$acc_meta"
if echo "$acc_meta" | grep "X-Account-Object-Count:" > /dev/null ; then
echo "+ ACC_meta Passed"
else
echo "+ ACC_meta Failed"
fi
acc_bytes=$(get_acct_bytes_used)
acc_conts=$(get_acct_cont_count)
CONTLIST=$(get_cont_list)
cont_num=$(echo "$CONTLIST" | wc -l)
if [ "$cont_num" -eq "$acc_conts" ]; then
echo "+ ACC_cont_list Passed"
else
echo "+ ACC_cont_list Failed"
fi
CONT=$(echo "$CONTLIST"|tail -n1)
cont_meta=$(get_cont_meta $CONT)
if echo "$cont_meta" | grep "X-Container-Object-Count:" > /dev/null ; then
echo "+ CONT_meta Passed"
else
echo "+ CONT_meta Failed"
fi
obj_count=$(get_obj_count $CONT)
OBJLIST=$(get_obj_list $CONT)
OBJLISTL=$(get_obj_list_long $CONT)
obj_num=$(echo -ne "$OBJLIST" | grep -c -v "^$")
obj_numl=$(echo -ne "$OBJLISTL" | grep -c -v "^$")
if [[ "$obj_num" -eq "$obj_count" || "$obj_num" -eq "$LIST_LIMIT" ]]; then
echo "+ CONT_obj_list Passed"
else
echo "+ CONT_obj_list Failed"
fi
if [ "$obj_numl" -eq "$obj_count" ]; then
echo "+ CONT_obj_list_long Passed"
else
echo "+ CONT_obj_list_long Failed"
fi
tmpfile=`mktemp`
get_obj_list_long "$CONT" "$tmpfile"
obj_numf=$(grep -c -v "^$" $tmpfile)
if [ "$obj_numf" -eq "$obj_count" ]; then
echo "+ CONT_obj_list_long 2 file Passed"
else
echo "+ CONT_obj_list_long 2 file Failed"
fi
rm "$tmpfile"
UCONT=`mktemp -qud -p "" -t "XXXXXX"`
if [ -z "$UCONT" ]; then
UCONT=`dd if=/dev/random count=1 2>/dev/null | md5sum | cut -c -6`
fi
if create_cont "$UCONT" ; then
echo "+ CONT_create Passed"
else
echo "+ CONT_create Failed"
fi
tmpfile=`mktemp`
OBJ_TCONT="Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
echo "${OBJ_TCONT}"> $tmpfile
OBJ="lorem.txt"
if put_obj "$UCONT" "$OBJ" "$tmpfile"; then
echo "+ OBJ_put Passed"
else
echo "+ OBJ_put Failed"
fi
rm $tmpfile
tmpfile=`mktemp`
get_obj "${UCONT}" "${OBJ}" "${tmpfile}"
OBJ_CONT=`cat ${tmpfile}`
if [ "$OBJ_CONT" == "$OBJ_TCONT" ]; then
echo "+ OBJ_get Passed"
else
echo "+ OBJ_get Failed"
fi
rm $tmpfile
if copy_obj "${UCONT}/${OBJ}" "${UCONT}/${OBJ}.copy"; then
OBJ_CCONT=`curl -s -H "X-Storage-Token: $API_TOKEN" $API_URL/"${UCONT}"/"${OBJ}.copy"`
if [ "$OBJ_CONT" == "$OBJ_CCONT" ]; then
echo "+ OBJ_copy Passed"
else
echo "+ OBJ_copy Failed"
fi
else
echo "+ OBJ_copy Failed"
fi
if delete_obj "${UCONT}"/"${OBJ}"; then
echo "+ OBJ_delete Passed"
else
echo "+ OBJ_delete Failed"
fi
if delete_obj "${UCONT}"/"${OBJ}.copy"; then
echo "+ OBJ_delete.copy Passed"
else
echo "+ OBJ_delete.copy Failed"
fi
if delete_cont "$UCONT" ; then
echo "+ CONT_delete Passed"
else
echo "+ CONT_delete Failed"
fi