From 50eaa3fbabd3c4c8c73fed56d5608829bf035cad Mon Sep 17 00:00:00 2001 From: Fabien Boucher Date: Aug 13 2020 08:52:25 +0000 Subject: functional test second step --- diff --git a/README.md b/README.md index 7ddc297..7ab2483 100644 --- a/README.md +++ b/README.md @@ -229,6 +229,7 @@ $ git commit -m"Init demo config" ### Run a Git deamon to serve the config repository ``` +$ sudo dnf install -y python3-dulwich $ dulwich web-daemon -l 0.0.0.0 / ``` diff --git a/tests/configure_zuul_jobs.yml b/tests/configure_zuul_jobs.yml new file mode 100644 index 0000000..93b2ae8 --- /dev/null +++ b/tests/configure_zuul_jobs.yml @@ -0,0 +1,84 @@ +- name: Install dulwich + package: + name: python3-dulwich + state: present + become: true + +- name: Create a local git repository + shell: git init {{ ansible_user_dir }}/zuul-config + +- name: Create .zuul.yaml + copy: + src: zuul.yaml + dest: "{{ ansible_user_dir }}/zuul-config/.zuul.yaml" + +- name: Create my-noop.yaml + copy: + src: my-noop.yaml + dest: "{{ ansible_user_dir }}/zuul-config/my-noop.yaml" + +- name: Commit zuul-config changes + shell: "{{ item }}" + register: cmd + failed_when: + - cmd.rc != 0 + - not "'nothing to commit' in cmd.stdout" + args: + chdir: "{{ ansible_user_dir }}/zuul-config/" + loop: + - git config user.name "John Doe" + - git config user.email "john@localhost" + - git add -A . + - git commit -m"Init demo config" + +- name: Ensure dulwich down + shell: pkill -f dulwich + +- name: Ensure dulwich running + shell: "dulwich web-daemon -l 0.0.0.0 / &" + +- name: Add the git connection into the zuul config + blockinfile: + path: /etc/zuul/zuul.conf + marker: "# {mark} local_git" + block: | + [connection local_git] + driver=git + baseurl=http://localhost:8000/home/fedora + poll_delay=300 + become: true + +- name: Setup the Zuul default tenant to load zuul-config + copy: + src: main.yaml + dest: /etc/zuul/main.yaml + become: true + +- name: Restart Zuul components + service: + name: "{{ item }}" + state: restarted + become: true + loop: + - zuul-scheduler + - zuul-executor + - zuul-web + +- name: Give some time to services to fully start + pause: + seconds: 15 + +- name: Check zuul services are up + shell: systemctl is-active {{ item }} + loop: + - zuul-scheduler + - zuul-executor + - zuul-web + become: true + +- name: Give some time to Zuul to trigger and execute the job + pause: + minutes: 1 + +- name: Ensure the my-noop job was executed + shell: python -c "import requests; r = requests.get('http://localhost/api/tenant/default/builds').json(); assert r[0]['job_name'] == 'my-noop'; assert r[0]['result'] == 'SUCCESS'" diff --git a/tests/main.yaml b/tests/main.yaml new file mode 100644 index 0000000..d6aca6e --- /dev/null +++ b/tests/main.yaml @@ -0,0 +1,6 @@ +- tenant: + name: default + source: + local_git: + config-projects: + - zuul-config diff --git a/tests/my-noop.yaml b/tests/my-noop.yaml new file mode 100644 index 0000000..46deb7f --- /dev/null +++ b/tests/my-noop.yaml @@ -0,0 +1,8 @@ +--- +- hosts: localhost + tasks: + - name: List working directory + command: ls -al {{ ansible_user_dir }} + - name: Sleep 30 seconds + wait_for: + timeout: 30 diff --git a/tests/orig_main.yaml b/tests/orig_main.yaml new file mode 100644 index 0000000..a62fde9 --- /dev/null +++ b/tests/orig_main.yaml @@ -0,0 +1,3 @@ +- tenant: + name: default + source: {} diff --git a/tests/setup_postgres.yml b/tests/setup_postgres.yml index 4b6357e..49b5898 100644 --- a/tests/setup_postgres.yml +++ b/tests/setup_postgres.yml @@ -17,7 +17,7 @@ shell: createdb --owner=postgres zuul register: cmd failed_when: cmd.rc != 0 and not "'already exists' in cmd.stderr" - ignore_errors: true + # ignore_errors: true become_user: postgres become: true environment: diff --git a/tests/setup_zuul_core.yml b/tests/setup_zuul_core.yml index 961d236..283da66 100644 --- a/tests/setup_zuul_core.yml +++ b/tests/setup_zuul_core.yml @@ -7,9 +7,16 @@ - zuul-scheduler become: true +- name: Setup the Zuul default tenant to be empty + copy: + src: orig_main.yaml + dest: /etc/zuul/main.yaml + become: true + - name: Define the sql connection blockinfile: path: /etc/zuul/zuul.conf + marker: "# {mark} sqlreporter" block: | [connection sqlreporter] driver=sql diff --git a/tests/tests.yml b/tests/tests.yml index 020c5f2..faf7fa9 100644 --- a/tests/tests.yml +++ b/tests/tests.yml @@ -17,3 +17,7 @@ - import_tasks: setup_zuul_web.yml tags: - setup_zuul_web + # Now configure Zuul to run a job + - import_tasks: configure_zuul_jobs.yml + tags: + - configure_zuul_jobs diff --git a/tests/zuul.yaml b/tests/zuul.yaml new file mode 100644 index 0000000..ab7c5fe --- /dev/null +++ b/tests/zuul.yaml @@ -0,0 +1,24 @@ +- pipeline: + name: periodic + post-review: true + description: Jobs in this queue are triggered every minute. + manager: independent + precedence: low + trigger: + timer: + - time: '* * * * *' + success: + sqlreporter: + failure: + sqlreporter: + +- job: + name: my-noop + description: Minimal working job + parent: null + run: my-noop.yaml + +- project: + periodic: + jobs: + - my-noop