CI: split netboot (cirros) and localboot (centos) jobs

Change-Id: I363a3f60efaec52a7e0bd12c9145205447354a6f
This commit is contained in:
Dmitry Tantsur 2018-07-06 16:56:32 +02:00
parent 99cae0ed55
commit 84976ec77d
6 changed files with 74 additions and 37 deletions

View File

@ -5,6 +5,7 @@
parent: devstack-minimal
pre-run: playbooks/integration/pre.yaml
post-run: playbooks/integration/post.yaml
run: playbooks/integration/run.yaml
irrelevant-files:
- ^.*\.rst$
- ^doc/.*$
@ -93,25 +94,37 @@
IRONIC_VM_SPECS_CPU: 2
IRONIC_VM_SPECS_DISK: 10
IRONIC_VM_SPECS_RAM: 1024
- job:
name: metalsmith-integration-glance
description: |
Integration job using Glance as image source.
parent: metalsmith-integration-base
pre-run: playbooks/integration/centos-image.yaml
run: playbooks/integration/run.yaml
vars:
centos_glance_initramds_image: test-centos-initramfs
centos_glance_kernel_image: test-centos-kernel
centos_glance_root_image: test-centos-partition
centos_glance_whole_disk_image: test-centos-wholedisk
centos_image_file: ~/CentOS-7-x86_64-GenericCloud.qcow2
centos_image_name: CentOS-7-x86_64-GenericCloud
centos_image_url: https://cloud.centos.org/centos/7/images/CentOS-7-x86_64-GenericCloud.qcow2.xz
centos_image_file: ~/CentOS-7-x86_64-GenericCloud.qcow2
centos_kernel_file: ~/CentOS-7-x86_64-GenericCloud.kernel
centos_initramfs_file: ~/CentOS-7-x86_64-GenericCloud.initramfs
centos_kernel_file: ~/CentOS-7-x86_64-GenericCloud.kernel
centos_partition_file: ~/CentOS-7-x86_64-GenericCloud-root.qcow2
centos_glance_whole_disk_image: test-centos-wholedisk
centos_glance_kernel_image: test-centos-kernel
centos_glance_initramds_image: test-centos-initramfs
centos_glance_root_image: test-centos-partition
metalsmith_root_size: 9
- job:
name: metalsmith-integration-glance-localboot-centos7
description: |
Integration job using Glance as image source and CentOS7 with local boot.
parent: metalsmith-integration-base
pre-run: playbooks/integration/centos-image.yaml
vars:
configure_instance_user: metalsmith
metalsmith_netboot: false
metalsmith_partition_image: test-centos-partition
metalsmith_whole_disk_image: test-centos-wholedisk
- job:
name: metalsmith-integration-glance-netboot-cirros
description: |
Integration job using Glance as image source and CirrOS with netboot.
parent: metalsmith-integration-base
vars:
metalsmith_netboot: true
- project:
templates:
@ -121,8 +134,10 @@
check:
jobs:
- openstack-tox-lower-constraints
- metalsmith-integration-glance
- metalsmith-integration-glance-localboot-centos7
- metalsmith-integration-glance-netboot-cirros
gate:
jobs:
- openstack-tox-lower-constraints
- metalsmith-integration-glance
- metalsmith-integration-glance-localboot-centos7
- metalsmith-integration-glance-netboot-cirros

View File

@ -64,9 +64,15 @@ class InstanceConfig(object):
:param hostname: instance hostname.
:return: a context manager yielding a directory with files
"""
# NOTE(dtantsur): CirrOS does not understand lists
if isinstance(self.ssh_keys, list):
ssh_keys = {str(i): v for i, v in enumerate(self.ssh_keys)}
else:
ssh_keys = self.ssh_keys
d = tempfile.mkdtemp()
try:
metadata = {'public_keys': self.ssh_keys,
metadata = {'public_keys': ssh_keys,
'uuid': node.uuid,
'name': node.name,
'hostname': hostname,

View File

@ -29,7 +29,7 @@ class TestInstanceConfig(testtools.TestCase):
self.node.name = 'node name'
def _check(self, config, expected_metadata, expected_userdata=None):
expected_m = {'public_keys': [],
expected_m = {'public_keys': {},
'uuid': '1234',
'name': 'node name',
'hostname': 'example.com',
@ -64,7 +64,11 @@ class TestInstanceConfig(testtools.TestCase):
def test_ssh_keys(self):
config = _config.InstanceConfig(ssh_keys=['abc', 'def'])
self._check(config, {'public_keys': ['abc', 'def']})
self._check(config, {'public_keys': {'0': 'abc', '1': 'def'}})
def test_ssh_keys_as_dict(self):
config = _config.InstanceConfig(ssh_keys={'default': 'abc'})
self._check(config, {'public_keys': {'default': 'abc'}})
def test_add_user(self):
config = _config.InstanceConfig()
@ -98,7 +102,7 @@ class TestInstanceConfig(testtools.TestCase):
def test_add_user_with_keys(self):
config = _config.InstanceConfig(ssh_keys=['abc', 'def'])
config.add_user('admin')
self._check(config, {'public_keys': ['abc', 'def']},
self._check(config, {'public_keys': {'0': 'abc', '1': 'def'}},
{'users': [{'name': 'admin',
'groups': ['wheel'],
'ssh_authorized_keys': ['abc', 'def']}]})

View File

@ -0,0 +1,18 @@
- name: Find Cirros UEC image
shell: |
openstack image list -f value -c ID -c Name \
| awk '/cirros.*uec/ { print $1; exit 0; }'
register: cirros_uec_image_result
failed_when: cirros_uec_image_result.stdout == ""
- name: Find Cirros disk image
shell: |
openstack image list -f value -c ID -c Name \
| awk '/cirros.*disk/ { print $1; exit 0; }'
register: cirros_disk_image_result
failed_when: cirros_disk_image_result.stdout == ""
- name: Set image facts
set_fact:
metalsmith_whole_disk_image: "{{ cirros_disk_image_result.stdout }}"
metalsmith_partition_image: "{{ cirros_uec_image_result.stdout }}"

View File

@ -23,12 +23,11 @@
metalsmith_instances:
- hostname: test
image: "{{ image }}"
netboot: "{{ netboot }}"
nics:
- "{{ nic }}"
root_size: 9
ssh_public_keys:
- "{{ ssh_key_file }}"
user_name: "{{ configure_instance_user | default('') }}"
- name: Get instance info via CLI
command: metalsmith --format=json show test
@ -50,7 +49,8 @@
- name: SSH into the instance
command: >
ssh -v -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ConnectTimeout=10
metalsmith@{{ instance_ip }} "cat /etc/hostname"
{{ configure_instance_user | default('cirros') }}@{{ instance_ip }}
"cat /etc/hostname"
register: ssh_result
until: ssh_result | succeeded
retries: 30

View File

@ -5,23 +5,17 @@
tasks:
- include: ssh-key.yaml
- name: Test partition image with netboot
include: exercise.yaml
vars:
image: "{{ centos_glance_root_image }}"
precreate_port: false
netboot: true
- include: cirros-image.yaml
when: metalsmith_whole_disk_image is not defined
- name: Test whole-disk image with local boot
- name: Test a partition image
include: exercise.yaml
vars:
image: "{{ centos_glance_whole_disk_image }}"
image: "{{ metalsmith_partition_image }}"
precreate_port: false
netboot: false
- name: Test partition image with local boot and port
- name: Test a whole-disk image
include: exercise.yaml
vars:
image: "{{ centos_glance_root_image }}"
precreate_port: true
netboot: false
image: "{{ metalsmith_whole_disk_image }}"
precreate_port: false