Labeled metrics interface
[ric-plt/xapp-frame.git] / pkg / xapp / metrics_test.go
1 /*
2 ==================================================================================
3   Copyright (c) 2019 AT&T Intellectual Property.
4   Copyright (c) 2019 Nokia
5
6    Licensed under the Apache License, Version 2.0 (the "License");
7    you may not use this file except in compliance with the License.
8    You may obtain a copy of the License at
9
10        http://www.apache.org/licenses/LICENSE-2.0
11
12    Unless required by applicable law or agreed to in writing, software
13    distributed under the License is distributed on an "AS IS" BASIS,
14    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15    See the License for the specific language governing permissions and
16    limitations under the License.
17 ==================================================================================
18 */
19
20 package xapp
21
22 import (
23         "testing"
24 )
25
26 func TestMetricCounter(t *testing.T) {
27         TestCounterOpt := CounterOpts{Name: "CounterBlaah1", Help: "CounterBlaah1"}
28         ret1 := Metric.RegisterCounter(TestCounterOpt, "TestMetricCounter")
29         ret1.Inc()
30         ret2 := Metric.RegisterCounter(TestCounterOpt, "TestMetricCounter")
31         ret2.Inc()
32         if ret1 != ret2 {
33                 t.Errorf("ret1 not same than ret2. cache not working?")
34         }
35 }
36
37 func TestMetricCounterGroup(t *testing.T) {
38         var TestCounterOpts = []CounterOpts{
39                 {Name: "CounterBlaah1", Help: "CounterBlaah1"},
40                 {Name: "CounterBlaah2", Help: "CounterBlaah2"},
41                 {Name: "CounterBlaah3", Help: "CounterBlaah3"},
42                 {Name: "CounterBlaah4", Help: "CounterBlaah4"},
43         }
44
45         ret1 := Metric.RegisterCounterGroup(TestCounterOpts, "TestMetricCounterGroup")
46
47         if len(ret1) == 0 {
48                 t.Errorf("ret1 counter group is empty")
49         }
50
51         ret1["CounterBlaah1"].Inc()
52         ret1["CounterBlaah2"].Inc()
53         ret1["CounterBlaah3"].Inc()
54         ret1["CounterBlaah4"].Inc()
55
56         ret2 := Metric.RegisterCounterGroup(TestCounterOpts, "TestMetricCounterGroup")
57
58         if len(ret2) == 0 {
59                 t.Errorf("ret2 counter group is empty")
60         }
61
62         ret2["CounterBlaah1"].Inc()
63         ret2["CounterBlaah2"].Inc()
64         ret2["CounterBlaah3"].Inc()
65         ret2["CounterBlaah4"].Inc()
66
67         if len(ret1) != len(ret2) {
68                 t.Errorf("ret1 len %d differs from ret2 len %d", len(ret1), len(ret2))
69         }
70 }
71
72 func TestMetricLabeledCounter(t *testing.T) {
73         //
74         //
75         c_1_1 := Metric.RegisterLabeledCounter(
76                 CounterOpts{Name: "counter1", Help: "counter1"},
77                 []string{"name", "event"},
78                 []string{"name1", "event1"},
79                 "SUBSYSTEML0")
80
81         c_1_2 := Metric.RegisterLabeledCounter(
82                 CounterOpts{Name: "counter1", Help: "counter1"},
83                 []string{"name", "event"},
84                 []string{"name1", "event1"},
85                 "SUBSYSTEML0")
86
87         c_1_1.Inc()
88         c_1_2.Inc()
89         if c_1_1 != c_1_2 {
90                 t.Errorf("c_1_1 not same than c_1_2. cache not working?")
91         }
92
93         //
94         //
95         c_2_1 := Metric.RegisterLabeledCounter(
96                 CounterOpts{Name: "counter1", Help: "counter1"},
97                 []string{"name", "event"},
98                 []string{"name1", "event2"},
99                 "SUBSYSTEML0")
100
101         c_2_2 := Metric.RegisterLabeledCounter(
102                 CounterOpts{Name: "counter1", Help: "counter1"},
103                 []string{"name", "event"},
104                 []string{"name1", "event2"},
105                 "SUBSYSTEML0")
106
107         c_2_1.Inc()
108         c_2_2.Inc()
109         if c_2_1 != c_2_2 {
110                 t.Errorf("c_2_1 not same than c_2_2. cache not working?")
111         }
112
113         if c_1_1 == c_2_1 {
114                 t.Errorf("c_1_1 same than c_2_1. what?")
115         }
116         if c_1_2 == c_2_2 {
117                 t.Errorf("c_1_2 same than c_2_2. what?")
118         }
119
120 }
121
122 func TestMetricLabeledCounterMismatch(t *testing.T) {
123         Metric.RegisterLabeledCounter(
124                 CounterOpts{Name: "counter1", Help: "counter1"},
125                 []string{"name", "event"},
126                 []string{"name1", "event1"},
127                 "SUBSYSTEMLERR")
128
129         Metric.RegisterLabeledCounter(
130                 CounterOpts{Name: "counter1", Help: "counter1"},
131                 []string{"name", "eventmismatch"},
132                 []string{"name1", "event1"},
133                 "SUBSYSTEMLERR")
134 }
135
136 func TestMetricLabeledCounterGroup(t *testing.T) {
137         //
138         //
139         c_grp1 := Metric.RegisterLabeledCounterGroup(
140                 []CounterOpts{{Name: "counter1", Help: "counter1"}},
141                 []string{"name", "event"},
142                 []string{"name1", "event1"},
143                 "SUBSYSTEML1")
144
145         if _, ok := c_grp1["counter1"]; ok == false {
146                 t.Errorf("c_grp1 counter1 not exists")
147         }
148         c_grp1["counter1"].Inc()
149
150         //
151         //
152         c_grp2 := Metric.RegisterLabeledCounterGroup(
153                 []CounterOpts{{Name: "counter1", Help: "counter1"}},
154                 []string{"name", "event"},
155                 []string{"name1", "event2"},
156                 "SUBSYSTEML1")
157
158         if _, ok := c_grp2["counter1"]; ok == false {
159                 t.Errorf("c_grp2 counter1 not exists")
160         }
161         c_grp2["counter1"].Inc()
162 }
163
164 func TestMetricGauge(t *testing.T) {
165         TestGaugeOpts := CounterOpts{Name: "GaugeBlaah1", Help: "GaugeBlaah1"}
166         ret1 := Metric.RegisterGauge(TestGaugeOpts, "TestMetricGauge")
167         ret1.Inc()
168         ret2 := Metric.RegisterGauge(TestGaugeOpts, "TestMetricGauge")
169         ret2.Inc()
170         if ret1 != ret2 {
171                 t.Errorf("ret1 not same than ret2. cache not working?")
172         }
173 }
174
175 func TestMetricGaugeGroup(t *testing.T) {
176         var TestGaugeOpts = []CounterOpts{
177                 {Name: "GaugeBlaah1", Help: "GaugeBlaah1"},
178                 {Name: "GaugeBlaah2", Help: "GaugeBlaah2"},
179                 {Name: "GaugeBlaah3", Help: "GaugeBlaah3"},
180                 {Name: "GaugeBlaah4", Help: "GaugeBlaah4"},
181         }
182
183         ret1 := Metric.RegisterGaugeGroup(TestGaugeOpts, "TestMetricGaugeGroup")
184
185         if len(ret1) == 0 {
186                 t.Errorf("ret1 gauge group is empty")
187         }
188
189         ret1["GaugeBlaah1"].Inc()
190         ret1["GaugeBlaah2"].Inc()
191         ret1["GaugeBlaah3"].Inc()
192         ret1["GaugeBlaah4"].Inc()
193
194         ret2 := Metric.RegisterGaugeGroup(TestGaugeOpts, "TestMetricGaugeGroup")
195
196         if len(ret2) == 0 {
197                 t.Errorf("ret2 gauge group is empty")
198         }
199
200         ret2["GaugeBlaah1"].Inc()
201         ret2["GaugeBlaah2"].Inc()
202         ret2["GaugeBlaah3"].Inc()
203         ret2["GaugeBlaah4"].Inc()
204
205         if len(ret1) != len(ret2) {
206                 t.Errorf("ret1 len %d differs from ret2 len %d", len(ret1), len(ret2))
207         }
208 }
209
210 func TestMetricLabeledGauge(t *testing.T) {
211         //
212         //
213         c_1_1 := Metric.RegisterLabeledGauge(
214                 CounterOpts{Name: "gauge1", Help: "gauge1"},
215                 []string{"name", "event"},
216                 []string{"name1", "event1"},
217                 "SUBSYSTEML0")
218
219         c_1_2 := Metric.RegisterLabeledGauge(
220                 CounterOpts{Name: "gauge1", Help: "gauge1"},
221                 []string{"name", "event"},
222                 []string{"name1", "event1"},
223                 "SUBSYSTEML0")
224
225         c_1_1.Inc()
226         c_1_2.Inc()
227         if c_1_1 != c_1_2 {
228                 t.Errorf("c_1_1 not same than c_1_2. cache not working?")
229         }
230
231         //
232         //
233         c_2_1 := Metric.RegisterLabeledGauge(
234                 CounterOpts{Name: "gauge1", Help: "gauge1"},
235                 []string{"name", "event"},
236                 []string{"name1", "event2"},
237                 "SUBSYSTEML0")
238
239         c_2_2 := Metric.RegisterLabeledGauge(
240                 CounterOpts{Name: "gauge1", Help: "gauge1"},
241                 []string{"name", "event"},
242                 []string{"name1", "event2"},
243                 "SUBSYSTEML0")
244
245         c_2_1.Inc()
246         c_2_2.Inc()
247         if c_2_1 != c_2_2 {
248                 t.Errorf("c_2_1 not same than c_2_2. cache not working?")
249         }
250
251         if c_1_1 == c_2_1 {
252                 t.Errorf("c_1_1 same than c_2_1. what?")
253         }
254         if c_1_2 == c_2_2 {
255                 t.Errorf("c_1_2 same than c_2_2. what?")
256         }
257
258 }
259
260 func TestMetricLabeledGaugeMismatch(t *testing.T) {
261         Metric.RegisterLabeledGauge(
262                 CounterOpts{Name: "gauge1", Help: "gauge1"},
263                 []string{"name", "event"},
264                 []string{"name1", "event1"},
265                 "SUBSYSTEMLERR")
266
267         Metric.RegisterLabeledGauge(
268                 CounterOpts{Name: "gauge1", Help: "gauge1"},
269                 []string{"name", "eventmismatch"},
270                 []string{"name1", "event1"},
271                 "SUBSYSTEMLERR")
272 }
273
274 func TestMetricLabeledGaugeGroup(t *testing.T) {
275         //
276         //
277         g_grp1 := Metric.RegisterLabeledGaugeGroup(
278                 []CounterOpts{{Name: "gauge1", Help: "gauge1"}},
279                 []string{"name", "event"},
280                 []string{"name1", "event1"},
281                 "SUBSYSTEML1")
282
283         if _, ok := g_grp1["gauge1"]; ok == false {
284                 t.Errorf("g_grp1 gauge1 not exists")
285         }
286         g_grp1["gauge1"].Inc()
287
288         //
289         //
290         g_grp2 := Metric.RegisterLabeledGaugeGroup(
291                 []CounterOpts{{Name: "gauge1", Help: "gauge1"}},
292                 []string{"name", "event"},
293                 []string{"name1", "event2"},
294                 "SUBSYSTEML1")
295
296         if _, ok := g_grp2["gauge1"]; ok == false {
297                 t.Errorf("g_grp2 gauge1 not exists")
298         }
299         g_grp2["gauge1"].Inc()
300 }
301
302 func TestMetricGroupCache(t *testing.T) {
303         //
304         //
305         c_grp1 := Metric.RegisterLabeledCounterGroup(
306                 []CounterOpts{{Name: "counter1", Help: "counter1"}},
307                 []string{"name", "event"},
308                 []string{"name1", "event1"},
309                 "SUBSYSTEML1")
310         if _, ok := c_grp1["counter1"]; ok == false {
311                 t.Errorf("c_grp1 counter1 not exists")
312         }
313         c_grp1["counter1"].Inc()
314
315         //
316         //
317         c_grp2 := Metric.RegisterLabeledCounterGroup(
318                 []CounterOpts{{Name: "counter1", Help: "counter1"}},
319                 []string{"name", "event"},
320                 []string{"name1", "event2"},
321                 "SUBSYSTEML1")
322         if _, ok := c_grp2["counter1"]; ok == false {
323                 t.Errorf("c_grp2 counter1 not exists")
324         }
325         c_grp2["counter1"].Inc()
326
327         //
328         //
329         g_grp1 := Metric.RegisterLabeledGaugeGroup(
330                 []CounterOpts{{Name: "gauge1", Help: "gauge1"}},
331                 []string{"name", "event"},
332                 []string{"name1", "event1"},
333                 "SUBSYSTEML1")
334         if _, ok := g_grp1["gauge1"]; ok == false {
335                 t.Errorf("g_grp1 gauge1 not exists")
336         }
337         g_grp1["gauge1"].Inc()
338
339         //
340         //
341         g_grp2 := Metric.RegisterLabeledGaugeGroup(
342                 []CounterOpts{{Name: "gauge1", Help: "gauge1"}},
343                 []string{"name", "event"},
344                 []string{"name1", "event2"},
345                 "SUBSYSTEML1")
346         if _, ok := g_grp2["gauge1"]; ok == false {
347                 t.Errorf("g_grp2 gauge1 not exists")
348         }
349         g_grp2["gauge1"].Inc()
350
351         //
352         //
353         m_grp := NewMetricGroupsCache()
354         m_grp.CombineCounterGroupsWithPrefix("event1_", c_grp1)
355         m_grp.CombineCounterGroupsWithPrefix("event2_", c_grp2)
356         m_grp.CombineGaugeGroupsWithPrefix("event1_", g_grp1)
357         m_grp.CombineGaugeGroupsWithPrefix("event2_", g_grp2)
358
359         if m_grp == nil {
360                 t.Errorf("Cache failed")
361         }
362
363         if m_grp.CIs("event1_counter1") == false {
364                 t.Errorf("m_grp.Counters event1_counter1 not exists")
365         }
366         m_grp.CInc("event1_counter1")
367
368         if m_grp.CIs("event2_counter1") == false {
369                 t.Errorf("m_grp.Counters event2_counter1 not exists")
370         }
371         m_grp.CInc("event2_counter1")
372
373         if m_grp.GIs("event1_gauge1") == false {
374                 t.Errorf("m_grp.Gauges event1_gauge1 not exists")
375         }
376         m_grp.GInc("event1_gauge1")
377
378         if m_grp.GIs("event2_gauge1") == false {
379                 t.Errorf("m_grp.Gauges event2_gauge1 not exists")
380         }
381         m_grp.GInc("event2_gauge1")
382
383         m_grp.CAdd("event2_counter1", 1)
384         m_grp.CGet("event2_counter1")
385         m_grp.GGet("event2_gauge1")
386         m_grp.GDec("event2_gauge1")
387         m_grp.GSet("event2_gauge1", 1)
388 }
389
390 // ----
391 // VECTORS ARE OLD WAY
392 // *Labeled* will do all work under the hood
393 // ----
394
395 var mCVect CounterVec
396 var mGVect GaugeVec
397
398 var mCGroupVect map[string]CounterVec
399 var mGGroupVect map[string]GaugeVec
400
401 func TestMetricSetup(t *testing.T) {
402         mCVect = Metric.RegisterCounterVec(CounterOpts{Name: "counter1", Help: "counter1"}, []string{"name", "event"}, "SUBSYSTEM0")
403
404         mCGroupVect = Metric.RegisterCounterVecGroup(
405                 []CounterOpts{
406                         {Name: "counter1", Help: "counter1"},
407                 },
408                 []string{"name", "event"},
409                 "SUBSYSTEM1")
410
411         mGVect = Metric.RegisterGaugeVec(CounterOpts{Name: "gauge1", Help: "gauge1"}, []string{"name", "event"}, "SUBSYSTEM0")
412
413         mGGroupVect = Metric.RegisterGaugeVecGroup(
414                 []CounterOpts{
415                         {Name: "gauge1", Help: "gauge1"},
416                 },
417                 []string{"name", "event"},
418                 "SUBSYSTEM1")
419
420         tmpCVect := Metric.RegisterCounterVec(CounterOpts{Name: "counter1", Help: "counter1"}, []string{"name", "event"}, "SUBSYSTEM0")
421
422         if tmpCVect.Vec != mCVect.Vec {
423                 t.Errorf("tmpCVect not same than mCVect. cache not working?")
424         }
425
426         tmpGVect := Metric.RegisterGaugeVec(CounterOpts{Name: "gauge1", Help: "gauge1"}, []string{"name", "event"}, "SUBSYSTEM0")
427
428         if tmpGVect.Vec != mGVect.Vec {
429                 t.Errorf("tmpGVect not same than mGVect. cache not working?")
430         }
431
432         Metric.RegisterCounterVec(CounterOpts{Name: "counter1", Help: "counter1"}, []string{"name", "eventMismatch"}, "SUBSYSTEM0")
433         Metric.RegisterGaugeVec(CounterOpts{Name: "gauge1", Help: "gauge1"}, []string{"name", "eventMismatch"}, "SUBSYSTEM0")
434
435 }
436
437 func TestMetricCounterVector(t *testing.T) {
438         //
439         //
440         c_1_1 := Metric.GetCounterFromVect([]string{"name1", "event1"}, mCVect)
441         c_1_1.Inc()
442         c_1_2 := Metric.GetCounterFromVect([]string{"name1", "event1"}, mCVect)
443         c_1_2.Inc()
444         if c_1_1 != c_1_2 {
445                 t.Errorf("c_1_1 not same than c_1_2. cache not working?")
446         }
447         //
448         //
449         c_2_1 := Metric.GetCounterFromVect([]string{"name1", "event2"}, mCVect)
450         c_2_1.Inc()
451         c_2_2 := Metric.GetCounterFromVect([]string{"name1", "event2"}, mCVect)
452         c_2_2.Inc()
453         if c_2_1 != c_2_2 {
454                 t.Errorf("c_2_1 not same than c_2_2. cache not working?")
455         }
456         if c_1_1 == c_2_1 {
457                 t.Errorf("c_1_1 same than c_2_1. what?")
458         }
459
460 }
461
462 func TestMetricCounterGroupVector(t *testing.T) {
463         //
464         //
465         c_grp1 := Metric.GetCounterGroupFromVects([]string{"name1", "event1"}, mCGroupVect)
466         if _, ok := c_grp1["counter1"]; ok == false {
467                 t.Errorf("c_grp1 counter1 not exists")
468         }
469         c_grp1["counter1"].Inc()
470
471         //
472         //
473         c_grp2 := Metric.GetCounterGroupFromVects([]string{"name1", "event2"}, mCGroupVect)
474         if _, ok := c_grp2["counter1"]; ok == false {
475                 t.Errorf("c_grp2 counter1 not exists")
476         }
477         c_grp2["counter1"].Inc()
478 }
479
480 func TestMetricGaugeVector(t *testing.T) {
481         //
482         //
483         c_1_1 := Metric.GetGaugeFromVect([]string{"name1", "event1"}, mGVect)
484         c_1_1.Inc()
485         c_1_2 := Metric.GetGaugeFromVect([]string{"name1", "event1"}, mGVect)
486         c_1_2.Inc()
487         if c_1_1 != c_1_2 {
488                 t.Errorf("c_1_1 not same than c_1_2. cache not working?")
489         }
490         //
491         //
492         c_2_1 := Metric.GetGaugeFromVect([]string{"name1", "event2"}, mGVect)
493         c_2_1.Inc()
494         c_2_2 := Metric.GetGaugeFromVect([]string{"name1", "event2"}, mGVect)
495         c_2_2.Inc()
496         if c_2_1 != c_2_2 {
497                 t.Errorf("c_2_1 not same than c_2_2. cache not working?")
498         }
499         if c_1_1 == c_2_1 {
500                 t.Errorf("c_1_1 same than c_2_1. what?")
501         }
502 }
503
504 func TestMetricGaugeGroupVector(t *testing.T) {
505         //
506         //
507         g_grp1 := Metric.GetGaugeGroupFromVects([]string{"name1", "event1"}, mGGroupVect)
508         if _, ok := g_grp1["gauge1"]; ok == false {
509                 t.Errorf("g_grp1 gauge1 not exists")
510         }
511         g_grp1["gauge1"].Inc()
512
513         //
514         //
515         g_grp2 := Metric.GetGaugeGroupFromVects([]string{"name1", "event2"}, mGGroupVect)
516         if _, ok := g_grp2["gauge1"]; ok == false {
517                 t.Errorf("g_grp2 gauge1 not exists")
518         }
519         g_grp2["gauge1"].Inc()
520 }
521
522 func TestMetricCounterGroupVectorPrefix(t *testing.T) {
523         //
524         //
525         c_grp1 := Metric.GetCounterGroupFromVectsWithPrefix("event1_", []string{"name1", "event1"}, mCGroupVect)
526         if _, ok := c_grp1["event1_counter1"]; ok == false {
527                 t.Errorf("c_grp1 event1_counter1 not exists")
528         }
529         c_grp1["event1_counter1"].Inc()
530
531         //
532         //
533         c_grp2 := Metric.GetCounterGroupFromVectsWithPrefix("event2_", []string{"name1", "event2"}, mCGroupVect)
534         if _, ok := c_grp2["event2_counter1"]; ok == false {
535                 t.Errorf("c_grp2 event2_counter1 not exists")
536         }
537         c_grp2["event2_counter1"].Inc()
538
539         //
540         //
541         m_grp := NewMetricGroupsCache()
542         m_grp.CombineCounterGroups(c_grp1, c_grp2)
543
544         //
545         //
546         if m_grp.CIs("event1_counter1") == false {
547                 t.Errorf("m_grp event1_counter1 not exists")
548         }
549         m_grp.CInc("event1_counter1")
550
551         //
552         //
553         if m_grp.CIs("event2_counter1") == false {
554                 t.Errorf("m_grp event2_counter1 not exists")
555         }
556
557         m_grp.CAdd("event2_counter1", 1)
558         m_grp.CGet("event2_counter1")
559 }
560
561 func TestMetricGaugeGroupVectorPrefix(t *testing.T) {
562         //
563         //
564         g_grp1 := Metric.GetGaugeGroupFromVectsWithPrefix("event1_", []string{"name1", "event1"}, mGGroupVect)
565         if _, ok := g_grp1["event1_gauge1"]; ok == false {
566                 t.Errorf("g_grp1 event1_gauge1 not exists")
567         }
568         g_grp1["event1_gauge1"].Inc()
569
570         //
571         //
572         g_grp2 := Metric.GetGaugeGroupFromVectsWithPrefix("event2_", []string{"name1", "event2"}, mGGroupVect)
573         if _, ok := g_grp2["event2_gauge1"]; ok == false {
574                 t.Errorf("g_grp2 event2_gauge1 not exists")
575         }
576         g_grp2["event2_gauge1"].Inc()
577
578         m_grp := NewMetricGroupsCache()
579         m_grp.CombineGaugeGroups(g_grp1, g_grp2)
580
581         //
582         //
583         if m_grp.GIs("event1_gauge1") == false {
584                 t.Errorf("m_grp event1_gauge1 not exists")
585         }
586         m_grp.GInc("event1_gauge1")
587
588         //
589         //
590         if m_grp.GIs("event2_gauge1") == false {
591                 t.Errorf("m_grp event2_gauge1 not exists")
592         }
593         m_grp.GInc("event2_gauge1")
594
595         m_grp.GGet("event2_gauge1")
596         m_grp.GDec("event2_gauge1")
597         m_grp.GSet("event2_gauge1", 1)
598 }
599
600 func TestMetricGroupCacheWithVect(t *testing.T) {
601         //
602         //
603         c_grp1 := Metric.GetCounterGroupFromVects([]string{"name1", "event1"}, mCGroupVect)
604         if _, ok := c_grp1["counter1"]; ok == false {
605                 t.Errorf("c_grp1 counter1 not exists")
606         }
607         c_grp1["counter1"].Inc()
608
609         //
610         //
611         c_grp2 := Metric.GetCounterGroupFromVects([]string{"name1", "event2"}, mCGroupVect)
612         if _, ok := c_grp2["counter1"]; ok == false {
613                 t.Errorf("c_grp2 counter1 not exists")
614         }
615         c_grp2["counter1"].Inc()
616
617         //
618         //
619         g_grp1 := Metric.GetGaugeGroupFromVects([]string{"name1", "event1"}, mGGroupVect)
620         if _, ok := g_grp1["gauge1"]; ok == false {
621                 t.Errorf("g_grp1 gauge1 not exists")
622         }
623         g_grp1["gauge1"].Inc()
624
625         //
626         //
627         g_grp2 := Metric.GetGaugeGroupFromVects([]string{"name1", "event2"}, mGGroupVect)
628         if _, ok := g_grp2["gauge1"]; ok == false {
629                 t.Errorf("g_grp2 gauge1 not exists")
630         }
631         g_grp2["gauge1"].Inc()
632
633         //
634         //
635         m_grp := NewMetricGroupsCache()
636         m_grp.CombineCounterGroupsWithPrefix("event1_", c_grp1)
637         m_grp.CombineCounterGroupsWithPrefix("event2_", c_grp2)
638         m_grp.CombineGaugeGroupsWithPrefix("event1_", g_grp1)
639         m_grp.CombineGaugeGroupsWithPrefix("event2_", g_grp2)
640
641         if m_grp == nil {
642                 t.Errorf("Cache failed")
643         }
644
645         if m_grp.CIs("event1_counter1") == false {
646                 t.Errorf("m_grp.Counters event1_counter1 not exists")
647         }
648         m_grp.CInc("event1_counter1")
649
650         if m_grp.CIs("event2_counter1") == false {
651                 t.Errorf("m_grp.Counters event2_counter1 not exists")
652         }
653         m_grp.CInc("event2_counter1")
654
655         if m_grp.GIs("event1_gauge1") == false {
656                 t.Errorf("m_grp.Gauges event1_gauge1 not exists")
657         }
658         m_grp.GInc("event1_gauge1")
659
660         if m_grp.GIs("event2_gauge1") == false {
661                 t.Errorf("m_grp.Gauges event2_gauge1 not exists")
662         }
663         m_grp.GInc("event2_gauge1")
664
665         m_grp.CAdd("event2_counter1", 1)
666         m_grp.CGet("event2_counter1")
667         m_grp.GGet("event2_gauge1")
668         m_grp.GDec("event2_gauge1")
669         m_grp.GSet("event2_gauge1", 1)
670 }