Commit bef98662 authored by Łukasz Nowak's avatar Łukasz Nowak

Provide more and often results

Instead of script being silent all the time provide results often, on
each try for runTestSuite.py.
Additionally print out full results of execution to the controlling
testnode, for better analysis.
in-vm-test script is adapted to follow such requirement.
parent 9683a6f8
...@@ -55,6 +55,15 @@ if [[ ! -s "$DEPLOYMENT_SCRIPT" ]] ; then ...@@ -55,6 +55,15 @@ if [[ ! -s "$DEPLOYMENT_SCRIPT" ]] ; then
echo "exit 1" > $DEPLOYMENT_SCRIPT echo "exit 1" > $DEPLOYMENT_SCRIPT
fi fi
function upload ()
{
try=$1
LOG_FILE=$2
t=`date '+%Y%m%d%H%S'`
mv $LOG_FILE ${LOG_FILE}.$t
curl -q -X POST --data-urlencode "path=test-script-result/log-file.log.$t" --data-urlencode "content@${LOG_FILE}.$t" http://10.0.2.100/
}
try=1 try=1
while true; do while true; do
echo "$0: Try $try. Running '/bin/bash $DEPLOYMENT_SCRIPT'" >> $LOG_FILE 2>&1 echo "$0: Try $try. Running '/bin/bash $DEPLOYMENT_SCRIPT'" >> $LOG_FILE 2>&1
...@@ -62,20 +71,19 @@ while true; do ...@@ -62,20 +71,19 @@ while true; do
result=$? result=$?
if [ $result == 0 ] ; then if [ $result == 0 ] ; then
echo "$0: Try $try. Script executed successfully." >> $LOG_FILE 2>&1 echo "$0: Try $try. Script executed successfully." >> $LOG_FILE 2>&1
upload $try $LOG_FILE
break break
fi fi
if (( try > TRIES )) ; then if (( try > TRIES )) ; then
echo "$0: Try $try. Amount of tries $TRIES exceeded, giving up." >> $LOG_FILE 2>&1 echo "$0: Try $try. Amount of tries $TRIES exceeded, giving up." >> $LOG_FILE 2>&1
upload $try $LOG_FILE
break break
fi fi
# wait WAITTIME before checking the state # wait WAITTIME before checking the state
echo "$0: Try $try. Sleeping $WAITTIME before retry." >> $LOG_FILE 2>&1 echo "$0: Try $try. Sleeping $WAITTIME before retry." >> $LOG_FILE 2>&1
upload $try $LOG_FILE
sleep $WAITTIME sleep $WAITTIME
((try++)) ((try++))
done done
echo "$0: Try $try. Uploading log and exiting with $result." >> $LOG_FILE 2>&1
t=`date '+%Y%m%d%H%S'`
mv $LOG_FILE ${LOG_FILE}.$t
curl -q -X POST --data-urlencode "path=test-script-result/log-file.log.$t" --data-urlencode "content@${LOG_FILE}.$t" http://10.0.2.100/
exit $result exit $result
...@@ -81,9 +81,10 @@ def main(): ...@@ -81,9 +81,10 @@ def main():
sleep_time = 10 sleep_time = 10
try_amount = (3600 * 10) / sleep_time try_amount = (3600 * 10) / sleep_time
try_num = 1 try_num = 1
result_path = None
start = time() start = time()
result_found = False
while 1: while 1:
finished = False
try_info = 'Try %s/%s.' % (try_num, try_amount) try_info = 'Try %s/%s.' % (try_num, try_amount)
print(try_info + ' Waiting for data.') print(try_info + ' Waiting for data.')
result_list = glob.glob( result_list = glob.glob(
...@@ -98,39 +99,16 @@ def main(): ...@@ -98,39 +99,16 @@ def main():
if len(result_list) > 0: if len(result_list) > 0:
print(try_info + ' Data found.') print(try_info + ' Data found.')
result_path = result_list[0] result_path = result_list[0]
break for result_file in (os.path.join(dirname, filename)
if try_num > try_amount:
print(try_info + ' Time exceeded, data not found.')
break
try_num += 1
sleep(10)
if result_path is None:
status_dict['stdout'] = 'Test timed out and no result found.'
status_dict.update(
test_count=0,
skip_count=0,
failure_count=0,
error_count=0
)
else:
oldest_result = min(
(os.path.join(dirname, filename)
for dirname, dirnames, filenames in os.walk(result_path) for dirname, dirnames, filenames in os.walk(result_path)
for filename in filenames for filename in filenames
), ):
key=lambda fn: os.stat(fn).st_mtime) result_found = True
if oldest_result is None: result_file = os.path.abspath(result_file)
status_dict['stdout'] = 'Test finished but no result found.' status_dict['command'] = result_file
status_dict.update( result = open(result_file).read()
test_count=1, print(try_info + 'Analysis of result %r:' % (result_file,))
skip_count=0, print(try_info + result)
failure_count=0,
error_count=1
)
else:
oldest_result = os.path.abspath(oldest_result)
status_dict['command'] = oldest_result
result = open(oldest_result).read()
if 'FATAL: all hosts have already failed -- aborting' in result: if 'FATAL: all hosts have already failed -- aborting' in result:
# failed # failed
status_dict.update( status_dict.update(
...@@ -139,6 +117,7 @@ def main(): ...@@ -139,6 +117,7 @@ def main():
failure_count=1, failure_count=1,
error_count=0 error_count=0
) )
finished = False
elif "\"msg\": \"[u'Build successful, connect to:', u'" in result: elif "\"msg\": \"[u'Build successful, connect to:', u'" in result:
# success # success
status_dict.update( status_dict.update(
...@@ -147,6 +126,8 @@ def main(): ...@@ -147,6 +126,8 @@ def main():
failure_count=0, failure_count=0,
error_count=0 error_count=0
) )
finished = True
break
else: else:
# unknown # unknown
status_dict.update( status_dict.update(
...@@ -157,9 +138,24 @@ def main(): ...@@ -157,9 +138,24 @@ def main():
) )
status_dict['stdout'] = \ status_dict['stdout'] = \
'Cannot find success or failure result in the output' 'Cannot find success or failure result in the output'
finished = False
# send only part of the result # send only part of the result
status_dict['stderr'] = result[-8192:] status_dict['stderr'] = result[-8192:]
if finished:
break
if try_num > try_amount:
print(try_info + ' Time exceeded, data not found.')
break
try_num += 1
sleep(10)
if not result_found:
status_dict['stdout'] = 'Test timed out and no result found.'
status_dict.update(
test_count=0,
skip_count=0,
failure_count=0,
error_count=0
)
end = time() end = time()
test_result_line.stop( test_result_line.stop(
......
...@@ -42,7 +42,7 @@ recipe = slapos.recipe.download ...@@ -42,7 +42,7 @@ recipe = slapos.recipe.download
ignore-existing = true ignore-existing = true
filename = in-vm-test filename = in-vm-test
url = ${:_profile_base_location_}/${:filename} url = ${:_profile_base_location_}/${:filename}
md5sum = 13f10035a3008cffb55d23a7dd069861 md5sum = e96e1338afa99381cef55093e1f5684d
mode = 0644 mode = 0644
download-only = true download-only = true
on-update = true on-update = true
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment