summaryrefslogtreecommitdiffstats
path: root/tests/utils/changelog/get-history.c
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2018-08-21 06:09:44 -0400
committerShyamsundar Ranganathan <srangana@redhat.com>2018-09-21 13:25:59 +0000
commitbbab048f0a06c34656c2c11c3cec4f2dd9883037 (patch)
treee1e453ecc35333a17707c11f4552746c67bd701a /tests/utils/changelog/get-history.c
parente50a6ee2c913b5b4df53f0efca4de66c5262d1e1 (diff)
libgfchangelog: Fix changelog history API
Problem: If requested start time and end time doesn't fall into first HTIME file, then history API fails even though continuous changelogs are avaiable for the requested range in other HTIME files. This is induced by changelog disable and enable which creates fresh HTIME index file. Cause and Analysis: Each HTIME index file represents the availability of continuous changelogs. If changelog is disabled and enabled, a new HTIME index file is created represents non availability of continuous changelogs. So as long as the requested start and end falls into single HTIME index file and not across, history API should succeed. But History API checks for the changelogs only in first HTIME index file and errors out if not available. Fix: Check in all HTIME index files for availability of continuous changelogs for requested change. Backport of: > Patch: https://review.gluster.org/21016/ > BUG: bz#1622549 > Change-Id: I80eeceb5afbd1b89f86a9dc4c320e161907d3559 > Signed-off-by: Kotresh HR <khiremat@redhat.com> (cherry picked from commit 35aa67001c8fac99b040fbc61f36ef4f1b1590ac) fixes: bz#1630141 Change-Id: I80eeceb5afbd1b89f86a9dc4c320e161907d3559 Signed-off-by: Kotresh HR <khiremat@redhat.com>
Diffstat (limited to 'tests/utils/changelog/get-history.c')
-rw-r--r--tests/utils/changelog/get-history.c73
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/utils/changelog/get-history.c b/tests/utils/changelog/get-history.c
new file mode 100644
index 00000000000..29dc60987ae
--- /dev/null
+++ b/tests/utils/changelog/get-history.c
@@ -0,0 +1,73 @@
+/*
+ Copyright (c) 2013 Red Hat, Inc. <http://www.redhat.com>
+ This file is part of GlusterFS.
+
+ This file is licensed to you under your choice of the GNU Lesser
+ General Public License, version 3 or any later version (LGPLv3 or
+ later), or the GNU General Public License, version 2 (GPLv2), in all
+ cases as published by the Free Software Foundation.
+*/
+
+/**
+ * get set of new changes every 10 seconds (just print the file names)
+ *
+ * Compile it using:
+ * gcc -o gethistory `pkg-config --cflags libgfchangelog` get-history.c \
+ * `pkg-config --libs libgfchangelog`
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/un.h>
+#include <limits.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+
+#include "changelog.h"
+
+int
+main (int argc, char **argv)
+{
+ int ret = 0;
+ unsigned long end_ts = 0;
+ int start = 0;
+ int end = 0;
+
+ ret = gf_changelog_init (NULL);
+ if (ret) {
+ printf ("-1");
+ fflush(stdout);
+ return -1;
+ }
+
+ ret = gf_changelog_register ("/d/backends/patchy0",
+ "/tmp/scratch_v1",
+ "/var/log/glusterfs/changes.log",
+ 9, 5);
+ if (ret) {
+ printf ("-2");
+ fflush(stdout);
+ return -1;
+ }
+
+ start = atoi(argv[1]);
+ end = atoi(argv[2]);
+
+ ret = gf_history_changelog ("/d/backends/patchy0/.glusterfs/changelogs",
+ start, end, 3, &end_ts);
+ if (ret < 0) {
+ printf ("-3");
+ fflush(stdout);
+ return -1;
+ } else if (ret == 1) {
+ printf ("1");
+ fflush(stdout);
+ return 0;
+ }
+
+out:
+ printf ("0");
+ fflush(stdout);
+ return 0;
+}