Skip to content

Commit 38881ca

Browse files
authored
Merge pull request #66 from redhat-performance/handle_all_tests
Updates to handle all the various file results formats that we have.
2 parents 204bbae + 3a50014 commit 38881ca

File tree

2 files changed

+142
-22
lines changed

2 files changed

+142
-22
lines changed

validate_line

Lines changed: 134 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,27 @@
1919

2020
exit_rtc=0
2121
base_results_file=""
22+
header=""
23+
compare_file=`mktemp /tmp/validate_compare.XXXXX`
24+
verification_base=`mktemp /tmp/validate_veri_base.XXXXX`
25+
verify_template=`mktemp /tmp/validate_veri_temp.XXXXX`
26+
test_results=`mktemp /tmp/validate_test_res.XXXXX`
2227

2328
usage()
2429
{
2530
echo Usage: $1
26-
echo " --fields <string>: Contains a list in the following format"
27-
echo " name:type,name:type"
28-
echo " Valid types are"
29-
echo " n: field is a numeric value"
30-
echo " s: field is a string of some sort"
31-
echo " sm: field is a string and must match exactly the name"
3231
echo " --header_lines <n>: How many lines of header do we we expect."
3332
echo " --results_file <path>: The results file generated by the test"
3433
echo " --base_results_file <path>: The path to the expected results that we are"
3534
echo " to compare to."
35+
echo File format
36+
echo " Format of file is expected to be csv with ':' as field separators"
37+
echo " Directives:"
38+
echo " %_header: Next line is the header"
39+
echo " %_passes: We have multiple passes of the test. First column in the csv"
40+
echo " file will be the pass number"
41+
echo " %_multiples: We have multiple lines of the data."
42+
echo " %_grouping: The data will appear in groups."
3643
exit $2
3744
}
3845

@@ -56,6 +63,9 @@ validate_lines()
5663
do
5764
regexp=`echo "$test_info" | cut -f 1`
5865
string=`echo "$test_info" | cut -f 2`
66+
if [[ $string == "" ]]; then
67+
continue
68+
fi
5969
#
6070
# Check to see if the string matches the regular expression.
6171
#
@@ -68,7 +78,6 @@ validate_lines()
6878
}
6979

7080
ARGUMENT_LIST=(
71-
"fields"
7281
"header_lines"
7382
"results_file"
7483
"base_results_file"
@@ -88,7 +97,6 @@ opts=$(getopt \
8897
eval set --$opts
8998

9099
results_file=""
91-
fields=""
92100
header_lines=0
93101

94102
while [[ $# -gt 0 ]]; do
@@ -97,10 +105,6 @@ while [[ $# -gt 0 ]]; do
97105
base_results_file=$2
98106
shift 2
99107
;;
100-
--fields)
101-
fields=`echo $2 | sed "s/ /_/g" | sed "s/,/ /g"`
102-
shift 2
103-
;;
104108
--header_lines)
105109
header_lines=$2
106110
shift 2
@@ -125,13 +129,73 @@ while [[ $# -gt 0 ]]; do
125129
esac
126130
done
127131

128-
meta_head=0
129132
meta_test=0
130133
header_line=""
131134
field_location=""
132135
separ=""
133136
field_index=1
134-
rm -f tmp_results compare_file
137+
138+
#
139+
# First create the verification base file.
140+
#
141+
iteration_test=0
142+
lines_per_pass=0
143+
multiple_entries=0
144+
multiple_groups=0
145+
multiple_search=""
146+
header_next=0
147+
grouping=0
148+
149+
while IFS= read -r verif_info
150+
do
151+
if [[ $header_next -eq 1 ]]; then
152+
echo $verif_info >> $verification_base
153+
header_next=0
154+
continue
155+
fi
156+
if [[ $verif_info == *"%_passes"* ]]; then
157+
iteration_test=1
158+
continue
159+
fi
160+
if [[ $verif_info == *"%_multiples"* ]]; then
161+
multiple_entries=1
162+
continue
163+
fi
164+
if [[ $verif_info == *"%_header"* ]]; then
165+
header_next=1
166+
continue
167+
fi
168+
if [[ $verif_info == *"%_grouping"* ]]; then
169+
grouping=1
170+
continue
171+
fi
172+
if [[ $multiple_entries -eq 1 ]] || [[ $grouping -eq 1 ]]; then
173+
echo $verif_info >> $verification_base
174+
continue
175+
fi
176+
if [[ $iteration_test -eq 1 ]]; then
177+
if [[ $verif_info != *"iteration"* ]]; then
178+
let "lines_per_pass=$lines_per_pass+1"
179+
#
180+
# Iteration number will be added later.
181+
#
182+
output=`echo $verif_info | cut -d: -f2-`
183+
echo $output >> $verification_base
184+
else
185+
header=$verif_info
186+
fi
187+
else
188+
echo $verif_info >> $verification_base
189+
fi
190+
done < "$base_results_file"
191+
192+
lines=0
193+
iterations=1
194+
header_processed=0
195+
196+
grep -q "Test general meta end" $results_file
197+
meta_head=$?
198+
echo meta_head $meta_head
135199
while IFS= read -r test_info
136200
do
137201
if [ $meta_head -eq 0 ]; then
@@ -143,6 +207,7 @@ do
143207
fi
144208
continue
145209
fi
210+
146211
if [[ $test_info == *"Test meta data start"* ]]; then
147212
#
148213
# Skip over the test meta data.
@@ -151,18 +216,68 @@ do
151216
continue
152217
fi
153218
if [[ $meta_test -eq 1 ]]; then
154-
if [[ $test_info == *"Test meta data end*" ]]; then
219+
if [[ $test_info == *"Test meta data end"* ]]; then
155220
meta_test=0
156221
fi
157222
continue
158223
fi
159-
echo $test_info >> tmp_results
224+
if [[ $iteration_test -eq 1 ]]; then
225+
base_results_file=$verify_template
226+
let "lines=$lines+1"
227+
if [[ $lines -eq $lines_per_pass ]]; then
228+
while IFS= read -r verf_info
229+
do
230+
if [[ $verf_info == *"iteration"* ]]; then
231+
continue
232+
else
233+
echo $iterations:$verf_info >> $verify_template
234+
fi
235+
done < $verification_base
236+
let "iterations=$iterations+1"
237+
lines=0
238+
fi
239+
fi
240+
if [[ $grouping -eq 1 ]] && [[ $groups_done -eq 0 ]]; then
241+
groups_done=1
242+
field=`echo $test_info | cut -d: -f 1`
243+
inst_cnt=`grep "^${field}:" $results_file | wc -l`
244+
let "inst_cnt=$inst_cnt+1"
245+
for i in `seq 0 $inst_cnt`;do
246+
cat $verification_base >> $verify_template
247+
done
248+
base_results_file=$verify_template
249+
fi
250+
if [[ $multiple_entries -eq 1 ]]; then
251+
next_line_header=0
252+
base_results_file=$verify_template
253+
line=0
254+
while IFS= read -r verf_info
255+
do
256+
if [[ $line -eq 0 ]]; then
257+
if [[ $header_processed -eq 0 ]]; then
258+
echo "$verf_info" >> $verify_template
259+
header_processed=1
260+
break
261+
fi
262+
let "line=$line+1"
263+
else
264+
echo "$verf_info" >> $verify_template
265+
fi
266+
done < $verification_base
267+
header_processed=1
268+
fi
269+
echo $test_info >> $test_results
160270
done < "$results_file"
161271
#
162272
# Create the compare file by pasting the base results (reg exp) against the tmp_results
163273
# file which is minus all the meta documentation.
164274
#
165-
paste $base_results_file tmp_results > compare_file
166-
validate_lines compare_file
167-
rm compare_file
275+
paste $base_results_file $test_results > $compare_file
276+
validate_lines $compare_file
277+
rm -f $compare_file $verification_base $verify_template $test_results
278+
if [[ $exit_rtc -ne 0 ]]; then
279+
echo Failed
280+
else
281+
echo Ran
282+
fi
168283
exit $exit_rtc

verification

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ verification_run()
3636
verify_res_before=`mktemp ${tmp_dir}/wrapper_verify.XXXXX`
3737
verify_res_after=`mktemp ${tmp_dir}wrapper_verify.XXXXX`
3838
test_descript=$verify_file
39+
if [[ ! -f $test_descript ]]; then
40+
echo $test_descript does not exist.
41+
exit 1
42+
fi
3943
required_systems=`grep "^Required_Systems:" $test_descript | cut -d: -f2`
4044
fields=`grep ^fields $test_descript | cut -d: -f2-`
4145
header_lines=`grep ^header_lines $test_descript | cut -d: -f2`
@@ -63,10 +67,11 @@ verification_run()
6367
rdir=`diff $verify_res_after $verify_res_before | grep -v tar | grep '<' | sed "s/< //g"`
6468
res_dir=${home_parent}/${run_user}/export_results/$rdir
6569
#
66-
# Locate the test csv file
70+
# Locate the test csv file. First grep for results_{$test_name} then grep for the csv, to
71+
# keep the tests that have sub tests (hammer) happy.
6772
#
68-
new_res_file=`find $res_dir -print | grep results_${test_name}.csv`
69-
$TOOLS_BIN/validate_line --results_file $new_res_file --fields "$fields" --base_results_file $base_res_file
73+
new_res_file=`find $res_dir -print | grep results_${test_name} | grep csv`
74+
$TOOLS_BIN/validate_line --results_file $new_res_file --base_results_file $base_res_file
7075
if [[ $? -ne 0 ]]; then
7176
exit_rtc=1
7277
fi

0 commit comments

Comments
 (0)