eada9910096a6ca402f73f59950a38f17582f6d3
[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   sh -c 'if [ "$USE_LIGHTY" != "True" ]; then (cd ../; for suffix in 121 221 71; do rm -rf "karaf$suffix"; cp -r karaf "karaf$suffix";done) ; fi'
35 #build controller, source JDK_JAVA_OPTIONS to remove illegal reflective acces warnings introduced by Java11
36   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"
37   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"
38 #patch Karaf exec for the same reason at runtime and also to have the possibility to use alternative ports
39   sh -c "../karaf/target/assembly/ressources/post_install_for_tests.sh"
40   sh -c 'if [ "$USE_LIGHTY" != "True" ]; then . $PWD/reflectwarn.sh && (for suffix in 121 221 71; do cd  ../"karaf$suffix"/; mvn clean install -B -q -s ../tests/odl_settings.xml -DskipTests -Dmaven.javadoc.skip=true; ./target/assembly/ressources/post_install_for_tests.sh;done) ; fi'
41 #build Lighty if needed
42   sh -c 'if [ "$USE_LIGHTY" = "True" ]; then (cd ../lighty && ./build.sh); fi'
43
44 [testenv:sims121]
45 whitelist_externals = sh
46 depends = buildcontroller
47 # sims profiles does not strictly depends on buildcontroller
48 # but this dependency avoids race condition in the gate
49 commands =
50   - sh -c "./install_honeynode.sh 1.2.1"
51
52 [testenv:sims221]
53 whitelist_externals = sh
54 depends = buildcontroller
55 commands =
56   - sh -c "./install_honeynode.sh 2.2.1"
57
58 [testenv:sims71]
59 whitelist_externals = sh
60 depends = buildcontroller
61 commands =
62   - sh -c "./install_honeynode.sh 7.1"
63
64 [testenv:testsPCE]
65 depends = buildcontroller
66 whitelist_externals = launch_tests.sh
67 passenv = LAUNCHER USE_LIGHTY
68 commands =
69   ./launch_tests.sh pce {posargs:}
70
71 [testenv:tests121]
72 depends = buildcontroller,sims121,testsPCE
73 # testsPCE dependency is only here to chain tests in the gate and avoid resources starvation
74 whitelist_externals = launch_tests.sh
75 passenv = LAUNCHER
76 setenv =
77     USE_LIGHTY=False
78     USE_ODL_ALT_WEBSOCKET_PORT=8186
79     USE_ODL_ALT_AKKA_PORT=2551
80     USE_ODL_ALT_AKKA_MGT_PORT=8559
81     USE_ODL_ALT_SHELL_PORT=8102
82     USE_ODL_ALT_RMI_REGISTRY_PORT=1100
83     USE_ODL_ALT_RMI_SERVER_PORT=44445
84     USE_ODL_ALT_RESTCONF_PORT=8182
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:tests221]
98 depends = buildcontroller,sims221,tests71
99 # tests71 dependency is only here to chain tests in the gate and avoid ressources starvation
100 whitelist_externals = launch_tests.sh
101 passenv = LAUNCHER
102 setenv =
103     USE_LIGHTY=False
104     USE_ODL_ALT_WEBSOCKET_PORT=8187
105     USE_ODL_ALT_AKKA_PORT=2552
106     USE_ODL_ALT_AKKA_MGT_PORT=8560
107     USE_ODL_ALT_SHELL_PORT=8103
108     USE_ODL_ALT_RMI_REGISTRY_PORT=1101
109     USE_ODL_ALT_RMI_SERVER_PORT=44446
110     USE_ODL_ALT_RESTCONF_PORT=8183
111     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf221
112 commands =
113   ./launch_tests.sh 2.2.1 {posargs:}
114
115 [testenv:tests71]
116 depends = buildcontroller,sims71
117 whitelist_externals = launch_tests.sh
118 passenv = LAUNCHER
119 setenv =
120     USE_LIGHTY=False
121     USE_ODL_ALT_WEBSOCKET_PORT=8188
122     USE_ODL_ALT_AKKA_PORT=2553
123     USE_ODL_ALT_AKKA_MGT_PORT=8561
124     USE_ODL_ALT_SHELL_PORT=8104
125     USE_ODL_ALT_RMI_REGISTRY_PORT=1102
126     USE_ODL_ALT_RMI_SERVER_PORT=44447
127     USE_ODL_ALT_RESTCONF_PORT=8184
128     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf71
129 commands =
130   ./launch_tests.sh 7.1 {posargs:}
131
132 [testenv:tests_hybrid]
133 depends = buildcontroller,sims121,sims221,sims71,tests121,tests221,tests71
134 #the last dependency is to avoid temporarily concurrent ressources problem in parallel mode
135 whitelist_externals = launch_tests.sh
136 passenv = LAUNCHER
137 setenv =
138     USE_LIGHTY=False
139     USE_ODL_ALT_WEBSOCKET_PORT=8186
140     USE_ODL_ALT_AKKA_PORT=2551
141     USE_ODL_ALT_AKKA_MGT_PORT=8559
142     USE_ODL_ALT_SHELL_PORT=8102
143     USE_ODL_ALT_RMI_REGISTRY_PORT=1100
144     USE_ODL_ALT_RMI_SERVER_PORT=44445
145     USE_ODL_ALT_RESTCONF_PORT=8182
146 commands =
147 #  nosetests --with-xunit transportpce_tests/hybrid/test01_device_change_notifications.py
148   ./launch_tests.sh hybrid {posargs:}
149
150 [testenv:gnpy]
151 depends = buildcontroller
152 whitelist_externals = sh
153                       sudo
154 commands =
155   #sudo docker pull atriki/gnpyrest:v1.2
156   sudo docker run -d -p 8008:5000 --name gnpy_tpce_rest1 atriki/gnpyrest:v1.2
157   nosetests --with-xunit transportpce_tests/with_docker/test_gnpy.py
158   sudo docker container rm -f gnpy_tpce_rest1
159
160 [testenv:nbinotifications]
161 depends = buildcontroller,sims221
162 whitelist_externals = sh
163                       sudo
164 commands =
165   sudo docker-compose -f ./nbinotifications/docker-compose.yml up -d
166   nosetests --with-xunit transportpce_tests/with_docker/test_nbinotifications.py
167   sudo docker-compose -f ./nbinotifications/docker-compose.yml down --rmi all
168
169 [testenv:docs]
170 passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
171 basepython = python3
172 deps = -rdocs/requirements.txt
173 commands =
174     sphinx-build -q -W -b html -n -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/html
175
176 [testenv:docs-linkcheck]
177 passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
178 basepython = python3
179 deps = -rdocs/requirements.txt
180 commands = sphinx-build -q -b linkcheck -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/linkcheck
181
182 [testenv:checkbashisms]
183 deps =
184 whitelist_externals = sh
185                       checkbashisms
186                       sudo
187                       find
188 commands =
189     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)'
190     find . -not -path '*/\.*' -name *.sh -exec checkbashisms -f  \{\} +
191
192 [testenv:spelling]
193 basepython = python3
194 deps =
195     -rdocs/requirements.txt
196     sphinxcontrib-spelling
197     PyEnchant
198 commands = sphinx-build -b spelling  -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/spelling
199
200 [testenv:autopep8]
201 basepython = python3
202 deps = autopep8
203 commands =
204     autopep8 --max-line-length 120 --in-place --recursive transportpce_tests/
205
206 [testenv:pylint]
207 basepython = python3
208 deps = pylint
209 whitelist_externals = find
210 commands =
211     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  \{\} +
212
213 [testenv:pyang]
214 basepython = python3
215 deps = pyang
216 whitelist_externals = find
217 commands =
218     pyang --version
219     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/ \{\} +
220 #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/ \{\} +
221
222 [testenv:pyangformat]
223 basepython = python3
224 deps = pyang
225 whitelist_externals = sh
226 commands =
227     pyang --version
228     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'
229
230 [testenv:pre-commit-install]
231 basepython = python3
232 deps = pre-commit
233 commands =
234     pre-commit install
235     pre-commit install --hook-type commit-msg
236
237 [testenv:pre-commit-uninstall]
238 basepython = python3
239 deps = pre-commit
240 commands =
241     pre-commit uninstall
242     pre-commit uninstall --hook-type commit-msg
243
244 [testenv:pre-commit]
245 basepython = python3
246 deps = pre-commit
247 passenv = HOME
248 commands =
249     pre-commit run --all-files --show-diff-on-failure
250     pre-commit run gitlint --hook-stage commit-msg --commit-msg-filename .git/COMMIT_EDITMSG
251     # Gitlint only proposes a pre-commit configuration for the commit-msg stage but none for the commit stage.
252     # Its default arguments --passed and --msg-filename are different from CI recommandations.
253     # As a result, the line above is always skipped in jenkins CI since there cannot be a .git/COMMIT_EDITMSG file.
254     # A dedicated gitlint profile for CI is proposed below. Also to behave fine locally, this profile must have access
255     # to the HOME variable so that Gitlint can retrieve Git user settings.
256
257 [testenv:gitlint]
258 basepython = python3
259 deps = gitlint
260 commands =
261     gitlint
262