Delete all subscriptions when Ran is under reset.
[ric-plt/submgr.git] / pkg / control / 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 control
21
22 import (
23         "testing"
24 )
25
26 func TestAddAllCountersOnce(t *testing.T) {
27
28         // Check that all counters can be added correctly
29         mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
30                 Counter{cSubReqFromXapp, 1},
31                 Counter{cSubRespToXapp, 1},
32                 Counter{cSubFailToXapp, 1},
33                 Counter{cRestSubReqFromXapp, 1},
34                 Counter{cRestSubRespToXapp, 1},
35                 Counter{cRestSubFailToXapp, 1},
36                 Counter{cRestReqRejDueE2Down, 1},
37                 Counter{cRestSubNotifToXapp, 1},
38                 Counter{cRestSubFailNotifToXapp, 1},
39                 Counter{cSubReqToE2, 1},
40                 Counter{cSubReReqToE2, 1},
41                 Counter{cSubRespFromE2, 1},
42                 Counter{cPartialSubRespFromE2, 1},
43                 Counter{cSubFailFromE2, 1},
44                 Counter{cSubReqTimerExpiry, 1},
45                 Counter{cRouteCreateFail, 1},
46                 Counter{cRouteCreateUpdateFail, 1},
47                 Counter{cMergedSubscriptions, 1},
48                 Counter{cDuplicateE2SubReq, 1},
49                 Counter{cSubDelReqFromXapp, 1},
50                 Counter{cSubDelRespToXapp, 1},
51                 Counter{cRestSubDelReqFromXapp, 1},
52                 Counter{cRestSubDelRespToXapp, 1},
53                 Counter{cSubDelReqToE2, 1},
54                 Counter{cSubDelReReqToE2, 1},
55                 Counter{cSubDelRespFromE2, 1},
56                 Counter{cSubDelFailFromE2, 1},
57                 Counter{cSubDelReqTimerExpiry, 1},
58                 Counter{cSubDelRequFromE2, 1},
59                 Counter{cRouteDeleteFail, 1},
60                 Counter{cRouteDeleteUpdateFail, 1},
61                 Counter{cUnmergedSubscriptions, 1},
62                 Counter{cSDLWriteFailure, 1},
63                 Counter{cSDLReadFailure, 1},
64                 Counter{cSDLRemoveFailure, 1},
65                 Counter{cE2StateChangedToUp, 1},
66                 Counter{cE2StateChangedToDown, 1},
67                 Counter{cE2StateUnderReset, 1},
68         })
69
70         mainCtrl.c.UpdateCounter(cSubReqFromXapp)
71         mainCtrl.c.UpdateCounter(cSubRespToXapp)
72         mainCtrl.c.UpdateCounter(cSubFailToXapp)
73         mainCtrl.c.UpdateCounter(cRestSubReqFromXapp)
74         mainCtrl.c.UpdateCounter(cRestSubRespToXapp)
75         mainCtrl.c.UpdateCounter(cRestSubFailToXapp)
76         mainCtrl.c.UpdateCounter(cRestReqRejDueE2Down)
77         mainCtrl.c.UpdateCounter(cRestSubNotifToXapp)
78         mainCtrl.c.UpdateCounter(cRestSubFailNotifToXapp)
79         mainCtrl.c.UpdateCounter(cSubReqToE2)
80         mainCtrl.c.UpdateCounter(cSubReReqToE2)
81         mainCtrl.c.UpdateCounter(cSubRespFromE2)
82         mainCtrl.c.UpdateCounter(cPartialSubRespFromE2)
83         mainCtrl.c.UpdateCounter(cSubFailFromE2)
84         mainCtrl.c.UpdateCounter(cSubReqTimerExpiry)
85         mainCtrl.c.UpdateCounter(cRouteCreateFail)
86         mainCtrl.c.UpdateCounter(cRouteCreateUpdateFail)
87         mainCtrl.c.UpdateCounter(cMergedSubscriptions)
88         mainCtrl.c.UpdateCounter(cDuplicateE2SubReq)
89         mainCtrl.c.UpdateCounter(cSubDelReqFromXapp)
90         mainCtrl.c.UpdateCounter(cSubDelRespToXapp)
91         mainCtrl.c.UpdateCounter(cRestSubDelReqFromXapp)
92         mainCtrl.c.UpdateCounter(cRestSubDelRespToXapp)
93         mainCtrl.c.UpdateCounter(cSubDelReqToE2)
94         mainCtrl.c.UpdateCounter(cSubDelReReqToE2)
95         mainCtrl.c.UpdateCounter(cSubDelRespFromE2)
96         mainCtrl.c.UpdateCounter(cSubDelFailFromE2)
97         mainCtrl.c.UpdateCounter(cSubDelReqTimerExpiry)
98         mainCtrl.c.UpdateCounter(cSubDelRequFromE2)
99         mainCtrl.c.UpdateCounter(cRouteDeleteFail)
100         mainCtrl.c.UpdateCounter(cRouteDeleteUpdateFail)
101         mainCtrl.c.UpdateCounter(cUnmergedSubscriptions)
102         mainCtrl.c.UpdateCounter(cSDLWriteFailure)
103         mainCtrl.c.UpdateCounter(cSDLReadFailure)
104         mainCtrl.c.UpdateCounter(cSDLRemoveFailure)
105         mainCtrl.c.UpdateCounter(cE2StateChangedToUp)
106         mainCtrl.c.UpdateCounter(cE2StateChangedToDown)
107         mainCtrl.c.UpdateCounter(cE2StateUnderReset)
108
109         mainCtrl.VerifyCounterValues(t)
110 }