aboutsummaryrefslogtreecommitdiffstats
path: root/profiles
diff options
context:
space:
mode:
authorSimran Singhal <singhalsimran0@gmail.com>2020-11-08 22:58:10 +0530
committerSimran Singhal <singhalsimran0@gmail.com>2020-11-14 10:10:33 +0530
commitc1746d5f32728608f2cec44910ac431a07d7c67d (patch)
treee6b54182c3fca276fbbc2bfa730c97accff94d65 /profiles
parentc08ddaced8c6c5be998933428ae4b44aece23380 (diff)
Add schema validate and refresh
Issue-ID: VNFSDK-614 Change-Id: I5d451b8a486f46bc37e189d3e36d0a1ffe230382 Signed-off-by: Simran Singhal <singhalsimran0@gmail.com>
Diffstat (limited to 'profiles')
-rw-r--r--profiles/robot/src/main/resources/script/discover-robot-testcases.py50
1 files changed, 50 insertions, 0 deletions
diff --git a/profiles/robot/src/main/resources/script/discover-robot-testcases.py b/profiles/robot/src/main/resources/script/discover-robot-testcases.py
index 06c460a3..fbb8d8be 100644
--- a/profiles/robot/src/main/resources/script/discover-robot-testcases.py
+++ b/profiles/robot/src/main/resources/script/discover-robot-testcases.py
@@ -22,6 +22,39 @@ from yaml.representer import SafeRepresenter
from yaml import Dumper
from collections import OrderedDict
import re
+import subprocess
+import sys
+
+class OcompException(Exception):
+ def __init__(self, code, message):
+ super(OcompException, self).__init__()
+ self.code = code;
+ self.message = message;
+
+class OCOMP:
+ def run(self, command, params={}):
+ CMD_NAME = 'oclip'
+ CMD = [CMD_NAME]
+
+ CMD.append(command)
+
+ for name, value in params.items():
+ CMD.append('--{}'.format(name))
+ CMD.append(value)
+
+ cmd_string = ' '.join(CMD)
+
+ try:
+ res = subprocess.Popen(CMD, stdout=subprocess.PIPE)
+ res.wait()
+ return res
+
+ except OSError as e:
+ sys.stderr.write(str(e))
+ msg = 'failed to executed the command {}'.format(cmd_string)
+ print (msg)
+ raise OcompException(9999, msg)
+
class LiteralString(str):
pass
@@ -73,6 +106,17 @@ def create_testcase_yaml(testcase_name, description, testsuite_name, test_suite_
with open(yaml_path + '/' + name + '.yaml', 'w') as file:
yaml.dump(data, file, Dumper=LineBreakDumper, default_flow_style=False)
+ ocomp = OCOMP()
+ res = ocomp.run(command='schema-validate', params={'schema-location': yaml_path + '/' + name + '.yaml'})
+ result = res.stdout.read().strip()
+
+ if res.returncode != 0:
+ if os.path.exists(yaml_path + '/' + name + '.yaml'):
+ os.remove(yaml_path + '/' + name + '.yaml')
+ print (yaml_path + '/' + name + '.yaml')
+ print(result)
+ print()
+
def discover_testcases(api_tests_folder_path):
for root, dirs, files in os.walk(api_tests_folder_path):
@@ -90,6 +134,12 @@ def discover_testcases(api_tests_folder_path):
except Exception as e:
pass
+ ocomp = OCOMP()
+ res = ocomp.run(command='schema-refresh')
+ result = res.stdout.read().strip()
+ if res.returncode != 0:
+ raise OcompException(9999, result)
+
def main():
text = 'This command helps to discover all robot testcases\n' \
'These python modules are need to be installed for running the tests\n' \