Fix: exec_pair trace; SPT bugs; print non-0 exit

- Fix crash when hitting logger.warning in exec_pair
- Fix SPT bugs:
  - iperf sometimes not installed for HW to HW test
  - iperf_server_stop broken in several ways
  - glance download script has wrong filename
  - SPT_parser traces on empty glance output
- Print to stdout on non-0 exit to tell about unclean exit to user
- Reorder SPT copy-paste line once more

Change-Id: I7a37b5fce5bc620cc9e2db8d232180c215cd3782
(cherry picked from commit 0f7a39be83d90a802315e0e1349ec8f8bbe62045)
(cherry picked from commit 46ae4f44e7e7416f31f75d4b479671bb83639be8)
This commit is contained in:
Dmitry Sutyagin 2017-02-24 14:41:01 -08:00 committed by Aleksandr Dobdin
parent ab715489a2
commit 73bdcde8cd
9 changed files with 64 additions and 55 deletions

View File

@ -4,7 +4,7 @@
%global pypi_name timmy
Name: python-%{pypi_name}
Version: 1.26.7
Version: 1.26.8
Release: 1%{?dist}~mos0
Summary: Log collector tool for OpenStack Fuel
@ -107,6 +107,9 @@ popd
%changelog
* Fri Feb 24 2017 Dmitry Sutyagin <dsutyagin@mirantis.com> - 1.26.8
- Fix: exec_pair trace; SPT bugs; print non-0 exit
* Thu Feb 23 2017 Dmitry Sutyagin <dsutyagin@mirantis.com> - 1.26.7
- Fix: UnicodeDecodeError, broken spec; add SPT
- Update documentation to match timmy 1.26.6 code

View File

@ -18,7 +18,7 @@
from timmy.analyze import analyze, analyze_print_results
from timmy.env import project_name, version
from timmy.nodes import Node
from timmy.tools import signal_wrapper
from timmy.tools import signal_wrapper, print_and_exit
import argparse
import logging
import logging.handlers
@ -340,7 +340,7 @@ def main(argv=None):
if not enough_space:
logger.error('Not enough space for logs in "%s", exiting.' %
nm.conf['archive_dir'])
sys.exit(100)
print_and_exit(100)
if not conf['offline'] and not args.only_logs:
if nm.has(Node.pkey):
pretty_run(args.quiet, 'Uploading files', nm.put_files)
@ -395,4 +395,4 @@ def main(argv=None):
if __name__ == '__main__':
sys.exit(main(sys.argv))
main(sys.argv)

View File

@ -16,7 +16,7 @@
# under the License.
project_name = 'timmy'
version = '1.26.7'
version = '1.26.8'
if __name__ == '__main__':
import sys

View File

@ -24,12 +24,11 @@ from datetime import datetime, date, timedelta
from timmy import conf
from timmy.env import project_name, version
from timmy import tools
from tools import w_list, run_with_lock
from tools import w_list, run_with_lock, print_and_exit
import logging
import os
import re
import shutil
import sys
class Node(object):
@ -65,7 +64,7 @@ class Node(object):
self.status = status
if ip is None:
self.logger.critical('Node: ip address must be defined')
sys.exit(111)
print_and_exit(111)
self.ip = ip
self.network_data = network_data
self.release = None
@ -337,7 +336,9 @@ class Node(object):
nd = sn.network_data
net_dict = dict((v['name'], v) for v in nd)
if i['network'] not in net_dict:
self.logger.warning(nonet_msg % (self.repr, sn.repr))
self.logger.warning(nonet_msg % (self.repr,
i['network'],
sn.repr))
return self.scripts_all_pairs
if 'ip' not in net_dict[i['network']]:
self.logger.warning(noip_msg % (self.repr, sn.repr,
@ -587,7 +588,7 @@ class NodeManager(object):
if (not os.path.exists(self.rqdir)):
self.logger.critical(('NodeManager: directory %s does not'
' exist') % self.rqdir)
sys.exit(101)
print_and_exit(101)
if self.conf['rqfile']:
self.import_rq()
self.nodes = {}
@ -980,9 +981,5 @@ class NodeManager(object):
return dict([(ip, n) for ip, n in self.nodes.items() if not n.skipped])
def main(argv=None):
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv))
pass

View File

@ -49,6 +49,14 @@ while 1:
'''
def print_and_exit(code):
msg = ('An error occured, exiting with code %s. See log or documentation'
' for details.')
logger.error(msg % code)
print(msg % code)
sys.exit(code)
def signal_wrapper(f):
def wrapper(*args, **kwargs):
setup_handle_sig()
@ -64,7 +72,7 @@ def signal_wrapper(f):
if not k.startswith('__') and k != 'message':
v = getattr(e, k)
logger.debug('Error details: %s = %s' % (k, v))
sys.exit(113)
print_and_exit(113)
return wrapper
@ -86,7 +94,7 @@ def main_handle_sig(sig, frame):
os.kill(int(pid), sig)
except OSError:
pass
sys.exit(sig)
print_and_exit(sig)
def sub_handle_sig(sig, frame):
@ -97,7 +105,7 @@ def sub_handle_sig(sig, frame):
os.killpg(os.getpid(), sig)
except OSError:
pass
sys.exit(sig)
print_and_exit(sig)
def setup_handle_sig(subprocess=False):
@ -196,7 +204,7 @@ def run_batch(item_list, maxthreads, dict_result=False):
for line in exc_text.splitlines():
logger.critical('____%s' % line)
cleanup(l)
sys.exit(109)
print_and_exit(109)
remove_procs.append(key)
for key in remove_procs:
logger.debug(rem_msg % key)
@ -243,10 +251,10 @@ def load_json_file(filename):
except IOError as e:
logger.critical("I/O error(%s): file: %s; msg: %s" %
(e.errno, e.filename, e.strerror))
sys.exit(107)
print_and_exit(107)
except ValueError:
logger.critical("Could not convert data", exc_info=True)
sys.exit(108)
print_and_exit(108)
def load_yaml_file(filename):
@ -259,14 +267,14 @@ def load_yaml_file(filename):
except IOError as e:
logger.critical("I/O error(%s): file: %s; msg: %s" %
(e.errno, e.filename, e.strerror))
sys.exit(102)
print_and_exit(102)
except ValueError:
logger.critical("Could not convert data", exc_info=True)
sys.exit(103)
print_and_exit(103)
except yaml.parser.ParserError as e:
logger.critical("Could not parse %s:\n%s" %
(filename, str(e)))
sys.exit(105)
print_and_exit(104)
def mdir(directory):
@ -279,7 +287,7 @@ def mdir(directory):
os.makedirs(directory)
except OSError:
logger.critical("Can't create a directory: %s" % directory)
sys.exit(110)
print_and_exit(110)
def launch_cmd(cmd, timeout, input=None, ok_codes=None):
@ -439,4 +447,4 @@ def all_pairs(items, one_way=False, max_pairs=0):
if __name__ == '__main__':
sys.exit(0)
pass

View File

@ -63,15 +63,15 @@ elif word == "kB/s":
if [ -n "$res_glance_create" ]
then
res_gc=`head -n 4 $res_glance_create | grep '^[0-9.]\+$' | python -c 'import sys; print("%.2f" % (4000/float(sys.stdin.read(),)))'`
res_gc=${res_gc}'MB/s'
res_gc=`head -n 4 $res_glance_create | grep '^[0-9.]\+$' | \
python -c 'import sys; print("%.2fMB/s" % (4000/float(sys.stdin.read(),)))' 2> /dev/null`
fi
print_result "Glance upload" $res_gc
if [ -n "$res_glance_download" ]
then
res_gd=`head -n 1 $res_glance_download | grep '^[0-9.]\+$' | python -c 'import sys; print("%.2f" % (4000/float(sys.stdin.read(),)))'`
res_gd=${res_gd}'MB/s'
res_gd=`head -n 1 $res_glance_download | grep '^[0-9.]\+$' | \
python -c 'import sys; print("%.2fMB/s" % (4000/float(sys.stdin.read(),)))' 2> /dev/null`
fi
print_result "Glance download" $res_gd
@ -85,6 +85,8 @@ print_result "Block Storage Write 4k" $res_4k
print_result "Block Storage Write 1M" $res_1m
print_result "Block Storage Write 1G" $res_1g
[ -n "$res_iperf_node" ] && nnum="$(wc -l <<< "$res_iperf_node")" && print_result "Number of nodes (during iperf HW to HW tests)" $nnum
if [ -n "$res_iperf_host" ]
then
res_t1=""
@ -102,22 +104,6 @@ res_t10=`echo "$res_t10" | python -c 'import sys; print(float(sys.stdin.read())/
print_result "HW to HW (best)" $res_t1
print_result "HW to HW (best) - 10 Threads" $res_t10
if [ -n "$res_iperf_vm" ]
then
res1=`head -n 8 $res_iperf_vm | tail -n 1 | grep '^\[.*sec' | rev | awk '{print $1$2}' | rev | sed 's/ //g'`
res2=`head -n 17 $res_iperf_vm | tail -n 1 | grep '^\[.*sec' | rev | awk '{print $1$2}' | rev | sed 's/ //g'`
res3=`head -n 44 $res_iperf_vm | tail -n 1 | grep '^\[SUM.*sec' | rev | awk '{print $1$2}' | rev | sed 's/ //g'`
res4=`head -n 52 $res_iperf_vm | tail -n 1 | grep '^\[.*sec' | rev | awk '{print $1$2}' | rev | sed 's/ //g'`
res5=`head -n 61 $res_iperf_vm | tail -n 1 | grep '^\[.*sec' | rev | awk '{print $1$2}' | rev | sed 's/ //g'`
fi
print_result "VM to VM - VMs on same node - via Private IP - 1 thread" $res1
print_result "VM to VM - VMs on different HW nodes - via Private IP - 1 thread" $res2
print_result "VM to VM - VMs on different HW nodes - via Private IP - MILTI 10 thread" $res3
print_result "VM to VM - via Floating IP and VMs are on different nodes - 1 thread" $res4
print_result "VM to VM - diff nodes, VMs connected to separate networks connected by vRouter - via Private IP - 1 thread" $res5
[ -n "$res_iperf_node" ] && nnum="$(wc -l <<< "$res_iperf_node")" && print_result "Number of nodes (during iperf HW to HW tests)" $nnum
if [ -n "$res_iperf_host" ]
then
res_mt1=""
@ -135,20 +121,35 @@ res_mt10=`echo "$res_mt10" | python -c 'import sys; print(float(sys.stdin.read()
print_result "HW to HW (worst)" $res_mt1
print_result "HW to HW (worst) - 10 Threads" $res_mt10
if [ -n "$res_iperf_vm" ]
then
res1=`head -n 8 $res_iperf_vm | tail -n 1 | grep '^\[.*sec' | rev | awk '{print $1$2}' | rev | sed 's/ //g'`
res2=`head -n 17 $res_iperf_vm | tail -n 1 | grep '^\[.*sec' | rev | awk '{print $1$2}' | rev | sed 's/ //g'`
res3=`head -n 44 $res_iperf_vm | tail -n 1 | grep '^\[SUM.*sec' | rev | awk '{print $1$2}' | rev | sed 's/ //g'`
res4=`head -n 52 $res_iperf_vm | tail -n 1 | grep '^\[.*sec' | rev | awk '{print $1$2}' | rev | sed 's/ //g'`
res5=`head -n 61 $res_iperf_vm | tail -n 1 | grep '^\[.*sec' | rev | awk '{print $1$2}' | rev | sed 's/ //g'`
fi
print_result "VM to VM - VMs on same node - via Private IP - 1 thread" $res1
print_result "VM to VM - VMs on different HW nodes - via Private IP - 1 thread" $res2
print_result "VM to VM - VMs on different HW nodes - via Private IP - MILTI 10 thread" $res3
print_result "VM to VM - via Floating IP and VMs are on different nodes - 1 thread" $res4
print_result "VM to VM - diff nodes, VMs connected to separate networks connected by vRouter - via Private IP - 1 thread" $res5
echo "--------------------------"
a `d $res_gc`
a `d $res_gd`
a `d $res_4k`
a `d $res_1m`
a `d $res_1g`
a $res_t1 # HW to HW
a $res_t10 # HW to HW
a $nnum
a $res_t1
a $res_t10
a $res_mt1
a $res_mt10
a $(c `b $res1`)
a $(c `b $res2`)
a $(c `b $res3`)
a $(c `b $res4`)
a $(c `b $res5`)
a $nnum
a $res_mt1 # HW to HW max concurrency
a $res_mt10 # HW to HW max concurrency
echo

View File

@ -6,7 +6,7 @@ SPT_IPERF_PORT=${SPT_IPERF_PORT:-"65432"}
which iperf &>/dev/null
if [ "$?" -ne "0" ]
then
result="$(DEBIAN_FRONTEND=noninteractive apt-get -y install iperf 2>&1)"
result="$(DEBIAN_FRONTEND=noninteractive apt-get -y --force-yes install iperf 2>&1)"
[ "$?" -ne "0" ] && echo -e "failed to install iperf:\n$result" && exit 1
fi

View File

@ -2,11 +2,11 @@
SPT_IPERF_PORT=${SPT_IPERF_PORT:-"65432"}
killall iperf
while ["$(iptables -L --line-numbers | grep -c 'spt-temporary-rule')" -ge 0 ]
killall -9 iperf
while [ "$(iptables -L --line-numbers | grep -c 'spt-temporary-rule')" -gt 0 ]
do
rulenum=`iptables -L --line-numbers | grep 'spt-temporary-rule' | head -n 1 | awk '{print $1}'`
[ -n "$sulenum" ] && [ "$rulenum" -ge 0 ] && iptables -D INPUT $rulenum
[ -n "$rulenum" ] && [ "$rulenum" -ge 0 ] && iptables -D INPUT $rulenum
done
if [ -n $SERVER_OUTPUT ]
then