diff options
author | Alberto Contreras <alberto.contreras@canonical.com> | 2022-07-07 01:23:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-06 17:23:00 -0600 |
commit | c58ea03114838341a1c4bd99a91da5c1b98f4cef (patch) | |
tree | c84385d9a98762f53df27650fd29832130d37e07 /tox.ini | |
parent | 4970f3b9f5a4c3f48e445ef7bcc2c73bd924315e (diff) | |
download | cloud-init-git-c58ea03114838341a1c4bd99a91da5c1b98f4cef.tar.gz |
Fuzz testing jsonchema (#1499)
- Add `hypothesis` and `hypothesis-jsonschema`
- Add `hypothesis-slow` tox env to run slow tests
- Implement `JsonLocalResolver` to avoid `hypothesis-jsonschema` errors
- Add fuzz test covering `validate_cloudconfig_schema`
Diffstat (limited to 'tox.ini')
-rw-r--r-- | tox.ini | 50 |
1 files changed, 37 insertions, 13 deletions
@@ -1,5 +1,13 @@ [tox] -envlist = py3, lowest-supported-dev, black, flake8, isort, mypy, pylint +envlist = + py3, + lowest-supported-dev, + hypothesis-slow, + black, + flake8, + isort, + mypy, + pylint recreate = True [doc8] @@ -15,6 +23,8 @@ passenv= [format_deps] black==22.3.0 flake8==4.0.1 +hypothesis==6.31.6 +hypothesis_jsonschema==0.20.1 isort==5.10.1 mypy==0.950 pylint==2.13.9 @@ -49,19 +59,23 @@ commands = {envpython} -m isort . --check-only [testenv:mypy] deps = + hypothesis=={[format_deps]hypothesis} + hypothesis_jsonschema=={[format_deps]hypothesis_jsonschema} mypy=={[format_deps]mypy} + pytest=={[format_deps]pytest} types-jsonschema=={[format_deps]types-jsonschema} types-oauthlib=={[format_deps]types-oauthlib} types-pyyaml=={[format_deps]types-PyYAML} types-requests=={[format_deps]types-requests} types-setuptools=={[format_deps]types-setuptools} - pytest=={[format_deps]pytest} commands = {envpython} -m mypy cloudinit/ tests/ tools/ [testenv:check_format] deps = black=={[format_deps]black} flake8=={[format_deps]flake8} + hypothesis=={[format_deps]hypothesis} + hypothesis_jsonschema=={[format_deps]hypothesis_jsonschema} isort=={[format_deps]isort} mypy=={[format_deps]mypy} pylint=={[format_deps]pylint} @@ -118,8 +132,17 @@ deps = -r{toxinidir}/test-requirements.txt commands = {envpython} -m pytest \ --durations 10 \ - {posargs:--cov=cloudinit --cov-branch \ - tests/unittests} + -m "not hypothesis_slow" \ + {posargs:--cov=cloudinit --cov-branch tests/unittests} + +[testenv:hypothesis-slow] +deps = + hypothesis==6.31.6 + hypothesis_jsonschema==0.20.1 + -r{toxinidir}/test-requirements.txt +commands = {envpython} -m pytest \ + -m hypothesis_slow \ + {posargs:--hypothesis-show-statistics tests/unittests} [lowest-supported-deps] # Tox is going to install requirements from pip. This is fine for @@ -257,25 +280,26 @@ addopts = --strict log_format = %(asctime)s %(levelname)-9s %(name)s:%(filename)s:%(lineno)d %(message)s log_date_format = %Y-%m-%d %H:%M:%S markers = - allow_subp_for: allow subp usage for the given commands (disable_subp_usage) + adhoc: only run on adhoc basis, not in any CI environment (travis or jenkins) allow_all_subp: allow all subp usage (disable_subp_usage) + allow_subp_for: allow subp usage for the given commands (disable_subp_usage) + azure: test will only run on Azure platform ci: run this integration test as part of CI test runs ds_sys_cfg: a sys_cfg dict to be used by datasource fixtures ec2: test will only run on EC2 platform gce: test will only run on GCE platform - azure: test will only run on Azure platform - oci: test will only run on OCI platform - openstack: test will only run on openstack platform + hypothesis_slow: hypothesis test too slow to run as unit test + instance_name: the name to be used for the test instance + is_iscsi: whether is an instance has iscsi net cfg or not lxd_config_dict: set the config_dict passed on LXD instance creation lxd_container: test will only run in LXD container lxd_setup: specify callable to be called between init and start lxd_use_exec: `execute` will use `lxc exec` instead of SSH lxd_vm: test will only run in LXD VM - not_bionic: test cannot run on the bionic release no_container: test cannot run in a container - user_data: the user data to be passed to the test instance - instance_name: the name to be used for the test instance + not_bionic: test cannot run on the bionic release + oci: test will only run on OCI platform + openstack: test will only run on openstack platform ubuntu: this test should run on Ubuntu unstable: skip this test because it is flakey - adhoc: only run on adhoc basis, not in any CI environment (travis or jenkins) - is_iscsi: whether is an instance has iscsi net cfg or not + user_data: the user data to be passed to the test instance |