[PATCH] libosmocore[master]: stats_test: Extend check to include test for counter group n...

Harald Welte gerrit-no-reply at lists.osmocom.org
Tue Oct 3 10:41:43 UTC 2017


Review at  https://gerrit.osmocom.org/4132

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
---
M tests/stats/stats_test.c
M tests/stats/stats_test.ok
2 files changed, 51 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/32/4132/1

diff --git a/tests/stats/stats_test.c b/tests/stats/stats_test.c
index 61673ba..59fc449 100644
--- a/tests/stats/stats_test.c
+++ b/tests/stats/stats_test.c
@@ -47,6 +47,19 @@
 	.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 @@
 {
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 @@
 	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 cb9daf2..8628adb 100644
--- a/tests/stats/stats_test.ok
+++ b/tests/stats/stats_test.ok
@@ -2,6 +2,10 @@
   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 @@
   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 @@
   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 @@
   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 @@
   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 @@
   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 @@
   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 @@
   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):

-- 
To view, visit https://gerrit.osmocom.org/4132
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie35682aa79526e2ffeab6995cd640b7847d855bf
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>


More information about the gerrit-log mailing list