From b87569abe8841e370d4d3e612760ce8e8b52a180 Mon Sep 17 00:00:00 2001 From: "anthony.lin" Date: Wed, 23 May 2018 15:38:31 +0800 Subject: [PATCH] Add tox tests to .zuul.yaml This patch set adds tox tests to .zuul.yaml Prometheus scrapers are not running in the airship-shipyard and hence removed to prevent airship-shipyard-ubuntu job from failing. Change-Id: Ib805946ea76664b7448e02b4c7e4adb40c4dbaf2 --- .zuul.yaml | 86 +++++++++++++++++-- .../playbooks/osh-infra-collect-logs.yaml | 2 - tools/gate/playbooks/roles | 1 + tools/gate/playbooks/run-image.yaml | 21 +++++ tools/gate/playbooks/run-tests.yaml | 20 +++++ .../build-images/tasks/airship-shipyard.yaml | 57 ++++++++++++ tools/gate/roles/build-images/tasks/main.yaml | 15 ++++ tools/gate/roles/run-tests/tasks/main.yaml | 15 ++++ .../gate/roles/run-tests/tasks/tox-tests.yaml | 20 +++++ tox.ini | 14 +++ 10 files changed, 242 insertions(+), 9 deletions(-) create mode 120000 tools/gate/playbooks/roles create mode 100644 tools/gate/playbooks/run-image.yaml create mode 100644 tools/gate/playbooks/run-tests.yaml create mode 100644 tools/gate/roles/build-images/tasks/airship-shipyard.yaml create mode 100644 tools/gate/roles/build-images/tasks/main.yaml create mode 100644 tools/gate/roles/run-tests/tasks/main.yaml create mode 100644 tools/gate/roles/run-tests/tasks/tox-tests.yaml diff --git a/.zuul.yaml b/.zuul.yaml index 56b2bb36..71d9884e 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -16,10 +16,9 @@ - airship-shipyard-linter - airship-shipyard-ubuntu: voting: false - irrelevant-files: - - ^.*\.rst$ - - ^doc/.*$ - - ^releasenotes/.*$ + - airship-shipyard-tox-py35 + - airship-shipyard-pep8 + - airship-shipyard-image gate: jobs: - airship-shipyard-linter @@ -29,19 +28,24 @@ # - ^.*\.rst$ # - ^doc/.*$ # - ^releasenotes/.*$ + - airship-shipyard-tox-py35 + - airship-shipyard-pep8 + - airship-shipyard-image - job: name: airship-shipyard-linter + description: | + Lints all files by checking them for whitespace. run: tools/gate/playbooks/zuul-linter.yaml nodeset: openstack-helm-single-node - job: - name: airship-shipyard + name: airship-shipyard-base roles: - zuul: openstack/openstack-helm-infra vars: zuul_osh_infra_relative_path: ../openstack-helm-infra/ - timeout: 7200 + timeout: 3600 pre-run: - tools/gate/playbooks/osh-infra-upgrade-host.yaml - tools/gate/playbooks/osh-infra-deploy-docker.yaml @@ -51,8 +55,76 @@ post-run: tools/gate/playbooks/osh-infra-collect-logs.yaml required-projects: - openstack/openstack-helm-infra + irrelevant-files: + - ^.*\.rst$ + - ^doc/.*$ + - ^releasenotes/.*$ - job: name: airship-shipyard-ubuntu - parent: airship-shipyard + parent: airship-shipyard-base + nodeset: openstack-helm-single-node + +- job: + name: airship-shipyard-tox-base + description: | + Base job for running airship-shipyard tests. Runs tests + against Docker image generated from source code. + roles: + - zuul: openstack/openstack-helm-infra + timeout: 3600 + pre-run: + - tools/gate/playbooks/osh-infra-upgrade-host.yaml + - tools/gate/playbooks/osh-infra-deploy-docker.yaml + run: tools/gate/playbooks/run-tests.yaml + required-projects: + - openstack/openstack-helm-infra + irrelevant-files: + - ^.*\.rst$ + - ^doc/.*$ + - ^releasenotes/.*$ + +- job: + name: airship-shipyard-tox-py35 + description: | + Run tox-based tests for the Airship Shipyard project under + cPython version 3.5. + parent: airship-shipyard-tox-base + nodeset: openstack-helm-single-node + vars: + tox_envlist: py35 + +- job: + name: airship-shipyard-pep8 + description: | + Run pep8 tests for the Airship Shipyard project under + cPython version 3.5. + parent: airship-shipyard-tox-base + nodeset: openstack-helm-single-node + vars: + tox_envlist: pep8 + +- job: + name: airship-shipyard-image-base + description: | + Base job for running airship-shipyard image related jobs. + roles: + - zuul: openstack/openstack-helm-infra + timeout: 3600 + pre-run: + - tools/gate/playbooks/osh-infra-upgrade-host.yaml + - tools/gate/playbooks/osh-infra-deploy-docker.yaml + run: tools/gate/playbooks/run-image.yaml + required-projects: + - openstack/openstack-helm-infra + irrelevant-files: + - ^.*\.rst$ + - ^doc/.*$ + - ^releasenotes/.*$ + +- job: + name: airship-shipyard-image + description: | + Run shipyard-image build. + parent: airship-shipyard-image-base nodeset: openstack-helm-single-node diff --git a/tools/gate/playbooks/osh-infra-collect-logs.yaml b/tools/gate/playbooks/osh-infra-collect-logs.yaml index f08f7066..2cb0982d 100644 --- a/tools/gate/playbooks/osh-infra-collect-logs.yaml +++ b/tools/gate/playbooks/osh-infra-collect-logs.yaml @@ -21,10 +21,8 @@ - helm-release-status - describe-kubernetes-objects - gather-pod-logs - - gather-prom-metrics tags: - gather-host-logs - helm-release-status - describe-kubernetes-objects - gather-pod-logs - - gather-prom-metrics \ No newline at end of file diff --git a/tools/gate/playbooks/roles b/tools/gate/playbooks/roles new file mode 120000 index 00000000..7b9ade87 --- /dev/null +++ b/tools/gate/playbooks/roles @@ -0,0 +1 @@ +../roles/ \ No newline at end of file diff --git a/tools/gate/playbooks/run-image.yaml b/tools/gate/playbooks/run-image.yaml new file mode 100644 index 00000000..39854068 --- /dev/null +++ b/tools/gate/playbooks/run-image.yaml @@ -0,0 +1,21 @@ +# Copyright 2018 AT&T Intellectual Property. All other 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. + +- hosts: all + gather_facts: False + become: yes + roles: + - build-images + tags: + - build-images diff --git a/tools/gate/playbooks/run-tests.yaml b/tools/gate/playbooks/run-tests.yaml new file mode 100644 index 00000000..7e79b2ff --- /dev/null +++ b/tools/gate/playbooks/run-tests.yaml @@ -0,0 +1,20 @@ +# Copyright 2018 AT&T Intellectual Property. All other 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. + +- hosts: all + gather_facts: False + roles: + - run-tests + tags: + - run-tests diff --git a/tools/gate/roles/build-images/tasks/airship-shipyard.yaml b/tools/gate/roles/build-images/tasks/airship-shipyard.yaml new file mode 100644 index 00000000..cb8fb84f --- /dev/null +++ b/tools/gate/roles/build-images/tasks/airship-shipyard.yaml @@ -0,0 +1,57 @@ +# Copyright 2018 AT&T Intellectual Property. All other 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. + +- name: set zuul_site_mirror_fqdn from env var if not defined + when: zuul_site_mirror_fqdn is not defined + set_fact: + zuul_site_mirror_fqdn: "{{ lookup('env','zuul_site_mirror_fqdn') }}" + +# NOTE(portdirect): Until https://github.com/ansible/ansible/issues/21433 is +# resolved, we build with a shell script to make use of the host network. +- name: Build Airship-Shipyard Image + block: + # NOTE(portdirect): We do this to ensure we are feeding the docker build + # a clean path to work with. + - name: Airship-Shipyard image build path + shell: cd "{{ work_dir }}"; pwd + register: airship_shipyard_path + vars: + zuul_airship_shipyard_relative_path: ../airship-shipyard + work_dir: "{{ zuul.project.src_dir }}/{{ zuul_airship_shipyard_relative_path | default('') }}" + + - name: Airship-Shipyard image build path + shell: |- + set -ex; + docker build \ + --network host \ + --force-rm \ + --label zuul \ + -f images/shipyard/Dockerfile \ + --build-arg ctx_base=src/bin \ + {% if zuul_site_mirror_fqdn is defined and zuul_site_mirror_fqdn %} + --build-arg UBUNTU_URL="http://{{ zuul_site_mirror_fqdn }}/ubuntu/" \ + --build-arg ALLOW_UNAUTHENTICATED="true" \ + --build-arg PIP_INDEX_URL="http://{{ zuul_site_mirror_fqdn }}/pypi/simple" \ + --build-arg PIP_TRUSTED_HOST="{{ zuul_site_mirror_fqdn }}" \ + {% endif %} + . + args: + chdir: "{{ airship_shipyard_path.stdout }}" + executable: /bin/bash + + - name: Register Shipyard Image ID + shell: |- + set -e; + echo $( docker images --filter label=zuul | awk '{print $3}' | head -2 | tail -1 ) + register: shipyard_image_id diff --git a/tools/gate/roles/build-images/tasks/main.yaml b/tools/gate/roles/build-images/tasks/main.yaml new file mode 100644 index 00000000..b88abb5e --- /dev/null +++ b/tools/gate/roles/build-images/tasks/main.yaml @@ -0,0 +1,15 @@ +# Copyright 2018 AT&T Intellectual Property. All other 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. + +- include: airship-shipyard.yaml diff --git a/tools/gate/roles/run-tests/tasks/main.yaml b/tools/gate/roles/run-tests/tasks/main.yaml new file mode 100644 index 00000000..a1c8c122 --- /dev/null +++ b/tools/gate/roles/run-tests/tasks/main.yaml @@ -0,0 +1,15 @@ +# Copyright 2018 AT&T Intellectual Property. All other 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. + +- include: tox-tests.yaml diff --git a/tools/gate/roles/run-tests/tasks/tox-tests.yaml b/tools/gate/roles/run-tests/tasks/tox-tests.yaml new file mode 100644 index 00000000..61532011 --- /dev/null +++ b/tools/gate/roles/run-tests/tasks/tox-tests.yaml @@ -0,0 +1,20 @@ +# Copyright 2018 AT&T Intellectual Property. All other 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. + +- name: Run Tox Tests + shell: | + set -xe; + tox -e {{ tox_envlist }} + args: + chdir: "{{ zuul.project.src_dir }}" diff --git a/tox.ini b/tox.ini index 152815f2..5bd4c002 100644 --- a/tox.ini +++ b/tox.ini @@ -29,3 +29,17 @@ whitelist_externals= commands= tox -c {toxinidir}/src/bin/shipyard_airflow/tox.ini tox -c {toxinidir}/src/bin/shipyard_client/tox.ini + +[testenv:py35] +whitelist_externals= + tox +commands= + tox -c {toxinidir}/src/bin/shipyard_airflow/tox.ini -e py35 + tox -c {toxinidir}/src/bin/shipyard_client/tox.ini -e py35 + +[testenv:pep8] +whitelist_externals= + tox +commands= + tox -c {toxinidir}/src/bin/shipyard_airflow/tox.ini -e pep8 + tox -c {toxinidir}/src/bin/shipyard_client/tox.ini -e pep8