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