2 ==================================================================================
3 Copyright (c) 2019 AT&T Intellectual Property.
4 Copyright (c) 2019 Nokia
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
10 http://www.apache.org/licenses/LICENSE-2.0
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 ==================================================================================
23 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
28 //-----------------------------------------------------------------------------
30 //-----------------------------------------------------------------------------
31 type testingSubmgrControl struct {
36 func createSubmgrControl(desc string, rtfile string, port string) *testingSubmgrControl {
37 mainCtrl = &testingSubmgrControl{}
38 mainCtrl.testingRmrControl.init(desc, rtfile, port)
39 mainCtrl.c = NewControl()
40 xapp.SetReadyCB(mainCtrl.ReadyCB, nil)
41 go xapp.RunWithParams(mainCtrl.c, false)
46 func (mc *testingSubmgrControl) wait_subs_clean(t *testing.T, e2SubsId int, secs int) bool {
47 var subs *Subscription
49 for ; i <= secs*2; i++ {
50 subs = mc.c.registry.GetSubscription(uint16(e2SubsId))
54 time.Sleep(500 * time.Millisecond)
57 testError(t, "(general) no clean within %d secs: %s", secs, subs.String())
59 testError(t, "(general) no clean within %d secs: subs(N/A)", secs)
64 func (mc *testingSubmgrControl) wait_subs_trans_clean(t *testing.T, e2SubsId int, secs int) bool {
65 var trans *Transaction
67 for ; i <= secs*2; i++ {
68 subs := mc.c.registry.GetSubscription(uint16(e2SubsId))
72 trans = subs.GetTransaction()
76 time.Sleep(500 * time.Millisecond)
79 testError(t, "(general) no clean within %d secs: %s", secs, trans.String())
81 testError(t, "(general) no clean within %d secs: trans(N/A)", secs)
86 func (mc *testingSubmgrControl) get_subid(t *testing.T) uint16 {
87 mc.c.registry.mutex.Lock()
88 defer mc.c.registry.mutex.Unlock()
89 return mc.c.registry.subIds[0]
92 func (mc *testingSubmgrControl) wait_subid_change(t *testing.T, origSubId uint16, secs int) (uint16, bool) {
94 for ; i <= secs*2; i++ {
95 mc.c.registry.mutex.Lock()
96 currSubId := mc.c.registry.subIds[0]
97 mc.c.registry.mutex.Unlock()
98 if currSubId != origSubId {
99 return currSubId, true
101 time.Sleep(500 * time.Millisecond)
103 testError(t, "(general) no subId change within %d secs", secs)
107 func (mc *testingSubmgrControl) get_msgcounter(t *testing.T) uint64 {
108 return mc.c.msgCounter
111 func (mc *testingSubmgrControl) wait_msgcounter_change(t *testing.T, orig uint64, secs int) (uint64, bool) {
113 for ; i <= secs*2; i++ {
114 curr := mc.c.msgCounter
118 time.Sleep(500 * time.Millisecond)
120 testError(t, "(general) no msg counter change within %d secs", secs)