Make option for test functionality added to tool to upgrade vnf,ns descriptors to... 32/5732/1
authorgcalvino <guillermo.calvinosanchez@altran.com>
Fri, 24 Nov 2017 12:48:51 +0000 (13:48 +0100)
committergcalvino <guillermo.calvinosanchez@altran.com>
Fri, 24 Nov 2017 12:48:51 +0000 (13:48 +0100)
Signed-off-by: gcalvino <guillermo.calvinosanchez@altran.com>
descriptor-packages/mk/dirs.mk
descriptor-packages/tools/launch_tests.sh [new file with mode: 0755]

index 85a05e5..b3df405 100644 (file)
@@ -14,6 +14,9 @@
 #   limitations under the License.
 #
 
+TOPDIR=$(shell readlink -f .|sed -e 's/\/descriptor-packages\/.*//')
+TOOLS_DIR := $(TOPDIR)/tools
+
 SUBDIRS_CLEAN = $(addsuffix .clean, $(SUBDIRS))
 
 .PHONY: $(SUBDIRS) $(SUBDIRS_CLEAN) clean
@@ -27,3 +30,6 @@ $(SUBDIRS_CLEAN): %.clean:
 
 $(SUBDIRS):
        @$(MAKE) --no-print-directory -C $@
+
+test:
+       $(TOOLS_DIR)/launch_tests.sh
diff --git a/descriptor-packages/tools/launch_tests.sh b/descriptor-packages/tools/launch_tests.sh
new file mode 100755 (executable)
index 0000000..066e35c
--- /dev/null
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+
+function test_format
+{
+ folder=$(dir -1)
+
+ for file in $folder;
+ do
+  if [ -n $file ]; then
+       if [ -d "$file" ]; then
+
+            cd $file
+            test_format
+            cd ..
+       else
+            extension=${file##*.}
+            name=${file%.*}
+            folder_file=`pwd`
+            if [ $extension == "yaml" ]; then
+                $tools_dir/upgrade_descriptor_version.py --test -i $folder_file"/"$name.$extension -o $folder_file"/"$name."output" 2> $folder_file"/"$name."error"
+                [ -s $folder_file"/"$name."output" ] || rm $folder_file"/"$name."output"
+                [ -s $folder_file"/"$name."error" ] || rm $folder_file"/"$name."error"
+            fi;
+       fi;
+  fi;
+ done;
+}
+
+
+top_dir=`readlink -f .|sed -e 's/\/descriptor-packages\/.*//'`
+tools_dir=${top_dir}/tools
+
+if [ -f $tools_dir/upgrade_descriptor_version.py ]; then
+    cd ${top_dir}/
+    test_format ./
+else
+    print "Error: 'make' command should be called inside '/devops/descriptor-packages/' folder to work"
+    exit -1
+fi;