gerrit: Initalize in testing
By setting the auth type to DEVELOPMENT_BECOME_ANY_ACCOUNT and passing --dev to the init process, gerrit will create an initial admin user for us. We leverage this user to create a sample project, change, Zuul user and sample CI result comment. We also update testinfra to take some screenshots of gerrit and report them back. Change-Id: I56cda99790d3c172e10b664e57abeca10efc5566
This commit is contained in:
parent
be085e564e
commit
d1694d4c98
@ -4,6 +4,7 @@ gerrit_home_dir: /home/gerrit2
|
||||
gerrit_site_dir: "{{ gerrit_home_dir }}/review_site"
|
||||
gerrit_run_compose_up: false
|
||||
gerrit_run_init: false
|
||||
gerrit_run_init_dev_mode: false
|
||||
gerrit_packed_git_open_files: 4096
|
||||
gerrit_container_image: docker.io/opendevorg/gerrit:3.2
|
||||
gerrit_container_volumes:
|
||||
|
@ -2,7 +2,7 @@
|
||||
shell:
|
||||
cmd: >
|
||||
docker-compose run shell
|
||||
java -jar /var/gerrit/bin/gerrit.war init -d /var/gerrit -b --no-auto-start --skip-plugins --skip-all-downloads
|
||||
java -jar /var/gerrit/bin/gerrit.war init -d /var/gerrit -b --no-auto-start --skip-plugins --skip-all-downloads {% if gerrit_run_init_dev_mode %} --dev {% endif %}
|
||||
chdir: /etc/gerrit-compose/
|
||||
when: gerrit_run_init | bool
|
||||
|
||||
|
@ -9,13 +9,17 @@
|
||||
reportBugUrl = https://docs.openstack.org/infra/system-config/project.html#contributing
|
||||
gitHttpUrl = https://{{ gerrit_vhost_name }}/
|
||||
serverId = {{ gerrit_serverid }}
|
||||
{% if not gerrit_run_init_dev_mode %}
|
||||
[auth]
|
||||
contributorAgreements = true
|
||||
type = OPENID_SSO
|
||||
cookieSecure = true
|
||||
enableRunAs = true
|
||||
openIdSsoUrl = https://login.ubuntu.com/+openid
|
||||
|
||||
{% else %}
|
||||
[auth]
|
||||
type = DEVELOPMENT_BECOME_ANY_ACCOUNT
|
||||
{% endif %}
|
||||
[sendemail]
|
||||
smtpServer = localhost
|
||||
from = MIXED
|
||||
|
84
playbooks/test-review.yaml
Normal file
84
playbooks/test-review.yaml
Normal file
@ -0,0 +1,84 @@
|
||||
- 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
|
||||
|
||||
- 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
|
||||
|
||||
- name: Create temp dir for project creation
|
||||
shell: mktemp -d
|
||||
register: project_tmp
|
||||
|
||||
- name: Create project project in Gerrit
|
||||
uri:
|
||||
url: http://localhost:8081/a/projects/test-project
|
||||
method: PUT
|
||||
user: admin
|
||||
password: secret
|
||||
status_code: 201
|
||||
|
||||
- name: Create initial commit and change in test-project
|
||||
shell:
|
||||
executable: /bin/sh
|
||||
chdir: "{{ project_tmp.stdout }}"
|
||||
cmd: |
|
||||
set -x
|
||||
git init .
|
||||
git config user.name "Admin"
|
||||
git config user.email "admin@example.com"
|
||||
cat >.gitreview <<EOF
|
||||
[gerrit]
|
||||
host=localhost
|
||||
port=29418
|
||||
project=project
|
||||
EOF
|
||||
git add .gitreview
|
||||
git commit -m "Initial commit"
|
||||
git remote add gerrit http://admin:secret@localhost:8081/test-project
|
||||
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
|
||||
|
||||
cat >file.txt <<EOF
|
||||
Hello, this is a file
|
||||
EOF
|
||||
git add file.txt
|
||||
git commit -m "Sample review"
|
||||
git push gerrit HEAD:refs/for/master
|
||||
|
||||
- name: Post a sample review
|
||||
uri:
|
||||
url: http://localhost:8081/a/changes/1/revisions/1/review
|
||||
method: POST
|
||||
user: zuul
|
||||
password: secret
|
||||
body_format: json
|
||||
body:
|
||||
tag: 'autogenerated:zuul:check'
|
||||
message: "Patch Set 8: Verified-1\n\nBuild failed (check pipeline). For information on how to proceed, see\nhttps://docs.opendev.org/opendev/infra-manual/latest/developers.html#automated-testing\n\n\n- system-config-puppet-apply-4-ubuntu-xenial https://zuul.opendev.org/t/openstack/build/00b1ce7d5d994339a54dd8142a6813a6 : SUCCESS in 10m 22s\n- system-config-legacy-logstash-filters https://zuul.opendev.org/t/openstack/build/20efbb1b6983453884103e9628a70942 : SUCCESS in 8m 24s\n- opendev-tox-docs https://zuul.opendev.org/t/openstack/build/43a00a7e190b4ce2b3e20a86166c011a : SUCCESS in 3m 40s\n- opendev-buildset-registry https://zuul.opendev.org/t/openstack/build/bc4a4559645b4088a9f8586c043c4764 : SUCCESS in 46m 19s\n- tox-linters https://zuul.opendev.org/t/openstack/build/cb469750b250430b95a02697931d6030 : FAILURE in 19m 14s\n- system-config-run-base https://zuul.opendev.org/t/openstack/build/0897fafc9652480794652fc49e3c9baf : SUCCESS in 12m 48s\n- system-config-run-base-ansible-devel https://zuul.opendev.org/t/openstack/build/57c4eb5174554cbfbb06fd9118eb1ae4 : SUCCESS in 16m 37s (non-voting)\n- system-config-run-gitea https://zuul.opendev.org/t/openstack/build/30afb96669fe4f19b6215e79615ecd90 : SUCCESS in 37m 58s\n- system-config-run-review https://zuul.opendev.org/t/openstack/build/76c69b8062284d959a85b55bc460f822 : FAILURE in 15m 27s"
|
||||
|
||||
- name: Run selenium container
|
||||
include_role:
|
||||
name: run-selenium
|
||||
|
@ -87,6 +87,7 @@ gerrit_replication_ssh_rsa_pubkey_contents: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAB
|
||||
gerrit_database_type: h2
|
||||
gerrit_run_compose_up: true
|
||||
gerrit_run_init: true
|
||||
gerrit_run_init_dev_mode: true
|
||||
gerrit_storyboard_token: 52514e74-4b8f-4d6d-a29a-a6262f97578a
|
||||
gerrit_email_private_key: wjpkxebohgbid6rpuwpfrYsouxpgseluqir6yupppBczoezj
|
||||
gerrit_rest_token_private_key: A83fAC8x72wxcu
|
||||
|
@ -12,6 +12,10 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from selenium import webdriver
|
||||
from selenium.webdriver.support.ui import WebDriverWait
|
||||
from selenium.common.exceptions import TimeoutException
|
||||
import time
|
||||
|
||||
testinfra_hosts = [
|
||||
'review01.openstack.org',
|
||||
@ -21,3 +25,24 @@ testinfra_hosts = [
|
||||
def test_gerrit_listening(host):
|
||||
gerrit_web = host.socket("tcp://:::8081")
|
||||
assert gerrit_web.is_listening
|
||||
|
||||
|
||||
def test_gerrit_screenshot(host):
|
||||
driver = webdriver.Remote(
|
||||
command_executor='http://%s:4444/wd/hub' % (host.backend.get_hostname()),
|
||||
desired_capabilities=webdriver.DesiredCapabilities.FIREFOX)
|
||||
|
||||
try:
|
||||
driver.get("http://localhost:8081")
|
||||
WebDriverWait(driver, 30).until(lambda driver: driver.execute_script(
|
||||
'return document.readyState') == 'complete')
|
||||
driver.save_screenshot("/var/log/screenshots/gerrit-main-page.png")
|
||||
|
||||
driver.get("http://localhost:8081/c/test-project/+/1")
|
||||
WebDriverWait(driver, 30).until(lambda driver: driver.execute_script(
|
||||
'return document.readyState') == 'complete')
|
||||
driver.save_screenshot("/var/log/screenshots/gerrit-change-page.png")
|
||||
except TimeoutException as e:
|
||||
raise e
|
||||
finally:
|
||||
driver.quit()
|
||||
|
@ -835,6 +835,7 @@
|
||||
- playbooks/letsencrypt.yaml
|
||||
- playbooks/service-review-dev.yaml
|
||||
- playbooks/service-review.yaml
|
||||
run_test_playbook: playbooks/test-review.yaml
|
||||
host-vars:
|
||||
review01.openstack.org:
|
||||
host_copy_output:
|
||||
|
Loading…
x
Reference in New Issue
Block a user