Lessons learned while packaging OpenStack's test sub-packages

Posted by Chandan Kumar on Sun, May 24, 2015
In RDO,
Tags openstack rdo fedora

On Mar 3, 2016, I started working on python--tests subpackage for all OpenStack Projects present in RDO.

It took me about a month to complete the whole task. But in this time interval, I have made lots of mistakes and learned a lot.

Below are my findings

RDO test sub-packages naming conventions

  • For openstack- package, the test sub-package name is python--tests. python- will be the required package.
  • If the OpenStack upstream project name is -tests, a new package openstack--tests should be included in RDO packages.

Placing the python test binaries at proper place

From %files macro of python- subpackage, exclude tests and _tempest_tests directories and include these directories under %files macro of python--tests subpackage.

The advantage of using %exclude is to avoid shipping twice the same files and creating conflicts.

%files -n python-<service>
%exclude %{python2_sitelib}/<service>/tests
%exclude %{python2_sitelib}/<service>_tempest_tests

%files -n python-<service>-tests
%{python2_sitelib}/<service>/tests
%{python2_sitelib}/<service>_tempest_tests

Use %license macro to place LICENSE

It is our common problem that we generally include LICENSE file under %doc macro which is still correct in any sub-package but %license has advantages like handling license specifics (a lot of duplication) and allowing some optimizations.

For more information check here : (http://www.rpm.org/ticket/116)

Do not do rm -rf .egg-info

Last night, we faced a lot of problems due to this silly mistake. If we do rm -rf .egg-info in %prep section, there are chances that test-fixtures (might required by tests) present under tests and _tempest_tests directories does not get copied at %{python2_sitelib}//tests and %{python2_sitelib}/_tempest_tests in python--tests subpackage and also causes subfolders not to be installed by setuptools.

So, think twice before you do this step in the spec file. For more information, check the Python Eggs from Fedora Python Packaging guidelines: (https://fedoraproject.org/wiki/Packaging:Python_Eggs)

Use rpmls command to verify the list of files with in a package

Use rpmls command from rpmdevtools package to check the files and their permissions included in the packages, so that you can fix later on based on your needs.

$ rpmls *.rpm

Use correct path in _tempest_plugin

We had completed the packaging of python--tests sub-packages. When these packages are consumed in puppet-openstack-integration CI, some of the OpenStack Components is unable to discover tempest tests due to wrong path mentioned in the codebase. For Example: In mistral

# https://review.openstack.org/#/c/303792/1/mistral_tempest_tests/services/base.py
main_package = 'mistral'
# it should be
main_package = 'mistral_tempest_tests'

However, we have fixed the same in Zaqar and Mistral

That’s it! Now all RDO OpenStack packages contain tests sub-packages.

Thanks to Alan, Javier, Haikel and Emilien for helping in getting this huge task done on time and always inspiring me to learn more.