summaryrefslogtreecommitdiff
path: root/playbooks
diff options
context:
space:
mode:
authorJames E. Blair <jeblair@redhat.com>2018-10-10 11:30:01 -0700
committerJames E. Blair <jeblair@redhat.com>2018-10-11 12:53:05 -0700
commit011d765915b4cf88f4db92e017a034a3efe5f40c (patch)
tree10e70ec7e2886043f9d36776cb84a132dae9a154 /playbooks
parenta1d8fc7a517594d9e4bfceaba652f83fd42827a9 (diff)
downloadzuul-011d765915b4cf88f4db92e017a034a3efe5f40c.tar.gz
Add a quick-start test job
This playbook performs approximately the same steps documented in the quick-start tutorial. Use it to verify that things still function. Note that it does not yet build the images from the current source (rather, it downloads them from dockerhub) so it is not suitable as a gate check (it does not use the change under test in zuul). It does, however, use the sample config files from the change under test, so can be used to verify changes to those. Incidentally, this is the first-ever live functional test between Zuul, Nodepool, and Gerrit. Change-Id: I5b3dc4b8a8d409787d07b4ad155898f97f1e9eb9
Diffstat (limited to 'playbooks')
-rw-r--r--playbooks/quick-start/main.yaml141
-rw-r--r--playbooks/quick-start/run.yaml49
2 files changed, 190 insertions, 0 deletions
diff --git a/playbooks/quick-start/main.yaml b/playbooks/quick-start/main.yaml
new file mode 100644
index 000000000..09f4e1ecf
--- /dev/null
+++ b/playbooks/quick-start/main.yaml
@@ -0,0 +1,141 @@
+- name: Run docker-compose up
+ shell:
+ cmd: docker-compose up -d
+ chdir: src/git.openstack.org/openstack-infra/zuul/doc/source/admin/examples
+ become: true
+- name: Wait for Gerrit to start
+ wait_for:
+ host: localhost
+ port: 29418
+- name: Wait for Zuul user to be created
+ uri:
+ url: http://localhost:8080/a/accounts/zuul/sshkeys
+ method: GET
+ user: admin
+ password: secret
+ register: result
+ until: result.status == 200 and result.redirected == false
+ delay: 1
+ retries: 120
+- name: fetch ssh host keys from gerrit
+ shell: ssh-keyscan -p 29418 localhost >> ~/.ssh/known_hosts
+- name: Check if example user exists in Gerrit
+ uri:
+ url: http://localhost:8080/accounts/user
+ status_code: 200, 404
+ register: user_check
+- name: Create example gerrit account
+ when: user_check.status==404
+ uri:
+ url: http://localhost:8080/a/accounts/user
+ method: PUT
+ user: admin
+ password: secret
+ status_code: 201
+ body_format: json
+ body:
+ name: Example User
+ ssh_key: "{{ ssh_public_key }}"
+ http_password: secret
+- name: Clone zuul-config
+ git:
+ repo: http://localhost:8080/zuul-config
+ dest: "{{ workspace }}/zuul-config"
+- name: Make initial change in zuul-config
+ copy:
+ src: ../../doc/source/admin/examples/zuul-config/
+ dest: "{{ workspace }}/zuul-config/"
+- name: Commit and upload initial change in zuul-config
+ shell:
+ chdir: "{{ workspace }}/zuul-config/"
+ executable: /bin/bash
+ cmd: |
+ {{ ssh_agent.stdout }}
+ rm zuul.d/jobs.yaml
+ git config user.email 'user@example.com'
+ git config user.name 'Example User'
+ git config gitreview.username 'user'
+ git add zuul.d playbooks
+ git commit -m "Add initial Zuul configuration"
+ git review -v
+- name: Query open changes
+ uri:
+ url: http://localhost:8080/a/changes/?q=status:open+project:zuul-config&o=CURRENT_REVISION
+ method: GET
+ user: admin
+ password: secret
+ return_content: true
+ register: changes
+- name: Approve zuul-config change
+ uri:
+ url: "http://localhost:8080/a/changes/{{ (changes.content[5:]|from_json)[0].id }}/revisions/{{ (changes.content[5:]|from_json)[0].current_revision }}/review"
+ method: POST
+ user: admin
+ password: secret
+ status_code: 200
+ body_format: json
+ body:
+ labels:
+ Code-Review: +2
+ Verified: +2
+ Workflow: +1
+- name: Merge zuul-config change
+ uri:
+ url: "http://localhost:8080/a/changes/{{ (changes.content[5:]|from_json)[0].id }}/revisions/{{ (changes.content[5:]|from_json)[0].current_revision }}/submit"
+ method: POST
+ user: admin
+ password: secret
+ status_code: 200
+- name: Clone test1
+ git:
+ repo: http://localhost:8080/test1
+ dest: "{{ workspace }}/test1"
+- name: Make test change in test1
+ copy:
+ src: ../../doc/source/admin/examples/test1/
+ dest: "{{ workspace }}/test1/"
+- name: Commit and upload test change in test1
+ shell:
+ chdir: "{{ workspace }}/test1/"
+ executable: /bin/bash
+ cmd: |
+ {{ ssh_agent.stdout }}
+ git config user.email 'user@example.com'
+ git config user.name 'Example User'
+ git config gitreview.username 'user'
+ mv zuul.yaml .zuul.yaml
+ git add .zuul.yaml playbooks
+ git commit -m "Add test Zuul job"
+ git review
+- name: Query open changes
+ uri:
+ url: http://localhost:8080/a/changes/?q=status:open+project:test1&o=CURRENT_REVISION
+ method: GET
+ user: admin
+ password: secret
+ return_content: true
+ register: changes
+- name: Wait for Zuul to report
+ uri:
+ url: "http://localhost:8080/a/changes/{{ (changes.content[5:]|from_json)[0].id }}//detail"
+ method: GET
+ user: admin
+ password: secret
+ return_content: true
+ register: result
+ until: (result.content[5:]|from_json).messages|length > 1
+ delay: 1
+ retries: 120
+- name: Find the log URL
+ set_fact:
+ log_url: "{{ (result.content[5:]|from_json).messages[1].message|regex_search('(http://[^ ]*)') }}"
+- debug:
+ msg: "{{ log_url }}"
+- name: Fetch log URL
+ get_url:
+ url: "{{ log_url }}job-output.txt.gz"
+ dest: "{{ workspace }}/job-output.txt.gz"
+- name: Uncompress log
+ command: "gunzip -f {{ workspace }}/job-output.txt.gz"
+- name: Verify log contents
+ command: "grep 'Hello world!' {{ workspace }}/job-output.txt"
diff --git a/playbooks/quick-start/run.yaml b/playbooks/quick-start/run.yaml
new file mode 100644
index 000000000..aff6f35e1
--- /dev/null
+++ b/playbooks/quick-start/run.yaml
@@ -0,0 +1,49 @@
+- hosts: all
+ vars:
+ workspace: /tmp/quickstart-test
+ tasks:
+ - name: Install docker-compose and git-review
+ package:
+ name:
+ - docker.io # See note [1]
+ - docker-compose
+ - git-review
+ state: present
+ become: true
+ - name: Create workspace directory
+ file:
+ state: directory
+ path: "{{ workspace }}"
+ - name: Generate example user ssh key
+ command: "ssh-keygen -f {{ workspace }}/id_rsa -N ''"
+ args:
+ creates: "{{ workspace }}/id_rsa.pub"
+ - name: Load example user SSH key
+ shell: "cat {{ workspace }}/id_rsa.pub"
+ register: ssh_key_cat
+ - name: Register example user SSH key
+ set_fact:
+ ssh_public_key: "{{ ssh_key_cat.stdout }}"
+ - name: Start ssh-agent
+ command: ssh-agent
+ register: ssh_agent
+ - name: Add key to ssh agent
+ shell:
+ executable: /bin/bash
+ cmd: |
+ {{ ssh_agent.stdout }}
+ ssh-add {{ workspace }}/id_rsa
+ - block:
+ - name: Run tasks in ssh agent
+ include_tasks: main.yaml
+ always:
+ - name: Stop ssh-agent
+ shell:
+ executable: /bin/bash
+ cmd: |
+ {{ ssh_agent.stdout }}
+ ssh-agent -k
+
+# [1]: docker.io is a recommended package and is therefore typically
+# automatically installed, however our test images disable this
+# behavior, so it is listed explicitly here.