Outsource tests scripts not in envlist
[transportpce.git] / tox.ini
1 [tox]
2 minversion = 3.7.0
3 envlist = buildcontroller,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:tests121]
68 depends = buildcontroller,sims121
69 commands =
70   nosetests --with-xunit transportpce_tests/1.2.1/test_portmapping.py
71   nosetests --with-xunit transportpce_tests/1.2.1/test_topo_portmapping.py
72   nosetests --with-xunit transportpce_tests/1.2.1/test_topology.py
73   nosetests --with-xunit transportpce_tests/1.2.1/test_renderer_service_path_nominal.py
74   nosetests --with-xunit transportpce_tests/1.2.1/test_pce.py
75   nosetests --with-xunit transportpce_tests/1.2.1/test_olm.py
76   nosetests --with-xunit transportpce_tests/1.2.1/test_end2end.py
77
78 [testenv:tests221]
79 depends = buildcontroller,sims221,tests121
80 #the last dependency is to avoid temporarily concurrent ressources problem to fix in parallel mode
81 commands =
82   nosetests --with-xunit transportpce_tests/2.2.1/test_portmapping.py
83   nosetests --with-xunit transportpce_tests/2.2.1/test_topology.py
84   nosetests --with-xunit transportpce_tests/2.2.1/test_otn_topology.py
85   nosetests --with-xunit transportpce_tests/2.2.1/test_flex_grid.py
86   nosetests --with-xunit transportpce_tests/2.2.1/test_renderer_service_path_nominal.py
87   nosetests --with-xunit transportpce_tests/2.2.1/test_otn_renderer.py
88   nosetests --with-xunit transportpce_tests/2.2.1/test_otn_sh_renderer.py
89   nosetests --with-xunit transportpce_tests/2.2.1/test_olm.py
90   nosetests --with-xunit transportpce_tests/2.2.1/test_tapi.py
91   nosetests --with-xunit transportpce_tests/2.2.1/test_otn_end2end.py
92   nosetests --with-xunit transportpce_tests/2.2.1/test_end2end.py
93
94 [testenv:tests71]
95 depends = buildcontroller,sims71,tests221
96 #the last dependency is to avoid temporarily concurrent ressources problem to fix in parallel mode
97 commands =
98   nosetests --with-xunit transportpce_tests/7.1/test_pce_400G.py
99   #NB: test pce_400G above does not depend on sims71
100   nosetests --with-xunit transportpce_tests/7.1/test_portmapping.py
101
102 [testenv:tests_hybrid]
103 depends = buildcontroller,sims121,sims221,sims71,tests71
104 #the last dependency is to avoid temporarily concurrent ressources problem to fix in parallel mode
105 commands =
106   nosetests --with-xunit transportpce_tests/hybrid/test_device_change_notifications.py
107
108 [testenv:gnpy]
109 depends = buildcontroller
110 whitelist_externals = sh
111                       sudo
112 commands =
113   #sudo docker pull atriki/gnpyrest:v1.2
114   sudo docker run -d -p 8008:5000 --name gnpy_tpce_rest1 atriki/gnpyrest:v1.2
115   nosetests --with-xunit transportpce_tests/with_docker/test_gnpy.py
116   sudo docker container rm -f gnpy_tpce_rest1
117
118 [testenv:nbinotifications]
119 depends = buildcontroller,sims221
120 whitelist_externals = sh
121                       sudo
122 commands =
123   sudo docker-compose -f ./nbinotifications/docker-compose.yml up -d
124   nosetests --with-xunit transportpce_tests/with_docker/test_nbinotifications.py
125   sudo docker-compose -f ./nbinotifications/docker-compose.yml down --rmi all
126
127 [testenv:docs]
128 passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
129 basepython = python3
130 deps = -rdocs/requirements.txt
131 commands =
132     sphinx-build -q -W -b html -n -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/html
133
134 [testenv:docs-linkcheck]
135 passenv = http_proxy HTTP_PROXY https_proxy HTTPS_PROXY no_proxy NO_PROXY
136 basepython = python3
137 deps = -rdocs/requirements.txt
138 commands = sphinx-build -q -b linkcheck -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/linkcheck
139
140 [testenv:checkbashisms]
141 deps =
142 whitelist_externals = sh
143                       checkbashisms
144                       sudo
145                       find
146 commands =
147     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)'
148     find . -not -path '*/\.*' -name *.sh -exec checkbashisms -f  \{\} +
149
150 [testenv:spelling]
151 basepython = python3
152 deps =
153     -rdocs/requirements.txt
154     sphinxcontrib-spelling
155     PyEnchant
156 commands = sphinx-build -b spelling  -d {envtmpdir}/doctrees ../docs/ {toxinidir}/docs/_build/spelling
157
158 [testenv:autopep8]
159 basepython = python3
160 deps = autopep8
161 commands =
162     autopep8 --max-line-length 120 --in-place --recursive transportpce_tests/
163
164 [testenv:pylint]
165 basepython = python3
166 deps = pylint
167 whitelist_externals = find
168 commands =
169     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  \{\} +
170
171 [testenv:pyang]
172 basepython = python3
173 deps = pyang
174 whitelist_externals = find
175 commands =
176     pyang --version
177     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/ \{\} +
178 #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/ \{\} +
179
180 [testenv:pyangformat]
181 basepython = python3
182 deps = pyang
183 whitelist_externals = sh
184 commands =
185     pyang --version
186     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'
187
188 [testenv:pre-commit-install]
189 basepython = python3
190 deps = pre-commit
191 commands =
192     pre-commit install
193     pre-commit install --hook-type commit-msg
194
195 [testenv:pre-commit-uninstall]
196 basepython = python3
197 deps = pre-commit
198 commands =
199     pre-commit uninstall
200     pre-commit uninstall --hook-type commit-msg
201
202 [testenv:pre-commit]
203 basepython = python3
204 deps = pre-commit
205 passenv = HOME
206 commands =
207     pre-commit run --all-files --show-diff-on-failure
208     pre-commit run gitlint --hook-stage commit-msg --commit-msg-filename .git/COMMIT_EDITMSG
209     # Gitlint only proposes a pre-commit configuration for the commit-msg stage but none for the commit stage.
210     # Its default arguments --passed and --msg-filename are different from CI recommandations.
211     # As a result, the line above is always skipped in jenkins CI since there cannot be a .git/COMMIT_EDITMSG file.
212     # A dedicated gitlint profile for CI is proposed below. Also to behave fine locally, this profile must have access
213     # to the HOME variable so that Gitlint can retrieve Git user settings.
214
215 [testenv:gitlint]
216 basepython = python3
217 deps = gitlint
218 commands =
219     gitlint
220