summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Klozik <martinx.klozik@intel.com>2015-10-12 07:15:54 +0100
committerMaryam Tahhan <maryam.tahhan@intel.com>2015-10-21 14:02:11 +0000
commitc2971871dd1380b88d58f29211a3e8478aca477a (patch)
tree043893808caaa962f77757b4d495a7b4ec9b9b3b
parent3572d56f5733592db30f0df2273fe93e731cba2d (diff)
Add Pylint to VSPERF commit gate
Initial pylint config file has been created to follow current code structure and design. A few issues have been fixed, so currently 56 of 67 files have rating 10/10. There are still issues to be fixed, mainly TODOs/FIXMEs and missing impelentation of abstract class members. Change-Id: Icf5b12c2150258f8ac657f8d50b47a697d1660a0 JIRA: VSPERF-91 Signed-off-by: Martin Klozik <martinx.klozik@intel.com> Reviewed-by: Maryam Tahhan <maryam.tahhan@intel.com> Reviewed-by: Fatih Degirmenci <fatih.degirmenci@ericsson.com> Reviewed-by: Gene Snider <eugene.snider@huawei.com> Reviewed-by: Al Morton <acmorton@att.com> Reviewed-by: Tv Rao <tv.rao@freescale.com> Reviewed-by: Brian Castelli <brian.castelli@spirent.com>
-rw-r--r--core/traffic_controller_rfc2544.py3
-rw-r--r--docs/to-be-reorganized/quickstart.rst12
-rw-r--r--pylint.rc382
-rw-r--r--src/dpdk/dpdk.py5
-rw-r--r--src/ovs/daemon.py16
-rw-r--r--tools/load_gen/dummy/dummy.py2
-rw-r--r--tools/load_gen/stress/stress.py7
-rw-r--r--tools/report/report.py2
-rw-r--r--tools/systeminfo.py2
-rw-r--r--vswitches/ovs_vanilla.py2
10 files changed, 412 insertions, 21 deletions
diff --git a/core/traffic_controller_rfc2544.py b/core/traffic_controller_rfc2544.py
index 5659569f..de45de92 100644
--- a/core/traffic_controller_rfc2544.py
+++ b/core/traffic_controller_rfc2544.py
@@ -48,8 +48,7 @@ class TrafficControllerRFC2544(ITrafficController, IResults):
self._packet_sizes = None
packet_sizes_cli = get_test_param('pkt_sizes')
if packet_sizes_cli:
- self._packet_sizes = [int(x.strip())
- for x in packet_sizes_cli.split(',')]
+ self._packet_sizes = [int(x.strip()) for x in packet_sizes_cli.split(',')]
else:
self._packet_sizes = settings.getValue('TRAFFICGEN_PKT_SIZES')
diff --git a/docs/to-be-reorganized/quickstart.rst b/docs/to-be-reorganized/quickstart.rst
index c575be59..bb009fce 100644
--- a/docs/to-be-reorganized/quickstart.rst
+++ b/docs/to-be-reorganized/quickstart.rst
@@ -243,6 +243,18 @@ To run tests using Vanilla OVS:
./vsperf --conf-file <path_to_settings_py>
+Code change verification by pylint
+----------------------------------
+Every developer participating in VSPERF project should run
+pylint before his python code is submitted for review. Project
+specific configuration for pylint is available at 'pylint.rc'.
+
+Example of manual pylint invocation:
+
+ .. code-block:: console
+
+ pylint --rcfile ./pylint.rc ./vsperf
+
GOTCHAs:
--------
diff --git a/pylint.rc b/pylint.rc
new file mode 100644
index 00000000..f748adac
--- /dev/null
+++ b/pylint.rc
@@ -0,0 +1,382 @@
+[MASTER]
+
+# Specify a configuration file.
+#rcfile=
+
+# Python code to execute, usually for sys.path manipulation such as
+# pygtk.require().
+#init-hook=
+
+# Profiled execution.
+profile=no
+
+# Add files or directories to the blacklist. They should be base names, not
+# paths.
+ignore=CVS,docs,conf
+
+# Pickle collected data for later comparisons.
+persistent=yes
+
+# List of plugins (as comma separated values of python modules names) to load,
+# usually to register additional checkers.
+load-plugins=
+
+# Use multiple processes to speed up Pylint.
+jobs=1
+
+# Allow loading of arbitrary C extensions. Extensions are imported into the
+# active Python interpreter and may run arbitrary code.
+unsafe-load-any-extension=no
+
+# A comma-separated list of package or module names from where C extensions may
+# be loaded. Extensions are loading into the active Python interpreter and may
+# run arbitrary code
+extension-pkg-whitelist=
+
+# Allow optimization of some AST trees. This will activate a peephole AST
+# optimizer, which will apply various small optimizations. For instance, it can
+# be used to obtain the result of joining multiple strings with the addition
+# operator. Joining a lot of strings can lead to a maximum recursion error in
+# Pylint and this flag can prevent that. It has one side effect, the resulting
+# AST will be different than the one from reality.
+optimize-ast=no
+
+
+[MESSAGES CONTROL]
+
+# Only show warnings with the listed confidence levels. Leave empty to show
+# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
+confidence=
+
+# Enable the message, report, category or checker with the given id(s). You can
+# either give multiple identifier separated by comma (,) or put this option
+# multiple time. See also the "--disable" option for examples.
+#enable=
+
+# Disable the message, report, category or checker with the given id(s). You
+# can either give multiple identifiers separated by comma (,) or put this
+# option multiple times (only on the command line, not in the configuration
+# file where it should appear only once).You can also use "--disable=all" to
+# disable everything first and then reenable specific checks. For example, if
+# you want to run only the similarities checker, you can use "--disable=all
+# --enable=similarities". If you want to run only the classes checker, but have
+# no Warning level messages displayed, use"--disable=all --enable=classes
+# --disable=W"
+disable=E1602,E1603,E1601,E1606,E1607,E1604,E1605,E1608,W0401,W1604,W1605,W1606,W1607,W1601,W1602,W1603,W1622,W1623,W1620,W1621,W1608,W1609,W1624,W1625,W1618,W1626,W1627,I0021,I0020,W0704,R0903,W1613,W1638,W1611,W1610,W1617,W1616,W1615,W1614,W1630,W1619,W1632,W1635,W1634,W1637,W1636,W1639,W1612,W1628,W1633,W1629,I0011,W1640
+
+
+[REPORTS]
+
+# Set the output format. Available formats are text, parseable, colorized, msvs
+# (visual studio) and html. You can also give a reporter class, eg
+# mypackage.mymodule.MyReporterClass.
+output-format=text
+
+# Put messages in a separate file for each module / package specified on the
+# command line instead of printing them on stdout. Reports (if any) will be
+# written in a file name "pylint_global.[txt|html]".
+files-output=no
+
+# Tells whether to display a full report or only the messages
+reports=yes
+
+# Python expression which should return a note less than 10 (10 is the highest
+# note). You have access to the variables errors warning, statement which
+# respectively contain the number of errors / warnings messages and the total
+# number of statements analyzed. This is used by the global evaluation report
+# (RP0004).
+evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
+
+# Add a comment according to your evaluation note. This is used by the global
+# evaluation report (RP0004).
+comment=no
+
+# Template used to display messages. This is a python new-style format string
+# used to format the message information. See doc for all details
+#msg-template=
+
+
+[BASIC]
+
+# Required attributes for module, separated by a comma
+required-attributes=
+
+# List of builtins function names that should not be used, separated by a comma
+bad-functions=filter,apply,file
+
+# Good variable names which should always be accepted, separated by a comma
+good-names=i,j,k,ex,Run,_
+
+# Bad variable names which should always be refused, separated by a comma
+bad-names=foo,bar,baz,toto,tutu,tata
+
+# Colon-delimited sets of names that determine each other's naming style when
+# the name regexes allow several styles.
+name-group=
+
+# Include a hint for the correct naming format with invalid-name
+include-naming-hint=yes
+
+# Regular expression matching correct inline iteration names
+inlinevar-rgx=[A-Za-z_][A-Za-z0-9_]*$
+
+# Naming hint for inline iteration names
+inlinevar-name-hint=[A-Za-z_][A-Za-z0-9_]*$
+
+# Regular expression matching correct class attribute names
+class-attribute-rgx=([A-Za-z_][A-Za-z0-9_]{1,30}|(__.*__))$
+
+# Naming hint for class attribute names
+class-attribute-name-hint=([A-Za-z_][A-Za-z0-9_]{1,30}|(__.*__))$
+
+# Regular expression matching correct argument names
+argument-rgx=[a-z_][a-z0-9_]{2,30}$
+
+# Naming hint for argument names
+argument-name-hint=[a-z_][a-z0-9_]{2,30}$
+
+# Regular expression matching correct variable names
+variable-rgx=[a-z_][a-z0-9_]{2,30}$
+
+# Naming hint for variable names
+variable-name-hint=[a-z_][a-z0-9_]{2,30}$
+
+# Regular expression matching correct module names
+module-rgx=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
+
+# Naming hint for module names
+module-name-hint=(([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
+
+# Regular expression matching correct class names
+class-rgx=[A-Z_][a-zA-Z0-9]+$
+
+# Naming hint for class names
+class-name-hint=[A-Z_][a-zA-Z0-9]+$
+
+# Regular expression matching correct function names
+function-rgx=[a-z_][a-z0-9_]{2,30}$
+
+# Naming hint for function names
+function-name-hint=[a-z_][a-z0-9_]{2,30}$
+
+# Regular expression matching correct method names
+method-rgx=[a-z_][a-z0-9_]{2,30}$
+
+# Naming hint for method names
+method-name-hint=[a-z_][a-z0-9_]{2,30}$
+
+# Regular expression matching correct attribute names
+attr-rgx=[a-z_][a-z0-9_]{2,30}$
+
+# Naming hint for attribute names
+attr-name-hint=[a-z_][a-z0-9_]{2,30}$
+
+# Regular expression matching correct constant names
+const-rgx=(([A-Z_][A-Z0-9_]*)|(__.*__))$
+
+# Naming hint for constant names
+const-name-hint=(([A-Z_][A-Z0-9_]*)|(__.*__))$
+
+# Regular expression which should only match function or class names that do
+# not require a docstring.
+no-docstring-rgx=__.*__
+
+# Minimum line length for functions/classes that require docstrings, shorter
+# ones are exempt.
+docstring-min-length=-1
+
+
+[FORMAT]
+
+# Maximum number of characters on a single line.
+max-line-length=120
+
+# Regexp for a line that is allowed to be longer than the limit.
+ignore-long-lines=^\s*(# )?<?https?://\S+>?$
+
+# Allow the body of an if to be on the same line as the test if there is no
+# else.
+single-line-if-stmt=no
+
+# List of optional constructs for which whitespace checking is disabled
+no-space-check=trailing-comma,dict-separator
+
+# Maximum number of lines in a module
+max-module-lines=1000
+
+# String used as indentation unit. This is usually " " (4 spaces) or "\t" (1
+# tab).
+indent-string=' '
+
+# Number of spaces of indent required inside a hanging or continued line.
+indent-after-paren=4
+
+# Expected format of line ending, e.g. empty (any line ending), LF or CRLF.
+expected-line-ending-format=
+
+
+[LOGGING]
+
+# Logging modules to check that the string format arguments are in logging
+# function parameter format
+logging-modules=logging
+
+
+[MISCELLANEOUS]
+
+# List of note tags to take in consideration, separated by a comma.
+notes=FIXME,XXX,TODO
+
+
+[SIMILARITIES]
+
+# Minimum lines number of a similarity.
+min-similarity-lines=4
+
+# Ignore comments when computing similarities.
+ignore-comments=yes
+
+# Ignore docstrings when computing similarities.
+ignore-docstrings=yes
+
+# Ignore imports when computing similarities.
+ignore-imports=no
+
+
+[SPELLING]
+
+# Spelling dictionary name. Available dictionaries: none. To make it working
+# install python-enchant package.
+spelling-dict=
+
+# List of comma separated words that should not be checked.
+spelling-ignore-words=
+
+# A path to a file that contains private dictionary; one word per line.
+spelling-private-dict-file=
+
+# Tells whether to store unknown words to indicated private dictionary in
+# --spelling-private-dict-file option instead of raising a message.
+spelling-store-unknown-words=no
+
+
+[TYPECHECK]
+
+# Tells whether missing members accessed in mixin class should be ignored. A
+# mixin class is detected if its name ends with "mixin" (case insensitive).
+ignore-mixin-members=yes
+
+# List of module names for which member attributes should not be checked
+# (useful for modules/projects where namespaces are manipulated during runtime
+# and thus existing member attributes cannot be deduced by static analysis
+ignored-modules=
+
+# List of classes names for which member attributes should not be checked
+# (useful for classes with attributes dynamically set).
+ignored-classes=SQLObject
+
+# When zope mode is activated, add a predefined set of Zope acquired attributes
+# to generated-members.
+zope=no
+
+# List of members which are set dynamically and missed by pylint inference
+# system, and so shouldn't trigger E0201 when accessed. Python regular
+# expressions are accepted.
+generated-members=REQUEST,acl_users,aq_parent
+
+
+[VARIABLES]
+
+# Tells whether we should check for unused import in __init__ files.
+init-import=no
+
+# A regular expression matching the name of dummy variables (i.e. expectedly
+# not used).
+dummy-variables-rgx=_$|dummy
+
+# List of additional names supposed to be defined in builtins. Remember that
+# you should avoid to define new builtins when possible.
+additional-builtins=
+
+# List of strings which can identify a callback function by name. A callback
+# name must start or end with one of those strings.
+callbacks=cb_,_cb
+
+
+[CLASSES]
+
+# List of interface methods to ignore, separated by a comma. This is used for
+# instance to not check methods defines in Zope's Interface base class.
+ignore-iface-methods=isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by
+
+# List of method names used to declare (i.e. assign) instance attributes.
+defining-attr-methods=__init__,__new__,setUp
+
+# List of valid names for the first argument in a class method.
+valid-classmethod-first-arg=cls
+
+# List of valid names for the first argument in a metaclass class method.
+valid-metaclass-classmethod-first-arg=mcs
+
+# List of member names, which should be excluded from the protected access
+# warning.
+exclude-protected=_asdict,_fields,_replace,_source,_make
+
+
+[DESIGN]
+
+# Maximum number of arguments for function / method
+max-args=6
+
+# Argument names that match this expression will be ignored. Default to name
+# with leading underscore
+ignored-argument-names=_.*
+
+# Maximum number of locals for function / method body
+max-locals=20
+
+# Maximum number of return / yield for function / method body
+max-returns=6
+
+# Maximum number of branch for function / method body
+max-branches=15
+
+# Maximum number of statements in function / method body
+max-statements=70
+
+# Maximum number of parents for a class (see R0901).
+max-parents=7
+
+# Maximum number of attributes for a class (see R0902).
+max-attributes=15
+
+# Minimum number of public methods for a class (see R0903).
+min-public-methods=2
+
+# Maximum number of public methods for a class (see R0904).
+max-public-methods=20
+
+
+[IMPORTS]
+
+# Deprecated modules which should not be used, separated by a comma
+deprecated-modules=regsub,TERMIOS,Bastion,rexec
+
+# Create a graph of every (i.e. internal and external) dependencies in the
+# given file (report RP0402 must not be disabled)
+import-graph=
+
+# Create a graph of external dependencies in the given file (report RP0402 must
+# not be disabled)
+ext-import-graph=
+
+# Create a graph of internal dependencies in the given file (report RP0402 must
+# not be disabled)
+int-import-graph=
+
+
+[EXCEPTIONS]
+
+# Exceptions that will emit a warning when being caught. Defaults to
+# "Exception"
+overgeneral-exceptions=Exception
diff --git a/src/dpdk/dpdk.py b/src/dpdk/dpdk.py
index 0a63c161..e1a8e657 100644
--- a/src/dpdk/dpdk.py
+++ b/src/dpdk/dpdk.py
@@ -318,9 +318,8 @@ def _unbind_nics():
except subprocess.CalledProcessError:
_LOGGER.error('Unable to unbind NICs %s',
str(settings.getValue('WHITELIST_NICS')))
- '''Rebind NICs to their original drivers
- using the Intel DPDK ``dpdk_nic_bind.py`` tool.
- '''
+ # Rebind NICs to their original drivers
+ # using the Intel DPDK ``dpdk_nic_bind.py`` tool.
for i, nic in enumerate(settings.getValue('WHITELIST_NICS')):
try:
if nic_drivers[i] != '':
diff --git a/src/ovs/daemon.py b/src/ovs/daemon.py
index db096353..0d518ea9 100644
--- a/src/ovs/daemon.py
+++ b/src/ovs/daemon.py
@@ -44,9 +44,7 @@ class VSwitchd(tasks.Process):
"""
_ovsdb_pid = None
_logfile = _LOG_FILE_VSWITCHD
- _ovsdb_pidfile_path = os.path.join(settings.getValue('LOG_DIR'),
- "ovsdb_pidfile.pid")
-
+ _ovsdb_pidfile_path = os.path.join(settings.getValue('LOG_DIR'), "ovsdb_pidfile.pid")
_proc_name = 'ovs-vswitchd'
def __init__(self, timeout=30, vswitchd_args=None, expected_cmd=None):
@@ -60,7 +58,7 @@ class VSwitchd(tasks.Process):
"""
self._logger = logging.getLogger(__name__)
self._timeout = timeout
- self._expect = expected_cmd;
+ self._expect = expected_cmd
vswitchd_args = vswitchd_args or []
self._cmd = ['sudo', '-E', _OVS_VSWITCHD_BIN] + vswitchd_args
@@ -84,7 +82,7 @@ class VSwitchd(tasks.Process):
self._kill_ovsdb()
raise exc
- def kill(self):
+ def kill(self, signal='-15', sleep=2):
"""Kill ``ovs-vswitchd`` instance if it is alive.
:returns: None
@@ -93,7 +91,7 @@ class VSwitchd(tasks.Process):
self._kill_ovsdb()
- super(VSwitchd, self).kill()
+ super(VSwitchd, self).kill(signal, sleep)
# helper functions
@@ -131,7 +129,7 @@ class VSwitchd(tasks.Process):
['sudo', _OVSDB_SERVER_BIN,
'--remote=punix:%s' % os.path.join(_OVS_VAR_DIR, 'db.sock'),
'--remote=db:Open_vSwitch,Open_vSwitch,manager_options',
- '--pidfile=' + self._ovsdb_pidfile_path , '--overwrite-pidfile'],
+ '--pidfile=' + self._ovsdb_pidfile_path, '--overwrite-pidfile'],
self._logger,
'Starting ovsdb-server...')
@@ -140,7 +138,7 @@ class VSwitchd(tasks.Process):
:returns: None
"""
- with open (self._ovsdb_pidfile_path, "r") as pidfile:
+ with open(self._ovsdb_pidfile_path, "r") as pidfile:
ovsdb_pid = pidfile.read().strip()
self._logger.info("Killing ovsdb with pid: " + ovsdb_pid)
@@ -150,7 +148,7 @@ class VSwitchd(tasks.Process):
self._logger, 'Killing ovsdb-server...')
@staticmethod
- def getDbSockPath():
+ def get_db_sock_path():
"""Method returns location of db.sock file
:returns: path to db.sock file.
diff --git a/tools/load_gen/dummy/dummy.py b/tools/load_gen/dummy/dummy.py
index 74fc33b7..1ad6c3fd 100644
--- a/tools/load_gen/dummy/dummy.py
+++ b/tools/load_gen/dummy/dummy.py
@@ -26,6 +26,6 @@ class DummyLoadGen(ILoadGenerator):
"""Start stress load if it was requested"""
pass
- def kill(self):
+ def kill(self, signal='-15', sleep=2):
"""Kill stress load if it is active"""
pass
diff --git a/tools/load_gen/stress/stress.py b/tools/load_gen/stress/stress.py
index 4a53f2d2..4c69a170 100644
--- a/tools/load_gen/stress/stress.py
+++ b/tools/load_gen/stress/stress.py
@@ -18,6 +18,7 @@
import logging
import subprocess
import copy
+import time
from tools import tasks
from tools import systeminfo
from tools.load_gen.load_gen import ILoadGenerator
@@ -111,13 +112,13 @@ class Stress(ILoadGenerator):
if self._running:
super(Stress, self).start()
- def kill(self):
+ def kill(self, signal='-15', sleep=2):
"""
Kill stress load if it is active
"""
if self._running and self._child and self._child.isalive():
- tasks.run_task(['sudo', 'pkill', self._proc_name],
- self._logger)
+ tasks.run_task(['sudo', 'pkill', signal, self._proc_name], self._logger)
+ time.sleep(sleep)
self._logger.info(
'Log available at %s', self._logfile)
diff --git a/tools/report/report.py b/tools/report/report.py
index 806aecbc..d51ff47d 100644
--- a/tools/report/report.py
+++ b/tools/report/report.py
@@ -104,7 +104,7 @@ def generate(input_file, tc_results, tc_stats):
'tests': tests,
}
- output_text = template.render(template_vars)
+ output_text = template.render(template_vars) #pylint: disable=no-member
with open(output_file, 'w') as file_:
file_.write(output_text)
logging.info('Test report written to "%s"', output_file)
diff --git a/tools/systeminfo.py b/tools/systeminfo.py
index 287a74d2..d3e24e5d 100644
--- a/tools/systeminfo.py
+++ b/tools/systeminfo.py
@@ -146,7 +146,7 @@ def get_pids(proc_names_list):
try:
pids = subprocess.check_output(['pidof'] + proc_names_list)
- except:
+ except subprocess.CalledProcessError:
# such process isn't running
return None
diff --git a/vswitches/ovs_vanilla.py b/vswitches/ovs_vanilla.py
index 36ad6054..acea4ecb 100644
--- a/vswitches/ovs_vanilla.py
+++ b/vswitches/ovs_vanilla.py
@@ -42,7 +42,7 @@ class OvsVanilla(IVSwitch):
def __init__(self):
#vswitchd_args = VSWITCHD_CONST_ARGS
- vswitchd_args = ["unix:%s" % VSwitchd.getDbSockPath()]
+ vswitchd_args = ["unix:%s" % VSwitchd.get_db_sock_path()]
vswitchd_args += settings.getValue('VSWITCHD_VANILLA_ARGS')
self._vswitchd = VSwitchd(vswitchd_args=vswitchd_args,
expected_cmd="db.sock: connected")