Skip to content

Commit

Permalink
glusterd: improved line/function coverage
Browse files Browse the repository at this point in the history
Fix:
Added a new `.t` file for improving line/function
coverage for glusterd component

Updates: gluster#1052

Change-Id: I7e1bf72c6aa923f2a0d6a915e43795eb47698db0
Signed-off-by: nik-redhat <[email protected]>
  • Loading branch information
nik-redhat authored and xhernandez committed May 20, 2021
1 parent 6e5d886 commit 634db84
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 11 deletions.
59 changes: 59 additions & 0 deletions tests/line-coverage/glusterd-coverage.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

. $(dirname $0)/../include.rc
. $(dirname $0)/../volume.rc
. $(dirname $0)/../cluster.rc

cleanup;

# Start glusterd on 2 nodes
TEST launch_cluster 2

# Create a volume
TEST $CLI_1 volume create ${V0}_1 $H1:$B1/${V0}_1_{1,2,3};
TEST $CLI_1 volume start ${V0}_1

# Negative scenarios for ganesha.enable option
TEST ! $CLI_1 volume set ${V0}_1 ganesha.enable invalid-value
TEST ! $CLI_1 volume set ${V0}_1 ganesha.enable enable

# Coverage for bitrot feature
TEST ! $CLI_1 volume bitrot ${V0}_1 disable
TEST $CLI_1 volume stop ${V0}_1
TEST ! $CLI_1 volume bitrot ${V0}_1 enable

TEST $CLI_1 volume start ${V0}_1
TEST $CLI_1 volume bitrot ${V0}_1 enable
TEST $CLI_1 volume bitrot ${V0}_1 disable

# Neagtive scenario for gfproxy, fsm log
TEST ! $CLI_1 volume set ${V0}_1 config.gfproxyd invalid-value
TEST ! $CLI_1 system:: fsm log localhost

# Create 2 volumes for vol list code coverage
TEST $CLI_1 volume create ${V0}_2 $H1:$B1/${V0}_2_{1,2,3};
TEST $CLI_1 volume list

# Check get option for individual volume
TEST ! $CLI_1 volume get ${V0}_3 all
TEST $CLI_1 volume get ${V0}_1 cluster.max-op-version
TEST $CLI_1 volume get ${V0}_1 cluster.op-version
TEST $CLI_1 volume get ${V0}_1 config.memory-accounting
TEST $CLI_1 volume get ${V0}_1 config.transport

# Create a 2 node cluster for peer code coverage
TEST $CLI_1 peer probe $H2

TEST $CLI_1 get-state

pid=$(ps aux | grep 'glusterd.pid' | grep -v 'grep' | awk '{print $2}')
TEST generate_statedump $pid

# Replace-brick negative scenarios
TEST ! $CLI_1 volume replace-brick ${V0}_2 $H1:$B1/${V0}_2_{1} ${V0}_2 $H1:$B1/${V0}_2_{4} commit force
TEST $CLI_1 volume start ${V0}_2
TEST ! $CLI_1 volume replace-brick ${V0}_2 $H1:$B1/${V0}_2_{1} ${V0}_2 $H1:$B1/${V0}_2_{4} commit force
TEST ! $CLI_1 volume replace-brick ${V0}_2 $H1:$B1/${V0}_2_{1} ${V0}_2 $H2:$B1/${V0}_2_{4} commit force
TEST ! $CLI_1 volume replace-brick ${V0}_2 $H1:$B1/${V0}_2_{1} ${V0}_2 $H1:$B1/${V0}_2_{1} commit force

cleanup;
12 changes: 1 addition & 11 deletions xlators/mgmt/glusterd/src/glusterd-handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -4232,17 +4232,7 @@ glusterd_get_volumes(rpcsvc_request_t *req, dict_t *dict, int32_t flags)
ret = 0;
goto respond;
}
if (flags == GF_CLI_GET_VOLUME_ALL) {
cds_list_for_each_entry(entry, &priv->volumes, vol_list)
{
ret = glusterd_add_volume_detail_to_dict(entry, volumes, count);
if (ret)
goto respond;

count++;
}

} else if (flags == GF_CLI_GET_NEXT_VOLUME) {
if (flags == GF_CLI_GET_NEXT_VOLUME) {
ret = dict_get_strn(dict, "volname", SLEN("volname"), &volname);

if (ret) {
Expand Down

0 comments on commit 634db84

Please sign in to comment.