Code

integration tests: Added simple tests for service and metric queries.
[sysdb.git] / t / integration / mock_plugin.c
index 8dcb410af3492a0da588c6ba56f5cc7c3b5ddfaf..8c161943617f58db39f195df1b87b7589941bc3b 100644 (file)
@@ -51,6 +51,20 @@ static const char *hostnames[] = {
        "localhost",
 };
 
+static struct {
+       const char *hostname;
+       const char *metric;
+} metrics[] = {
+       { "some.host.name", "foo/bar/qux" },
+       { "some.host.name", "foo/bar/baz" },
+       { "some.host.name", "foo2/bar/qux" },
+       { "some.host.name", "foo2/bar/baz" },
+       { "other.host.name", "foo/bar/qux" },
+       { "other.host.name", "foo/bar/baz" },
+       { "other.host.name", "foo2/bar/qux" },
+       { "other.host.name", "foo2/bar/baz" },
+};
+
 static struct {
        const char *hostname;
        const char *service;
@@ -136,6 +150,14 @@ 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, 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()))) {