Browse Source

Add functional tests to CI

Change-Id: I74f74e57f8a908f57d6b63d381b7e3af3d08e711
tags/1.0.22
Grzegorz Grasza 7 months ago
parent
commit
47ce2f7136

+ 41
- 0
.zuul.yaml View File

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

+ 8
- 4
README.rst View File

@@ -38,10 +38,14 @@ Package Requirements
38 38
 Beyond those packages normally installed by Openstack, these are also
39 39
 required::
40 40
 
41
-    {free}ipa-python
42
-
43
-These may be pip-installable but as of March 2017 it has only been
44
-extensively tested with real packages installed on RHEL/CentOS/Fedora.
41
+  python-ipalib
42
+  python-ipaclient
43
+
44
+These may be pip-installable but still require other system packages
45
+like `krb5-devel` to be present and may not be compatible with your
46
+FreeIPA installation, so it is best to install them with your system
47
+package manager. Functional tests are configured to run against
48
+system packages found on RHEL/CentOS/Fedora.
45 49
 
46 50
 
47 51
 Configuration

+ 5
- 0
bindep.txt View File

@@ -0,0 +1,5 @@
1
+# System distribution package dependencies
2
+# This is used by bindep: sudo [apt-get | yum] install $(bindep -b)
3
+
4
+python-ipalib
5
+python-ipaclient

+ 33
- 0
playbooks/functional/post.yaml View File

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

+ 27
- 0
playbooks/functional/pre.yaml View File

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

+ 12
- 0
playbooks/functional/run.yaml View File

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

+ 59
- 0
roles/configure-freeipa/tasks/main.yaml View File

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

+ 55
- 0
roles/configure-novajoin/tasks/main.yaml View File

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

+ 16
- 0
roles/download-centos/tasks/main.yaml View File

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

+ 1
- 1
tox.ini View File

@@ -69,7 +69,7 @@ envdir = {toxworkdir}/pep8
69 69
 commands = oslo-config-generator --config-file=files/novajoin-config-generator.conf
70 70
 
71 71
 [testenv:functional]
72
-basepython = python3
72
+sitepackages = true
73 73
 deps = -r{toxinidir}/test-requirements.txt
74 74
 setenv =
75 75
     OS_TEST_PATH={toxinidir}/novajoin/tests/functional

Loading…
Cancel
Save