This document briefly summarizes some points that can be of interest for anyone modifying the FTS3 RESTful API.
It is not intended for developers of client applications. For them we have the auto generated API documentation, the list of curl examples or the easy bindings.
The service is written using Pylons 0.9.7
The database abstraction is done by SQLAlchemy 0.8
There are a bunch of tests written using Python's unittest module, and they can be executed automatically with nosetests.
Integrated development version. Should be in a consistent state, but not necessarely stable. This means, new features go here, and they should be in a workable state.
Stable branch. Only critical bugfixes. Runs on the FTS3 pilot service first, and then in the FTS3 production services.
develop should be consistent and workable. For big changesets, you can keep them in a separate branch, and merge them into develop when they are ready (remember to rebase first). You don't need to keep these branches in the remote repositories.
- New features are commited into develop. Big new features go into their own branch and later merged into develop.
- Keep documentation up to date
- When develop is ready for being a release candidate, merge develop into master.
- Increase the version of develop after this!
- When master is stable and ready for release
- Make sure the documentation is up to date
- Write release notes for the new version (contained in docs/releases)
- Tag, and mark version as released in JIRA (move any remaining tickets to the next release)
This is just a small recopilatory of some guidelines that I consider worth considering when working on this project. They don't have to strictly be followed. Nevertheless, they are handy.
Remember to add the copyright notice
# Copyright notice:
# Copyright CERN, 2017.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
If you find a bug, or someone reports one, it is helpful to write a regression test before actually doing the fix. So write the tests reproducing the buggy behavior, execute, and make sure they do fail. Once the bug has a test that automatically reproduces it, you do the fix. Re-run the test, and now it should pass.
I would recommend to run the whole test suite afterwards, to make sure the fix didn't break anything else! Precisely this is why I recommend writting a test. It will ensure this bug doesn't come back after some future modifications.
Remind creating a ticket in the JIRA tracker and linking it to the proper version!
Basically, the same idea applies. Write some tests for the new functionality, so you know you are achieving what you are expecting.
JIRA tickets are mandatory in this case. Otherwise, tracking release changes is hard.
Python's logging is really handy and powerful. Use it!
P.S I recognise I don't use it as much as I should.
- Write meaningful commit messages
- Specify any relevant JIRA ticket in the commit
- Avoid multipurpose jumbo commits
- They should not contain unrelated changes (i.e. two bug fixes in one commit, bad)
- Before pushing, group related commits (yes, you can do this with git)
- If you have two commits for one single bug fix, try grouping them whenever it makes sense.
Use PEP8. There are tools and IDE's that check for consistency with this guidelines. Do not kill yourself over it, but try to follow as much as possible.
- In a normally installed service,
/etc/fts3/fts3rest.ini
- If you are running the tests with nosetests, then
src/fts3rest/test.ini
is used instead
cd src/fts3rest/
nosetests -x
Note: In case the tests are run on Centos7, ./setup_pylons_plugin.py install --user needs to run first
That's it. For the tests, a SQLite database (/tmp/fts3.db) is used, so it is safe to run them as many times as you want.
The option -x
lets nosetests know that it should stop running as soon as it encounters an error, so you can omit it.
If you have nosestests1.1
installed, you can run the test suite as follows
cd src/fts3rest/
nosetests1.1 --with-coverage --cover-package=fts3rest
That will give coverage information. This is, which lines have been triggered by the tests.
Yes, you can. Just edit the relevant configuration file, look for [logger_sqlalchemy]
and set the level to INFO.
The queries will be dumped into the log file.