From 9ff29b108dcd35f16ba8f76ba833ade47ad33ade Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Tue, 5 Mar 2019 15:24:24 -0800 Subject: [PATCH] Test gitea project creation playbook Add an option to run a playbook (in the fake bridge context) after running the base playbook. Use this to run a new playbook which exercises gitea project creation after bootstrapping the gitea service. Disable ansible-lint 304 because it erroneously thinks shell and command are the same thing. Change-Id: I0394b614771bc62b9fe23d811defd7767b3d10db --- .zuul.yaml | 2 ++ playbooks/zuul/run-base.yaml | 3 +++ playbooks/zuul/test-gitea.yaml | 30 ++++++++++++++++++++++++++++++ tox.ini | 3 ++- 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 playbooks/zuul/test-gitea.yaml diff --git a/.zuul.yaml b/.zuul.yaml index 4b42522712..e8bbc86537 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -513,6 +513,8 @@ label: ubuntu-bionic - name: gitea01.opendev.org label: ubuntu-bionic + vars: + run_base_test_playbook: playbooks/zuul/test-gitea.yaml host-vars: gitea01.opendev.org: host_copy_output: diff --git a/playbooks/zuul/run-base.yaml b/playbooks/zuul/run-base.yaml index 46df223717..4ffb60009a 100644 --- a/playbooks/zuul/run-base.yaml +++ b/playbooks/zuul/run-base.yaml @@ -69,6 +69,9 @@ command: ansible localhost -m debug -a 'var=groups' - name: Run base.yaml command: ansible-playbook -v /home/zuul/src/git.openstack.org/openstack-infra/system-config/playbooks/base.yaml + - name: Run test playbook + when: run_base_test_playbook is defined + shell: "ANSIBLE_ROLES_PATH=/home/zuul/src/git.openstack.org/openstack-infra/system-config/playbooks/roles ansible-playbook -v /home/zuul/src/git.openstack.org/openstack-infra/system-config/{{ run_base_test_playbook }}" - name: Run testinfra to validate configuration include_role: name: tox diff --git a/playbooks/zuul/test-gitea.yaml b/playbooks/zuul/test-gitea.yaml new file mode 100644 index 0000000000..3bedfa8515 --- /dev/null +++ b/playbooks/zuul/test-gitea.yaml @@ -0,0 +1,30 @@ +- hosts: "localhost" + name: "Setup test project data" + vars: + projects: + - project: opendev/base-jobs + description: Zuul configuration common to all OpenDev tenants + tasks: + - name: Create test project-config directory + file: + path: "/opt/project-config/gerrit/" + state: directory + - name: Write test project configuration + copy: + dest: "/opt/project-config/gerrit/projects.yaml" + content: "{{ projects }}" + +- hosts: "gitea" + name: "Create repos on gitea servers" + strategy: free + max_fail_percentage: 1 + roles: + - role: gitea-git-repos + +- hosts: "gitea" + tasks: + - name: Test project was created in gitea + uri: + url: "https://localhost:3000/opendev/base-jobs" + validate_certs: false + status_code: 200 diff --git a/tox.ini b/tox.ini index bee07450e5..b308646562 100644 --- a/tox.ini +++ b/tox.ini @@ -24,7 +24,8 @@ commands = # We often deploy latest pip packages bash -c "find roles playbooks -type f -regex '.*.y[a]?ml' -print0 | xargs -t -n1 -0 \ ansible-lint -x ANSIBLE0004 -x ANSIBLE0006 -x ANSIBLE0007 -x ANSIBLE0010 \ - -x ANSIBLE0011 -x ANSIBLE0012 -x ANSIBLE0013 -x ANSIBLE0015" + -x ANSIBLE0011 -x ANSIBLE0012 -x ANSIBLE0013 -x ANSIBLE0015 \ + -x 304" [testenv:venv] commands = {posargs}