From a3a7c66ff3e578384135f7adccdf0ca18ea09d34 Mon Sep 17 00:00:00 2001 From: chenhb Date: Mon, 11 Mar 2019 17:41:54 +0800 Subject: [PATCH] [gates]Restore the gate for "rally verify" Found some issues about `rally verify` recently, restore the gate to do some check. Change-Id: Ib7f0b098628ce4a5debc4100284dc99558da74a3 --- .zuul.d/rally-verify-tempest.yaml | 16 ++++ .zuul.d/zuul.yaml | 2 + tests/ci/pages/verify-index.html | 93 +++++++++++++++++++++++ tests/ci/playbooks/post-rally-verify.yaml | 27 +++++++ tests/ci/playbooks/run-rally-verify.yaml | 16 ++++ tests/ci/rally_verify.py | 22 ++++-- 6 files changed, 170 insertions(+), 6 deletions(-) create mode 100644 .zuul.d/rally-verify-tempest.yaml create mode 100644 tests/ci/pages/verify-index.html create mode 100644 tests/ci/playbooks/post-rally-verify.yaml create mode 100644 tests/ci/playbooks/run-rally-verify.yaml mode change 100755 => 100644 tests/ci/rally_verify.py diff --git a/.zuul.d/rally-verify-tempest.yaml b/.zuul.d/rally-verify-tempest.yaml new file mode 100644 index 00000000..a76df10d --- /dev/null +++ b/.zuul.d/rally-verify-tempest.yaml @@ -0,0 +1,16 @@ +- job: + name: rally-verify-tempest + parent: devstack + required-projects: + - name: openstack-dev/devstack + - name: openstack-infra/devstack-gate + - name: openstack/rally-openstack + - name: openstack/rally + timeout: 7200 + roles: + - zuul: openstack-dev/devstack + vars: + devstack_plugins: + rally-openstack: https://git.openstack.org/openstack/rally-openstack + run: tests/ci/playbooks/run-rally-verify.yaml + post-run: tests/ci/playbooks/post-rally-verify.yaml diff --git a/.zuul.d/zuul.yaml b/.zuul.d/zuul.yaml index 3ea9b82a..3de69fe7 100644 --- a/.zuul.d/zuul.yaml +++ b/.zuul.d/zuul.yaml @@ -70,6 +70,7 @@ # watcher-api did not start last time voting: false - rally-task-zaqar + - rally-verify-tempest gate: jobs: - rally-tox-pep8 @@ -90,3 +91,4 @@ - rally-task-neutron - rally-task-telemetry - rally-task-zaqar + - rally-verify-tempest diff --git a/tests/ci/pages/verify-index.html b/tests/ci/pages/verify-index.html new file mode 100644 index 00000000..be29ede1 --- /dev/null +++ b/tests/ci/pages/verify-index.html @@ -0,0 +1,93 @@ + + + + + + Rally | Rally Verification Job Results + + + + + + + +
+

Logs and Results Files

+ + +

Steps

+ +{% for step in steps %} + {{ step|safe }} +{% endfor %} + +

About Rally

+

Rally is benchmarking and verification system for OpenStack:

+ +
+ + diff --git a/tests/ci/playbooks/post-rally-verify.yaml b/tests/ci/playbooks/post-rally-verify.yaml new file mode 100644 index 00000000..688a0a04 --- /dev/null +++ b/tests/ci/playbooks/post-rally-verify.yaml @@ -0,0 +1,27 @@ +- hosts: controller + tasks: + - name: Copy the html report + synchronize: + src: '{{ zuul.project.src_dir }}/rally-verify' + dest: '{{ zuul.executor.log_root }}' + mode: pull + copy_links: true + verify_host: true + rsync_opts: + - --include=/** + - --include=*/ + - --exclude=* + - --prune-empty-dirs + + - name: Put index.html in the right place + synchronize: + src: '{{ zuul.project.src_dir }}/rally-verify/extra/index.html' + dest: '{{ zuul.executor.log_root }}/index.html' + mode: pull + copy_links: true + verify_host: true + rsync_opts: + - --include=/** + - --include=*/ + - --exclude=* + - --prune-empty-dirs \ No newline at end of file diff --git a/tests/ci/playbooks/run-rally-verify.yaml b/tests/ci/playbooks/run-rally-verify.yaml new file mode 100644 index 00000000..ea9fe6e5 --- /dev/null +++ b/tests/ci/playbooks/run-rally-verify.yaml @@ -0,0 +1,16 @@ +- hosts: all + roles: + - run-devstack + +- hosts: controller + tasks: + - name: Run Rally verify + shell: + cmd: | + cd {{ zuul.project.src_dir }} + . /opt/stack/.rally/openrc admin admin + export OS_CACERT=/opt/stack/data/ca-bundle.pem + rally deployment create --fromenv --name tempest + rally deployment config + python tests/ci/rally_verify.py + executable: /bin/bash \ No newline at end of file diff --git a/tests/ci/rally_verify.py b/tests/ci/rally_verify.py old mode 100755 new mode 100644 index 49f13b0e..885ceb78 --- a/tests/ci/rally_verify.py +++ b/tests/ci/rally_verify.py @@ -23,8 +23,9 @@ import subprocess import sys import uuid +import jinja2 + from rally import api -from rally.ui import utils LOG = logging.getLogger("verify-job") LOG.setLevel(logging.DEBUG) @@ -55,7 +56,8 @@ class Step(object): self.args = args self.rapi = rapi self.result = {"status": Status.PASS, - "doc": self.__doc__} + "doc": self.__doc__, + "cmd": "None command found"} @property def name(self): @@ -141,7 +143,7 @@ class Step(object): class SetUpStep(Step): """Validate deployment, create required resources and directories.""" - DEPLOYMENT_NAME = "devstack" + DEPLOYMENT_NAME = "tempest" def run(self): if not os.path.exists("%s/extra" % self.BASE_DIR): @@ -493,6 +495,16 @@ def run(args): return results.values() +def create_report(results): + template_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), + "pages") + loader = jinja2.FileSystemLoader(template_dir) + env = jinja2.Environment(loader=loader) + template = env.get_template("verify-index.html") + with open(os.path.join(Step.BASE_DIR, "extra/index.html"), "w") as f: + f.write(template.render(steps=results)) + + def main(): parser = argparse.ArgumentParser(description="Launch rally-verify job.") parser.add_argument("--mode", type=str, default="light", @@ -514,9 +526,7 @@ def main(): steps = run(args) results = [step.to_html() for step in steps] - template = utils.get_template("ci/index_verify.html") - with open(os.path.join(Step.BASE_DIR, "extra/index.html"), "w") as f: - f.write(template.render(steps=results)) + create_report(results) if len([None for step in steps if step.result["status"] == Status.PASS]) == len(steps):