Add tests for autonomous service rerouting
[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     gitlint
13     pylint
14 skipsdist = true
15 setupdir = tests/
16
17 [testenv]
18 passenv = USE_LIGHTY http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY OLM_TIMER1 OLM_TIMER2
19 setenv =
20 #    USE_LIGHTY=True
21     OLM_TIMER1=3000
22     OLM_TIMER2=2000
23
24 usedevelop = true
25 basepython = python3
26 deps =
27   -r{toxinidir}/tests/requirements.txt
28   -r{toxinidir}/tests/test-requirements.txt
29   setuptools>=7.0
30 changedir = {toxinidir}/tests
31 parallel_show_output = true
32
33 [testenv:buildcontroller]
34 whitelist_externals = build_controller.sh
35 commands =
36   ./build_controller.sh
37
38 [testenv:sims121]
39 whitelist_externals = install_honeynode.sh
40 depends = buildcontroller
41 # sims profiles does not strictly depends on buildcontroller
42 # but this dependency avoids race condition in the gate
43 commands =
44   ./install_honeynode.sh 1.2.1
45
46 [testenv:sims221]
47 whitelist_externals = install_honeynode.sh
48 depends = buildcontroller
49 commands =
50   ./install_honeynode.sh 2.2.1
51
52 [testenv:sims71]
53 whitelist_externals = install_honeynode.sh
54 depends = buildcontroller
55 commands =
56   ./install_honeynode.sh 7.1
57
58 [testenv:testsPCE]
59 depends = buildcontroller
60 #the following lines retrieve unofficial package of GNPy with REST support from Orange opensource Gitlab repo
61 setenv =
62     PIP_EXTRA_INDEX_URL = https://gitlab.com/api/v4/projects/33090323/packages/pypi/simple
63 #    USE_LIGHTY=True
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 USE_ODL_RESTCONF_VERSION
71 basepython = python3.8
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 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 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 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 # testsPCE dependency is only here to chain tests in the gate and avoid resources starvation
160 whitelist_externals = launch_tests.sh
161 passenv = LAUNCHER USE_LIGHTY
162 setenv =
163 #    USE_LIGHTY=True
164     USE_ODL_ALT_KARAF_ENV=./karaf121.env
165     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf_hybrid
166 commands =
167   ./build_karaf_for_tests.sh
168
169 [testenv:tests_hybrid]
170 depends = buildcontroller,build_karaf_tests_hybrid,sims121,sims221,sims71,tests121,tests221,tests71
171 #the last dependency is to avoid temporarily concurrent ressources problem in parallel mode
172 whitelist_externals = launch_tests.sh
173 passenv = LAUNCHER USE_LIGHTY USE_ODL_RESTCONF_VERSION
174 setenv =
175 #    USE_LIGHTY=True
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
185 passenv = LAUNCHER USE_LIGHTY 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   ./launch_tests.sh tapi {posargs:}
197
198 [testenv:nbinotifications]
199 depends = buildcontroller,sims221
200 whitelist_externals = launch_tests.sh
201                       dockercmd.sh
202 passenv = LAUNCHER USE_LIGHTY USE_ODL_RESTCONF_VERSION OLM_TIMER1 OLM_TIMER2
203 setenv =
204     OLM_TIMER1=3000
205     OLM_TIMER2=2000
206     INSTALL_NBINOTIFICATIONS=True
207
208 commands =
209   ./dockercmd.sh run -d -p 2181:2181 -p 9092:9092 --env ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 --name tpce_kafka1 teivah/kafka:2.0.0
210   ./launch_tests.sh with_docker nbinotifications
211   ./dockercmd.sh container rm -f tpce_kafka1
212
213 [testenv:docs]
214 passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
215 basepython = python3
216 deps = -rdocs/requirements.txt
217 commands =
218     sphinx-build -q -W --keep-going -b html -n -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/html
219
220 [testenv:docs-linkcheck]
221 passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
222 basepython = python3
223 deps = -rdocs/requirements.txt
224 commands = sphinx-build -q -b linkcheck -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/linkcheck
225
226 [testenv:checkbashisms]
227 deps =
228 whitelist_externals = sh
229                       checkbashisms
230                       sudo
231                       find
232 commands =
233     sh -c 'command checkbashisms>/dev/null || sudo yum install devscripts-minimal || (echo "checkbashisms command not found - please install it (e.g. sudo apt-get install devscripts | yum install devscripts-minimal )" >&2 && exit 1)'
234     find . -not -path '*/\.*' -name *.sh -exec checkbashisms -f  \{\} +
235
236 [testenv:spelling]
237 basepython = python3
238 deps =
239     -rdocs/requirements.txt
240     sphinxcontrib-spelling
241     PyEnchant
242 commands = sphinx-build -b spelling -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/spelling
243
244 [testenv:autopep8]
245 basepython = python3
246 deps = autopep8
247 commands =
248     autopep8 --max-line-length 120 --in-place --recursive transportpce_tests/
249
250 [testenv:pylint_full]
251 basepython = python3
252 deps = pylint>=2.6.0
253 whitelist_externals = find
254 commands =
255     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  \{\} +
256
257 [testenv:pylint]
258 basepython = python3
259 deps = pylint>=2.6.0
260 whitelist_externals = find
261 commands =
262     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}$" \{\} +
263
264 [testenv:pyang]
265 basepython = python3
266 deps = pyang
267 whitelist_externals = find
268 commands =
269     pyang --version
270     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/ \{\} +
271 #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/ \{\} +
272
273 [testenv:pyangformat]
274 basepython = python3
275 deps = pyang
276 whitelist_externals = sh
277 commands =
278     pyang --version
279     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'
280
281 [testenv:pre-commit-install]
282 basepython = python3
283 deps = pre-commit
284 commands =
285     pre-commit install
286     pre-commit install --hook-type commit-msg
287
288 [testenv:pre-commit-uninstall]
289 basepython = python3
290 deps = pre-commit
291 commands =
292     pre-commit uninstall
293     pre-commit uninstall --hook-type commit-msg
294
295 [testenv:pre-commit-autoupdate]
296 basepython = python3
297 deps = pre-commit
298 commands =
299     pre-commit autoupdate
300
301 [testenv:pre-commit]
302 basepython = python3
303 deps = pre-commit
304 passenv = HOME
305 commands =
306     pre-commit run --all-files --show-diff-on-failure
307     pre-commit run gitlint --hook-stage commit-msg --commit-msg-filename .git/COMMIT_EDITMSG
308     # Gitlint only proposes a pre-commit configuration for the commit-msg stage but none for the commit stage.
309     # Its default arguments --passed and --msg-filename are different from CI recommandations.
310     # As a result, the line above is always skipped in jenkins CI since there cannot be a .git/COMMIT_EDITMSG file.
311     # A dedicated gitlint profile for CI is proposed below. Also to behave fine locally, this profile must have access
312     # to the HOME variable so that Gitlint can retrieve Git user settings.
313
314 [testenv:gitlint]
315 basepython = python3
316 deps = gitlint
317 commands =
318     gitlint --config ../.gitlint
319