magnum/doc/source/dev/functional-test.rst
Hongbin Lu dca02f1d98 Reduce memory consumption of gate tests
Recently, the gate jobs took too long to complete (between 2 to 8
hours). The reason is jenkins slave agent die during the test, which
cause the CI to re-start the whole test in a new VM.

The failure mainly occurred at magnum-api pipeline, but also occurred
at other pipelines. In term of distribution of test nodes, this
failure mainly occurred at OVH nodes, in which there is no dedicated
swap device. As a result, at OVH nodes, local disk is used for swap
when memory is over-consuming. It looks this leads to resource
starvation, which cause the failure.

This patch attempted to reduce the memory consumption of the gate
tests. In the api test, the number of worker nodes was reduced from
2 to 1. In all tests (api/k8s/swarm/mesos), the memory of worker node
was reduced from 1G to 512M.

Closes-Bug: #1542386
Change-Id: If7822d07f95ebc935a8763b92f038f10cf07b5ca
2016-02-09 14:05:19 -05:00

3.7 KiB

Running functional tests

This is a guide for developers who want to run functional tests in their local machine.

Prerequisite

You need to have a Magnum instance running somewhere. If you are using devstack, follow the developer quickstart guide to deploy Magnum in a devstack environment

http://docs.openstack.org/developer/magnum/dev/quickstart.html

Configuration

The functional tests require a couple configuration files, so you'll need to generate them yourself.

For devstack

If you're using devstack, you can copy and modify the devstack configuration:

cd /opt/stack/magnum
cp /opt/stack/tempest/etc/tempest.conf /opt/stack/magnum/etc/tempest.conf
cp functional_creds.conf.sample functional_creds.conf

# update the IP address
HOST=$(cat /etc/magnum/magnum.conf | awk '/^host = /{print $3}')
sed -i "s/127.0.0.1/$HOST/" functional_creds.conf

# update admin password
source /opt/stack/devstack/openrc admin admin
iniset functional_creds.conf admin pass $OS_PASSWORD

# update demo password
source /opt/stack/devstack/openrc demo demo
iniset functional_creds.conf auth password $OS_PASSWORD

Create the necessary keypair and flavor:

source /opt/stack/devstack/openrc admin admin
nova keypair-add --pub-key ~/.ssh/id_rsa.pub default
nova flavor-create  m1.magnum 100 1024 8 1
nova flavor-create  m1.magnum2 200 512 8 1

source /opt/stack/devstack/openrc demo demo
nova keypair-add --pub-key ~/.ssh/id_rsa.pub default

You may need to explicitly upgrade required packages if you've installed them before and their versions become too old:

UPPER_CONSTRAINTS=/opt/stack/requirements/upper-constraints.txt
sudo pip install -c $UPPER_CONSTRAINTS -U -r test-requirements.txt

Outside of devstack

If you are not using devstack, you'll need to create the configuration files. The /etc/tempest.conf configuration file is documented here

http://docs.openstack.org/developer/tempest/configuration.html#tempest-configuration

Here's a reasonable sample of tempest.conf settings you might need:

[auth]
use_dynamic_credentials=False
test_accounts_file=/tmp/etc/magnum/accounts.yaml
admin_username=admin
admin_password=password
admin_tenant_name=admin

[identity]
disable_ssl_certificate_validation=True
uri=https://identity.example.com/v2.0
auth_version=v2
region=EAST

[identity-feature-enabled]
api_v2 = true
api_v3 = false
trust = false

[oslo_concurrency]
lock_path = /tmp/

[magnum]
image_id=22222222-2222-2222-2222-222222222222
nic_id=11111111-1111-1111-1111-111111111111
keypair_id=default
flavor_id=small
magnum_url=https://magnum.example.com/v1

[debug]
trace_requests=true

A sample functional_creds.conf can be found in the root of this project named functional_creds.conf.sample

When you run tox, be sure to specify the location of your tempest.conf using TEMPEST_CONFIG_DIR:

export TEMPEST_CONFIG_DIR=/tmp/etc/magnum/
tox -e functional-api

Execution

Magnum has different functional tests for each COE and for the API. All the environments are detailed in Magnum's tox.ini:

cat tox.ini | grep functional- | awk -F: '{print $2}' | sed s/]//

To run a particular subset of tests, specify that group as a tox environment. For example, here is how you would run all of the kubernates tests:

tox -e functional-k8s

To run a specific test or group of tests, specify the test path as a positional argument:

tox -e functional-k8s -- magnum.tests.functional.k8s.v1.test_k8s_python_client.TestBayModelResource