index 8047b2668bae56b596d4cc6e2067c40d930408f6..5330999c2d091e9828b00dc9d0c01fb1509b810a 100644 (file)
# include "config.h"
#endif
+#include "core/plugin.h"
#include "frontend/connection.h"
#include "frontend/connection-private.h"
#include "testutils.h"
static void
populate(void)
{
+ sdb_store_t *store;
sdb_data_t datum;
- sdb_store_host("h1", 1 * SDB_INTERVAL_SECOND);
- sdb_store_host("h2", 3 * SDB_INTERVAL_SECOND);
+ /* the frontend accesses the store via the plugin API */
+ store = sdb_store_create();
+ ck_assert(store != NULL);
+ ck_assert(sdb_plugin_register_writer("test-writer",
+ &sdb_store_writer, SDB_OBJ(store)) == 0);
+ ck_assert(sdb_plugin_register_reader("test-reader",
+ &sdb_store_reader, SDB_OBJ(store)) == 0);
+ sdb_object_deref(SDB_OBJ(store));
+
+ /* populate the store */
+ sdb_plugin_store_host("h1", 1 * SDB_INTERVAL_SECOND);
+ sdb_plugin_store_host("h2", 3 * SDB_INTERVAL_SECOND);
datum.type = SDB_TYPE_STRING;
datum.data.string = "v1";
- sdb_store_attribute("h1", "k1", &datum, 1 * SDB_INTERVAL_SECOND);
+ sdb_plugin_store_attribute("h1", "k1", &datum, 1 * SDB_INTERVAL_SECOND);
datum.data.string = "v2";
- sdb_store_attribute("h1", "k2", &datum, 2 * SDB_INTERVAL_SECOND);
+ sdb_plugin_store_attribute("h1", "k2", &datum, 2 * SDB_INTERVAL_SECOND);
datum.data.string = "v3";
- sdb_store_attribute("h1", "k3", &datum, 2 * SDB_INTERVAL_SECOND);
+ sdb_plugin_store_attribute("h1", "k3", &datum, 2 * SDB_INTERVAL_SECOND);
- sdb_store_metric("h1", "m1", /* store */ NULL, 2 * SDB_INTERVAL_SECOND);
- sdb_store_metric("h1", "m2", /* store */ NULL, 1 * SDB_INTERVAL_SECOND);
- sdb_store_metric("h2", "m1", /* store */ NULL, 1 * SDB_INTERVAL_SECOND);
+ sdb_plugin_store_metric("h1", "m1", /* store */ NULL, 2 * SDB_INTERVAL_SECOND);
+ sdb_plugin_store_metric("h1", "m2", /* store */ NULL, 1 * SDB_INTERVAL_SECOND);
+ sdb_plugin_store_metric("h2", "m1", /* store */ NULL, 1 * SDB_INTERVAL_SECOND);
datum.type = SDB_TYPE_INTEGER;
datum.data.integer = 42;
- sdb_store_metric_attr("h1", "m1", "k3", &datum, 2 * SDB_INTERVAL_SECOND);
+ sdb_plugin_store_metric_attribute("h1", "m1", "k3",
+ &datum, 2 * SDB_INTERVAL_SECOND);
- sdb_store_service("h2", "s1", 1 * SDB_INTERVAL_SECOND);
- sdb_store_service("h2", "s2", 2 * SDB_INTERVAL_SECOND);
+ sdb_plugin_store_service("h2", "s1", 1 * SDB_INTERVAL_SECOND);
+ sdb_plugin_store_service("h2", "s2", 2 * SDB_INTERVAL_SECOND);
datum.data.integer = 123;
- sdb_store_service_attr("h2", "s2", "k1", &datum, 2 * SDB_INTERVAL_SECOND);
+ sdb_plugin_store_service_attribute("h2", "s2", "k1",
+ &datum, 2 * SDB_INTERVAL_SECOND);
datum.data.integer = 4711;
- sdb_store_service_attr("h2", "s2", "k2", &datum, 1 * SDB_INTERVAL_SECOND);
+ sdb_plugin_store_service_attribute("h2", "s2", "k2",
+ &datum, 1 * SDB_INTERVAL_SECOND);
} /* populate */
+static void
+turndown(void)
+{
+ sdb_plugin_unregister_all();
+} /* turndown */
+
#define HOST_H1 \
"{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:01 +0000\", " \
"\"update_interval\": \"0s\", \"backends\": [], " \
TEST_MAIN("frontend::query")
{
TCase *tc = tcase_create("core");
- tcase_add_checked_fixture(tc, populate, sdb_store_clear);
+ tcase_add_checked_fixture(tc, populate, turndown);
TC_ADD_LOOP_TEST(tc, query);
ADD_TCASE(tc);
}