Skip to content

Commit 8403c4e

Browse files
authored
Fix workreport error info (crustio#230)
1 parent 8f5cebd commit 8403c4e

4 files changed

Lines changed: 29 additions & 24 deletions

File tree

src/app/ocalls/OCalls.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -732,7 +732,7 @@ void ocall_store_workreport(const char *data, size_t data_size, bool cover /*=tr
732732
}
733733
else
734734
{
735-
std::string str = get_g_enclave_workload();
735+
std::string str = get_g_enclave_workreport();
736736
str.append(data, data_size);
737737
set_g_enclave_workreport(str);
738738
}

test/integration/performance/run_test.sh

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,10 @@ function _seal()
55
file_num_g=0
66
local total_num=$(get_config ".performance|.file_num")
77
while true; do
8-
sleep 3
98
if [ $file_num_g -lt $total_num ]; then
10-
local num=1000
11-
while [ $num -ge 0 ] && [ $(cat $sealsyncfile) -lt 10 ]; do
12-
(
13-
flock -w 30 202
14-
if [ $(cat $sealsyncfile) -lt 10 ]; then
15-
_seal_r &
16-
local cur_num=$(cat $sealsyncfile)
17-
((cur_num++))
18-
echo $cur_num > $sealsyncfile
19-
fi
20-
) 202>$seallockfile
9+
local num=800
10+
while [ $num -ge 0 ]; do
11+
_seal_r
2112
((num--))
2213
done
2314
fi
@@ -32,16 +23,17 @@ function _seal_r()
3223
rm -rf $file_path &>/dev/null
3324
return 1
3425
fi
35-
seal_file $file_path $testfiledir &>$TMPFILE
26+
local tmpfile=${TMPFILE}${RANDOM}$(date +%N)
27+
seal_file $file_path $testfiledir &>$tmpfile
3628
if [ $? -eq 0 ]; then
37-
local ret_body=$(cat $TMPFILE)
29+
local ret_body=$(cat $tmpfile)
3830
local sealed_hash=$(echo $ret_body | jq '.path' | sed 's/"//g' | xargs -I {} basename {} 2>/dev/null)
3931
#verbose INFO "sealing hash:$sealed_hash..." h
4032
if [ x"$sealed_hash" != x"" ] && [ ${#sealed_hash} -eq 64 ]; then
4133
#verbose INFO "success" t
4234
echo 0 > $sealtmpdir/$sealed_hash
43-
((file_num_g++))
4435
res_inc "seal" "success" $sealresfile
36+
((file_num_g++))
4537
else
4638
#verbose ERROR "failed" t
4739
res_inc "seal" "failed" $sealresfile
@@ -50,6 +42,7 @@ function _seal_r()
5042
res_inc "seal" "failed" $sealresfile
5143
fi
5244
rm -rf $file_path
45+
rm -rf $tmpfile
5346
}
5447

5548
function _unseal()
@@ -124,6 +117,7 @@ function _validate
124117
validate_file &>/dev/null
125118
validate_srd &>/dev/null
126119
store_metadata &>/dev/null
120+
res_inc "confirm" "success" $validateresfile
127121
done
128122
}
129123

@@ -195,14 +189,17 @@ function _delete_r()
195189

196190
function _workreport()
197191
{
192+
local lfile=workreport
193+
local tag=0
198194
while true; do
199195
sleep $((20 + $RANDOM % 10))
200-
report_work &>/dev/null
196+
report_work &>$instdir/${lfile}.$tag
201197
if [ $? -eq 0 ]; then
202198
res_inc "report" "success" $reportresfile
203199
else
204200
res_inc "report" "failed" $reportresfile
205201
fi
202+
((tag=(tag+1)%2))
206203
done
207204
}
208205

@@ -215,6 +212,7 @@ cat << EOF >$TMPFILE
215212
"confirm":{"success":$(get_success $confirmresfile),"failed":$(get_failed $confirmresfile)},
216213
"delete":{"success":$(get_success $deleteresfile),"failed":$(get_failed $deleteresfile)},
217214
"srd":{"success":$(get_success $srdresfile),"failed":$(get_failed $srdresfile)},
215+
"validate":{"success":$(get_success $validateresfile),"failed":$(get_failed $validateresfile)},
218216
"workreport":{"success":$(get_success $reportresfile),"failed":$(get_failed $reportresfile)}
219217
}
220218
EOF
@@ -300,12 +298,17 @@ unsealresfile=$ptmpdir/unseal_info
300298
reportresfile=$ptmpdir/report_info
301299
deleteresfile=$ptmpdir/delete_info
302300
confirmresfile=$ptmpdir/confirm_info
301+
validateresfile=$ptmpdir/validate_info
303302
srdresfile=$ptmpdir/srd_info
304303
deletefilethres=3
305304
deletetime=100
306305
deletelockfile=$ptmpdir/deletelockfile
306+
<<<<<<< HEAD
307307
seallockfile=$ptmpdir/seallockfile
308308
sealsyncfile=$ptmpdir/sealsyncfile
309+
=======
310+
sealsyncdir=$ptmpdir/sealsyncdir
311+
>>>>>>> dev
309312

310313
# Control sig num
311314
sigShowInfo=28
@@ -319,6 +322,7 @@ trap 'show_info' $sigShowInfo
319322
mkdir -p $sealtmpdir
320323
mkdir -p $confirmtmpdir
321324
mkdir -p $ptmpdir
325+
mkdir -p $sealsyncdir
322326

323327
declare -A name2pid_m
324328

test/integration/scripts/start_test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ fi
115115
cd $testdir
116116
rm -rf tee_base_path
117117
rm -rf files
118+
mkdir files
118119
verbose INFO "starting crust-sworker..." h
119120
./bin/crust-sworker -c etc/Config.json --offline --debug &>$sworkerlog &
120121
pid=$!

test/integration/scripts/utils.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ function crust_split()
55
local storepath=$2
66
if [ ! -s "$filepath" ]; then
77
verbose ERROR "File path is invalid!"
8-
exit 1
8+
return 1
99
fi
1010
if [ ! -e "$storepath" ]; then
1111
verbose ERROR "Store path is not existed!"
12-
exit 1
12+
return 1
1313
fi
1414
# Generated dir name
1515
local detdir="dettmp.$(date +%N)"
@@ -56,7 +56,7 @@ function crust_split()
5656
done
5757
totalhash=$(echo $totalhash | xxd -r -p | sha256sum | awk '{print $1}')
5858
mt_json="$mt_json],\"hash\":\"${totalhash}\"}"
59-
local newdetdir="$(dirname $detdir)/$totalhash"
59+
local newdetdir="$(dirname $detdir)/${totalhash}.${RANDOM}$(date +%N)"
6060
echo "$mt_json $newdetdir"
6161
cd - &>/dev/null
6262
rm $filepath
@@ -81,15 +81,15 @@ function seal_file()
8181
{
8282
local data_path=$1
8383
local store_path=$2
84-
store_path=${store_path}.$RANDOM
85-
local tmp_file=tmp_file.$RANDOM
84+
local tmp_file=tmp_file.${RANDOM}$(date +%N)
8685

8786
### Split file
88-
local mt_json=($(crust_split $data_path $store_path 2>$tmp_file))
89-
if [ -s "$tmp_file" ]; then
87+
crust_split $data_path $store_path &>$tmp_file
88+
if [ $? -ne 0 ]; then
9089
rm $tmp_file
9190
return 1
9291
fi
92+
local mt_json=($(cat $tmp_file))
9393

9494
### Seal file block
9595
seal ${mt_json[0]} ${mt_json[1]} >$tmp_file

0 commit comments

Comments
 (0)