summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 074f1b4)
raw | patch | inline | side by side (parent: 074f1b4)
author | Sebastian Harl <sh@tokkee.org> | |
Fri, 16 Jan 2015 20:22:06 +0000 (21:22 +0100) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Fri, 16 Jan 2015 20:22:06 +0000 (21:22 +0100) |
index 3bdb10490915912190c4e7b46070a6342e6de6b4..b25e9502988bf310664b4f39365e22c39e1146df 100755 (executable)
--- a/t/integration/config.sh
+++ b/t/integration/config.sh
stop_sysdbd
+# vim: set tw=78 sw=4 ts=4 noexpandtab :
index da75b9aa5312bbe7ae50dfe2085efcd1c8b78cbe..ddcf78532bbee17d85852c367b95f0155a15ab14 100755 (executable)
--- a/t/integration/filter.sh
+++ b/t/integration/filter.sh
stop_sysdbd
+# vim: set tw=78 sw=4 ts=4 noexpandtab :
index 8b25ed3cc062627115f32bdb45e62abde3a54b66..34e7c549b9005a067bb9f643981e749089614f03 100755 (executable)
stop_sysdbd
+# vim: set tw=78 sw=4 ts=4 noexpandtab :
index 1fb59fc1f39dbca0b248cbf3ab28ef236c92c3c5..8041c0dfab9a4e1af2b5132d886528642ec5c27d 100644 (file)
sdb_metric_store_t store;
} metrics[] = {
{ "some.host.name", "foo/bar/qux",
- { "dummy", "/var/lib/collectd/rrd/foo/bar/qux.rrd" } },
+ { "mock", "/var/lib/collectd/rrd/foo/bar/qux.rrd" } },
{ "some.host.name", "foo/bar/baz",
- { "dummy", "/var/lib/collectd/rrd/foo/bar/baz.rrd" } },
+ { "mock", "/var/lib/collectd/rrd/foo/bar/baz.rrd" } },
{ "some.host.name", "foo2/bar/qux",
- { "dummy", "/var/lib/collectd/rrd/foo2/bar/qux.rrd" } },
+ { "mock", "/var/lib/collectd/rrd/foo2/bar/qux.rrd" } },
{ "some.host.name", "foo2/bar/baz",
- { "dummy", "/var/lib/collectd/rrd/foo2/bar/baz.rrd" } },
+ { "mock", "/var/lib/collectd/rrd/foo2/bar/baz.rrd" } },
{ "other.host.name", "foo/bar/qux",
- { "dummy", "/var/lib/collectd/rrd/foo/bar/qux.rrd" } },
+ { "mock", "/var/lib/collectd/rrd/foo/bar/qux.rrd" } },
{ "other.host.name", "foo/bar/baz",
- { "dummy", "/var/lib/collectd/rrd/foo/bar/baz.rrd" } },
+ { "mock", "/var/lib/collectd/rrd/foo/bar/baz.rrd" } },
{ "other.host.name", "foo2/bar/qux",
- { "dummy", "/var/lib/collectd/rrd/foo2/bar/qux.rrd" } },
+ { "mock", "/var/lib/collectd/rrd/foo2/bar/qux.rrd" } },
{ "other.host.name", "foo2/bar/baz",
- { "dummy", "/var/lib/collectd/rrd/foo2/bar/baz.rrd" } },
+ { "mock", "/var/lib/collectd/rrd/foo2/bar/baz.rrd" } },
};
static struct {
return 0;
} /* mock_collect */
+static sdb_timeseries_t *
+mock_fetch_ts(const char *id, sdb_timeseries_opts_t *opts,
+ sdb_object_t *user_data)
+{
+ sdb_timeseries_t *ts;
+ const char *names[] = { "nameA", "nameB" };
+ size_t i, j;
+
+ if (*id != '/') {
+ sdb_log(SDB_LOG_ERR, "mock::plugin: Invalid time-series %s", id);
+ exit(1);
+ }
+
+ if (SDB_OBJ_WRAPPER(user_data)->data != MAGIC_DATA) {
+ sdb_log(SDB_LOG_ERR, "mock::plugin: Invalid user data %p "
+ "passed to collect", SDB_OBJ_WRAPPER(user_data)->data);
+ exit(1);
+ }
+
+ ts = sdb_timeseries_create(SDB_STATIC_ARRAY_LEN(names), names, 10);
+ if (! ts)
+ return NULL;
+
+ ts->start = opts->start;
+ ts->end = opts->end;
+
+ for (i = 0; i < 10; ++i) {
+ for (j = 0; j < SDB_STATIC_ARRAY_LEN(names); ++j) {
+ ts->data[j][i].timestamp = ts->start
+ + i * (ts->end - ts->start) / 10;
+ ts->data[j][i].value = (double)(i + j);
+ }
+ }
+ return ts;
+} /* mock_fetch_ts */
+
static int
mock_config(oconfig_item_t *ci)
{
sdb_plugin_register_collector("main", mock_collect,
/* interval = */ NULL, user_data);
+ sdb_plugin_register_ts_fetcher("mock", mock_fetch_ts, user_data);
+
sdb_object_deref(user_data);
return 0;
} /* mock_config */
diff --git a/t/integration/query.sh b/t/integration/query.sh
index eb4ccd8814771f058f6a9a357f1b669f5803b5e5..b2e6ed82a644074cb3745b58b3d45e388a471313 100755 (executable)
--- a/t/integration/query.sh
+++ b/t/integration/query.sh
-c "TIMESERIES 'invalid.host'.'invalid-metric'" && exit 1
# Does not work yet since there is no fetcher plugin.
-run_sysdb -H "$SOCKET_FILE" \
- -c "TIMESERIES 'some.host.name'.'foo/bar/qux'" && exit 1
+output="$( run_sysdb -H "$SOCKET_FILE" \
+ -c "TIMESERIES 'some.host.name'.'foo/bar/qux'" )"
+echo "$output" \
+ | grep -F '"value": "1.000000"' \
+ | grep -F '"value": "2.000000"' \
+ | grep -F '"value": "3.000000"' \
+ | grep -F '"value": "4.000000"' \
+ | grep -F '"value": "5.000000"' \
+ | grep -F '"value": "6.000000"' \
+ | grep -F '"value": "7.000000"' \
+ | grep -F '"value": "8.000000"' \
+ | grep -F '"value": "9.000000"' \
+ | grep -F '"value": "10.000000"'
stop_sysdbd
+# vim: set tw=78 sw=4 ts=4 noexpandtab :
index f6898e4678a9359e7e3b78949e095f8d2f36e9fc..8206ddfd5d21bad444dbf3a40b395556ebd59a02 100644 (file)
fi
}
+# vim: set tw=78 sw=4 ts=4 noexpandtab :