summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorchenzizhan <[email protected]>2024-07-04 16:36:32 +0800
committerchenzizhan <[email protected]>2024-07-04 16:36:32 +0800
commitef42511b52486a2b79b28b8c9cd3bb68fec2b940 (patch)
treed27d69af9c2c41f06b1db77f5e22bf1b3f449bb6 /test
parent277de12fc277f1fc050eb5b92e8958126baa08e3 (diff)
metric name set; refactor on get or add cell
Diffstat (limited to 'test')
-rw-r--r--test/test_metric_counter.cpp62
-rw-r--r--test/test_register_and_reset.cpp16
2 files changed, 8 insertions, 70 deletions
diff --git a/test/test_metric_counter.cpp b/test/test_metric_counter.cpp
index efa42ae..f0ed7bc 100644
--- a/test/test_metric_counter.cpp
+++ b/test/test_metric_counter.cpp
@@ -212,36 +212,6 @@ TEST(metric_test_counter, add_and_query_on_dummy_cell_of_topk)
fieldstat_free(instance);
}
-TEST(metric_test_counter, set_on_primary_metric_going_smaller)
-{
- struct fieldstat *instance = fieldstat_new();
- int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 10);
- int metric_id = fieldstat_register_counter(instance, "primary");
-
- int ret = fieldstat_counter_set(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 10);
- EXPECT_EQ(ret, FS_OK);
- ret = fieldstat_counter_set(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 2);
- EXPECT_EQ(ret, FS_ERR_INVALID_PARAM);
-
- fieldstat_free(instance);
-}
-
-TEST(metric_test_counter, set_on_primary_metric_going_bigger)
-{
- struct fieldstat *instance = fieldstat_new();
- int cube_id = fieldstat_create_cube(instance, &TEST_SHARED_TAG, 1, SAMPLING_MODE_TOPK, 10);
- int metric_id = fieldstat_register_counter(instance, "primary");
-
- int ret = fieldstat_counter_set(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 10);
- EXPECT_EQ(ret, FS_OK);
- ret = fieldstat_counter_set(instance, cube_id, metric_id, &TEST_TAG_INT, 1, 20);
- EXPECT_EQ(ret, FS_OK);
-
- EXPECT_EQ(my_fieldstat_counter_get(instance, cube_id, metric_id), 20);
-
- fieldstat_free(instance);
-}
-
TEST(metric_test_counter, primary_counter_add_after_first)
{
struct fieldstat *instance = fieldstat_new();
@@ -274,38 +244,6 @@ TEST(metric_test_counter, primary_counter_add_after_first)
fieldstat_free(instance);
}
-TEST(metric_test_counter, topk_set_and_test_accuracy)
-{
- struct fieldstat *instance = fieldstat_new();
- fieldstat_create_cube(instance, &TEST_TAG_INT_collided, 1, SAMPLING_MODE_TOPK, 6);
- fieldstat_register_counter(instance, "test");
-
- struct fieldstat_tag tag = TEST_TAG_INT;
- // tag : [0, 1, 2, 3, 4 ,5]
- // value: [0, 1, 2, 3, 4 ,5]
- for (int i = 0; i < 6; i++) {
- tag.value_longlong = i;
- EXPECT_EQ(fieldstat_counter_set(instance, 0, 0, &tag, 1, i), FS_OK);
- }
- // tag : [0, 1, 2, 3, 4 ,5, 6, 7, 8]
- // value: [0, 1, 2, 100, 100, 100, 100, 100, 100]
- for (int i = 0; i < 6; i++) {
- tag.value_longlong = i + 3;
- EXPECT_EQ(fieldstat_counter_set(instance, 0, 0, &tag, 1, 100), FS_OK);
- }
-
- struct fieldstat_tag_list *tag_list = NULL;
- size_t n_cell = 0;
- fieldstat_get_cells_used_by_cube(instance, 0, &tag_list, &n_cell);
- EXPECT_EQ(n_cell, 6);
- for (size_t i = 0; i < n_cell; i++) {
- EXPECT_EQ(my_fieldstat_counter_get(instance, 0, 0, &tag_list[i]), 100);
- }
-
- fieldstat_tag_list_arr_free(tag_list, n_cell);
- fieldstat_free(instance);
-}
-
int main(int argc, char *argv[])
{
testing::InitGoogleTest(&argc, argv);
diff --git a/test/test_register_and_reset.cpp b/test/test_register_and_reset.cpp
index 11c8abb..b284730 100644
--- a/test/test_register_and_reset.cpp
+++ b/test/test_register_and_reset.cpp
@@ -568,7 +568,7 @@ TEST(unit_test_tag_map, add_after_reset_and_ensure_performance_improvement) {
clock_t start, end;
const int TEST_ROUND = 100000;
// struct cell_manager *hk = cell_manager_new(SAMPLING_MODE_COMPREHENSIVE, TEST_ROUND);
- struct tag_map *hk = tag_map_new(TEST_ROUND);
+ struct hash_table *hk = hash_table_new(TEST_ROUND);
vector<struct tag_hash_key *> keys;
for (int i = 0; i < TEST_ROUND; i++)
{
@@ -577,32 +577,32 @@ TEST(unit_test_tag_map, add_after_reset_and_ensure_performance_improvement) {
}
for (int i = 0; i < TEST_ROUND; i++) {
- tag_map_add(hk, keys[i], NULL);
+ hash_table_add(hk, keys[i], NULL);
}
- tag_map_reset(hk);
+ hash_table_reset(hk);
start = clock();
for (int i = 0; i < TEST_ROUND; i++)
{
- tag_map_add(hk, keys[i], NULL);
+ hash_table_add(hk, keys[i], NULL);
}
end = clock();
clock_t time_reset_once = end - start;
- tag_map_reset(hk);
- tag_map_reset(hk);
+ hash_table_reset(hk);
+ hash_table_reset(hk);
start = clock();
for (int i = 0; i < TEST_ROUND; i++)
{
- tag_map_add(hk, keys[i], NULL);
+ hash_table_add(hk, keys[i], NULL);
}
end = clock();
clock_t time_reset_twice = end - start;
EXPECT_GE(time_reset_twice, time_reset_once);
- tag_map_free(hk);
+ hash_table_free(hk);
for (int i = 0; i < TEST_ROUND; i++) {
tag_hash_key_free(keys[i]);
}