X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=t%2Fintegration%2Fmock_plugin.c;h=5a9718de9d7c0d2698e977a8033096673a8027ea;hb=967d9181f6329ca00b910c0c458b1c6b60f2a0d6;hp=459a7e2de61f0ebda8670f22e253831402be7127;hpb=d3db3ba2620c4673f263ac997398d03056ca7b94;p=sysdb.git diff --git a/t/integration/mock_plugin.c b/t/integration/mock_plugin.c index 459a7e2..5a9718d 100644 --- a/t/integration/mock_plugin.c +++ b/t/integration/mock_plugin.c @@ -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; @@ -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()))) { @@ -183,9 +215,9 @@ mock_config(oconfig_item_t *ci) exit(1); } - sdb_plugin_register_init("mock::init", mock_init, user_data); - sdb_plugin_register_shutdown("mock::shutdown", mock_shutdown, user_data); - sdb_plugin_register_collector("mock::collect", mock_collect, + sdb_plugin_register_init("main", mock_init, user_data); + sdb_plugin_register_shutdown("main", mock_shutdown, user_data); + sdb_plugin_register_collector("main", mock_collect, /* interval = */ NULL, user_data); sdb_object_deref(user_data); @@ -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 "); @@ -203,7 +234,7 @@ sdb_module_init(sdb_plugin_info_t *info) sdb_plugin_set_info(info, SDB_PLUGIN_INFO_VERSION, SDB_VERSION); sdb_plugin_set_info(info, SDB_PLUGIN_INFO_PLUGIN_VERSION, SDB_VERSION); - sdb_plugin_register_config("test::integration::mock", mock_config); + sdb_plugin_register_config(mock_config); return 0; } /* sdb_module_init */