diff options
author | Niels de Vos <ndevos@redhat.com> | 2017-01-06 12:49:32 +0100 |
---|---|---|
committer | Shyamsundar Ranganathan <srangana@redhat.com> | 2017-01-19 10:44:22 -0800 |
commit | d93a6691538270aefe7703e8f8d7c822f53528e5 (patch) | |
tree | b07a719b7e9cc2ca8cb5e3fb054d8e9d8fea3cdb /tests/basic/gfapi | |
parent | 89cf743118ab6554c7f210754e51c4921cbb60c7 (diff) |
gfapi: add API to trigger events for debugging and troubleshooting
Introduce glfs_sysrq() as a generic API for triggering debug and
troubleshoot events. This interface will be used by the feature to get
statedumps for applications using libgfapi.
The current events that can be requested through this API are:
- 'h'elp: log a mesage with all supported events
- 's'tatedump: trigger a statedump for the passed glfs_t
In future, this API can be used by a CLI to trigger statedumps from
storage servers. At the moment it is limited to take statedumps, but it
is extensible to set the log-level, clear caches, force reconnects and
much more.
BUG: 1169302
Change-Id: I18858359a3957870cea5139c79efe1365a15a992
Original-author: Poornima G <pgurusid@redhat.com>
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: http://review.gluster.org/16414
Reviewed-by: Prashanth Pai <ppai@redhat.com>
Smoke: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Diffstat (limited to 'tests/basic/gfapi')
-rw-r--r-- | tests/basic/gfapi/glfs_sysrq.c | 61 | ||||
-rwxr-xr-x | tests/basic/gfapi/glfs_sysrq.t | 39 |
2 files changed, 100 insertions, 0 deletions
diff --git a/tests/basic/gfapi/glfs_sysrq.c b/tests/basic/gfapi/glfs_sysrq.c new file mode 100644 index 00000000000..c843c2a3559 --- /dev/null +++ b/tests/basic/gfapi/glfs_sysrq.c @@ -0,0 +1,61 @@ +/** glfs_sysrq.c + * + * Simple test application to run all glfs_syqrq() debugging calls. + * + * Usage: ./glfs_sysrq <host> <volume> <logfile> + */ +#include <errno.h> +#include <stdio.h> + +#include <glusterfs/api/glfs.h> + +int +main (int argc, char *argv[]) +{ + /* cmdline arguments */ + char *host = NULL; + char *volume = NULL; + char *logfile = NULL; + + /* other variables */ + glfs_t *fs = NULL; + int ret = 0; + + if (argc != 4) { + fprintf (stderr, "Usage: %s <host> <volume> <logfile>\n", + argv[0]); + return -1; + } + + host = argv[1]; + volume = argv[2]; + logfile = argv[3]; + + fs = glfs_new (volume); + if (!fs) { + return -1; + } + + ret = glfs_set_logging (fs, logfile, 7); + if (ret < 0) { + return -1; + } + + ret = glfs_set_volfile_server (fs, "tcp", host, 24007); + if (ret < 0) { + return -1; + } + + ret = glfs_init (fs); + if (ret < 0) { + return -1; + } + + /* checking of the results is easier in the script running this test */ + glfs_sysrq (fs, GLFS_SYSRQ_HELP); + glfs_sysrq (fs, GLFS_SYSRQ_STATEDUMP); + + glfs_fini (fs); + + return 0; +} diff --git a/tests/basic/gfapi/glfs_sysrq.t b/tests/basic/gfapi/glfs_sysrq.t new file mode 100755 index 00000000000..d1a0e9bc248 --- /dev/null +++ b/tests/basic/gfapi/glfs_sysrq.t @@ -0,0 +1,39 @@ +#!/bin/bash +# +# Run glfs_sysrq, a gfapi applications calling all glfs_sysrq() commands. +# Each command generates a specific log message, or something else that can be +# tested for existance. +# + +. $(dirname $0)/../../include.rc +. $(dirname $0)/../../volume.rc + +cleanup + +TEST glusterd +TEST pidof glusterd +TEST $CLI volume create $V0 $H0:$B0/brick1 +EXPECT 'Created' volinfo_field $V0 'Status' + +TEST $CLI volume start $V0; +EXPECT 'Started' volinfo_field $V0 'Status' + +logdir=$(gluster --print-logdir) + +# clear all statedumps +cleanup_statedump +TEST ! test -e $statedumpdir/*.dump.* +# vim friendly command */ + +build_tester $(dirname $0)/glfs_sysrq.c -lgfapi +TEST $(dirname $0)/glfs_sysrq $H0 $V0 $logdir/glfs_sysrq.log + +# check for the help message in the log +TEST grep -q '"(H)elp"' $logdir/glfs_sysrq.log + +# see if there is a statedump +TEST test -e $statedumpdir/*.dump.* +# vim friendly command */ + +cleanup_tester $(dirname $0)/glfs_sysrq +cleanup |