index 9dc157068183b49c2e2c4e1e74276bcccee9c064..baecf8053d1986576ee2cd4b42e7bcad3e010248 100644 (file)
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "core/store.h"
-#include "libsysdb_test.h"
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif
-#include <assert.h>
+#include "core/plugin.h"
+#include "core/store.h"
+#include "testutils.h"
#include <check.h>
#include <stdlib.h>
#include <check.h>
#include <stdlib.h>
+/* Make SDB_INTERVAL_SECOND a constant initializer. */
+#undef SDB_INTERVAL_SECOND
+#define SDB_INTERVAL_SECOND 1000000000L
+
static void
populate(void)
{
sdb_data_t datum;
static void
populate(void)
{
sdb_data_t datum;
- sdb_store_host("h1", 1);
- sdb_store_host("h2", 3);
+ sdb_store_init();
+
+ 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";
datum.type = SDB_TYPE_STRING;
datum.data.string = "v1";
- sdb_store_attribute("h1", "k1", &datum, 1);
+ sdb_plugin_store_attribute("h1", "k1", &datum, 1 * SDB_INTERVAL_SECOND);
datum.data.string = "v2";
datum.data.string = "v2";
- sdb_store_attribute("h1", "k2", &datum, 2);
+ sdb_plugin_store_attribute("h1", "k2", &datum, 2 * SDB_INTERVAL_SECOND);
datum.data.string = "v3";
datum.data.string = "v3";
- sdb_store_attribute("h1", "k3", &datum, 2);
+ sdb_plugin_store_attribute("h1", "k3", &datum, 2 * SDB_INTERVAL_SECOND);
/* make sure that older updates don't overwrite existing values */
datum.data.string = "fail";
/* make sure that older updates don't overwrite existing values */
datum.data.string = "fail";
- sdb_store_attribute("h1", "k2", &datum, 1);
- sdb_store_attribute("h1", "k3", &datum, 2);
+ sdb_plugin_store_attribute("h1", "k2", &datum, 1 * SDB_INTERVAL_SECOND);
+ sdb_plugin_store_attribute("h1", "k3", &datum, 2 * SDB_INTERVAL_SECOND);
- sdb_store_metric("h1", "m1", /* store */ NULL, 2);
- sdb_store_metric("h1", "m2", /* store */ NULL, 1);
- sdb_store_metric("h2", "m1", /* store */ NULL, 1);
+ 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);
- sdb_store_service("h2", "s1", 1);
- sdb_store_service("h2", "s2", 2);
+ sdb_plugin_store_service("h2", "s1", 1 * SDB_INTERVAL_SECOND);
+ sdb_plugin_store_service("h2", "s2", 2 * SDB_INTERVAL_SECOND);
datum.type = SDB_TYPE_INTEGER;
datum.data.integer = 42;
datum.type = SDB_TYPE_INTEGER;
datum.data.integer = 42;
- sdb_store_metric_attr("h1", "m1", "k3", &datum, 2);
+ sdb_plugin_store_metric_attribute("h1", "m1", "k3",
+ &datum, 2 * SDB_INTERVAL_SECOND);
datum.data.integer = 123;
datum.data.integer = 123;
- sdb_store_service_attr("h2", "s2", "k1", &datum, 2);
+ sdb_plugin_store_service_attribute("h2", "s2", "k1",
+ &datum, 2 * SDB_INTERVAL_SECOND);
datum.data.integer = 4711;
datum.data.integer = 4711;
- sdb_store_service_attr("h2", "s2", "k2", &datum, 1);
+ sdb_plugin_store_service_attribute("h2", "s2", "k2",
+ &datum, 1 * SDB_INTERVAL_SECOND);
/* don't overwrite k1 */
datum.data.integer = 666;
/* don't overwrite k1 */
datum.data.integer = 666;
- sdb_store_service_attr("h2", "s2", "k1", &datum, 2);
+ sdb_plugin_store_service_attribute("h2", "s2", "k1",
+ &datum, 2 * SDB_INTERVAL_SECOND);
} /* populate */
static int
} /* populate */
static int
struct {
struct {
struct {
struct {
- sdb_store_matcher_t *(*m)(sdb_store_expr_t *,
- sdb_store_expr_t *);
+ sdb_store_matcher_t *(*m)(sdb_store_expr_t *, sdb_store_expr_t *);
int field;
sdb_data_t value;
} filter;
int field;
sdb_data_t value;
} filter;
{ { NULL, 0, SDB_DATA_INIT },
SDB_HOST, scan_tojson_full,
"["
{ { NULL, 0, SDB_DATA_INIT },
SDB_HOST, scan_tojson_full,
"["
- "{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:01 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"attributes\": ["
"{\"name\": \"k1\", \"value\": \"v1\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"attributes\": ["
"{\"name\": \"k1\", \"value\": \"v1\", "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"k2\", \"value\": \"v2\", "
"\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"k2\", \"value\": \"v2\", "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"k3\", \"value\": \"v3\", "
"\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"k3\", \"value\": \"v3\", "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []}"
"], "
"\"metrics\": ["
"{\"name\": \"m1\", "
"\"timeseries\": false, "
"\"update_interval\": \"0s\", \"backends\": []}"
"], "
"\"metrics\": ["
"{\"name\": \"m1\", "
"\"timeseries\": false, "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"attributes\": ["
"\"update_interval\": \"0s\", \"backends\": [], "
"\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h1\", "
+ "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"k3\", \"value\": 42, "
"{\"name\": \"k3\", \"value\": 42, "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []}"
"]},"
"{\"name\": \"m2\", "
"\"timeseries\": false, "
"\"update_interval\": \"0s\", \"backends\": []}"
"]},"
"{\"name\": \"m2\", "
"\"timeseries\": false, "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\", \"backends\": []}"
+ "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": [], "
+ "\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h1\", "
+ "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []}"
+ "]}"
"]},"
"]},"
- "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:03 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"metrics\": ["
"{\"name\": \"m1\", "
"\"timeseries\": false, "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"metrics\": ["
"{\"name\": \"m1\", "
"\"timeseries\": false, "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\", \"backends\": []}"
+ "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": [], "
+ "\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h2\", "
+ "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []}"
+ "]}"
"], "
"\"services\": ["
"{\"name\": \"s1\", "
"], "
"\"services\": ["
"{\"name\": \"s1\", "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\", \"backends\": []},"
+ "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": [], "
+ "\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h2\", "
+ "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []}"
+ "]},"
"{\"name\": \"s2\", "
"{\"name\": \"s2\", "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"attributes\": ["
"\"update_interval\": \"0s\", \"backends\": [], "
"\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h2\", "
+ "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"k1\", \"value\": 123, "
"{\"name\": \"k1\", \"value\": 123, "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"k2\", \"value\": 4711, "
"\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"k2\", \"value\": 4711, "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []}"
"]}"
"]}"
"\"update_interval\": \"0s\", \"backends\": []}"
"]}"
"]}"
{ { NULL, 0, SDB_DATA_INIT },
SDB_HOST, scan_tojson,
"["
{ { NULL, 0, SDB_DATA_INIT },
SDB_HOST, scan_tojson,
"["
- "{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:01 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []},"
"\"update_interval\": \"0s\", \"backends\": []},"
- "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:03 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []}"
"]" },
{ { sdb_store_eq_matcher, SDB_FIELD_NAME,
{ SDB_TYPE_STRING, { .string = "h1" } } },
SDB_HOST, scan_tojson_full,
"["
"\"update_interval\": \"0s\", \"backends\": []}"
"]" },
{ { sdb_store_eq_matcher, SDB_FIELD_NAME,
{ SDB_TYPE_STRING, { .string = "h1" } } },
SDB_HOST, scan_tojson_full,
"["
- "{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:01 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []}"
"]" },
{ { sdb_store_gt_matcher, SDB_FIELD_LAST_UPDATE,
"\"update_interval\": \"0s\", \"backends\": []}"
"]" },
{ { sdb_store_gt_matcher, SDB_FIELD_LAST_UPDATE,
- { SDB_TYPE_DATETIME, { .datetime = 1 } } },
+ { SDB_TYPE_DATETIME, { .datetime = 1 * SDB_INTERVAL_SECOND } } },
SDB_HOST, scan_tojson_full,
"["
SDB_HOST, scan_tojson_full,
"["
- "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:03 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"services\": ["
"{\"name\": \"s2\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"services\": ["
"{\"name\": \"s2\", "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"attributes\": ["
"\"update_interval\": \"0s\", \"backends\": [], "
"\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h2\", "
+ "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"k1\", \"value\": 123, "
"{\"name\": \"k1\", \"value\": 123, "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []}"
"]}"
"]}"
"]" },
{ { sdb_store_le_matcher, SDB_FIELD_LAST_UPDATE,
"\"update_interval\": \"0s\", \"backends\": []}"
"]}"
"]}"
"]" },
{ { sdb_store_le_matcher, SDB_FIELD_LAST_UPDATE,
- { SDB_TYPE_DATETIME, { .datetime = 1 } } },
+ { SDB_TYPE_DATETIME, { .datetime = 1 * SDB_INTERVAL_SECOND } } },
SDB_HOST, scan_tojson_full,
"["
SDB_HOST, scan_tojson_full,
"["
- "{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:01 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"attributes\": ["
"{\"name\": \"k1\", \"value\": \"v1\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"attributes\": ["
"{\"name\": \"k1\", \"value\": \"v1\", "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []}"
"], "
"\"metrics\": ["
"{\"name\": \"m2\", "
"\"timeseries\": false, "
"\"update_interval\": \"0s\", \"backends\": []}"
"], "
"\"metrics\": ["
"{\"name\": \"m2\", "
"\"timeseries\": false, "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\", \"backends\": []}"
+ "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": [], "
+ "\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h1\", "
+ "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []}"
+ "]}"
"]}"
"]" },
{ { sdb_store_ge_matcher, SDB_FIELD_LAST_UPDATE,
"]}"
"]" },
{ { sdb_store_ge_matcher, SDB_FIELD_LAST_UPDATE,
- { SDB_TYPE_DATETIME, { .datetime = 3 } } },
+ { SDB_TYPE_DATETIME, { .datetime = 3 * SDB_INTERVAL_SECOND } } },
SDB_HOST, scan_tojson_full,
"["
SDB_HOST, scan_tojson_full,
"["
- "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:03 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []}"
"]" },
{ { sdb_store_lt_matcher, SDB_FIELD_LAST_UPDATE,
"\"update_interval\": \"0s\", \"backends\": []}"
"]" },
{ { sdb_store_lt_matcher, SDB_FIELD_LAST_UPDATE,
{ { NULL, 0, SDB_DATA_INIT },
SDB_SERVICE, scan_tojson_full,
"["
{ { NULL, 0, SDB_DATA_INIT },
SDB_SERVICE, scan_tojson_full,
"["
- "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:03 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"services\": ["
"{\"name\": \"s1\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"services\": ["
"{\"name\": \"s1\", "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\", \"backends\": []},"
+ "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": [], "
+ "\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h2\", "
+ "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []}"
+ "]},"
"{\"name\": \"s2\", "
"{\"name\": \"s2\", "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"attributes\": ["
"\"update_interval\": \"0s\", \"backends\": [], "
"\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h2\", "
+ "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"k1\", \"value\": 123, "
"{\"name\": \"k1\", \"value\": 123, "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"k2\", \"value\": 4711, "
"\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"k2\", \"value\": 4711, "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []}"
"]}"
"]}"
"\"update_interval\": \"0s\", \"backends\": []}"
"]}"
"]}"
{ { NULL, 0, SDB_DATA_INIT },
SDB_SERVICE, scan_tojson,
"["
{ { NULL, 0, SDB_DATA_INIT },
SDB_SERVICE, scan_tojson,
"["
- "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:03 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"services\": ["
"{\"name\": \"s1\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"services\": ["
"{\"name\": \"s1\", "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"s2\", "
"\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"s2\", "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []}"
"]}"
"]" },
{ { sdb_store_gt_matcher, SDB_FIELD_LAST_UPDATE,
"\"update_interval\": \"0s\", \"backends\": []}"
"]}"
"]" },
{ { sdb_store_gt_matcher, SDB_FIELD_LAST_UPDATE,
- { SDB_TYPE_DATETIME, { .datetime = 1 } } },
+ { SDB_TYPE_DATETIME, { .datetime = 1 * SDB_INTERVAL_SECOND } } },
SDB_SERVICE, scan_tojson_full,
"["
SDB_SERVICE, scan_tojson_full,
"["
- "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:03 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"services\": ["
"{\"name\": \"s2\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"services\": ["
"{\"name\": \"s2\", "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"attributes\": ["
"\"update_interval\": \"0s\", \"backends\": [], "
"\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h2\", "
+ "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"k1\", \"value\": 123, "
"{\"name\": \"k1\", \"value\": 123, "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []}"
"]}"
"]}"
"\"update_interval\": \"0s\", \"backends\": []}"
"]}"
"]}"
{ { NULL, 0, SDB_DATA_INIT },
SDB_METRIC, scan_tojson_full,
"["
{ { NULL, 0, SDB_DATA_INIT },
SDB_METRIC, scan_tojson_full,
"["
- "{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:01 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"metrics\": ["
"{\"name\": \"m1\", "
"\"timeseries\": false, "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"metrics\": ["
"{\"name\": \"m1\", "
"\"timeseries\": false, "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"attributes\": ["
"\"update_interval\": \"0s\", \"backends\": [], "
"\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h1\", "
+ "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"k3\", \"value\": 42, "
"{\"name\": \"k3\", \"value\": 42, "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []}"
"]},"
"{\"name\": \"m2\", "
"\"timeseries\": false, "
"\"update_interval\": \"0s\", \"backends\": []}"
"]},"
"{\"name\": \"m2\", "
"\"timeseries\": false, "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\", \"backends\": []}"
+ "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": [], "
+ "\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h1\", "
+ "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []}"
+ "]}"
"]},"
"]},"
- "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:03 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"metrics\": ["
"{\"name\": \"m1\", "
"\"timeseries\": false, "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"metrics\": ["
"{\"name\": \"m1\", "
"\"timeseries\": false, "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\", \"backends\": []}"
+ "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": [], "
+ "\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h2\", "
+ "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []}"
+ "]}"
"]}"
"]" },
{ { NULL, 0, SDB_DATA_INIT },
SDB_METRIC, scan_tojson,
"["
"]}"
"]" },
{ { NULL, 0, SDB_DATA_INIT },
SDB_METRIC, scan_tojson,
"["
- "{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:01 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"metrics\": ["
"{\"name\": \"m1\", "
"\"timeseries\": false, "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"metrics\": ["
"{\"name\": \"m1\", "
"\"timeseries\": false, "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"last_update\": \"1970-01-01 00:00:02 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"m2\", "
"\"timeseries\": false, "
"\"update_interval\": \"0s\", \"backends\": []},"
"{\"name\": \"m2\", "
"\"timeseries\": false, "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []}"
"]},"
"\"update_interval\": \"0s\", \"backends\": []}"
"]},"
- "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:03 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"metrics\": ["
"{\"name\": \"m1\", "
"\"timeseries\": false, "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"metrics\": ["
"{\"name\": \"m1\", "
"\"timeseries\": false, "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []}"
"]}"
"]" },
{ { sdb_store_le_matcher, SDB_FIELD_LAST_UPDATE,
"\"update_interval\": \"0s\", \"backends\": []}"
"]}"
"]" },
{ { sdb_store_le_matcher, SDB_FIELD_LAST_UPDATE,
- { SDB_TYPE_DATETIME, { .datetime = 1 } } },
+ { SDB_TYPE_DATETIME, { .datetime = 1 * SDB_INTERVAL_SECOND } } },
SDB_METRIC, scan_tojson_full,
"["
SDB_METRIC, scan_tojson_full,
"["
- "{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
+ "{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:01 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"metrics\": ["
"{\"name\": \"m2\", "
"\"timeseries\": false, "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"metrics\": ["
"{\"name\": \"m2\", "
"\"timeseries\": false, "
- "\"last_update\": \"1970-01-01 00:00:00 +0000\", "
- "\"update_interval\": \"0s\", \"backends\": []}"
+ "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": [], "
+ "\"attributes\": ["
+ "{\"name\": \"hostname\", \"value\": \"h1\", "
+ "\"last_update\": \"1970-01-01 00:00:01 +0000\", "
+ "\"update_interval\": \"0s\", \"backends\": []}"
+ "]}"
"]}"
"]" },
{ { sdb_store_lt_matcher, SDB_FIELD_LAST_UPDATE,
"]}"
"]" },
{ { sdb_store_lt_matcher, SDB_FIELD_LAST_UPDATE,
sdb_strbuf_clear(buf);
f = sdb_store_json_formatter(buf,
store_tojson_data[_i].type, SDB_WANT_ARRAY);
sdb_strbuf_clear(buf);
f = sdb_store_json_formatter(buf,
store_tojson_data[_i].type, SDB_WANT_ARRAY);
- assert(f);
+ ck_assert(f != NULL);
status = sdb_store_scan(store_tojson_data[_i].type,
/* m = */ NULL, filter, store_tojson_data[_i].f, f);
status = sdb_store_scan(store_tojson_data[_i].type,
/* m = */ NULL, filter, store_tojson_data[_i].f, f);
}
END_TEST
}
END_TEST
-Suite *
-core_store_json_suite(void)
+TEST_MAIN("core::store_json")
{
{
- Suite *s = suite_create("core::store_json");
- TCase *tc;
-
- tc = tcase_create("core");
+ TCase *tc = tcase_create("core");
TC_ADD_LOOP_TEST(tc, store_tojson);
tcase_add_unchecked_fixture(tc, populate, sdb_store_clear);
TC_ADD_LOOP_TEST(tc, store_tojson);
tcase_add_unchecked_fixture(tc, populate, sdb_store_clear);
- suite_add_tcase(s, tc);
-
- return s;
-} /* core_store_json_suite */
+ ADD_TCASE(tc);
+}
+TEST_MAIN_END
/* vim: set tw=78 sw=4 ts=4 noexpandtab : */
/* vim: set tw=78 sw=4 ts=4 noexpandtab : */