Add perltidy to pre-commit linters
[transportpce.git] / tox.ini
1 [tox]
2 minversion = 3.7.0
3 envlist = buildcontroller,testsPCE,
4     sims121,build_karaf_tests121,tests121,
5     sims221,build_karaf_tests221,tests221,tests_tapi,
6     sims71,build_karaf_tests71,tests71,
7     build_karaf_tests_hybrid,tests_hybrid,
8     docs
9     docs-linkcheck
10     checkbashisms
11     pre-commit
12     pylint
13 skipsdist = true
14 setupdir = tests/
15
16 [testenv]
17 passenv = USE_LIGHTY NO_ODL_STARTUP http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY OLM_TIMER1 OLM_TIMER2
18 setenv =
19 #    USE_LIGHTY=True
20     OLM_TIMER1=3000
21     OLM_TIMER2=2000
22
23 usedevelop = true
24 basepython = python3
25 deps =
26   -r{toxinidir}/tests/requirements.txt
27   -r{toxinidir}/tests/test-requirements.txt
28   setuptools>=7.0
29 changedir = {toxinidir}/tests
30 parallel_show_output = true
31
32 [testenv:buildcontroller]
33 whitelist_externals = build_controller.sh
34 commands =
35   ./build_controller.sh
36
37 [testenv:sims121]
38 whitelist_externals = install_honeynode.sh
39 depends = buildcontroller
40 # sims profiles does not strictly depends on buildcontroller
41 # but this dependency avoids race condition in the gate
42 commands =
43   ./install_honeynode.sh 1.2.1
44
45 [testenv:sims221]
46 whitelist_externals = install_honeynode.sh
47 depends = buildcontroller
48 commands =
49   ./install_honeynode.sh 2.2.1
50
51 [testenv:sims71]
52 whitelist_externals = install_honeynode.sh
53 depends = buildcontroller
54 commands =
55   ./install_honeynode.sh 7.1
56
57 [testenv:testsPCE]
58 depends = buildcontroller
59 #the following lines retrieve unofficial package of GNPy with REST support from Orange opensource Gitlab repo
60 setenv =
61     PIP_EXTRA_INDEX_URL = https://gitlab.com/api/v4/projects/33090323/packages/pypi/simple
62 #    USE_LIGHTY=True
63 #    USE_ODL_RESTCONF_VERSION=draft-bierman02
64 deps =
65   -r{toxinidir}/tests/requirements.txt
66   -r{toxinidir}/tests/test-requirements.txt
67   setuptools>=7.0
68   gnpy4tpce==2.4.7
69 whitelist_externals = launch_tests.sh
70 passenv = LAUNCHER USE_LIGHTY NO_ODL_STARTUP USE_ODL_RESTCONF_VERSION
71 basepython = python3
72 commands =
73   ./launch_tests.sh pce {posargs:}
74
75 [testenv:build_karaf_tests121]
76 depends = buildcontroller
77 # testsPCE dependency is only here to chain tests in the gate and avoid resources starvation
78 whitelist_externals = launch_tests.sh
79 passenv = LAUNCHER USE_LIGHTY
80 setenv =
81 #    USE_LIGHTY=True
82     USE_ODL_ALT_KARAF_ENV=./karaf121.env
83     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf121
84 commands =
85   ./build_karaf_for_tests.sh
86
87 [testenv:tests121]
88 depends = buildcontroller,build_karaf_tests121,sims121,testsPCE
89 # testsPCE dependency is only here to chain tests in the gate and avoid resources starvation
90 whitelist_externals = launch_tests.sh
91 passenv = LAUNCHER USE_LIGHTY NO_ODL_STARTUP USE_ODL_RESTCONF_VERSION
92 setenv =
93 #    USE_LIGHTY=True
94 #    USE_ODL_RESTCONF_VERSION=draft-bierman02
95     USE_ODL_ALT_KARAF_ENV=./karaf121.env
96     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf121
97 commands =
98   ./launch_tests.sh 1.2.1 {posargs:}
99 # By default, all tests in the folder transportpce_tests/1.2.1/ are run.
100 # Though, a restricted list of tests can be passed as argument to 'tox -e tests121'.
101 # For example, 'tox -e tests121 portmapping' will run only the portmapping test.
102 # and 'tox -e tests121 "portmapping pce"' will run the portmapping and pce tests.
103 # Additionnally, a different launcher command than 'nosetests --with-xunit' can be
104 # used by exporting the variable LAUNCHER. For example 'export LAUNCHER="python3"'
105 # which is more verbose than nose or 'export LAUNCHER="ls -l"' to only list script
106 # files attributes.
107
108 [testenv:build_karaf_tests221]
109 depends = buildcontroller
110 # testsPCE dependency is only here to chain tests in the gate and avoid resources starvation
111 whitelist_externals = launch_tests.sh
112 passenv = LAUNCHER USE_LIGHTY
113 setenv =
114 #    USE_LIGHTY=True
115     USE_ODL_ALT_KARAF_ENV=./karaf221.env
116     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf221
117 commands =
118   ./build_karaf_for_tests.sh
119
120 [testenv:tests221]
121 depends = buildcontroller,build_karaf_tests221,sims221,tests71
122 # tests71 dependency is only here to chain tests in the gate and avoid ressources starvation
123 whitelist_externals = launch_tests.sh
124 passenv = LAUNCHER USE_LIGHTY NO_ODL_STARTUP USE_ODL_RESTCONF_VERSION
125 setenv =
126 #    USE_LIGHTY=True
127 #    USE_ODL_RESTCONF_VERSION=draft-bierman02
128     USE_ODL_ALT_KARAF_ENV=./karaf221.env
129     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf221
130 commands =
131   ./launch_tests.sh 2.2.1 {posargs:}
132
133 [testenv:build_karaf_tests71]
134 depends = buildcontroller
135 # testsPCE dependency is only here to chain tests in the gate and avoid resources starvation
136 whitelist_externals = launch_tests.sh
137 passenv = LAUNCHER USE_LIGHTY
138 setenv =
139 #    USE_LIGHTY=True
140     USE_ODL_ALT_KARAF_ENV=./karaf71.env
141     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf71
142 commands =
143   ./build_karaf_for_tests.sh
144
145 [testenv:tests71]
146 depends = buildcontroller,build_karaf_tests71,sims71,tests_tapi
147 whitelist_externals = launch_tests.sh
148 passenv = LAUNCHER USE_LIGHTY NO_ODL_STARTUP USE_ODL_RESTCONF_VERSION
149 setenv =
150 #    USE_LIGHTY=True
151 #    USE_ODL_RESTCONF_VERSION=draft-bierman02
152     USE_ODL_ALT_KARAF_ENV=./karaf71.env
153     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf71
154 commands =
155   ./launch_tests.sh 7.1 {posargs:}
156
157 [testenv:build_karaf_tests_hybrid]
158 depends = buildcontroller
159 whitelist_externals = launch_tests.sh
160 passenv = LAUNCHER USE_LIGHTY
161 setenv =
162 #    USE_LIGHTY=True
163     USE_ODL_ALT_KARAF_ENV=./karaf121.env
164     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf_hybrid
165 commands =
166   ./build_karaf_for_tests.sh
167
168 [testenv:tests_hybrid]
169 depends = buildcontroller,build_karaf_tests_hybrid,sims121,sims221,sims71,tests121,tests221,tests71
170 #the last dependency is to avoid temporarily concurrent ressources problem in parallel mode
171 whitelist_externals = launch_tests.sh
172 passenv = LAUNCHER USE_LIGHTY NO_ODL_STARTUP USE_ODL_RESTCONF_VERSION
173 setenv =
174 #    USE_LIGHTY=True
175 #    USE_ODL_RESTCONF_VERSION=draft-bierman02
176     USE_ODL_ALT_KARAF_ENV=./karaf121.env
177     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf_hybrid
178 commands =
179 #  nosetests --with-xunit transportpce_tests/hybrid/test01_device_change_notifications.py
180   ./launch_tests.sh hybrid {posargs:}
181
182 [testenv:tests_tapi]
183 depends = buildcontroller,build_karaf_tests221,sims221
184 whitelist_externals = launch_tests.sh add_tapi_feature_to_tests221.sh
185 passenv = LAUNCHER USE_LIGHTY NO_ODL_STARTUP OLM_TIMER1 OLM_TIMER2 USE_ODL_RESTCONF_VERSION
186 setenv =
187 #    USE_LIGHTY=True
188 #    USE_ODL_RESTCONF_VERSION=draft-bierman02
189     USE_ODL_ALT_KARAF_ENV=./karaf221.env
190     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf221
191     INSTALL_TAPI=True
192     OLM_TIMER1=3000
193     OLM_TIMER2=2000
194
195 commands =
196 #  ./add_tapi_feature_to_tests221.sh
197   ./launch_tests.sh tapi {posargs:}
198
199 [testenv:with_docker]
200 depends = buildcontroller,sims221
201 whitelist_externals = launch_tests.sh
202                       dockercmd.sh
203 passenv = LAUNCHER USE_LIGHTY NO_ODL_STARTUP USE_ODL_RESTCONF_VERSION OLM_TIMER1 OLM_TIMER2
204 setenv =
205     OLM_TIMER1=3000
206     OLM_TIMER2=2000
207     INSTALL_TAPI=True
208     INSTALL_NBINOTIFICATIONS=True
209 #    USE_ODL_RESTCONF_VERSION=draft-bierman02
210
211 commands =
212   ./dockercmd.sh run -d -p 2181:2181 -p 9092:9092 --env ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 --name tpce_kafka1 teivah/kafka:2.0.0
213   ./launch_tests.sh with_docker {posargs:}
214   ./dockercmd.sh container rm -f tpce_kafka1
215
216 [testenv:docs]
217 passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
218 basepython = python3
219 deps = -rdocs/requirements.txt
220 commands =
221     sphinx-build -q -W --keep-going -b html -n -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/html
222
223 [testenv:docs-linkcheck]
224 passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
225 basepython = python3
226 deps = -rdocs/requirements.txt
227 commands = sphinx-build -q -b linkcheck -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/linkcheck
228
229 [testenv:checkbashisms]
230 deps =
231 whitelist_externals = sh
232                       checkbashisms
233                       sudo
234                       find
235 commands =
236     sh -c 'command checkbashisms>/dev/null || sudo yum install -y devscripts-checkbashisms || sudo yum install -y devscripts-minimal || sudo yum install -y devscripts \
237         || sudo yum install -y https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/31/Everything/x86_64/os/Packages/d/devscripts-checkbashisms-2.19.6-2.fc31.x86_64.rpm \
238         || (echo "checkbashisms command not found - please install it \
239              (e.g. sudo apt-get install devscripts | yum install devscripts-minimal )" >&2 && exit 1)'
240     find . -not -path '*/\.*' -name *.sh -exec checkbashisms -f  \{\} +
241
242 [testenv:spelling]
243 basepython = python3
244 deps =
245     -rdocs/requirements.txt
246     sphinxcontrib-spelling
247     PyEnchant
248 commands = sphinx-build -b spelling -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/spelling
249
250 [testenv:autopep8]
251 basepython = python3
252 deps = autopep8
253 commands =
254     autopep8 --max-line-length 120 --in-place --recursive transportpce_tests/
255
256 [testenv:pylint_full]
257 basepython = python3
258 deps = pylint>=2.6.0
259 whitelist_externals = find
260 commands =
261     find transportpce_tests/ -name *.py -exec pylint --fail-under=9.22 --max-line-length=120 --disable=missing-docstring --module-rgx="([a-z0-9_]+$)|([0-9.]{1,30}$)" --method-rgx="(([a-z_][a-zA-Z0-9_]{2,})|(_[a-z0-9_]*)|(__[a-zA-Z][a-zA-Z0-9_]+__))$" --variable-rgx="[a-zA-Z_][a-zA-Z0-9_]{1,30}$" --reports=y --score=y  --output-format=colorized  \{\} +
262
263 [testenv:pylint]
264 basepython = python3
265 deps = pylint>=2.6.0
266 whitelist_externals = find
267 commands =
268     find transportpce_tests/ -name *.py -exec pylint --fail-under=10 --max-line-length=120 --disable=missing-docstring --disable=fixme --disable=duplicate-code --module-rgx="([a-z0-9_]+$)|([0-9.]{1,30}$)" --method-rgx="(([a-z_][a-zA-Z0-9_]{2,})|(_[a-z0-9_]*)|(__[a-zA-Z][a-zA-Z0-9_]+__))$" --variable-rgx="[a-zA-Z_][a-zA-Z0-9_]{1,30}$" \{\} +
269
270 [testenv:pyang]
271 basepython = python3
272 deps = pyang
273 whitelist_externals = find
274 commands =
275     pyang --version
276     find ../api/ -name target -prune -o -name *.yang -exec pyang --lint --canonical --max-line-length=120 -p../api/src/main/yang/:../ordmodels/common/src/main/yang/:../ordmodels/service/src/main/yang/:../tapimodels/src/main/yang/ \{\} +
277 #find ../api/ ../ordmodels/ ../tapimodels/ -name target -prune -o -name *.yang -exec pyang --lint --canonical --max-line-length=120 -p../api/src/main/yang/:../ordmodels/common/src/main/yang/:../ordmodels/service/src/main/yang/:../tapimodels/src/main/yang/ \{\} +
278
279 [testenv:pyangformat]
280 basepython = python3
281 deps = pyang
282 whitelist_externals = sh
283 commands =
284     pyang --version
285     sh -c 'find ../api/ -name target -prune -o -name *.yang -print | while read -r fname; do pyang -f yang --yang-canonical --yang-remove-unused-imports --max-line-length=120 --keep-comments -p../api/src/main/yang/:../ordmodels/common/src/main/yang/:../ordmodels/service/src/main/yang/:../tapimodels/src/main/yang/ "$fname"  -o /tmp/tmpfile.$$ && mv /tmp/tmpfile.$$ "$fname";done'
286
287 [testenv:pre-commit-install]
288 basepython = python3
289 deps = pre-commit
290 commands =
291     pre-commit install
292     pre-commit install --hook-type commit-msg
293
294 [testenv:pre-commit-uninstall]
295 basepython = python3
296 deps = pre-commit
297 commands =
298     pre-commit uninstall
299     pre-commit uninstall --hook-type commit-msg
300
301 [testenv:pre-commit-autoupdate]
302 basepython = python3
303 deps = pre-commit
304 commands =
305     pre-commit autoupdate
306
307 [testenv:pre-commit]
308 basepython = python3
309 deps = pre-commit
310 passenv = HOME
311 commands =
312     pre-commit run --all-files --show-diff-on-failure
313     pre-commit run gitlint-ci --hook-stage manual
314
315 [testenv:gitlint]
316 basepython = python3
317 deps = gitlint
318 commands =
319     gitlint --config ../.gitlint
320
321
322 [testenv:allure-report-init]
323 basepython = python3
324 deps = allure-pytest>=2.10.0
325 # allure is under Apache License 2.0
326 whitelist_externals =
327     mkdir
328     sed
329 commands =
330     mkdir -p allure-report
331     sed -i_ '$a\allure-pytest # Apache License 2.0' ./test-requirements.txt
332
333
334 [testenv:allure-report-serve]
335 basepython = python3
336 whitelist_externals =
337     allure
338 commands =
339     allure serve "allure-report"