system-config/playbooks/test-gitea.yaml
Clark Boylan 4d4e88a3d0 Update our gitea test to handle new git behavior
Git was recently updated to fix a security issue that prevents git from
operating on a repo as userA if the repo is owned by userB. In our gitea
tests we use our local zuul repo clone of system-config to push back
into gitea to get some real content into gitea. We were operating as
root but zuul owns that repo. Update the commands to run as zuul to
workaround the git error.

Change-Id: I87105bae4bdd69465cce4d5bc412241dc1c88623
2022-04-13 13:07:13 -07:00

77 lines
2.9 KiB
YAML

- hosts: "gitea"
tasks:
- name: Run selenium container
include_role:
name: run-selenium
- name: Test base jobs project was created in gitea
uri:
url: "https://localhost:3000/opendev/base-jobs"
validate_certs: false
status_code: 200
- name: Test zuul project was created in gitea
uri:
url: "https://localhost:3000/zuul/zuul"
validate_certs: false
status_code: 200
return_content: yes
register: zuul_content
- name: Assert description updated
fail:
msg: Zuul description was not updated
when: '"Zuuls new description" not in zuul_content.content'
- name: Configure ssh for pushing into test gitea
shell: |
ssh-keyscan -t rsa -p 222 localhost >> /home/zuul/.ssh/known_hosts
ssh-keygen -t ed25519 -f /home/zuul/.ssh/id_ed25519 -C giteagerrittest -P ''
# We become zuul here because we need to git push has zuul later to
# ensure the owner of the git repo is the one operating on it.
become: true
become_user: zuul
- name: Register new gitea gerrit pubkey value
slurp:
src: /home/zuul/.ssh/id_ed25519.pub
register: slurped_gitea_gerrit_pubkey
- name: Set testing key on gerrit account in gitea
no_log: true
uri:
user: root
password: "{{ gitea_root_password }}"
force_basic_auth: true
url: "https://localhost:3000/api/v1/admin/users/gerrit/keys"
validate_certs: false
method: POST
status_code: 201
body_format: json
body:
key: "{{ slurped_gitea_gerrit_pubkey['content'] | b64decode }}"
read_only: false
title: "Gerrit testing key"
- name: Push system-config into our test gitea for testing
shell: |
cd /home/zuul/src/opendev.org/opendev/system-config
git remote add test-gitea ssh://git@localhost:222/opendev/system-config
GIT_SSH_COMMAND='ssh -i /home/zuul/.ssh/id_ed25519' git push -f test-gitea master
# We run this as zuul because zuul owns the git repo in /home/zuul
# and git by default does not want to operate on a git repo as another
# user.
become: true
become_user: zuul
- name: Clone system-config to check that partial clones aren't breaking stuff
shell: |
cd /tmp
GIT_SSL_NO_VERIFY=1 git clone --filter=blob:none https://localhost:3081/opendev/system-config test-system-config-clone
- name: Run rename playbook
import_playbook: rename_repos.yaml
vars:
repolist: /home/zuul/src/opendev.org/opendev/system-config/playbooks/zuul/test_gitea_renames.yaml
# This is conveniently left here so that it can be uncommented in order to
# autohold the system-config-run-gitea job in zuul.
#- hosts: bridge.openstack.org
# tasks:
# - name: Force a failure for human intervention
# fail:
# msg: Failing so that we can check on things with a hold