Shift tox nbinotifications to with_docker profile
[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     USE_ODL_RESTCONF_VERSION=draft-bierman02
65 deps =
66   -r{toxinidir}/tests/requirements.txt
67   -r{toxinidir}/tests/test-requirements.txt
68   setuptools>=7.0
69   gnpy4tpce==2.4.7
70 whitelist_externals = launch_tests.sh
71 passenv = LAUNCHER USE_LIGHTY USE_ODL_RESTCONF_VERSION
72 basepython = python3
73 commands =
74   ./launch_tests.sh pce {posargs:}
75
76 [testenv:build_karaf_tests121]
77 depends = buildcontroller
78 # testsPCE dependency is only here to chain tests in the gate and avoid resources starvation
79 whitelist_externals = launch_tests.sh
80 passenv = LAUNCHER USE_LIGHTY
81 setenv =
82 #    USE_LIGHTY=True
83     USE_ODL_ALT_KARAF_ENV=./karaf121.env
84     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf121
85 commands =
86   ./build_karaf_for_tests.sh
87
88 [testenv:tests121]
89 depends = buildcontroller,build_karaf_tests121,sims121,testsPCE
90 # testsPCE dependency is only here to chain tests in the gate and avoid resources starvation
91 whitelist_externals = launch_tests.sh
92 passenv = LAUNCHER USE_LIGHTY USE_ODL_RESTCONF_VERSION
93 setenv =
94 #    USE_LIGHTY=True
95     USE_ODL_RESTCONF_VERSION=draft-bierman02
96     USE_ODL_ALT_KARAF_ENV=./karaf121.env
97     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf121
98 commands =
99   ./launch_tests.sh 1.2.1 {posargs:}
100 # By default, all tests in the folder transportpce_tests/1.2.1/ are run.
101 # Though, a restricted list of tests can be passed as argument to 'tox -e tests121'.
102 # For example, 'tox -e tests121 portmapping' will run only the portmapping test.
103 # and 'tox -e tests121 "portmapping pce"' will run the portmapping and pce tests.
104 # Additionnally, a different launcher command than 'nosetests --with-xunit' can be
105 # used by exporting the variable LAUNCHER. For example 'export LAUNCHER="python3"'
106 # which is more verbose than nose or 'export LAUNCHER="ls -l"' to only list script
107 # files attributes.
108
109 [testenv:build_karaf_tests221]
110 depends = buildcontroller
111 # testsPCE dependency is only here to chain tests in the gate and avoid resources starvation
112 whitelist_externals = launch_tests.sh
113 passenv = LAUNCHER USE_LIGHTY
114 setenv =
115 #    USE_LIGHTY=True
116     USE_ODL_ALT_KARAF_ENV=./karaf221.env
117     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf221
118 commands =
119   ./build_karaf_for_tests.sh
120
121 [testenv:tests221]
122 depends = buildcontroller,build_karaf_tests221,sims221,tests71
123 # tests71 dependency is only here to chain tests in the gate and avoid ressources starvation
124 whitelist_externals = launch_tests.sh
125 passenv = LAUNCHER USE_LIGHTY USE_ODL_RESTCONF_VERSION
126 setenv =
127 #    USE_LIGHTY=True
128     USE_ODL_RESTCONF_VERSION=draft-bierman02
129     USE_ODL_ALT_KARAF_ENV=./karaf221.env
130     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf221
131 commands =
132   ./launch_tests.sh 2.2.1 {posargs:}
133
134 [testenv:build_karaf_tests71]
135 depends = buildcontroller
136 # testsPCE dependency is only here to chain tests in the gate and avoid resources starvation
137 whitelist_externals = launch_tests.sh
138 passenv = LAUNCHER USE_LIGHTY
139 setenv =
140 #    USE_LIGHTY=True
141     USE_ODL_ALT_KARAF_ENV=./karaf71.env
142     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf71
143 commands =
144   ./build_karaf_for_tests.sh
145
146 [testenv:tests71]
147 depends = buildcontroller,build_karaf_tests71,sims71,tests_tapi
148 whitelist_externals = launch_tests.sh
149 passenv = LAUNCHER USE_LIGHTY USE_ODL_RESTCONF_VERSION
150 setenv =
151 #    USE_LIGHTY=True
152     USE_ODL_RESTCONF_VERSION=draft-bierman02
153     USE_ODL_ALT_KARAF_ENV=./karaf71.env
154     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf71
155 commands =
156   ./launch_tests.sh 7.1 {posargs:}
157
158 [testenv:build_karaf_tests_hybrid]
159 depends = buildcontroller
160 # testsPCE dependency is only here to chain tests in the gate and avoid resources starvation
161 whitelist_externals = launch_tests.sh
162 passenv = LAUNCHER USE_LIGHTY
163 setenv =
164 #    USE_LIGHTY=True
165 #    USE_ODL_RESTCONF_VERSION=draft-bierman02
166     USE_ODL_ALT_KARAF_ENV=./karaf121.env
167     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf_hybrid
168 commands =
169   ./build_karaf_for_tests.sh
170
171 [testenv:tests_hybrid]
172 depends = buildcontroller,build_karaf_tests_hybrid,sims121,sims221,sims71,tests121,tests221,tests71
173 #the last dependency is to avoid temporarily concurrent ressources problem in parallel mode
174 whitelist_externals = launch_tests.sh
175 passenv = LAUNCHER USE_LIGHTY USE_ODL_RESTCONF_VERSION
176 setenv =
177 #    USE_LIGHTY=True
178     USE_ODL_RESTCONF_VERSION=draft-bierman02
179     USE_ODL_ALT_KARAF_ENV=./karaf121.env
180     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf_hybrid
181 commands =
182 #  nosetests --with-xunit transportpce_tests/hybrid/test01_device_change_notifications.py
183   ./launch_tests.sh hybrid {posargs:}
184
185 [testenv:tests_tapi]
186 depends = buildcontroller,build_karaf_tests221,sims221
187 whitelist_externals = launch_tests.sh
188 passenv = LAUNCHER USE_LIGHTY OLM_TIMER1 OLM_TIMER2 USE_ODL_RESTCONF_VERSION
189 setenv =
190 #    USE_LIGHTY=True
191     USE_ODL_RESTCONF_VERSION=draft-bierman02
192     USE_ODL_ALT_KARAF_ENV=./karaf221.env
193     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf221
194     INSTALL_TAPI=True
195     OLM_TIMER1=3000
196     OLM_TIMER2=2000
197
198 commands =
199   ./launch_tests.sh tapi {posargs:}
200
201 [testenv:with_docker]
202 depends = buildcontroller,sims221
203 whitelist_externals = launch_tests.sh
204                       dockercmd.sh
205 passenv = LAUNCHER USE_LIGHTY USE_ODL_RESTCONF_VERSION OLM_TIMER1 OLM_TIMER2
206 setenv =
207     OLM_TIMER1=3000
208     OLM_TIMER2=2000
209     INSTALL_TAPI=True
210     INSTALL_NBINOTIFICATIONS=True
211
212 commands =
213   ./dockercmd.sh run -d -p 2181:2181 -p 9092:9092 --env ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 --name tpce_kafka1 teivah/kafka:2.0.0
214   ./launch_tests.sh with_docker {posargs:}
215   ./dockercmd.sh container rm -f tpce_kafka1
216
217 [testenv:docs]
218 passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
219 basepython = python3
220 deps = -rdocs/requirements.txt
221 commands =
222     sphinx-build -q -W --keep-going -b html -n -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/html
223
224 [testenv:docs-linkcheck]
225 passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
226 basepython = python3
227 deps = -rdocs/requirements.txt
228 commands = sphinx-build -q -b linkcheck -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/linkcheck
229
230 [testenv:checkbashisms]
231 deps =
232 whitelist_externals = sh
233                       checkbashisms
234                       sudo
235                       find
236 commands =
237     sh -c 'command checkbashisms>/dev/null || sudo yum install -y devscripts-checkbashisms || sudo yum install -y devscripts-minimal || sudo yum install -y devscripts \
238         || 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 \
239         || (echo "checkbashisms command not found - please install it \
240              (e.g. sudo apt-get install devscripts | yum install devscripts-minimal )" >&2 && exit 1)'
241     find . -not -path '*/\.*' -name *.sh -exec checkbashisms -f  \{\} +
242
243 [testenv:spelling]
244 basepython = python3
245 deps =
246     -rdocs/requirements.txt
247     sphinxcontrib-spelling
248     PyEnchant
249 commands = sphinx-build -b spelling -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/spelling
250
251 [testenv:autopep8]
252 basepython = python3
253 deps = autopep8
254 commands =
255     autopep8 --max-line-length 120 --in-place --recursive transportpce_tests/
256
257 [testenv:pylint_full]
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=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  \{\} +
263
264 [testenv:pylint]
265 basepython = python3
266 deps = pylint>=2.6.0
267 whitelist_externals = find
268 commands =
269     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}$" \{\} +
270
271 [testenv:pyang]
272 basepython = python3
273 deps = pyang
274 whitelist_externals = find
275 commands =
276     pyang --version
277     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/ \{\} +
278 #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/ \{\} +
279
280 [testenv:pyangformat]
281 basepython = python3
282 deps = pyang
283 whitelist_externals = sh
284 commands =
285     pyang --version
286     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'
287
288 [testenv:pre-commit-install]
289 basepython = python3
290 deps = pre-commit
291 commands =
292     pre-commit install
293     pre-commit install --hook-type commit-msg
294
295 [testenv:pre-commit-uninstall]
296 basepython = python3
297 deps = pre-commit
298 commands =
299     pre-commit uninstall
300     pre-commit uninstall --hook-type commit-msg
301
302 [testenv:pre-commit-autoupdate]
303 basepython = python3
304 deps = pre-commit
305 commands =
306     pre-commit autoupdate
307
308 [testenv:pre-commit]
309 basepython = python3
310 deps = pre-commit
311 passenv = HOME
312 commands =
313     pre-commit run --all-files --show-diff-on-failure
314     pre-commit run gitlint --hook-stage commit-msg --commit-msg-filename .git/COMMIT_EDITMSG
315     # Gitlint only proposes a pre-commit configuration for the commit-msg stage but none for the commit stage.
316     # Its default arguments --passed and --msg-filename are different from CI recommandations.
317     # As a result, the line above is always skipped in jenkins CI since there cannot be a .git/COMMIT_EDITMSG file.
318     # A dedicated gitlint profile for CI is proposed below. Also to behave fine locally, this profile must have access
319     # to the HOME variable so that Gitlint can retrieve Git user settings.
320
321 [testenv:gitlint]
322 basepython = python3
323 deps = gitlint
324 commands =
325     gitlint --config ../.gitlint
326