#7 Add basic testing
Merged 2 years ago by zuul. Opened 2 years ago by mhuin.
rpms/ mhuin/python-zuul-client zuul_tests  into  rawhide

file modified
+4 -1
@@ -2,7 +2,7 @@ 

  

  Name:       python-%{pypi_name}

  Version:    0.0.4

- Release:    1%{?dist}

+ Release:    2%{?dist}

  Summary:    The zuulclient Python module

  License:    ASL 2.0

  URL:        https://zuul-ci.org
@@ -89,6 +89,9 @@ 

  %doc build/html

  

  %changelog

+ * Thu Feb  4 2021 Matthieu Huin <mhuin@redhat.com> - 0.0.4-2

+ - Add basic testing

+ 

  * Thu Feb  4 2021 Matthieu Huin <mhuin@redhat.com> - 0.0.4-1

  - Bump to 0.0.4

  

@@ -0,0 +1,86 @@ 

+ - 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 web-daemon

+   ignore_errors: true

+ 

+ # https://bugzilla.redhat.com/show_bug.cgi?id=1866463

+ - name: Ensure dulwich running

+   shell: "python3 /usr/lib64/python3.9/site-packages/dulwich/cli.py 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/{{ ansible_user_dir }}

+       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: 2

+ 

+ - 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'"

@@ -0,0 +1,9 @@ 

+ - name: Install Zuul packages

+   package:

+     name:

+       - zuul-scheduler

+       - zuul-executor

+       - zuul-web

+       - python3-zuul-client

+     state: present

+   become: true

file added
+6
@@ -0,0 +1,6 @@ 

+ - tenant:

+     name: default

+     source:

+       local_git:

+         config-projects:

+           - zuul-config

file added
+8
@@ -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

@@ -0,0 +1,3 @@ 

+ - tenant:

+     name: default

+     source: {}

empty or binary file added
file added
+2
@@ -0,0 +1,2 @@ 

+ [config]

+ key=secret

@@ -0,0 +1,56 @@ 

+ - name: Ensure scheduler and executor service are down

+   service:

+     name: "{{ item }}"

+     state: stopped

+   loop:

+     - zuul-executor

+     - 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

+       dburi=postgresql://postgres:mypassword@127.0.0.1:5432/zuul

+   become: true

+ 

+ - name: Setup Ansible virtual environment for the Zuul executor

+   shell: zuul-manage-ansible -u -r /var/lib/zuul/ansible-bin

+   become_user: zuul

+   become: true

+ 

+ - name: Create ssh keypair for Zuul

+   shell: ssh-keygen -t rsa -N '' -f /var/lib/zuul/.ssh/id_rsa

+   args:

+     creates: /var/lib/zuul/.ssh/id_rsa

+   become_user: zuul

+   become: true

+ 

+ - name: Start scheduler and executor services

+   service:

+     name: "{{ item }}"

+     state: started

+   loop:

+     - zuul-executor

+     - zuul-scheduler

+   become: true

+ 

+ - name: Give some time to services to fully start

+   pause:

+     seconds: 15

+ 

+ - name: Check zuul core services are up

+   shell: systemctl is-active {{ item }}

+   loop:

+     - zuul-executor

+     - zuul-scheduler

+   become: true

@@ -0,0 +1,85 @@ 

+ - name: Install JDK

+   package:

+     name:

+       - java-latest-openjdk

+       - postgresql

+       - postgresql-server

+       - python3-psycopg2

+     state: present

+   become: true

+ 

+ - name: Create /tmp/zookeeper

+   file:

+     path: /tmp/zookeeper

+     state: directory

+   become: true

+ 

+ - name: Get and extract Zookeeper

+   unarchive:

+     src: https://archive.apache.org/dist/zookeeper/zookeeper-{{ zookeeper_version }}/apache-zookeeper-{{ zookeeper_version }}-bin.tar.gz

+     dest: /tmp/zookeeper

+     remote_src: yes

+   become: true

+ 

+ - name: Setup Zookeeper config file

+   copy:

+     src: /tmp/zookeeper/apache-zookeeper-{{ zookeeper_version }}-bin/conf/zoo_sample.cfg

+     dest: /tmp/zookeeper/apache-zookeeper-{{ zookeeper_version }}-bin/conf/zoo.cfg

+     remote_src: true

+   become: true

+ 

+ - name: Ensure Zookeeper not running

+   command: pkill -f zookeeper

+   ignore_errors: true

+   become: true

+ 

+ - name: Start Zookeeper

+   shell: /tmp/zookeeper/apache-zookeeper-{{ zookeeper_version }}-bin/bin/zkServer.sh start

+   become: true

+ 

+ - name: Init postgresql DB

+   shell: /usr/bin/postgresql-setup --initdb

+   ignore_errors: true

+   become: true

+ 

+ - name: Start postgres

+   service:

+     name: postgresql

+     state: started

+   become: true

+ 

+ - name: Wait for the service to be up

+   pause:

+     seconds: 15

+ 

+ - name: Setup a postgres admin password

+   shell: psql -c "ALTER USER postgres WITH PASSWORD 'mypassword';"

+   become_user: postgres

+   become: true

+   environment:

+     PGPASSWORD: mypassword

+ 

+ - name: Create the database for zuul

+   shell: createdb --owner=postgres zuul

+   register: cmd

+   failed_when: cmd.rc != 0 and not "'already exists' in cmd.stderr"

+   # ignore_errors: true

+   become_user: postgres

+   become: true

+   environment:

+     PGPASSWORD: mypassword

+ 

+ - name: Enable auth access

+   shell: sed -i 's|127.0.0.1/32            ident|127.0.0.1/32            md5|' /var/lib/pgsql/data/pg_hba.conf

+   become: true

+ 

+ - name: Restart postgres

+   service:

+     name: postgresql

+     state: restarted

+   become: true

+ 

+ - name: Ensure postgres access

+   shell: psql -h 127.0.0.1 -U postgres zuul -c "\dt"

+   environment:

+     PGPASSWORD: mypassword

@@ -0,0 +1,59 @@ 

+ - name: Ensure zuul-web service is down

+   service:

+     name: zuul-web

+     state: stopped

+   become: true

+ 

+ - name: Install httpd

+   package:

+     name:

+       - httpd

+     state: present

+   become: true

+ 

+ - name: Ensure httpd can connect to zuul-web

+   command: setsebool -P httpd_can_network_connect on

+   become: true

+ 

+ - name: Add the reverse proxy setting in httpd

+   blockinfile:

+     create: true

+     path: /etc/httpd/conf.d/zuul.conf

+     block: |

+       RewriteEngine on

+       RewriteRule ^/api/tenant/(.*)/console-stream ws://localhost:9000/api/tenant/$1/console-stream [P]

+       RewriteRule ^/(.*)$ http://localhost:9000/$1 [P]

+   become: true

+ 

+ - name: Reload httpd

+   service:

+     name: httpd

+     state: reloaded

+   become: true

+ 

+ - name: Ensure zuul-web service is up

+   service:

+     name: zuul-web

+     state: started

+   become: true

+ 

+ - name: Give some time to services to fully start

+   pause:

+     seconds: 15

+ 

+ - name: Check zuul web services are up

+   shell: systemctl is-active {{ item }}

+   loop:

+     - zuul-web

+     - httpd

+   become: true

+ 

+ - name: Check we can access the Zuul API

+   shell: curl http://localhost:9000/api/tenants

+   register: cmd

+   failed_when: not "'default' in cmd.stdout"

+ 

+ - name: Check we can access the Zuul API via httpd

+   shell: curl http://localhost/api/tenants

+   register: cmd

+   failed_when: not "'default' in cmd.stdout"

@@ -0,0 +1,57 @@ 

+ - name: copy secret file

+   copy:

+     src: secret

+     dest: secret

+   become: true

+ 

+ - name: test secret generation

+   command: zuul-client --insecure --zuul-url http://localhost/ encrypt --tenant default --project zuul-config --infile secret --secret-name mysecret --field-name file

+   register: zc

+   failed_when:

+     - zc.rc != 0

+ 

+ - name: create auth token

+   command: zuul create-auth-token --auth-config zuul_operator --tenant default --user testuser

+   register: raw_token

+   failed_when:

+     - raw_token.rc != 0

+     - not raw_token.output.startswith('Bearer ')

+   become: true

+ 

+ - name: test autohold job

+   command: zuul-client --insecure --zuul-url http://localhost/ --auth-token {{ raw_token.stdout[7:] }} autohold --tenant default --project zuul-config --job my-noop --reason REASON

+   register: ah

+   failed_when:

+     - ah.rc != 0

+ 

+ - name: get zuul version

+   command: zuul --version

+   register: zuul_version

+ 

+ # works with zuul > 3.19.1 - missing 'max_count' in JSON response

+ - name: test autohold info

+   command: zuul-client --insecure --zuul-url http://localhost/ autohold-list --tenant default

+   register: ah_info

+   failed_when:

+     - ah_info.rc != 0

+   when: zuul_version.stdout.find('3.19.1-') == -1

+ 

+ - name: test autohold delete

+   command: zuul-client --insecure --zuul-url http://localhost/ --auth-token {{ raw_token.stdout[7:] }} autohold-delete --tenant default 0000000000

+   register: ah_delete

+   failed_when:

+     - ah_delete.rc != 0

+ 

+ # works with zuul > 3.19.1 - "trigger" still needed

+ - name: test enqueue-ref

+   command: zuul-client --insecure --zuul-url http://localhost/ --auth-token {{ raw_token.stdout[7:] }} enqueue-ref --tenant default --project zuul-config --pipeline test --ref refs/heads/master

+   register: enqueue

+   failed_when:

+     - enqueue.rc != 0

+   when: zuul_version.stdout.find('3.19.1-') == -1

+ 

+ # - name: test dequeue

+ #   command: zuul-client --insecure --zuul-url http://localhost/ --auth-token {{ raw_token.stdout[7:] }} dequeue --tenant default --pipeline test --project zuul-config --ref refs/heads/master

+ #   register: dequeue

+ #   failed_when:

+ #     - dequeue.rc != 0

file added
+23
@@ -0,0 +1,23 @@ 

+ # Shamelessly adapted from rpms/zuul tests

+ - hosts: localhost

+   vars:

+     zookeeper_version: "3.6.1"

+   tasks:

+     - import_tasks: setup_zuul_prerequisites.yml

+       tags:

+         - zuul_prerequisites

+     - import_tasks: install_zuul_and_client.yml

+       tags:

+         - install_zuul_and_client

+     - import_tasks: setup_zuul_core.yml

+       tags:

+         - setup_zuul_core

+     - import_tasks: setup_zuul_web.yml

+       tags:

+         - setup_zuul_web

+     - import_tasks: configure_zuul_jobs.yml

+       tags:

+         - configure_zuul_jobs

+     - import_tasks: test_zuul_client.yml

+       tags:

+         - test_zuul_client

file added
+40
@@ -0,0 +1,40 @@ 

+ - 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:

+ 

+ - pipeline:

+     name: test

+     description: a test pipeline.

+     manager: independent

+     precedence: low

+     trigger:

+       local_git:

+         - event: ref-updated

+     success:

+       sqlreporter:

+     failure:

+       sqlreporter:

+ 

+ - job:

+     name: my-noop

+     description: Minimal working job

+     parent: null

+     run: my-noop.yaml

+ 

+ - project:

+     periodic:

+       jobs:

+         - my-noop

+     test:

+       jobs:

+         - my-noop

no initial comment

TODO
- see if we can import tests from rpms/zuul
- test re-enqueue

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci

1 new commit added

  • fix bad indentation
2 years ago

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci

1 new commit added

  • fix indent error
2 years ago

Build succeeded.

1 new commit added

  • Test autohold
2 years ago

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci

1 new commit added

  • Test enqueue and dequeue
2 years ago

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci

1 new commit added

  • Fix trigger argument
2 years ago

Build failed. More information on how to proceed and troubleshoot errors available at https://fedoraproject.org/wiki/Zuul-based-ci

1 new commit added

  • Remove tests incompatible with zuul 3.19.1
2 years ago

Build succeeded.

Metadata Update from @mhuin:
- Pull-request tagged with: gateit

2 years ago

Build succeeded (gate pipeline).

Pull-Request has been merged by zuul

2 years ago

Build succeeded (promote pipeline).