-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathobject_testscript.sh
More file actions
executable file
·123 lines (102 loc) · 4.08 KB
/
object_testscript.sh
File metadata and controls
executable file
·123 lines (102 loc) · 4.08 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
#!/bin/bash
estatus=0
cmdPath='./gcscmd'
testCases() {
echo "_/_/_/_/_/_/_/_/_/_/_/_/_/ 对象操作 开始 _/_/_/_/_/_/_/_/_/_/_/_/_/"
echo '对象操作 => 查看对象 => 桶内所有文件查询-有此桶 => gcscmd ls cs://bbb start'
echo '数据准备'
echo '1、创建新桶'
bucketName="bucket-object-"$(date "+%Y%m%d%H%M%S")"-"$RANDOM
$cmdPath mb cs://$bucketName
execCmd '对象操作' '查看对象' '桶内所有文件查询-有此桶' 'gcscmd ls cs://'$bucketName 'ls cs://'$bucketName ''
echo '2、数据清理'
$cmdPath rb cs://$bucketName --force
echo '对象操作 => 查看对象 => 桶内所有文件查询-有此桶 => gcscmd ls cs://bbb end'
echo ''
echo '对象操作 => 查看对象 => 桶内所有文件查询-无此桶 => gcscmd ls cs://bbb start'
echo '此操作应给出错误提示'
execCmdFail '对象操作' '查看对象' '桶内所有文件查询-无此桶' 'gcscmd ls cs://'$bucketName 'ls cs://'$bucketName ''
echo '对象操作 => 查看对象 => 桶内所有文件查询-无此桶 => gcscmd ls cs://bbb end'
echo ''
echo '对象操作 => 查看对象 => 桶内对应 cid 查询-cid正确 => gcscmd ls cs://bbb --cid QmWgnG7pPjG31w328hZyALQ2BgW5aQrZyKpT47jVpn8CNo start'
echo '数据准备'
echo '1、创建新桶'
bucketName="bucket-object-"$(date "+%Y%m%d%H%M%S")"-"$RANDOM
$cmdPath mb cs://$bucketName
echo '2、添加对象'
testDataFileName="testdata_"$(date "+%Y%m%d%H%M%S")"-"$RANDOM".dat"
#echo $testDataFileName
dd if=/dev/urandom of=$testDataFileName bs=1024 count=1024
resp=$($cmdPath put $testDataFileName cs://$bucketName)
echo '3、获取CID'
cid=$(echo "$resp" | awk '/CID:/{print $2}')
execCmd '对象操作' '查看对象' '桶内对应 cid 查询-cid正确' 'gcscmd ls cs://'$bucketName' --cid '$cid 'ls cs://'$bucketName' --cid '$cid ''
echo '4、数据清理'
rm -rf $testDataFileName
echo '对象操作 => 查看对象 => 桶内对应 cid 查询-cid正确 => gcscmd ls cs://bbb --cid QmWgnG7pPjG31w328hZyALQ2BgW5aQrZyKpT47jVpn8CNo end'
echo ''
echo '对象操作 => 查看对象 => 桶内对象名查询-对象名正确 => gcscmd ls cs://bbb --name Tarkov.mp4 start'
echo '设置对象名称'
objectName=$testDataFileName
execCmd '对象操作' '查看对象' '桶内对象名查询-对象名正确' 'gcscmd ls cs://'$bucketName' --name '$objectName 'ls cs://'$bucketName' --name '$objectName ''
echo '对象操作 => 查看对象 => 桶内对象名查询-对象名正确 => gcscmd ls cs://bbb --name Tarkov.mp4 end'
echo ''
echo '对象操作测试数据清理'
$cmdPath rb cs://$bucketName --force
# rm -rf $testDataFileName
echo "_/_/_/_/_/_/_/_/_/_/_/_/_/ 对象操作 结束 _/_/_/_/_/_/_/_/_/_/_/_/_/"
echo ''
}
execCmd() {
testModule=$1
testFunction=$2
testCase=$3
testDescription=$4
testCmd=$5
testExpectation=$6
testFail=$7
# echo $testModule"=>"$testFunction"=>"$testCase"=>"$testDescription
cmdStr=$cmdPath' '$testCmd
echo 'executing '$cmdStr
eval $cmdStr
exitCode=$?
echo ''
if [ $exitCode -eq 0 ]; then
echo -e "\033[32mSuccess: $cmdStr test pass. \033[0m"
else
echo -e "\033[31mFailure: $cmdStr test fail. \033[0m"
estatus=$(($etatus + 1))
fi
echo "exitcode:"$exitCode
echo ""
}
execCmdFail() {
testModule=$1
testFunction=$2
testCase=$3
testDescription=$4
testCmd=$5
testExpectation=$6
testFail=$7
# echo $testModule"=>"$testFunction"=>"$testCase"=>"$testDescription
cmdStr=$cmdPath' '$testCmd
echo 'executing '$cmdStr
eval $cmdStr
exitCode=$?
echo ''
if [ $exitCode -eq 0 ]; then
echo -e "\033[31mFailure: $cmdStr test should be prompt error message. \033[0m"
estatus=$(($etatus + 1))
else
echo -e "\033[32mSuccess: $cmdStr test pass, return error message and exit code is not equal zero. \033[0m"
# estatus=$?
fi
echo "exitcode:"$exitCode
echo ""
}
echo "===========================Chainstorage cli Test start=========================="
echo ''
testCases
echo "===========================Chainstorage cli Test end============================="
echo "Test status code:"$estatus
exit $estatus