More updates

This commit is contained in:
Liam Young
2020-02-24 10:34:48 +00:00
committed by Corey Bryant
parent 1724e482a1
commit 6347bb707f
6 changed files with 128 additions and 27 deletions

View File

@@ -18,7 +18,6 @@ import logging
import zaza.openstack.utilities.openstack as openstack_utils
CIRROS_IMAGE_NAME = "cirros"
CIRROS_ALT_IMAGE_NAME = "cirros_alt"
LTS_RELEASE = "bionic"
LTS_IMAGE_NAME = "bionic"
@@ -78,21 +77,6 @@ def add_cirros_image(glance_client=None, image_name=None):
image_name=image_name)
def add_cirros_alt_image(glance_client=None, image_name=None):
"""Add a cirros image to the current deployment.
:param glance: Authenticated glanceclient
:type glance: glanceclient.Client
:param image_name: Label for the image in glance
:type image_name: str
"""
image_name = image_name or CIRROS_ALT_IMAGE_NAME
image_url = openstack_utils.find_cirros_image(arch='x86_64')
add_image(image_url,
glance_client=glance_client,
image_name=image_name)
def add_lts_image(glance_client=None, image_name=None, release=None):
"""Add an Ubuntu LTS image to the current deployment.

View File

@@ -0,0 +1,15 @@
# Copyright 2018 Canonical Ltd.
#
# 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.
"""Collection of code for setting up and using tempest."""

View File

@@ -18,11 +18,15 @@ import os
import subprocess
import zaza.model
import zaza.utilities.deployment_env as deployment_env
import zaza.openstack.utilities.openstack as openstack_utils
import zaza.openstack.charm_tests.glance.setup as glance_setup
import zaza.openstack.charm_tests.tempest.templates.tempest_v3 as tempest_v3
import zaza.openstack.charm_tests.tempest.templates.accounts as accounts
import keystoneauth1
import novaclient
SETUP_ENV_VARS = [
'OS_TEST_GATEWAY',
'OS_TEST_CIDR_EXT',
@@ -31,6 +35,9 @@ SETUP_ENV_VARS = [
'OS_TEST_CIDR_PRIV',
'OS_TEST_SWIFT_IP',
]
TEMPEST_FLAVOR_NAME = 'm1.tempest'
TEMPEST_ALT_FLAVOR_NAME = 'm2.tempest'
TEMPEST_CIRROS_ALT_IMAGE_NAME = 'cirros_alt'
def get_app_access_ip(application_name):
@@ -53,6 +60,16 @@ def add_application_ips(ctxt):
ctxt['ncc'] = get_app_access_ip('nova-cloud-controller')
def add_nova_config(ctxt, keystone_session):
nova_client = openstack_utils.get_nova_session_client(
keystone_session)
for flavor in nova_client.flavors.list():
if flavor.name == TEMPEST_FLAVOR_NAME:
ctxt['flavor_ref'] = flavor.id
if flavor.name == TEMPEST_ALT_FLAVOR_NAME:
ctxt['flavor_ref_alt'] = flavor.id
def add_neutron_config(ctxt, keystone_session):
neutron_client = openstack_utils.get_neutron_session_client(
keystone_session)
@@ -72,7 +89,7 @@ def add_glance_config(ctxt, keystone_session):
image = openstack_utils.get_images_by_name(
glance_client, glance_setup.CIRROS_IMAGE_NAME)
image_alt = openstack_utils.get_images_by_name(
glance_client, glance_setup.CIRROS_ALT_IMAGE_NAME)
glance_client, TEMPEST_CIRROS_ALT_IMAGE_NAME)
if image:
ctxt['image_id'] = image[0].id
if image_alt:
@@ -89,8 +106,9 @@ def add_keystone_config(ctxt, keystone_session):
def add_environment_var_config(ctxt):
deploy_env = deployment_env.get_deployment_context()
for var in SETUP_ENV_VARS:
value = os.environ.get(var)
value = deploy_env.get(var)
if value:
ctxt[var.lower()] = value
else:
@@ -102,12 +120,19 @@ def add_environment_var_config(ctxt):
def add_access_protocol(ctxt):
overcloud_auth = openstack_utils.get_overcloud_auth()
ctxt['proto'] = urllib.parse.urlparse(overcloud_auth['OS_AUTH_URL']).scheme
ctxt['admin_username'] = overcloud_auth['OS_USERNAME']
ctxt['admin_password'] = overcloud_auth['OS_PASSWORD']
ctxt['admin_project_name'] = overcloud_auth['OS_PROJECT_NAME']
ctxt['admin_domain_name'] = overcloud_auth['OS_DOMAIN_NAME']
ctxt['default_credentials_domain_name'] = overcloud_auth[
'OS_PROJECT_DOMAIN_NAME']
def get_tempest_context():
keystone_session = openstack_utils.get_overcloud_keystone_session()
ctxt = {}
add_application_ips(ctxt)
add_nova_config(ctxt, keystone_session)
add_neutron_config(ctxt, keystone_session)
add_glance_config(ctxt, keystone_session)
add_keystone_config(ctxt, keystone_session)
@@ -136,7 +161,7 @@ def setup_tempest(tempest_template, accounts_template):
accounts_template)
def tempest_keystone_v3():
def render_tempest_config_keystone_v3():
setup_tempest(tempest_v3, accounts)
@@ -145,6 +170,54 @@ def clone_tempest():
subprocess.check_call(
[
'git',
'clone',
'clone',
'https://opendev.org/openstack/tempest',
'tempest'])
def add_cirros_alt_image():
"""Add a cirros image to the current deployment.
:param glance: Authenticated glanceclient
:type glance: glanceclient.Client
:param image_name: Label for the image in glance
:type image_name: str
"""
image_url = openstack_utils.find_cirros_image(arch='x86_64')
glance_setup.add_image(
image_url,
glance_client=None,
image_name=TEMPEST_CIRROS_ALT_IMAGE_NAME)
def add_tempest_flavors():
keystone_session = openstack_utils.get_overcloud_keystone_session()
nova_client = openstack_utils.get_nova_session_client(
keystone_session)
try:
nova_client.flavors.create(
name=TEMPEST_FLAVOR_NAME,
ram=256,
vcpus=1,
disk=1)
except novaclient.exceptions.Conflict:
pass
try:
nova_client.flavors.create(
name=TEMPEST_ALT_FLAVOR_NAME,
ram=512,
vcpus=1,
disk=1)
except novaclient.exceptions.Conflict:
pass
def add_tempest_roles():
keystone_session = openstack_utils.get_overcloud_keystone_session()
keystone_client = openstack_utils.get_keystone_session_client(
keystone_session)
for role_name in ['Member', 'ResellerAdmin']:
try:
keystone_client.roles.create('Member')
except keystoneauth1.exceptions.http.Conflict:
pass

View File

@@ -0,0 +1,15 @@
# Copyright 2018 Canonical Ltd.
#
# 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.
"""Collection of templates for tempest."""

View File

@@ -6,17 +6,17 @@ log_file = tempest.log
[auth]
test_accounts_file = accounts.yaml
default_credentials_domain_name = admin_domain
admin_username = admin
admin_project_name = admin
admin_password = openstack
admin_domain_name = admin_domain
default_credentials_domain_name = {default_credentials_domain_name}
admin_username = {admin_username}
admin_project_name = {admin_project_name}
admin_password = {admin_password}
admin_domain_name = {admin_domain_name}
[compute]
image_ref = {image_id}
image_ref_alt = {image_alt_id}
flavor_ref = 7
flavor_ref_alt = 8
flavor_ref = {flavor_ref}
flavor_ref_alt = {flavor_ref_alt}
min_compute_nodes = 3
# TODO: review this as its release specific

View File

@@ -0,0 +1,14 @@
import zaza.charm_lifecycle.test
import tempest.cmd.main
class TempestTest():
test_runner = zaza.charm_lifecycle.test.DIRECT
def run(self):
the_app = tempest.cmd.main.Main()
return the_app.run([
'run',
'--smoke',
'--config', 'tempest/etc/tempest.conf'])