diff options
author | Raghavendra Bhat <raghavendrabhat@gluster.com> | 2011-12-14 10:36:27 +0530 |
---|---|---|
committer | Vijay Bellur <vijay@gluster.com> | 2011-12-15 02:54:32 -0800 |
commit | cd24be007c64bd10d8c28e8e9b1c988478a32c8c (patch) | |
tree | 5adfe3eaf23844aa8a1d98f38847d6e5ad78332f /xlators/debug | |
parent | ebe0cedb072baf4c1f4bd81f22745c428ab6b911 (diff) |
debug/error-gen: add option to generate errors at random percentage
Currently error-gen has a option where the percentage of the errors generated
can be specified. This patch adds a new option, which if given errors
are generated at random percentage. If both the random failure option and
the specific percentage of the errors are provided, then random error
generation is given preference.
Change-Id: I43fffcd7da8935761ed7d30e2a9677895d6a31fb
BUG: 767192
Signed-off-by: Raghavendra Bhat <raghavendrabhat@gluster.com>
Reviewed-on: http://review.gluster.com/786
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'xlators/debug')
-rw-r--r-- | xlators/debug/error-gen/src/error-gen.c | 11 | ||||
-rw-r--r-- | xlators/debug/error-gen/src/error-gen.h | 1 |
2 files changed, 11 insertions, 1 deletions
diff --git a/xlators/debug/error-gen/src/error-gen.c b/xlators/debug/error-gen/src/error-gen.c index 6d6c5f24a1c..909dc681ebe 100644 --- a/xlators/debug/error-gen/src/error-gen.c +++ b/xlators/debug/error-gen/src/error-gen.c @@ -362,7 +362,8 @@ error_gen (xlator_t *this, int op_no) rand_no = 0; ret = error_no_list[op_no].error_no[rand_no]; } - egp->failure_iter_no = 3 + (rand () % GF_UNIVERSAL_ANSWER); + if (egp->random_failure == _gf_true) + egp->failure_iter_no = 3 + (rand () % GF_UNIVERSAL_ANSWER); } return ret; } @@ -1871,6 +1872,7 @@ init (xlator_t *this) data_t *error_no = NULL; data_t *failure_percent = NULL; data_t *enable = NULL; + gf_boolean_t random_failure = _gf_false; int32_t ret = 0; char *error_enable_fops = NULL; char *op_no_str = NULL; @@ -1953,6 +1955,11 @@ init (xlator_t *this) } } } + + random_failure = dict_get_str_boolean (this->options, "random-failure", + _gf_false); + pvt->random_failure = random_failure; + this->private = pvt; /* Give some seed value here */ @@ -2036,6 +2043,8 @@ struct volume_options options[] = { "ENODEV","EXDEV","EMFILE","ENFILE","ENOSYS","EINTR", "EFBIG","EAGAIN"}, .type = GF_OPTION_TYPE_STR }, + { .key = {"random-failure"}, + .type = GF_OPTION_TYPE_BOOL}, { .key = {"enable"}, .type = GF_OPTION_TYPE_STR }, { .key = {NULL} } diff --git a/xlators/debug/error-gen/src/error-gen.h b/xlators/debug/error-gen/src/error-gen.h index bd92aad6a80..bb3adb2ab98 100644 --- a/xlators/debug/error-gen/src/error-gen.h +++ b/xlators/debug/error-gen/src/error-gen.h @@ -34,6 +34,7 @@ typedef struct { int op_count; int failure_iter_no; char *error_no; + gf_boolean_t random_failure; gf_lock_t lock; } eg_t; |