Improve honeynode installation process in tox 38/95338/1
authorguillaume.lambert <guillaume.lambert@orange.com>
Wed, 24 Feb 2021 09:19:10 +0000 (10:19 +0100)
committerguillaume.lambert <guillaume.lambert@orange.com>
Wed, 24 Feb 2021 09:19:10 +0000 (10:19 +0100)
- update install_honeynode.sh script to allow an installation
  per version or a list of versions as argument(s)
  rather than forcing the installing of all versions systematically.
- remove honeynode installation from tox gnpy profile
  since gnpy test does not use any simulator.
- fix flexgrid placement in tox.ini (it should be with 2.2.1 profiles)
- split honeynode installation in 2 lines inside tox.ini
  so that the called profiles only install the honeynode version(s)
  that they need.
  This spares ressources and time on the gate and prevent
  the installation of version 7.1, which is currently not used.

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

tests/install_honeynode.sh
tox.ini

index 0af1ee6a08b055d70de260d506c372d16bebd1d0..d88dc8857881369f9fea6ec243122ee47af8869b 100755 (executable)
@@ -2,6 +2,8 @@
 
 #set -x
 
+VERSIONS_LIST=${@:-"1.2.1 2.2.1 7.1"}
+
 #check if curl exists
 if ! [ -x "$(command -v curl)" ];then
     echo "curl is not installed." >&2
@@ -13,33 +15,38 @@ if ! [ -x "$(command -v unzip)" ];then
     exit 1
 fi
 
-#clean honeynode directories
+for VERSION in $VERSIONS_LIST
+do
+    case "$VERSION" in
+        "1.2.1") PLUGIN_VERSION=1.0.4
+        ;;
+        "2.2.1") PLUGIN_VERSION=2.0.5
+        ;;
+        "7.1") PLUGIN_VERSION=7.1.2
+        ;;
+        *) echo "unsupported device version" >&2
+        continue
+        ;;
+    esac
+    TARGET_DIR=$(dirname $0)/honeynode/$VERSION
+    INSTALL_DIR=$TARGET_DIR/honeynode-simulator
+    ARTIFACT_ZIPFILE=$TARGET_DIR/artifact.zip
+    TARGET_URL="https://gitlab.com/api/v4/projects/17518226/jobs/artifacts/honeynode-plugin-aggregator-$PLUGIN_VERSION/download?job=mvn-build"
 
-if [ -d "$(dirname $0)/honeynode/1.2.1/honeynode-simulator" ];then
-    echo "Removing $(dirname $0)/honeynode/1.2.1/honeynode-simulator directory"
-    rm -rf $(dirname $0)/honeynode/1.2.1/honeynode-simulator
-fi
-if [ -d "$(dirname $0)/honeynode/2.2.1/honeynode-simulator" ];then
-    echo "Removing $(dirname $0)/honeynode/2.2.1/honeynode-simulator directory"
-    rm -rf $(dirname $0)/honeynode/2.2.1/honeynode-simulator
-fi
-if [ -d "$(dirname $0)/honeynode/7.1/honeynode-simulator" ];then
-    echo "Removing $(dirname $0)/honeynode/7.1/honeynode-simulator directory"
-    rm -rf $(dirname $0)/honeynode/7.1/honeynode-simulator
-fi
-#download honeynode for 1.2.1 devices and install it
-#complete source code can be found at https://gitlab.com/Orange-OpenSource/lfn/odl/honeynode-simulator.git
-echo "Installing honeynode for 1.2.1 devices to $(dirname $0)/honeynode/1.2.1/honeynode-simulator directory "
-curl -sS --location --request GET "https://gitlab.com/api/v4/projects/17518226/jobs/artifacts/honeynode-plugin-aggregator-1.0.4/download?job=mvn-build" -o $(dirname $0)/honeynode/1.2.1/artifact.zip
-unzip -q $(dirname $0)/honeynode/1.2.1/artifact.zip -d $(dirname $0)/honeynode/1.2.1
-rm -f $(dirname $0)/honeynode/1.2.1/artifact.zip
-#download honeynode for 2.2.1 devices and install it
-echo "Installing honeynode for 2.2.1 devices to $(dirname $0)/honeynode/2.2.1/honeynode-simulator directory "
-curl -sS --location --request GET "https://gitlab.com/api/v4/projects/17518226/jobs/artifacts/honeynode-plugin-aggregator-2.0.5/download?job=mvn-build" -o $(dirname $0)/honeynode/2.2.1/artifact.zip
-unzip -q $(dirname $0)/honeynode/2.2.1/artifact.zip -d $(dirname $0)/honeynode/2.2.1
-rm -f $(dirname $0)/honeynode/2.2.1/artifact.zip
-#download honeynode for 7.1 devices and install it
-echo "Installing honeynode for 7.1 devices to $(dirname $0)/honeynode/7.1/honeynode-simulator directory "
-curl -sS --location --request GET "https://gitlab.com/api/v4/projects/17518226/jobs/artifacts/honeynode-plugin-aggregator-7.1.2/download?job=mvn-build" -o $(dirname $0)/honeynode/7.1/artifact.zip
-unzip -q $(dirname $0)/honeynode/7.1/artifact.zip -d $(dirname $0)/honeynode/7.1
-rm -f $(dirname $0)/honeynode/7.1/artifact.zip
+    #clean honeynode install directory
+
+    if [ -d "$INSTALL_DIR" ];then
+        echo "Removing $INSTALL_DIR directory"
+        rm -rf $INSTALL_DIR
+    fi
+
+    #download honeynode  and install it
+    #complete source code can be found at https://gitlab.com/Orange-OpenSource/lfn/odl/honeynode-simulator.git
+
+    echo "Installing honeynode for $VERSION devices to $INSTALL_DIR directory "
+    curl -sS --location --request GET $TARGET_URL -o $ARTIFACT_ZIPFILE
+    unzip -q $ARTIFACT_ZIPFILE -d $TARGET_DIR
+    rm -f $ARTIFACT_ZIPFILE
+
+done
+exit
diff --git a/tox.ini b/tox.ini
index c8917cc050f7f1dc1f2ebcf2c3f25902c5e58b6c..bcc41929d4e79ae82eb3b00925cac2aadcbcf243 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -18,23 +18,23 @@ whitelist_externals = sh
 changedir={toxinidir}/tests
 commands =
 #install maven and JDK11 on the Gate since they are not there by default
-  {py3,portmapping,topoPortMapping,flexgrid,rspn,topology,pce,olm,end2end,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otntopology,olm221,tapi221,otnend2end,end2end221,gnpy}: - sh -c "if [ ! `which mvn` ]; then ./installMavenCentOS.sh  ; fi"
-#install honeynode simulators
-  {py3,portmapping,topoPortMapping,flexgrid,rspn,topology,pce,olm,end2end,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otntopology,olm221,tapi221,otnend2end,end2end221,gnpy}: - sh -c "./install_honeynode.sh"
+  {py3,portmapping,topoPortMapping,rspn,topology,pce,olm,end2end,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otntopology,flexgrid,olm221,tapi221,otnend2end,end2end221,gnpy}: - sh -c "if [ ! `which mvn` ]; then ./installMavenCentOS.sh  ; fi"
+#install honeynode 1.2.1 simulators
+  {py3,portmapping,topoPortMapping,rspn,topology,pce,olm,end2end}: - sh -c "./install_honeynode.sh 1.2.1"
 #patch OLM constant to speed up tests, unnecessary for PCE
   {py3,portmapping,topoPortMapping,rspn,topology,olm,end2end,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otn-topology,olm221,otnend2end,end2end221,tapi221}: - sh -c "sed -i'_' 's@=.*//#FUNCTESTVAL=@=@g' ../olm/src/main/java/org/opendaylight/transportpce/olm/util/OlmUtils.java"
 #build controller, source JDK_JAVA_OPTIONS to remove illegal reflective acces warnings introduced by Java11
-  {py3,portmapping,topoPortMapping,flexgrid,rspn,topology,pce,olm,end2end,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otntopology,olm221,tapi221,otnend2end,end2end221,gnpy}: - sh -c ". $PWD/reflectwarn.sh && cd .. && mvn clean install -s tests/odl_settings.xml -DskipTests -Dmaven.javadoc.skip=true -Dodlparent.spotbugs.skip -Dodlparent.checkstyle.skip"
+  {py3,portmapping,topoPortMapping,rspn,topology,pce,olm,end2end,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otntopology,flexgrid,olm221,tapi221,otnend2end,end2end221,gnpy}: - sh -c ". $PWD/reflectwarn.sh && cd .. && mvn clean install -s tests/odl_settings.xml -DskipTests -Dmaven.javadoc.skip=true -Dodlparent.spotbugs.skip -Dodlparent.checkstyle.skip"
   {py3,portmapping,topoPortMapping,rspn,topology,olm,end2end,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otn-topology,olm221,otnend2end,end2end221,tapi221}: - 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"
 #patch Karaf exec for the same reason at runtime
-  {py3,portmapping,topoPortMapping,flexgrid,rspn,topology,pce,olm,end2end,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otntopology,olm221,tapi221,otnend2end,end2end221,gnpy}: - sh -c "sed -i'_' 's@!/bin/sh@!/bin/sh\'$'\n. $(dirname $0)/../../../../tests/reflectwarn.sh@' ../karaf/target/assembly/bin/karaf"
+  {py3,portmapping,topoPortMapping,rspn,topology,pce,olm,end2end,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otntopology,flexgrid,olm221,tapi221,otnend2end,end2end221,gnpy}: - sh -c "sed -i'_' 's@!/bin/sh@!/bin/sh\'$'\n. $(dirname $0)/../../../../tests/reflectwarn.sh@' ../karaf/target/assembly/bin/karaf"
   # the following command would be the straight and right way to support both BSD and GNU sed versions
   # sh -c "sed -i'_' '1 a\'$'\n. \$(dirname \$0)/\.\./\.\./\.\./\.\./tests/reflectwarn.sh\n' ../karaf/target/assembly/bin/karaf"
   # but tox reinterprets the quotes as
   # sh -c 'sed -i'"'"'_'"'"' '"'"'1 a\'"'"'$'"'"'\n. \$(dirname \$0)/\.\./\.\./\.\./\.\./tests/reflectwarn.sh\n'"'"' ../karaf/target/assembly/bin/karaf'
   # ,what results in an unexpected different formating (with a $ on the second line and the dot on the third)
 #build Lighty if needed
-  {py3,portmapping,topoPortMapping,flexgrid,rspn,topology,pce,olm,end2end,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otntopology,olm221,tapi221,otnend2end,end2end221,gnpy}: - sh -c 'if [ "$USE_LIGHTY" = "True" ]; then (cd ../lighty && ./build.sh); fi'
+  {py3,portmapping,topoPortMapping,rspn,topology,pce,olm,end2end,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otntopology,flexgrid,olm221,tapi221,otnend2end,end2end221,gnpy}: - sh -c 'if [ "$USE_LIGHTY" = "True" ]; then (cd ../lighty && ./build.sh); fi'
 #run 1.2.1 functional tests
   {py3,portmapping}: nosetests --with-xunit transportpce_tests/1.2.1/test_portmapping.py
   {py3,topoPortMapping}: nosetests --with-xunit transportpce_tests/1.2.1/test_topo_portmapping.py
@@ -44,6 +44,8 @@ commands =
   {py3,olm}: nosetests --with-xunit transportpce_tests/1.2.1/test_olm.py
   #E2E 1.2.1 moved at the end before 2.2.1 E2E
 #run 2.2.1 functional tests
+#install honeynode 2.2.1 simulators
+  {py3,portmapping221,rspn221,otnrenderer,otnshrenderer,topology221,otntopology,flexgrid,olm221,tapi221,otnend2end,end2end221}: - sh -c "./install_honeynode.sh 2.2.1"
   {py3,portmapping221}: nosetests --with-xunit transportpce_tests/2.2.1/test_portmapping.py
   {py3,topology221}: nosetests --with-xunit transportpce_tests/2.2.1/test_topology.py
   {py3,otntopology}: nosetests --with-xunit transportpce_tests/2.2.1/test_otn_topology.py