diff options
28 files changed, 477 insertions, 225 deletions
@@ -60,3 +60,8 @@ docs/_build/ # PyBuilder target/ + +*~ +.*.sw? +/docs_build/ +/docs_output/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000..980a15ac --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + 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. diff --git a/docs/etc/conf.py b/docs/etc/conf.py deleted file mode 100644 index 65e85db9..00000000 --- a/docs/etc/conf.py +++ /dev/null @@ -1,31 +0,0 @@ -import datetime - - -try: - __import__('imp').find_module('sphinx.ext.numfig') - extensions = ['sphinx.ext.numfig'] -except ImportError: - # 'pip install sphinx_numfig' - extensions = ['sphinx_numfig'] - -# numfig: -number_figures = True -figure_caption_prefix = "Fig." - -source_suffix = '.rst' -master_doc = 'index' -pygments_style = 'sphinx' -html_use_index = False - -pdf_documents = [('index', u'OPNFV', u'OPNFV Project', u'OPNFV')] -pdf_fit_mode = "shrink" -pdf_stylesheets = ['sphinx', 'kerning', 'a4'] - -latex_elements = { - 'printindex': '', -} - -project = u'OPNFV: Template documentation config' -copyright = u'%s, OPNFV' % datetime.date.today().year -version = u'1.0.0' -release = u'1.0.0' diff --git a/docs/etc/opnfv-logo.png b/docs/etc/opnfv-logo.png Binary files differdeleted file mode 100644 index 1519503e..00000000 --- a/docs/etc/opnfv-logo.png +++ /dev/null diff --git a/docs/how-to-use-docs/documentation-example.rst b/docs/how-to-use-docs/documentation-example.rst deleted file mode 100644 index 89b95075..00000000 --- a/docs/how-to-use-docs/documentation-example.rst +++ /dev/null @@ -1,87 +0,0 @@ -.. two dots create a comment. please leave this logo at the top of each of your rst files. -.. image:: ../etc/opnfv-logo.png - :height: 40 - :width: 200 - :alt: OPNFV - :align: left -.. these two pipes are to seperate the logo from the first title -| -| -How to create documentation for your OPNFV project -================================================== - -this is the directory structure of the docs/ directory that can be found in the root of your project directory - -.. code-block:: bash - - ./etc - ./etc/opnfv-logo.png - ./etc/conf.py - ./how-to-use-docs - ./how-to-use-docs/documentation-example.rst - ./how-to-use-docs/index.rst - -To create your own documentation, Create any number of directories (depending on your need) -and place in each of them an index.rst. -This index file must refence your other rst files. - -* Here is an example index.rst - -.. code-block:: bash - - Example Documentation table of contents - ======================================= - - Contents: - - .. toctree:: - :numbered: - :maxdepth: 4 - - documentation-example.rst - - Indices and tables - ================== - - * :ref:`search` - - Revision: _sha1_ - - Build date: |today| - - -The Sphinx Build -================ - -When you push documentation changes to gerrit a jenkins job will create html documentation. - -* Verify Jobs -For verify jobs a link to the documentation will show up as a comment in gerrit for you to see the result. - -* Merge jobs - -Once you are happy with the look of your documentation you can submit the patchset the merge job will -copy the output of each documentation directory to http://artifacts.opnfv.org/$project/docs/$name_of_your_folder/index.html - -Here are some quick examples of how to use rst markup - -This is a headline:: - - here is some code, note that it is indented - -links are easy to add: Here is a link to sphinx, the tool that we are using to generate documetation http://sphinx-doc.org/ - -* Bulleted Items - - **this will be bold** - -.. code-block:: bash - - echo "Heres is a code block with bash syntax highlighting" - - -Leave these at the bottom of each of your documents they are used internally - -Revision: _sha1_ - -Build date: |today| diff --git a/docs/how-to-use-docs/index.rst b/docs/how-to-use-docs/index.rst deleted file mode 100644 index 713599c0..00000000 --- a/docs/how-to-use-docs/index.rst +++ /dev/null @@ -1,34 +0,0 @@ -.. OPNFV Release Engineering documentation, created by - sphinx-quickstart on Tue Jun 9 19:12:31 2015. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -.. image:: ../etc/opnfv-logo.png - :height: 40 - :width: 200 - :alt: OPNFV - :align: left - -Example Documentation table of contents -======================================= - -Contents: - -.. toctree:: - :numbered: - :maxdepth: 4 - - documentation-example.rst - 01-introduction.rst - 02-methodology.rst - 03-usage-guide.rst - - -Indices and tables -================== - -* :ref:`search` - -Revision: _sha1_ - -Build date: |today| diff --git a/func/cli.py b/func/cli.py index 5e8f02cf..4613b507 100644 --- a/func/cli.py +++ b/func/cli.py @@ -54,13 +54,15 @@ class cli: @staticmethod def _parse_args(args): parser = argparse.ArgumentParser() - parser.add_argument('-l ', '--lab', help='Name of Lab on which being tested, These can' + parser.add_argument('-l ', '--lab', required=True, help='Name of Lab ' + 'on which being tested, These can' 'be found in the test_cases/ directory. Please ' 'ensure that you have edited the respective files ' 'before using them. For testing other than through Jenkins' ' The user should list default after -l . all the fields in' ' the files are necessary and should be filled') - parser.add_argument('-f', '--file', help='File in test_list with the list of tests. there are three files' + parser.add_argument('-f', '--file', required=True, help='File in ' + 'test_list with the list of tests. there are three files' '\n compute ' '\n storage ' '\n network ' diff --git a/func/spawn_vm.py b/func/spawn_vm.py index ec63230c..15c26861 100644 --- a/func/spawn_vm.py +++ b/func/spawn_vm.py @@ -26,7 +26,6 @@ class SpawnVM(Env_setup): installer = ''
def __init__(self, vm_info):
- Env_setup.__init__(self)
print 'SpawnVM Class initiated'
vm_role_ip_dict = vm_info.copy()
print 'Generating Heat Template\n'
diff --git a/requirements.txt b/requirements.txt index 358b7d0d..af07083d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,3 +7,6 @@ python-cinderclient==1.4.0 python-heatclient==0.6.0 python-keystoneclient==1.6.0 reportlab==3.0 +Flask==0.11.1 +Flask-RESTful==0.3.5 +flask-restful-swagger==0.19 diff --git a/restful_server/__init__.py b/restful_server/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/restful_server/__init__.py diff --git a/restful_server/db.py b/restful_server/db.py new file mode 100644 index 00000000..b8314de2 --- /dev/null +++ b/restful_server/db.py @@ -0,0 +1,48 @@ +############################################################################## +# Copyright (c) 2016 ZTE Corp 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 +############################################################################## +from datetime import datetime +import uuid + +jobs = {} + + +def create_job(args): + if len(filter(lambda x: jobs[x]['state'] == 'processing', jobs.keys())) > 0: + return None + else: + job = {'job_id': str(uuid.uuid4()), + 'installer_type': args["installer_type"], + 'installer_ip': args["installer_ip"], + 'pod_name': args["pod_name"], + 'suite_name': args["suite_name"], + 'deadline': args["deadline"], + 'type': args["type"], + 'start-time': str(datetime.now()), + 'end-time': None, + 'state': 'processing', + 'state_detail': [], + 'result': []} + jobs[job['job_id']] = job + return job['job_id'] + + +def delete_job(job_id): + if job_id in jobs.keys(): + jobs[job_id]['end_time'] = datetime.now() + jobs[job_id]['state'] = 'terminated' + return True + else: + return False + + +def get_job_info(job_id): + if job_id in jobs.keys(): + return jobs[job_id] + else: + return None diff --git a/restful_server/qtip_server.py b/restful_server/qtip_server.py new file mode 100644 index 00000000..59588363 --- /dev/null +++ b/restful_server/qtip_server.py @@ -0,0 +1,138 @@ +############################################################################## +# Copyright (c) 2016 ZTE Corp 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 +############################################################################## +from flask import Flask, abort +from flask_restful import Api, Resource, fields, reqparse +from flask_restful_swagger import swagger +import db + + +app = Flask(__name__) +api = swagger.docs(Api(app), apiVersion='0.1') + + +@swagger.model +class JobModel: + resource_fields = { + 'installer_type': fields.String, + 'installer_ip': fields.String, + 'deadline': fields.Integer, + 'pod_name': fields.String, + 'suite_name': fields.String, + 'type': fields.String + } + required = ['installer_type', 'install_ip'] + + +@swagger.model +class JobResponseModel: + resource_fields = { + 'job_id': fields.String + } + + +class Job(Resource): + @swagger.operation( + notes='get a job by ID', + nickname='get', + parameters=[], + responseMessages=[ + { + "code": 200, + "message": "Job detail info." + }, + { + "code": 404, + "message": "Can't not find the job id XXXXXXX" + } + ] + ) + def get(self, id): + ret = db.get_job_info(id) + return ret if ret else abort(404, " Can't not find the job id %s" % id) + + @swagger.operation( + notes='delete a job by ID', + nickname='delete', + parameters=[], + responseMessages=[ + { + "code": 200, + "message": "Delete successfully" + }, + { + "code": 404, + "message": "Can not find job_id XXXXXXXXX" + } + ] + ) + def delete(self, id): + ret = db.delete_job(id) + return {'result': "Delete successfully"} if ret else abort(404, "Can not find job_id %s" % id) + + +class JobList(Resource): + @swagger.operation( + note='create a job with parameters', + nickname='create', + parameters=[ + { + "name": "body", + "description": """ +"installer_type": The installer type, for example fuel, compass.., + +"installer_ip": The installer ip of the pod, + +"deadline": If specified, the maximum duration in minutes +for any single test iteration, default is '10', + +"pod_name": If specified, the Pod name, default is 'default', + +"suite_name": If specified, Test suite name, for example 'compute', 'network', 'storage', 'all', +default is 'all' +"type": BM or VM,default is 'BM' + """, + "required": True, + "type": "JobModel", + "paramType": "body" + } + ], + type=JobResponseModel.__name__, + responseMessages=[ + { + "code": 200, + "message": "Job submitted" + }, + { + "code": 400, + "message": "Missing configuration data" + }, + { + "code": 409, + "message": "It already has one job running now!" + } + ] + ) + def post(self): + parser = reqparse.RequestParser() + parser.add_argument('installer_type', type=str, required=True, help='Installer_type is required') + parser.add_argument('installer_ip', type=str, required=True, help='Installer_ip is required') + parser.add_argument('deadline', type=int, required=False, default=10, help='dealine should be integer') + parser.add_argument('pod_name', type=str, required=False, default='default', help='pod_name should be string') + parser.add_argument('suite_name', type=str, required=False, default='all', help='suite_name should be string') + parser.add_argument('type', type=str, required=False, default='BM', help='type should be BM, VM and ALL') + args = parser.parse_args() + ret = db.create_job(args) + return {'job_id': str(ret)} if ret else abort(409, 'message:It already has one job running now!') + + +api.add_resource(JobList, '/api/v1.0/jobs') +api.add_resource(Job, '/api/v1.0/jobs/<string:id>') + +if __name__ == "__main__": + app.run(debug=True) diff --git a/test_cases/zte-pod1/compute/dhrystone_bm.yaml b/test_cases/zte-pod1/compute/dhrystone_bm.yaml index 437dafd8..15a40d42 100644 --- a/test_cases/zte-pod1/compute/dhrystone_bm.yaml +++ b/test_cases/zte-pod1/compute/dhrystone_bm.yaml @@ -17,12 +17,6 @@ Context: Virtual_Machines: - Proxy_Environment: - http_proxy: http://10.20.0.1:8118 - https_proxy: http://10.20.0.1:8118 - no_proxy: localhost,127.0.0.1,10.20.*,192.168.* - - Test_Description: Test_category: "Compute" diff --git a/test_cases/zte-pod1/compute/dhrystone_vm.yaml b/test_cases/zte-pod1/compute/dhrystone_vm.yaml index 6f213426..9e3f2113 100644 --- a/test_cases/zte-pod1/compute/dhrystone_vm.yaml +++ b/test_cases/zte-pod1/compute/dhrystone_vm.yaml @@ -20,11 +20,6 @@ Context: flavor: m1.large role: host - Proxy_Environment: - http_proxy: http://10.20.0.1:8118 - https_proxy: http://10.20.0.1:8118 - no_proxy: localhost,127.0.0.1,10.20.*,192.168.* - Test_Description: Test_category: "Compute" Benchmark: "dhrystone" diff --git a/test_cases/zte-pod1/compute/dpi_bm.yaml b/test_cases/zte-pod1/compute/dpi_bm.yaml index d1c5963e..940307c3 100644 --- a/test_cases/zte-pod1/compute/dpi_bm.yaml +++ b/test_cases/zte-pod1/compute/dpi_bm.yaml @@ -14,10 +14,6 @@ Context: role: host Virtual_Machines: - Proxy_Environment: - http_proxy: http://10.20.0.1:8118 - https_proxy: http://10.20.0.1:8118 - no_proxy: localhost,127.0.0.1,10.20.*,192.168.* Test_Description: Test_category: "Compute" diff --git a/test_cases/zte-pod1/compute/dpi_vm.yaml b/test_cases/zte-pod1/compute/dpi_vm.yaml index d47b7f31..e61bf79f 100644 --- a/test_cases/zte-pod1/compute/dpi_vm.yaml +++ b/test_cases/zte-pod1/compute/dpi_vm.yaml @@ -20,11 +20,6 @@ Context: role: 1Run flavor: m1.large - Proxy_Environment: - http_proxy: http://10.20.0.1:8118 - https_proxy: http://10.20.0.1:8118 - no_proxy: localhost,127.0.0.1,10.20.*,192.168.* - Test_Description: Test_category: "Compute" Benchmark: "dpi" diff --git a/test_cases/zte-pod1/compute/ramspeed_bm.yaml b/test_cases/zte-pod1/compute/ramspeed_bm.yaml index d9e1f170..f126a19d 100644 --- a/test_cases/zte-pod1/compute/ramspeed_bm.yaml +++ b/test_cases/zte-pod1/compute/ramspeed_bm.yaml @@ -17,10 +17,6 @@ Context: Virtual_Machines: - Proxy_Environment: - http_proxy: http://10.20.0.1:8118 - https_proxy: http://10.20.0.1:8118 - no_proxy: localhost,127.0.0.1,10.20.*,192.168.* Test_Description: diff --git a/test_cases/zte-pod1/compute/ramspeed_vm.yaml b/test_cases/zte-pod1/compute/ramspeed_vm.yaml index 942aa3fe..7a2ef849 100644 --- a/test_cases/zte-pod1/compute/ramspeed_vm.yaml +++ b/test_cases/zte-pod1/compute/ramspeed_vm.yaml @@ -20,10 +20,6 @@ Context: flavor: m1.large role: host - Proxy_Environment: - http_proxy: http://10.20.0.1:8118 - https_proxy: http://10.20.0.1:8118 - no_proxy: localhost,127.0.0.1,10.20.*,192.168.* Test_Description: Test_category: "Compute" diff --git a/test_cases/zte-pod1/compute/ssl_bm.yaml b/test_cases/zte-pod1/compute/ssl_bm.yaml index e4f608e6..95d53840 100644 --- a/test_cases/zte-pod1/compute/ssl_bm.yaml +++ b/test_cases/zte-pod1/compute/ssl_bm.yaml @@ -14,12 +14,6 @@ Context: role: host Virtual_Machines: - Proxy_Environment: - http_proxy: http://10.20.0.1:8118 - https_proxy: http://10.20.0.1:8118 - no_proxy: localhost,127.0.0.1,10.20.*,192.168.* - - Test_Description: Test_category: "Compute" Benchmark: "ssl" diff --git a/test_cases/zte-pod1/compute/ssl_vm.yaml b/test_cases/zte-pod1/compute/ssl_vm.yaml index cc97ecfd..60045903 100644 --- a/test_cases/zte-pod1/compute/ssl_vm.yaml +++ b/test_cases/zte-pod1/compute/ssl_vm.yaml @@ -19,10 +19,6 @@ Context: flavor: 'm1.large' role: host - Proxy_Environment: - http_proxy: http://10.20.0.1:8118 - https_proxy: http://10.20.0.1:8118 - no_proxy: localhost,127.0.0.1,10.20.*,192.168.* Test_Description: Test_category: "Compute" diff --git a/test_cases/zte-pod1/compute/whetstone_bm.yaml b/test_cases/zte-pod1/compute/whetstone_bm.yaml index 6c703de1..bf14ea3a 100644 --- a/test_cases/zte-pod1/compute/whetstone_bm.yaml +++ b/test_cases/zte-pod1/compute/whetstone_bm.yaml @@ -16,12 +16,6 @@ Context: role: host Virtual_Machines: - Proxy_Environment: - http_proxy: http://10.20.0.1:8118 - https_proxy: http://10.20.0.1:8118 - no_proxy: localhost,127.0.0.1,10.20.*,192.168.* - - Test_Description: Test_category: "Compute" Benchmark: "whetstone" diff --git a/test_cases/zte-pod1/compute/whetstone_vm.yaml b/test_cases/zte-pod1/compute/whetstone_vm.yaml index bcde58c1..9f12597f 100644 --- a/test_cases/zte-pod1/compute/whetstone_vm.yaml +++ b/test_cases/zte-pod1/compute/whetstone_vm.yaml @@ -20,10 +20,6 @@ Context: flavor: m1.large role: host - Proxy_Environment: - http_proxy: http://10.20.0.1:8118 - https_proxy: http://10.20.0.1:8118 - no_proxy: localhost,127.0.0.1,10.20.*,192.168.* Test_Description: Test_category: "Compute" diff --git a/test_cases/zte-pod1/network/iperf_bm.yaml b/test_cases/zte-pod1/network/iperf_bm.yaml index 5b2126fd..e022d4a4 100644 --- a/test_cases/zte-pod1/network/iperf_bm.yaml +++ b/test_cases/zte-pod1/network/iperf_bm.yaml @@ -21,11 +21,6 @@ Context: Virtual_Machines: - Proxy_Environment: - http_proxy: http://10.20.0.1:8118 - https_proxy: http://10.20.0.1:8118 - no_proxy: localhost,127.0.0.1,10.20.*,192.168.* - Test_Description: Test_category: "network" Benchmark: "iperf" diff --git a/test_cases/zte-pod1/network/iperf_vm.yaml b/test_cases/zte-pod1/network/iperf_vm.yaml index f03b5b6f..57e09e02 100644 --- a/test_cases/zte-pod1/network/iperf_vm.yaml +++ b/test_cases/zte-pod1/network/iperf_vm.yaml @@ -27,11 +27,6 @@ Context: role: 2-host flavor: m1.large - Proxy_Environment: - http_proxy: http://10.20.0.1:8118 - https_proxy: http://10.20.0.1:8118 - no_proxy: localhost,127.0.0.1,10.20.*,192.168.* - Test_Description: Test_category: "network" Benchmark: "iperf" diff --git a/test_cases/zte-pod1/network/iperf_vm_2.yaml b/test_cases/zte-pod1/network/iperf_vm_2.yaml index 649adf8c..c3cd6b35 100644 --- a/test_cases/zte-pod1/network/iperf_vm_2.yaml +++ b/test_cases/zte-pod1/network/iperf_vm_2.yaml @@ -28,10 +28,6 @@ Context: role: 2-host flavor: m1.large - Proxy_Environment: - http_proxy: http://10.20.0.1:8118 - https_proxy: http://10.20.0.1:8118 - no_proxy: localhost,127.0.0.1,10.20.*,192.168.* Test_Description: Test_category: "network" diff --git a/test_cases/zte-pod1/storage/fio_bm.yaml b/test_cases/zte-pod1/storage/fio_bm.yaml index d07623c5..e940e9ba 100644 --- a/test_cases/zte-pod1/storage/fio_bm.yaml +++ b/test_cases/zte-pod1/storage/fio_bm.yaml @@ -17,10 +17,6 @@ Context: Virtual_Machines: - Proxy_Environment: - http_proxy: http://10.20.0.1:8118 - https_proxy: http://10.20.0.1:8118 - no_proxy: localhost,127.0.0.1,10.20.*,192.168.* Test_Description: diff --git a/test_cases/zte-pod1/storage/fio_vm.yaml b/test_cases/zte-pod1/storage/fio_vm.yaml index 3e2f9174..65a1e67b 100644 --- a/test_cases/zte-pod1/storage/fio_vm.yaml +++ b/test_cases/zte-pod1/storage/fio_vm.yaml @@ -20,10 +20,6 @@ Context: flavor: m1.large role: host - Proxy_Environment: - http_proxy: http://10.20.0.1:8118 - https_proxy: http://10.20.0.1:8118 - no_proxy: localhost,127.0.0.1,10.20.*,192.168.* Test_Description: Test_category: "Storage" diff --git a/tests/qtip_server_test.py b/tests/qtip_server_test.py new file mode 100644 index 00000000..31aa96dc --- /dev/null +++ b/tests/qtip_server_test.py @@ -0,0 +1,78 @@ +import restful_server.qtip_server as server +import pytest +import json + + +@pytest.fixture +def app(): + return server.app + + +@pytest.fixture +def app_client(app): + client = app.test_client() + return client + + +class TestClass: + @pytest.mark.parametrize("body, expected", [ + ({'installer_type': 'fuel', + 'installer_ip': '10.20.0.2'}, + {'job_id': '', + 'installer_type': 'fuel', + 'installer_ip': '10.20.0.2', + 'pod_name': 'default', + 'suite_name': 'all', + 'deadline': 10, + 'type': 'BM', + 'state': 'processing', + 'state_detail': [], + 'result': []}), + ({'installer_type': 'fuel', + 'installer_ip': '10.20.0.2', + 'pod_name': 'zte-pod1', + 'deadline': 20, + 'suite_name': 'compute', + 'type': 'VM'}, + {'job_id': '', + 'installer_type': 'fuel', + 'installer_ip': '10.20.0.2', + 'pod_name': 'zte-pod1', + 'suite_name': 'compute', + 'deadline': 20, + 'type': 'VM', + 'state': 'processing', + 'state_detail': [], + 'result': []}) + ]) + def test_post_get_delete_job_successful(self, app_client, body, expected): + reply = app_client.post("/api/v1.0/jobs", data=body) + print reply.data + id = json.loads(reply.data)['job_id'] + expected['job_id'] = id + get_reply = app_client.get("/api/v1.0/jobs/%s" % id) + reply_data = json.loads(get_reply.data) + assert len(filter(lambda x: reply_data[x] == expected[x], expected.keys())) == len(expected) + delete_reply = app_client.delete("/api/v1.0/jobs/%s" % id) + assert "successful" in delete_reply.data + + @pytest.mark.parametrize("body, expected", [ + ([{'installer_type': 'fuel', + 'installer_ip': '10.20.0.2'}, + {'installer_type': 'compass', + 'installer_ip': '192.168.20.50'}], + ['job_id', + 'It already has one job running now!']), + ([{'installer_type': 'fuel', + 'installer_ip': '10.20.0.2'}, + {'installer_type': 'compass', + 'insta_ip': '192.168.20.50'}], + ['job_id', + 'Installer_ip is required']) + ]) + def test_post_two_jobs_unsuccessful(self, app_client, body, expected): + reply_1 = app_client.post("/api/v1.0/jobs", data=body[0]) + reply_2 = app_client.post("/api/v1.0/jobs", data=body[1]) + assert expected[0] in json.loads(reply_1.data).keys() + app_client.delete("/api/v1.0/jobs/%s" % json.loads(reply_1.data)['job_id']) + assert expected[1] in json.dumps(reply_2.data) |