From 7d2c1abd25353ae4f1fe86f6d851b9a0cc93d2f6 Mon Sep 17 00:00:00 2001 From: rishubhjain Date: Mon, 22 Apr 2019 20:48:02 +0530 Subject: tests: add .t files to increase cli code coverage Tests added for gluster volume top and profile with and without xml output Change-Id: I66aa6390b53ca448014059a3d27dc72e405216d2 updates: bz#1693692 Signed-off-by: rishubhjain --- .../cli-volume-top-profile-coverage.t | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 tests/line-coverage/cli-volume-top-profile-coverage.t (limited to 'tests/line-coverage/cli-volume-top-profile-coverage.t') diff --git a/tests/line-coverage/cli-volume-top-profile-coverage.t b/tests/line-coverage/cli-volume-top-profile-coverage.t new file mode 100644 index 00000000000..73b72ff2446 --- /dev/null +++ b/tests/line-coverage/cli-volume-top-profile-coverage.t @@ -0,0 +1,62 @@ +#!/bin/bash + +. $(dirname $0)/../include.rc +. $(dirname $0)/../cluster.rc +. $(dirname $0)/../volume.rc + +cleanup + +# Creating cluster +TEST launch_cluster 3 + +# Probing peers +TEST $CLI_1 peer probe $H2 +TEST $CLI_1 peer probe $H3 +EXPECT_WITHIN $PROBE_TIMEOUT 2 peer_count 3 + +# Creating a volume and starting it. +TEST $CLI_1 volume create $V0 replica 3 $H1:$B1/$V0 $H2:$B2/$V0 $H3:$B3/$V0 +TEST $CLI_1 volume start $V0 +EXPECT 'Started' cluster_volinfo_field 1 $V0 'Status'; + +TEST glusterfs -s $H1 --volfile-id $V0 $M1 +TEST touch $M1/file{1..100} + +# Testing volume top command with and without xml output +function test_volume_top_cmds () { + local ret=0 + declare -a top_cmds=("read" "open" "write" "opendir" "readdir") + for cmd in ${top_cmds[@]}; do + $CLI_1 volume top $V0 $cmd + (( ret += $? )) + $CLI_1 volume top $V0 clear + (( ret += $? )) + $CLI_1 volume top $V0 $cmd --xml + (( ret += $? )) + $CLI_1 volume top $V0 $cmd brick $H1:$B1/$V0 + (( ret += $? )) + $CLI_1 volume top $V0 clear brick $H1:$B1/$V0 + (( ret += $? )) + $CLI_1 volume top $V0 $cmd brick $H1:$B1/$V0 --xml + (( ret += $? )) + done + return $ret +} + +# Testing volume profile command with and without xml +function test_volume_profile_cmds () { + local ret=0 + declare -a profile_cmds=("start" "info" "stop") + for cmd in ${profile_cmds[@]}; do + $CLI_1 volume profile $V0 $cmd + (( ret += $? )) + $CLI_1 volume profile $V0 $cmd --xml + (( ret += $? )) + done + return $ret +} + +TEST test_volume_top_cmds; +TEST test_volume_profile_cmds; + +cleanup -- cgit