Commit Graph

261 Commits

Author SHA1 Message Date
Takashi Kajinami 1ea7c827f6 bandit: Install baseline extra
Since bandit 1.7.7[1] we have to install the baseline extra to use
bandit-baseline.

[1] 22c75a8306

Change-Id: I3eda10d6dd5244c1075c576f24a5a024f7e50afd
2024-01-29 22:46:33 +09:00
Akihiro Motoki 40e416b8fc Add unit tests with Django 4.2
Django 4.2 is our primary version in 2023.2 (Caracal),
so we need to start testing with Django 4.2.
Once all unit tests work, let's switch it to voting.

PYTHONWARNINGS in tox.ini is also simplified. We had three similar
variants of PYTHONWARNINGS in tox.ini. There is no need to use a
different value for py3 and py39 as we already use py39 by default.
PendingDeprecationWarning was added to hide Django deprecation
warnings, so I keep it now. On the other hand I think we should
handle Django deprecation warnings much earlier to sync Django
releases more promptly, so TODO comment is added.

Change-Id: I530be8fde637a912968b4ce7dbc94a4108dc50df
2023-10-19 22:13:22 +09:00
Radomir Dopieralski 36536272ff Add pytest-based selenium tests
This is a patch to start work on re-writing the integration tests
using pytest syntax and several improvements, as proposed on the
upstream meeting, and summarized at https://etherpad.opendev.org/p/horizon-pytest

The new tests are to eventually replace the existing integration
tests. At the moment they don't run automatically, you have to explicitly run them using tox or pytest. When the new tests are complete, we will switch to them on the gate.



Change-Id: Iea38e4f9771ff3cae7ae8675863e9c488f3f6d8a
2023-08-08 11:45:20 +00:00
Akihiro Motoki 20966c4968 Fix tox.ini parse error with tox 4.2.8
The validation of setenv in the recent tox like 4.2.8 seems more strict.
We need a space between a factor and envvar.

Note that we need to discuss the three variants of PYTHONWARNINGS
but this commit focuses on fixing the gate failure due to tox.ini.

Change-Id: I13be2d39850e77f15e5bbf67b0022b10b09e5c6f
2023-01-12 12:23:42 +09:00
Akihiro Motoki aec6340398 Adjust tox.ini for tox4
OpenStack CI now uses tox4 by default.

- Drop "skipsdist = True".
  If skipsdist is specified, horizon is not installed into tox env.
- Env vars specified in passenv should be one per line (or separated by
  comma) in tox4.

Change-Id: I60d2db52e9aac580859de3ed17fde14f9fd262a2
2022-12-26 08:48:27 +09:00
Radomir Dopieralski 4eb24797e5 Make integration tests stop on first failure
This should save us some time and decrease the server load. If a single
test failed, we already know the patch is bad (or the tests need to be
rerun) so it makes no sense to execute the rest of the tests on the
gate.

Change-Id: Ic56d5e192487d444afd0cdf0bce5e1a691ba087c
2022-10-12 16:21:36 +02:00
Zuul c28cdb8afb Merge "Drop lower-constraints.txt and its testing" 2022-08-18 18:32:26 +00:00
manchandavishal 68e12b8100 Drop lower-constraints.txt and its testing
As discussed in TC PTG[1] and TC resolution[2], we are
dropping the lower-constraints.txt file and its testing.
We will keep lower bounds in the requirements.txt file but
with a note that these are not tested lower bounds and we
try our best to keep them updated.

[1] https://etherpad.opendev.org/p/tc-zed-ptg#L326
[2] https://governance.openstack.org/tc/resolutions/20220414-drop-lower-constraints.html#proposal

Change-Id: Ia315117f43a299fc68f3a15db59ddae37f8d30cf
2022-06-08 12:38:07 +00:00
Akihiro Motoki ee80782504 Drop py36 and py37 support
Python runtimes for Zed are 3.8, 3.9 and optionally 3.10 [1][2],
so tox envs in tox.ini are updated accordingly.

Declare python_requires >=3.8 in setup.cfg
python_requires are declared in many projects during dropping
python 2.7 support. It is good to follow the convention and
it also clarifies our python interpreter requirement.

This commit also cleans up python2.7 related stuffs in setup.py.
Both are related to the supported versions of python,
so I made both changes in a single commit.

[1] https://governance.openstack.org/tc/reference/runtimes/zed.html
[2] b740b42fb1/zuul.d/project-templates.yaml (L542)

Change-Id: I4161816fd1fec19a3834cc7d994b3f761e1ab2ce
Closes-Bug: #1960887
2022-06-06 17:59:13 +09:00
Takashi Kajinami f7e0492332 Bump tox minversion to 3.18.0
Since tox 3.18.0, the whitelist_externals option has been deprecated in
favor of the new allow_list_externals option[1].

This change bumps the minversion of tox so that we can replace
the deprecated option.

[1] https://github.com/tox-dev/tox/blob/master/docs/changelog.rst#v3180-2020-07-23

Change-Id: I1943ddbe8d63c577b5c8084a158af5bae4d1f9fc
2022-05-23 08:15:37 +09:00
Akihiro Motoki 115326769f Integration tests: Allow to run a specific test from tox
Previously the path of the integration tests was specified explicitly
in tox.ini and we cannot run a specific test from tox.
{posargs} existed in the previous command line, but it can be used
only to specify extra options and we cannot change the test path,
so the whole integration tests are always run.
It can be solved by passing the integration test path as
the default value of {posargs}.

The most possible case where we would like to change the test command
is to run a specific set of tests instead of the whole tests,
so I believe this solution would work.

Change-Id: Ifa478a360a8af8b3d959de7ec632eedef484391d
2022-02-16 19:19:34 +09:00
manchandavishal 7249e7c1dc Updating python testing as per Yoga testing runtime
Yoga testing runtime[1] has been updated to add py39
testing as voting. Unit tests update are
handled by the job template change in openstack-zuul-job

- https://review.opendev.org/c/openstack/openstack-zuul-jobs/+/820286

this commit makes other required changes in ``.zuul.d/cross-jobs.yaml``,
tox.ini and update the classifier in setup.cfg file.

[1] https://governance.openstack.org/tc/reference/runtimes/yoga.html

Change-Id: Ie66460c19e5e670e9be3b1262d5f06e821078be9
2021-12-15 13:06:16 +05:30
Akihiro Motoki f3d2b9d540 Preparation for Django 3.2 support
This commit adds a non-voting unit test job with Django 3.2.

Jobs with Django 3.0 and 3.1 are dropped now.
They were introduced before Django 3.2 was released.
Django 3.0 reached EOL and Django 3.1 will reach EOL this December.
Django 3.2 is an LTS version so testing with Django 3.2 is enough.

Change-Id: Ic6ba0ea281b287b7f4762f92e2e81a6fd654da8f
2021-09-16 16:43:17 +09:00
Zuul 49b79a6f30 Merge "Preparation for Django 3.0 and 3.1 support (1)" 2021-07-29 14:52:45 +00:00
Akihiro Motoki ffe84dbf9d Move linters dependencies to tox.ini
One of suggestions discussed in the mailling thread [1] is to decouple
linters from test-requirements.txt. We uses specific versions of linters
(hacking, flake8, pylint and bandit) and they are potentially incompatbile
with other libraries in test-requirements.txt.
One example is bandit incompatibility detected by the new pip resolver.
This commit moves linters to tox.ini and introduces a new tox envdir
shared by linter related tox envs.

Note that we have a unit test for a local hacking rule so hacking needs
to be installed as part of the default dependencies. We can have it in
test-requirements.txt but I think it is better to have it in tox.ini
as hacking is a part of linters and other linter dependencies are
declared in tox.ini now.

[1] http://lists.openstack.org/pipermail/openstack-discuss/2020-December/thread.html#19362

Change-Id: Ia41c5f665f01bdab187c9256b2319885998d12c3
2021-03-19 11:25:28 +09:00
Akihiro Motoki 6a2635e32d Preparation for Django 3.0 and 3.1 support (1)
This commit enables non-voting unit test jobs with Django 3.0/3.1.

PendingDeprecationWarning is added to PYTHONWARNINGS in tox.ini.
PendingDeprecationWarning in Django 3.0+ includes deprecation warnings
on what will be dropped in Django 4.0 and they cannot be addressed
as long as we use Django 2.2.

Change-Id: I44e511ddc1d93fc3e2b68393b88c5f2cd1360854
2021-02-26 03:35:13 +09:00
zhangboye f0460fc437 Use TOX_CONSTRAINTS_FILE
UPPER_CONSTRAINTS_FILE is old name and deprecated
This allows to use upper-constraints file as more
readable way instead of UPPER_CONSTRAINTS_FILE=<lower-constraints file>.
For more info. please refer [1].

[1] https://zuul-ci.org/docs/zuul-jobs/python-roles.html#rolevar-tox.tox_constraints_file

Change-Id: I1600df016b90383c77e179e186d8c58fa9868d92
2021-01-29 19:49:41 +00:00
Jim Rollenhagen 1202faa709 Fix coverage job
`coverage run pytest` runs coverage against the tests in a file called
"pytest", whereas `coverage run -m pytest` uses pytest as the test
runner, which is what we really want here.

To avoid duplicated maitenance of pytest arguments,
unit_tests.sh is updated to handle the coverage run.

Co-Authored-By: Akihiro Motoki <amotoki@gmail.com>
Change-Id: I106cb5227ca8c4f0a6f9d81c37e745a6f304de45
2020-10-05 15:32:06 +09:00
Akihiro Motoki 92edabdcf3 doc: Enable parallel build
"-j auto" enable parallel documentation build with multiple processes
and the number of processors is detected automatically.
This speeds up local documentation build a lot.

Change-Id: I7fab3a37a4a15b886d3456eebad86115a1a63f11
2020-08-20 06:45:34 +09:00
Sean McGinnis 55f3344cd1
Bump default tox env from py37 to py38
Python 3.8 is now our highest level supported python runtime.
This updates the default tox target environments to swap out
py37 for py38 to make sure local development testing is
covering this version.

This does not impact zuul jobs in any way, nor prevent local
tests against py37. It just changes the default if none is
explicitly provided.

Change-Id: I067ad1c53df481f578bad8ccc16c4c9d12a2d381
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-04-24 10:25:42 -05:00
Zuul 9cbd32f2b8 Merge "Fix video recording for integration tests" 2020-04-16 11:34:14 +00:00
Ivan Kolodyazhny 8f887350e0 Fix video recording for integration tests
libav-tools package doesn't exist anymore so we need to use ffmpeg now
to capture the screen.

Change-Id: I58384f42ded3ed864de0dc2a9a56d2d9943168b9
2020-04-09 09:20:04 +00:00
Oleksii Petrenko d6fe0170ee Change horizon test runner to pytest
Changes test invocation from `manage.py test` to `pytest`. Adds addtitional
test requirements like pytest, pytest-django, pytest-html. Adds
`pytest.mark` alongside django's test `tag`. Adds posibility to export test
results into xml and html formats.

Depends-On: https://review.opendev.org/#/c/712315/
Related-Bug: #1866666
Co-Authored-By: Ivan Kolodyazhny <e0ne@e0ne.info>
Change-Id: Idb6e63cd23ca2ba8ca56f36eb8b63069bd211944
2020-04-03 13:47:18 +03:00
Ivan Kolodyazhny 5e979b7515 Remove PYTHONHASHSEED variable from integration tests env
PYTHONHASHSEED for integration tests was added in 2015 to run tests in a
same order each time. Now we don't need this workaround because
integration tests work well in any order they are executed.

Change-Id: Ide019baaf8786da14cc9edcc46b40ab5fabf3ef5
2020-02-28 21:10:51 +00:00
Zuul ddb9a8219e Merge "flake8: Ensure local check in hacking 2.0.0" 2020-02-19 12:57:55 +00:00
Akihiro Motoki 8c2b51acc2 flake8: Ensure local check in hacking 2.0.0
local-check-factory support was dropped in hacking 2.0.0.
The release notes of hacking 2.0.0 [1] suggests to use flake8's
native local plugin support [2]. This commit follows it.

[1] https://docs.openstack.org/releasenotes/hacking/unreleased.html#relnotes-2-0-0
[2] https://flake8.pycqa.org/en/3.7.0/user/configuration.html#using-local-plugins

Change-Id: Ie19630a58d7b4ce735007b8abdd6ebac85d60946
2020-01-27 02:43:48 +09:00
Akihiro Motoki 4ef9ba94c0 Avoid duplicated maintenance of integration test config
Configurations of the integration tests are maintained both
in horizon.conf and in-code configuration. It is redundant.

Configurations of the integration tests are defined by oslo.config.
We can use default values from them and generate a sample config file
using oslo-config-generator.

This commit drops horizon.conf and generates the sample config.
We no longer have horizon.conf, so the logic to load the config files
is updated accordingly.

Also makes the usage of single and double quotes in config.py consistent.

Change-Id: Id16c9fd4114316ade63c74097e486623d0c5be9f
2020-01-10 00:55:43 +09:00
Radomir Dopieralski a617bb67e2 Add a separate tox env for extracting and compiling translations
Change-Id: I44d4c93142365f1a069be59a4c4d5650952c58c6
2020-01-06 09:32:08 +01:00
Akihiro Motoki c5dd1536a0 Prepare non-primary Django tests in zuul jobs
We already have a template 'horizon-non-primary-django-jobs'
to test horizon and plugins with non-primary django versions,
but we still need to update tox.ini in all horizon plugins
whenever we change Django versions used.

This commit prepares per-Django environment in the zuul job.

Per-Django tox environments like py3-{dj111,dj20,dj22} are
no longer needed. It would be a big merit that we will no longer
need to update tox.ini in all horizon plugins.

The downside is that we do not provide a convenient way to
test it locally, but I think it can be covered in the document.

Change-Id: I726b19130ee9e7d06eb33231071c2673cfd3a49f
2019-12-29 05:20:33 +09:00
Zuul b638437b6d Merge "Make tox -e runserver work faster" 2019-12-09 18:10:21 +00:00
Zuul 1fd23504c3 Merge "tox: Move doc8 to docs related envs" 2019-11-15 01:33:30 +00:00
Radomir Dopieralski e4025301a4 Make tox -e runserver work faster
Compiling translation messages on every run of runserver makes it very
slow and inconvenient for development. Editing of the translations is
done rarely, and compilemessages can be run manually when it does
happen.

I'm also adding -v 0 to all the manage commands, to make it output
less garbage to the screen, making it a little easier to find actual
errors during development.

Change-Id: I95db4505c3a9cd5b2ecc3e6ad6a30d438a4447b9
2019-11-12 14:39:08 +01:00
Ivan Kolodyazhny 7f17dcb4dd Remove Python 2.7 jobs
Ussuri release won't support Python 2.7 officially [1] so we can
drop CI jobs to test with Python 2.7.

[1] https://governance.openstack.org/tc/reference/runtimes/ussuri.html

Depends-On: https://review.opendev.org/688997
Change-Id: I650ca71c5a7c922a73f20cdf5ceb02caae464d02
2019-10-24 21:44:39 +00:00
Akihiro Motoki 205ebe0f47 tox: Move doc8 to docs related envs
Previously doc8 is run as part of pep8 tox env. This leads to some tricky
'deps' in pep8 which installs the docs dependencies. This can be fixed by
moving doc8 to the docs related tox envs (docs and releasenotes).

This also helps developers using devstack avoid hitting an error in
"manage.py compilemessages" in stack.sh. The error is caused by sphinx
installed under .tox directory (as compilemessages tries to compile all
message catalogs even under dot directories like .tox).
Developers sometimes change the horizon code under /opt/stack/horizon
and it is not surprising to run "tox -e pep8".
(I think it is more common compared to a chance to run "tox -e docs".)
Thus I believe it is reasonable to move doc8 to the docs env.

Change-Id: I6345ebbcd24afc358555e9be4b2ca700c4b33861
2019-10-02 09:28:11 +09:00
Zuul a629d100be Merge "PDF documentation build" 2019-09-11 16:53:48 +00:00
Stephen Finucane f8552fc958 tox: Enable warnings
Let's try to minimize the chances of [1] hitting us in the future
through lots of annoying logging.

[1] http://lists.openstack.org/pipermail/openstack-discuss/2019-August/008723.html

Change-Id: I70292634fa564e34381108fef55f3a8f9a20fa2e
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2019-09-10 18:50:44 +09:00
Stephen Finucane 98d20a65d8 tox: Slight tweaks
- Use 'ignore_basepython_conflict' and set 'basepython' globally,
  avoiding the need to do it in each environment
- Set 'commands' in the top-level 'testenv' and just reference this
  where needed
- Remove unneeded 'setenv'

Change-Id: Ib2ac6279abf5cf3fa39cb1b72622e41c502429b5
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2019-09-10 18:50:44 +09:00
Akihiro Motoki 0a0fb835b8 PDF documentation build
Based on https://review.opendev.org/#/c/601659/ and
https://review.opendev.org/#/c/664555/

The generated PDF file is found at the top directory of the job log.

Story: 2006084
Task: 34864
Depends-On: https://review.opendev.org/664555
Change-Id: I5e25f1dfbec22b26d42eff3c6776a2d01e90bc60
2019-09-04 05:19:00 +00:00
Zuul 83b6a46db8 Merge "Add non-voting job with Python 3 + Django 2.2" 2019-08-11 19:08:51 +00:00
Ivan Kolodyazhny d2ae6b105f Add non-voting job with Python 3 + Django 2.2
Change-Id: I6eb64af5ae1b112195712e07b09e427a541a0089
2019-07-24 12:36:02 +00:00
Yves-Gwenael Bourhis 66144165ff Use the python real executable
Use the real python executable as shebang
Use exec instead of execfile if using python 3

Change-Id: I8acea40851c7e9dc248751be967859b2b9430af7
Closes-Bug: #1836580
2019-07-17 16:23:33 +02:00
tonybrad b3fada890b Update the constraints url
For more detail, see http://lists.openstack.org/pipermail/openstack-discuss/2019-May/006478.html

Change-Id: I9e8eb1bd79c64e1a84c7e7f596e6cda89f45a611
2019-06-12 15:54:45 +00:00
BubaVV e8fd0020ab Generate locale messages at dev server startup
By default, Horizon doesn't compile localized messages in tox
environment. It leads to silent fail of language change with 'Success'
message. Proposed patch includes compilation of messages to tox runserver
command

Change-Id: I149a622a81a17e9d951c68829349fc70fbb8ed2a
2019-05-17 10:20:09 +03:00
ZhongShengping a569f0faf3 Replace git.openstack.org URLs with opendev.org URLs
Thorough replacement of git.openstack.org URLs with their opendev.org
counterparts.

Change-Id: I7f5506455ed52e4670b8e428548e931db13b13db
2019-04-24 12:25:40 +08:00
Zuul f9c2af5936 Merge "Add py36 and py37 tox envs" 2019-03-25 07:39:55 +00:00
Zuul 430b218344 Merge "Drop py35 jobs" 2019-03-25 07:34:32 +00:00
manchandavishal f8e0be59a2 Add py36 and py37 tox envs
With python3.6 and python3.7 jobs added to the Zuul jobs, it makes sense
to add this to the tox config too.

Change-Id: Icf4a05048c406250ad6331f5593617471dcba319
2019-03-18 05:48:24 +00:00
Ivan Kolodyazhny 43f8c3b1f5 Switch integration tests to run with python3
tox env for the integration tests is now renamed to 'integration'
as it is no longer run under python 2.7.

__hash__() method is now defined in integration_tests.helpers.BaseTestCase
to avoid unhashable error during loading django test runner. This is
originally caused by the fact that the base testcase class for integration
tests is implemented on top of testtools and testtools does not define
__hash__() method. In Python 3, __hash__() method must be defined
if a class (re)defines __eq__() method to make the class hashable [1].
Ideally integration base TestCase class can be implemented on top of
Django test case, but the current implementation depends on features
from testtools a lot, so it seems better to add __hash__() method
as a workaround.

Unbound methods don't exist in Python 3[2], so six.create_unbound_method
doesn' work as expected. To dynamic method generation we have to use new
descriptors interface [3] or just generate new
functools.partialmethod [4] function introduced in Python 3.4 to
generate class methods with pre-defined 'path' argument and pass 'self'
as a first function argument for class instance.

[1] https://docs.python.org/3.5/reference/datamodel.html#object.__hash__
[2] https://six.readthedocs.io/#six.create_unbound_method
[3] https://docs.python.org/3/howto/descriptor.html
[4] https://docs.python.org/3/library/functools.html#functools.partialmethod

Change-Id: I5c3078bdc66e33fe676d431bb28d92b35faaf479
2019-03-05 09:10:01 +00:00
manchandavishal 096438b647 Drop py35 jobs
Python 3.5 was the target runtime for the Rocky release. The current
target py3 runtime for Stein is Python 3.6, so there is no reason to
keep testing against the older version as mentioned here[1].

[1] https://governance.openstack.org/tc/reference/runtimes/stein.html

Change-Id: Ib585add30e8b34016a4af18d567a3613aaa74241
2019-02-27 16:32:40 +05:30
Akihiro Motoki 220b1346bd Enable pylint in horizon
tests.py files are excluded from targets checked by pylint
because it takes longer and longer time to check them somehow.

pylint 2.2.x is supported only in Python 3 and we already switched
our pep8 basepython to python3, so pylint and astroid are installed
only for python3. This seems the easiest way to ensure py27 env works.

literal-comparison error in openstack_dashboard/api/nova.py
is also fixed in this commit as it is simple enough.

Change-Id: Ic8868a44b296dba457be721716ca6f9d37ad9369
2019-01-12 22:41:20 +09:00