Refactor Karaf builds for tests and tox.ini 99/98199/2
authorguillaume.lambert <guillaume.lambert@orange.com>
Mon, 25 Oct 2021 10:15:02 +0000 (12:15 +0200)
committerGilles Thouenon <gilles.thouenon@orange.com>
Fri, 29 Oct 2021 09:08:21 +0000 (11:08 +0200)
- use dedicated env files for Karaf listening ports settings
- create tox profiles to (re)build Karaf folders dedicated to tests
- adapt tests launcher and build scripts accordingly

This should avoid weird race conditions that can happen when performing
several tests locally.

JIRA: TRNSPRTPCE-482
Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
Change-Id: Icfa0e09e65ed054155002b9e4b07370ca1ad0aaf

docs/tox-guide.rst
tests/build_karaf_for_tests.sh
tests/karaf121.env [new file with mode: 0644]
tests/karaf221.env [new file with mode: 0644]
tests/karaf71.env [new file with mode: 0644]
tests/launch_tests.sh
tox.ini

index fc01f247c53fb96fd6046c0d3418caaa6fd8fa94..1ede63a3c2ef130330899a9ef175b553fdcd856f 100644 (file)
@@ -191,7 +191,7 @@ And::
 
 are equivalent to::
 
-    $ nosetests transportpce_tests/2.2.1/test01_portmapping.py
+    $ nosetests transportpce_tests/7.1/test01_portmapping.py
 
 but will ask tests script to use the controller `lighty.io <https://lighty.io/>`_
 build instead of Karaf.
@@ -214,6 +214,9 @@ Each of these profiles depend on the `buildcontroller` profile, which is simply
 there to build the controller from sources and adapt OLM default timers.
 They can also depend on `sims121` or `sims221` or `sims71` profiles to download
 simulators of OpenROADM devices when needed.
+Other profiles named from the pattern `build_karaf_testsXXX` have also been
+added to configure separate karaf instances with alternate listening ports
+in order to use concurrency.
 
 The `depend` parameter in `tox.ini` allows tox to establish the most efficient
 tests order strategy  when calling tox without the `-e` option.
@@ -226,6 +229,10 @@ For example::
 
     $ tox -e buildcontroller,sims121,tests121
 
+or with karaf alternate builds::
+
+    $ tox -e buildcontroller,build_karaf_tests121,sims121,tests121
+
 will build the controller and download simulators before running every functional
 tests for OpenROADM devices 1.2.1.
 Once that done, you only need to list the others sims versions profiles before
@@ -233,6 +240,10 @@ lauching hybrid tests::
 
     $ tox -e sims221,sims71,tests_hybrid
 
+or with karaf alternate builds::
+
+    $ tox -e build_karaf_tests_hybrid,sims221,sims71,tests_hybrid
+
 Also the same way arguments can be passed to the `launch_tests.sh` script,
 tests names can be passed as argument when calling the corresponding tox profiles.
 
@@ -340,3 +351,7 @@ For example, the following command will test the portmapping behavior
 for every OpenROADM devices supported versions::
 
     $  tox -p 3 -e buildcontroller,sims121,sims221,sims71,tests121,tests221,tests71 portmapping
+
+or with karaf alternate builds::
+
+    $  tox -p 3 -e buildcontroller,build_karaf_tests121,build_karaf_tests221,build_karaf_tests71,sims121,sims221,sims71,tests121,tests221,tests71 portmapping
index 3476e713c2e64a68ec92b9f00c6b0edd9cffe725..e2d13cd12eba411c3a645576e7a49b68aa897c5d 100755 (executable)
@@ -1,15 +1,21 @@
 #!/bin/sh
 
+if [ "$USE_LIGHTY" = "True" ]; then
+    echo "USE_LIGHTY set to True - no need to build karaf"
+    exit
+fi
+
 if [ -z "$USE_ODL_ALT_KARAF_INSTALL_DIR" ]; then
     exit
 fi
 
 cd $(dirname $0)
 
-if [ -f ../"$USE_ODL_ALT_KARAF_INSTALL_DIR"/target/assembly/bin/karaf_ ]; then
+if [ -z "$USE_ODL_ALT_KARAF_ENV" ]; then
     exit
 fi
 
+. $USE_ODL_ALT_KARAF_ENV
 . ./reflectwarn.sh
 cd  ../$USE_ODL_ALT_KARAF_INSTALL_DIR
 mvn clean install -B -q -s ../tests/odl_settings.xml -DskipTests -Dmaven.javadoc.skip=true
diff --git a/tests/karaf121.env b/tests/karaf121.env
new file mode 100644 (file)
index 0000000..078e71e
--- /dev/null
@@ -0,0 +1,7 @@
+export USE_ODL_ALT_WEBSOCKET_PORT=8186
+export USE_ODL_ALT_AKKA_PORT=2551
+export USE_ODL_ALT_AKKA_MGT_PORT=8559
+export USE_ODL_ALT_SHELL_PORT=8102
+export USE_ODL_ALT_RMI_REGISTRY_PORT=1100
+export USE_ODL_ALT_RMI_SERVER_PORT=44445
+export USE_ODL_ALT_RESTCONF_PORT=8182
diff --git a/tests/karaf221.env b/tests/karaf221.env
new file mode 100644 (file)
index 0000000..1366aab
--- /dev/null
@@ -0,0 +1,7 @@
+export USE_ODL_ALT_WEBSOCKET_PORT=8187
+export USE_ODL_ALT_AKKA_PORT=2552
+export USE_ODL_ALT_AKKA_MGT_PORT=8560
+export USE_ODL_ALT_SHELL_PORT=8103
+export USE_ODL_ALT_RMI_REGISTRY_PORT=1101
+export USE_ODL_ALT_RMI_SERVER_PORT=44446
+export USE_ODL_ALT_RESTCONF_PORT=8183
diff --git a/tests/karaf71.env b/tests/karaf71.env
new file mode 100644 (file)
index 0000000..9d8c219
--- /dev/null
@@ -0,0 +1,7 @@
+export USE_ODL_ALT_WEBSOCKET_PORT=8188
+export USE_ODL_ALT_AKKA_PORT=2553
+export USE_ODL_ALT_AKKA_MGT_PORT=8561
+export USE_ODL_ALT_SHELL_PORT=8104
+export USE_ODL_ALT_RMI_REGISTRY_PORT=1102
+export USE_ODL_ALT_RMI_SERVER_PORT=44447
+export USE_ODL_ALT_RESTCONF_PORT=8184
index f1951c2205bf83d9186a62c7c77060df8e3bb3c9..a2f3f1997ddd50e7c02b198161c05aa9f687ea12 100755 (executable)
@@ -1,7 +1,8 @@
 #!/bin/sh
 
-if [ "$USE_LIGHTY" != "True" ]; then
-    ./build_karaf_for_tests.sh
+if [ -n "$USE_ODL_ALT_KARAF_ENV" ]; then
+    echo "using environment variables from $USE_ODL_ALT_KARAF_ENV"
+    . $USE_ODL_ALT_KARAF_ENV
 fi
 
 for arg in $@; do
diff --git a/tox.ini b/tox.ini
index 303b01356a801c5583f958f867f8ce693c77ee56..0751d9b1dd82dc207f89ed4738127273a7708896 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -1,6 +1,10 @@
 [tox]
 minversion = 3.7.0
-envlist = buildcontroller,testsPCE,sims121,tests121,sims221,tests221,sims71,tests71,tests_hybrid
+envlist = buildcontroller,testsPCE,
+    sims121,build_karaf_tests121,tests121,
+    sims221,build_karaf_tests221,tests221,
+    sims71,build_karaf_tests71,tests71,
+    build_karaf_tests_hybrid,tests_hybrid,
     docs
     docs-linkcheck
     checkbashisms
@@ -56,20 +60,26 @@ passenv = LAUNCHER USE_LIGHTY
 commands =
   ./launch_tests.sh pce {posargs:}
 
+[testenv:build_karaf_tests121]
+depends = buildcontroller
+# testsPCE dependency is only here to chain tests in the gate and avoid resources starvation
+whitelist_externals = launch_tests.sh
+passenv = LAUNCHER USE_LIGHTY
+setenv =
+#    USE_LIGHTY=True
+    USE_ODL_ALT_KARAF_ENV=./karaf121.env
+    USE_ODL_ALT_KARAF_INSTALL_DIR=karaf121
+commands =
+  ./build_karaf_for_tests.sh
+
 [testenv:tests121]
-depends = buildcontroller,sims121,testsPCE
+depends = buildcontroller,build_karaf_tests121,sims121,testsPCE
 # testsPCE dependency is only here to chain tests in the gate and avoid resources starvation
 whitelist_externals = launch_tests.sh
 passenv = LAUNCHER USE_LIGHTY
 setenv =
 #    USE_LIGHTY=True
-    USE_ODL_ALT_WEBSOCKET_PORT=8186
-    USE_ODL_ALT_AKKA_PORT=2551
-    USE_ODL_ALT_AKKA_MGT_PORT=8559
-    USE_ODL_ALT_SHELL_PORT=8102
-    USE_ODL_ALT_RMI_REGISTRY_PORT=1100
-    USE_ODL_ALT_RMI_SERVER_PORT=44445
-    USE_ODL_ALT_RESTCONF_PORT=8182
+    USE_ODL_ALT_KARAF_ENV=./karaf121.env
     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf121
 commands =
   ./launch_tests.sh 1.2.1 {posargs:}
@@ -82,41 +92,65 @@ commands =
 # which is more verbose than nose or 'export LAUNCHER="ls -l"' to only list script
 # files attributes.
 
+[testenv:build_karaf_tests221]
+depends = buildcontroller
+# testsPCE dependency is only here to chain tests in the gate and avoid resources starvation
+whitelist_externals = launch_tests.sh
+passenv = LAUNCHER USE_LIGHTY
+setenv =
+#    USE_LIGHTY=True
+    USE_ODL_ALT_KARAF_ENV=./karaf221.env
+    USE_ODL_ALT_KARAF_INSTALL_DIR=karaf221
+commands =
+  ./build_karaf_for_tests.sh
+
 [testenv:tests221]
-depends = buildcontroller,sims221,tests71
+depends = buildcontroller,build_karaf_tests221,sims221,tests71
 # tests71 dependency is only here to chain tests in the gate and avoid ressources starvation
 whitelist_externals = launch_tests.sh
 passenv = LAUNCHER USE_LIGHTY
 setenv =
 #    USE_LIGHTY=True
-    USE_ODL_ALT_WEBSOCKET_PORT=8187
-    USE_ODL_ALT_AKKA_PORT=2552
-    USE_ODL_ALT_AKKA_MGT_PORT=8560
-    USE_ODL_ALT_SHELL_PORT=8103
-    USE_ODL_ALT_RMI_REGISTRY_PORT=1101
-    USE_ODL_ALT_RMI_SERVER_PORT=44446
-    USE_ODL_ALT_RESTCONF_PORT=8183
+    USE_ODL_ALT_KARAF_ENV=./karaf221.env
     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf221
 commands =
   ./launch_tests.sh 2.2.1 {posargs:}
 
+[testenv:build_karaf_tests71]
+depends = buildcontroller
+# testsPCE dependency is only here to chain tests in the gate and avoid resources starvation
+whitelist_externals = launch_tests.sh
+passenv = LAUNCHER USE_LIGHTY
+setenv =
+#    USE_LIGHTY=True
+    USE_ODL_ALT_KARAF_ENV=./karaf71.env
+    USE_ODL_ALT_KARAF_INSTALL_DIR=karaf71
+commands =
+  ./build_karaf_for_tests.sh
+
 [testenv:tests71]
-depends = buildcontroller,sims71
+depends = buildcontroller,build_karaf_tests71,sims71
 whitelist_externals = launch_tests.sh
 passenv = LAUNCHER USE_LIGHTY
 setenv =
 #    USE_LIGHTY=True
-    USE_ODL_ALT_WEBSOCKET_PORT=8188
-    USE_ODL_ALT_AKKA_PORT=2553
-    USE_ODL_ALT_AKKA_MGT_PORT=8561
-    USE_ODL_ALT_SHELL_PORT=8104
-    USE_ODL_ALT_RMI_REGISTRY_PORT=1102
-    USE_ODL_ALT_RMI_SERVER_PORT=44447
-    USE_ODL_ALT_RESTCONF_PORT=8184
+    USE_ODL_ALT_KARAF_ENV=./karaf71.env
     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf71
 commands =
   ./launch_tests.sh 7.1 {posargs:}
 
+[testenv:build_karaf_tests_hybrid]
+depends = buildcontroller
+# testsPCE dependency is only here to chain tests in the gate and avoid resources starvation
+whitelist_externals = launch_tests.sh
+passenv = LAUNCHER USE_LIGHTY
+setenv =
+#    USE_LIGHTY=True
+    USE_ODL_ALT_KARAF_ENV=./karaf121.env
+    USE_ODL_ALT_KARAF_INSTALL_DIR=karaf_hybrid
+commands =
+  ./build_karaf_for_tests.sh
+
 [testenv:tests_hybrid]
 depends = buildcontroller,sims121,sims221,sims71,tests121,tests221,tests71
 #the last dependency is to avoid temporarily concurrent ressources problem in parallel mode
@@ -124,13 +158,7 @@ whitelist_externals = launch_tests.sh
 passenv = LAUNCHER USE_LIGHTY
 setenv =
 #    USE_LIGHTY=True
-    USE_ODL_ALT_WEBSOCKET_PORT=8186
-    USE_ODL_ALT_AKKA_PORT=2551
-    USE_ODL_ALT_AKKA_MGT_PORT=8559
-    USE_ODL_ALT_SHELL_PORT=8102
-    USE_ODL_ALT_RMI_REGISTRY_PORT=1100
-    USE_ODL_ALT_RMI_SERVER_PORT=44445
-    USE_ODL_ALT_RESTCONF_PORT=8182
+    USE_ODL_ALT_KARAF_ENV=./karaf121.env
     USE_ODL_ALT_KARAF_INSTALL_DIR=karaf_hybrid
 commands =
 #  nosetests --with-xunit transportpce_tests/hybrid/test01_device_change_notifications.py