Code

Replaced sdb_store_<type> with sdb_plugin_store_<type>.
[sysdb.git] / t / integration / mock_plugin.c
index 8dcb410af3492a0da588c6ba56f5cc7c3b5ddfaf..87c86a84f08d4f896ca50d79cc6c38d7879b8367 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",
+               { "mock", "/var/lib/collectd/rrd/foo/bar/qux.rrd" } },
+       { "some.host.name", "foo/bar/baz",
+               { "mock", "/var/lib/collectd/rrd/foo/bar/baz.rrd" } },
+       { "some.host.name", "foo2/bar/qux",
+               { "mock", "/var/lib/collectd/rrd/foo2/bar/qux.rrd" } },
+       { "some.host.name", "foo2/bar/baz",
+               { "mock", "/var/lib/collectd/rrd/foo2/bar/baz.rrd" } },
+       { "other.host.name", "foo/bar/qux",
+               { "mock", "/var/lib/collectd/rrd/foo/bar/qux.rrd" } },
+       { "other.host.name", "foo/bar/baz",
+               { "mock", "/var/lib/collectd/rrd/foo/bar/baz.rrd" } },
+       { "other.host.name", "foo2/bar/qux",
+               { "mock", "/var/lib/collectd/rrd/foo2/bar/qux.rrd" } },
+       { "other.host.name", "foo2/bar/baz",
+               { "mock", "/var/lib/collectd/rrd/foo2/bar/baz.rrd" } },
+};
+
 static struct {
        const char *hostname;
        const char *service;
@@ -130,14 +153,23 @@ mock_collect(sdb_object_t *user_data)
        }
 
        for (i = 0; i < SDB_STATIC_ARRAY_LEN(hostnames); ++i) {
-               if ((check = sdb_store_host(hostnames[i], sdb_gettime()))) {
+               if ((check = sdb_plugin_store_host(hostnames[i], sdb_gettime()))) {
                        sdb_log(SDB_LOG_ERR, "mock::plugin: Failed to store host: "
                                        "status %d", check);
                        exit(1);
                }
        }
+       for (i = 0; i < SDB_STATIC_ARRAY_LEN(metrics); ++i) {
+               if ((check = sdb_plugin_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,
+               if ((check = sdb_plugin_store_service(services[i].hostname,
                                                services[i].service, sdb_gettime()))) {
                        sdb_log(SDB_LOG_ERR, "mock::plugin: Failed to store service: "
                                        "status %d", check);
@@ -148,7 +180,7 @@ mock_collect(sdb_object_t *user_data)
                sdb_data_t datum = { SDB_TYPE_STRING, { .string = NULL } };
                datum.data.string = strdup(attributes[i].value);
 
-               if ((check = sdb_store_attribute(attributes[i].hostname,
+               if ((check = sdb_plugin_store_attribute(attributes[i].hostname,
                                                attributes[i].name, &datum, sdb_gettime()))) {
                        sdb_log(SDB_LOG_ERR, "mock::plugin: Failed to store attribute: "
                                        "status %d", check);