cli: Fixing the xml output in failure cases for gluster peer probe
Change-Id: I9ebec995cbf47d9ced7140e37787e74ff9c63769 BUG: 879490 Signed-off-by: Avra Sengupta <asengupt@redhat.com> Reviewed-on: http://review.gluster.org/4301 Reviewed-by: Kaushal M <kaushal@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com>
This commit is contained in:
parent
020fc23776
commit
c9c0fe3f7d
@ -179,8 +179,10 @@ gf_cli_probe_cbk (struct rpc_req *req, struct iovec *iov,
|
||||
}
|
||||
|
||||
if (global_state->mode & GLUSTER_MODE_XML) {
|
||||
ret = cli_xml_output_str ("peerProbe", msg, rsp.op_ret,
|
||||
rsp.op_errno, NULL);
|
||||
ret = cli_xml_output_str (NULL,
|
||||
(rsp.op_ret == -1)? NULL : msg,
|
||||
rsp.op_ret, rsp.op_errno,
|
||||
(rsp.op_ret == -1)? msg : NULL);
|
||||
if (ret)
|
||||
gf_log ("cli", GF_LOG_ERROR,
|
||||
"Error outputting to xml");
|
||||
|
@ -149,13 +149,19 @@ cli_xml_output_str (char *op, char *str, int op_ret, int op_errno,
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"cliOp",
|
||||
"%s", op);
|
||||
XML_RET_CHECK_AND_GOTO (ret, out);
|
||||
if (op) {
|
||||
ret = xmlTextWriterWriteFormatElement (writer,
|
||||
(xmlChar *)"cliOp",
|
||||
"%s", op);
|
||||
XML_RET_CHECK_AND_GOTO (ret, out);
|
||||
}
|
||||
|
||||
ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"output",
|
||||
"%s", str);
|
||||
XML_RET_CHECK_AND_GOTO (ret, out);
|
||||
if (str) {
|
||||
ret = xmlTextWriterWriteFormatElement (writer,
|
||||
(xmlChar *)"output",
|
||||
"%s", str);
|
||||
XML_RET_CHECK_AND_GOTO (ret, out);
|
||||
}
|
||||
|
||||
ret = cli_end_xml_output (writer, buf);
|
||||
|
||||
|
37
tests/bugs/bug-879490.t
Executable file
37
tests/bugs/bug-879490.t
Executable file
@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
|
||||
. $(dirname $0)/../include.rc
|
||||
. $(dirname $0)/../volume.rc
|
||||
|
||||
cleanup;
|
||||
|
||||
## Start and create a volume
|
||||
TEST glusterd;
|
||||
TEST pidof glusterd;
|
||||
TEST $CLI volume info;
|
||||
|
||||
TEST $CLI volume create $V0 replica 2 stripe 2 $H0:$B0/${V0}{1,2,3,4,5,6,7,8};
|
||||
|
||||
## Verify volume is is created
|
||||
EXPECT "$V0" volinfo_field $V0 'Volume Name';
|
||||
EXPECT 'Created' volinfo_field $V0 'Status';
|
||||
|
||||
## Start volume and verify
|
||||
TEST $CLI volume start $V0;
|
||||
EXPECT 'Started' volinfo_field $V0 'Status';
|
||||
|
||||
function peer_probe()
|
||||
{
|
||||
$CLI peer probe a.b.c.d --xml | xmllint --format - | grep "<opErrstr>"
|
||||
}
|
||||
|
||||
EXPECT " <opErrstr>Probe returned with unknown errno 107</opErrstr>" peer_probe
|
||||
|
||||
## Finish up
|
||||
TEST $CLI volume stop $V0;
|
||||
EXPECT 'Stopped' volinfo_field $V0 'Status';
|
||||
|
||||
TEST $CLI volume delete $V0;
|
||||
TEST ! $CLI volume info $V0;
|
||||
|
||||
cleanup;
|
Loading…
Reference in New Issue
Block a user