Add a tox profile to install lightynode 27/110127/7
authorGilles Thouenon <gilles.thouenon@orange.com>
Fri, 2 Feb 2024 16:52:55 +0000 (17:52 +0100)
committerChristophe Betoule <christophe.betoule@orange.com>
Thu, 29 Feb 2024 16:53:51 +0000 (17:53 +0100)
- create a new tox profile that install lightynode
- fix a bug when lightynode directory was not present
- adapt the shell script to be able to specify eiter a specific released
or snapshot version to install
- make tox fail when download fails

JIRA: TRNSPRTPCE-754
Signed-off-by: Gilles Thouenon <gilles.thouenon@orange.com>
Change-Id: I8660893e48a02d6c355fb6d63778ee5667cd2b69

tests/install_lightynode.sh
tox.ini

index 50102621db6348c9020576a6b03f675833c27dc8..6d1f52e200b4b47fab75faa90f663b388de523e2 100755 (executable)
@@ -2,6 +2,8 @@
 
 #set -x
 
+PLUGIN_VERSION=${1:-19.1.0.3}
+
 #check if curl exists
 if ! [ -x "$(command -v curl)" ];then
     echo "curl is not installed." >&2
@@ -13,11 +15,22 @@ if ! [ -x "$(command -v unzip)" ];then
     exit 1
 fi
 
-PLUGIN_VERSION=18.1.0.8
+if [ -n "$2" ];then
+    echo "Using lighynode version $1 $2"
+    FILE_NAME="lighty-openroadm-device-$(echo $1 | cut -d - -f 1)-$2-bin.zip"
+    TARGET_URL="https://gitlab.com/api/v4/projects/36076125/packages/maven/io/lighty/transportpce/netconf/device/lighty-openroadm-device/$PLUGIN_VERSION/${FILE_NAME}"
+else
+    echo "Using lighynode version $PLUGIN_VERSION"
+    TARGET_URL="https://gitlab.com/api/v4/projects/36076125/packages/maven/io/lighty/transportpce/netconf/device/lighty-openroadm-device/$PLUGIN_VERSION/lighty-openroadm-device-$PLUGIN_VERSION-bin.zip"
+fi
+
 TARGET_DIR=$(dirname $0)/lightynode
 INSTALL_DIR=$TARGET_DIR/lightynode-openroadm-device
 ARTIFACT_ZIPFILE=$TARGET_DIR/artifact.zip
-TARGET_URL="https://gitlab.com/api/v4/projects/36076125/packages/maven/io/lighty/transportpce/netconf/device/lighty-openroadm-device/$PLUGIN_VERSION/lighty-openroadm-device-$PLUGIN_VERSION-bin.zip"
+if ! [ -d "$TARGET_DIR" ];then
+    echo "Creating 'lightynode' directory."
+    mkdir lightynode
+fi
 
 #clean lightynode install directory
 if [ -d "$INSTALL_DIR" ];then
@@ -28,8 +41,8 @@ fi
 #download lightynode  and install it
 #complete source code can be found at https://gitlab.com/Orange-OpenSource/lfn/odl/lightynode-simulator.git
 echo "Installing lightynode device to $INSTALL_DIR directory "
-curl --retry-delay 10 --retry 3 -sS --location --request GET $TARGET_URL -o $ARTIFACT_ZIPFILE || exit 2
-unzip -q $ARTIFACT_ZIPFILE -d $TARGET_DIR
+curl --retry-delay 10 --retry 3 -sS --fail --location --request GET $TARGET_URL -o $ARTIFACT_ZIPFILE || exit 2
+unzip -q -o $ARTIFACT_ZIPFILE -d $TARGET_DIR
 rm -f $ARTIFACT_ZIPFILE
 mv $TARGET_DIR/lighty-openroadm-device-$PLUGIN_VERSION $INSTALL_DIR
 
diff --git a/tox.ini b/tox.ini
index 1c3d9abf60064b2383c4f818b7bf81267b86bf3e..2f79e58107334b5b0ea2c5728aabdd4fbc3aa29e 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -62,6 +62,13 @@ changedir = {toxinidir}/lighty
 commands =
   ./build.sh
 
+[testenv:sims]
+passenv = USE_SIMS
+allowlist_externals = install_lightynode.sh
+depends = buildcontroller
+commands =
+  ./install_lightynode.sh {posargs:}
+
 [testenv:sims121]
 passenv = USE_SIMS
 allowlist_externals = install_sims.sh