From: guillaume.lambert Date: Wed, 18 Mar 2020 12:39:16 +0000 (+0100) Subject: make Honeynode and tox scripts BSD compatible X-Git-Tag: 2.0.0~176 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=transportpce.git;a=commitdiff_plain;h=f7c30c15a03bfc9250476e225c615dad928b5129 make Honeynode and tox scripts BSD compatible - 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 Signed-off-by: guillaume.lambert Change-Id: I6d390cede8abbbd44f92554e7b0f164ae5c0b173 --- diff --git a/tests/buildHoneynode.sh b/tests/buildHoneynode.sh index 11633563a..d91bd9ead 100755 --- a/tests/buildHoneynode.sh +++ b/tests/buildHoneynode.sh @@ -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 diff --git a/tests/honeynode/1.2.1/minimal-distribution-core/src/main/resources/honeycomb-minimal-resources/honeycomb-tpce b/tests/honeynode/1.2.1/minimal-distribution-core/src/main/resources/honeycomb-minimal-resources/honeycomb-tpce index 091954c10..331ca69d0 100755 --- a/tests/honeynode/1.2.1/minimal-distribution-core/src/main/resources/honeycomb-minimal-resources/honeycomb-tpce +++ b/tests/honeynode/1.2.1/minimal-distribution-core/src/main/resources/honeycomb-minimal-resources/honeycomb-tpce @@ -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 diff --git a/tests/honeynode/2.2.1/minimal-distribution-core/src/main/resources/honeycomb-minimal-resources/honeycomb-tpce b/tests/honeynode/2.2.1/minimal-distribution-core/src/main/resources/honeycomb-minimal-resources/honeycomb-tpce index e4e2afc29..331ca69d0 100755 --- a/tests/honeynode/2.2.1/minimal-distribution-core/src/main/resources/honeycomb-minimal-resources/honeycomb-tpce +++ b/tests/honeynode/2.2.1/minimal-distribution-core/src/main/resources/honeycomb-minimal-resources/honeycomb-tpce @@ -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 diff --git a/tests/requirements.txt b/tests/requirements.txt index a28f5ce44..5ebd5e2e7 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -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 diff --git a/tests/transportpce_tests/1.2.1/test_utils.py b/tests/transportpce_tests/1.2.1/test_utils.py index 618dfb572..5d9aacf59 100644 --- a/tests/transportpce_tests/1.2.1/test_utils.py +++ b/tests/transportpce_tests/1.2.1/test_utils.py @@ -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)) diff --git a/tests/transportpce_tests/2.2.1/test_utils.py b/tests/transportpce_tests/2.2.1/test_utils.py index 699072b31..ec577ad07 100644 --- a/tests/transportpce_tests/2.2.1/test_utils.py +++ b/tests/transportpce_tests/2.2.1/test_utils.py @@ -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 325dc7d09..efaf6da92 100644 --- 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