2f79e58107334b5b0ea2c5728aabdd4fbc3aa29e
[transportpce.git] / tox.ini
1 [tox]
2 minversion = 3.7.0
3 envlist = buildcontroller
4      testsPCE
5      sims121
6      build_karaf_tests121
7      tests121
8      sims221
9      build_karaf_tests221
10      tests_tapi
11      tests221
12      sims71
13      build_karaf_tests71
14      tests71
15      build_karaf_tests_hybrid
16      tests_hybrid
17      buildlighty
18      docs
19      docs-linkcheck
20      checkbashisms
21      pre-commit
22      pylint
23 skipsdist = true
24 setupdir = tests/
25
26 [testenv]
27 passenv = LAUNCHER
28      USE_LIGHTY
29      USE_SIMS
30      NO_ODL_STARTUP
31      http_proxy
32      HTTP_PROXY
33      https_proxy
34      HTTPS_PROXY
35      no_proxy
36      NO_PROXY
37      OLM_TIMER1
38      OLM_TIMER2
39 setenv =
40 #    USE_LIGHTY=True,
41     OLM_TIMER1=3000
42     OLM_TIMER2=2000
43
44 usedevelop = true
45 basepython = python3
46 deps =
47   -r{toxinidir}/tests/requirements.txt
48   -r{toxinidir}/tests/test-requirements.txt
49   setuptools>=7.0
50 changedir = {toxinidir}/tests
51 parallel_show_output = true
52
53 [testenv:buildcontroller]
54 allowlist_externals = build_controller.sh
55 commands =
56   ./build_controller.sh
57
58 [testenv:buildlighty]
59 allowlist_externals = build.sh
60 depends = buildcontroller,tests_hybrid
61 changedir = {toxinidir}/lighty
62 commands =
63   ./build.sh
64
65 [testenv:sims]
66 passenv = USE_SIMS
67 allowlist_externals = install_lightynode.sh
68 depends = buildcontroller
69 commands =
70   ./install_lightynode.sh {posargs:}
71
72 [testenv:sims121]
73 passenv = USE_SIMS
74 allowlist_externals = install_sims.sh
75 depends = buildcontroller
76 # sims profiles does not strictly depends on buildcontroller
77 # but this dependency avoids race condition in the gate
78 commands =
79   ./install_sims.sh 1.2.1
80
81 [testenv:sims221]
82 passenv = USE_SIMS
83 allowlist_externals = install_sims.sh
84 depends = buildcontroller
85 commands =
86   ./install_sims.sh 2.2.1
87
88 [testenv:sims71]
89 passenv = USE_SIMS
90 allowlist_externals = install_sims.sh
91 depends = buildcontroller
92 commands =
93   ./install_sims.sh 7.1
94
95 [testenv:testsPCE]
96 depends = buildcontroller
97 #the following lines retrieve unofficial package of GNPy with REST support from Orange opensource Gitlab repo
98 setenv =
99     PIP_EXTRA_INDEX_URL = https://gitlab.com/api/v4/projects/33090323/packages/pypi/simple
100 #    USE_LIGHTY=True
101 #    USE_ODL_RESTCONF_VERSION=draft-bierman02
102 deps =
103   -r{toxinidir}/tests/requirements.txt
104   -r{toxinidir}/tests/test-requirements.txt
105   setuptools>=7.0
106   gnpy4tpce==2.4.7
107 allowlist_externals = launch_tests.sh
108 passenv = LAUNCHER
109     USE_LIGHTY
110     NO_ODL_STARTUP
111     USE_ODL_RESTCONF_VERSION
112 basepython = python3
113 commands =
114   ./launch_tests.sh pce {posargs:}
115
116 [testenv:build_karaf_tests121]
117 depends = buildcontroller
118 # testsPCE dependency is only here to chain tests in the gate and avoid resources starvation
119 allowlist_externals = launch_tests.sh
120 passenv = USE_LIGHTY
121 setenv =
122 #    USE_LIGHTY=True
123     USE_ODL_ALT_KARAF_ENV=./karaf121.env
124     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf121
125 commands =
126   ./build_karaf_for_tests.sh
127
128 [testenv:tests121]
129 depends = buildcontroller,build_karaf_tests121,sims121,testsPCE
130 # testsPCE dependency is only here to chain tests in the gate and avoid resources starvation
131 allowlist_externals = launch_tests.sh
132 passenv = LAUNCHER
133     USE_LIGHTY
134     USE_SIMS
135     USE_ODL_RESTCONF_VERSION
136 setenv =
137 #    USE_LIGHTY=True
138 #    USE_ODL_RESTCONF_VERSION=draft-bierman02
139     USE_ODL_ALT_KARAF_ENV=./karaf121.env
140     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf121
141 commands =
142   ./launch_tests.sh 1.2.1 {posargs:}
143 # By default, all tests in the folder transportpce_tests/1.2.1/ are run.
144 # Though, a restricted list of tests can be passed as argument to 'tox -e tests121'.
145 # For example, 'tox -e tests121 portmapping' will run only the portmapping test.
146 # and 'tox -e tests121 "portmapping pce"' will run the portmapping and pce tests.
147 # Additionnally, a different launcher command than 'nosetests --with-xunit' can be
148 # used by exporting the variable LAUNCHER. For example 'export LAUNCHER="python3"'
149 # which is more verbose than nose or 'export LAUNCHER="ls -l"' to only list script
150 # files attributes.
151
152 [testenv:build_karaf_tests221]
153 depends = buildcontroller
154 # testsPCE dependency is only here to chain tests in the gate and avoid resources starvation
155 allowlist_externals = launch_tests.sh
156 passenv = USE_LIGHTY
157 setenv =
158 #    USE_LIGHTY=True
159     USE_ODL_ALT_KARAF_ENV=./karaf221.env
160     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf221
161 commands =
162   ./build_karaf_for_tests.sh
163
164 [testenv:launch]
165 depends = buildcontroller,build_karaf_tests221,sims,tests71
166 # tests71 dependency is only here to chain tests in the gate and avoid ressources starvation
167 allowlist_externals = launch.sh
168 passenv = LAUNCHER
169     USE_LIGHTY
170     NO_ODL_STARTUP
171     USE_ODL_RESTCONF_VERSION
172 setenv =
173 #    USE_LIGHTY=True
174 #    USE_ODL_RESTCONF_VERSION=draft-bierman02
175     USE_ODL_ALT_KARAF_ENV=./karaf221.env
176     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf221
177 commands =
178   ./launch.sh
179
180
181 [testenv:tests221]
182 depends = buildcontroller,build_karaf_tests221,sims221,tests71
183 # tests71 dependency is only here to chain tests in the gate and avoid ressources starvation
184 allowlist_externals = launch_tests.sh
185 passenv = LAUNCHER
186     USE_LIGHTY
187     USE_SIMS
188     NO_ODL_STARTUP
189     USE_ODL_RESTCONF_VERSION
190 setenv =
191 #    USE_LIGHTY=True
192 #    USE_ODL_RESTCONF_VERSION=draft-bierman02
193     USE_ODL_ALT_KARAF_ENV=./karaf221.env
194     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf221
195 commands =
196   ./launch_tests.sh 2.2.1 {posargs:}
197
198 [testenv:build_karaf_tests71]
199 depends = buildcontroller
200 # testsPCE dependency is only here to chain tests in the gate and avoid resources starvation
201 allowlist_externals = launch_tests.sh
202 passenv = USE_LIGHTY
203 setenv =
204 #    USE_LIGHTY=True
205     USE_ODL_ALT_KARAF_ENV=./karaf71.env
206     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf71
207 commands =
208   ./build_karaf_for_tests.sh
209
210 [testenv:tests71]
211 depends = buildcontroller,build_karaf_tests71,sims71,tests_tapi
212 allowlist_externals = launch_tests.sh install_honeynode.sh
213 passenv = LAUNCHER
214     USE_LIGHTY
215     NO_ODL_STARTUP
216     USE_ODL_RESTCONF_VERSION
217 setenv =
218 #    USE_LIGHTY=True
219 #    USE_ODL_RESTCONF_VERSION=draft-bierman02
220     USE_SIMS=honeynode
221     USE_ODL_ALT_KARAF_ENV=./karaf71.env
222     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf71
223 commands =
224   ./install_honeynode.sh 7.1
225   ./launch_tests.sh 7.1 {posargs:}
226
227 [testenv:build_karaf_tests_hybrid]
228 depends = buildcontroller
229 allowlist_externals = launch_tests.sh
230 passenv = USE_LIGHTY
231 setenv =
232 #    USE_LIGHTY=True
233     USE_ODL_ALT_KARAF_ENV=./karaf121.env
234     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf_hybrid
235 commands =
236   ./build_karaf_for_tests.sh
237
238 [testenv:tests_hybrid]
239 depends = buildcontroller,build_karaf_tests_hybrid,sims121,sims221,sims71,tests121,tests221,tests71
240 #the last dependency is to avoid temporarily concurrent ressources problem in parallel mode
241 allowlist_externals = launch_tests.sh install_honeynode.sh
242 passenv = LAUNCHER
243     USE_LIGHTY
244     USE_SIMS
245     NO_ODL_STARTUP
246     USE_ODL_RESTCONF_VERSION
247 setenv =
248     USE_SIMS=honeynode
249 #    USE_LIGHTY=True
250 #    USE_ODL_RESTCONF_VERSION=draft-bierman02
251     USE_ODL_ALT_KARAF_ENV=./karaf121.env
252     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf_hybrid
253 commands =
254 #  nosetests --with-xunit transportpce_tests/hybrid/test01_device_change_notifications.py
255   ./install_honeynode.sh
256   ./launch_tests.sh hybrid {posargs:}
257
258 [testenv:tests_tapi]
259 depends = buildcontroller,build_karaf_tests221,sims221
260 allowlist_externals = launch_tests.sh
261 #                      add_tapi_feature_to_tests221.sh
262 passenv = LAUNCHER
263     USE_LIGHTY
264     USE_SIMS
265     NO_ODL_STARTUP
266     OLM_TIMER1
267     OLM_TIMER2
268     USE_ODL_RESTCONF_VERSION
269 setenv =
270 #    USE_LIGHTY=True
271 #    USE_ODL_RESTCONF_VERSION=draft-bierman02
272     USE_ODL_ALT_KARAF_ENV=./karaf221.env
273     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf221
274     INSTALL_TAPI=True
275     OLM_TIMER1=3000
276     OLM_TIMER2=2000
277
278 commands =
279 #  ./add_tapi_feature_to_tests221.sh
280   ./launch_tests.sh tapi {posargs:}
281
282 [testenv:with_docker]
283 depends = buildcontroller,sims221
284 allowlist_externals = launch_tests.sh dockercmd.sh install_honeynode.sh
285 passenv = LAUNCHER
286     USE_LIGHTY
287     NO_ODL_STARTUP
288     USE_ODL_RESTCONF_VERSION
289 #    OLM_TIMER1
290 #    OLM_TIMER2
291 setenv =
292     USE_SIMS=honeynode
293     OLM_TIMER1=3000
294     OLM_TIMER2=2000
295     INSTALL_TAPI=True
296     INSTALL_NBINOTIFICATIONS=True
297 #    USE_ODL_RESTCONF_VERSION=draft-bierman02
298
299 commands =
300   ./install_honeynode.sh 2.2.1
301   ./dockercmd.sh run -d -p 2181:2181 -p 9092:9092 --env ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 --name tpce_kafka1 teivah/kafka:2.0.0
302   ./launch_tests.sh with_docker {posargs:}
303   ./dockercmd.sh container rm -f tpce_kafka1
304
305 [testenv:docs]
306 passenv = http_proxy
307     HTTP_PROXY
308     https_proxy
309     HTTPS_PROXY
310     no_proxy
311     NO_PROXY
312 basepython = python3
313 deps = -rdocs/requirements.txt
314 commands =
315     sphinx-build -q -W --keep-going -b html -n -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/html
316
317 [testenv:docs-linkcheck]
318 passenv = http_proxy
319     HTTP_PROXY
320     https_proxy
321     HTTPS_PROXY
322     no_proxy
323     NO_PROXY
324 basepython = python3
325 deps = -rdocs/requirements.txt
326 commands = sphinx-build -q -b linkcheck -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/linkcheck
327
328 [testenv:checkbashisms]
329 deps =
330 allowlist_externals = sh
331                       checkbashisms
332                       sudo
333                       find
334 commands =
335     sh -c 'command checkbashisms>/dev/null || sudo yum install -y devscripts-checkbashisms || sudo yum install -y devscripts-minimal || sudo yum install -y devscripts \
336         || 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 \
337         || (echo "checkbashisms command not found - please install it \
338              (e.g. sudo apt-get install devscripts | yum install devscripts-minimal )" >&2 && exit 1)'
339     find . -not -path '*/\.*' -name *.sh -exec checkbashisms -f  \{\} +
340
341 [testenv:spelling]
342 basepython = python3
343 deps =
344     -rdocs/requirements.txt
345     sphinxcontrib-spelling
346     PyEnchant
347 commands = sphinx-build -b spelling -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/spelling
348
349 [testenv:autopep8]
350 basepython = python3
351 deps = autopep8
352 commands =
353     autopep8 --max-line-length 120 --in-place --recursive transportpce_tests/
354
355 [testenv:pylint_full]
356 basepython = python3
357 deps = pylint>=2.6.0
358 allowlist_externals = find
359 commands =
360     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  \{\} +
361
362 [testenv:pylint]
363 basepython = python3
364 deps = pylint>=2.6.0
365 allowlist_externals = find
366 commands =
367     find transportpce_tests/ -name *.py -exec pylint --fail-under=10 --max-line-length=120 --disable=missing-docstring,import-error --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}$" \{\} +
368
369 [testenv:pyang]
370 basepython = python3
371 deps = pyang
372 allowlist_externals = find
373 commands =
374     pyang --version
375     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/ \{\} +
376 #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/ \{\} +
377
378 [testenv:pyangformat]
379 basepython = python3
380 deps = pyang
381 allowlist_externals = sh
382 commands =
383     pyang --version
384     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'
385
386 [testenv:pre-commit-install]
387 basepython = python3
388 deps = pre-commit
389 commands =
390     pre-commit install
391     pre-commit install --hook-type commit-msg
392
393 [testenv:pre-commit-uninstall]
394 basepython = python3
395 deps = pre-commit
396 commands =
397     pre-commit uninstall
398     pre-commit uninstall --hook-type commit-msg
399
400 [testenv:pre-commit-autoupdate]
401 basepython = python3
402 deps = pre-commit
403 commands =
404     pre-commit autoupdate
405
406 [testenv:pre-commit]
407 basepython = python3
408 deps = pre-commit
409 passenv = HOME
410 commands =
411     pre-commit run --all-files --show-diff-on-failure
412     pre-commit run gitlint-ci --hook-stage manual
413
414 [testenv:gitlint]
415 basepython = python3
416 deps = gitlint
417 commands =
418     gitlint --config ../.gitlint
419
420 [testenv:allure-report-init]
421 basepython = python3
422 deps = allure-pytest>=2.10.0
423 # allure is under Apache License 2.0
424 allowlist_externals =
425     mkdir
426     sed
427 commands =
428     mkdir -p allure-report
429     sed -i_ '$a\allure-pytest # Apache License 2.0' ./test-requirements.txt
430
431 [testenv:allure-report-serve]
432 basepython = python3
433 allowlist_externals =
434     allure
435 commands =
436     allure serve "allure-report"