Browse Source

Add CI job for ironic

Adds four new CI jobs for testing centos/ubuntu binary/source deploys
with ironic enabled. These are run only when there are changes to the
ironic role.

Performs some simple testing by creating a node using the fake-hardware
hardware type and creating a server.

Change-Id: Ie669e57ce2af53257b4ca05f45193cb73f48827a
Depends-On: https://review.opendev.org/664011
changes/29/568829/68
Mark Goddard 1 year ago
parent
commit
845040ad3f

+ 8
- 0
tests/get_logs.sh View File

@@ -7,6 +7,8 @@ copy_logs() {
7 7
 
8 8
     cp -rnL /var/lib/docker/volumes/kolla_logs/_data/* ${LOG_DIR}/kolla/
9 9
     cp -rnL /etc/kolla/* ${LOG_DIR}/kolla_configs/
10
+    # Don't save the IPA images.
11
+    rm ${LOG_DIR}/kolla_configs/config/ironic/ironic-agent.{kernel,initramfs}
10 12
     cp -rvnL /var/log/* ${LOG_DIR}/system_logs/
11 13
 
12 14
 
@@ -62,6 +64,12 @@ copy_logs() {
62 64
         docker exec haproxy bash -c 'echo show stat | socat stdio /var/lib/kolla/haproxy/haproxy.sock' > ${LOG_DIR}/kolla/haproxy/stats.txt
63 65
     fi
64 66
 
67
+    # FIXME: remove
68
+    if [[ $(docker ps -a --filter name=ironic_inspector --format "{{.Names}}") ]]; then
69
+        mkdir -p ${LOG_DIR}/kolla/ironic-inspector
70
+        ls -lR /var/lib/docker/volumes/ironic_inspector_dhcp_hosts > ${LOG_DIR}/kolla/ironic-inspector/var-lib-ls.txt
71
+    fi
72
+
65 73
     for container in $(docker ps -a --format "{{.Names}}"); do
66 74
         docker logs --tail all ${container} &> ${LOG_DIR}/docker_logs/${container}.txt
67 75
     done

+ 29
- 1
tests/run.yml View File

@@ -98,8 +98,29 @@
98 98
         - src: "tests/templates/bifrost-dib-overrides.j2"
99 99
           dest: /etc/kolla/config/bifrost/dib.yml
100 100
           when: scenario == "bifrost"
101
+        - src: "tests/templates/ironic-overrides.j2"
102
+          dest: /etc/kolla/config/ironic.conf
103
+          when: "{{ scenario == 'ironic' }}"
101 104
       when: item.when | default(true)
102 105
 
106
+    - block:
107
+        - name: ensure ironic config directory exists
108
+          file:
109
+            path: /etc/kolla/config/ironic
110
+            state: directory
111
+            mode: 0777
112
+
113
+        - name: download Ironic Python Agent (IPA) images
114
+          get_url:
115
+            url: "https://tarballs.openstack.org/ironic-python-agent/tinyipa/files/{{ item.src }}"
116
+            dest: "/etc/kolla/config/ironic/{{ item.dest }}"
117
+          with_items:
118
+            - src: "tinyipa-{{ zuul.branch | replace('/', '-') }}.gz"
119
+              dest: ironic-agent.initramfs
120
+            - src: "tinyipa-{{ zuul.branch | replace('/', '-') }}.vmlinuz"
121
+              dest: ironic-agent.kernel
122
+      when: scenario == "ironic"
123
+
103 124
     - name: install kolla-ansible requirements
104 125
       pip:
105 126
         requirements: "{{ kolla_ansible_src_dir }}/requirements.txt"
@@ -173,7 +194,7 @@
173 194
             chdir: "{{ kolla_ansible_src_dir }}"
174 195
           environment:
175 196
             ACTION: "{{ scenario }}"
176
-          when: scenario not in ['scenario_nfv']
197
+          when: scenario not in ['ironic', 'scenario_nfv']
177 198
 
178 199
         - name: Run test-scenario-nfv.sh script
179 200
           script:
@@ -182,6 +203,13 @@
182 203
             chdir: "{{ kolla_ansible_src_dir }}"
183 204
           when: scenario == "scenario_nfv"
184 205
 
206
+        - name: Run test-ironic.sh script
207
+          script:
208
+            cmd: test-ironic.sh
209
+            executable: /bin/bash
210
+            chdir: "{{ kolla_ansible_src_dir }}"
211
+          when: scenario == "ironic"
212
+
185 213
         - name: Run reconfigure.sh script
186 214
           script:
187 215
             cmd: reconfigure.sh

+ 5
- 0
tests/templates/globals-default.j2 View File

@@ -67,3 +67,8 @@ enable_mistral: "yes"
67 67
 enable_redis: "yes"
68 68
 enable_barbican: "yes"
69 69
 {% endif %}
70
+
71
+{% if scenario == "ironic" %}
72
+enable_ironic: "yes"
73
+ironic_dnsmasq_dhcp_range: "10.42.0.2,10.42.0.254"
74
+{% endif %}

+ 19
- 0
tests/templates/ironic-overrides.j2 View File

@@ -0,0 +1,19 @@
1
+[DEFAULT]
2
+# Enable all fake hardware types and interfaces.
3
+enabled_hardware_types = fake-hardware
4
+enabled_boot_interfaces = fake
5
+enabled_console_interfaces = ipmitool-socat,no-console
6
+enabled_deploy_interfaces = fake
7
+enabled_inspect_interfaces = inspector,no-inspect
8
+enabled_management_interfaces = fake
9
+enabled_network_interfaces = noop,flat,neutron
10
+default_network_interface = neutron
11
+enabled_power_interfaces = fake
12
+enabled_raid_interfaces = agent,no-raid
13
+default_raid_interface = no-raid
14
+enabled_rescue_interfaces = fake
15
+enabled_vendor_interfaces = no-vendor
16
+
17
+[neutron]
18
+cleaning_network = public1
19
+provisioning_network = public1

+ 138
- 0
tests/test-ironic.sh View File

@@ -0,0 +1,138 @@
1
+#!/bin/bash
2
+
3
+set -o xtrace
4
+set -o errexit
5
+set -o pipefail
6
+
7
+# Enable unbuffered output for Ansible in Jenkins.
8
+export PYTHONUNBUFFERED=1
9
+
10
+# Adapted from the function of the same name in the ironic devstack plugin.
11
+function wait_for_placement_resources {
12
+    # After nodes have been enrolled, we need to wait for both ironic and
13
+    # nova's periodic tasks to populate the resource tracker with available
14
+    # nodes and resources. Wait up to 2 minutes for a given resource before
15
+    # timing out.
16
+    local expected_count=1
17
+    local resource_class="RC0"
18
+
19
+    curl -L -o jq https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64
20
+    chmod +x jq
21
+
22
+    # TODO(mgoddard): switch to Placement OSC plugin, once it exists
23
+    local token
24
+    token=$(openstack token issue -f value -c id)
25
+    local endpoint
26
+    endpoint=$(openstack endpoint list --service placement --interface public -f value -c URL)
27
+    if [[ -z $endpoint ]]; then
28
+        echo "Cannot find Placement API endpoint"
29
+        return 1
30
+    fi
31
+
32
+    local i
33
+    local count
34
+    echo "Waiting 2 minutes for Nova resource tracker to pick up $expected_count nodes"
35
+    for i in $(seq 1 120); do
36
+        # Fetch provider UUIDs from Placement
37
+        local providers
38
+        providers=$(curl -sH "X-Auth-Token: $token" $endpoint/resource_providers \
39
+            | ./jq -r '.resource_providers[].uuid')
40
+
41
+        local p
42
+        # Total count of the resource class, has to be equal to nodes count
43
+        count=0
44
+        for p in $providers; do
45
+            local amount
46
+            # A resource class inventory record looks something like
47
+            # {"max_unit": 1, "min_unit": 1, "step_size": 1, "reserved": 0, "total": 1, "allocation_ratio": 1}
48
+            # Subtract reserved from total (defaulting both to 0)
49
+            amount=$(curl -sH "X-Auth-Token: $token" $endpoint/resource_providers/$p/inventories \
50
+                | ./jq ".inventories.CUSTOM_$resource_class as \$cls
51
+                    | (\$cls.total // 0) - (\$cls.reserved // 0)")
52
+            if [ $amount -gt 0 ]; then
53
+                count=$(( count + $amount ))
54
+            fi
55
+        done
56
+
57
+        if [ $count -ge $expected_count ]; then
58
+            return 0
59
+        fi
60
+        sleep 1
61
+    done
62
+
63
+    echo "Timed out waiting for Nova to track $expected_count nodes"
64
+    return 1
65
+}
66
+
67
+function create_resources {
68
+    # Create a bare metal node and port.
69
+    openstack baremetal node create \
70
+        --name node-0 \
71
+        --driver fake-hardware \
72
+        --network-interface noop \
73
+        --property cpu_arch=x86_64 \
74
+        --resource-class rc0
75
+    node_uuid=$(openstack baremetal node show node-0 -f value -c uuid)
76
+    openstack baremetal port create \
77
+        00:11:22:33:44:55 \
78
+        --node $node_uuid
79
+    openstack baremetal node power off node-0
80
+    openstack baremetal node manage node-0 --wait
81
+    openstack baremetal node provide node-0 --wait
82
+
83
+    # Create a bare metal flavor in nova.
84
+    openstack flavor create \
85
+        baremetal \
86
+        --vcpus 1 \
87
+        --ram 1024 \
88
+        --disk 10 \
89
+        --property resources:CUSTOM_RC0=1 \
90
+        --property resources:VCPU=0 \
91
+        --property resources:MEMORY_MB=0 \
92
+        --property resources:DISK_GB=0 \
93
+        --public
94
+}
95
+
96
+function test_ironic_logged {
97
+    # Assumes init-runonce has been executed.
98
+    . /etc/kolla/admin-openrc.sh
99
+    . ~/ironic-venv/bin/activate
100
+
101
+    # Smoke test ironic API.
102
+    if ! openstack baremetal driver list | grep fake-hardware; then
103
+        echo "No active conductors with fake-hardware driver"
104
+        exit 1
105
+    fi
106
+    openstack baremetal node list
107
+    openstack baremetal port list
108
+
109
+    create_resources
110
+    wait_for_placement_resources
111
+
112
+    echo "TESTING: Server creation"
113
+    openstack server create --wait --image cirros --flavor baremetal --key-name mykey --network demo-net kolla_boot_test
114
+    openstack --debug server list
115
+    # If the status is not ACTIVE, print info and exit 1
116
+    if [[ $(openstack server show kolla_boot_test -f value -c status) != "ACTIVE" ]]; then
117
+        echo "FAILED: Instance is not active"
118
+        openstack --debug server show kolla_boot_test
119
+        return 1
120
+    fi
121
+    echo "SUCCESS: Server creation"
122
+
123
+    echo "TESTING: Server deletion"
124
+    openstack server delete --wait kolla_boot_test
125
+    echo "SUCCESS: Server deletion"
126
+}
127
+
128
+function test_ironic {
129
+    echo "Testing Ironic"
130
+    if ! test_ironic_logged > /tmp/logs/ansible/test-ironic 2>&1; then
131
+        echo "Testing Ironic failed. See ansible/test-ironic for details"
132
+        return 1
133
+    else
134
+        echo "Successfully tested Ironic. See ansible/test-ironic for details"
135
+    fi
136
+}
137
+
138
+test_ironic

+ 0
- 1
tests/test-openstack.sh View File

@@ -6,7 +6,6 @@ set -o errexit
6 6
 # Enable unbuffered output for Ansible in Jenkins.
7 7
 export PYTHONUNBUFFERED=1
8 8
 
9
-
10 9
 function test_openstack_logged {
11 10
     . /etc/kolla/admin-openrc.sh
12 11
 

+ 10
- 1
tools/setup_gate.sh View File

@@ -42,6 +42,9 @@ EOF
42 42
     if [[ $ACTION == "scenario_nfv" ]]; then
43 43
         GATE_IMAGES+=",tacker,mistral,redis,barbican"
44 44
     fi
45
+    if [[ $ACTION == "ironic" ]]; then
46
+        GATE_IMAGES+=",dnsmasq,ironic,iscsid"
47
+    fi
45 48
 
46 49
     cat <<EOF | sudo tee /etc/kolla/kolla-build.conf
47 50
 [DEFAULT]
@@ -93,6 +96,13 @@ function setup_ansible {
93 96
     if [[ $ACTION == "zun" ]]; then
94 97
         sudo -H pip install -U "python-zunclient"
95 98
     fi
99
+    if [[ $ACTION == ironic ]]; then
100
+        # NOTE(mgoddard): Installing python-ironicclient to site-packages fails
101
+        # due to pip 10 distutils issue with ipaddress package.
102
+        virtualenv ~/ironic-venv
103
+        ~/ironic-venv/bin/pip install -U pip
104
+        ~/ironic-venv/bin/pip install python-openstackclient python-ironicclient
105
+    fi
96 106
     detect_distro
97 107
 
98 108
     sudo mkdir /etc/ansible
@@ -121,7 +131,6 @@ function prepare_images {
121 131
     popd
122 132
 }
123 133
 
124
-
125 134
 setup_ansible
126 135
 setup_config
127 136
 setup_node

+ 10
- 0
zuul.d/base.yaml View File

@@ -37,3 +37,13 @@
37 37
       scenario: bifrost
38 38
       install_type: source
39 39
       enable_core_openstack: no
40
+
41
+- job:
42
+    name: kolla-ansible-ironic-base
43
+    parent: kolla-ansible-base
44
+    voting: false
45
+    files:
46
+      - ^ansible\/roles\/ironic\/.*
47
+      - ^tests/test-ironic.sh
48
+    vars:
49
+      scenario: ironic

+ 34
- 0
zuul.d/jobs.yaml View File

@@ -205,3 +205,37 @@
205 205
       base_distro: centos
206 206
       install_type: source
207 207
       scenario: scenario_nfv
208
+
209
+- job:
210
+    name: kolla-ansible-centos-source-ironic
211
+    parent: kolla-ansible-ironic-base
212
+    nodeset: kolla-ansible-centos
213
+    vars:
214
+      base_distro: centos
215
+      install_type: source
216
+
217
+- job:
218
+    name: kolla-ansible-centos-binary-ironic
219
+    parent: kolla-ansible-ironic-base
220
+    nodeset: kolla-ansible-centos
221
+    vars:
222
+      base_distro: centos
223
+      install_type: binary
224
+
225
+- job:
226
+    name: kolla-ansible-ubuntu-source-ironic
227
+    parent: kolla-ansible-ironic-base
228
+    nodeset: kolla-ansible-bionic
229
+    vars:
230
+      base_distro: ubuntu
231
+      install_type: source
232
+
233
+# Not running this job because the ironic-neutron-agent image is not available
234
+# for Ubuntu binary.
235
+- job:
236
+    name: kolla-ansible-ubuntu-binary-ironic
237
+    parent: kolla-ansible-ironic-base
238
+    nodeset: kolla-ansible-bionic
239
+    vars:
240
+      base_distro: ubuntu
241
+      install_type: binary

+ 6
- 0
zuul.d/project.yaml View File

@@ -27,6 +27,9 @@
27 27
             files: ^ansible\/roles\/(zun|kuryr)\/.*
28 28
         - kolla-ansible-centos-source-scenario-nfv:
29 29
             files: ^ansible\/roles\/(barbican|heat|mistral|redis|tacker)\/.*
30
+        - kolla-ansible-centos-source-ironic
31
+        - kolla-ansible-centos-binary-ironic
32
+        - kolla-ansible-ubuntu-source-ironic
30 33
         - kolla-ansible-centos-source-upgrade
31 34
         - kolla-ansible-ubuntu-source-upgrade
32 35
         - kolla-ansible-centos-source-upgrade-ceph
@@ -46,6 +49,9 @@
46 49
         - kolla-ansible-centos-source-scenario-nfv
47 50
         - kolla-ansible-ubuntu-source-cinder-lvm
48 51
         - kolla-ansible-centos-source-cinder-lvm
52
+        - kolla-ansible-centos-source-ironic
53
+        - kolla-ansible-centos-binary-ironic
54
+        - kolla-ansible-ubuntu-source-ironic
49 55
         - kolla-ansible-centos-source-upgrade
50 56
         - kolla-ansible-ubuntu-source-upgrade
51 57
         - kolla-ansible-centos-source-upgrade-ceph

Loading…
Cancel
Save