test,tools: capture boost::program_options in a try

When something fails boost::program_options throws an exception that
needs to be caught.

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
test: catch boost::program_options errors

And display it before returning on error.

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
tools: display boost::program_options errors

Instead of silently discarding them. Do not display the usage on error
as it will probably hide the error message that shows before it.

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
tools: move po::collect_unrecognized in the try block

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
tools: allow_unregistered() options

So that --debug-mon etc. can be parsed afterwards.

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
test,tools: indentation, whitespace only

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
Merge pull request #2511 from dachary/wip-catch-options-errors

test,tools: catch option parsing exceptions

Reviewed-by: Sahid Orentino Ferdjaoui <sahid.ferdjaoui@redhat.com>
doc: update debian compilation dependencies

Using the content of debian/control.

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
ceph-disk: encapsulate partprobe / partx calls

Add the update_partition function to reduce code duplication.
The action is made an argument although it always is -a because it will
be -d when deleting a partition.

Use the update_partition function in prepare_journal_dev

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
ceph-disk: use update_partition in prepare_dev and main_prepare

In the case of prepare_dev the partx alternative was missing and is not
added because update_partition does it.

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
ceph-disk: run partprobe after zap

Not running partprobe after zapping a device can lead to the following:

* ceph-disk prepare /dev/loop2
* links are created in /dev/disk/by-partuuid
* ceph-disk zap /dev/loop2
* links are not removed from /dev/disk/by-partuuid
* ceph-disk prepare /dev/loop2
* some links are not created in /dev/disk/by-partuuid

This is assuming there is a bug in the way udev events are handled by
the operating system.

http://tracker.ceph.com/issues/9665 Fixes: #9665

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
ceph-disk: implement init=none for block devices

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
tests: helper to run unit / function tests in docker

For instance

   test/docker-test.sh --os-type ubuntu --os-version 14.04 \
        test/ceph-disk.sh

runs test/ceph-disk.sh in a ubuntu 14.04 docker container. Once the
container is populated and ceph compiled, running a test script roughly
requires entering the container and running make TESTS=tests/foo.sh check

* docker build ceph-ubuntu-14.04 using ubuntu.dockerfile as a Dockerfile
* it will run apt-get install ceph compilation / run dependencies
* git clone the-local-clone ceph-ubuntu-14.04
* docker run ceph-ubuntu-14.04 make -j4 in the ceph-ubuntu-14.04 clone
* docker run test/ceph-disk.sh

test/docker-test.sh is the command line interface for
test/docker-test-helper.sh which can be invoked from shell scripts.
test/ubuntu.dockerfile and test/ubuntu.dockerfile are regular
Dockerfiles which allow substitution of environment variables.

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
ceph-disk: test prepare / activate on a device

This indirectly tests that partprobe is called after zap because it
would fail to map the partitions to /dev/disk/by-partuuid otherwise.

It also indirectly test the implementation of init=none when using a
block device because the test would fail to put an object into the rbd
pool using the device otherwise.

Signed-off-by: Loic Dachary <loic-201408@dachary.org>
autotools: add --enable-docker

Docker based tests should be explicit instead of auto-detected. It is
good that they do not run if docker is not available. It would be bad if
they run when the developer does not expect them to create docker
containers.

Signed-off-by: Loic Dachary <loic-201408@dachary.org>