Add CentOS image and flavor fixtures

Change-Id: I3f1f86cb9b35c2be02703960e502140645a36da8
This commit is contained in:
Federico Ressi 2019-07-18 14:55:42 +02:00
parent 1b11ec7a04
commit ff2d87ce5c
7 changed files with 105 additions and 7 deletions

View File

@ -18,9 +18,6 @@ import itertools
from oslo_config import cfg
CIRROS_IMAGE_URL = \
'http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img'
GROUP_NAME = 'glance'
OPTIONS = [
cfg.StrOpt('image_dir',
@ -30,7 +27,8 @@ OPTIONS = [
]
GLANCE_IMAGE_NAMES = ['cirros',
GLANCE_IMAGE_NAMES = ['centos',
'cirros',
'ubuntu']

View File

@ -15,12 +15,17 @@
# under the License.
from __future__ import absolute_import
from tobiko.openstack.stacks import _centos
from tobiko.openstack.stacks import _cirros
from tobiko.openstack.stacks import _l3ha
from tobiko.openstack.stacks import _neutron
from tobiko.openstack.stacks import _nova
from tobiko.openstack.stacks import _ubuntu
CentosFlavorStackFixture = _centos.CentosFlavorStackFixture
CentosImageFixture = _centos.CentosImageFixture
CentosServerStackFixture = _centos.CentosServerStackFixture
CirrosFlavorStackFixture = _cirros.CirrosFlavorStackFixture
CirrosImageFixture = _cirros.CirrosImageFixture
CirrosServerStackFixture = _cirros.CirrosServerStackFixture

View File

@ -0,0 +1,55 @@
# Copyright 2019 Red Hat
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from __future__ import absolute_import
import tobiko
from tobiko import config
from tobiko.openstack import glance
from tobiko.openstack.stacks import _nova
CONF = config.CONF
if glance.has_lzma():
CENTOS_IMAGE_URL = (
'http://cloud.centos.org/centos/7/images/'
'CentOS-7-x86_64-GenericCloud.qcow2.xz')
else:
CENTOS_IMAGE_URL = (
'http://cloud.centos.org/centos/7/images/'
'CentOS-7-x86_64-GenericCloud.qcow2c')
class CentosImageFixture(glance.URLGlanceImageFixture):
image_url = CONF.tobiko.centos.image_url or CENTOS_IMAGE_URL
image_name = CONF.tobiko.centos.image_name
image_file = CONF.tobiko.centos.image_file
disk_format = CONF.tobiko.centos.disk_format or "qcow2"
container_format = CONF.tobiko.centos.container_format or "bare"
username = CONF.tobiko.centos.username or 'centos'
password = CONF.tobiko.centos.password
class CentosFlavorStackFixture(_nova.FlavorStackFixture):
ram = 512
class CentosServerStackFixture(_nova.ServerStackFixture):
#: Glance image used to create a Nova server instance
image_fixture = tobiko.required_setup_fixture(CentosImageFixture)
#: Flavor used to create a Nova server instance
flavor_stack = tobiko.required_setup_fixture(CentosFlavorStackFixture)

View File

@ -45,7 +45,7 @@ class CirrosServerStackFixture(_nova.ServerStackFixture):
#: Glance image used to create a Nova server instance
image_fixture = tobiko.required_setup_fixture(CirrosImageFixture)
#: Glance image used to create a Nova server instance
#: Flavor used to create a Nova server instance
flavor_stack = tobiko.required_setup_fixture(CirrosFlavorStackFixture)

View File

@ -26,7 +26,6 @@ UBUNTU_IMAGE_URL = \
class UbuntuImageFixture(glance.URLGlanceImageFixture):
image_url = CONF.tobiko.ubuntu.image_url or UBUNTU_IMAGE_URL
image_name = CONF.tobiko.ubuntu.image_name
image_file = CONF.tobiko.ubuntu.image_file
@ -45,5 +44,5 @@ class UbuntuServerStackFixture(_nova.ServerStackFixture):
#: Glance image used to create a Nova server instance
image_fixture = tobiko.required_setup_fixture(UbuntuImageFixture)
#: Glance image used to create a Nova server instance
#: Flavor used to create a Nova server instance
flavor_stack = tobiko.required_setup_fixture(UbuntuFlavorStackFixture)

View File

@ -271,16 +271,21 @@ class ShellProcessFixture(tobiko.SharedFixture):
self.check_stdin_is_opened()
sent_bytes = self.stdin.write(data)
if sent_bytes:
LOG.debug("Written %d bytes to STDIN (%s)", sent_bytes,
self.command)
return data[sent_bytes:] or None
else:
LOG.debug("%r closed by peer on %r", self.stdin, self)
self.stdin.close()
return data
def _read_from_stdout(self, buffer_size=None):
"""Read data from remote stream"""
# Read data from remote stream
chunk = self.stdout.read(buffer_size)
if chunk:
LOG.debug("Read %d bytes from STDOUT (%s)", len(chunk),
self.command)
return chunk
else:
LOG.debug("%r closed by peer on %r", self.stdout, self)
@ -292,6 +297,8 @@ class ShellProcessFixture(tobiko.SharedFixture):
# Read data from remote stream
chunk = self.stderr.read(buffer_size)
if chunk:
LOG.debug("Read %d bytes from STDERR (%s)", len(chunk),
self.command)
return chunk
else:
LOG.debug("%r closed by peer on %r", self.stderr, self)

View File

@ -0,0 +1,34 @@
# Copyright (c) 2019 Red Hat, Inc.
#
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from __future__ import absolute_import
import tobiko
from tobiko.shell import sh
from tobiko.openstack import stacks
from tobiko.tests.functional.openstack.stacks import test_cirros
class CentosServerStackTest(test_cirros.CirrosServerStackTest):
"""Tests connectivity to Nova instances via floating IPs"""
#: Stack of resources with a server attached to a floating IP
stack = tobiko.required_setup_fixture(stacks.CentosServerStackFixture)
def test_python(self):
python_version = sh.execute(['python', '--version'],
ssh_client=self.stack.ssh_client).stderr
self.assertTrue(python_version.startswith('Python 2.7'),
python_version)