Make functional test work with new tox env
The check-functional-dsvm-magnum gate job was failing due to the functional tests not picking up valid OpenStack credentials. Update how we aquire credentials -- fixes side effect of how tox 2.0 handles environment variables Closes-Bug: #1455102 Change-Id: I56ecd8003594fd436874681670bb9ead19b95dea
This commit is contained in:
parent
44724f0f89
commit
986aac0b3e
|
@ -0,0 +1,11 @@
|
||||||
|
# Credentials for functional testing
|
||||||
|
[auth]
|
||||||
|
auth_url = http://127.0.0.1:5000/v2.0
|
||||||
|
magnum_url = http://127.0.0.1:9511/v1
|
||||||
|
[admin]
|
||||||
|
user = admin
|
||||||
|
tenant = admin
|
||||||
|
pass = secrete
|
||||||
|
[magnum]
|
||||||
|
image_id = fedora-21-atomic-3
|
||||||
|
nic_id = public
|
|
@ -32,6 +32,9 @@ echo_summary "magnum's post_test_hook.sh was called..."
|
||||||
|
|
||||||
sudo pip install -U -r requirements.txt -r test-requirements.txt
|
sudo pip install -U -r requirements.txt -r test-requirements.txt
|
||||||
|
|
||||||
|
export MAGNUM_DIR="$BASE/new/magnum"
|
||||||
|
sudo chown -R jenkins:stack $MAGNUM_DIR
|
||||||
|
|
||||||
# Get admin credentials
|
# Get admin credentials
|
||||||
pushd ../devstack
|
pushd ../devstack
|
||||||
source openrc admin admin
|
source openrc admin admin
|
||||||
|
@ -42,13 +45,32 @@ popd
|
||||||
export NIC_ID=$(neutron net-show public | awk '/ id /{print $4}')
|
export NIC_ID=$(neutron net-show public | awk '/ id /{print $4}')
|
||||||
export IMAGE_ID=$(glance image-show fedora-21-atomic-3 | awk '/ id /{print $4}')
|
export IMAGE_ID=$(glance image-show fedora-21-atomic-3 | awk '/ id /{print $4}')
|
||||||
|
|
||||||
|
|
||||||
|
# pass the appropriate variables via a config file
|
||||||
|
CREDS_FILE=$MAGNUM_DIR/functional_creds.conf
|
||||||
|
cat <<EOF > $CREDS_FILE
|
||||||
|
# Credentials for functional testing
|
||||||
|
|
||||||
|
[auth]
|
||||||
|
auth_url = $OS_AUTH_URL
|
||||||
|
magnum_url = $BYPASS_URL
|
||||||
|
[admin]
|
||||||
|
user = $OS_USERNAME
|
||||||
|
tenant = $OS_TENANT_NAME
|
||||||
|
pass = $OS_PASSWORD
|
||||||
|
region_name = $OS_REGION_NAME
|
||||||
|
[magnum]
|
||||||
|
image_id = $IMAGE_ID
|
||||||
|
nic_id = $NIC_ID
|
||||||
|
EOF
|
||||||
|
|
||||||
# Create a keypair for use in the functional tests.
|
# Create a keypair for use in the functional tests.
|
||||||
echo_summary "Generate a key-pair"
|
echo_summary "Generate a key-pair"
|
||||||
nova keypair-add default
|
nova keypair-add default
|
||||||
|
|
||||||
# Run functional tests
|
# Run functional tests
|
||||||
echo "Running magnum functional test suite"
|
echo "Running magnum functional test suite"
|
||||||
sudo -E -H -u stack tox -e functional
|
sudo -E -H -u jenkins tox -e functional
|
||||||
EXIT_CODE=$?
|
EXIT_CODE=$?
|
||||||
|
|
||||||
# Delete the keypair used in the functional test.
|
# Delete the keypair used in the functional test.
|
||||||
|
|
|
@ -19,6 +19,7 @@ test_magnum
|
||||||
Tests for `magnum` module.
|
Tests for `magnum` module.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import ConfigParser
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
@ -34,14 +35,42 @@ from magnum.tests import base
|
||||||
class BaseMagnumClient(base.TestCase):
|
class BaseMagnumClient(base.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(BaseMagnumClient, self).setUp()
|
super(BaseMagnumClient, self).setUp()
|
||||||
self.cs = client.Client(username=cliutils.env('OS_USERNAME'),
|
# Collecting of credentials:
|
||||||
api_key=cliutils.env('OS_PASSWORD'),
|
#
|
||||||
project_id=cliutils.env('OS_TENANT_ID'),
|
# Support the existence of a functional_creds.conf for
|
||||||
project_name=cliutils.env('OS_TENANT_NAME'),
|
# testing. This makes it possible to use a config file.
|
||||||
auth_url=cliutils.env('OS_AUTH_URL'),
|
user = cliutils.env('OS_USERNAME')
|
||||||
|
passwd = cliutils.env('OS_PASSWORD')
|
||||||
|
tenant = cliutils.env('OS_TENANT_NAME')
|
||||||
|
tenant_id = cliutils.env('OS_TENANT_ID')
|
||||||
|
auth_url = cliutils.env('OS_AUTH_URL')
|
||||||
|
region_name = cliutils.env('OS_REGION_NAME')
|
||||||
|
magnum_url = cliutils.env('BYPASS_URL')
|
||||||
|
image_id = cliutils.env('IMAGE_ID')
|
||||||
|
nic_id = cliutils.env('NIC_ID')
|
||||||
|
|
||||||
|
config = ConfigParser.RawConfigParser()
|
||||||
|
if config.read('functional_creds.conf'):
|
||||||
|
# the OR pattern means the environment is preferred for
|
||||||
|
# override
|
||||||
|
user = user or config.get('admin', 'user')
|
||||||
|
passwd = passwd or config.get('admin', 'pass')
|
||||||
|
tenant = tenant or config.get('admin', 'tenant')
|
||||||
|
auth_url = auth_url or config.get('auth', 'auth_url')
|
||||||
|
magnum_url = magnum_url or config.get('auth', 'magnum_url')
|
||||||
|
image_id = image_id or config.get('magnum', 'image_id')
|
||||||
|
nic_id = nic_id or config.get('magnum', 'nic_id')
|
||||||
|
|
||||||
|
self.image_id = image_id
|
||||||
|
self.nic_id = nic_id
|
||||||
|
self.cs = client.Client(username=user,
|
||||||
|
api_key=passwd,
|
||||||
|
project_id=tenant_id,
|
||||||
|
project_name=tenant,
|
||||||
|
auth_url=auth_url,
|
||||||
service_type='container',
|
service_type='container',
|
||||||
region_name=cliutils.env('OS_REGION_NAME'),
|
region_name=region_name,
|
||||||
magnum_url=cliutils.env('BYPASS_URL'))
|
magnum_url=magnum_url)
|
||||||
|
|
||||||
|
|
||||||
class TestListResources(BaseMagnumClient):
|
class TestListResources(BaseMagnumClient):
|
||||||
|
@ -72,8 +101,8 @@ class TestBayModelResource(BaseMagnumClient):
|
||||||
baymodel = self.cs.baymodels.create(
|
baymodel = self.cs.baymodels.create(
|
||||||
name='default',
|
name='default',
|
||||||
keypair_id='default',
|
keypair_id='default',
|
||||||
external_network_id=cliutils.env('NIC_ID'),
|
external_network_id=self.nic_id,
|
||||||
image_id=cliutils.env('IMAGE_ID'),
|
image_id=self.image_id,
|
||||||
flavor_id='m1.small',
|
flavor_id='m1.small',
|
||||||
docker_volume_size=5,
|
docker_volume_size=5,
|
||||||
coe='kubernetes',
|
coe='kubernetes',
|
||||||
|
@ -102,8 +131,8 @@ class TestBayResource(BaseMagnumClient):
|
||||||
self.baymodel = self.cs.baymodels.create(
|
self.baymodel = self.cs.baymodels.create(
|
||||||
name='default',
|
name='default',
|
||||||
keypair_id='default',
|
keypair_id='default',
|
||||||
external_network_id=cliutils.env('NIC_ID'),
|
external_network_id=self.nic_id,
|
||||||
image_id=cliutils.env('IMAGE_ID'),
|
image_id=self.image_id,
|
||||||
flavor_id='m1.small',
|
flavor_id='m1.small',
|
||||||
docker_volume_size=5,
|
docker_volume_size=5,
|
||||||
coe='kubernetes',
|
coe='kubernetes',
|
||||||
|
|
Loading…
Reference in New Issue