Add initial unit test 51/451/8
authorYang (Gabriel) Yu <Gabriel.yuyang@huawei.com>
Thu, 7 Mar 2019 07:05:26 +0000 (15:05 +0800)
committerYang (Gabriel) Yu <Gabriel.yuyang@huawei.com>
Wed, 3 Apr 2019 02:29:28 +0000 (10:29 +0800)
JIRA: ELIOT-1

Add verify scirpits enabling python style test

Changes:
1. add verigy.sh
2. add requirements/verify.txt

Change-Id: Ibb628d3c0cb92670000513c66815e1b00e6302f2
Signed-off-by: Yang (Gabriel) Yu <Gabriel.yuyang@huawei.com>
eliot/__init__.py [new file with mode: 0644]
eliot/test.sh [new file with mode: 0644]
flake8_cfg [new file with mode: 0644]
requirements/verify.txt [new file with mode: 0644]
verify.sh [new file with mode: 0644]

diff --git a/eliot/__init__.py b/eliot/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/eliot/test.sh b/eliot/test.sh
new file mode 100644 (file)
index 0000000..fb6f29f
--- /dev/null
@@ -0,0 +1 @@
+:ls
diff --git a/flake8_cfg b/flake8_cfg
new file mode 100644 (file)
index 0000000..c51bf82
--- /dev/null
@@ -0,0 +1,6 @@
+[flake8]
+format = pylint
+statistics = True
+count = True
+show_source = True
+exclude = ./bottlenecks_venv/
diff --git a/requirements/verify.txt b/requirements/verify.txt
new file mode 100644 (file)
index 0000000..93843ee
--- /dev/null
@@ -0,0 +1,15 @@
+##############################################################################
+# Copyright (c) 2016 Huawei Tech. and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+# This file is for verify job excuted by Akraino CI modified from OPNFV
+# Bottlenecks Project
+
+flake8==3.7.7
+nose==1.3.7
+coverage==4.5.2
+yamllint==1.15.0
diff --git a/verify.sh b/verify.sh
new file mode 100644 (file)
index 0000000..7255e43
--- /dev/null
+++ b/verify.sh
@@ -0,0 +1,88 @@
+#!/bin/bash
+
+##############################################################################
+# Copyright (c) 2016 Huawei Tech and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+# Run flake8, unit, coverage test
+
+echo "Running unit tests..."
+
+virtualenv ./bottlenecks_venv
+source ./bottlenecks_venv/bin/activate
+
+# install python packages
+#easy_install -U setuptools
+#easy_install -U pip
+pip install -r ./requirements/verify.txt
+
+getopts ":f" FILE_OPTION
+STYLE_CHECK_DIRS="./"
+
+run_flake8() {
+    echo "========================================="
+    echo "Running flake8 for python style check:   "
+    echo "-----------------------------------------"
+    logfile=flake8_verify.log
+    if [ $FILE_OPTION == "f" ]; then
+       flake8 --config=flake8_cfg ${STYLE_CHECK_DIRS} > $logfile
+    else
+       flake8 --config=flake8_cfg ${STYLE_CHECK_DIRS}
+    fi
+
+    if [ $? -ne 0 ]; then
+        echo "FAILED"
+        if [ $FILE_OPTION == "f" ]; then
+            echo "Results in $logfile"
+        fi
+        exit 1
+    else
+        echo "The patch has passed python style check  "
+        echo "===================END==================="
+    fi
+}
+
+run_yamllint() {
+    echo "========================================="
+    echo "Running yamllint for yaml style check:   "
+    echo "-----------------------------------------"
+    logfile=yamllint_verify.log
+    yamllint ./
+
+    if [ $? -ne 0 ]; then
+        echo "FAILED"
+        if [ $FILE_OPTION == "f" ]; then
+            echo "Results in $logfile"
+        fi
+        exit 1
+    else
+        echo "The patch has passed yaml style check  "
+        echo "===================END==================="
+    fi
+}
+
+run_nosetests() {
+    echo "========================================="
+    echo "Running unit and coverage test:          "
+    echo "-----------------------------------------"
+    echo "Do not include any coverage test yet..."
+    echo "===================END==================="
+
+}
+
+
+for((i=1;i<=1;i++));do echo -e "\n";done
+run_flake8
+
+for((i=1;i<=1;i++));do echo -e "\n";done
+run_nosetests
+
+for((i=1;i<=1;i++));do echo -e "\n";done
+run_yamllint
+
+deactivate