eff9f360f7
This switches from the ansible/dhall operator framework to kopf, an operator framework written in pure Python. This allows us to: * Build the operator application as a Python app. * Build the operator image using the opendev python builder images. * Run the operator as a Python CLI program "zuul-operator". * Write procedural Python code to handle operator tasks (such as creating new nodepool launchers when providers are added). * Use Jinja for templating config files and k8s resource files (direct pythonic manipulation of resources is an option too). The new CR nearly matches the existing one, with some minor differences. Some missing features and documentation are added in the commits immediately following; they should be reviewed and merged as a unit. Also, fx waiting for scheduler to settle in functional test since we changed this log line in Zuul. Change-Id: Ib37b67e3444b7cd44692d48eee77775ee9049e9f Change-Id: I70ec31ecd8fe264118215944022b2e7b513dced9
147 lines
4.4 KiB
YAML
147 lines
4.4 KiB
YAML
- name: run functional tst
|
|
hosts: all
|
|
pre_tasks:
|
|
- name: install git
|
|
become: yes
|
|
package:
|
|
name:
|
|
- git
|
|
- jq
|
|
|
|
- name: install websocket client
|
|
become: yes
|
|
command: python3 -m pip install websocket-client
|
|
|
|
tasks:
|
|
- name: get rest api url
|
|
command: kubectl get svc zuul-web -o jsonpath='{.spec.clusterIP}'
|
|
register: zuul_web_ip
|
|
|
|
- name: set fact zuul_web_url
|
|
set_fact:
|
|
zuul_web_url: "http://{{ zuul_web_ip.stdout_lines[0] }}:9000"
|
|
zuul_ws_url: "ws://{{ zuul_web_ip.stdout_lines[0] }}:9000"
|
|
|
|
- name: ensure zuul web api is working
|
|
when: skip_check is not defined
|
|
include_tasks: tasks/zuul_web_check.yaml
|
|
vars:
|
|
endpoint: "/api/tenants"
|
|
expected:
|
|
- name: local
|
|
projects: 1
|
|
queue: 0
|
|
|
|
- name: setup git service
|
|
include_tasks: tasks/git_setup.yaml
|
|
|
|
- name: create a config project
|
|
include_tasks: tasks/create_config.yaml
|
|
|
|
- name: update kubernetes resources
|
|
vars:
|
|
tenants:
|
|
- tenant:
|
|
name: local
|
|
source:
|
|
opendev.org:
|
|
config-projects:
|
|
- zuul/zuul-base-jobs
|
|
untrusted-projects:
|
|
- zuul/zuul-jobs
|
|
local-git:
|
|
config-projects:
|
|
- config
|
|
block:
|
|
- k8s:
|
|
namespace: default
|
|
definition:
|
|
apiVersion: v1
|
|
kind: Secret
|
|
metadata:
|
|
name: "zuul-yaml-conf"
|
|
stringData:
|
|
main.yaml: "{{ tenants | to_yaml }}"
|
|
|
|
- include_tasks: tasks/apply_cr.yaml
|
|
vars:
|
|
spec:
|
|
executor:
|
|
count: 1
|
|
sshkey:
|
|
secretName: executor-ssh-key
|
|
merger:
|
|
count: 1
|
|
scheduler:
|
|
config:
|
|
secretName: zuul-yaml-conf
|
|
launcher:
|
|
config:
|
|
secretName: nodepool-yaml-conf
|
|
connections:
|
|
opendev.org:
|
|
baseurl: https://opendev.org
|
|
driver: git
|
|
local-git:
|
|
baseurl: "git://{{ ansible_all_ipv4_addresses[0] }}/"
|
|
driver: git
|
|
externalConfig:
|
|
kubernetes:
|
|
secretName: nodepool-kube-config
|
|
jobVolumes:
|
|
- context: trusted
|
|
access: rw
|
|
path: /system-dbus/
|
|
dir: /system-dbus/
|
|
volume:
|
|
name: system-dbus
|
|
hostPath:
|
|
path: /run/dbus
|
|
type: DirectoryOrCreate
|
|
|
|
- name: ensure a job is running
|
|
when: skip_check is not defined
|
|
include_tasks: tasks/zuul_web_check.yaml
|
|
vars:
|
|
endpoint: "/api/tenants"
|
|
expected:
|
|
- name: local
|
|
projects: 1
|
|
# 1 queue means a job is running
|
|
queue: 1
|
|
|
|
- name: get buillds results
|
|
include_tasks: tasks/zuul_web_check.yaml
|
|
vars:
|
|
endpoint: "/api/tenant/local/builds"
|
|
|
|
- name: ensure success build
|
|
assert:
|
|
that:
|
|
- result.json[0].result == 'SUCCESS'
|
|
|
|
- name: grab job uuid
|
|
shell: |
|
|
curl -s {{ zuul_web_url }}/api/tenant/local/status | jq -r '.pipelines[].change_queues[].heads[][].jobs[].uuid'
|
|
register: _job_uuid
|
|
# Wait until the executor start the job
|
|
until: _job_uuid.stdout != "" and _job_uuid.stdout != "null"
|
|
retries: 60
|
|
delay: 1
|
|
|
|
- name: connect to console-stream
|
|
command: |
|
|
python3 /usr/local/bin/wsdump.py -r --eof-wait 5 -t '{"uuid":"{{ _job_uuid.stdout_lines[0] }}","logfile":"console.log"}' {{ zuul_ws_url }}/api/tenant/local/console-stream
|
|
register: console_stream
|
|
|
|
- name: show console stream
|
|
debug:
|
|
var: console_stream
|
|
|
|
- name: fail if console stream does not contains expected job output
|
|
when: "'Job console starting...' not in console_stream.stdout"
|
|
# It seems like wsdump.py doesn't always stay connected for the whole job duration
|
|
# when: "'Demo job is running' not in console_stream.stdout"
|
|
fail:
|
|
msg: "Task output is missing from: {{ console_stream.stdout }}"
|