make Honeynode and tox scripts BSD compatible 86/88486/4
authorguillaume.lambert <guillaume.lambert@orange.com>
Wed, 18 Mar 2020 12:39:16 +0000 (13:39 +0100)
committerguillaume.lambert <guillaume.lambert@orange.com>
Thu, 19 Mar 2020 13:47:58 +0000 (14:47 +0100)
- use a sed syntax compatible with both BSD and GNU versions
- replace /bin/bash by /bin/sh (regular bourne shell)
  make necessary adaptations for compatibility
- upgrade python psutils requirements to 5.6.7
  most BSD does not support earlier version with python 3.7

Co-authored-by: Shweta Vachhani <sv111y@att.com>
Signed-off-by: guillaume.lambert <guillaume.lambert@orange.com>
Change-Id: I6d390cede8abbbd44f92554e7b0f164ae5c0b173

tests/buildHoneynode.sh
tests/honeynode/1.2.1/minimal-distribution-core/src/main/resources/honeycomb-minimal-resources/honeycomb-tpce
tests/honeynode/2.2.1/minimal-distribution-core/src/main/resources/honeycomb-minimal-resources/honeycomb-tpce
tests/requirements.txt
tests/transportpce_tests/1.2.1/test_utils.py
tests/transportpce_tests/2.2.1/test_utils.py
tox.ini

index 11633563aa931774407275d250ed4ee7ff22bcdb..d91bd9ead2f8e294c8cf68c18c6f2687a130db16 100755 (executable)
@@ -1,9 +1,9 @@
-#!/bin/bash
+#!/bin/sh
 
 ORDMVERSION=${1:-1.2.1}
 
 set -e
-. reflectwarn.sh
+. $(dirname $0)/reflectwarn.sh
 cd honeynode/$ORDMVERSION
 mvn clean install -DskipTests -Dcheckstyle.skip -Dmaven.javadoc.skip=true -s ../fd_io_honeycomb_settings.xml -q -V
 chmod +x ./honeynode-distribution/target/honeynode-distribution-1.19.04-hc/honeynode-distribution-1.19.04/honeycomb-tpce
index 091954c10226060b297c2b499ea83f068f8a1f96..331ca69d01dde567632df3169b7a716c142d17a0 100755 (executable)
@@ -32,18 +32,18 @@ then
         filename=$(basename -- "$CONFIG")
         device=$(basename "$CONFIG" .xml)
         echo "changing netconf port with $PORT in netconf.json file ..."
-        sed -i' ' "/netconf-ssh-binding-port/c\  \"netconf-ssh-binding-port\" : "$PORT"," $(dirname $0)/config/netconf.json
+        sed  -i' ' "s/\"netconf-ssh-binding-port\".*,/\"netconf-ssh-binding-port\" : "$PORT",/g" $(dirname $0)/config/netconf.json
         echo "changing restconf http port with $REST_HTTP in restconf.json file ..."
-        sed -i' ' "/restconf-port/c\  \"restconf-port\" : "$REST_HTTP"," $(dirname $0)/config/restconf.json
+        sed  -i' ' "s/\"restconf-port\".*,/\"restconf-port\" : "$REST_HTTP",/g" $(dirname $0)/config/restconf.json
         echo "changing restconf websocket with $REST_WEBSOCKET in restconf.json file ..."
-        sed -i' ' "/restconf-websocket-port/c\  \"restconf-websocket-port\" : "$REST_WEBSOCKET"," $(dirname $0)/config/restconf.json
+        sed  -i' ' "s/\"restconf-websocket-port\".*,/\"restconf-websocket-port\" : "$REST_WEBSOCKET",/g" $(dirname $0)/config/restconf.json
         echo "changing restconf-https-enabled to false in restconf.json file ..."
-        sed -i' ' "/restconf-https-enabled/c\  \"restconf-https-enabled\" : \"false\"," $(dirname $0)/config/restconf.json
+        sed  -i' ' "s/\"restconf-https-enabled\".*,/\"restconf-https-enabled\" : \"false\",/g" $(dirname $0)/config/restconf.json
         echo "changing persist-context and persist-config to false in honeycomb.json file ..."
-        sed -i' ' "/persist-context/c\  \"persist-context\" : \"false\"," $(dirname $0)/config/honeycomb.json
-        sed -i' ' "/persist-config/c\  \"persist-config\" : \"false\"," $(dirname $0)/config/honeycomb.json
+        sed  -i' ' "s/\"persist-context\".*,/\"persist-context\" : \"false\",/g" $(dirname $0)/config/honeycomb.json
+        sed  -i' ' "s/\"persist-config\".*,/\"persist-config\" : \"false\",/g" $(dirname $0)/config/honeycomb.json
         echo "changing netconf-initial-config-xml location with $CONFIG in honeycomb.json file ..."
-        sed -i' ' "/netconf-initial-config-xml/c\  \"netconf-initial-config-xml\" : \"device/$filename\"," $(dirname $0)/config/honeycomb.json
+        sed -i' ' "s@\"netconf-initial-config-xml\".*,@\"netconf-initial-config-xml\" : \"device/$filename\",@g" $(dirname $0)/config/honeycomb.json
          while [ $STATUS -eq 100 ]
          do
            . $(dirname $0)/../../../../../../reflectwarn.sh
index e4e2afc29e3d84093dc9938a599cb2915e9b3833..331ca69d01dde567632df3169b7a716c142d17a0 100755 (executable)
@@ -6,16 +6,16 @@ JAVA_VER=$("$JAVA_CMD" -version 2>&1 | sed -n ';s/.* version "\(.*\)\.\(.*\)\..*
 echo $JAVA_VER
 [ "$JAVA_VER" -ge 110 ] && echo "ok, java is 11 or newer" || { echo "it's too old..."; exit 1; }
 if [ -d  $(dirname $0)/config/yang/common ]; then
-        mv  $(dirname $0)/config/yang/common/*  $(dirname $0)/config/yang/.
-        rm -rf  $(dirname $0)/config/yang/common
+    mv  $(dirname $0)/config/yang/common/*  $(dirname $0)/config/yang/.
+    rm -rf  $(dirname $0)/config/yang/common
 fi
 if [ -d  $(dirname $0)/config/yang/devices ]; then
-        mv  $(dirname $0)/config/yang/devices/*  $(dirname $0)/config/yang/.
-        rm -rf  $(dirname $0)/config/yang/devices
+    mv  $(dirname $0)/config/yang/devices/*  $(dirname $0)/config/yang/.
+    rm -rf  $(dirname $0)/config/yang/devices
 fi
 if [ -d  $(dirname $0)/config/yang/openconfig ]; then
-        mv  $(dirname $0)/config/yang/openconfig/*  $(dirname $0)/config/yang/.
-        rm -rf  $(dirname $0)/config/yang/openconfig
+    mv  $(dirname $0)/config/yang/openconfig/*  $(dirname $0)/config/yang/.
+    rm -rf  $(dirname $0)/config/yang/openconfig
 fi
 
 if [ "$#" -ge 2 ]
@@ -32,18 +32,18 @@ then
         filename=$(basename -- "$CONFIG")
         device=$(basename "$CONFIG" .xml)
         echo "changing netconf port with $PORT in netconf.json file ..."
-        sed -i' ' "/netconf-ssh-binding-port/c\  \"netconf-ssh-binding-port\" : "$PORT"," $(dirname $0)/config/netconf.json
+        sed  -i' ' "s/\"netconf-ssh-binding-port\".*,/\"netconf-ssh-binding-port\" : "$PORT",/g" $(dirname $0)/config/netconf.json
         echo "changing restconf http port with $REST_HTTP in restconf.json file ..."
-        sed -i' ' "/restconf-port/c\  \"restconf-port\" : "$REST_HTTP"," $(dirname $0)/config/restconf.json
+        sed  -i' ' "s/\"restconf-port\".*,/\"restconf-port\" : "$REST_HTTP",/g" $(dirname $0)/config/restconf.json
         echo "changing restconf websocket with $REST_WEBSOCKET in restconf.json file ..."
-        sed -i' ' "/restconf-websocket-port/c\  \"restconf-websocket-port\" : "$REST_WEBSOCKET"," $(dirname $0)/config/restconf.json
+        sed  -i' ' "s/\"restconf-websocket-port\".*,/\"restconf-websocket-port\" : "$REST_WEBSOCKET",/g" $(dirname $0)/config/restconf.json
         echo "changing restconf-https-enabled to false in restconf.json file ..."
-        sed -i' ' "/restconf-https-enabled/c\  \"restconf-https-enabled\" : \"false\"," $(dirname $0)/config/restconf.json
+        sed  -i' ' "s/\"restconf-https-enabled\".*,/\"restconf-https-enabled\" : \"false\",/g" $(dirname $0)/config/restconf.json
         echo "changing persist-context and persist-config to false in honeycomb.json file ..."
-        sed -i' ' "/persist-context/c\  \"persist-context\" : \"false\"," $(dirname $0)/config/honeycomb.json
-        sed -i' ' "/persist-config/c\  \"persist-config\" : \"false\"," $(dirname $0)/config/honeycomb.json
+        sed  -i' ' "s/\"persist-context\".*,/\"persist-context\" : \"false\",/g" $(dirname $0)/config/honeycomb.json
+        sed  -i' ' "s/\"persist-config\".*,/\"persist-config\" : \"false\",/g" $(dirname $0)/config/honeycomb.json
         echo "changing netconf-initial-config-xml location with $CONFIG in honeycomb.json file ..."
-        sed -i' ' "/netconf-initial-config-xml/c\  \"netconf-initial-config-xml\" : \"device/$filename\"," $(dirname $0)/config/honeycomb.json
+        sed -i' ' "s@\"netconf-initial-config-xml\".*,@\"netconf-initial-config-xml\" : \"device/$filename\",@g" $(dirname $0)/config/honeycomb.json
          while [ $STATUS -eq 100 ]
          do
            . $(dirname $0)/../../../../../../reflectwarn.sh
index a28f5ce443b6683a9d6d65340a4f4392aea4ab73..5ebd5e2e7e5284c53e9b5ce37a494f002859846c 100644 (file)
@@ -1,2 +1,2 @@
-psutil>=3.0.1 # 3-clause / New BSD License
+psutil>=5.6.7 # 3-clause / New BSD License
 requests!=2.12.2,>=2.10.0 # Apache License 2.0
index 618dfb572623df622cd0ec97f45bb189236105ca..5d9aacf59bdb3c53196ba0e151b427bb3b73c12d 100644 (file)
@@ -70,12 +70,12 @@ def start_tpce():
         executable = "../lighty/target/lighty-transportpce-12.0.0-SNAPSHOT/clean-start-controller.sh"
         with open('odl.log', 'w') as outfile:
             return subprocess.Popen(
-                ["bash", executable], stdout=outfile, stderr=outfile,
+                ["sh", executable], stdout=outfile, stderr=outfile,
                 stdin=open(os.devnull))
     else:
         print ("starting KARAF TransportPCE build...")
         executable = "../karaf/target/assembly/bin/karaf"
         with open('odl.log', 'w') as outfile:
             return subprocess.Popen(
-                ["bash", executable, "server"], stdout=outfile, stderr=outfile,
+                ["sh", executable, "server"], stdout=outfile, stderr=outfile,
                 stdin=open(os.devnull))
index 699072b314cb9505b13b9a6f29c7d9f48b48c369..ec577ad0743090969f50aeac59158157f419d398 100644 (file)
@@ -61,12 +61,12 @@ def start_tpce():
         executable = "../lighty/target/lighty-transportpce-12.0.0-SNAPSHOT/clean-start-controller.sh"
         with open('odl.log', 'w') as outfile:
             return subprocess.Popen(
-                ["bash", executable], stdout=outfile, stderr=outfile,
+                ["sh", executable], stdout=outfile, stderr=outfile,
                 stdin=open(os.devnull))
     else:
         print ("starting KARAF TransportPCE build...")
         executable = "../karaf/target/assembly/bin/karaf"
         with open('odl.log', 'w') as outfile:
             return subprocess.Popen(
-                ["bash", executable, "server"], stdout=outfile, stderr=outfile,
+                ["sh", executable, "server"], stdout=outfile, stderr=outfile,
                 stdin=open(os.devnull))
diff --git a/tox.ini b/tox.ini
index 325dc7d09b09b45d6367ff73dde58bc975dc4007..efaf6da929e6c327a073d48a6e7c8a9ff260109b 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -13,22 +13,22 @@ basepython = python3
 deps =
   -r{toxinidir}/tests/requirements.txt
   -r{toxinidir}/tests/test-requirements.txt
-whitelist_externals = bash
+whitelist_externals = sh
                       sudo
 changedir={toxinidir}/tests
 commands =
 #install maven and JDK11 on the Gate since they are not there by default
-  {py3,portmapping,topoPortMapping,rspn,topology,pce,olm,end2end,portmapping221,rspn221,otnrenderer,topology221,otntopology,olm221,end2end221,gnpy}: - bash -c "if [ ! `which mvn` ]; then ./installMavenCentOS.sh  ; fi"
+  {py3,portmapping,topoPortMapping,rspn,topology,pce,olm,end2end,portmapping221,rspn221,otnrenderer,topology221,otntopology,olm221,end2end221,gnpy}: - sh -c "if [ ! `which mvn` ]; then ./installMavenCentOS.sh  ; fi"
 #build 1.2.1 sims
-  {py3,portmapping,topoPortMapping,rspn,topology,olm,end2end}: - bash -c "./buildHoneynode.sh"
+  {py3,portmapping,topoPortMapping,rspn,topology,olm,end2end}: - sh -c "./buildHoneynode.sh"
 #patch OLM constant to speed up tests, unnecessary for PCE
-  {py3,portmapping,topoPortMapping,rspn,topology,olm,end2end,portmapping221,rspn221,otnrenderer,topology221,otn-topology,olm221,end2end221}: - bash -c "sed -i' ' 's@=.*//#FUNCTESTVAL=@=@g' ../olm/src/main/java/org/opendaylight/transportpce/olm/util/OlmUtils.java"
+  {py3,portmapping,topoPortMapping,rspn,topology,olm,end2end,portmapping221,rspn221,otnrenderer,topology221,otn-topology,olm221,end2end221}: - 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,rspn,topology,pce,olm,end2end,portmapping221,rspn221,otnrenderer,topology221,otntopology,olm221,end2end221,gnpy}: - bash -c ". 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,topology221,otntopology,olm221,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"
 #patch Karaf exec for the same reason at runtime
-  {py3,portmapping,topoPortMapping,rspn,topology,pce,olm,end2end,portmapping221,rspn221,otnrenderer,topology221,otntopology,olm221,end2end221,gnpy}: - bash -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,topology221,otntopology,olm221,end2end221,gnpy}: - sh -c "sed -i' ' 's@!/bin/sh@!/bin/sh\'$'\n. $(dirname $0)/../../../../tests/reflectwarn.sh@' ../karaf/target/assembly/bin/karaf"
 #build Lighty if needed
-  {py3,portmapping,topoPortMapping,rspn,topology,pce,olm,end2end,portmapping221,rspn221,otnrenderer,topology221,otntopology,olm221,end2end221,gnpy}: - bash -c 'if [ "$USE_LIGHTY" == "True" ]; then (cd ../lighty && ./build.sh); fi'
+  {py3,portmapping,topoPortMapping,rspn,topology,pce,olm,end2end,portmapping221,rspn221,otnrenderer,topology221,otntopology,olm221,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_topoPortMapping.py
@@ -38,7 +38,7 @@ commands =
   {py3,olm}: nosetests --with-xunit transportpce_tests/1.2.1/test_olm.py
   {end2end}: nosetests --with-xunit transportpce_tests/1.2.1/test_end2end.py
 #build 2.2.1 sims
-  {py3,portmapping221,rspn221,otnrenderer,topology221,otntopology,olm221,end2end221}: - bash -c "./buildHoneynode.sh 2.2.1"
+  {py3,portmapping221,rspn221,otnrenderer,topology221,otntopology,olm221,end2end221}: - sh -c "./buildHoneynode.sh 2.2.1"
 #run 2.2.1 functional tests
   {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