Code

frontend/grammar: Drop support for the special 'host' field.
[sysdb.git] / t / integration / mock_plugin.c
index 2573e64765543ee4c6cc2802250083d8ed362eec..1fb59fc1f39dbca0b248cbf3ab28ef236c92c3c5 100644 (file)
@@ -51,6 +51,29 @@ static const char *hostnames[] = {
        "localhost",
 };
 
+static struct {
+       const char *hostname;
+       const char *metric;
+       sdb_metric_store_t store;
+} metrics[] = {
+       { "some.host.name", "foo/bar/qux",
+               { "dummy", "/var/lib/collectd/rrd/foo/bar/qux.rrd" } },
+       { "some.host.name", "foo/bar/baz",
+               { "dummy", "/var/lib/collectd/rrd/foo/bar/baz.rrd" } },
+       { "some.host.name", "foo2/bar/qux",
+               { "dummy", "/var/lib/collectd/rrd/foo2/bar/qux.rrd" } },
+       { "some.host.name", "foo2/bar/baz",
+               { "dummy", "/var/lib/collectd/rrd/foo2/bar/baz.rrd" } },
+       { "other.host.name", "foo/bar/qux",
+               { "dummy", "/var/lib/collectd/rrd/foo/bar/qux.rrd" } },
+       { "other.host.name", "foo/bar/baz",
+               { "dummy", "/var/lib/collectd/rrd/foo/bar/baz.rrd" } },
+       { "other.host.name", "foo2/bar/qux",
+               { "dummy", "/var/lib/collectd/rrd/foo2/bar/qux.rrd" } },
+       { "other.host.name", "foo2/bar/baz",
+               { "dummy", "/var/lib/collectd/rrd/foo2/bar/baz.rrd" } },
+};
+
 static struct {
        const char *hostname;
        const char *service;
@@ -136,6 +159,15 @@ mock_collect(sdb_object_t *user_data)
                        exit(1);
                }
        }
+       for (i = 0; i < SDB_STATIC_ARRAY_LEN(metrics); ++i) {
+               if ((check = sdb_store_metric(metrics[i].hostname,
+                                               metrics[i].metric, &metrics[i].store,
+                                               sdb_gettime()))) {
+                       sdb_log(SDB_LOG_ERR, "mock::plugin: Failed to store metric: "
+                                       "status %d", check);
+                       exit(1);
+               }
+       }
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(services); ++i) {
                if ((check = sdb_store_service(services[i].hostname,
                                                services[i].service, sdb_gettime()))) {
@@ -195,7 +227,6 @@ mock_config(oconfig_item_t *ci)
 int
 sdb_module_init(sdb_plugin_info_t *info)
 {
-       sdb_plugin_set_info(info, SDB_PLUGIN_INFO_NAME, "test::integration::mock");
        sdb_plugin_set_info(info, SDB_PLUGIN_INFO_DESC, "a mock plugin");
        sdb_plugin_set_info(info, SDB_PLUGIN_INFO_COPYRIGHT,
                        "Copyright (C) 2012 Sebastian 'tokkee' Harl <sh@tokkee.org>");