Add RedHat 8.2 server instance

Change-Id: I6753b7cdccb45699f43ab246d7c849001158c643
Co-Authored-By: Eduardo Olivares <eolivare@redhat.com>
This commit is contained in:
Eduardo Olivares 2020-06-19 13:46:18 +02:00 committed by Federico Ressi
parent 531d16c9a5
commit 7896ec482c
7 changed files with 121 additions and 12 deletions

View File

@ -16,6 +16,7 @@ from __future__ import absolute_import
import json
import os
import inspect
import sys
import fixtures
from oslo_log import log
@ -97,12 +98,25 @@ def remove_fixture(obj, fixture_id=None, manager=None):
return manager.remove_fixture(obj, fixture_id=fixture_id)
def setup_fixture(obj, fixture_id=None, manager=None):
def setup_fixture(obj, fixture_id=None, manager=None, alternative=None):
'''Get registered fixture and setup it up'''
fixture = get_fixture(obj, fixture_id=fixture_id, manager=manager)
if alternative is None:
objs = [obj]
else:
objs = [obj, alternative]
with _exception.handle_multiple_exceptions(
handle_exception=handle_setup_error):
fixture.setUp()
errors = []
for _obj in objs:
fixture = get_fixture(_obj, fixture_id=fixture_id, manager=manager)
try:
fixture.setUp()
break
except testtools.MultipleExceptions:
errors.append(sys.exc_info())
else:
raise testtools.MultipleExceptions(*errors)
return fixture
@ -260,18 +274,18 @@ def fixture_property(*args, **kwargs):
return FixtureProperty(*args, **kwargs)
def required_fixture(obj):
def required_fixture(obj, **params):
'''Creates a property that gets fixture identified by given :param obj:
'''
return RequiredFixtureProperty(obj)
return RequiredFixtureProperty(obj, **params)
def required_setup_fixture(obj):
def required_setup_fixture(obj, **params):
'''Creates a property that sets up fixture identified by given :param obj:
'''
return RequiredSetupFixtureProperty(obj)
return RequiredSetupFixtureProperty(obj, **params)
def get_object_name(obj):
@ -430,8 +444,9 @@ class FixtureProperty(property):
class RequiredFixtureProperty(object):
def __init__(self, fixture):
def __init__(self, fixture, **params):
self.fixture = fixture
self.fixture_params = params
def __get__(self, instance, _):
if instance is None:
@ -440,7 +455,7 @@ class RequiredFixtureProperty(object):
return self.get_fixture(instance)
def get_fixture(self, _instance):
return get_fixture(self.fixture)
return get_fixture(self.fixture, **self.fixture_params)
@property
def __tobiko_required_fixtures__(self):
@ -450,7 +465,7 @@ class RequiredFixtureProperty(object):
class RequiredSetupFixtureProperty(RequiredFixtureProperty):
def get_fixture(self, _instance):
fixture = setup_fixture(self.fixture)
fixture = setup_fixture(self.fixture, **self.fixture_params)
if (hasattr(_instance, 'addCleanup') and
hasattr(_instance, 'getDetails')):
_instance.addCleanup(_detail.gather_details,

View File

@ -29,6 +29,7 @@ OPTIONS = [
GLANCE_IMAGE_NAMES = ['centos',
'cirros',
'rhel',
'ubuntu']

View File

@ -17,6 +17,7 @@ from __future__ import absolute_import
from tobiko.openstack.stacks import _centos
from tobiko.openstack.stacks import _cirros
from tobiko.openstack.stacks import _redhat
from tobiko.openstack.stacks import _l3ha
from tobiko.openstack.stacks import _neutron
from tobiko.openstack.stacks import _nova
@ -39,6 +40,10 @@ RebootCirrosServerOperation = _cirros.RebootCirrosServerOperation
EvacuableCirrosImageFixture = _cirros.EvacuableCirrosImageFixture
EvacuableServerStackFixture = _cirros.EvacuableServerStackFixture
RedHatFlavorStackFixture = _redhat.RedHatFlavorStackFixture
RhelImageFixture = _redhat.RhelImageFixture
RedHatServerStackFixture = _redhat.RedHatServerStackFixture
L3haNetworkStackFixture = _l3ha.L3haNetworkStackFixture
L3haServerStackFixture = _l3ha.L3haServerStackFixture
L3haUbuntuServerStackFixture = _l3ha.L3haUbuntuServerStackFixture

View File

@ -70,7 +70,7 @@ class KeyPairStackFixture(heat.HeatStackFixture):
class FlavorStackFixture(heat.HeatStackFixture):
template = _hot.heat_template_file('nova/flavor.yaml')
disk = None
disk: typing.Optional[int] = None
ephemeral = None
extra_specs = None
is_public = None

View File

@ -0,0 +1,59 @@
# Copyright 2020 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 _centos
CONF = config.CONF
RHEL_IMAGE_MAJOR_VERSION = '8.2'
RHEL_IMAGE_MINOR_VERSION = '501'
RHEL_IMAGE_URL = ('http://download.devel.redhat.com/brewroot/packages/'
f'rhel-guest-image/{RHEL_IMAGE_MAJOR_VERSION}/'
f'{RHEL_IMAGE_MINOR_VERSION}/images/'
f'rhel-guest-image-{RHEL_IMAGE_MAJOR_VERSION}-'
f'{RHEL_IMAGE_MINOR_VERSION}.x86_64.qcow2')
class RhelImageFixture(glance.URLGlanceImageFixture):
image_url = CONF.tobiko.rhel.image_url or RHEL_IMAGE_URL
image_name = CONF.tobiko.rhel.image_name
image_file = CONF.tobiko.rhel.image_file
disk_format = CONF.tobiko.rhel.disk_format or "qcow2"
container_format = CONF.tobiko.rhel.container_format or "bare"
username = CONF.tobiko.rhel.username or 'cloud-user'
password = CONF.tobiko.rhel.password
connection_timeout = CONF.tobiko.rhel.connection_timeout
class RedHatFlavorStackFixture(_centos.CentosFlavorStackFixture):
pass
class RedHatServerStackFixture(_centos.CentosServerStackFixture):
#: Glance image used to create a Nova server instance
# (alternative is given for cases the RHEL image is failed to be
# set up)
image_fixture = tobiko.required_setup_fixture(
RhelImageFixture, alternative=_centos.CentosImageFixture)
#: Flavor used to create a Nova server instance
flavor_stack = tobiko.required_setup_fixture(RedHatFlavorStackFixture)

View File

@ -27,7 +27,7 @@ from tobiko.tests.functional.openstack.stacks import test_cirros
@keystone.skip_unless_has_keystone_credentials()
class CentosServerStackTest(test_cirros.CirrosServerStackTest):
"""Tests connectivity to Nova instances via floating IPs"""
"""Test CentOS server instance"""
#: Stack of resources with a server attached to a floating IP
stack = tobiko.required_setup_fixture(stacks.CentosServerStackFixture)

View File

@ -0,0 +1,29 @@
# Copyright (c) 2020 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.openstack import keystone
from tobiko.openstack import stacks
from tobiko.tests.functional.openstack.stacks import test_centos
@keystone.skip_unless_has_keystone_credentials()
class RedHatServerStackTest(test_centos.CentosServerStackTest):
"""Test Red Hat server instance"""
#: Stack of resources with a server attached to a floating IP
stack = tobiko.required_setup_fixture(stacks.RedHatServerStackFixture)