diff --git a/.zuul.d/docker-jobs.yaml b/.zuul.d/docker-jobs.yaml new file mode 100644 index 00000000..c8bb7923 --- /dev/null +++ b/.zuul.d/docker-jobs.yaml @@ -0,0 +1,52 @@ +- secret: + name: rally-openstack-dockerhub-credentials + data: + username: !encrypted/pkcs1-oaep + - D76f4bTe1hv1uL30TaW3QiO6ytmB/XvFuTn6SF7HBPjiKKWS2TnPXc4B73EXuiXTDRfeM + AEaNV7zqIRiSIPv9f31p7gJR7XHUb7S0osXvnzytNY+4B43p2Q6+fQlZsQ+3Df69xYKLd + 2S4uAc3HF9AvHMQ4E1Fn1XzrBGfmamKK90rkeRwvbFUeOVyoeB9etFIkB3QGzRDWqrkM3 + qAOkjkNP2QIUTdWmCBgXt9SgOiRIZMG5dIyvlYQKGnLGtXzROb3sIUCGtWwh3pBJf2UuD + LIb43OlxAm3AaSGhvbNX10295a0iHChAuR1NX8j3e2GPvCn+0aOdp8T038BWjqKZPblZU + UYekgsMzgUaqs6naY1fwrRAoAcGvi2JqXcpSUkTh9XdfAcFumwSZlg26HCDz1UEpwIvKj + XSAcYeC+Ol9VNE97QXRgdcQQIO8tDHjbXbs30TbMJI5RoQ0N1vFBLxNd2nsHK2PIBzfik + 2N93XoE5fCEcumULtlwBK9pbMBElRjBpWBUKMR4WicJUAhwQgf/PT6g1TEK8sZHIjS6lw + E1iVfAqq2cP3CyvvnjUUeCx1RuWgaFcmFxio9rK189eeZnLNYtgJlnA/pvZoJ9oNNAvPX + XotXoZ7wmiV6ISVF9U6nHLOoWT+54smeTfAXHu93AtKHzUocHBq7A66cV5jX54= + password: !encrypted/pkcs1-oaep + - CthIToeDxeITidxDPpkFrRCHqLqeL6dE7w/eA6AYRNLpHYHtq2rqLmqb2XGnAw4ZX5pQ9 + mKVO5TE0Nnj3INBvCtgoY1n0CmPVD8B2YzoPYkzfwF6lX5wap2SfnSoW4f0caJQiBMPdd + YAjCxb14RtofdTEhiVTskmUMmQ7nFrb4oGMa2ub6k/K2KXxqh1jEUTCc2HEcJqEh2Lbb/ + txsh2bqabXC4oOcysdb4VPAcIwF3wRoOqIrTChiu1wDie0pj8IEJ9MAapB1YNLFj5qVUe + zfQGW1QaYzXjNrvabGLYBDR7HXoTf9Rlr76vu5HHfyIIh5QwPMa6+ux67tmT/yR9B2qov + ijdJbKqIKx77KBo8VyZsI8KWQb8rK/2C84Hia+3XbW7PM6vxx+bLijcEI8PMFhaeE1Gnm + pNf7tVXPG6Hzk3O26f2zahMsRxvFPpkcVCVGixj+hv+ltMaQ9842MlrdGwJbxK/qBjLJ9 + uDFJyClrPBC4AAe/ctaFq0K08mg0RMlS4F8zzEOOR9vvjNcdc2r9Qar0pVkTQQKCoLIBP + pm95hJSPjVDW6LhujIKIWL21swKyeSrJGB9f3MlaYkiQn3vZ1Dy/7rE/fRN9a9Vur/KNU + eh7c/tXVG3k0n2Y+7O6gMnLpT6lHM18jlbjyNfvEWLSfDVoRWG87L2BDeVTZtY= + +- job: + name: rally-openstack-docker-build + parent: rally-docker-build + required-projects: + - name: openstack/rally + - name: openstack/rally-openstack + vars: + docker_repository: "xrally/xrally-openstack" + docker_image_version: latest + rally_plugin_name: "Dummy.openstack" + rally_package_name: "rally-openstack" + +- job: + name: rally-openstack-docker-build-and-push + parent: rally-docker-build-and-push + required-projects: + - name: openstack/rally + - name: openstack/rally-openstack + vars: + docker_repository: "xrally/xrally-openstack" + rally_plugin_name: "Dummy.openstack" + rally_package_name: "rally-openstack" + secrets: + name: dockerhub_credentials + secret: rally-openstack-dockerhub-credentials + pass-to-parent: true diff --git a/.zuul.d/rally-docker-check.yaml b/.zuul.d/rally-docker-check.yaml deleted file mode 100644 index fb8674f7..00000000 --- a/.zuul.d/rally-docker-check.yaml +++ /dev/null @@ -1,6 +0,0 @@ -- job: - name: rally-docker-check - parent: base - nodeset: ubuntu-bionic - run: tests/ci/playbooks/run-rally-docker-check.yaml - timeout: 1800 diff --git a/.zuul.d/zuul.yaml b/.zuul.d/zuul.yaml index 912605f6..45fdafc5 100644 --- a/.zuul.d/zuul.yaml +++ b/.zuul.d/zuul.yaml @@ -7,7 +7,7 @@ - rally-tox-py37 - rally-tox-py38 - rally-dsvm-tox-functional - - rally-docker-check + - rally-openstack-docker-build - rally-task-basic-with-existing-users - rally-task-simple-job - rally-task-barbican: @@ -83,7 +83,7 @@ - rally-tox-py37 - rally-tox-py38 - rally-dsvm-tox-functional - - rally-docker-check + - rally-openstack-docker-build - rally-task-basic-with-existing-users - rally-task-simple-job - rally-task-barbican: @@ -111,3 +111,11 @@ - rally-task-telemetry - rally-task-zaqar - rally-verify-tempest + post: + jobs: + - rally-openstack-docker-build-and-push: + vars: + docker_image_version: latest + release: + jobs: + - rally-openstack-docker-build-and-push diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 2bd09361..fd770f80 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -30,6 +30,9 @@ Added * ManilaShares.create_share_and_access_from_vm scenario which allows to check share access from within a VM. +* Regular automated builds for `docker image + `_ + Changed ~~~~~~~ diff --git a/DOCKER_README.md b/DOCKER_README.md new file mode 100644 index 00000000..697d91e2 --- /dev/null +++ b/DOCKER_README.md @@ -0,0 +1,60 @@ +# What is Rally-OpenSack/xRally-OpenStack + +Rally is tool & framework that allows one to write simple plugins and combine +them in complex tests scenarios that allows to perform all kinds of testing! + +Rally-OpenStack is a package of Rally plugins for OpenStack platform. + +# How to run and use xrally-openstack container + +First of all, you need to pull the container. We suggest to use the last +tagged version: + + # pull the 1.7.0 image (the latest release at the point of writing the note) + $ docker pull xrally/xrally-openstack:1.7.0 + +**WARNING: never attach folders and volumes to `/rally` inside the container. It can break everything.** + +The default configuration file is located at `/etc/rally/rally.conf`. You +should not be aware of it. If you want to override some options, use +`/home/rally/.rally/rally.conf` location instead. Rally does not load all +configuration files, so the primary one will be used. + +The default place for rally database file is `/home/rally/.rally/rally.sqlite`. +To make the storage persistent across all container runs, you may want to use +docker volumes or mount the directory. + +* use docker volumes. It is the easiest way. You just need to do something like: + + $ docker volume create --name rally_volume + $ docker run -v rally_volume:/home/rally/.rally xrally/xrally-openstack:1.7.0 env create --name "foo" + +* mount outer directory inside the container + + # you can create directory in whatever you want to place, but you + # may wish to make the data available for all users + $ sudo mkdir /var/lib/rally_container + + # In order for the directory to be accessible by the Rally user + # (uid: 65500) inside the container, it must be accessible by UID + # 65500 *outside* the container as well, which is why it is created + # in ``/var/lib/rally_container``. Creating it in your home directory is + # only likely to work if your home directory has excessively open + # permissions (e.g., ``0755``), which is not recommended. + $ sudo chown 65500 /var/lib/rally_container + + # As opposed to mounting docker image, you must initialize rally database* + $ docker run -v /var/lib/rally_container:/home/rally/.rally xrally/xrally-openstack:1.7.0 db create + + # And finally, you can start doing your things.* + $ docker run -v /var/lib/rally_container:/home/rally/.rally xrally/xrally-openstack:1.7.0 env create --name "foo" + +Have fun! + +# Links + +* Free software: Apache license +* Documentation: https://xrally.org +* Source: https://github.com/openstack/rally-openstack +* Bugs: https://bugs.launchpad.net/rally +* Gitter chat: https://gitter.im/xRally/Lobby diff --git a/tests/ci/playbooks/run-rally-docker-check.yaml b/tests/ci/playbooks/run-rally-docker-check.yaml deleted file mode 100644 index 851c230c..00000000 --- a/tests/ci/playbooks/run-rally-docker-check.yaml +++ /dev/null @@ -1,61 +0,0 @@ - -- hosts: all - name: Performs checks for building rally-openstack docker image - tasks: - - name: Install docker - become: True - become_user: root - shell: - executable: /bin/sh - cmd: | - set -e - - apt update - - apt install --yes apt-transport-https ca-certificates curl software-properties-common - - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - - - add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" - - apt update - apt-cache policy docker-ce - - apt install --yes docker-ce - - - name: Check docker service status - become: True - become_user: root - command: systemctl status docker - - - name: Build rally-openstack image - become: True - become_user: root - shell: "cd {{ zuul.project.src_dir }} && docker build -t xrally/xrally-openstack ./" - - - name: Create Docker volume as for persistant Rally container storage - become: True - become_user: root - command: "docker volume create --name rally_volume" - - - name: Create an Environment - become: True - become_user: root - command: docker run -v rally_volume:/home/rally/.rally xrally/xrally-openstack env create --name "special_env_name" - - - name: List all available environments - become: True - become_user: root - command: docker run -v rally_volume:/home/rally/.rally xrally/xrally-openstack env list - register: env_list - - # Check availability of that environment (check that volume stores Rally database) - - fail: - msg: There is no created environment available. - when: '"special_env_name" not in env_list.stdout' - - - name: Check loading of rally-openstack plugin - become: True - become_user: root - # this plugin was added with rally-openstack 1.1.0 - command: docker run -v rally_volume:/home/rally/.rally xrally/xrally-openstack plugin show GnocchiMetric.list_metric diff --git a/tests/unit/doc/test_docker_readme.py b/tests/unit/doc/test_docker_readme.py new file mode 100644 index 00000000..d028e8f7 --- /dev/null +++ b/tests/unit/doc/test_docker_readme.py @@ -0,0 +1,87 @@ +# All Rights Reserved. +# +# 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. + +from docutils import frontend +from docutils import nodes +from docutils.parsers import rst +from docutils import utils +import os +import re +import sys +from unittest import mock + +import rally_openstack +from tests.unit import test + + +ROOT_DIR = os.path.dirname(os.path.dirname(rally_openstack.__file__)) + + +class DockerReadmeTestCase(test.TestCase): + RE_RELEASE = re.compile(r"\[(?P[0-9]+\.[0-9]+.[0-9]+)\]") + + def get_releases(self): + full_path = os.path.join(ROOT_DIR, "CHANGELOG.rst") + with open(full_path) as f: + changelog = f.read() + with mock.patch.object(sys, "stderr"): + parser = rst.Parser() + settings = frontend.OptionParser( + components=(rst.Parser,)).get_default_values() + document = utils.new_document(changelog, settings) + parser.parse(changelog, document) + changelog = document.children + if len(changelog) != 1: + self.fail("'%s' file should contain one global section " + "with subsections for each release." % full_path) + + releases = [] + for node in changelog[0].children: + if not isinstance(node, nodes.section): + continue + title = node.astext().split("\n", 1)[0] + result = self.RE_RELEASE.match(title) + if result: + releases.append(result.groupdict()["version"]) + if not releases: + self.fail("'%s' doesn't mention any releases..." % full_path) + return releases + + def test_mentioned_latest_version(self): + full_path = os.path.join(ROOT_DIR, "DOCKER_README.md") + with open(full_path) as f: + readme = f.read() + + releases = self.get_releases() + latest_release = releases[0] + previous_release = releases[1] + print("All discovered releases: %s" % ", ".join(releases)) + + found = False + for i, line in enumerate(readme.split("\n"), 1): + if latest_release in line: + found = True + elif previous_release in line: + self.fail( + "You need to change %s to %s in all places where the " + "latest release is mentioned." + "\n Filename: %s" + "\n Line Number: %s" + "\n Line: %s" % + (previous_release, latest_release, full_path, i, line)) + + if not found: + self.fail("No latest nor previous release is found at README file " + "for our Docker image. It looks like the format of it " + "had changed. Please adopt the current test suite.") diff --git a/tests/unit/rally_jobs/test_zuul_jobs.py b/tests/unit/rally_jobs/test_zuul_jobs.py index 2f6173d0..3e869fae 100644 --- a/tests/unit/rally_jobs/test_zuul_jobs.py +++ b/tests/unit/rally_jobs/test_zuul_jobs.py @@ -50,7 +50,7 @@ class RallyJobsTestCase(test.TestCase): jobs = self.project_cfg[pipeline]["jobs"] specific_jobs = ["rally-dsvm-tox-functional", - "rally-docker-check", + "rally-openstack-docker-build", "rally-task-basic-with-existing-users", "rally-task-simple-job"] error_message = (