diff options
-rw-r--r-- | docs/etc/conf.py | 34 | ||||
-rw-r--r-- | docs/etc/opnfv-logo.png | bin | 0 -> 2829 bytes | |||
-rw-r--r-- | docs/how-to-use-docs/documentation-example.rst | 86 | ||||
-rw-r--r-- | docs/how-to-use-docs/index.rst | 30 | ||||
-rw-r--r-- | keystone-moon/examples/moon/policies/policy_empty_authz/assignment.json | 7 | ||||
-rw-r--r-- | keystone-moon/examples/moon/policies/policy_empty_authz/metadata.json | 12 | ||||
-rw-r--r-- | keystone-moon/examples/moon/policies/policy_empty_authz/metarule.json | 12 | ||||
-rw-r--r-- | keystone-moon/examples/moon/policies/policy_empty_authz/perimeter.json | 5 | ||||
-rw-r--r-- | keystone-moon/examples/moon/policies/policy_empty_authz/rule.json | 3 | ||||
-rw-r--r-- | keystone-moon/examples/moon/policies/policy_empty_authz/scope.json | 7 | ||||
-rw-r--r-- | moonclient/moonclient/tests.py | 71 | ||||
-rw-r--r-- | moonclient/moonclient/tests/tests_external_commands.json | 109 |
12 files changed, 358 insertions, 18 deletions
diff --git a/docs/etc/conf.py b/docs/etc/conf.py new file mode 100644 index 00000000..18deb8b7 --- /dev/null +++ b/docs/etc/conf.py @@ -0,0 +1,34 @@ +import datetime
+import sys
+import os
+
+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_domain_indices = False
+#latex_use_modindex = False
+
+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 differnew file mode 100644 index 00000000..1519503e --- /dev/null +++ b/docs/etc/opnfv-logo.png diff --git a/docs/how-to-use-docs/documentation-example.rst b/docs/how-to-use-docs/documentation-example.rst new file mode 100644 index 00000000..81c9f026 --- /dev/null +++ b/docs/how-to-use-docs/documentation-example.rst @@ -0,0 +1,86 @@ +.. 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 new file mode 100644 index 00000000..8af7427e --- /dev/null +++ b/docs/how-to-use-docs/index.rst @@ -0,0 +1,30 @@ +.. 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
+
+Indices and tables
+==================
+
+* :ref:`search`
+
+Revision: _sha1_
+
+Build date: |today|
diff --git a/keystone-moon/examples/moon/policies/policy_empty_authz/assignment.json b/keystone-moon/examples/moon/policies/policy_empty_authz/assignment.json new file mode 100644 index 00000000..24018a09 --- /dev/null +++ b/keystone-moon/examples/moon/policies/policy_empty_authz/assignment.json @@ -0,0 +1,7 @@ +{ + "subject_assignments": {}, + + "action_assignments": {}, + + "object_assignments": {} +} diff --git a/keystone-moon/examples/moon/policies/policy_empty_authz/metadata.json b/keystone-moon/examples/moon/policies/policy_empty_authz/metadata.json new file mode 100644 index 00000000..4f300d78 --- /dev/null +++ b/keystone-moon/examples/moon/policies/policy_empty_authz/metadata.json @@ -0,0 +1,12 @@ +{ + "name": "MLS_Policy", + "model": "MLS", + "genre": "authz", + "description": "Multi Level Security Policy", + + "subject_categories": [], + + "action_categories": [], + + "object_categories": [] +} diff --git a/keystone-moon/examples/moon/policies/policy_empty_authz/metarule.json b/keystone-moon/examples/moon/policies/policy_empty_authz/metarule.json new file mode 100644 index 00000000..7acd8848 --- /dev/null +++ b/keystone-moon/examples/moon/policies/policy_empty_authz/metarule.json @@ -0,0 +1,12 @@ +{ + "sub_meta_rules": { + "mls_rule": { + "subject_categories": [], + "action_categories": [], + "object_categories": [], + "algorithm": "" + } + }, + "aggregation": "" +} + diff --git a/keystone-moon/examples/moon/policies/policy_empty_authz/perimeter.json b/keystone-moon/examples/moon/policies/policy_empty_authz/perimeter.json new file mode 100644 index 00000000..9da8a8c0 --- /dev/null +++ b/keystone-moon/examples/moon/policies/policy_empty_authz/perimeter.json @@ -0,0 +1,5 @@ +{ + "subjects": [], + "actions": [], + "objects": [] +} diff --git a/keystone-moon/examples/moon/policies/policy_empty_authz/rule.json b/keystone-moon/examples/moon/policies/policy_empty_authz/rule.json new file mode 100644 index 00000000..fe4fae5a --- /dev/null +++ b/keystone-moon/examples/moon/policies/policy_empty_authz/rule.json @@ -0,0 +1,3 @@ +{ + "mls_rule":[] +} diff --git a/keystone-moon/examples/moon/policies/policy_empty_authz/scope.json b/keystone-moon/examples/moon/policies/policy_empty_authz/scope.json new file mode 100644 index 00000000..1efebe6f --- /dev/null +++ b/keystone-moon/examples/moon/policies/policy_empty_authz/scope.json @@ -0,0 +1,7 @@ +{ + "subject_scopes": {}, + + "action_scopes": {}, + + "object_scopes": {} +} diff --git a/moonclient/moonclient/tests.py b/moonclient/moonclient/tests.py index 5badf4bc..dd0dd7de 100644 --- a/moonclient/moonclient/tests.py +++ b/moonclient/moonclient/tests.py @@ -12,6 +12,7 @@ from cliff.command import Command from uuid import uuid4 import os import time +import subprocess class TestsLaunch(Lister): @@ -19,7 +20,8 @@ class TestsLaunch(Lister): log = logging.getLogger(__name__) result_vars = dict() - logfile = open("/tmp/moonclient_test_{}.log".format(time.strftime("%Y%m%d-%H%M%S")), "w") + logfile_name = "/tmp/moonclient_test_{}.log".format(time.strftime("%Y%m%d-%H%M%S")) + logfile = open(logfile_name, "w") def get_parser(self, prog_name): parser = super(TestsLaunch, self).get_parser(prog_name) @@ -31,9 +33,12 @@ class TestsLaunch(Lister): return parser def __replace_var_in_str(self, data_str): + self.log.debug("__replace_var_in_str " + data_str) for exp in re.findall("\$\w+", data_str): + self.log.debug("--->" + exp + str(self.result_vars)) if exp.replace("$", "") in self.result_vars: data_str = re.sub(exp.replace("$", "\$") + "(?!\w)", self.result_vars[exp.replace("$", "")], data_str) + self.log.debug("__replace_var_in_str " + data_str) return data_str def __compare_results(self, expected, observed): @@ -44,7 +49,7 @@ class TestsLaunch(Lister): return False def take_action(self, parsed_args): - self.log.info("Write tests output to {}".format(self.logfile)) + self.log.info("Write tests output to {}".format(self.logfile_name)) stdout_back = self.app.stdout if not parsed_args.testfile: self.log.error("You don't give a test filename.") @@ -56,37 +61,67 @@ class TestsLaunch(Lister): global_command_options = tests_dict["command_options"] data = list() for group_name, tests_list in tests_dict["tests_group"].iteritems(): + overall_result = True self.log.info("\n\033[1mgroup {}\033[0m".format(group_name)) self.logfile.write("{}:\n\n".format(group_name)) + test_count = len(tests_list) for test in tests_list: + result_str = "" + error_str = "" data_tmp = list() tmp_filename = os.path.join("/tmp", uuid4().hex) tmp_filename_fd = open(tmp_filename, "w") self.log.debug("test={}".format(test)) - if "command_options" in test: - command = test["command"] + " " + test["command_options"] - else: - command = test["command"] + " " + global_command_options - command = self.__replace_var_in_str(command) - self.logfile.write("-----> {}\n".format(command)) - self.log.info(" \\-executing {}".format(command)) - self.app.stdout = tmp_filename_fd - result_id = self.app.run_subcommand(shlex.split(command)) - tmp_filename_fd.close() - self.app.stdout = stdout_back - result_str = open(tmp_filename, "r").read() - self.logfile.write("{}".format(result_str)) + if "command" not in test: + ext_command = test["external_command"] + ext_command = self.__replace_var_in_str(ext_command) + self.logfile.write("-----> {}\n".format(ext_command)) + self.log.info(" \\-executing external \"{}\"".format(ext_command)) + pipe = subprocess.Popen(shlex.split(ext_command), stdout=subprocess.PIPE, stderr=subprocess.PIPE) + com = pipe.communicate() + result_str = com[0] + error_str = com[1] + self.logfile.write("stdout: {}\n".format(result_str)) + self.logfile.write("stderr: {}\n".format(error_str)) + if "command" in test: + if "command_options" in test: + command = test["command"] + " " + test["command_options"] + else: + command = test["command"] + " " + global_command_options + command = self.__replace_var_in_str(command) + self.logfile.write("-----> {}\n".format(command)) + self.log.info(" \\-executing {}".format(command)) + self.app.stdout = tmp_filename_fd + result_id = self.app.run_subcommand(shlex.split(command)) + tmp_filename_fd.close() + self.app.stdout = stdout_back + result_str = open(tmp_filename, "r").read() + self.logfile.write("{}".format(result_str)) data_tmp.append(group_name) data_tmp.append(test["name"]) compare = self.__compare_results(self.__replace_var_in_str(test["result"]), result_str) self.logfile.write("----->{} ({})\n\n".format(compare, self.__replace_var_in_str(test["result"]))) - if compare: - compare = "\033[32mTrue\033[m" - else: + if error_str: compare = "\033[1m\033[31mFalse\033[m" + overall_result = False + else: + overall_result = overall_result and compare + if compare: + compare = "\033[32mTrue\033[m" + else: + compare = "\033[1m\033[31mFalse\033[m" data_tmp.append(compare) data_tmp.append(test["description"]) data.append(data_tmp) + data_tmp = list() + data_tmp.append("\033[1m" + group_name + "\033[m") + data_tmp.append("\033[1mOverall results ({})\033[m".format(test_count)) + if overall_result: + data_tmp.append("\033[1m\033[32mTrue\033[m") + else: + data_tmp.append("\033[1m\033[31mFalse\033[m") + data_tmp.append(self.logfile_name) + data.append(data_tmp) return ( ("group_name", "test_name", "result", "description"), diff --git a/moonclient/moonclient/tests/tests_external_commands.json b/moonclient/moonclient/tests/tests_external_commands.json new file mode 100644 index 00000000..0aa6f704 --- /dev/null +++ b/moonclient/moonclient/tests/tests_external_commands.json @@ -0,0 +1,109 @@ +{ + "command_options": "-f value", + "tests_group": { + "main": [ + { + "name": "list tenant", + "command": "tenant list", + "result": "(?!demo)", + "description": "List all tenants (must be empty)" + }, + { + "name": "add tenant demo", + "command": "tenant add demo", + "result": "^$", + "description": "Add a new tenant", + "command_options": "" + }, + { + "name": "check tenant demo", + "command": "tenant list", + "result": "(?P<uuid>\\w+)\\s+demo", + "description": "Check that tenant demo has been correctly added" + }, + { + "name": "create_intraextension_admin", + "command": "intraextension add --policy_model policy_rbac_admin admin_test", + "result": "IntraExtension created: (?P<uuid_admin>\\w+)", + "description": "Create an admin intra extension", + "command_options": "" + }, + { + "name": "list_intraextension_admin", + "command": "intraextension list", + "result": "$uuid_admin", + "description": "Check the existence of that admin intra extension" + }, + { + "name": "create_intraextension_authz", + "command": "intraextension add --policy_model policy_authz authz_test", + "result": "IntraExtension created: (?P<uuid_authz>\\w+)", + "description": "Create an authz intra extension", + "command_options": "" + }, + { + "name": "list_intraextension_authz", + "command": "intraextension list", + "result": "$uuid_authz", + "description": "Check the existence of that authz intra extension" + }, + { + "name": "set_tenant_authz", + "command": "tenant set --authz $uuid_authz $uuid", + "result": "", + "description": "Connect the authz intra extension to the tenant demo", + "command_options": "" + }, + { + "name": "check authz ie for tenant demo", + "command": "tenant list", + "result": "demo $uuid_authz", + "description": "Check that authz ie has been correctly added for tenant demo ", + "command_options": "-c name -c intra_authz_extension_id -f value" + }, + { + "name": "set_tenant_admin", + "command": "tenant set --admin $uuid_admin $uuid", + "result": "", + "description": "Connect the admin intra extension to the tenant demo", + "command_options": "" + }, + { + "name": "check admin ie for tenant demo", + "command": "tenant list", + "result": "demo $uuid_admin", + "description": "Check that admin ie has been correctly added for tenant demo ", + "command_options": "-c name -c intra_admin_extension_id -f value" + }, + + { + "name": "check nova command", + "external_command": "nova list", + "result": "\\| (?P<uuid_server>[\\w\\-]+)\\s+\\| (?P<name_server>\\w+)\\s+\\| ACTIVE\\s+\\| [\\w\\-]+\\s+\\| Running", + "description": "Check that nova is running and get the ID of one running server" + }, + + { + "name": "delete_admin_intra_extension", + "command": "intraextension delete $uuid_admin", + "result": "", + "description": "Delete the admin intra extension", + "command_options": "" + }, + { + "name": "delete_authz_intra_extension", + "command": "intraextension delete $uuid_authz", + "result": "", + "description": "Delete the authz intra extension", + "command_options": "" + }, + { + "name": "delete_tenant", + "command": "tenant delete $uuid", + "result": "", + "description": "Delete the tenant demo", + "command_options": "" + } + ] + } +}
\ No newline at end of file |