| 1 |
Functional tests |
| 2 |
================ |
| 3 |
|
| 4 |
There is a suite of functional tests under the |
| 5 |
python-manilaclient/tests/functional directory. Unlike unit tests, these |
| 6 |
tests perform API calls to Manila and are designed to run on a DevStack. |
| 7 |
|
| 8 |
Adding functional tests to your changes is not mandatory but it's certainly |
| 9 |
a good practice and it's encouraged. |
| 10 |
|
| 11 |
Prerequisite |
| 12 |
------------ |
| 13 |
|
| 14 |
You need to have manila running somewhere. If you wish to use DevStack to |
| 15 |
run manila, a good place to start would be the `manila contributor guide`_. |
| 16 |
|
| 17 |
.. note:: |
| 18 |
|
| 19 |
We absolutely recommend using a ``fake shared file system back end`` as |
| 20 |
opposed to a real storage system, because our tests are written with the |
| 21 |
assumption that all APIs manila exposes are usable. In reality, |
| 22 |
different real world storage back ends have `different capabilities`_ and |
| 23 |
this project doesn't need to worry about them to provide a general purpose |
| 24 |
interface to Manila. A fake driver provides fake storage, so don't |
| 25 |
expect to be able to mount or use the shared file systems that you |
| 26 |
create with it. |
| 27 |
|
| 28 |
You can use the following local.conf file to configure DevStack including |
| 29 |
Manila using a few fake back ends: |
| 30 |
|
| 31 |
.. code-block:: bash |
| 32 |
|
| 33 |
[[local|localrc]] |
| 34 |
|
| 35 |
# auth |
| 36 |
ADMIN_PASSWORD=nomoresecret |
| 37 |
DATABASE_PASSWORD=$ADMIN_PASSWORD |
| 38 |
RABBIT_PASSWORD=$ADMIN_PASSWORD |
| 39 |
SERVICE_PASSWORD=$ADMIN_PASSWORD |
| 40 |
|
| 41 |
# enable logging for DevStack |
| 42 |
LOGFILE=/opt/stack/logs/stack.sh.log |
| 43 |
|
| 44 |
# Logging mode for DevStack services |
| 45 |
VERBOSE=True |
| 46 |
|
| 47 |
# manila |
| 48 |
enable_plugin manila https://opendev.org/openstack/manila |
| 49 |
|
| 50 |
# python-manilaclient |
| 51 |
LIBS_FROM_GIT=python-manilaclient |
| 52 |
|
| 53 |
# share driver |
| 54 |
SHARE_DRIVER=manila.tests.share.drivers.dummy.DummyDriver |
| 55 |
|
| 56 |
# share types |
| 57 |
MANILA_DEFAULT_SHARE_TYPE_EXTRA_SPECS='snapshot_support=True create_share_from_snapshot_support=True revert_to_snapshot_support=True mount_snapshot_support=True' |
| 58 |
MANILA_CONFIGURE_DEFAULT_TYPES=True |
| 59 |
|
| 60 |
# backends and groups |
| 61 |
MANILA_ENABLED_BACKENDS=alpha,beta,gamma,delta |
| 62 |
MANILA_CONFIGURE_GROUPS=alpha,beta,gamma,delta,membernet,adminnet |
| 63 |
|
| 64 |
# alpha |
| 65 |
MANILA_OPTGROUP_alpha_share_driver=manila.tests.share.drivers.dummy.DummyDriver |
| 66 |
MANILA_OPTGROUP_alpha_driver_handles_share_servers=True |
| 67 |
MANILA_OPTGROUP_alpha_share_backend_name=ALPHA |
| 68 |
MANILA_OPTGROUP_alpha_network_config_group=membernet |
| 69 |
MANILA_OPTGROUP_alpha_admin_network_config_group=adminnet |
| 70 |
|
| 71 |
# beta |
| 72 |
MANILA_OPTGROUP_beta_share_driver=manila.tests.share.drivers.dummy.DummyDriver |
| 73 |
MANILA_OPTGROUP_beta_driver_handles_share_servers=True |
| 74 |
MANILA_OPTGROUP_beta_share_backend_name=BETA |
| 75 |
MANILA_OPTGROUP_beta_network_config_group=membernet |
| 76 |
MANILA_OPTGROUP_beta_admin_network_config_group=adminnet |
| 77 |
|
| 78 |
# gamma |
| 79 |
MANILA_OPTGROUP_gamma_share_driver=manila.tests.share.drivers.dummy.DummyDriver |
| 80 |
MANILA_OPTGROUP_gamma_driver_handles_share_servers=False |
| 81 |
MANILA_OPTGROUP_gamma_share_backend_name=GAMMA |
| 82 |
MANILA_OPTGROUP_gamma_replication_domain=DUMMY_DOMAIN |
| 83 |
|
| 84 |
# delta |
| 85 |
MANILA_OPTGROUP_delta_share_driver=manila.tests.share.drivers.dummy.DummyDriver |
| 86 |
MANILA_OPTGROUP_delta_driver_handles_share_servers=False |
| 87 |
MANILA_OPTGROUP_delta_share_backend_name=DELTA |
| 88 |
MANILA_OPTGROUP_delta_replication_domain=DUMMY_DOMAIN |
| 89 |
|
| 90 |
# membernet |
| 91 |
MANILA_OPTGROUP_membernet_network_api_class=manila.network.standalone_network_plugin.StandaloneNetworkPlugin |
| 92 |
MANILA_OPTGROUP_membernet_standalone_network_plugin_gateway=10.0.0.1 |
| 93 |
MANILA_OPTGROUP_membernet_standalone_network_plugin_mask=24 |
| 94 |
MANILA_OPTGROUP_membernet_standalone_network_plugin_network_type=vlan |
| 95 |
MANILA_OPTGROUP_membernet_standalone_network_plugin_segmentation_id=1010 |
| 96 |
MANILA_OPTGROUP_membernet_standalone_network_plugin_allowed_ip_ranges=10.0.0.10-10.0.0.209 |
| 97 |
MANILA_OPTGROUP_membernet_network_plugin_ipv4_enabled=True |
| 98 |
|
| 99 |
# adminnet |
| 100 |
MANILA_OPTGROUP_adminnet_network_api_class=manila.network.standalone_network_plugin.StandaloneNetworkPlugin |
| 101 |
MANILA_OPTGROUP_adminnet_standalone_network_plugin_gateway=11.0.0.1 |
| 102 |
MANILA_OPTGROUP_adminnet_standalone_network_plugin_mask=24 |
| 103 |
MANILA_OPTGROUP_adminnet_standalone_network_plugin_network_type=vlan |
| 104 |
MANILA_OPTGROUP_adminnet_standalone_network_plugin_segmentation_id=1011 |
| 105 |
MANILA_OPTGROUP_adminnet_standalone_network_plugin_allowed_ip_ranges=11.0.0.10-11.0.0.19,11.0.0.30-11.0.0.39,11.0.0.50-11.0.0.199 |
| 106 |
MANILA_OPTGROUP_adminnet_network_plugin_ipv4_enabled=True |
| 107 |
|
| 108 |
Configuration |
| 109 |
------------- |
| 110 |
|
| 111 |
The functional tests require a couple of configuration files, so you will need |
| 112 |
to generate them before running the tests. |
| 113 |
|
| 114 |
For DevStack |
| 115 |
^^^^^^^^^^^^ |
| 116 |
|
| 117 |
On your DevStack machine, you can run the following script. It assumes that |
| 118 |
``devstack`` is cloned onto your base folder. |
| 119 |
|
| 120 |
.. code-block:: bash |
| 121 |
|
| 122 |
DEST=${DEST:-/opt/stack} |
| 123 |
MANILACLIENT_DIR=${MANILACLIENT_DIR:-$DEST/python-manilaclient} |
| 124 |
MANILACLIENT_CONF="$MANILACLIENT_DIR/etc/manilaclient/manilaclient.conf" |
| 125 |
# Go to the manilaclient dir |
| 126 |
cd $MANILACLIENT_DIR |
| 127 |
# Give permissions |
| 128 |
sudo chown -R $USER:stack . |
| 129 |
# Create manilaclient config file |
| 130 |
touch $MANILACLIENT_CONF |
| 131 |
# Import functions from devstack |
| 132 |
source $HOME/devstack/functions |
| 133 |
# Set options to config client. |
| 134 |
source $HOME/devstack/openrc demo demo |
| 135 |
export OS_TENANT_NAME=${OS_PROJECT_NAME:-$OS_TENANT_NAME} |
| 136 |
iniset $MANILACLIENT_CONF DEFAULT username $OS_USERNAME |
| 137 |
iniset $MANILACLIENT_CONF DEFAULT tenant_name $OS_TENANT_NAME |
| 138 |
iniset $MANILACLIENT_CONF DEFAULT password $OS_PASSWORD |
| 139 |
iniset $MANILACLIENT_CONF DEFAULT auth_url $OS_AUTH_URL |
| 140 |
iniset $MANILACLIENT_CONF DEFAULT project_domain_name $OS_PROJECT_DOMAIN_NAME |
| 141 |
iniset $MANILACLIENT_CONF DEFAULT user_domain_name $OS_USER_DOMAIN_NAME |
| 142 |
iniset $MANILACLIENT_CONF DEFAULT project_domain_id $OS_PROJECT_DOMAIN_ID |
| 143 |
iniset $MANILACLIENT_CONF DEFAULT user_domain_id $OS_USER_DOMAIN_ID |
| 144 |
source $HOME/devstack/openrc admin demo |
| 145 |
export OS_TENANT_NAME=${OS_PROJECT_NAME:-$OS_TENANT_NAME} |
| 146 |
iniset $MANILACLIENT_CONF DEFAULT admin_username $OS_USERNAME |
| 147 |
iniset $MANILACLIENT_CONF DEFAULT admin_tenant_name $OS_TENANT_NAME |
| 148 |
iniset $MANILACLIENT_CONF DEFAULT admin_password $OS_PASSWORD |
| 149 |
iniset $MANILACLIENT_CONF DEFAULT admin_auth_url $OS_AUTH_URL |
| 150 |
iniset $MANILACLIENT_CONF DEFAULT admin_project_domain_name $OS_PROJECT_DOMAIN_NAME |
| 151 |
iniset $MANILACLIENT_CONF DEFAULT admin_user_domain_name $OS_USER_DOMAIN_NAME |
| 152 |
iniset $MANILACLIENT_CONF DEFAULT admin_project_domain_id $OS_PROJECT_DOMAIN_ID |
| 153 |
iniset $MANILACLIENT_CONF DEFAULT admin_user_domain_id $OS_USER_DOMAIN_ID |
| 154 |
# Suppress errors in cleanup of resources |
| 155 |
SUPPRESS_ERRORS=${SUPPRESS_ERRORS_IN_CLEANUP:-False} |
| 156 |
iniset $MANILACLIENT_CONF DEFAULT suppress_errors_in_cleanup $SUPPRESS_ERRORS |
| 157 |
# Set access type usage specific to dummy driver that we are using in CI |
| 158 |
iniset $MANILACLIENT_CONF DEFAULT access_types_mapping "nfs:ip,cifs:user" |
| 159 |
# Dummy driver is capable of running share migration tests |
| 160 |
iniset $MANILACLIENT_CONF DEFAULT run_migration_tests "True" |
| 161 |
# Running mountable snapshot tests in dummy driver |
| 162 |
iniset $MANILACLIENT_CONF DEFAULT run_mount_snapshot_tests "True" |
| 163 |
# Create share network and use it for functional tests if required |
| 164 |
USE_SHARE_NETWORK=$(trueorfalse True USE_SHARE_NETWORK) |
| 165 |
|
| 166 |
.. code-block:: bash |
| 167 |
|
| 168 |
if [[ ${USE_SHARE_NETWORK} = True ]]; then |
| 169 |
SHARE_NETWORK_NAME=${SHARE_NETWORK_NAME:-ci} |
| 170 |
DEFAULT_NEUTRON_NET=$(openstack network show private -c id -f value) |
| 171 |
DEFAULT_NEUTRON_SUBNET=$(openstack subnet show private-subnet -c id -f value) |
| 172 |
NEUTRON_NET=${NEUTRON_NET:-$DEFAULT_NEUTRON_NET} |
| 173 |
NEUTRON_SUBNET=${NEUTRON_SUBNET:-$DEFAULT_NEUTRON_SUBNET} |
| 174 |
manila share-network-create --name $SHARE_NETWORK_NAME --neutron-net $NEUTRON_NET --neutron-subnet $NEUTRON_SUBNET |
| 175 |
iniset $MANILACLIENT_CONF DEFAULT share_network $SHARE_NETWORK_NAME |
| 176 |
iniset $MANILACLIENT_CONF DEFAULT admin_share_network $SHARE_NETWORK_NAME |
| 177 |
|
| 178 |
fi |
| 179 |
|
| 180 |
.. code-block:: bash |
| 181 |
|
| 182 |
# Set share type if required |
| 183 |
if [[ "$SHARE_TYPE" ]]; then |
| 184 |
iniset $MANILACLIENT_CONF DEFAULT share_type $SHARE_TYPE |
| 185 |
|
| 186 |
fi |
| 187 |
|
| 188 |
Running the tests |
| 189 |
----------------- |
| 190 |
|
| 191 |
To run all functional tests make sure you are in the top level of your |
| 192 |
python-manilaclient module (e.g. /opt/stack/python-manilaclient/) and simply |
| 193 |
run:: |
| 194 |
|
| 195 |
tox -e functional |
| 196 |
|
| 197 |
This will create a virtual environment, load all the packages from |
| 198 |
test-requirements.txt and run all functional tests. |
| 199 |
|
| 200 |
|
| 201 |
.. _manila contributor guide: https://docs.openstack.org/manila/latest/contributor/development-environment-devstack.html |
| 202 |
.. _different capabilities: https://docs.openstack.org/manila/latest/admin/share_back_ends_feature_support_mapping.html |