yaml parser for bluval 18/518/11
authorNaga Sugguna <ns156u@att.com>
Sat, 23 Mar 2019 06:53:38 +0000 (01:53 -0500)
committerNaga Sugguna <ns156u@att.com>
Tue, 9 Apr 2019 13:37:30 +0000 (08:37 -0500)
Creating YAML parser for loading, validating and executing
testcases mentioned in yaml file.

Change-Id: Id183e2e08e6cbc5f030db1e5ff6b7ca7ef6662d6
Signed-off-by: Naga Sugguna <ns156u@att.com>
bluval/README.md [new file with mode: 0644]
bluval/bluval-base.yaml [new file with mode: 0644]
bluval/bluval.py [new file with mode: 0644]
bluval/requirements.txt [new file with mode: 0644]
helloworld/helloworld.robot [new file with mode: 0644]

diff --git a/bluval/README.md b/bluval/README.md
new file mode 100644 (file)
index 0000000..0ccd6c5
--- /dev/null
@@ -0,0 +1,10 @@
+# BluVal
+
+## Installation
+
+Minimum required python verson is python3.5
+
+```
+python3 -m pip install -r requirements.txt
+```
+
diff --git a/bluval/bluval-base.yaml b/bluval/bluval-base.yaml
new file mode 100644 (file)
index 0000000..4a9ce70
--- /dev/null
@@ -0,0 +1,77 @@
+---
+##############################################################################
+# Copyright (c) 2019 AT&T Intellectual Property.                             #
+# Copyright (c) 2019 Nokia.                                                  #
+#                                                                            #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
+# not use this file except in compliance with the License.                   #
+#                                                                            #
+# You may obtain a copy of the License at                                    #
+#       http://www.apache.org/licenses/LICENSE-2.0                           #
+#                                                                            #
+# Unless required by applicable law or agreed to in writing, software        #
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT  #
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.           #
+# See the License for the specific language governing permissions and        #
+# limitations under the License.                                             #
+##############################################################################
+blueprint:
+    name: base
+    sections:
+        - hw
+        - os
+        - networking
+        - k8s
+        - k8s_networking
+        - sds
+        - sdn
+        - vim
+    # Any hardware some basic tests
+    hw: &hw_base
+        -
+            name: bios_version
+            # something that can be evaluated to true or false
+            condition: true
+            what: /opt/akraino/validation/helloworld
+            # true or false, default is false
+            show_stopper: false
+    os: &os_base
+        -
+            name: os_version
+            what: /opt/akraino/validation/helloworld
+    networking: &networking
+        -
+            name: pxe_networking_test
+            what: /opt/akraino/validation/helloworld
+        -
+            name: routes_test
+            what: /opt/akraino/validation/helloworld
+    k8s: &k8s
+        -
+            name: conformance
+            what: /opt/akraino/validation/helloworld
+        -
+            name: e2e
+            what: /opt/akraino/validation/helloworld
+    k8s_networking: &k8s_networking
+        -
+            name: node_connectivity
+            what: /opt/akraino/validation/helloworld
+        -
+            name: pod_connectivity
+            what: /opt/akraino/validation/helloworld
+    # software defined storage
+    sds: &sds
+        -
+            name: sds
+            what: /opt/akraino/validation/helloworld
+    # software defined network
+    sdn: &sdn
+        -
+            name: sns
+            what: /opt/akraino/validation/helloworld
+    # Virtual Infrastructure Manager
+    vim: &vim
+        -
+            name: vim_basic
+            what: /opt/akraino/validation/helloworld
diff --git a/bluval/bluval.py b/bluval/bluval.py
new file mode 100644 (file)
index 0000000..bf5e0c8
--- /dev/null
@@ -0,0 +1,62 @@
+#!/usr/bin/python3
+##############################################################################
+# Copyright (c) 2019 AT&T Intellectual Property.                             #
+# Copyright (c) 2019 Nokia.                                                  #
+#                                                                            #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
+# not use this file except in compliance with the License.                   #
+#                                                                            #
+# You may obtain a copy of the License at                                    #
+#       http://www.apache.org/licenses/LICENSE-2.0                           #
+#                                                                            #
+# Unless required by applicable law or agreed to in writing, software        #
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT  #
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.           #
+# See the License for the specific language governing permissions and        #
+# limitations under the License.                                             #
+##############################################################################
+"""This module parses yaml file, reads sections, testcases and executes each
+testcase
+"""
+
+import subprocess
+import sys
+import yaml
+
+def run_testcase(testcase):
+    """Runs a single testcase
+    """
+    show_stopper = testcase.get('show_stopper', False)
+
+    print('Executing testcase {}'.format(testcase['name']))
+    print('          show_stopper {}'.format(show_stopper))
+    cmd = 'robot {}'.format(testcase['what'])
+    print('Invoking {}'.format(cmd))
+    try:
+        status = subprocess.call(cmd, shell=True)
+        if status != 0 and testcase['show_stopper']:
+            print('Show stopper testcase failed')
+            return status
+    except OSError:
+        print('Error while executing {}'.format(cmd))
+        return -1
+    return status
+
+
+def parse_yaml(testcase_loc):
+    """Parse yaml file and do tasks on each testcase
+    """
+    with open(testcase_loc) as testcase_file:
+        testcases = yaml.safe_load(testcase_file)
+    blueprint = testcases['blueprint']
+    for section in blueprint['sections']:
+        print('## Section {}'.format(section))
+        for testcase in blueprint[section]:
+            run_testcase(testcase)
+
+
+if __name__ == "__main__":
+    if len(sys.argv) != 2:
+        print('usage: bluval.py <testcase.yaml>')
+        sys.exit(1)
+    parse_yaml(sys.argv[1])
diff --git a/bluval/requirements.txt b/bluval/requirements.txt
new file mode 100644 (file)
index 0000000..c3726e8
--- /dev/null
@@ -0,0 +1 @@
+pyyaml
diff --git a/helloworld/helloworld.robot b/helloworld/helloworld.robot
new file mode 100644 (file)
index 0000000..aa85d18
--- /dev/null
@@ -0,0 +1,22 @@
+##############################################################################
+# Copyright (c) 2019 AT&T Intellectual Property.                             #
+# Copyright (c) 2019 Nokia.                                                  #
+#                                                                            #
+# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
+# not use this file except in compliance with the License.                   #
+#                                                                            #
+# You may obtain a copy of the License at                                    #
+#       http://www.apache.org/licenses/LICENSE-2.0                           #
+#                                                                            #
+# Unless required by applicable law or agreed to in writing, software        #
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT  #
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.           #
+# See the License for the specific language governing permissions and        #
+# limitations under the License.                                             #
+##############################################################################
+*** Test Cases ***
+Test With Settings
+    [Documentation]    Another dummy test
+    [Tags]    dummy    owner-johndoe
+    Log    Hello, world!
+