Commit Graph

15 Commits

Author SHA1 Message Date
Al Bailey e5a8ba7ff4 Tox and Zuul cleanup for python3.9
Added in the following tox targets for fm-rest-api:
 - bandit
 - flake8 / pep8
 - pylint (suppressing most of the codes)

All the tox targets run on python3
The test-requirements.txt have been updated
The StarlingX Debian upper constraints are utilized.
The spec-lint (rpm) job is removed from Zuul.

Zuul runs pylint for sub directories
Bandit exclusions are updated.

Included a change to a .py file to trigger
the bandit zuul job.

Test Plan (for fm-rest-api)
  PASS: tox -e bandit
  PASS: tox -e coverage
  PASS: tox -e flake8
  PASS: tox -e pylint

Story: 2010531
Task: 47575
Signed-off-by: Al Bailey <al.bailey@windriver.com>
Change-Id: I7ecaf1c90495b283c26e02e3b481bfe4c77c3939
2023-03-02 19:32:25 +00:00
albailey 90d9eb4161 Attempt to fix zuul jobs from timing out
The tox jobs for fault are having problems with a
timeout, which appears to be related to how long it takes
to setup the python requirements.

This update tries to limit the scope for yamllint, and
eliminate some of the sdist related actions.

pylint has been relocated to the test-requirements file.

The usedevelop = False is required for the base tox.ini
because there are no setup files at that directory level.

Several pylint errors had to be suppressed, and will be
restored once py3 changes are merged from centos8 branch.

Story: 2008943
Task: 42967
Signed-off-by: albailey <Al.Bailey@windriver.com>
Change-Id: Icc8747226511f0be614df20800813fe4eb9e6b96
2021-08-10 07:32:57 -05:00
Charles Short 03090ca2bb Fix pep8 gate failures
Set hacking to < 4.0.1 in test-requirements.txt so that
the pep8 gate passes again.

Test:
Ran tox -e pep8 command to validate the flake8 job and result.

Related-Bug: 1926172

Signed-off-by: Charles Short <charles.short@windriver.com>
Change-Id: I5b27a89d0e078912814ca2999bf28e6602980fd0
2021-04-26 15:39:52 -04:00
albailey 08130cd625 Fix zuul jobs broken due to pip upversion
python 2.7 zuul jobs such as py27 and pylint could fail
when trying to import bandit using the new pip
since bandit 1.7 was released Dec 12 and is python3 only.

The cpp file header was only changed in this review to
trigger the appropriate zuul jobs.

Partial-Bug: #1907678
Change-Id: Idb1e97d16773d36027d29f4eb100d8b453a8069f
Signed-off-by: albailey <Al.Bailey@windriver.com>
2020-12-18 08:41:07 -06:00
Pablo Bovina 8e74a0ee1e Reimplementation logic for trap generation
In the current implementation "Fault" is responsible
for the generation and dispatch of traps.

This logic is removed from it, leaving only the
responsibility of sending the metadata of a trap
to a service dedicated to generating and sending them.

The fm.conf file will contain the IP and port values
of the service.

Story: 2008132
Task: 40867
Depends-On: https://review.opendev.org/761217

Change-Id: I575dfa2329f11821404ca4cb1d539e5189444b4e
Signed-off-by: Pablo Bovina <pablo.bovina@windriver.com>
2020-12-08 18:37:50 -03:00
albailey 42a9cfa882 Use newer flake8 on python3.8 zuul systems
flake8 2.5.5 fails on ubuntu-focal zuul machines running python3.8
with the following error:
AttributeError: 'FlakesChecker' object has no attribute 'CONSTANT'

Fixed:
 E117 over-indented
 E741 ambiguous variable name
 F841 local variable is assigned to but never used

Per-Line-Suppressed:
 E402 module level import not at top of file
 F632 use ==/!= to compare constant literals

Global Suppress:
 W504 line break after binary operator
 W605 invalid escape sequence

The suppressed errors can be fixed by later submissions.

Change-Id: I2df3ece427f0c84ce16c1a82f4d9f0c9a5a6982b
Partial-Bug: 1895054
Signed-off-by: albailey <Al.Bailey@windriver.com>
2020-11-16 13:35:31 -06:00
Sharath Kumar K 2f364daa08 Tox and Zuul job for the python code scan in starlingx/fault
Setting up the bandit tool for the scanning of HIGH severity issues
in the python codes under Starlingx/fault folder.
Expecting this merge will enable zuul job for CI/CD of bandit scan.

Configuration files:
1. tox.ini for adding bandit environment and command.
2. test-requirements.txt for adding bandit version.
3. .zuul.yaml file for adding bandit job and configuring under
   check job to run code scan every time before code commit.

Test:
Run tox -e bandit command inside the fault folder to validate the
bandit scan and result.

Please note:
Changes will be implemented in batches and  this is Batch2 change.

Story: 2007541
Task: 39490
Depends-On: https://review.opendev.org/#/c/721294/

Change-Id: I84449691281d9769e9219e6f9f1338c20f518f40
Signed-off-by: Sharath Kumar K <sharath.kumar@intel.com>
2020-04-27 11:14:36 +02:00
albailey ce56ce7ea5 Adding pylint zuul and tox target
Adding a pylint tox target which only suppresses
the error codes that are currently failing.
This will prevent any of the passing checks from being
broken by future submissions.
The currently suppressed codes can be fixed by subsequent
commits.

Adds a zuul pylint target to invoke the new tox target.

Unified the install_command in tox.ini to ensure
the upper constraints are used.

Change-Id: Id2fb8cbb7ce63f844a06403410d461c601822ad6
Story: 2007082
Task: 39020
Signed-off-by: albailey <Al.Bailey@windriver.com>
2020-03-11 09:05:18 -05:00
chenyan 2f37da8e8e Add unit test case for fm-rest-api/fm/fm/common/utils.py
Add test case FaultUtilsTestCase.
Add fake log in tests/base.py.

Story: 2007082
Task: 38093
Task: 38084

Depends-on: https://review.opendev.org/#/c/702175/
Change-Id: I560415ed1519834c21f0090f594f2da6c26f3eca
Signed-off-by: chenyan <yan.chen@intel.com>
2020-01-16 16:45:54 +08:00
chenyan 385f274a8f Create test framework for python with stestr.
Add add the first unit test for fm-rest-api/fm/fm/common/timeutils.
Add tox task for py27/35 as zuul checking and gating jobs.

Story: 2007082
Task: 38077

Change-Id: I2f259dcf2178f42546966063c0d724bc17e2a804
Signed-off-by: chenyan <yan.chen@intel.com>
2020-01-16 16:45:45 +08:00
Saul Wold 91af45019b Tox: add tox job and requirements to improve specfiles
This is a tox job to scan the RPM specfiles and do some
initial sanity checks and use the OpenDev Spec-Cleaner tool, this
is not a 'linter' per-se, but will output a diff of recommended
changes for the specfile.

Initial disable cleaning our default CentOS specfiles since we
know they need work, we can enable this later.

This uses the speclint script in starlingx/integ a proposed
by the Depends-On.

The recommended guildline for openSUSE is located here:
https://en.opensuse.org/openSUSE:Specfile_guidelines

Fix up fm-rest-api opensuse specfile

Depends-On: https://review.opendev.org/664995
Change-Id: I46da780a667569a9dccedd551d955c983e9601cd
Signed-off-by: Saul Wold <sgw@linux.intel.com>
2019-07-16 13:15:24 -07:00
Al Bailey a40bce19f9 Enable additional flake8 checks
By setting 'hacking' as the dependency, flake8
will include hacking and other checks.
This is the same set used by other openstack
components.

This commit suppresses any of those new checks that
would fail.
 H102  Apache 2.0 license header not found
 H104  File contains nothing but comments
 H105  Don't use author tags
 H233  Python 3.x incompatible use of print operator
 H236  Python 3.x incompatible __metaclass__
 H238  old style class declaration, use new style
 H301  one import per line
 H306  imports not in alphabetical order
 H401  docstring should not start with a space
 H403  multi line docstrings should end on a new line
 H404  multi line docstring should start without a leading new line
 H405  multi line docstring summary not separated with an empty line
 H702  Argument to ... must be a string
 H903  Windows style line endings not allowed in code

At a later time, additional commits will fix and un-suppress them.

Story: 2004515
Task: 29304
Change-Id: I7f9e36cb605e47338dc5d33c94d1c0b09943a38a
Signed-off-by: Al Bailey <Al.Bailey@windriver.com>
2019-02-01 17:07:53 -06:00
Bart Wensley 8080f496b6 Lock down flake8 version
The new flake8 version 3.6.0 introduces new warnings that cause
the check and gate jobs to fail. Locking down the flake8 version
to avoid these surprises in the future. We can later increment
the flake8 version and fix the new warnings in a controlled
manner.

Change-Id: I6bd40eea0ec8599af5ded99f7696e81d5c64f31e
Partial-Bug: 1799721
Signed-off-by: Bart Wensley <barton.wensley@windriver.com>
2018-10-24 10:06:43 -05:00
chenyan 7bdf6fd47c add flake8 as pep8 codestyle check.
Enable test for pep8 and use flake8 as check tool.

Story: 2003310
Task: 24446

Change-Id: Idf5cbde46dc1a2a579587438b83f2dcb7b9352bb
Signed-off-by: chenyan <yan.chen@intel.com>
2018-08-10 11:39:57 +08:00
Dean Troyer 3a4be5f79c Add default test framework
Change-Id: Idbc2f22873edff7a80b5abc5a5110b41b75fa6cc
Signed-off-by: Dean Troyer <dtroyer@gmail.com>
2018-06-09 08:44:12 -05:00