From ab78424814fb38a688567daad9c7091b5f58d3d6 Mon Sep 17 00:00:00 2001 From: Naga Sugguna Date: Sat, 23 Mar 2019 01:53:38 -0500 Subject: [PATCH] yaml parser for bluval Creating YAML parser for loading, validating and executing testcases mentioned in yaml file. Change-Id: Id183e2e08e6cbc5f030db1e5ff6b7ca7ef6662d6 Signed-off-by: Naga Sugguna --- bluval/README.md | 10 ++++++ bluval/bluval-base.yaml | 77 +++++++++++++++++++++++++++++++++++++++++++++ bluval/bluval.py | 62 ++++++++++++++++++++++++++++++++++++ bluval/requirements.txt | 1 + helloworld/helloworld.robot | 22 +++++++++++++ 5 files changed, 172 insertions(+) create mode 100644 bluval/README.md create mode 100644 bluval/bluval-base.yaml create mode 100644 bluval/bluval.py create mode 100644 bluval/requirements.txt create mode 100644 helloworld/helloworld.robot diff --git a/bluval/README.md b/bluval/README.md new file mode 100644 index 0000000..0ccd6c5 --- /dev/null +++ b/bluval/README.md @@ -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 index 0000000..4a9ce70 --- /dev/null +++ b/bluval/bluval-base.yaml @@ -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 index 0000000..bf5e0c8 --- /dev/null +++ b/bluval/bluval.py @@ -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 ') + sys.exit(1) + parse_yaml(sys.argv[1]) diff --git a/bluval/requirements.txt b/bluval/requirements.txt new file mode 100644 index 0000000..c3726e8 --- /dev/null +++ b/bluval/requirements.txt @@ -0,0 +1 @@ +pyyaml diff --git a/helloworld/helloworld.robot b/helloworld/helloworld.robot new file mode 100644 index 0000000..aa85d18 --- /dev/null +++ b/helloworld/helloworld.robot @@ -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! + -- 2.16.6