summaryrefslogtreecommitdiffstats
path: root/profiles/robot/src/main/resources
diff options
context:
space:
mode:
Diffstat (limited to 'profiles/robot/src/main/resources')
-rw-r--r--profiles/robot/src/main/resources/META-INF/services/org.onap.cli.fw.cmd.OnapCommand15
-rw-r--r--profiles/robot/src/main/resources/open-cli-schema/robot/default_input_parameters_robot.yaml37
-rw-r--r--profiles/robot/src/main/resources/script/run-robot-testcase.py84
3 files changed, 136 insertions, 0 deletions
diff --git a/profiles/robot/src/main/resources/META-INF/services/org.onap.cli.fw.cmd.OnapCommand b/profiles/robot/src/main/resources/META-INF/services/org.onap.cli.fw.cmd.OnapCommand
new file mode 100644
index 00000000..f69721e2
--- /dev/null
+++ b/profiles/robot/src/main/resources/META-INF/services/org.onap.cli.fw.cmd.OnapCommand
@@ -0,0 +1,15 @@
+# Copyright 2020 Simran Singhal.
+#
+# 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.
+
+org.onap.cli.fw.robot.cmd.OnapRobotCommand \ No newline at end of file
diff --git a/profiles/robot/src/main/resources/open-cli-schema/robot/default_input_parameters_robot.yaml b/profiles/robot/src/main/resources/open-cli-schema/robot/default_input_parameters_robot.yaml
new file mode 100644
index 00000000..31687a74
--- /dev/null
+++ b/profiles/robot/src/main/resources/open-cli-schema/robot/default_input_parameters_robot.yaml
@@ -0,0 +1,37 @@
+# Copyright 2020 Simran Singhal.
+#
+# 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.
+
+open_cli_schema_version: 1.0
+
+parameters:
+ - name: variables-file-path
+ description: Variables file path
+ type: string
+ short_option: x
+ long_option: variables-file-path
+ is_optional: true
+ default_value: ''
+ - name: api-tests-folder-path
+ type: string
+ description: Location to api-tests folder
+ short_option: l
+ long_option: api-tests-folder-path
+ is_optional: false
+ - name: format
+ type: string
+ description: Output formats, supported formats such as table, csv, json, yaml
+ short_option: f
+ long_option: format
+ default_value: text
+ is_default_param: true \ No newline at end of file
diff --git a/profiles/robot/src/main/resources/script/run-robot-testcase.py b/profiles/robot/src/main/resources/script/run-robot-testcase.py
new file mode 100644
index 00000000..9fe0f607
--- /dev/null
+++ b/profiles/robot/src/main/resources/script/run-robot-testcase.py
@@ -0,0 +1,84 @@
+#!/usr/bin/python
+# Copyright 2020 Simran Singhal.
+#
+# 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.
+
+import os
+import argparse
+import uuid
+from robot import run
+from argparse import RawTextHelpFormatter
+
+def execute_robot_run(request_id, test_suite, testcase, variables_file_path):
+ output_dir = os.getenv('OPEN_CLI_HOME') + '/data/executions/' + request_id + '/logs'
+
+ with open('run.txt', 'w') as output:
+ if(variables_file_path):
+ run(test_suite, report=None, log=None, test=testcase, variablefile=variables_file_path, stdout=output, stderr=output, outputdir=output_dir)
+ else:
+ run(test_suite, report=None, log=None, test=testcase, stdout=output, stderr=output, outputdir=output_dir)
+
+ if os.path.exists('run.txt'):
+ with open('run.txt', 'r') as log:
+ print(log.read())
+ os.remove('run.txt')
+
+def main():
+ text = 'This command helps to run a robot testcase\n' \
+ 'These python modules are need to be installed for running the tests\n' \
+ 'robotframework==3.1\n' \
+ 'RESTinstance==1.0.0rc4\n' \
+ 'robotframework-dependencylibrary==1.0.0.post1\n' \
+ 'robotframework-jsonlibrary==0.3\n' \
+ 'robotframework-jsonschemalibrary==1.0\n' \
+ 'robotframework-mockserver==0.0.4\n'
+
+ parser = argparse.ArgumentParser(description=text, formatter_class=RawTextHelpFormatter)
+ parser.add_argument('--request-id', action='store', dest='request_id',
+ help='Request Id to track the progress of running this script',
+ default=os.environ.get('OPEN_CLI_REQUEST_ID'))
+ parser.add_argument('--test-suite', action='store', dest='test_suite',
+ help='Location to test suite file', required=True)
+ parser.add_argument('--testcase', action='store', dest='testcase',
+ help='Name of the testcase', required=True, nargs='+')
+ parser.add_argument('--variables-file-path', action='store', dest='variables_file_path',
+ help='Location to variable file', nargs='?', const='')
+
+ args = parser.parse_args()
+
+ request_id = args.request_id
+ test_suite = args.test_suite
+ testcase = ' '.join(args.testcase)
+ variables_file_path = ''
+
+ if not request_id:
+ request_id = str(uuid.uuid4())
+
+ if args.variables_file_path:
+ variables_file_path = args.variables_file_path
+
+ if os.path.exists(variables_file_path):
+
+ if not os.path.isfile(variables_file_path):
+ raise Exception('Given variable file path is not a file\n')
+
+ else:
+ raise Exception('Given variable file path does not exist\n')
+
+ if not os.path.exists(test_suite):
+ raise Exception('Given api-tests folder location does not exist\n')
+
+ execute_robot_run(request_id,test_suite, testcase, variables_file_path)
+
+if __name__ == '__main__':
+ main()