summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Grasza <xek@redhat.com>2018-11-07 14:37:06 +0100
committerGrzegorz Grasza <xek@redhat.com>2018-11-20 20:01:01 +0100
commit47ce2f713686e0e15a1421c0c38d6998510c9e05 (patch)
treedb87e1a8bc20238e38941e965e7230144e395f0f
parente8ced3d13c61bb3278c7c2b2ae4167fb3f1ae242 (diff)
Add functional tests to CI
Notes
Notes (review): Code-Review+2: Juan Antonio Osorio Robles <jaosorior@redhat.com> Code-Review+2: Ade Lee <alee@redhat.com> Workflow+1: Ade Lee <alee@redhat.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Mon, 26 Nov 2018 19:23:12 +0000 Reviewed-on: https://review.openstack.org/616201 Project: openstack/novajoin Branch: refs/heads/master
-rw-r--r--.zuul.yaml41
-rw-r--r--README.rst12
-rw-r--r--bindep.txt5
-rw-r--r--playbooks/functional/post.yaml33
-rw-r--r--playbooks/functional/pre.yaml27
-rw-r--r--playbooks/functional/run.yaml12
-rw-r--r--roles/configure-freeipa/tasks/main.yaml59
-rw-r--r--roles/configure-novajoin/tasks/main.yaml55
-rw-r--r--roles/download-centos/tasks/main.yaml16
-rw-r--r--tox.ini2
10 files changed, 257 insertions, 5 deletions
diff --git a/.zuul.yaml b/.zuul.yaml
new file mode 100644
index 0000000..d064d49
--- /dev/null
+++ b/.zuul.yaml
@@ -0,0 +1,41 @@
1- project:
2 check:
3 jobs:
4 - novajoin-functional:
5 voting: false
6
7- job:
8 name: novajoin-functional
9 description: |
10 Run functional tests for novajoin.
11 parent: devstack-tox-base
12 nodeset: devstack-single-node-centos-7
13 pre-run: playbooks/functional/pre.yaml
14 run: playbooks/functional/run.yaml
15 post-run: playbooks/functional/post.yaml
16 vars:
17 devstack_services:
18 # FreeIPA is using Apache with TLS
19 tls-proxy: false
20 # Disable Swift services
21 s-account: false
22 s-container: false
23 s-object: false
24 s-proxy: false
25 # Disable Cinder services
26 c-api: false
27 c-bak: false
28 c-sch: false
29 c-vol: false
30 cinder: false
31 group-vars:
32 # This job runs single node, but for completeness:
33 subnode:
34 devstack_services:
35 # FreeIPA is using Apache with TLS
36 tls-proxy: false
37 # Disable Swift services
38 # s-*: false
39 # Disable Cinder services
40 c-bak: false
41 c-vol: false
diff --git a/README.rst b/README.rst
index a151bfc..9c3fc06 100644
--- a/README.rst
+++ b/README.rst
@@ -38,10 +38,14 @@ Package Requirements
38Beyond those packages normally installed by Openstack, these are also 38Beyond those packages normally installed by Openstack, these are also
39required:: 39required::
40 40
41 {free}ipa-python 41 python-ipalib
42 42 python-ipaclient
43These may be pip-installable but as of March 2017 it has only been 43
44extensively tested with real packages installed on RHEL/CentOS/Fedora. 44These may be pip-installable but still require other system packages
45like `krb5-devel` to be present and may not be compatible with your
46FreeIPA installation, so it is best to install them with your system
47package manager. Functional tests are configured to run against
48system packages found on RHEL/CentOS/Fedora.
45 49
46 50
47Configuration 51Configuration
diff --git a/bindep.txt b/bindep.txt
new file mode 100644
index 0000000..41fa95d
--- /dev/null
+++ b/bindep.txt
@@ -0,0 +1,5 @@
1# System distribution package dependencies
2# This is used by bindep: sudo [apt-get | yum] install $(bindep -b)
3
4python-ipalib
5python-ipaclient
diff --git a/playbooks/functional/post.yaml b/playbooks/functional/post.yaml
new file mode 100644
index 0000000..2e23a9d
--- /dev/null
+++ b/playbooks/functional/post.yaml
@@ -0,0 +1,33 @@
1- hosts: all
2 tasks:
3
4 - name: Make ipaserver-install log readable
5 file:
6 path: "/var/log/ipaserver-install.log"
7 mode: 0644
8 become: true
9 failed_when: false
10
11 - name: Collect ipaserver-install logs
12 synchronize:
13 dest: "{{ zuul.executor.log_root }}"
14 mode: pull
15 src: "/var/log/ipaserver-install.log"
16 verify_host: true
17 failed_when: false
18
19 - name: Collect novajoin-install logs
20 synchronize:
21 dest: "{{ zuul.executor.log_root }}"
22 mode: pull
23 src: "/var/log/novajoin-install.log"
24 verify_host: true
25 failed_when: false
26
27 - name: Collect novajoin logs
28 synchronize:
29 dest: "{{ zuul.executor.log_root }}"
30 mode: pull
31 src: "/var/log/novajoin"
32 verify_host: true
33 failed_when: false
diff --git a/playbooks/functional/pre.yaml b/playbooks/functional/pre.yaml
new file mode 100644
index 0000000..9cfa5df
--- /dev/null
+++ b/playbooks/functional/pre.yaml
@@ -0,0 +1,27 @@
1- hosts: all
2 tasks:
3
4 - name: Change hostname in /etc/hosts
5 replace:
6 path: /etc/hosts
7 regexp: '{{ ansible_hostname }}'
8 replace: '{{ ansible_hostname }}.example.test {{ ansible_hostname }}'
9 become: true
10
11 - name: Remove 127.0.1.1 from /etc/hosts
12 lineinfile:
13 path: /etc/hosts
14 regexp: '127\.0\.1\.1'
15 state: absent
16 become: true
17
18 - name: Remove controller from /etc/hosts
19 lineinfile:
20 path: /etc/hosts
21 regexp: 'controller'
22 state: absent
23 become: true
24
25 - name: Change hostname
26 command: 'hostnamectl set-hostname {{ ansible_hostname }}.example.test'
27 become: true
diff --git a/playbooks/functional/run.yaml b/playbooks/functional/run.yaml
new file mode 100644
index 0000000..5a814a2
--- /dev/null
+++ b/playbooks/functional/run.yaml
@@ -0,0 +1,12 @@
1- hosts: all
2 roles:
3 - run-devstack
4 - configure-freeipa
5 - role: bindep
6 bindep_profile: test
7 bindep_dir: "{{ zuul_work_dir }}"
8 - configure-novajoin
9 - download-centos
10 - test-setup
11 - ensure-tox
12 - tox
diff --git a/roles/configure-freeipa/tasks/main.yaml b/roles/configure-freeipa/tasks/main.yaml
new file mode 100644
index 0000000..d1a33c5
--- /dev/null
+++ b/roles/configure-freeipa/tasks/main.yaml
@@ -0,0 +1,59 @@
1- name: Find Paramiko ssh_gss.py
2 command: python -c "from paramiko import ssh_gss; print(ssh_gss.__file__.rstrip('c'))"
3 register: ssh_gss_file
4
5- name: Patch Paramiko (https://github.com/paramiko/paramiko/pull/1311)
6 replace:
7 path: '{{ ssh_gss_file.stdout }}'
8 regexp: 'GSS_EXCEPTIONS = \(gssapi.GSSException,\)'
9 replace: 'GSS_EXCEPTIONS = ()'
10 become: true
11
12- name: Patch Paramiko (https://github.com/paramiko/paramiko/pull/1311)
13 replace:
14 path: '{{ ssh_gss_file.stdout }}'
15 regexp: 'GSS_AUTH_AVAILABLE = True'
16 replace: 'GSS_AUTH_AVAILABLE = False'
17 become: true
18
19- name: Uninstall urllib3 to fix later conflict with python-urllib3 system package
20 pip:
21 name: urllib3
22 state: absent
23 become: true
24
25- name: Install FreeIPA
26 package:
27 name: ipa-server-dns
28 state: present
29 become: true
30
31- name: check if mod_nss is installed
32 package:
33 name: mod_nss
34 state: present
35 check_mode: true
36 ignore_errors: yes
37 register: mod_nss_check
38
39- name: Remove mod_ssl config which conflicts with FreeIPA
40 file:
41 path: /etc/httpd/conf.d/ssl.conf
42 state: absent
43 become: true
44 when: not mod_nss_check.changed
45
46- name: Stop unbound
47 systemd:
48 name: unbound
49 state: stopped
50 become: true
51
52- name: Configure FreeIPA
53 command: >
54 ipa-server-install -U -r EXAMPLE.TEST
55 -p password -a password --hostname {{ ansible_hostname }}.example.test
56 --ip-address={{ ansible_default_ipv4.address }} --setup-dns --no-reverse
57 --forwarder={{ unbound_primary_nameserver_v4 | default('1.1.1.1') }}
58 --forwarder={{ unbound_secondary_nameserver_v4 | default('8.8.8.8') }}
59 become: true
diff --git a/roles/configure-novajoin/tasks/main.yaml b/roles/configure-novajoin/tasks/main.yaml
new file mode 100644
index 0000000..7e7ae6b
--- /dev/null
+++ b/roles/configure-novajoin/tasks/main.yaml
@@ -0,0 +1,55 @@
1- name: Build novajoin
2 command: python setup.py build
3 args:
4 chdir: '{{ zuul.project.src_dir }}'
5
6- name: Install novajoin
7 command: python setup.py install
8 args:
9 chdir: '{{ zuul.project.src_dir }}'
10 become: true
11
12- name: Configure novajoin
13 shell: >
14 source /opt/stack/devstack/openrc admin admin &&
15 novajoin-install --debug --principal admin --password password
16 --user stack --nova-password secretservice
17 --keystone-auth-url http://127.0.0.1/identity
18 args:
19 executable: /bin/bash
20 become: true
21
22- name: Create novajoin log directory
23 file:
24 path: /var/log/novajoin
25 state: directory
26 owner: stack
27 become: true
28
29- name: Start novajoin-server
30 shell: nohup novajoin-server --debug </dev/null >/dev/null 2>&1 &
31 become: true
32 become_user: stack
33
34- name: Start novajoin-notify
35 shell: nohup novajoin-notify --debug </dev/null >/dev/null 2>&1 &
36 become: true
37 become_user: stack
38
39- name: Restart nova services
40 command: systemctl restart devstack@n-*
41 become: true
42
43- name: Set FreeIPA DNS in demo private-subnet
44 shell: >
45 source /opt/stack/devstack/openrc demo demo &&
46 openstack subnet set --no-dns-nameservers private-subnet &&
47 openstack subnet set --dns-nameserver {{ ansible_default_ipv4.address }} private-subnet
48 args:
49 executable: /bin/bash
50
51- name: Chmod /etc/novajoin/krb5.keytab for use by tests
52 file:
53 path: /etc/novajoin/krb5.keytab
54 mode: 0644
55 become: true
diff --git a/roles/download-centos/tasks/main.yaml b/roles/download-centos/tasks/main.yaml
new file mode 100644
index 0000000..7ea27e5
--- /dev/null
+++ b/roles/download-centos/tasks/main.yaml
@@ -0,0 +1,16 @@
1- name: Download image
2 get_url:
3 url: https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2.xz
4 dest: /tmp/centos-image.qcow2.xz
5
6- name: Extract image
7 command: unxz /tmp/centos-image.qcow2.xz
8
9- name: Add centos-image to Glance
10 shell: >
11 source /opt/stack/devstack/openrc admin admin &&
12 openstack image create --disk-format qcow2 --container-format bare
13 --public --file /tmp/centos-image.qcow2 centos-image
14 args:
15 executable: /bin/bash
16 become: true
diff --git a/tox.ini b/tox.ini
index 6c58567..94bb66a 100644
--- a/tox.ini
+++ b/tox.ini
@@ -69,7 +69,7 @@ envdir = {toxworkdir}/pep8
69commands = oslo-config-generator --config-file=files/novajoin-config-generator.conf 69commands = oslo-config-generator --config-file=files/novajoin-config-generator.conf
70 70
71[testenv:functional] 71[testenv:functional]
72basepython = python3 72sitepackages = true
73deps = -r{toxinidir}/test-requirements.txt 73deps = -r{toxinidir}/test-requirements.txt
74setenv = 74setenv =
75 OS_TEST_PATH={toxinidir}/novajoin/tests/functional 75 OS_TEST_PATH={toxinidir}/novajoin/tests/functional