sheep: fix an incorrect assertion

Reported-by: Ruoyu <liangry@ucweb.com>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
sheep/http: fix error in bucket_delete

In current implementation, When we create a bucket, we decide
the bnode's location in account VDI using sd_hash(bucket_name)
as key. We handle hash conflict by linear probing hash table.
Here is the bug:
When we delete a bucket, we can't discard its bnode. Because
bnode_lookup() need it to find if some bucket exists or not
by checking adjacent bnodes. Therefore, we just zero its
bnode.name when client want to delete a bucket. When we create
a bucket later, we can reuse the zero bnode if they hash to
the same location in account VDI. So, we need to change the
implementation of bnode lookup and bnode create function, too.

Signed-off-by: Bingpeng Zhu <bingpeng.zbp@alibaba-inc.com>
Signed-off-by: Liu Yuan <namei.unix@gmail.com>
dog/common: check empty argument for commands those need arguments

Advised by Hitoshi:

If we execute a command like this: dog node md plug "",
sheep dies because sheep daemon assumes a path name passed
by dog process is correct.

Response by Ruoyu:

I think the above checking should be processed in framework, too.
Otherwise, we must check it in every function that needs arguments.

Signed-off-by: Ruoyu <liangry@ucweb.com>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
dog/node: remove checking argument in md plug/unplug since root cause is found

The purpose of the checking in the function is to ensure the
argument is not null. But it is not needed any longer because
the argument should be guaranteed in the framework as long as
CMD_NEED_ARG is specified in subcommand.

Since the problem is solved in commit e6d1706, we can remove
the checking safely.

Signed-off-by: Ruoyu <liangry@ucweb.com>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
sheep/cluster: fix error in sheep log

zk_timeout is measured in milliseconds, so
it should be divided by 1000 to seconds.

Signed-off-by: Bingpeng Zhu <bingpeng.zbp@alibaba-inc.com>
test/func: add test cases for vdi check -e

TC 077 and 083 are involved.

Signed-off-by: Ruoyu <liangry@ucweb.com>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
test/func: add test cases for cluster wide snapshot

Because saving and loading specified vdi in cluster wide snapshot
was introduced, TC 030 is updated for new test cases.

Signed-off-by: Ruoyu <liangry@ucweb.com>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
test/func: add test cases for alter cluster copy and alter vdi copy

New test suite 096 is added.

Signed-off-by: Ruoyu <liangry@ucweb.com>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
dog/farm: add an option for multi-thread cluster snapshot save process

There is no reason we can't multi-thread it. Let's go multi-threading and enjoy
boost.

Consider that we often save snapshots on the fly so we use single thread as
default to minimize the impact of running cluster.

usage:
 $ dog cluster snapshot save -m ... # enable multi-threads

[Hitoshi: added "m" to the accepted options of cluster snapshot
command]

Signed-off-by: Liu Yuan <namei.unix@gmail.com>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
sheep: return SD_RES_VDI_LOCKED in a case of failed lock

Returning SD_RES_VDI_NOT_LOCKED in a case of failed lock can produce
a confusing error message.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
dog: use -T as the option for showing elapsed time

Currently, "-t" has been used as the option abbr for both showing
elapsed time of executing dog command and enabling strict mode.
"-t" for strict mode is already available in stable-0.8. For keeping
compatibility, maybe we should use "-T" for showing elapsed time.

Signed-off-by: Bingpeng Zhu <bingpeng.zbp@alibaba-inc.com>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
fix sheep crash when executing functional test 009

No participant should be permitted. In the situation, just return
is OKay in function del_participant.

Signed-off-by: Ruoyu <liangry@ucweb.com>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
sheep: revive backward compatibility of locking operation

Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
add test-driver to .gitignore

Signed-off-by: Ruoyu <liangry@ucweb.com>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
func/test: _kill_xxx methods use SIGTERM by default

Since the bug, sheep sometimes cannot be killed, is fixed by the commit
f473561, functional tests should use 'pkill' instead of 'pkill -9'
by default. Otherwise, some tests using zookeeper as their cluster
manager will be failure because zookeeper cannot receive the leaving
message at the first time.

For the purpose of killing program forcibly, _kill_xxx_force methods
are added. They kill programs with SIGKILL (-9).

Signed-off-by: Ruoyu <liangry@ucweb.com>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
func/test: fix some test scripts when using multi disk

check script supports -md option to enable multi disk for functional test.
But it seems some test suites are not compatible with it. This patch
fixes the problem.

Test suites 010, 027, 032, 033 and 042 are involved.

Signed-off-by: Ruoyu <liangry@ucweb.com>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
configure: enabling assert() in default

Enabling assert in default is better for development. This patch adds
options for configure script: --enable-assert and --disable-assert. If
a user want to disable assert, passing --disable-assert is required.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
test/func: update output file because source code of sheep is changed

Signed-off-by: Ruoyu <liangry@ucweb.com>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
sheep: don't collect cinfo when there are no other members

Current master branch doesn't pass test 032. Because current sheep
tries to collect cluster info (e.g. VDI locking information) even
there are no other members. This patch fixes the problem.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>
tests/functional: add a new test for iSCSI multipath

The new test checks whether the iSCSI multipath functionality of
sheepdog works collect or not. I excluded it from auto group because
it heavily depends on distribution specific stuff (e.g. configuration
file of multipathd and open-iscsi).

Signed-off-by: Hitoshi Mitake <mitake.hitoshi@lab.ntt.co.jp>