be29d12ceec8ed3b651fd200a103e2f9f5cef6d2
[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 = True
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
38   sh -c "sed -i'_' 's@!/bin/sh@!/bin/sh\'$'\n. $(dirname $0)/../../../../tests/reflectwarn.sh@' ../karaf/target/assembly/bin/karaf"
39   # the following command would be the straight and right way to support both BSD and GNU sed versions
40   # sh -c "sed -i'_' '1 a\'$'\n. \$(dirname \$0)/\.\./\.\./\.\./\.\./tests/reflectwarn.sh\n' ../karaf/target/assembly/bin/karaf"
41   # but tox reinterprets the quotes as
42   # sh -c 'sed -i'"'"'_'"'"' '"'"'1 a\'"'"'$'"'"'\n. \$(dirname \$0)/\.\./\.\./\.\./\.\./tests/reflectwarn.sh\n'"'"' ../karaf/target/assembly/bin/karaf'
43   # ,what results in an unexpected different formating (with a $ on the second line and the dot on the third)
44 #build Lighty if needed
45   sh -c 'if [ "$USE_LIGHTY" = "True" ]; then (cd ../lighty && ./build.sh); fi'
46
47 [testenv:sims121]
48 whitelist_externals = sh
49 depends = buildcontroller
50 # sims profiles does not strictly depends on buildcontroller
51 # but this dependency avoids race condition in the gate
52 commands =
53   - sh -c "./install_honeynode.sh 1.2.1"
54
55 [testenv:sims221]
56 whitelist_externals = sh
57 depends = buildcontroller
58 commands =
59   - sh -c "./install_honeynode.sh 2.2.1"
60
61 [testenv:sims71]
62 whitelist_externals = sh
63 depends = buildcontroller
64 commands =
65   - sh -c "./install_honeynode.sh 7.1"
66
67 [testenv:testsPCE]
68 depends = buildcontroller
69 whitelist_externals = launch_tests.sh
70 passenv = LAUNCHER USE_LIGHTY
71 commands =
72   ./launch_tests.sh pce {posargs:}
73
74 [testenv:tests121]
75 depends = buildcontroller,sims121,testsPCE
76 #the last dependency is to avoid temporarily concurrent ressources problem to fix in parallel mode
77 whitelist_externals = launch_tests.sh
78 passenv = LAUNCHER
79 setenv =
80     USE_LIGHTY=True
81     USE_ODL_ALT_RESTCONF_PORT=8182
82     USE_ODL_ALT_WEBSOCKET_PORT=8186
83     USE_ODL_ALT_AKKA_PORT=2551
84     USE_ODL_ALT_AKKA_MGT_PORT=8559
85 commands =
86   ./launch_tests.sh 1.2.1 {posargs:}
87 # By default, all tests in the folder transportpce_tests/1.2.1/ are run.
88 # Though, a restricted list of tests can be passed as argument to 'tox -e tests121'.
89 # For example, 'tox -e tests121 portmapping' will run only the portmapping test.
90 # and 'tox -e tests121 "portmapping pce"' will run the portmapping and pce tests.
91 # Additionnally, a different launcher command than 'nosetests --with-xunit' can be
92 # used by exporting the variable LAUNCHER. For example 'export LAUNCHER="python3"'
93 # which is more verbose than nose or 'export LAUNCHER="ls -l"' to only list script
94 # files attributes.
95
96 [testenv:tests221]
97 depends = buildcontroller,sims221,tests121
98 #the last dependency is to avoid temporarily concurrent ressources problem to fix in parallel mode
99 whitelist_externals = launch_tests.sh
100 passenv = LAUNCHER
101 setenv =
102     USE_LIGHTY=True
103     USE_ODL_ALT_RESTCONF_PORT=8183
104     USE_ODL_ALT_WEBSOCKET_PORT=8187
105     USE_ODL_ALT_AKKA_PORT=2552
106     USE_ODL_ALT_AKKA_MGT_PORT=8560
107 commands =
108   ./launch_tests.sh 2.2.1 {posargs:}
109
110 [testenv:tests71]
111 depends = buildcontroller,sims71,tests221
112 #the last dependency is to avoid temporarily concurrent ressources problem to fix in parallel mode
113 whitelist_externals = launch_tests.sh
114 passenv = LAUNCHER
115 setenv =
116     USE_LIGHTY=True
117     USE_ODL_ALT_RESTCONF_PORT=8184
118     USE_ODL_ALT_WEBSOCKET_PORT=8188
119     USE_ODL_ALT_AKKA_PORT=2553
120     USE_ODL_ALT_AKKA_MGT_PORT=8561
121 commands =
122   ./launch_tests.sh 7.1 {posargs:}
123
124 [testenv:tests_hybrid]
125 depends = buildcontroller,sims121,sims221,sims71,tests121,tests221,tests71
126 #the last dependency is to avoid temporarily concurrent ressources problem to fix in parallel mode
127 whitelist_externals = launch_tests.sh
128 passenv = LAUNCHER
129 setenv =
130     USE_LIGHTY=True
131     USE_ODL_ALT_RESTCONF_PORT=8182
132     USE_ODL_ALT_WEBSOCKET_PORT=8186
133     USE_ODL_ALT_AKKA_PORT=2551
134     USE_ODL_ALT_AKKA_MGT_PORT=8559
135 commands =
136 #  nosetests --with-xunit transportpce_tests/hybrid/test01_device_change_notifications.py
137   ./launch_tests.sh hybrid {posargs:}
138
139 [testenv:gnpy]
140 depends = buildcontroller
141 whitelist_externals = sh
142                       sudo
143 commands =
144   #sudo docker pull atriki/gnpyrest:v1.2
145   sudo docker run -d -p 8008:5000 --name gnpy_tpce_rest1 atriki/gnpyrest:v1.2
146   nosetests --with-xunit transportpce_tests/with_docker/test_gnpy.py
147   sudo docker container rm -f gnpy_tpce_rest1
148
149 [testenv:nbinotifications]
150 depends = buildcontroller,sims221
151 whitelist_externals = sh
152                       sudo
153 commands =
154   sudo docker-compose -f ./nbinotifications/docker-compose.yml up -d
155   nosetests --with-xunit transportpce_tests/with_docker/test_nbinotifications.py
156   sudo docker-compose -f ./nbinotifications/docker-compose.yml down --rmi all
157
158 [testenv:docs]
159 passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
160 basepython = python3
161 deps = -rdocs/requirements.txt
162 commands =
163     sphinx-build -q -W -b html -n -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/html
164
165 [testenv:docs-linkcheck]
166 passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
167 basepython = python3
168 deps = -rdocs/requirements.txt
169 commands = sphinx-build -q -b linkcheck -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/linkcheck
170
171 [testenv:checkbashisms]
172 deps =
173 whitelist_externals = sh
174                       checkbashisms
175                       sudo
176                       find
177 commands =
178     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)'
179     find . -not -path '*/\.*' -name *.sh -exec checkbashisms -f  \{\} +
180
181 [testenv:spelling]
182 basepython = python3
183 deps =
184     -rdocs/requirements.txt
185     sphinxcontrib-spelling
186     PyEnchant
187 commands = sphinx-build -b spelling  -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/spelling
188
189 [testenv:autopep8]
190 basepython = python3
191 deps = autopep8
192 commands =
193     autopep8 --max-line-length 120 --in-place --recursive transportpce_tests/
194
195 [testenv:pylint]
196 basepython = python3
197 deps = pylint
198 whitelist_externals = find
199 commands =
200     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  \{\} +
201
202 [testenv:pyang]
203 basepython = python3
204 deps = pyang
205 whitelist_externals = find
206 commands =
207     pyang --version
208     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/ \{\} +
209 #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/ \{\} +
210
211 [testenv:pyangformat]
212 basepython = python3
213 deps = pyang
214 whitelist_externals = sh
215 commands =
216     pyang --version
217     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'
218
219 [testenv:pre-commit-install]
220 basepython = python3
221 deps = pre-commit
222 commands =
223     pre-commit install
224     pre-commit install --hook-type commit-msg
225
226 [testenv:pre-commit-uninstall]
227 basepython = python3
228 deps = pre-commit
229 commands =
230     pre-commit uninstall
231     pre-commit uninstall --hook-type commit-msg
232
233 [testenv:pre-commit]
234 basepython = python3
235 deps = pre-commit
236 passenv = HOME
237 commands =
238     pre-commit run --all-files --show-diff-on-failure
239     pre-commit run gitlint --hook-stage commit-msg --commit-msg-filename .git/COMMIT_EDITMSG
240     # Gitlint only proposes a pre-commit configuration for the commit-msg stage but none for the commit stage.
241     # Its default arguments --passed and --msg-filename are different from CI recommandations.
242     # As a result, the line above is always skipped in jenkins CI since there cannot be a .git/COMMIT_EDITMSG file.
243     # A dedicated gitlint profile for CI is proposed below. Also to behave fine locally, this profile must have access
244     # to the HOME variable so that Gitlint can retrieve Git user settings.
245
246 [testenv:gitlint]
247 basepython = python3
248 deps = gitlint
249 commands =
250     gitlint
251