diff options
author | Harald Welte <laforge@gnumonks.org> | 2017-10-03 18:34:48 +0800 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2017-10-24 16:00:45 +0000 |
commit | 04c881207f903f48bd5863bc851b8384a06578de (patch) | |
tree | b308125b1abf0c4f0a7f41eb17f527879a82f96a /tests/stats | |
parent | a7a5065385be71239d49bb60a690402d3153eb34 (diff) |
stats_test: Extend check to include test for counter group name mangling
In Change-Id Ifc6ac824f5dae9a848bb4a5d067c64a69eb40b56 we introduce
name mangling to replace any '.' in counter (group) names to be
converted to ':'. Let's test for this functionality explicitly as part
of the stats_test.
Change-Id: Ie35682aa79526e2ffeab6995cd640b7847d855bf
Diffstat (limited to 'tests/stats')
-rw-r--r-- | tests/stats/stats_test.c | 37 | ||||
-rw-r--r-- | tests/stats/stats_test.ok | 24 |
2 files changed, 51 insertions, 10 deletions
diff --git a/tests/stats/stats_test.c b/tests/stats/stats_test.c index 61673ba8..59fc449c 100644 --- a/tests/stats/stats_test.c +++ b/tests/stats/stats_test.c @@ -47,6 +47,19 @@ static const struct rate_ctr_group_desc ctrg_desc = { .class_id = OSMO_STATS_CLASS_SUBSCRIBER, }; +static const struct rate_ctr_desc ctr_description_dot[] = { + [TEST_A_CTR] = { "ctr.a", "The A counter value with ."}, + [TEST_B_CTR] = { "ctr.b", "The B counter value with ."}, +}; + +static const struct rate_ctr_group_desc ctrg_desc_dot = { + .group_name_prefix = "ctr-test.one_dot", + .group_description = "Counter test number 1dot", + .num_ctr = ARRAY_SIZE(ctr_description_dot), + .ctr_desc = ctr_description_dot, + .class_id = OSMO_STATS_CLASS_SUBSCRIBER, +}; + enum test_items { TEST_A_ITEM, TEST_B_ITEM, @@ -296,7 +309,7 @@ static void test_reporting() { struct osmo_stats_reporter *srep1, *srep2, *srep; struct osmo_stat_item_group *statg1, *statg2; - struct rate_ctr_group *ctrg1, *ctrg2; + struct rate_ctr_group *ctrg1, *ctrg2, *ctrg3; void *stats_ctx = talloc_named_const(NULL, 1, "stats test context"); int rc; @@ -312,6 +325,8 @@ static void test_reporting() OSMO_ASSERT(ctrg1 != NULL); ctrg2 = rate_ctr_group_alloc(stats_ctx, &ctrg_desc, 2); OSMO_ASSERT(ctrg2 != NULL); + ctrg3 = rate_ctr_group_alloc(stats_ctx, &ctrg_desc_dot, 3); + OSMO_ASSERT(ctrg3 != NULL); srep1 = stats_reporter_create_test("test1"); OSMO_ASSERT(srep1 != NULL); @@ -339,7 +354,7 @@ static void test_reporting() printf("report (initial):\n"); send_count = 0; osmo_stats_report(); - OSMO_ASSERT(send_count == 16); + OSMO_ASSERT(send_count == 20); printf("report (srep1 global):\n"); /* force single flush */ @@ -348,7 +363,7 @@ static void test_reporting() srep2->force_single_flush = 1; send_count = 0; osmo_stats_report(); - OSMO_ASSERT(send_count == 8); + OSMO_ASSERT(send_count == 10); printf("report (srep1 peer):\n"); /* force single flush */ @@ -357,7 +372,7 @@ static void test_reporting() srep2->force_single_flush = 1; send_count = 0; osmo_stats_report(); - OSMO_ASSERT(send_count == 12); + OSMO_ASSERT(send_count == 14); printf("report (srep1 subscriber):\n"); /* force single flush */ @@ -366,7 +381,7 @@ static void test_reporting() srep2->force_single_flush = 1; send_count = 0; osmo_stats_report(); - OSMO_ASSERT(send_count == 16); + OSMO_ASSERT(send_count == 20); printf("report (srep2 disabled):\n"); /* force single flush */ @@ -376,14 +391,14 @@ static void test_reporting() OSMO_ASSERT(rc >= 0); send_count = 0; osmo_stats_report(); - OSMO_ASSERT(send_count == 8); + OSMO_ASSERT(send_count == 10); printf("report (srep2 enabled, no flush forced):\n"); rc = osmo_stats_reporter_enable(srep2); OSMO_ASSERT(rc >= 0); send_count = 0; osmo_stats_report(); - OSMO_ASSERT(send_count == 8); + OSMO_ASSERT(send_count == 10); printf("report (should be empty):\n"); send_count = 0; @@ -410,7 +425,7 @@ static void test_reporting() rate_ctr_group_free(ctrg1); send_count = 0; osmo_stats_report(); - OSMO_ASSERT(send_count == 8); + OSMO_ASSERT(send_count == 12); printf("report (remove srep1):\n"); /* force single flush */ @@ -419,7 +434,7 @@ static void test_reporting() osmo_stats_reporter_free(srep1); send_count = 0; osmo_stats_report(); - OSMO_ASSERT(send_count == 4); + OSMO_ASSERT(send_count == 6); printf("report (remove statg2):\n"); /* force single flush */ @@ -427,7 +442,7 @@ static void test_reporting() osmo_stat_item_group_free(statg2); send_count = 0; osmo_stats_report(); - OSMO_ASSERT(send_count == 2); + OSMO_ASSERT(send_count == 4); printf("report (remove srep2):\n"); /* force single flush */ @@ -443,6 +458,8 @@ static void test_reporting() osmo_stats_report(); OSMO_ASSERT(send_count == 0); + rate_ctr_group_free(ctrg3); + /* Leak check */ OSMO_ASSERT(talloc_total_blocks(stats_ctx) == 1); talloc_free(stats_ctx); diff --git a/tests/stats/stats_test.ok b/tests/stats/stats_test.ok index cb9daf22..8628adb7 100644 --- a/tests/stats/stats_test.ok +++ b/tests/stats/stats_test.ok @@ -2,6 +2,10 @@ Start test: test_reporting test1: open test2: open report (initial): + test2: counter p= g=ctr-test:one_dot i=3 n=ctr:a v=0 d=0 + test1: counter p= g=ctr-test:one_dot i=3 n=ctr:a v=0 d=0 + test2: counter p= g=ctr-test:one_dot i=3 n=ctr:b v=0 d=0 + test1: counter p= g=ctr-test:one_dot i=3 n=ctr:b v=0 d=0 test2: counter p= g=ctr-test:one i=2 n=ctr:a v=0 d=0 test1: counter p= g=ctr-test:one i=2 n=ctr:a v=0 d=0 test2: counter p= g=ctr-test:one i=2 n=ctr:b v=0 d=0 @@ -19,6 +23,8 @@ report (initial): test2: item p= g=test.one i=1 n=item.b v=-1 u=kb test1: item p= g=test.one i=1 n=item.b v=-1 u=kb report (srep1 global): + test2: counter p= g=ctr-test:one_dot i=3 n=ctr:a v=0 d=0 + test2: counter p= g=ctr-test:one_dot i=3 n=ctr:b v=0 d=0 test2: counter p= g=ctr-test:one i=2 n=ctr:a v=0 d=0 test2: counter p= g=ctr-test:one i=2 n=ctr:b v=0 d=0 test2: counter p= g=ctr-test:one i=1 n=ctr:a v=0 d=0 @@ -28,6 +34,8 @@ report (srep1 global): test2: item p= g=test.one i=1 n=item.a v=-1 u=ma test2: item p= g=test.one i=1 n=item.b v=-1 u=kb report (srep1 peer): + test2: counter p= g=ctr-test:one_dot i=3 n=ctr:a v=0 d=0 + test2: counter p= g=ctr-test:one_dot i=3 n=ctr:b v=0 d=0 test2: counter p= g=ctr-test:one i=2 n=ctr:a v=0 d=0 test2: counter p= g=ctr-test:one i=2 n=ctr:b v=0 d=0 test2: counter p= g=ctr-test:one i=1 n=ctr:a v=0 d=0 @@ -41,6 +49,10 @@ report (srep1 peer): test2: item p= g=test.one i=1 n=item.b v=-1 u=kb test1: item p= g=test.one i=1 n=item.b v=-1 u=kb report (srep1 subscriber): + test2: counter p= g=ctr-test:one_dot i=3 n=ctr:a v=0 d=0 + test1: counter p= g=ctr-test:one_dot i=3 n=ctr:a v=0 d=0 + test2: counter p= g=ctr-test:one_dot i=3 n=ctr:b v=0 d=0 + test1: counter p= g=ctr-test:one_dot i=3 n=ctr:b v=0 d=0 test2: counter p= g=ctr-test:one i=2 n=ctr:a v=0 d=0 test1: counter p= g=ctr-test:one i=2 n=ctr:a v=0 d=0 test2: counter p= g=ctr-test:one i=2 n=ctr:b v=0 d=0 @@ -59,6 +71,8 @@ report (srep1 subscriber): test1: item p= g=test.one i=1 n=item.b v=-1 u=kb report (srep2 disabled): test2: close + test1: counter p= g=ctr-test:one_dot i=3 n=ctr:a v=0 d=0 + test1: counter p= g=ctr-test:one_dot i=3 n=ctr:b v=0 d=0 test1: counter p= g=ctr-test:one i=2 n=ctr:a v=0 d=0 test1: counter p= g=ctr-test:one i=2 n=ctr:b v=0 d=0 test1: counter p= g=ctr-test:one i=1 n=ctr:a v=0 d=0 @@ -69,6 +83,8 @@ report (srep2 disabled): test1: item p= g=test.one i=1 n=item.b v=-1 u=kb report (srep2 enabled, no flush forced): test2: open + test2: counter p= g=ctr-test:one_dot i=3 n=ctr:a v=0 d=0 + test2: counter p= g=ctr-test:one_dot i=3 n=ctr:b v=0 d=0 test2: counter p= g=ctr-test:one i=2 n=ctr:a v=0 d=0 test2: counter p= g=ctr-test:one i=2 n=ctr:b v=0 d=0 test2: counter p= g=ctr-test:one i=1 n=ctr:a v=0 d=0 @@ -85,6 +101,10 @@ report (group 1, item 1 update): test2: item p= g=test.one i=1 n=item.a v=10 u=ma test1: item p= g=test.one i=1 n=item.a v=10 u=ma report (remove statg1, ctrg1): + test2: counter p= g=ctr-test:one_dot i=3 n=ctr:a v=0 d=0 + test1: counter p= g=ctr-test:one_dot i=3 n=ctr:a v=0 d=0 + test2: counter p= g=ctr-test:one_dot i=3 n=ctr:b v=0 d=0 + test1: counter p= g=ctr-test:one_dot i=3 n=ctr:b v=0 d=0 test2: counter p= g=ctr-test:one i=2 n=ctr:a v=0 d=0 test1: counter p= g=ctr-test:one i=2 n=ctr:a v=0 d=0 test2: counter p= g=ctr-test:one i=2 n=ctr:b v=0 d=0 @@ -95,11 +115,15 @@ report (remove statg1, ctrg1): test1: item p= g=test.one i=2 n=item.b v=-1 u=kb report (remove srep1): test1: close + test2: counter p= g=ctr-test:one_dot i=3 n=ctr:a v=0 d=0 + test2: counter p= g=ctr-test:one_dot i=3 n=ctr:b v=0 d=0 test2: counter p= g=ctr-test:one i=2 n=ctr:a v=0 d=0 test2: counter p= g=ctr-test:one i=2 n=ctr:b v=0 d=0 test2: item p= g=test.one i=2 n=item.a v=-1 u=ma test2: item p= g=test.one i=2 n=item.b v=-1 u=kb report (remove statg2): + test2: counter p= g=ctr-test:one_dot i=3 n=ctr:a v=0 d=0 + test2: counter p= g=ctr-test:one_dot i=3 n=ctr:b v=0 d=0 test2: counter p= g=ctr-test:one i=2 n=ctr:a v=0 d=0 test2: counter p= g=ctr-test:one i=2 n=ctr:b v=0 d=0 report (remove srep2): |