4b469529907a1bd8b91b3bcde3098e1d980dfd5b
[transportpce.git] / tox.ini
1 [tox]
2 minversion = 3.7.0
3 envlist = buildcontroller,testsPCE,sims121,tests121,sims221,tests221,sims71,tests71,tests_hybrid
4     docs
5     docs-linkcheck
6     checkbashisms
7     pre-commit
8     gitlint
9 skipsdist = true
10 setupdir = tests/
11
12 [testenv]
13 passenv = USE_LIGHTY http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
14 setenv =
15     USE_LIGHTY = False
16 usedevelop = true
17 basepython = python3
18 deps =
19   -r{toxinidir}/tests/requirements.txt
20   -r{toxinidir}/tests/test-requirements.txt
21   setuptools>=7.0
22 changedir = {toxinidir}/tests
23 parallel_show_output = true
24
25 [testenv:buildcontroller]
26 whitelist_externals = sh
27                       sudo
28 commands =
29 #install maven and JDK11 on the Gate since they are not there by default
30   sh -c "which mvn >/dev/null || ./installMavenCentOS.sh"
31 #install honeynode 1.2.1 simulators
32 #patch OLM constant to speed up tests, unnecessary for PCE tests
33   sh -c "sed -i'_' 's@=.*//#FUNCTESTVAL=@=@g' ../olm/src/main/java/org/opendaylight/transportpce/olm/util/OlmUtils.java"
34 #build controller, source JDK_JAVA_OPTIONS to remove illegal reflective acces warnings introduced by Java11
35   sh -c ". $PWD/reflectwarn.sh && cd .. && mvn clean install -B -q -s tests/odl_settings.xml -DskipTests -Dmaven.javadoc.skip=true -Dodlparent.spotbugs.skip -Dodlparent.checkstyle.skip"
36   sh -c "mv  ../olm/src/main/java/org/opendaylight/transportpce/olm/util/OlmUtils.java_  ../olm/src/main/java/org/opendaylight/transportpce/olm/util/OlmUtils.java"
37 #patch Karaf exec for the same reason at runtime and also to have the possibility to use alternative ports
38   sh -c "../karaf/target/assembly/ressources/post_install_for_tests.sh"
39 #build Lighty if needed
40   sh -c 'if [ "$USE_LIGHTY" = "True" ]; then (cd ../lighty && ./build.sh); fi'
41
42 [testenv:sims121]
43 whitelist_externals = sh
44 depends = buildcontroller
45 # sims profiles does not strictly depends on buildcontroller
46 # but this dependency avoids race condition in the gate
47 commands =
48   - sh -c "./install_honeynode.sh 1.2.1"
49
50 [testenv:sims221]
51 whitelist_externals = sh
52 depends = buildcontroller
53 commands =
54   - sh -c "./install_honeynode.sh 2.2.1"
55
56 [testenv:sims71]
57 whitelist_externals = sh
58 depends = buildcontroller
59 commands =
60   - sh -c "./install_honeynode.sh 7.1"
61
62 [testenv:testsPCE]
63 depends = buildcontroller
64 whitelist_externals = launch_tests.sh
65 passenv = LAUNCHER USE_LIGHTY
66 commands =
67   ./launch_tests.sh pce {posargs:}
68
69 [testenv:tests121]
70 depends = buildcontroller,sims121,testsPCE
71 # testsPCE dependency is only here to chain tests in the gate and avoid resources starvation
72 whitelist_externals = launch_tests.sh
73 passenv = LAUNCHER
74 setenv =
75     USE_LIGHTY=False
76     USE_ODL_ALT_WEBSOCKET_PORT=8186
77     USE_ODL_ALT_AKKA_PORT=2551
78     USE_ODL_ALT_AKKA_MGT_PORT=8559
79     USE_ODL_ALT_SHELL_PORT=8102
80     USE_ODL_ALT_RMI_REGISTRY_PORT=1100
81     USE_ODL_ALT_RMI_SERVER_PORT=44445
82     USE_ODL_ALT_RESTCONF_PORT=8182
83 commands =
84   ./launch_tests.sh 1.2.1 {posargs:}
85 # By default, all tests in the folder transportpce_tests/1.2.1/ are run.
86 # Though, a restricted list of tests can be passed as argument to 'tox -e tests121'.
87 # For example, 'tox -e tests121 portmapping' will run only the portmapping test.
88 # and 'tox -e tests121 "portmapping pce"' will run the portmapping and pce tests.
89 # Additionnally, a different launcher command than 'nosetests --with-xunit' can be
90 # used by exporting the variable LAUNCHER. For example 'export LAUNCHER="python3"'
91 # which is more verbose than nose or 'export LAUNCHER="ls -l"' to only list script
92 # files attributes.
93
94 [testenv:tests221]
95 depends = buildcontroller,sims221,tests121
96 # tests71 dependency is only here to chain tests in the gate and avoid ressources starvation
97 whitelist_externals = launch_tests.sh
98 passenv = LAUNCHER
99 setenv =
100     USE_LIGHTY=False
101     USE_ODL_ALT_WEBSOCKET_PORT=8187
102     USE_ODL_ALT_AKKA_PORT=2552
103     USE_ODL_ALT_AKKA_MGT_PORT=8560
104     USE_ODL_ALT_SHELL_PORT=8103
105     USE_ODL_ALT_RMI_REGISTRY_PORT=1101
106     USE_ODL_ALT_RMI_SERVER_PORT=44446
107     USE_ODL_ALT_RESTCONF_PORT=8183
108 commands =
109   ./launch_tests.sh 2.2.1 {posargs:}
110
111 [testenv:tests71]
112 depends = buildcontroller,sims71,tests221
113 whitelist_externals = launch_tests.sh
114 passenv = LAUNCHER
115 setenv =
116     USE_LIGHTY=False
117     USE_ODL_ALT_WEBSOCKET_PORT=8188
118     USE_ODL_ALT_AKKA_PORT=2553
119     USE_ODL_ALT_AKKA_MGT_PORT=8561
120     USE_ODL_ALT_SHELL_PORT=8104
121     USE_ODL_ALT_RMI_REGISTRY_PORT=1102
122     USE_ODL_ALT_RMI_SERVER_PORT=44447
123     USE_ODL_ALT_RESTCONF_PORT=8184
124 commands =
125   ./launch_tests.sh 7.1 {posargs:}
126
127 [testenv:tests_hybrid]
128 depends = buildcontroller,sims121,sims221,sims71,tests121,tests221,tests71
129 #the last dependency is to avoid temporarily concurrent ressources problem in parallel mode
130 whitelist_externals = launch_tests.sh
131 passenv = LAUNCHER
132 setenv =
133     USE_LIGHTY=False
134     USE_ODL_ALT_WEBSOCKET_PORT=8186
135     USE_ODL_ALT_AKKA_PORT=2551
136     USE_ODL_ALT_AKKA_MGT_PORT=8559
137     USE_ODL_ALT_SHELL_PORT=8102
138     USE_ODL_ALT_RMI_REGISTRY_PORT=1100
139     USE_ODL_ALT_RMI_SERVER_PORT=44445
140     USE_ODL_ALT_RESTCONF_PORT=8182
141 commands =
142 #  nosetests --with-xunit transportpce_tests/hybrid/test01_device_change_notifications.py
143   ./launch_tests.sh hybrid {posargs:}
144
145 [testenv:gnpy]
146 depends = buildcontroller
147 whitelist_externals = sh
148                       sudo
149 commands =
150   #sudo docker pull atriki/gnpyrest:v1.2
151   sudo docker run -d -p 8008:5000 --name gnpy_tpce_rest1 atriki/gnpyrest:v1.2
152   nosetests --with-xunit transportpce_tests/with_docker/test_gnpy.py
153   sudo docker container rm -f gnpy_tpce_rest1
154
155 [testenv:nbinotifications]
156 depends = buildcontroller,sims221
157 whitelist_externals = sh
158                       sudo
159 commands =
160   sudo docker-compose -f ./nbinotifications/docker-compose.yml up -d
161   nosetests --with-xunit transportpce_tests/with_docker/test_nbinotifications.py
162   sudo docker-compose -f ./nbinotifications/docker-compose.yml down --rmi all
163
164 [testenv:docs]
165 passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
166 basepython = python3
167 deps = -rdocs/requirements.txt
168 commands =
169     sphinx-build -q -W -b html -n -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/html
170
171 [testenv:docs-linkcheck]
172 passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
173 basepython = python3
174 deps = -rdocs/requirements.txt
175 commands = sphinx-build -q -b linkcheck -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/linkcheck
176
177 [testenv:checkbashisms]
178 deps =
179 whitelist_externals = sh
180                       checkbashisms
181                       sudo
182                       find
183 commands =
184     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)'
185     find . -not -path '*/\.*' -name *.sh -exec checkbashisms -f  \{\} +
186
187 [testenv:spelling]
188 basepython = python3
189 deps =
190     -rdocs/requirements.txt
191     sphinxcontrib-spelling
192     PyEnchant
193 commands = sphinx-build -b spelling  -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/spelling
194
195 [testenv:autopep8]
196 basepython = python3
197 deps = autopep8
198 commands =
199     autopep8 --max-line-length 120 --in-place --recursive transportpce_tests/
200
201 [testenv:pylint]
202 basepython = python3
203 deps = pylint
204 whitelist_externals = find
205 commands =
206     find transportpce_tests/ -name *.py -exec pylint --max-line-length=120 --disable=missing-docstring --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  \{\} +
207
208 [testenv:pyang]
209 basepython = python3
210 deps = pyang
211 whitelist_externals = find
212 commands =
213     pyang --version
214     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/ \{\} +
215 #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/ \{\} +
216
217 [testenv:pyangformat]
218 basepython = python3
219 deps = pyang
220 whitelist_externals = sh
221 commands =
222     pyang --version
223     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'
224
225 [testenv:pre-commit-install]
226 basepython = python3
227 deps = pre-commit
228 commands =
229     pre-commit install
230     pre-commit install --hook-type commit-msg
231
232 [testenv:pre-commit-uninstall]
233 basepython = python3
234 deps = pre-commit
235 commands =
236     pre-commit uninstall
237     pre-commit uninstall --hook-type commit-msg
238
239 [testenv:pre-commit]
240 basepython = python3
241 deps = pre-commit
242 passenv = HOME
243 commands =
244     pre-commit run --all-files --show-diff-on-failure
245     pre-commit run gitlint --hook-stage commit-msg --commit-msg-filename .git/COMMIT_EDITMSG
246     # Gitlint only proposes a pre-commit configuration for the commit-msg stage but none for the commit stage.
247     # Its default arguments --passed and --msg-filename are different from CI recommandations.
248     # As a result, the line above is always skipped in jenkins CI since there cannot be a .git/COMMIT_EDITMSG file.
249     # A dedicated gitlint profile for CI is proposed below. Also to behave fine locally, this profile must have access
250     # to the HOME variable so that Gitlint can retrieve Git user settings.
251
252 [testenv:gitlint]
253 basepython = python3
254 deps = gitlint
255 commands =
256     gitlint
257