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