Rationalize examples and functional extra config loading

This whole thing is a mess. examples is doing the right thing and
using get_extra_config, but its docs are wrong. functional is
reading config from a non-standard place but is the place that
the examples docs incorrect say it should be read from.

Update both places to read from the RIGHT location and update
the docs as well. Make examples support setting a key to use
and then set that key in tox so that we can just use the
functional settings for both.

Also, fix the clustering functional test so that it consumes
the IMAGE_NAME discovered in functional.base.

Change-Id: Ia9f150bbdd3825cb3e0d4282af3ca8f23dc1d888
This commit is contained in:
Monty Taylor 2020-03-11 14:03:59 -05:00
parent 64c58edd8c
commit 54a76faf72
5 changed files with 30 additions and 28 deletions

View File

@ -6,10 +6,6 @@ clouds:
username: demo
password: secrete
project_name: demo
example:
image_name: fedora-20.x86_64
flavor_name: m1.small
network_name: private
rackspace:
cloud: rackspace
auth:
@ -17,3 +13,7 @@ clouds:
password: joes-password
project_name: 123123
region_name: IAD
example:
image_name: fedora-20.x86_64
flavor_name: m1.small
network_name: private

View File

@ -31,6 +31,7 @@ openstack.enable_logging(True, stream=sys.stdout)
#: will determine where the examples will be run and what resource defaults
#: will be used to run the examples.
TEST_CLOUD = os.getenv('OS_TEST_CLOUD', 'devstack-admin')
EXAMPLE_CONFIG_KEY = os.getenv('OPENSTACKSDK_EXAMPLE_CONFIG_KEY', 'example')
config = loader.OpenStackConfig()
cloud = openstack.connect(cloud=TEST_CLOUD)
@ -44,7 +45,8 @@ class Opts(object):
def _get_resource_value(resource_key, default):
return config.get_extra_config('example').get(resource_key, default)
return config.get_extra_config(
EXAMPLE_CONFIG_KEY).get(resource_key, default)
SERVER_NAME = 'openstacksdk-example'

View File

@ -22,15 +22,14 @@ from openstack.tests import base
#: file, typically in $HOME/.config/openstack/clouds.yaml. That configuration
#: will determine where the functional tests will be run and what resource
#: defaults will be used to run the functional tests.
TEST_CONFIG = openstack.config.OpenStackConfig()
TEST_CLOUD_NAME = os.getenv('OS_CLOUD', 'devstack-admin')
TEST_CLOUD_REGION = openstack.config.get_cloud_region(cloud=TEST_CLOUD_NAME)
def _get_resource_value(resource_key, default):
try:
return TEST_CLOUD_REGION.config['functional'][resource_key]
except KeyError:
return default
return TEST_CONFIG.get_extra_config(
'functional').get(resource_key, default)
def _disable_keep_alive(conn):

View File

@ -116,7 +116,7 @@ class TestClustering(base.BaseFunctionalTest):
spec = {
"properties": {
"flavor": "m1.tiny",
"image": "cirros-0.4.0-x86_64-disk",
"image": base.IMAGE_NAME,
"networks": [
{
"network": "private"
@ -146,7 +146,7 @@ class TestClustering(base.BaseFunctionalTest):
spec = {
"properties": {
"flavor": "m1.tiny",
"image": "cirros-0.4.0-x86_64-disk",
"image": base.IMAGE_NAME,
"networks": [
{
"network": "private"
@ -190,7 +190,7 @@ class TestClustering(base.BaseFunctionalTest):
spec = {
"properties": {
"flavor": "m1.tiny",
"image": "cirros-0.4.0-x86_64-disk",
"image": base.IMAGE_NAME,
"networks": [
{
"network": "private"
@ -233,7 +233,7 @@ class TestClustering(base.BaseFunctionalTest):
spec = {
"properties": {
"flavor": "m1.tiny",
"image": "cirros-0.4.0-x86_64-disk",
"image": base.IMAGE_NAME,
"networks": [
{
"network": "private"
@ -319,7 +319,7 @@ class TestClustering(base.BaseFunctionalTest):
spec = {
"properties": {
"flavor": "m1.tiny",
"image": "cirros-0.4.0-x86_64-disk",
"image": base.IMAGE_NAME,
"networks": [
{
"network": "private"
@ -393,7 +393,7 @@ class TestClustering(base.BaseFunctionalTest):
spec = {
"properties": {
"flavor": "m1.tiny",
"image": "cirros-0.4.0-x86_64-disk",
"image": base.IMAGE_NAME,
"networks": [
{
"network": "private"
@ -475,7 +475,7 @@ class TestClustering(base.BaseFunctionalTest):
spec = {
"properties": {
"flavor": "m1.tiny",
"image": "cirros-0.4.0-x86_64-disk",
"image": base.IMAGE_NAME,
"networks": [
{
"network": "private"
@ -568,7 +568,7 @@ class TestClustering(base.BaseFunctionalTest):
spec = {
"properties": {
"flavor": "m1.tiny",
"image": "cirros-0.4.0-x86_64-disk",
"image": base.IMAGE_NAME,
"networks": [
{
"network": "private"
@ -657,7 +657,7 @@ class TestClustering(base.BaseFunctionalTest):
spec = {
"properties": {
"flavor": "m1.tiny",
"image": "cirros-0.4.0-x86_64-disk",
"image": base.IMAGE_NAME,
"networks": [
{
"network": "private"
@ -714,7 +714,7 @@ class TestClustering(base.BaseFunctionalTest):
spec = {
"properties": {
"flavor": "m1.tiny",
"image": "cirros-0.4.0-x86_64-disk",
"image": base.IMAGE_NAME,
"networks": [
{
"network": "private"
@ -776,7 +776,7 @@ class TestClustering(base.BaseFunctionalTest):
spec = {
"properties": {
"flavor": "m1.tiny",
"image": "cirros-0.4.0-x86_64-disk",
"image": base.IMAGE_NAME,
"networks": [
{
"network": "private"
@ -864,7 +864,7 @@ class TestClustering(base.BaseFunctionalTest):
spec = {
"properties": {
"flavor": "m1.tiny",
"image": "cirros-0.4.0-x86_64-disk",
"image": base.IMAGE_NAME,
"networks": [
{
"network": "private"
@ -915,7 +915,7 @@ class TestClustering(base.BaseFunctionalTest):
spec = {
"properties": {
"flavor": "m1.tiny",
"image": "cirros-0.4.0-x86_64-disk",
"image": base.IMAGE_NAME,
"networks": [
{
"network": "private"
@ -1019,7 +1019,7 @@ class TestClustering(base.BaseFunctionalTest):
spec = {
"properties": {
"flavor": "m1.tiny",
"image": "cirros-0.4.0-x86_64-disk",
"image": base.IMAGE_NAME,
"networks": [
{
"network": "private"
@ -1057,7 +1057,7 @@ class TestClustering(base.BaseFunctionalTest):
spec = {
"properties": {
"flavor": "m1.tiny",
"image": "cirros-0.4.0-x86_64-disk",
"image": base.IMAGE_NAME,
"networks": [
{
"network": "private"
@ -1095,7 +1095,7 @@ class TestClustering(base.BaseFunctionalTest):
spec = {
"properties": {
"flavor": "m1.tiny",
"image": "cirros-0.4.0-x86_64-disk",
"image": base.IMAGE_NAME,
"networks": [
{
"network": "private"
@ -1131,7 +1131,7 @@ class TestClustering(base.BaseFunctionalTest):
spec = {
"properties": {
"flavor": "m1.tiny",
"image": "cirros-0.4.0-x86_64-disk",
"image": base.IMAGE_NAME,
"networks": [
{
"network": "private"
@ -1298,7 +1298,7 @@ class TestClustering(base.BaseFunctionalTest):
spec = {
"properties": {
"flavor": "m1.tiny",
"image": "cirros-0.4.0-x86_64-disk",
"image": base.IMAGE_NAME,
"networks": [
{
"network": "private"
@ -1357,7 +1357,7 @@ class TestClustering(base.BaseFunctionalTest):
spec = {
"properties": {
"flavor": "m1.tiny",
"image": "cirros-0.4.0-x86_64-disk",
"image": base.IMAGE_NAME,
"networks": [
{
"network": "private"

View File

@ -35,6 +35,7 @@ setenv =
{[testenv]setenv}
OS_TEST_TIMEOUT=600
OPENSTACKSDK_FUNC_TEST_TIMEOUT_LOAD_BALANCER=600
OPENSTACKSDK_EXAMPLE_CONFIG_KEY=functional
commands = stestr --test-path ./openstack/tests/functional/{env:OPENSTACKSDK_TESTS_SUBDIR:} run --serial {posargs}
stestr slowest