8131efd36ef5432788957a77c27a112fa60f1fac
[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,
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
19 #setenv =
20 #    USE_LIGHTY=True
21 usedevelop = true
22 basepython = python3
23 deps =
24   -r{toxinidir}/tests/requirements.txt
25   -r{toxinidir}/tests/test-requirements.txt
26   setuptools>=7.0
27 changedir = {toxinidir}/tests
28 parallel_show_output = true
29
30 [testenv:buildcontroller]
31 whitelist_externals = build_controller.sh
32 commands =
33   ./build_controller.sh
34
35 [testenv:sims121]
36 whitelist_externals = install_honeynode.sh
37 depends = buildcontroller
38 # sims profiles does not strictly depends on buildcontroller
39 # but this dependency avoids race condition in the gate
40 commands =
41   ./install_honeynode.sh 1.2.1
42
43 [testenv:sims221]
44 whitelist_externals = install_honeynode.sh
45 depends = buildcontroller
46 commands =
47   ./install_honeynode.sh 2.2.1
48
49 [testenv:sims71]
50 whitelist_externals = install_honeynode.sh
51 depends = buildcontroller
52 commands =
53   ./install_honeynode.sh 7.1
54
55 [testenv:testsPCE]
56 depends = buildcontroller
57 whitelist_externals = launch_tests.sh
58 passenv = LAUNCHER USE_LIGHTY USE_ODL_RESTCONF_VERSION
59 #setenv =
60 #    USE_LIGHTY=True
61 commands =
62   ./launch_tests.sh pce {posargs:}
63
64 [testenv:build_karaf_tests121]
65 depends = buildcontroller
66 # testsPCE dependency is only here to chain tests in the gate and avoid resources starvation
67 whitelist_externals = launch_tests.sh
68 passenv = LAUNCHER USE_LIGHTY
69 setenv =
70 #    USE_LIGHTY=True
71     USE_ODL_ALT_KARAF_ENV=./karaf121.env
72     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf121
73 commands =
74   ./build_karaf_for_tests.sh
75
76 [testenv:tests121]
77 depends = buildcontroller,build_karaf_tests121,sims121,testsPCE
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 USE_ODL_RESTCONF_VERSION
81 setenv =
82 #    USE_LIGHTY=True
83 #    USE_ODL_RESTCONF_VERSION=draft-bierman02
84     USE_ODL_ALT_KARAF_ENV=./karaf121.env
85     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf121
86 commands =
87   ./launch_tests.sh 1.2.1 {posargs:}
88 # By default, all tests in the folder transportpce_tests/1.2.1/ are run.
89 # Though, a restricted list of tests can be passed as argument to 'tox -e tests121'.
90 # For example, 'tox -e tests121 portmapping' will run only the portmapping test.
91 # and 'tox -e tests121 "portmapping pce"' will run the portmapping and pce tests.
92 # Additionnally, a different launcher command than 'nosetests --with-xunit' can be
93 # used by exporting the variable LAUNCHER. For example 'export LAUNCHER="python3"'
94 # which is more verbose than nose or 'export LAUNCHER="ls -l"' to only list script
95 # files attributes.
96
97 [testenv:build_karaf_tests221]
98 depends = buildcontroller
99 # testsPCE dependency is only here to chain tests in the gate and avoid resources starvation
100 whitelist_externals = launch_tests.sh
101 passenv = LAUNCHER USE_LIGHTY
102 setenv =
103 #    USE_LIGHTY=True
104     USE_ODL_ALT_KARAF_ENV=./karaf221.env
105     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf221
106 commands =
107   ./build_karaf_for_tests.sh
108
109 [testenv:tests221]
110 depends = buildcontroller,build_karaf_tests221,sims221,tests71
111 # tests71 dependency is only here to chain tests in the gate and avoid ressources starvation
112 whitelist_externals = launch_tests.sh
113 passenv = LAUNCHER USE_LIGHTY USE_ODL_RESTCONF_VERSION
114 setenv =
115 #    USE_LIGHTY=True
116 #    USE_ODL_RESTCONF_VERSION=draft-bierman02
117     USE_ODL_ALT_KARAF_ENV=./karaf221.env
118     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf221
119 commands =
120   ./launch_tests.sh 2.2.1 {posargs:}
121
122 [testenv:build_karaf_tests71]
123 depends = buildcontroller
124 # testsPCE dependency is only here to chain tests in the gate and avoid resources starvation
125 whitelist_externals = launch_tests.sh
126 passenv = LAUNCHER USE_LIGHTY
127 setenv =
128 #    USE_LIGHTY=True
129     USE_ODL_ALT_KARAF_ENV=./karaf71.env
130     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf71
131 commands =
132   ./build_karaf_for_tests.sh
133
134 [testenv:tests71]
135 depends = buildcontroller,build_karaf_tests71,sims71
136 whitelist_externals = launch_tests.sh
137 passenv = LAUNCHER USE_LIGHTY USE_ODL_RESTCONF_VERSION
138 setenv =
139 #    USE_LIGHTY=True
140 #    USE_ODL_RESTCONF_VERSION=draft-bierman02
141     USE_ODL_ALT_KARAF_ENV=./karaf71.env
142     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf71
143 commands =
144   ./launch_tests.sh 7.1 {posargs:}
145
146 [testenv:build_karaf_tests_hybrid]
147 depends = buildcontroller
148 # testsPCE dependency is only here to chain tests in the gate and avoid resources starvation
149 whitelist_externals = launch_tests.sh
150 passenv = LAUNCHER USE_LIGHTY
151 setenv =
152 #    USE_LIGHTY=True
153     USE_ODL_ALT_KARAF_ENV=./karaf121.env
154     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf_hybrid
155 commands =
156   ./build_karaf_for_tests.sh
157
158 [testenv:tests_hybrid]
159 depends = buildcontroller,sims121,sims221,sims71,tests121,tests221,tests71
160 #the last dependency is to avoid temporarily concurrent ressources problem in parallel mode
161 whitelist_externals = launch_tests.sh
162 passenv = LAUNCHER USE_LIGHTY USE_ODL_RESTCONF_VERSION
163 setenv =
164 #    USE_LIGHTY=True
165     USE_ODL_ALT_KARAF_ENV=./karaf121.env
166     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf_hybrid
167 commands =
168 #  nosetests --with-xunit transportpce_tests/hybrid/test01_device_change_notifications.py
169   ./launch_tests.sh hybrid {posargs:}
170
171 [testenv:gnpy]
172 depends = buildcontroller
173 whitelist_externals = launch_tests.sh
174                       dockercmd.sh
175 passenv = LAUNCHER USE_LIGHTY USE_ODL_RESTCONF_VERSION
176 commands =
177   #sudo docker pull atriki/gnpyrest:v1.2
178   ./dockercmd.sh run -d -p 8008:5000 --name gnpy_tpce_rest1 atriki/gnpyrest:v1.2
179   ./launch_tests.sh with_docker gnpy
180   ./dockercmd.sh container rm -f gnpy_tpce_rest1
181
182 [testenv:nbinotifications]
183 depends = buildcontroller,sims221
184 whitelist_externals = launch_tests.sh
185                       dockercmd.sh
186 passenv = LAUNCHER USE_LIGHTY USE_ODL_RESTCONF_VERSION
187 commands =
188   ./dockercmd.sh run -d -p 2181:2181 -p 9092:9092 --env ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092 --name tpce_kafka1 teivah/kafka:2.0.0
189   ./launch_tests.sh with_docker nbinotifications
190   ./dockercmd.sh container rm -f tpce_kafka1
191
192 [testenv:docs]
193 passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
194 basepython = python3
195 deps = -rdocs/requirements.txt
196 commands =
197     sphinx-build -q -W -b html -n -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/html
198
199 [testenv:docs-linkcheck]
200 passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
201 basepython = python3
202 deps = -rdocs/requirements.txt
203 commands = sphinx-build -q -b linkcheck -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/linkcheck
204
205 [testenv:checkbashisms]
206 deps =
207 whitelist_externals = sh
208                       checkbashisms
209                       sudo
210                       find
211 commands =
212     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)'
213     find . -not -path '*/\.*' -name *.sh -exec checkbashisms -f  \{\} +
214
215 [testenv:spelling]
216 basepython = python3
217 deps =
218     -rdocs/requirements.txt
219     sphinxcontrib-spelling
220     PyEnchant
221 commands = sphinx-build -b spelling  -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/spelling
222
223 [testenv:autopep8]
224 basepython = python3
225 deps = autopep8
226 commands =
227     autopep8 --max-line-length 120 --in-place --recursive transportpce_tests/
228
229 [testenv:pylint_full]
230 basepython = python3
231 deps = pylint>=2.6.0
232 whitelist_externals = find
233 commands =
234     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  \{\} +
235
236 [testenv:pylint]
237 basepython = python3
238 deps = pylint>=2.6.0
239 whitelist_externals = find
240 commands =
241     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}$" \{\} +
242
243 [testenv:pyang]
244 basepython = python3
245 deps = pyang
246 whitelist_externals = find
247 commands =
248     pyang --version
249     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/ \{\} +
250 #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/ \{\} +
251
252 [testenv:pyangformat]
253 basepython = python3
254 deps = pyang
255 whitelist_externals = sh
256 commands =
257     pyang --version
258     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'
259
260 [testenv:pre-commit-install]
261 basepython = python3
262 deps = pre-commit
263 commands =
264     pre-commit install
265     pre-commit install --hook-type commit-msg
266
267 [testenv:pre-commit-uninstall]
268 basepython = python3
269 deps = pre-commit
270 commands =
271     pre-commit uninstall
272     pre-commit uninstall --hook-type commit-msg
273
274 [testenv:pre-commit-autoupdate]
275 basepython = python3
276 deps = pre-commit
277 commands =
278     pre-commit autoupdate
279
280 [testenv:pre-commit]
281 basepython = python3
282 deps = pre-commit
283 passenv = HOME
284 commands =
285     pre-commit run --all-files --show-diff-on-failure
286     pre-commit run gitlint --hook-stage commit-msg --commit-msg-filename .git/COMMIT_EDITMSG
287     # Gitlint only proposes a pre-commit configuration for the commit-msg stage but none for the commit stage.
288     # Its default arguments --passed and --msg-filename are different from CI recommandations.
289     # As a result, the line above is always skipped in jenkins CI since there cannot be a .git/COMMIT_EDITMSG file.
290     # A dedicated gitlint profile for CI is proposed below. Also to behave fine locally, this profile must have access
291     # to the HOME variable so that Gitlint can retrieve Git user settings.
292
293 [testenv:gitlint]
294 basepython = python3
295 deps = gitlint
296 commands =
297     gitlint
298