2020-12-03 11:54:48 +11:00
- hosts : "review"
tasks :
- name : Wait for Gerrit to be up
uri :
url : http://localhost:8081/a/accounts/admin/sshkeys
method : GET
user : admin
password : secret
register : result
until : result.status == 200 and not result.redirected
delay : 1
retries : 120
2021-07-23 13:14:28 -07:00
- name : Create openstack-project-creator user
uri :
url : http://localhost:8081/a/accounts/openstack-project-creator
method : PUT
user : admin
password : secret
body_format : json
body :
username : 'openstack-project-creator'
name : 'Project Creator'
email : 'project.creator@example.com'
http_password : 'secret'
groups :
- Administrators
status_code : 201
2021-01-28 13:52:08 +11:00
- name : Create CI group
uri :
url : 'http://localhost:8081/a/groups/CI-tools'
method : PUT
user : admin
password : secret
body_format : json
body :
description : 'Continuous Integration Tools'
status_code : 201
2020-12-03 11:54:48 +11:00
- name : Create Zuul user
uri :
url : http://localhost:8081/a/accounts/zuul
method : PUT
user : admin
password : secret
body_format : json
body :
name : 'Zuul'
email : 'zuul@example.com'
http_password : 'secret'
status_code : 201
2021-01-28 13:52:08 +11:00
- name : Add Zuul to group
uri :
url : 'http://localhost:8081/a/groups/CI-tools/members/zuul'
method : PUT
user : admin
password : secret
status_code : 201
- name : Get group UUID
uri :
url : 'http://localhost:8081/a/groups/CI-tools'
method : GET
user : admin
password : secret
status_code : 200
return_content : yes
register : group_raw
- name : Debug serialized json
debug :
var : group_raw
- name : Deserialize returned data to internal variable.
set_fact :
# The first 4 bytes of the returned data are )]}' which is
# invalid json.
group_json : '{{ group_raw.content | regex_replace("^....", "") | from_json }}'
- name : Debug deserialized json
debug :
var : group_json
- name : Setup key and initial gerrit config
shell :
executable : /bin/bash
cmd : |
set -xe
ssh-keygen -t ed25519 -f /root/.ssh/id_25519 -P ""
curl -X POST --user "admin:secret" -H "Content-Type: text/plain" -d@/root/.ssh/id_25519.pub http://localhost:8081/a/accounts/admin/sshkeys
git config --global user.name "Admin"
git config --global user.email "admin@example.com"
git clone http://admin:secret@localhost:8081/a/All-Projects
pushd All-Projects
echo "{{ group_json.id }} CI-tools" >> groups # noqa 203
git commit -a -m "Add CI-tools group"
git push origin HEAD:refs/meta/config
cat >> project.config << EOF
[ label "Verified"]
2023-01-30 16:21:45 -08:00
function = NoBlock
2021-01-28 13:52:08 +11:00
value = -2 Fails
value = -1 Doesn't seem to work
value = 0 No score
value = +1 Works for me
value = +2 Verified
2023-01-13 08:39:37 -08:00
[ submit-requirement "Verified"]
description = CI result votes. Maximum required to merge and is provided by the Zuul's gate queue.
submittableIf = label:Verified=MAX AND -label:Verified=MIN
canOverrideInChildProjects = false
2021-01-28 13:52:08 +11:00
[ access "refs/heads/*"]
label-Verified = -2..+2 group CI-tools
EOF
2021-03-02 11:09:18 +11:00
git commit -a -m 'Update All-Project configuration'
2021-01-28 13:52:08 +11:00
git push origin HEAD:refs/meta/config
popd
2021-07-23 13:14:28 -07:00
# openstack-project-creator bootstrapping
curl -X POST --user "openstack-project-creator:secret" -H "Content-Type: text/plain" -d@/home/gerrit2/review_site/etc/ssh_project_rsa_key.pub http://localhost:8081/a/accounts/openstack-project-creator/sshkeys
2021-05-03 15:19:49 +10:00
# This is helpful on a held node when you're trying to fix/enhance
# the Zuul summary plugin. You can build it locally, scp the new
# .jar to /tmp and run this to deploy your changes.
- name : Create summary plugin helper script
shell :
executable : /bin/bash
cmd : |
set -xe
cat > /root/deploy-zuul-results-summary.sh << EOF
#!/bin/bash
echo "Copying plugin"
docker cp /tmp/zuul-results-summary.jar \
gerrit-compose_gerrit_1:/var/gerrit/plugins/
echo "Reloading"
ssh -i /root/.ssh/id_25519 -p 29418 admin@localhost \
gerrit plugin reload zuul-results-summary
echo "Done"
EOF
chmod a+x /root/deploy-zuul-results-summary.sh
2020-12-03 11:54:48 +11:00
- name : Create temp dir for project creation
shell : mktemp -d
register : project_tmp
- name : Create project project in Gerrit
uri :
2021-08-02 14:12:57 -07:00
url : http://localhost:8081/a/projects/y%2Ftestproject
2020-12-03 11:54:48 +11:00
method : PUT
user : admin
password : secret
status_code : 201
2022-12-19 16:13:47 +11:00
- name : Setup initial test project
shell :
executable : /bin/bash
chdir : "{{ project_tmp.stdout }}"
cmd : |
set -xe
git init testproject.config
pushd testproject.config
git remote add origin http://admin:secret@localhost:8081/a/y/testproject
git pull origin refs/meta/config
echo "{{ group_json.id }} CI-tools" >> groups # noqa 203
cat >project.config <<EOF
[ access]
inheritFrom = All-Projects
[ submit]
action = inherit
[ access "refs/heads/*"]
label-Review-Priority = -1..+2 group CI-tools
label-Backport-Candidate = -1..+1 group CI-tools
[ label "Review-Priority"]
copyCondition = changekind:NO_CODE_CHANGE OR changekind:TRIVIAL_REBASE OR is:MAX OR is:MIN
defaultValue = 0
function = NoBlock
value = -1 Branch Freeze
value = 0 No Priority
value = +1 Important Change
value = +2 Urgent Change
[ label "Backport-Candidate"]
copyCondition = changekind:NO_CODE_CHANGE OR changekind:TRIVIAL_REBASE OR is:MAX OR is:MIN
defaultValue = 0
function = NoBlock
value = -1 Not a backport candidate
value = 0 Backport review needed
value = +1 Should backport
[ submit-requirement "Review-Priority"]
description = The review priority
submittableIf = -label:Review-Priority=MIN
[ submit-requirement "Backport-Candidate"]
applicableIf = is:false
description = Backport candidate status
submittableIf = is:true
EOF
git add project.config groups
git commit -m 'Updated project config'
git push origin HEAD:refs/meta/config
- name : Create initial commit and changes in testproject
2020-12-03 11:54:48 +11:00
shell :
executable : /bin/sh
chdir : "{{ project_tmp.stdout }}"
cmd : |
set -x
2021-01-28 13:52:08 +11:00
2020-12-03 11:54:48 +11:00
git init .
cat >.gitreview <<EOF
[ gerrit]
host=localhost
port=29418
2021-08-02 14:12:57 -07:00
project=y/testproject
2020-12-03 11:54:48 +11:00
EOF
git add .gitreview
git commit -m "Initial commit"
2021-08-02 14:12:57 -07:00
git remote add gerrit http://admin:secret@localhost:8081/y/testproject
2020-12-03 11:54:48 +11:00
git push -f --set-upstream gerrit +HEAD:master
curl -Lo .git/hooks/commit-msg http://localhost:8081/tools/hooks/commit-msg
chmod u+x .git/hooks/commit-msg
2021-01-28 13:52:08 +11:00
cat >file-1.txt <<EOF
Hello, this is a file
EOF
git add file-1.txt
git commit -m "Sample review 1"
git push gerrit HEAD:refs/for/master
cat >file-2.txt <<EOF
Hello, this is a file
EOF
git add file-2.txt
git commit -m "Sample review 2"
git push gerrit HEAD:refs/for/master
cat >file-3.txt <<EOF
2020-12-03 11:54:48 +11:00
Hello, this is a file
EOF
2021-01-28 13:52:08 +11:00
git add file-3.txt
git commit -m "Sample review 3"
2020-12-03 11:54:48 +11:00
git push gerrit HEAD:refs/for/master
2021-01-28 13:52:08 +11:00
- name : Post a sample failure review
2020-12-03 11:54:48 +11:00
uri :
2022-12-19 16:13:47 +11:00
url : 'http://localhost:8081/a/changes/{{ item.id }}/revisions/1/review'
2020-12-03 11:54:48 +11:00
method : POST
user : zuul
password : secret
body_format : json
body :
tag : 'autogenerated:zuul:check'
2021-01-28 13:52:08 +11:00
labels :
2022-12-19 16:13:47 +11:00
'Verified' : '{{ item.verified }}'
'Review-Priority' : '{{ item.priority }}'
'Backport-Candidate' : '{{ item.backport }}'
2021-01-28 13:52:08 +11:00
message : |
Build failed (check pipeline). For information on how to proceed, see
https://docs.opendev.org/opendev/infra-manual/latest/developers.html#automated-testing
- test-success https://zuul.opendev.org/t/openstack/build/00b1ce7d5d994339a54dd8142a6813a6 : SUCCESS in {{ range(1, 59) | random }}m 22s
- test-failure https://zuul.opendev.org/t/openstack/build/00b1ce7d5d994339a54dd8142a6813a6 : FAILURE in {{ range(1, 59) | random }}m 22s
- test-retry-limit https://zuul.opendev.org/t/openstack/build/20efbb1b6983453884103e9628a70942 : RETRY_LIMIT in {{ range(1, 59) | random }}m 24s
2021-02-24 16:50:46 +11:00
- test-skipped https://zuul.opendev.org/t/openstack/build/None : SKIPPED
2021-01-28 13:52:08 +11:00
- test-aborted https://zuul.opendev.org/t/openstack/build/bc4a4559645b4088a9f8586c043c4764 : ABORTED in {{ range(1, 59) | random }}m 19s
- test-merger-failure https://zuul.opendev.org/t/openstack/build/cb469750b250430b95a02697931d6030 : MERGER_FAILURE in {{ range(1, 59) | random }}m 14s
- test-node-failure https://zuul.opendev.org/t/openstack/build/0897fafc9652480794652fc49e3c9baf : NODE_FAILURE in {{ range(1, 59) | random }}m 48s
- test-timed-out https://zuul.opendev.org/t/openstack/build/57c4eb5174554cbfbb06fd9118eb1ae4 : TIMED_OUT in {{ range(1, 59) | random }}m 37s (non-voting)
- test-post-failure https://zuul.opendev.org/t/openstack/build/30afb96669fe4f19b6215e79615ecd90 : POST_FAILURE in {{ range(1, 59) | random }}m 58s
- test-config-error https://zuul.opendev.org/t/openstack/build/76c69b8062284d959a85b55bc460f822 : CONFIG_ERROR in {{ range(1, 59) | random }}m 27s
- test-disk-full https://zuul.opendev.org/t/openstack/build/0897fafc9743580794652fc49e3c9baf : DISK_FULL in {{ range(1, 59) | random }}m 48s
2021-02-24 16:50:46 +11:00
- test-error https://zuul.opendev.org/t/openstack/build/0897bedc9743580794652fc49e3c1234 : ERROR This is an error message in {{ range(1, 59) | random }}m 32s
2021-01-28 13:52:08 +11:00
loop :
2022-12-19 16:13:47 +11:00
- id : '1'
verified : '-2'
priority : '-1'
backport : '-1'
- id : '2'
verified : '+1'
priority : '+1'
backport : '0'
- id : '3'
verified : '+2'
priority : '+2'
backport : '+1'
2021-01-28 13:52:08 +11:00
- name : Post a sample good review in another pipeline
uri :
url : 'http://localhost:8081/a/changes/{{ item }}/revisions/1/review'
method : POST
user : zuul
password : secret
body_format : json
body :
tag : 'autogenerated:zuul:check-secondary'
message : |
Build succeeded (Secondary pipeline).
- test-second-ci https://zuul.opendev.org/t/openstack/build/f9c14856bf4e485089ca8fc8f00f324b : SUCCESS in {{ range(1, 59) | random}}m 11s
loop :
- 1
- 2
- 3
2020-12-03 11:54:48 +11:00
2021-11-10 06:50:49 +11:00
# NOTE(ianw) we do an add/delete/add cycle as we've seen issues
# with duplicate updates causing problems before; e.g.
# https://gerrit-review.googlesource.com/c/gerrit/+/312602
2021-11-05 10:05:33 +11:00
- name : Post a file review to confirm accountPatchDb connection
uri :
url : 'http://localhost:8081/a/changes/y%2Ftestproject~1/revisions/1/files/file-1.txt/reviewed'
2021-11-10 06:50:49 +11:00
method : '{{ item[0] }}'
2021-11-05 10:05:33 +11:00
user : admin
password : secret
2021-11-10 06:50:49 +11:00
status_code : '{{ item[1] }}'
loop :
- [ PUT, 201 ]
- [ DELETE, 204 ]
- [ PUT, 201 ]