blob: b1379052548864c83c916d90ba6324d1c691193d [file] [log] [blame]
Juha Hyttinenfa015662020-01-24 10:05:18 +02001/*
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
20package control
21
22import (
Anssi Mannila4abf1802021-01-28 13:06:46 +020023 "testing"
24 "time"
25
Anssi Mannila9bcb0a42020-02-11 11:30:44 +020026 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
Markku Virtanenfa39fed2021-05-25 08:18:43 +000027 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper"
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020028 "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststube2ap"
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +020029 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
30 "github.com/stretchr/testify/assert"
Juha Hyttinenfa015662020-01-24 10:05:18 +020031)
32
Markku Virtanenfa39fed2021-05-25 08:18:43 +000033func TestRESTSubReqAndDeleteOkWithE2apUtWrapper(t *testing.T) {
34
35 // The effect of this call shall endure thgough the UT suite!
36 // If this causes any issues, the previout interface can be restored
37 // like this:
38 // SetPackerIf(e2ap_wrapper.NewAsn1E2APPacker())
39
40 SetPackerIf(e2ap_wrapper.NewUtAsn1E2APPacker())
41
42 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, nil)
43
44 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
45
46 waitSubsCleanup(t, e2SubsId, 10)
47}
48
Juha Hyttinenfa015662020-01-24 10:05:18 +020049//-----------------------------------------------------------------------------
50// TestSubReqAndRouteNok
51//
52// stub stub
53// +-------+ +---------+ +---------+
Anssi Mannila4abf1802021-01-28 13:06:46 +020054// | xapp | | submgr | | rtmgr |
Juha Hyttinenfa015662020-01-24 10:05:18 +020055// +-------+ +---------+ +---------+
56// | | |
57// | SubReq | |
58// |------------->| |
59// | | |
60// | | RouteCreate |
61// | |------------->|
62// | | |
63// | | RouteCreate |
64// | | status:400 |
65// | |<-------------|
66// | | |
67// | [SUBS INT DELETE] |
68// | | |
69//
70//-----------------------------------------------------------------------------
71
72func TestSubReqAndRouteNok(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020073 CaseBegin("TestSubReqAndRouteNok")
Juha Hyttinenfa015662020-01-24 10:05:18 +020074
Anssi Mannila4abf1802021-01-28 13:06:46 +020075 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +020076 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
77 Counter{cSubReqFromXapp, 1},
78 Counter{cRouteCreateFail, 1},
79 })
Anssi Mannila4abf1802021-01-28 13:06:46 +020080
Juha Hyttinenfa015662020-01-24 10:05:18 +020081 waiter := rtmgrHttp.AllocNextEvent(false)
Juha Hyttinen1683f912020-04-17 10:39:57 +030082 newSubsId := mainCtrl.get_registry_next_subid(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020083 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +020084 waiter.WaitResult(t)
85
86 //Wait that subs is cleaned
Juha Hyttinen83ada002020-01-30 10:36:33 +020087 mainCtrl.wait_subs_clean(t, newSubsId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +020088
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020089 xappConn1.TestMsgChanEmpty(t)
90 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +020091 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +020092 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +020093
94 <-time.After(1 * time.Second)
95 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +020096}
97
98//-----------------------------------------------------------------------------
Anssi Mannila4abf1802021-01-28 13:06:46 +020099// TestSubReqAndRouteUpdateNok
100
101// stub stub
102// +-------+ +-------+ +---------+ +---------+
103// | xapp2 | | xapp1 | | submgr | | rtmgr |
104// +-------+ +-------+ +---------+ +---------+
105// | | | |
106// | [SUBS CREATE] | |
107// | | | |
108// | | | |
109// | | | |
110// | SubReq (mergeable) | |
111// |--------------------------->| | |
112// | | | |
113// | | | RouteUpdate |
114// | | |------------->|
115// | | | |
116// | | | RouteUpdate |
117// | | | status:400 |
118// | | |<-------------|
119// | | | |
120// | [SUBS INT DELETE] | |
121// | | | |
122// | | | |
123// | [SUBS DELETE] | |
124// | | | |
archaggeafbf95f2021-04-14 08:54:05 +0300125
Anssi Mannila4abf1802021-01-28 13:06:46 +0200126func TestSubReqAndRouteUpdateNok(t *testing.T) {
127 CaseBegin("TestSubReqAndRouteUpdateNok")
128
129 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200130 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
131 Counter{cSubReqFromXapp, 2},
132 Counter{cSubReqToE2, 1},
133 Counter{cSubRespFromE2, 1},
134 Counter{cSubRespToXapp, 1},
135 Counter{cRouteCreateUpdateFail, 1},
136 Counter{cSubDelReqFromXapp, 1},
137 Counter{cSubDelReqToE2, 1},
138 Counter{cSubDelRespFromE2, 1},
139 Counter{cSubDelRespToXapp, 1},
140 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200141
142 cretrans := xappConn1.SendSubsReq(t, nil, nil)
143 crereq, cremsg := e2termConn1.RecvSubsReq(t)
144 e2termConn1.SendSubsResp(t, crereq, cremsg)
145 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
146
147 resp, _ := xapp.Subscription.QuerySubscriptions()
148 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
149 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300150 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200151
152 waiter := rtmgrHttp.AllocNextEvent(false)
153 newSubsId := mainCtrl.get_registry_next_subid(t)
154 xappConn2.SendSubsReq(t, nil, nil)
155 waiter.WaitResult(t)
156
157 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
158 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
159
160 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
161 xappConn1.RecvSubsDelResp(t, deltrans)
162
163 //Wait that subs is cleaned
164 mainCtrl.wait_subs_clean(t, newSubsId, 10)
165 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
166
167 xappConn1.TestMsgChanEmpty(t)
168 xappConn2.TestMsgChanEmpty(t)
169 e2termConn1.TestMsgChanEmpty(t)
170 mainCtrl.wait_registry_empty(t, 10)
171
172 mainCtrl.VerifyCounterValues(t)
173}
174
175//-----------------------------------------------------------------------------
176// TestSubDelReqAndRouteDeleteNok
177//
178// stub stub
179// +-------+ +---------+ +---------+ +---------+
180// | xapp | | submgr | | e2term | | rtmgr |
181// +-------+ +---------+ +---------+ +---------+
182// | | | |
183// | [SUBS CREATE] | |
184// | | | |
185// | | | |
186// | | | |
187// | SubDelReq | | |
188// |------------->| | |
189// | | SubDelReq | |
190// | |------------->| |
191// | | SubDelRsp | |
192// | |<-------------| |
193// | SubDelRsp | | |
194// |<-------------| | |
195// | | RouteDelete | |
196// | |---------------------------->|
197// | | | |
198// | | RouteDelete | |
199// | | status:400 | |
200// | |<----------------------------|
201// | | | |
202func TestSubDelReqAndRouteDeleteNok(t *testing.T) {
203 CaseBegin("TestSubDelReqAndRouteDeleteNok")
204
205 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200206 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
207 Counter{cSubReqFromXapp, 1},
208 Counter{cSubReqToE2, 1},
209 Counter{cSubRespFromE2, 1},
210 Counter{cSubRespToXapp, 1},
211 Counter{cSubDelReqFromXapp, 1},
212 Counter{cRouteDeleteFail, 1},
213 Counter{cSubDelReqToE2, 1},
214 Counter{cSubDelRespFromE2, 1},
215 Counter{cSubDelRespToXapp, 1},
216 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200217
218 cretrans := xappConn1.SendSubsReq(t, nil, nil)
219 crereq, cremsg := e2termConn1.RecvSubsReq(t)
220 e2termConn1.SendSubsResp(t, crereq, cremsg)
221 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
222
223 resp, _ := xapp.Subscription.QuerySubscriptions()
224 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
225 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300226 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200227
228 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
229 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
230
231 waiter := rtmgrHttp.AllocNextEvent(false)
232 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
233 waiter.WaitResult(t)
234
235 xappConn1.RecvSubsDelResp(t, deltrans)
236
237 //Wait that subs is cleaned
238 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
239
240 xappConn1.TestMsgChanEmpty(t)
241 xappConn2.TestMsgChanEmpty(t)
242 e2termConn1.TestMsgChanEmpty(t)
243 mainCtrl.wait_registry_empty(t, 10)
244
245 mainCtrl.VerifyCounterValues(t)
246}
247
248//-----------------------------------------------------------------------------
249// TestSubMergeDelAndRouteUpdateNok
250// stub stub
251// +-------+ +-------+ +---------+ +---------+
252// | xapp2 | | xapp1 | | submgr | | e2term |
253// +-------+ +-------+ +---------+ +---------+
254// | | | |
255// | | | |
256// | | | |
257// | | SubReq1 | |
258// | |------------->| |
259// | | | |
260// | | | SubReq1 |
261// | | |------------->|
262// | | | SubResp1 |
263// | | |<-------------|
264// | | SubResp1 | |
265// | |<-------------| |
266// | | | |
267// | SubReq2 | |
268// |--------------------------->| |
269// | | | |
270// | SubResp2 | |
271// |<---------------------------| |
272// | | | |
273// | | SubDelReq 1 | |
274// | |------------->| |
275// | | | RouteUpdate |
276// | | |-----> rtmgr |
277// | | | |
278// | | | RouteUpdate |
279// | | | status:400 |
280// | | |<----- rtmgr |
281// | | | |
282// | | SubDelResp 1 | |
283// | |<-------------| |
284// | | | |
285// | SubDelReq 2 | |
286// |--------------------------->| |
287// | | | |
288// | | | SubDelReq 2 |
289// | | |------------->|
290// | | | |
291// | | | SubDelReq 2 |
292// | | |------------->|
293// | | | |
294// | SubDelResp 2 | |
295// |<---------------------------| |
296//
297//-----------------------------------------------------------------------------
298func TestSubMergeDelAndRouteUpdateNok(t *testing.T) {
299 CaseBegin("TestSubMergeDelAndRouteUpdateNok")
300
301 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200302 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
303 Counter{cSubReqFromXapp, 2},
304 Counter{cSubReqToE2, 1},
305 Counter{cSubRespFromE2, 1},
306 Counter{cSubRespToXapp, 2},
307 Counter{cSubDelReqFromXapp, 2},
308 Counter{cRouteDeleteUpdateFail, 1},
309 Counter{cSubDelReqToE2, 1},
310 Counter{cSubDelRespFromE2, 1},
311 Counter{cSubDelRespToXapp, 2},
312 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200313
314 //Req1
315 rparams1 := &teststube2ap.E2StubSubsReqParams{}
316 rparams1.Init()
317 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
318 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
319 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
320 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
321
322 //Req2
323 rparams2 := &teststube2ap.E2StubSubsReqParams{}
324 rparams2.Init()
325 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
326 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
327
328 resp, _ := xapp.Subscription.QuerySubscriptions()
329 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
330 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300331 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannila4abf1802021-01-28 13:06:46 +0200332
333 //Del1
334 waiter := rtmgrHttp.AllocNextEvent(false)
335 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
336 waiter.WaitResult(t)
337
338 xappConn1.RecvSubsDelResp(t, deltrans1)
339
340 //Del2
341 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
342 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
343 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
344 xappConn2.RecvSubsDelResp(t, deltrans2)
345 //Wait that subs is cleaned
346 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
347
348 xappConn1.TestMsgChanEmpty(t)
349 xappConn2.TestMsgChanEmpty(t)
350 e2termConn1.TestMsgChanEmpty(t)
351 mainCtrl.wait_registry_empty(t, 10)
352
353 mainCtrl.VerifyCounterValues(t)
354}
355
356//-----------------------------------------------------------------------------
357
358//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200359// TestSubReqAndSubDelOk
360//
361// stub stub
362// +-------+ +---------+ +---------+
363// | xapp | | submgr | | e2term |
364// +-------+ +---------+ +---------+
365// | | |
366// | SubReq | |
367// |------------->| |
368// | | |
369// | | SubReq |
370// | |------------->|
371// | | |
372// | | SubResp |
373// | |<-------------|
374// | | |
375// | SubResp | |
376// |<-------------| |
377// | | |
378// | | |
379// | SubDelReq | |
380// |------------->| |
381// | | |
382// | | SubDelReq |
383// | |------------->|
384// | | |
385// | | SubDelResp |
386// | |<-------------|
387// | | |
388// | SubDelResp | |
389// |<-------------| |
390//
391//-----------------------------------------------------------------------------
392func TestSubReqAndSubDelOk(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200393 CaseBegin("TestSubReqAndSubDelOk")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200394
Anssi Mannila4abf1802021-01-28 13:06:46 +0200395 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200396 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
397 Counter{cSubReqFromXapp, 1},
398 Counter{cSubReqToE2, 1},
399 Counter{cSubRespFromE2, 1},
400 Counter{cSubRespToXapp, 1},
401 Counter{cSubDelReqFromXapp, 1},
402 Counter{cSubDelReqToE2, 1},
403 Counter{cSubDelRespFromE2, 1},
404 Counter{cSubDelRespToXapp, 1},
405 })
Anssi Mannila4abf1802021-01-28 13:06:46 +0200406
407 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200408 crereq, cremsg := e2termConn1.RecvSubsReq(t)
409 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200410 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200411
412 resp, _ := xapp.Subscription.QuerySubscriptions()
413 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
414 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +0300415 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200416
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200417 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200418 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200419
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200420 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200421 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200422
423 //Wait that subs is cleaned
424 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
425
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200426 xappConn1.TestMsgChanEmpty(t)
427 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200428 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200429 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200430
431 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200432}
433
434//-----------------------------------------------------------------------------
435// TestSubReqRetransmission
436//
437// stub stub
438// +-------+ +---------+ +---------+
439// | xapp | | submgr | | e2term |
440// +-------+ +---------+ +---------+
441// | | |
442// | SubReq | |
443// |------------->| |
444// | | |
445// | | SubReq |
446// | |------------->|
447// | | |
448// | SubReq | |
449// | (retrans) | |
450// |------------->| |
451// | | |
452// | | SubResp |
453// | |<-------------|
454// | | |
455// | SubResp | |
456// |<-------------| |
457// | | |
458// | [SUBS DELETE] |
459// | | |
460//
461//-----------------------------------------------------------------------------
462func TestSubReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200463 CaseBegin("TestSubReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200464
465 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200466 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200467 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200468
469 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200470 xappConn1.SendSubsReq(t, nil, cretrans) //Retransmitted SubReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200471 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
472
Juha Hyttinen1683f912020-04-17 10:39:57 +0300473 // hack as there is no real way to see has message be handled.
474 // Previuos counter check just tells that is has been received by submgr
475 // --> artificial delay
476 <-time.After(1 * time.Second)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200477 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200478 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200479
480 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200481 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200482 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
483 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200484 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200485
486 //Wait that subs is cleaned
487 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
488
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200489 xappConn1.TestMsgChanEmpty(t)
490 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200491 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200492 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200493}
494
495//-----------------------------------------------------------------------------
496// TestSubDelReqRetransmission
497//
498// stub stub
499// +-------+ +---------+ +---------+
500// | xapp | | submgr | | e2term |
501// +-------+ +---------+ +---------+
502// | | |
503// | [SUBS CREATE] |
504// | | |
505// | | |
506// | SubDelReq | |
507// |------------->| |
508// | | |
509// | | SubDelReq |
510// | |------------->|
511// | | |
512// | SubDelReq | |
513// | (same sub) | |
514// | (same xid) | |
515// |------------->| |
516// | | |
517// | | SubDelResp |
518// | |<-------------|
519// | | |
520// | SubDelResp | |
521// |<-------------| |
522//
523//-----------------------------------------------------------------------------
524func TestSubDelReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200525 CaseBegin("TestSubDelReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200526
527 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200528 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200529 crereq, cremsg := e2termConn1.RecvSubsReq(t)
530 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200531 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200532
533 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200534 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200535 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200536
537 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200538 xappConn1.SendSubsDelReq(t, deltrans, e2SubsId) //Retransmitted SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200539 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
540
Juha Hyttinen1683f912020-04-17 10:39:57 +0300541 // hack as there is no real way to see has message be handled.
542 // Previuos counter check just tells that is has been received by submgr
543 // --> artificial delay
544 <-time.After(1 * time.Second)
545
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200546 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200547 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200548
549 //Wait that subs is cleaned
550 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
551
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200552 xappConn1.TestMsgChanEmpty(t)
553 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200554 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200555 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200556}
557
558//-----------------------------------------------------------------------------
559// TestSubDelReqCollision
560//
561// stub stub
562// +-------+ +---------+ +---------+
563// | xapp | | submgr | | e2term |
564// +-------+ +---------+ +---------+
565// | | |
566// | [SUBS CREATE] |
567// | | |
568// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200569// | SubDelReq 1 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200570// |------------->| |
571// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200572// | | SubDelReq 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200573// | |------------->|
574// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200575// | SubDelReq 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200576// | (same sub) | |
577// | (diff xid) | |
578// |------------->| |
579// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200580// | | SubDelResp 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200581// | |<-------------|
582// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200583// | SubDelResp 1 | |
584// |<-------------| |
585// | | |
586// | SubDelResp 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200587// |<-------------| |
588//
589//-----------------------------------------------------------------------------
Juha Hyttinen3944a222020-01-24 11:51:46 +0200590
Juha Hyttinenfa015662020-01-24 10:05:18 +0200591func TestSubDelReqCollision(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200592 CaseBegin("TestSubDelReqCollision")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200593
594 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200595 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200596 crereq, cremsg := e2termConn1.RecvSubsReq(t)
597 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200598 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200599
600 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200601 xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200602 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200603
Juha Hyttinen3944a222020-01-24 11:51:46 +0200604 // Subs Delete colliding
Juha Hyttinenfa015662020-01-24 10:05:18 +0200605 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200606 deltranscol2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
607 xappConn1.SendSubsDelReq(t, deltranscol2, e2SubsId) //Colliding SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200608 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
609
Juha Hyttinen1683f912020-04-17 10:39:57 +0300610 // hack as there is no real way to see has message be handled.
611 // Previuos counter check just tells that is has been received by submgr
612 // --> artificial delay
613 <-time.After(1 * time.Second)
614
Juha Hyttinen3944a222020-01-24 11:51:46 +0200615 // Del resp for first and second
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200616 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200617
618 // don't care in which order responses are received
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200619 xappConn1.RecvSubsDelResp(t, nil)
620 xappConn1.RecvSubsDelResp(t, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200621
622 //Wait that subs is cleaned
623 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
624
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200625 xappConn1.TestMsgChanEmpty(t)
626 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200627 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200628 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200629}
630
631//-----------------------------------------------------------------------------
632// TestSubReqAndSubDelOkTwoParallel
633//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200634// stub stub stub
635// +-------+ +-------+ +---------+ +---------+
636// | xapp | | xapp | | submgr | | e2term |
637// +-------+ +-------+ +---------+ +---------+
638// | | | |
639// | | | |
640// | | | |
641// | | SubReq1 | |
642// | |------------->| |
643// | | | |
644// | | | SubReq1 |
645// | | |------------->|
646// | | | |
647// | SubReq2 | |
648// |------------------------>| |
649// | | | |
650// | | | SubReq2 |
651// | | |------------->|
652// | | | |
653// | | | SubResp1 |
654// | | |<-------------|
655// | | SubResp1 | |
656// | |<-------------| |
657// | | | |
658// | | | SubResp2 |
659// | | |<-------------|
660// | SubResp2 | |
661// |<------------------------| |
662// | | | |
663// | | [SUBS 1 DELETE] |
664// | | | |
665// | | [SUBS 2 DELETE] |
666// | | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200667//
668//-----------------------------------------------------------------------------
archaggeafbf95f2021-04-14 08:54:05 +0300669
Juha Hyttinenfa015662020-01-24 10:05:18 +0200670func TestSubReqAndSubDelOkTwoParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200671 CaseBegin("TestSubReqAndSubDelOkTwoParallel")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200672
673 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200674 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +0200675 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200676 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200677 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200678
679 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200680 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +0200681 rparams2.Init()
Juha Hyttinencdc35bf2020-07-11 13:32:57 +0300682
683 rparams2.Req.EventTriggerDefinition.Data.Length = 1
684 rparams2.Req.EventTriggerDefinition.Data.Data = make([]uint8, rparams2.Req.EventTriggerDefinition.Data.Length)
685 rparams2.Req.EventTriggerDefinition.Data.Data[0] = 2
686
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200687 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200688 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200689
690 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200691 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200692 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200693
694 //Resp2
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200695 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200696 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200697
698 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200699 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200700 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
701 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200702 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200703 //Wait that subs is cleaned
704 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
705
706 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200707 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200708 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
709 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200710 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200711 //Wait that subs is cleaned
712 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
713
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200714 xappConn1.TestMsgChanEmpty(t)
715 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200716 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200717 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200718}
719
720//-----------------------------------------------------------------------------
721// TestSameSubsDiffRan
722// Same subscription to different RANs
723//
724// stub stub
725// +-------+ +---------+ +---------+
726// | xapp | | submgr | | e2term |
727// +-------+ +---------+ +---------+
728// | | |
729// | | |
730// | | |
731// | SubReq(r1) | |
732// |------------->| |
733// | | |
734// | | SubReq(r1) |
735// | |------------->|
736// | | |
737// | | SubResp(r1) |
738// | |<-------------|
739// | | |
740// | SubResp(r1) | |
741// |<-------------| |
742// | | |
743// | SubReq(r2) | |
744// |------------->| |
745// | | |
746// | | SubReq(r2) |
747// | |------------->|
748// | | |
749// | | SubResp(r2) |
750// | |<-------------|
751// | | |
752// | SubResp(r2) | |
753// |<-------------| |
754// | | |
755// | [SUBS r1 DELETE] |
756// | | |
757// | [SUBS r2 DELETE] |
758// | | |
759//
760//-----------------------------------------------------------------------------
761func TestSameSubsDiffRan(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200762 CaseBegin("TestSameSubsDiffRan")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200763
764 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200765 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
766 xappConn1.SendSubsReq(t, nil, cretrans1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200767 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
768 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200769 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200770
771 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200772 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
773 xappConn1.SendSubsReq(t, nil, cretrans2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200774 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
775 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200776 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200777
778 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200779 deltrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
780 xappConn1.SendSubsDelReq(t, deltrans1, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200781 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
782 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200783 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200784 //Wait that subs is cleaned
785 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
786
787 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200788 deltrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
789 xappConn1.SendSubsDelReq(t, deltrans2, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200790 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
791 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200792 xappConn1.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200793 //Wait that subs is cleaned
794 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
795
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200796 xappConn1.TestMsgChanEmpty(t)
797 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200798 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200799 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200800}
801
802//-----------------------------------------------------------------------------
803// TestSubReqRetryInSubmgr
804//
805// stub stub
806// +-------+ +---------+ +---------+
807// | xapp | | submgr | | e2term |
808// +-------+ +---------+ +---------+
809// | | |
810// | SubReq | |
811// |------------->| |
812// | | |
813// | | SubReq |
814// | |------------->|
815// | | |
816// | | |
817// | | SubReq |
818// | |------------->|
819// | | |
820// | | SubResp |
821// | |<-------------|
822// | | |
823// | SubResp | |
824// |<-------------| |
825// | | |
826// | [SUBS DELETE] |
827// | | |
828//
829//-----------------------------------------------------------------------------
830
831func TestSubReqRetryInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200832 CaseBegin("TestSubReqRetryInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200833
834 // Init counter check
835 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
836 Counter{cSubReqFromXapp, 1},
837 Counter{cSubReqToE2, 1},
838 Counter{cSubReReqToE2, 1},
839 Counter{cSubRespFromE2, 1},
840 Counter{cSubRespToXapp, 1},
841 Counter{cSubDelReqFromXapp, 1},
842 Counter{cSubDelReqToE2, 1},
843 Counter{cSubDelRespFromE2, 1},
844 Counter{cSubDelRespToXapp, 1},
845 })
Juha Hyttinenfa015662020-01-24 10:05:18 +0200846
847 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200848 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200849
850 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200851 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200852
853 // E2t: Receive 2nd SubsReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200854 crereq, cremsg := e2termConn1.RecvSubsReq(t)
855 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200856
857 // Xapp: Receive SubsResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200858 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200859
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200860 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200861 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
862 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200863 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200864
865 // Wait that subs is cleaned
866 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
867
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200868 xappConn1.TestMsgChanEmpty(t)
869 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200870 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200871 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200872
873 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200874}
875
876//-----------------------------------------------------------------------------
877// TestSubReqTwoRetriesNoRespSubDelRespInSubmgr
878//
879// stub stub
880// +-------+ +---------+ +---------+
881// | xapp | | submgr | | e2term |
882// +-------+ +---------+ +---------+
883// | | |
884// | SubReq | |
885// |------------->| |
886// | | |
887// | | SubReq |
888// | |------------->|
889// | | |
890// | | |
891// | | SubReq |
892// | |------------->|
893// | | |
894// | | SubDelReq |
895// | |------------->|
896// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200897// | | SubDelResp |
898// | |<-------------|
899// | | |
900//
901//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200902func TestSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200903 CaseBegin("TestSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200904
905 // Init counter check
906 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
907 Counter{cSubReqFromXapp, 1},
908 Counter{cSubReqToE2, 1},
909 Counter{cSubReReqToE2, 1},
910 Counter{cSubReqTimerExpiry, 2},
911 Counter{cSubDelReqToE2, 1},
912 Counter{cSubDelRespFromE2, 1},
913 })
Juha Hyttinenfa015662020-01-24 10:05:18 +0200914
915 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200916 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200917
918 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200919 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200920
921 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200922 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200923
924 // E2t: Send receive SubsDelReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200925 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
926 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200927
928 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +0300929 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200930
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200931 xappConn1.TestMsgChanEmpty(t)
932 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200933 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200934 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +0200935
936 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200937}
938
939//-----------------------------------------------------------------------------
940// TestSubReqTwoRetriesNoRespAtAllInSubmgr
941//
942// stub stub
943// +-------+ +---------+ +---------+
944// | xapp | | submgr | | e2term |
945// +-------+ +---------+ +---------+
946// | | |
947// | SubReq | |
948// |------------->| |
949// | | |
950// | | SubReq |
951// | |------------->|
952// | | |
953// | | |
954// | | SubReq |
955// | |------------->|
956// | | |
957// | | SubDelReq |
958// | |------------->|
959// | | |
960// | | |
961// | | SubDelReq |
962// | |------------->|
963// | | |
964// | | |
965//
966//-----------------------------------------------------------------------------
967
968func TestSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200969 CaseBegin("TestSubReqTwoRetriesNoRespAtAllInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +0200970
971 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
972 Counter{cSubReqFromXapp, 1},
973 Counter{cSubReqToE2, 1},
974 Counter{cSubReReqToE2, 1},
975 Counter{cSubReqTimerExpiry, 2},
976 Counter{cSubDelReqToE2, 1},
977 Counter{cSubDelReReqToE2, 1},
978 Counter{cSubDelReqTimerExpiry, 2},
979 })
Juha Hyttinenfa015662020-01-24 10:05:18 +0200980
981 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200982 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200983
984 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200985 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200986
987 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200988 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200989
990 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200991 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200992
993 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200994 delreq, _ := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200995
996 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +0300997 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200998
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200999 xappConn1.TestMsgChanEmpty(t)
1000 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001001 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001002 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001003
1004 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001005}
1006
1007//-----------------------------------------------------------------------------
1008// TestSubReqSubFailRespInSubmgr
1009//
1010// stub stub
1011// +-------+ +---------+ +---------+
1012// | xapp | | submgr | | e2term |
1013// +-------+ +---------+ +---------+
1014// | | |
1015// | SubReq | |
1016// |------------->| |
1017// | | |
1018// | | SubReq |
1019// | |------------->|
1020// | | |
1021// | | SubFail |
1022// | |<-------------|
1023// | | |
archaggeafbf95f2021-04-14 08:54:05 +03001024// | | SubDelReq |
1025// | |------------->|
1026// | | |
1027// | | SubDelResp |
1028// | |<-------------|
1029// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +02001030// | SubFail | |
1031// |<-------------| |
1032// | | |
1033//
1034//-----------------------------------------------------------------------------
1035
1036func TestSubReqSubFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001037 CaseBegin("TestSubReqSubFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001038
1039 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1040 Counter{cSubReqFromXapp, 1},
1041 Counter{cSubReqToE2, 1},
1042 Counter{cSubFailFromE2, 1},
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001043 Counter{cSubFailToXapp, 1},
1044 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001045
1046 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001047 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001048
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001049 // E2t: Receive SubsReq and send SubsFail (first)
1050 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1051 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1052 fparams1.Set(crereq1)
1053 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1054
archaggeafbf95f2021-04-14 08:54:05 +03001055 // E2t: Receive SubsDelReq and send SubsDelResp (internal first)
1056 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1057 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
1058
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001059 // Xapp: Receive SubsFail
1060 e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
1061
1062 // Wait that subs is cleaned
1063 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1064
1065 xappConn1.TestMsgChanEmpty(t)
1066 xappConn2.TestMsgChanEmpty(t)
1067 e2termConn1.TestMsgChanEmpty(t)
1068 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001069
1070 mainCtrl.VerifyCounterValues(t)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001071}
1072
1073//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +02001074// TestSubDelReqRetryInSubmgr
1075//
1076// stub stub
1077// +-------+ +---------+ +---------+
1078// | xapp | | submgr | | e2term |
1079// +-------+ +---------+ +---------+
1080// | | |
1081// | [SUBS CREATE] |
1082// | | |
1083// | | |
1084// | SubDelReq | |
1085// |------------->| |
1086// | | |
1087// | | SubDelReq |
1088// | |------------->|
1089// | | |
1090// | | SubDelReq |
1091// | |------------->|
1092// | | |
1093// | | SubDelResp |
1094// | |<-------------|
1095// | | |
1096// | SubDelResp | |
1097// |<-------------| |
1098//
1099//-----------------------------------------------------------------------------
1100
1101func TestSubDelReqRetryInSubmgr(t *testing.T) {
1102
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001103 CaseBegin("TestSubDelReqRetryInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001104
1105 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001106 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001107 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1108 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001109 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001110
1111 // Subs Delete
1112 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001113 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001114
1115 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001116 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001117
1118 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001119 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1120 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001121
1122 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001123 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001124
1125 // Wait that subs is cleaned
1126 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1127
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001128 xappConn1.TestMsgChanEmpty(t)
1129 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001130 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001131 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001132}
1133
1134//-----------------------------------------------------------------------------
1135// TestSubDelReqTwoRetriesNoRespInSubmgr
1136//
1137// stub stub
1138// +-------+ +---------+ +---------+
1139// | xapp | | submgr | | e2term |
1140// +-------+ +---------+ +---------+
1141// | | |
1142// | [SUBS CREATE] |
1143// | | |
1144// | | |
1145// | SubDelReq | |
1146// |------------->| |
1147// | | |
1148// | | SubDelReq |
1149// | |------------->|
1150// | | |
1151// | | SubDelReq |
1152// | |------------->|
1153// | | |
1154// | | |
1155// | SubDelResp | |
1156// |<-------------| |
1157//
1158//-----------------------------------------------------------------------------
1159
1160func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
1161
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001162 CaseBegin("TestSubDelReTwoRetriesNoRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001163
1164 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001165 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001166 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1167 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001168 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001169
1170 // Subs Delete
1171 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001172 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001173
1174 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001175 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001176
1177 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001178 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001179
1180 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001181 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001182
1183 // Wait that subs is cleaned
1184 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1185
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001186 xappConn1.TestMsgChanEmpty(t)
1187 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001188 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001189 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001190}
1191
1192//-----------------------------------------------------------------------------
1193// TestSubDelReqSubDelFailRespInSubmgr
1194//
1195// stub stub
1196// +-------+ +---------+ +---------+
1197// | xapp | | submgr | | e2term |
1198// +-------+ +---------+ +---------+
1199// | | |
1200// | [SUBS CREATE] |
1201// | | |
1202// | | |
1203// | SubDelReq | |
1204// |------------->| |
1205// | | |
1206// | | SubDelReq |
1207// | |------------->|
1208// | | |
1209// | | SubDelFail |
1210// | |<-------------|
1211// | | |
1212// | SubDelResp | |
1213// |<-------------| |
1214// | | |
1215//
1216//-----------------------------------------------------------------------------
1217
1218func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001219 CaseBegin("TestSubReqSubDelFailRespInSubmgr start")
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001220
1221 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1222 Counter{cSubReqFromXapp, 1},
1223 Counter{cSubReqToE2, 1},
1224 Counter{cSubRespFromE2, 1},
1225 Counter{cSubRespToXapp, 1},
1226 Counter{cSubDelReqFromXapp, 1},
1227 Counter{cSubDelReqToE2, 1},
1228 Counter{cSubDelFailFromE2, 1},
1229 Counter{cSubDelRespToXapp, 1},
1230 })
Juha Hyttinenfa015662020-01-24 10:05:18 +02001231
1232 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001233 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001234 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1235 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001236 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001237
1238 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001239 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001240
1241 // E2t: Send receive SubsDelReq and send SubsDelFail
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001242 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1243 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001244
1245 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001246 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001247
1248 // Wait that subs is cleaned
1249 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1250
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001251 xappConn1.TestMsgChanEmpty(t)
1252 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001253 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001254 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001255
1256 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001257}
1258
1259//-----------------------------------------------------------------------------
1260// TestSubReqAndSubDelOkSameAction
1261//
1262// stub stub
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001263// +-------+ +-------+ +---------+ +---------+
1264// | xapp2 | | xapp1 | | submgr | | e2term |
1265// +-------+ +-------+ +---------+ +---------+
1266// | | | |
1267// | | | |
1268// | | | |
1269// | | SubReq1 | |
1270// | |------------->| |
1271// | | | |
1272// | | | SubReq1 |
1273// | | |------------->|
1274// | | | SubResp1 |
1275// | | |<-------------|
1276// | | SubResp1 | |
1277// | |<-------------| |
1278// | | | |
1279// | SubReq2 | |
1280// |--------------------------->| |
1281// | | | |
1282// | SubResp2 | |
1283// |<---------------------------| |
1284// | | | |
1285// | | SubDelReq 1 | |
1286// | |------------->| |
1287// | | | |
1288// | | SubDelResp 1 | |
1289// | |<-------------| |
1290// | | | |
1291// | SubDelReq 2 | |
1292// |--------------------------->| |
1293// | | | |
1294// | | | SubDelReq 2 |
1295// | | |------------->|
1296// | | | |
1297// | | | SubDelReq 2 |
1298// | | |------------->|
1299// | | | |
1300// | SubDelResp 2 | |
1301// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001302//
1303//-----------------------------------------------------------------------------
1304func TestSubReqAndSubDelOkSameAction(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001305 CaseBegin("TestSubReqAndSubDelOkSameAction")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001306
Anssi Mannila4abf1802021-01-28 13:06:46 +02001307 // Init counter check
Anssi Mannila6b3796f2021-02-12 09:11:35 +02001308 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
1309 Counter{cSubReqFromXapp, 2},
1310 Counter{cSubReqToE2, 1},
1311 Counter{cSubRespFromE2, 1},
1312 Counter{cSubRespToXapp, 2},
1313 Counter{cMergedSubscriptions, 1},
1314 Counter{cUnmergedSubscriptions, 1},
1315 Counter{cSubDelReqFromXapp, 2},
1316 Counter{cSubDelReqToE2, 1},
1317 Counter{cSubDelRespFromE2, 1},
1318 Counter{cSubDelRespToXapp, 2},
1319 })
Anssi Mannila4abf1802021-01-28 13:06:46 +02001320
Juha Hyttinen3944a222020-01-24 11:51:46 +02001321 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001322 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001323 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001324 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001325 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1326 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001327 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001328
1329 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001330 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001331 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001332 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001333 //crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
1334 //e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001335 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001336
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001337 resp, _ := xapp.Subscription.QuerySubscriptions()
1338 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
1339 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03001340 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001341
Juha Hyttinen3944a222020-01-24 11:51:46 +02001342 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001343 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001344 //e2termConn1.RecvSubsDelReq(t)
1345 //e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001346 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001347 //Wait that subs is cleaned
1348 //mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1349
1350 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001351 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001352 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1353 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001354 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001355 //Wait that subs is cleaned
1356 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1357
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001358 xappConn1.TestMsgChanEmpty(t)
1359 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001360 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001361 mainCtrl.wait_registry_empty(t, 10)
Anssi Mannila4abf1802021-01-28 13:06:46 +02001362
1363 mainCtrl.VerifyCounterValues(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001364}
1365
1366//-----------------------------------------------------------------------------
1367// TestSubReqAndSubDelOkSameActionParallel
1368//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001369// stub stub stub
1370// +-------+ +-------+ +---------+ +---------+
1371// | xapp2 | | xapp1 | | submgr | | e2term |
1372// +-------+ +-------+ +---------+ +---------+
1373// | | | |
1374// | | | |
1375// | | | |
1376// | | SubReq1 | |
1377// | |------------->| |
1378// | | | |
1379// | | | SubReq1 |
1380// | | |------------->|
1381// | SubReq2 | |
1382// |--------------------------->| |
1383// | | | SubResp1 |
1384// | | |<-------------|
1385// | | SubResp1 | |
1386// | |<-------------| |
1387// | | | |
1388// | SubResp2 | |
1389// |<---------------------------| |
1390// | | | |
1391// | | SubDelReq 1 | |
1392// | |------------->| |
1393// | | | |
1394// | | SubDelResp 1 | |
1395// | |<-------------| |
1396// | | | |
1397// | SubDelReq 2 | |
1398// |--------------------------->| |
1399// | | | |
1400// | | | SubDelReq 2 |
1401// | | |------------->|
1402// | | | |
1403// | | | SubDelReq 2 |
1404// | | |------------->|
1405// | | | |
1406// | SubDelResp 2 | |
1407// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001408//
1409//-----------------------------------------------------------------------------
1410func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001411 CaseBegin("TestSubReqAndSubDelOkSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001412
1413 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001414 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001415 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001416 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001417 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001418
1419 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001420 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001421 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001422 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001423
1424 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001425 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001426 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001427
1428 //Resp2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001429 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001430
1431 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001432 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1433 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001434
1435 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001436 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001437 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1438 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001439 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001440
1441 //Wait that subs is cleaned
1442 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1443
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001444 xappConn1.TestMsgChanEmpty(t)
1445 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001446 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001447 mainCtrl.wait_registry_empty(t, 10)
1448}
1449
1450//-----------------------------------------------------------------------------
1451// TestSubReqAndSubDelNokSameActionParallel
1452//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001453// stub stub stub
1454// +-------+ +-------+ +---------+ +---------+
1455// | xapp2 | | xapp1 | | submgr | | e2term |
1456// +-------+ +-------+ +---------+ +---------+
1457// | | | |
1458// | | | |
1459// | | | |
1460// | | SubReq1 | |
1461// | |------------->| |
1462// | | | |
1463// | | | SubReq1 |
1464// | | |------------->|
1465// | SubReq2 | |
1466// |--------------------------->| |
1467// | | | SubFail1 |
1468// | | |<-------------|
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001469// | | | |
archaggeafbf95f2021-04-14 08:54:05 +03001470// | | | SubDelReq |
1471// | | |------------->|
1472// | | | SubDelResp |
1473// | | |<-------------|
1474// | | | |
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001475// | | SubFail1 | |
1476// | |<-------------| |
1477// | | | |
1478// | SubFail2 | |
1479// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001480//
1481//-----------------------------------------------------------------------------
1482func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001483 CaseBegin("TestSubReqAndSubDelNokSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001484
1485 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001486 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001487 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001488 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001489
1490 // E2t: Receive SubsReq (first)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001491 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001492
1493 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001494 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001495 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001496 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001497 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001498 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001499
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001500 // E2t: send SubsFail (first)
1501 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1502 fparams1.Set(crereq1)
1503 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1504
archaggeafbf95f2021-04-14 08:54:05 +03001505 // E2t: internal delete
1506 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1507 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1508
Juha Hyttinen3944a222020-01-24 11:51:46 +02001509 //Fail1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001510 e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001511 //Fail2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001512 xappConn2.RecvSubsFail(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001513
1514 //Wait that subs is cleaned
1515 mainCtrl.wait_subs_clean(t, e2SubsId1, 15)
1516
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001517 xappConn1.TestMsgChanEmpty(t)
1518 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001519 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001520 mainCtrl.wait_registry_empty(t, 10)
1521}
1522
1523//-----------------------------------------------------------------------------
1524// TestSubReqAndSubDelNoAnswerSameActionParallel
1525//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001526// stub stub stub
1527// +-------+ +-------+ +---------+ +---------+
1528// | xapp2 | | xapp1 | | submgr | | e2term |
1529// +-------+ +-------+ +---------+ +---------+
1530// | | | |
1531// | | | |
1532// | | | |
1533// | | SubReq1 | |
1534// | |------------->| |
1535// | | | |
1536// | | | SubReq1 |
1537// | | |------------->|
1538// | | SubReq2 | |
1539// |--------------------------->| |
1540// | | | |
1541// | | | SubReq1 |
1542// | | |------------->|
1543// | | | |
1544// | | | |
1545// | | | SubDelReq |
1546// | | |------------->|
1547// | | | |
1548// | | | SubDelResp |
1549// | | |<-------------|
Juha Hyttinen3944a222020-01-24 11:51:46 +02001550//
1551//-----------------------------------------------------------------------------
1552func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001553 CaseBegin("TestSubReqAndSubDelNoAnswerSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001554
1555 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001556 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001557 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001558 xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001559
Juha Hyttinen1683f912020-04-17 10:39:57 +03001560 crereq1, _ := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001561
1562 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001563 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001564 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001565 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001566 xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001567 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001568
1569 //Req1 (retransmitted)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001570 e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001571
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001572 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1573 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001574
1575 //Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001576 mainCtrl.wait_subs_clean(t, delreq1.RequestId.InstanceId, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001577
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001578 xappConn1.TestMsgChanEmpty(t)
1579 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001580 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001581 mainCtrl.wait_registry_empty(t, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001582}
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001583
1584//----------------------------- Policy cases ---------------------------------
1585//-----------------------------------------------------------------------------
1586// TestSubReqPolicyAndSubDelOk
1587//
1588// stub stub
1589// +-------+ +---------+ +---------+
1590// | xapp | | submgr | | e2term |
1591// +-------+ +---------+ +---------+
1592// | | |
1593// | SubReq | |
1594// |------------->| |
1595// | | |
1596// | | SubReq |
1597// | |------------->|
1598// | | |
1599// | | SubResp |
1600// | |<-------------|
1601// | | |
1602// | SubResp | |
1603// |<-------------| |
1604// | | |
1605// | | |
1606// | SubDelReq | |
1607// |------------->| |
1608// | | |
1609// | | SubDelReq |
1610// | |------------->|
1611// | | |
1612// | | SubDelResp |
1613// | |<-------------|
1614// | | |
1615// | SubDelResp | |
1616// |<-------------| |
1617//
1618//-----------------------------------------------------------------------------
1619func TestSubReqPolicyAndSubDelOk(t *testing.T) {
1620 CaseBegin("TestSubReqAndSubDelOk")
1621
1622 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1623 rparams1.Init()
1624 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
1625 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
1626
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001627 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1628 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001629 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1630 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001631 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001632
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001633 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001634 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001635
1636 //Wait that subs is cleaned
1637 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1638
1639 xappConn1.TestMsgChanEmpty(t)
1640 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001641 e2termConn1.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001642 mainCtrl.wait_registry_empty(t, 10)
1643}
1644
1645//-----------------------------------------------------------------------------
1646// TestSubReqPolicyChangeAndSubDelOk
1647//
1648// stub stub
1649// +-------+ +---------+ +---------+
1650// | xapp | | submgr | | e2term |
1651// +-------+ +---------+ +---------+
1652// | | |
1653// | SubReq | |
1654// |------------->| |
1655// | | |
1656// | | SubReq |
1657// | |------------->|
1658// | | |
1659// | | SubResp |
1660// | |<-------------|
1661// | | |
1662// | SubResp | |
1663// |<-------------| |
1664// | | |
1665// | SubReq | |
1666// |------------->| |
1667// | | |
1668// | | SubReq |
1669// | |------------->|
1670// | | |
1671// | | SubResp |
1672// | |<-------------|
1673// | | |
1674// | SubResp | |
1675// |<-------------| |
1676// | | |
1677// | SubDelReq | |
1678// |------------->| |
1679// | | |
1680// | | SubDelReq |
1681// | |------------->|
1682// | | |
1683// | | SubDelResp |
1684// | |<-------------|
1685// | | |
1686// | SubDelResp | |
1687// |<-------------| |
1688//
1689//-----------------------------------------------------------------------------
1690
1691func TestSubReqPolicyChangeAndSubDelOk(t *testing.T) {
1692 CaseBegin("TestSubReqAndSubDelOk")
1693
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001694 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1695 rparams1.Init()
1696 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
1697 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001698
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001699 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1700 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001701 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1702
1703 //Policy change
Juha Hyttinenaada6452020-04-07 08:47:58 +03001704 rparams1.Req.RequestId.InstanceId = e2SubsId
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001705 rparams1.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW200ms
1706 xappConn1.SendSubsReq(t, rparams1, cretrans)
1707
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001708 crereq, cremsg = e2termConn1.RecvSubsReq(t)
1709 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001710 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
1711 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001712 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001713
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001714 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001715 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001716
1717 //Wait that subs is cleaned
1718 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1719
1720 xappConn1.TestMsgChanEmpty(t)
1721 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001722 e2termConn1.TestMsgChanEmpty(t)
1723 mainCtrl.wait_registry_empty(t, 10)
1724}
1725
1726//-----------------------------------------------------------------------------
1727// TestSubReqAndSubDelOkTwoE2termParallel
1728//
1729// stub stub stub
1730// +-------+ +---------+ +---------+ +---------+
1731// | xapp | | submgr | | e2term1 | | e2term2 |
1732// +-------+ +---------+ +---------+ +---------+
1733// | | | |
1734// | | | |
1735// | | | |
1736// | SubReq1 | | |
1737// |------------->| | |
1738// | | | |
1739// | | SubReq1 | |
1740// | |------------->| |
1741// | | | |
1742// | SubReq2 | | |
1743// |------------->| | |
1744// | | | |
1745// | | SubReq2 | |
1746// | |---------------------------->|
1747// | | | |
1748// | | SubResp1 | |
1749// | |<-------------| |
1750// | SubResp1 | | |
1751// |<-------------| | |
1752// | | SubResp2 | |
1753// | |<----------------------------|
1754// | SubResp2 | | |
1755// |<-------------| | |
1756// | | | |
1757// | [SUBS 1 DELETE] | |
1758// | | | |
1759// | [SUBS 2 DELETE] | |
1760// | | | |
1761//
1762//-----------------------------------------------------------------------------
1763func TestSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
1764 CaseBegin("TestSubReqAndSubDelOkTwoE2termParallel")
1765
1766 //Req1
1767 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1768 xappConn1.SendSubsReq(t, nil, cretrans1)
1769 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1770
1771 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_11")
1772 xappConn1.SendSubsReq(t, nil, cretrans2)
1773 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
1774
1775 //Resp1
1776 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
1777 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
1778
1779 //Resp2
1780 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
1781 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
1782
1783 //Del1
1784 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1785 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1786 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
1787 xappConn1.RecvSubsDelResp(t, deltrans1)
1788 //Wait that subs is cleaned
1789 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1790
1791 //Del2
1792 deltrans2 := xappConn1.SendSubsDelReq(t, nil, e2SubsId2)
1793 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
1794 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
1795 xappConn1.RecvSubsDelResp(t, deltrans2)
1796 //Wait that subs is cleaned
1797 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1798
1799 xappConn1.TestMsgChanEmpty(t)
1800 xappConn2.TestMsgChanEmpty(t)
1801 e2termConn1.TestMsgChanEmpty(t)
1802 e2termConn2.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001803 mainCtrl.wait_registry_empty(t, 10)
1804}
Anssi Mannilaf0d95262020-08-17 13:00:20 +03001805
1806//-----------------------------------------------------------------------------
1807// TestSubReqInsertAndSubDelOk
1808//
1809// stub stub
1810// +-------+ +---------+ +---------+
1811// | xapp | | submgr | | e2term |
1812// +-------+ +---------+ +---------+
1813// | | |
1814// | SubReq | |
1815// |------------->| |
1816// | | |
1817// | | SubReq |
1818// | |------------->|
1819// | | |
1820// | | SubResp |
1821// | |<-------------|
1822// | | |
1823// | SubResp | |
1824// |<-------------| |
1825// | | |
1826// | | |
1827// | SubDelReq | |
1828// |------------->| |
1829// | | |
1830// | | SubDelReq |
1831// | |------------->|
1832// | | |
1833// | | SubDelResp |
1834// | |<-------------|
1835// | | |
1836// | SubDelResp | |
1837// |<-------------| |
1838//
1839//-----------------------------------------------------------------------------
1840func TestSubReqInsertAndSubDelOk(t *testing.T) {
1841 CaseBegin("TestInsertSubReqAndSubDelOk")
1842
1843 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1844 rparams1.Init()
1845 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeInsert
1846 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
1847
1848 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1849 e2termConn1.SendSubsResp(t, crereq, cremsg)
1850 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1851 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
1852 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1853
1854 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1855 xappConn1.RecvSubsDelResp(t, deltrans)
1856
1857 //Wait that subs is cleaned
1858 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1859
1860 xappConn1.TestMsgChanEmpty(t)
1861 xappConn2.TestMsgChanEmpty(t)
1862 e2termConn1.TestMsgChanEmpty(t)
1863 mainCtrl.wait_registry_empty(t, 10)
1864}
Anssi Mannila2f26fb22020-12-07 08:32:13 +02001865
1866//-----------------------------------------------------------------------------
1867// TestSubReqRetransmissionWithSameSubIdDiffXid
1868//
1869// This case simulates case where xApp restarts and starts sending same
1870// subscription requests which have already subscribed successfully
1871
1872// stub stub
1873// +-------+ +---------+ +---------+
1874// | xapp | | submgr | | e2term |
1875// +-------+ +---------+ +---------+
1876// | | |
1877// | SubReq | |
1878// |------------->| |
1879// | | |
1880// | | SubReq |
1881// | |------------->|
1882// | | |
1883// | | SubResp |
1884// | |<-------------|
1885// | | |
1886// | SubResp | |
1887// |<-------------| |
1888// | | |
1889// | xApp restart | |
1890// | | |
1891// | SubReq | |
1892// | (retrans with same xApp generated subid but diff xid)
1893// |------------->| |
1894// | | |
1895// | SubResp | |
1896// |<-------------| |
1897// | | |
1898// | [SUBS DELETE] |
1899// | | |
1900//
1901//-----------------------------------------------------------------------------
1902func TestSubReqRetransmissionWithSameSubIdDiffXid(t *testing.T) {
1903 CaseBegin("TestSubReqRetransmissionWithSameSubIdDiffXid")
1904
1905 //Subs Create
1906 cretrans := xappConn1.SendSubsReq(t, nil, nil)
1907 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1908 e2termConn1.SendSubsResp(t, crereq, cremsg)
1909 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1910
1911 // xApp restart here
1912 // --> artificial delay
1913 <-time.After(1 * time.Second)
1914
1915 //Subs Create
1916 cretrans = xappConn1.SendSubsReq(t, nil, nil) //Retransmitted SubReq
1917 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
1918
1919 //Subs Delete
1920 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
1921 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1922 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1923 xappConn1.RecvSubsDelResp(t, deltrans)
1924
1925 //Wait that subs is cleaned
1926 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1927
1928 xappConn1.TestMsgChanEmpty(t)
1929 xappConn2.TestMsgChanEmpty(t)
1930 e2termConn1.TestMsgChanEmpty(t)
1931 mainCtrl.wait_registry_empty(t, 10)
1932}
Anssi Mannilac92b4212020-12-07 14:59:34 +02001933
1934//-----------------------------------------------------------------------------
1935// TestSubReqNokAndSubDelOkWithRestartInMiddle
1936//
1937// stub stub
1938// +-------+ +---------+ +---------+
1939// | xapp | | submgr | | e2term |
1940// +-------+ +---------+ +---------+
1941// | | |
1942// | SubReq | |
1943// |------------->| |
1944// | | |
1945// | | SubReq |
1946// | |------------->|
1947// | | |
1948// | | SubResp |
1949// | <----|
1950// | |
1951// | Submgr restart |
1952// | |
1953// | | |
1954// | | SubDelReq |
1955// | |------------->|
1956// | | |
1957// | | SubDelResp |
1958// | |<-------------|
1959// | | |
1960//
1961//-----------------------------------------------------------------------------
1962
1963func TestSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
1964 CaseBegin("TestSubReqNokAndSubDelOkWithRestartInMiddle")
1965
1966 // Remove possible existing subscrition
1967 mainCtrl.removeExistingSubscriptions(t)
1968
1969 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
1970 xappConn1.SendSubsReq(t, nil, nil)
1971 e2termConn1.RecvSubsReq(t)
1972 mainCtrl.SetResetTestFlag(t, false)
1973
1974 resp, _ := xapp.Subscription.QuerySubscriptions()
1975 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03001976 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02001977 e2SubsId := uint32(resp[0].SubscriptionID)
1978 t.Logf("e2SubsId = %v", e2SubsId)
1979
archaggeafbf95f2021-04-14 08:54:05 +03001980 mainCtrl.SimulateRestart(t)
1981 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02001982
1983 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1984 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1985
1986 // Wait that subs is cleaned
1987 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1988
1989 xappConn1.TestMsgChanEmpty(t)
1990 xappConn2.TestMsgChanEmpty(t)
1991 e2termConn1.TestMsgChanEmpty(t)
1992 mainCtrl.wait_registry_empty(t, 10)
1993}
1994
1995//-----------------------------------------------------------------------------
1996// TestSubReqAndSubDelOkWithRestartInMiddle
1997//
1998// stub stub
1999// +-------+ +---------+ +---------+
2000// | xapp | | submgr | | e2term |
2001// +-------+ +---------+ +---------+
2002// | | |
2003// | SubReq | |
2004// |------------->| |
2005// | | |
2006// | | SubReq |
2007// | |------------->|
2008// | | |
2009// | | SubResp |
2010// | |<-------------|
2011// | | |
2012// | SubResp | |
2013// |<-------------| |
2014// | | |
2015// | |
2016// | Submgr restart |
2017// | |
2018// | SubDelReq | |
2019// |------------->| |
2020// | | |
2021// | | SubDelReq |
2022// | |------------->|
2023// | | |
2024// | | SubDelResp |
2025// | |<-------------|
2026// | | |
2027// | SubDelResp | |
2028// |<-------------| |
2029//
2030//-----------------------------------------------------------------------------
2031
2032func TestSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
2033 CaseBegin("TestSubReqAndSubDelOkWithRestartInMiddle")
2034
2035 cretrans := xappConn1.SendSubsReq(t, nil, nil)
2036 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2037 e2termConn1.SendSubsResp(t, crereq, cremsg)
2038 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
2039
2040 // Check subscription
2041 resp, _ := xapp.Subscription.QuerySubscriptions()
2042 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2043 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002044 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002045
2046 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002047 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002048
2049 // Check that subscription is restored correctly after restart
2050 resp, _ = xapp.Subscription.QuerySubscriptions()
2051 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
2052 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002053 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002054
2055 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
2056 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2057 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2058 xappConn1.RecvSubsDelResp(t, deltrans)
2059
2060 //Wait that subs is cleaned
2061 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2062
2063 xappConn1.TestMsgChanEmpty(t)
2064 xappConn2.TestMsgChanEmpty(t)
2065 e2termConn1.TestMsgChanEmpty(t)
2066 mainCtrl.wait_registry_empty(t, 10)
2067}
2068
2069//-----------------------------------------------------------------------------
2070// TestSubReqAndSubDelOkSameActionWithRestartsInMiddle
2071//
2072// stub stub
2073// +-------+ +-------+ +---------+ +---------+
2074// | xapp2 | | xapp1 | | submgr | | e2term |
2075// +-------+ +-------+ +---------+ +---------+
2076// | | | |
2077// | | | |
2078// | | | |
2079// | | SubReq1 | |
2080// | |------------->| |
2081// | | | |
2082// | | | SubReq1 |
2083// | | |------------->|
2084// | | | SubResp1 |
2085// | | |<-------------|
2086// | | SubResp1 | |
2087// | |<-------------| |
2088// | | | |
2089// | |
2090// | submgr restart |
2091// | |
2092// | | | |
2093// | | | |
2094// | SubReq2 | |
2095// |--------------------------->| |
2096// | | | |
2097// | SubResp2 | |
2098// |<---------------------------| |
2099// | | | |
2100// | | SubDelReq 1 | |
2101// | |------------->| |
2102// | | | |
2103// | | SubDelResp 1 | |
2104// | |<-------------| |
2105// | | | |
2106// | | | |
2107// | |
2108// | submgr restart |
2109// | |
2110// | | | |
2111// | SubDelReq 2 | |
2112// |--------------------------->| |
2113// | | | |
2114// | | | SubDelReq 2 |
2115// | | |------------->|
2116// | | | |
2117// | | | SubDelReq 2 |
2118// | | |------------->|
2119// | | | |
2120// | SubDelResp 2 | |
2121// |<---------------------------| |
2122//
2123//-----------------------------------------------------------------------------
2124
2125func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
2126 CaseBegin("TestSubReqAndSubDelOkSameActionWithRestartsInMiddle")
2127
2128 //Req1
2129 rparams1 := &teststube2ap.E2StubSubsReqParams{}
2130 rparams1.Init()
2131 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
2132 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2133 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2134 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
2135
2136 //Req2
2137 rparams2 := &teststube2ap.E2StubSubsReqParams{}
2138 rparams2.Init()
2139 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
2140 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
2141
2142 // Check subscription
2143 resp, _ := xapp.Subscription.QuerySubscriptions() ////////////////////////////////
2144 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2145 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002146 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002147
2148 mainCtrl.SimulateRestart(t)
archaggeafbf95f2021-04-14 08:54:05 +03002149 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
Anssi Mannilac92b4212020-12-07 14:59:34 +02002150
2151 // Check that subscription is restored correctly after restart
2152 resp, _ = xapp.Subscription.QuerySubscriptions()
2153 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
2154 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
archaggea5c58bc2021-04-14 08:54:05 +03002155 assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
Anssi Mannilac92b4212020-12-07 14:59:34 +02002156
2157 //Del1
2158 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
2159 xapp.Logger.Debug("xappConn1.RecvSubsDelResp")
2160 xappConn1.RecvSubsDelResp(t, deltrans1)
2161 xapp.Logger.Debug("xappConn1.RecvSubsDelResp received")
2162
2163 mainCtrl.SimulateRestart(t)
2164 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
2165
2166 //Del2
2167 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
2168 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2169
2170 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2171 xappConn2.RecvSubsDelResp(t, deltrans2)
2172
2173 //Wait that subs is cleaned
2174 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
2175
2176 xappConn1.TestMsgChanEmpty(t)
2177 xappConn2.TestMsgChanEmpty(t)
2178 e2termConn1.TestMsgChanEmpty(t)
2179 mainCtrl.wait_registry_empty(t, 10)
2180}
Anssi Mannila47518ae2021-04-16 09:27:07 +03002181
archaggeafbf95f2021-04-14 08:54:05 +03002182//*****************************************************************************
2183// REST interface test cases
2184//*****************************************************************************
2185
Anssi Mannila47518ae2021-04-16 09:27:07 +03002186//-----------------------------------------------------------------------------
2187// Test debug GET and POST requests
2188//
2189// curl
2190// +-------+ +---------+
2191// | user | | submgr |
2192// +-------+ +---------+
2193// | |
2194// | GET/POST Req |
2195// |------------->|
2196// | Resp |
2197// |<-------------|
2198// | |
Anssi Mannila47518ae2021-04-16 09:27:07 +03002199func TestGetSubscriptions(t *testing.T) {
2200
2201 mainCtrl.sendGetRequest(t, "localhost:8088", "/ric/v1/subscriptions")
2202}
2203
2204func TestGetSymptomData(t *testing.T) {
2205
2206 mainCtrl.sendGetRequest(t, "localhost:8080", "/ric/v1/symptomdata")
2207}
2208
2209func TestPostdeleteSubId(t *testing.T) {
2210
2211 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/deletesubid=1")
2212}
2213
2214func TestPostEmptyDb(t *testing.T) {
2215
2216 mainCtrl.sendPostRequest(t, "localhost:8080", "/ric/v1/test/emptydb")
2217}
archaggeafbf95f2021-04-14 08:54:05 +03002218
2219//-----------------------------------------------------------------------------
2220// TestRESTSubReqAndRouteNok
2221//
2222// stub stub
2223// +-------+ +---------+ +---------+
2224// | xapp | | submgr | | rtmgr |
2225// +-------+ +---------+ +---------+
2226// | | |
2227// | RESTSubReq | |
2228// |---------------->| |
2229// | | |
2230// | RESTSubResp | |
2231// |<----------------| |
2232// | | RouteCreate |
2233// | |------------->|
2234// | | |
2235// | | RouteCreate |
2236// | | status:400 |
2237// | |(Bad request) |
2238// | |<-------------|
2239// | RESTNotif | |
2240// |<----------------| |
2241// | | |
2242// | [SUBS INT DELETE] |
2243// | | |
2244// | RESTSubDelReq | |
2245// |---------------->| |
2246// | RESTSubDelResp | |
2247// |<----------------| |
2248//
2249//-----------------------------------------------------------------------------
2250func TestRESTSubReqAndRouteNok(t *testing.T) {
2251 CaseBegin("TestRESTSubReqAndRouteNok")
2252
2253 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2254 Counter{cSubReqFromXapp, 1},
2255 Counter{cRouteCreateFail, 1},
2256 Counter{cSubRespToXapp, 1},
2257 Counter{cSubDelReqFromXapp, 1},
2258 Counter{cSubDelRespToXapp, 1},
2259 })
2260
2261 const subReqCount int = 1
2262 const parameterSet = 1
2263 const actionDefinitionPresent bool = true
2264 const actionParamCount int = 1
Markku Virtanenda34eec2021-05-20 08:22:04 +00002265 // Add delay for rtmgt HTTP handling so that HTTP response is received before notify on XAPP side
2266 waiter := rtmgrHttp.AllocNextSleep(50, false)
archaggeafbf95f2021-04-14 08:54:05 +03002267 newSubsId := mainCtrl.get_registry_next_subid(t)
2268
2269 // Req
2270 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2271 restSubId := xappConn1.SendRESTSubsReq(t, params)
Markku Virtanenda34eec2021-05-20 08:22:04 +00002272 xappConn1.ExpectRESTNotification(t, restSubId)
archaggeafbf95f2021-04-14 08:54:05 +03002273 waiter.WaitResult(t)
2274
archaggeafbf95f2021-04-14 08:54:05 +03002275 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2276 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
2277
2278 // Del
2279 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2280
2281 // Wait that subs is cleaned
2282 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2283 waitSubsCleanup(t, e2SubsId, 10)
2284 mainCtrl.VerifyCounterValues(t)
2285}
2286
2287func TestRESTSubReqAndRouteUpdateNok(t *testing.T) {
2288 CaseBegin("TestSubReqAndRouteUpdateNok")
2289
2290 //Init counter check
2291 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2292 Counter{cSubReqFromXapp, 2},
2293 Counter{cSubReqToE2, 1},
2294 Counter{cSubRespFromE2, 1},
2295 Counter{cSubRespToXapp, 2},
2296 Counter{cRouteCreateUpdateFail, 1},
2297 Counter{cSubDelReqFromXapp, 1},
2298 Counter{cSubDelReqToE2, 1},
2299 Counter{cSubDelRespFromE2, 1},
2300 Counter{cSubDelRespToXapp, 1},
2301 })
2302
2303 var params *teststube2ap.RESTSubsReqParams = nil
2304
2305 //Subs Create
2306 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2307
2308 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2309
2310 // xapp2 ROUTE creation shall fail with 400 from rtmgr -> submgr
2311 waiter := rtmgrHttp.AllocNextEvent(false)
2312 newSubsId := mainCtrl.get_registry_next_subid(t)
2313 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2314 params.SetMeid("RAN_NAME_1")
2315 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
2316 xapp.Logger.Info("Send REST subscriber request for second subscriber : %v", restSubId2)
2317 xappConn2.ExpectRESTNotification(t, restSubId2)
2318 waiter.WaitResult(t)
2319 // e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2) - TOD: missing delete
2320 xappConn2.WaitRESTNotification(t, restSubId2)
2321
2322 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2323
2324 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2325
2326 mainCtrl.wait_subs_clean(t, newSubsId, 10)
2327 //Wait that subs is cleaned
2328 waitSubsCleanup(t, e2SubsId, 10)
2329
2330 mainCtrl.VerifyCounterValues(t)
2331}
2332
2333func TestRESTSubDelReqAndRouteDeleteNok(t *testing.T) {
2334 CaseBegin("TestRESTSubDelReqAndRouteDeleteNok")
2335
2336 // Init counter check
2337 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2338 Counter{cSubReqFromXapp, 1},
2339 Counter{cSubReqToE2, 1},
2340 Counter{cSubRespFromE2, 1},
2341 Counter{cSubRespToXapp, 1},
2342 Counter{cSubDelReqFromXapp, 1},
2343 Counter{cRouteDeleteFail, 1},
2344 Counter{cSubDelReqToE2, 1},
2345 Counter{cSubDelRespFromE2, 1},
2346 Counter{cSubDelRespToXapp, 1},
2347 })
2348
2349 var params *teststube2ap.RESTSubsReqParams = nil
2350
2351 //Subs Create
2352 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2353
2354 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2355
2356 waiter := rtmgrHttp.AllocNextEvent(false)
2357 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2358 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2359 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2360 waiter.WaitResult(t)
2361
2362 waitSubsCleanup(t, e2SubsId, 10)
2363
2364 mainCtrl.VerifyCounterValues(t)
2365}
2366
2367func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) {
2368 CaseBegin("TestRESTSubMergeDelAndRouteUpdateNok")
2369
2370 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2371 Counter{cSubReqFromXapp, 2},
2372 Counter{cSubReqToE2, 1},
2373 Counter{cSubRespFromE2, 1},
2374 Counter{cSubRespToXapp, 2},
2375 Counter{cSubDelReqFromXapp, 2},
2376 Counter{cRouteDeleteUpdateFail, 1},
2377 Counter{cSubDelReqToE2, 1},
2378 Counter{cSubDelRespFromE2, 1},
2379 Counter{cSubDelRespToXapp, 2},
2380 })
2381
2382 var params *teststube2ap.RESTSubsReqParams = nil
2383
2384 //Subs Create
2385 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2386
2387 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2388 restSubId2, e2SubsId2 := createXapp2MergedSubscription(t, "RAN_NAME_1")
2389
2390 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
2391
2392 //Del1, this shall fail on rtmgr side
2393 waiter := rtmgrHttp.AllocNextEvent(false)
2394 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2395 waiter.WaitResult(t)
2396
2397 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13660"})
2398
2399 //Del2
2400 deleteXapp2Subscription(t, &restSubId2)
2401
2402 waitSubsCleanup(t, e2SubsId2, 10)
2403
2404 mainCtrl.VerifyCounterValues(t)
2405}
2406
2407//-----------------------------------------------------------------------------
2408// TestRESTSubReqRetransmission
2409//
2410// stub stub
2411// +-------+ +---------+ +---------+
2412// | xapp | | submgr | | e2term |
2413// +-------+ +---------+ +---------+
2414// | | |
2415// | RESTSubReq1 | |
2416// |---------------->| |
2417// | | |
2418// | RESTSubResp | |
2419// |<----------------| |
2420// | | SubReq1 |
2421// | |------------->|
2422// | | |
2423// | RESTSubReq2 | |
2424// | (retrans) | |
2425// |---------------->| |
2426// | | |
2427// | | SubReq2 |
2428// | |------------->|
2429// | RESTSubResp2 | |
2430// |<----------------| |
2431// | | SubResp1 |
2432// | |<-------------|
2433// | RESTNotif1 | |
2434// |<----------------| |
2435// | | SubResp1 |
2436// | |<-------------|
2437// | RESTNotif2 | |
2438// |<----------------| |
2439// | | |
2440// | [SUBS DELETE] |
2441// | | |
2442//
2443//-----------------------------------------------------------------------------
Markku Virtanenda34eec2021-05-20 08:22:04 +00002444
archaggeafbf95f2021-04-14 08:54:05 +03002445func TestRESTSubReqRetransmission(t *testing.T) {
2446 CaseBegin("TestRESTSubReqRetransmission")
2447
2448 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2449 Counter{cSubReqFromXapp, 2},
2450 Counter{cSubReqToE2, 2},
2451 Counter{cSubRespFromE2, 2},
2452 Counter{cSubRespToXapp, 2},
2453 Counter{cSubDelReqFromXapp, 2},
2454 Counter{cSubDelReqToE2, 2},
2455 Counter{cSubDelRespFromE2, 2},
2456 Counter{cSubDelRespToXapp, 2},
2457 })
2458 // Retry/duplicate will get the same way as the first request. Submgr cannot detect duplicate RESTRequests
2459 // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending
2460 // second request from same xapp as doing it from xappConn1 would not work as notification would not be received
2461
2462 // Subs Create
2463 const subReqCount int = 1
2464 const parameterSet = 1
2465 const actionDefinitionPresent bool = true
2466 const actionParamCount int = 1
2467
2468 // In order to force both XAPP's to create their own subscriptions, force rtmgr to block a while so that 2nd create
2469 // gets into execution before the rtmgrg responds for the first one.
2470 waiter := rtmgrHttp.AllocNextSleep(10, true)
2471 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2472 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
2473 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
2474
2475 waiter.WaitResult(t)
2476
2477 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
2478
2479 // Depending one goroutine scheduling order, we cannot say for sure which xapp reaches e2term first. Thus
2480 // the order is not significant he6re.
2481 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2482 e2termConn1.SendSubsResp(t, crereq, cremsg)
2483 crereq, cremsg = e2termConn1.RecvSubsReq(t)
2484 e2termConn1.SendSubsResp(t, crereq, cremsg)
2485
2486 e2SubsIdA := <-xappConn1.ListedRESTNotifications
2487 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
2488 e2SubsIdB := <-xappConn1.ListedRESTNotifications
2489 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
2490
2491 // Del1
2492 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
2493 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2494 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
2495
archaggeafbf95f2021-04-14 08:54:05 +03002496 // Del2
2497 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
2498 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
2499 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
2500
Markku Virtanenda34eec2021-05-20 08:22:04 +00002501 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
2502
archaggeafbf95f2021-04-14 08:54:05 +03002503 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
2504
2505 mainCtrl.VerifyCounterValues(t)
2506}
Markku Virtanenda34eec2021-05-20 08:22:04 +00002507
archaggeafbf95f2021-04-14 08:54:05 +03002508func TestRESTSubDelReqRetransmission(t *testing.T) {
2509 CaseBegin("TestRESTSubDelReqRetransmission")
2510
2511 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2512 Counter{cSubReqFromXapp, 1},
2513 Counter{cSubReqToE2, 1},
2514 Counter{cSubRespFromE2, 1},
2515 Counter{cSubRespToXapp, 1},
2516 Counter{cSubDelReqFromXapp, 2},
2517 Counter{cSubDelReqToE2, 1},
2518 Counter{cSubDelRespFromE2, 1},
2519 Counter{cSubDelRespToXapp, 1},
2520 })
2521
2522 var params *teststube2ap.RESTSubsReqParams = nil
2523
2524 //Subs Create
2525 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
2526
2527 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2528
2529 //Subs Delete
2530 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2531 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2532
2533 seqBef := mainCtrl.get_msgcounter(t)
2534 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2535 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
2536
2537 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2538
2539 waitSubsCleanup(t, e2SubsId, 10)
2540
2541 mainCtrl.VerifyCounterValues(t)
2542}
2543
2544//-----------------------------------------------------------------------------
2545// TestRESTSubReqDelReq
2546//
2547// stub stub
2548// +-------+ +---------+ +---------+
2549// | xapp | | submgr | | e2term |
2550// +-------+ +---------+ +---------+
2551// | | |
2552// | RESTSubReq | |
2553// |---------------->| |
2554// | | |
2555// | RESTSubResp | |
2556// |<----------------| |
2557// | | SubReq |
2558// | |------------->|
2559// | RESTSubDelReq | |
2560// |---------------->| |
2561// | RESTSubDelResp | |
2562// | unsuccess | |
2563// |<----------------| |
2564// | | SubResp |
2565// | |<-------------|
2566// | RESTNotif1 | |
2567// |<----------------| |
2568// | | |
2569// | [SUBS DELETE] |
2570// | | |
2571//
2572//-----------------------------------------------------------------------------
2573func TestRESTSubReqDelReq(t *testing.T) {
2574 CaseBegin("TestRESTSubReqDelReq")
2575
2576 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2577 Counter{cSubReqFromXapp, 1},
2578 Counter{cSubReqToE2, 1},
2579 Counter{cSubRespFromE2, 1},
2580 Counter{cSubRespToXapp, 1},
2581 Counter{cSubDelReqFromXapp, 2},
2582 Counter{cSubDelReqToE2, 1},
2583 Counter{cSubDelRespFromE2, 1},
2584 Counter{cSubDelRespToXapp, 1},
2585 })
2586
2587 const subReqCount int = 1
2588 const parameterSet = 1
2589 const actionDefinitionPresent bool = true
2590 const actionParamCount int = 1
2591
2592 // Req
2593 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2594 restSubId := xappConn1.SendRESTSubsReq(t, params)
2595
2596 // Del. This will fail as processing of the subscription
2597 // is still ongoing in submgr. Deletion is not allowed before
2598 // subscription creation has been completed.
2599 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2600 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2601 xappConn1.ExpectRESTNotification(t, restSubId)
2602 e2termConn1.SendSubsResp(t, crereq, cremsg)
2603 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2604
2605 // Retry del
2606 xappConn1.SendRESTSubsDelReq(t, &restSubId)
2607
2608 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2609 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2610
2611 // Wait that subs is cleaned
2612 waitSubsCleanup(t, e2SubsId, 10)
2613 mainCtrl.VerifyCounterValues(t)
2614
2615}
2616
2617func TestRESTSubDelReqCollision(t *testing.T) {
2618 CaseBegin("TestRESTSubDelReqCollision - not relevant for REST API")
2619}
2620
2621func TestRESTSubReqAndSubDelOkTwoParallel(t *testing.T) {
2622 CaseBegin("TestRESTSubReqAndSubDelOkTwoParallel")
2623
2624 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2625 Counter{cSubReqFromXapp, 2},
2626 Counter{cSubReqToE2, 2},
2627 Counter{cSubRespFromE2, 2},
2628 Counter{cSubRespToXapp, 2},
2629 Counter{cSubDelReqFromXapp, 2},
2630 Counter{cSubDelReqToE2, 2},
2631 Counter{cSubDelRespFromE2, 2},
2632 Counter{cSubDelRespToXapp, 2},
2633 })
2634
2635 //Req1
2636 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2637 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
2638 xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
2639
2640 //Req2
2641 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2642 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
2643 xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
2644
2645 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2646 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
2647
2648 //XappConn1 receives both of the responses
2649 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
2650
2651 //Resp1
2652 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
2653 //Resp2
2654 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
2655
2656 e2SubsIdA := <-xappConn1.ListedRESTNotifications
2657 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
2658 e2SubsIdB := <-xappConn1.ListedRESTNotifications
2659 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
2660
2661 //Del1
2662 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
2663 //Del2
2664 deleteSubscription(t, xappConn2, e2termConn1, &restSubId2)
2665
2666 //Wait that subs is cleaned
2667 mainCtrl.wait_subs_clean(t, e2SubsIdA.E2SubsId, 10)
2668 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
2669
2670 mainCtrl.VerifyCounterValues(t)
2671
2672}
2673
2674func TestRESTSameSubsDiffRan(t *testing.T) {
2675 CaseBegin("TestRESTSameSubsDiffRan")
2676
2677 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2678 Counter{cSubReqFromXapp, 2},
2679 Counter{cSubReqToE2, 2},
2680 Counter{cSubRespFromE2, 2},
2681 Counter{cSubRespToXapp, 2},
2682 Counter{cSubDelReqFromXapp, 2},
2683 Counter{cSubDelReqToE2, 2},
2684 Counter{cSubDelRespFromE2, 2},
2685 Counter{cSubDelRespToXapp, 2},
2686 })
2687
2688 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2689 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
2690 xapp.Logger.Info("Send 1st REST subscriber request for subscriberId : %v", restSubId1)
2691
2692 params = xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2693 params.SetMeid("RAN_NAME_2")
2694 restSubId2, e2SubsId2 := createSubscription(t, xappConn1, e2termConn1, params)
2695 xapp.Logger.Info("Send 2nd REST subscriber request for subscriberId : %v", restSubId2)
2696
2697 //Del1
2698 deleteSubscription(t, xappConn1, e2termConn1, &restSubId1)
2699 //Del2
2700 deleteSubscription(t, xappConn1, e2termConn1, &restSubId2)
2701
2702 //Wait that subs is cleaned
2703 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
2704 waitSubsCleanup(t, e2SubsId2, 10)
2705
2706 mainCtrl.VerifyCounterValues(t)
2707
2708}
2709
2710func TestRESTSubReqRetryInSubmgr(t *testing.T) {
2711 CaseBegin("TestRESTSubReqRetryInSubmgr start")
2712
2713 // Init counter check
2714 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2715 Counter{cSubReqFromXapp, 1},
2716 Counter{cSubReqToE2, 1},
2717 Counter{cSubReReqToE2, 1},
2718 Counter{cSubRespFromE2, 1},
2719 Counter{cSubRespToXapp, 1},
2720 Counter{cSubDelReqFromXapp, 1},
2721 Counter{cSubDelReqToE2, 1},
2722 Counter{cSubDelRespFromE2, 1},
2723 Counter{cSubDelRespToXapp, 1},
2724 })
2725
2726 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2727 restSubId := xappConn1.SendRESTSubsReq(t, params)
2728
2729 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2730
2731 // Catch the first message and ignore it
2732 crereq, cremsg := e2termConn1.RecvSubsReq(t)
2733 xapp.Logger.Info("Ignore REST subscriber request for subscriber : %v", restSubId)
2734
2735 // The second request is being handled normally
2736 crereq, cremsg = e2termConn1.RecvSubsReq(t)
2737 xappConn1.ExpectRESTNotification(t, restSubId)
2738 e2termConn1.SendSubsResp(t, crereq, cremsg)
2739 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2740
2741 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
2742
2743 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
2744
2745 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
2746 //Wait that subs is cleaned
2747 waitSubsCleanup(t, e2SubsId, 10)
2748
2749 mainCtrl.VerifyCounterValues(t)
2750
2751}
2752
2753//-----------------------------------------------------------------------------
2754// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
2755//
2756// stub stub
2757// +-------+ +---------+ +---------+
2758// | xapp | | submgr | | e2term |
2759// +-------+ +---------+ +---------+
2760// | | |
2761// | RESTSubReq | |
2762// |---------------->| |
2763// | | |
2764// | RESTSubResp | |
2765// |<----------------| |
2766// | | SubReq |
2767// | |------------->|
2768// | | |
2769// | | |
2770// | | SubReq |
2771// | |------------->|
2772// | | |
2773// | | SubDelReq |
2774// | |------------->|
2775// | | |
2776// | | |
2777// | | SubDelReq |
2778// | |------------->|
2779// | | |
2780// | | |
2781// | | SubDelResp |
2782// | |<-------------|
2783// | RESTNotif | |
2784// | unsuccess | |
2785// |<----------------| |
2786// | | |
2787// | [SUBS DELETE] |
2788// | | |
2789//
2790//-----------------------------------------------------------------------------
2791func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
2792 CaseBegin("TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
2793
2794 // Init counter check
2795 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2796 Counter{cSubReqFromXapp, 1},
2797 Counter{cSubReqToE2, 1},
2798 Counter{cSubReReqToE2, 1},
2799 Counter{cSubReqTimerExpiry, 2},
2800 Counter{cSubDelReqToE2, 1},
2801 Counter{cSubDelRespFromE2, 1},
2802 })
2803
2804 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2805 restSubId := xappConn1.SendRESTSubsReq(t, params)
2806 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2807
2808 e2termConn1.RecvSubsReq(t)
2809 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
2810
2811 e2termConn1.RecvSubsReq(t)
2812 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
2813
2814 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
2815 xappConn1.ExpectRESTNotification(t, restSubId)
2816 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
2817 // e2SubsId := xappConn1.WaitRESTNotification(t, restSubId) - TODO: Should we delete this?
2818 xappConn1.WaitRESTNotification(t, restSubId)
2819
2820 // Wait that subs is cleaned
2821 waitSubsCleanup(t, delreq.RequestId.InstanceId, 10)
2822
2823 mainCtrl.VerifyCounterValues(t)
2824}
2825
2826func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
2827 CaseBegin("TestREST2eTermNotRespondingToSubReq start")
2828
2829 // Init counter check
2830 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2831 Counter{cSubReqFromXapp, 1},
2832 Counter{cSubReqToE2, 1},
2833 Counter{cSubReReqToE2, 1},
2834 Counter{cSubReqTimerExpiry, 2},
2835 Counter{cSubDelReqToE2, 1},
2836 Counter{cSubDelReqTimerExpiry, 2},
2837 })
2838
2839 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2840 restSubId := xappConn1.SendRESTSubsReq(t, params)
2841 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2842
2843 e2termConn1.RecvSubsReq(t)
2844 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
2845
2846 e2termConn1.RecvSubsReq(t)
2847 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
2848
2849 e2termConn1.RecvSubsDelReq(t)
2850 xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
2851
2852 xappConn1.ExpectRESTNotification(t, restSubId)
2853 e2termConn1.RecvSubsDelReq(t)
2854 xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
2855
2856 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2857
2858 waitSubsCleanup(t, e2SubsId, 10)
2859
2860 mainCtrl.VerifyCounterValues(t)
2861
2862}
2863
2864//-----------------------------------------------------------------------------
2865// TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr
2866//
2867// stub stub
2868// +-------+ +---------+ +---------+
2869// | xapp | | submgr | | e2term |
2870// +-------+ +---------+ +---------+
2871// | | |
2872// | RESTSubReq | |
2873// |---------------->| |
2874// | | |
2875// | RESTSubResp | |
2876// |<----------------| |
2877// | | SubReq |
2878// | |------------->|
2879// | | |
2880// | | |
2881// | | SubReq |
2882// | |------------->|
2883// | | |
2884// | | SubDelReq |
2885// | |------------->|
2886// | | |
2887// | | |
2888// | | SubDelReq |
2889// | |------------->|
2890// | | |
2891// | | |
2892// | | SubDelResp |
2893// | |<-------------|
2894// | RESTNotif | |
2895// | unsuccess | |
2896// |<----------------| |
2897// | | |
2898// | [SUBS DELETE] |
2899// | | |
2900//
2901//-----------------------------------------------------------------------------
2902func TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
2903 CaseBegin("TestRESTSubReqTwoRetriesNoRespAtAllInSubmgr start")
2904
2905 // Init counter check
2906 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2907 Counter{cSubReqFromXapp, 1},
2908 Counter{cSubReqToE2, 1},
2909 Counter{cSubReReqToE2, 1},
2910 Counter{cSubReqTimerExpiry, 2},
2911 Counter{cSubDelReqToE2, 1},
2912 Counter{cSubDelReReqToE2, 1},
2913 Counter{cSubDelReqTimerExpiry, 2},
2914 })
2915
2916 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2917 restSubId := xappConn1.SendRESTSubsReq(t, params)
2918 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
2919
2920 e2termConn1.RecvSubsReq(t)
2921 xapp.Logger.Info("Ignore 1st REST subscriber request for subscriber : %v", restSubId)
2922
2923 e2termConn1.RecvSubsReq(t)
2924 xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
2925
2926 e2termConn1.RecvSubsDelReq(t)
2927 xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
2928
2929 xappConn1.ExpectRESTNotification(t, restSubId)
2930 e2termConn1.RecvSubsDelReq(t)
2931 xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
2932
2933 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
2934
2935 waitSubsCleanup(t, e2SubsId, 10)
2936
2937 mainCtrl.VerifyCounterValues(t)
2938}
2939
2940//-----------------------------------------------------------------------------
2941// TestRESTSubReqSubFailRespInSubmgr
2942//
2943// stub stub
2944// +-------+ +---------+ +---------+
2945// | xapp | | submgr | | e2term |
2946// +-------+ +---------+ +---------+
2947// | | |
2948// | RESTSubReq | |
2949// |---------------->| |
2950// | | |
2951// | RESTSubResp | |
2952// |<----------------| |
2953// | | SubReq |
2954// | |------------->|
2955// | | |
2956// | | SubFail |
2957// | |<-------------|
2958// | | |
2959// | | SubDelReq |
2960// | |------------->|
2961// | | |
2962// | | SubDelResp |
2963// | |<-------------|
2964// | | |
2965// | RESTNotif | |
2966// | unsuccess | |
2967// |<----------------| |
2968// | | |
2969// | [SUBS DELETE] |
2970// | | |
2971//
2972//-----------------------------------------------------------------------------
2973func TestRESTSubReqSubFailRespInSubmgr(t *testing.T) {
2974 CaseBegin("TestRESTSubReqSubFailRespInSubmgr")
2975
2976 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
2977 Counter{cSubReqFromXapp, 1},
2978 Counter{cSubReqToE2, 1},
2979 Counter{cSubFailFromE2, 1},
2980 Counter{cSubRespToXapp, 1},
2981 Counter{cSubDelReqFromXapp, 1},
2982 })
2983
2984 const subReqCount int = 1
2985 const parameterSet = 1
2986 const actionDefinitionPresent bool = true
2987 const actionParamCount int = 1
2988
2989 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
2990 restSubId := xappConn1.SendRESTSubsReq(t, params)
2991
2992 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
2993 fparams1 := &teststube2ap.E2StubSubsFailParams{}
2994 fparams1.Set(crereq1)
2995 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
2996
2997 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
2998 xappConn1.ExpectRESTNotification(t, restSubId)
2999 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3000 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3001 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
3002
3003 // REST subscription sill there to be deleted
3004 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3005
3006 // Wait that subs is cleaned
3007 waitSubsCleanup(t, e2SubsId, 10)
3008
3009 mainCtrl.VerifyCounterValues(t)
3010
3011}
3012
3013//-----------------------------------------------------------------------------
3014// TestRESTSubDelReqRetryInSubmgr
3015//
3016// stub stub
3017// +-------+ +---------+ +---------+
3018// | xapp | | submgr | | e2term |
3019// +-------+ +---------+ +---------+
3020// | | |
3021// | [SUBS CREATE] |
3022// | | |
3023// | | |
3024// | RESTSubDelReq | |
3025// |---------------->| |
3026// | | |
3027// | RESTSubDelResp | |
3028// |<----------------| |
3029// | | SubDelReq |
3030// | |------------->|
3031// | | |
3032// | | SubDelReq |
3033// | |------------->|
3034// | | |
3035// | | SubDelResp |
3036// | |<-------------|
3037// | | |
3038//
3039//-----------------------------------------------------------------------------
3040func TestRESTSubDelReqRetryInSubmgr(t *testing.T) {
3041 CaseBegin("TestRESTSubDelReqRetryInSubmgr")
3042
3043 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3044 Counter{cSubReqFromXapp, 1},
3045 Counter{cSubReqToE2, 1},
3046 Counter{cSubRespFromE2, 1},
3047 Counter{cSubRespToXapp, 1},
3048 Counter{cSubDelReqFromXapp, 1},
3049 Counter{cSubDelReqToE2, 1},
3050 Counter{cSubDelReReqToE2, 1},
3051 Counter{cSubDelRespFromE2, 1},
3052 Counter{cSubDelRespToXapp, 1},
3053 })
3054 // Req
3055 var params *teststube2ap.RESTSubsReqParams = nil
3056 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3057
3058 // Del
3059 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3060
3061 // E2t: Receive 1st SubsDelReq
3062 e2termConn1.RecvSubsDelReq(t)
3063
3064 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
3065 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3066 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3067
3068 //Wait that subs is cleaned
3069 waitSubsCleanup(t, e2SubsId, 10)
3070
3071 mainCtrl.VerifyCounterValues(t)
3072}
3073
3074//-----------------------------------------------------------------------------
3075// TestRESTSubDelReqTwoRetriesNoRespInSubmgr
3076//
3077// stub stub
3078// +-------+ +---------+ +---------+
3079// | xapp | | submgr | | e2term |
3080// +-------+ +---------+ +---------+
3081// | | |
3082// | [SUBS CREATE] |
3083// | | |
3084// | | |
3085// | RESTSubDelReq | |
3086// |---------------->| |
3087// | | |
3088// | RESTSubDelResp | |
3089// |<----------------| |
3090// | | SubDelReq |
3091// | |------------->|
3092// | | |
3093// | | SubDelReq |
3094// | |------------->|
3095// | | |
3096// | | |
3097//
3098//-----------------------------------------------------------------------------
3099func TestRESTSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
3100 CaseBegin("TestRESTSubDelReTwoRetriesNoRespInSubmgr")
3101
3102 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3103 Counter{cSubReqFromXapp, 1},
3104 Counter{cSubReqToE2, 1},
3105 Counter{cSubRespFromE2, 1},
3106 Counter{cSubRespToXapp, 1},
3107 Counter{cSubDelReqFromXapp, 1},
3108 Counter{cSubDelReqToE2, 1},
3109 Counter{cSubDelReReqToE2, 1},
3110 Counter{cSubDelRespFromE2, 1},
3111 Counter{cSubDelRespToXapp, 1},
3112 })
3113
3114 // Req
3115 var params *teststube2ap.RESTSubsReqParams = nil
3116 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3117
3118 // Del
3119 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3120
3121 // E2t: Receive 1st SubsDelReq
3122 e2termConn1.RecvSubsDelReq(t)
3123
3124 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
3125 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3126 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3127
3128 //Wait that subs is cleaned
3129 waitSubsCleanup(t, e2SubsId, 10)
3130
3131 mainCtrl.VerifyCounterValues(t)
3132}
3133
3134//-----------------------------------------------------------------------------
3135// TestRESTSubDelReqSubDelFailRespInSubmgr
3136//
3137// stub stub
3138// +-------+ +---------+ +---------+
3139// | xapp | | submgr | | e2term |
3140// +-------+ +---------+ +---------+
3141// | | |
3142// | [SUBS CREATE] |
3143// | | |
3144// | | |
3145// | RESTSubDelReq | |
3146// |---------------->| |
3147// | | |
3148// | RESTSubDelResp | |
3149// |<----------------| |
3150// | | SubDelReq |
3151// | |------------->|
3152// | | |
3153// | | SubDelFail |
3154// | |<-------------|
3155// | | |
3156//
3157//-----------------------------------------------------------------------------
3158func TestRESTSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
3159 CaseBegin("TestRESTSubDelReqSubDelFailRespInSubmgr")
3160
3161 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3162 Counter{cSubReqFromXapp, 1},
3163 Counter{cSubReqToE2, 1},
3164 Counter{cSubRespFromE2, 1},
3165 Counter{cSubRespToXapp, 1},
3166 Counter{cSubDelReqFromXapp, 1},
3167 Counter{cSubDelReqToE2, 1},
3168 Counter{cSubDelFailFromE2, 1},
3169 Counter{cSubDelRespToXapp, 1},
3170 })
3171
3172 // Req
3173 var params *teststube2ap.RESTSubsReqParams = nil
3174 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3175
3176 // Del
3177 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3178
3179 // E2t: Send receive SubsDelReq and send SubsDelFail
3180 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3181 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
3182
3183 //Wait that subs is cleaned
3184 waitSubsCleanup(t, e2SubsId, 10)
3185
3186 mainCtrl.VerifyCounterValues(t)
3187}
3188
3189//-----------------------------------------------------------------------------
3190// TestRESTSubReqAndSubDelOkSameAction
3191//
3192// stub stub
3193// +-------+ +-------+ +---------+ +---------+
3194// | xapp2 | | xapp1 | | submgr | | e2term |
3195// +-------+ +-------+ +---------+ +---------+
3196// | | | |
3197// | | RESTSubReq1 | |
3198// | |---------------->| |
3199// | | | |
3200// | | RESTSubResp1 | |
3201// | |<----------------| |
3202// | | | |
3203// | | | SubReq1 |
3204// | | |------------->|
3205// | | | SubResp1 |
3206// | | |<-------------|
3207// | | RESTNotif1 | |
3208// | |<----------------| |
3209// | | | |
3210// | RESTSubReq2 | |
3211// |------------------------------>| |
3212// | | | |
3213// | RESTSubResp2 | |
3214// |<------------------------------| |
3215// | | | |
3216// | | RESTNotif2 | |
3217// |<------------------------------| |
3218// | | | |
3219// | | RESTSubDelReq1 | |
3220// | |---------------->| |
3221// | | | |
3222// | | RESTSubDelResp1 | |
3223// | |<----------------| |
3224// | | | |
3225// | RESTSubDelReq2 | |
3226// |------------------------------>| |
3227// | | | |
3228// | RESTSubDelResp2 | |
3229// |<------------------------------| |
3230// | | | |
3231// | | | SubDelReq2 |
3232// | | |------------->|
3233// | | | |
3234// | | | SubDelResp2 |
3235// | | |<-------------|
3236// | | | |
3237//
3238//-----------------------------------------------------------------------------
3239func TestRESTSubReqAndSubDelOkSameAction(t *testing.T) {
3240 CaseBegin("TestRESTSubReqAndSubDelOkSameAction")
3241
3242 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3243 Counter{cSubReqFromXapp, 2},
3244 Counter{cSubReqToE2, 1},
3245 Counter{cSubRespFromE2, 1},
3246 Counter{cSubRespToXapp, 2},
3247 Counter{cMergedSubscriptions, 1},
3248 Counter{cUnmergedSubscriptions, 1},
3249 Counter{cSubDelReqFromXapp, 2},
3250 Counter{cSubDelReqToE2, 1},
3251 Counter{cSubDelRespFromE2, 1},
3252 Counter{cSubDelRespToXapp, 2},
3253 })
3254
3255 // Req1
3256 var params *teststube2ap.RESTSubsReqParams = nil
3257
3258 //Subs Create
3259 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
3260 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
3261
3262 // Req2
3263 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3264 params.SetMeid("RAN_NAME_1")
3265
3266 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
3267 xappConn2.WaitRESTNotificationForAnySubscriptionId(t)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00003268 waiter := rtmgrHttp.AllocNextSleep(10, true)
archaggeafbf95f2021-04-14 08:54:05 +03003269 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
Markku Virtanen5ae07f42021-05-18 12:03:16 +00003270 waiter.WaitResult(t)
archaggeafbf95f2021-04-14 08:54:05 +03003271 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
3272 e2SubsId2 := <-xappConn2.RESTNotification
3273 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
3274
3275 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
3276
3277 // Del1
3278 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3279
3280 // Del2
3281 deleteXapp2Subscription(t, &restSubId2)
3282
3283 //Wait that subs is cleaned
3284 waitSubsCleanup(t, e2SubsId2, 10)
3285
3286 mainCtrl.VerifyCounterValues(t)
3287}
3288
3289//-----------------------------------------------------------------------------
3290// TestSubReqAndSubDelOkSameActionParallel
3291//
3292// stub stub stub
3293// +-------+ +-------+ +---------+ +---------+
3294// | xapp2 | | xapp1 | | submgr | | e2term |
3295// +-------+ +-------+ +---------+ +---------+
3296// | | | |
3297// | | | |
3298// | | | |
3299// | | SubReq1 | |
3300// | |------------->| |
3301// | | | |
3302// | | | SubReq1 |
3303// | | |------------->|
3304// | SubReq2 | |
3305// |--------------------------->| |
3306// | | | SubResp1 |
3307// | | |<-------------|
3308// | | SubResp1 | |
3309// | |<-------------| |
3310// | | | SubReq2 |
3311// | | |------------->|
3312// | | | |
3313// | | | SubResp2 |
3314// | | |<-------------|
3315// | SubResp2 | |
3316// |<---------------------------| |
3317// | | | |
3318// | | SubDelReq 1 | |
3319// | |------------->| |
3320// | | | |
3321// | | SubDelResp 1 | |
3322// | |<-------------| |
3323// | | | |
3324// | SubDelReq 2 | |
3325// |--------------------------->| |
3326// | | | |
3327// | | | SubDelReq 2 |
3328// | | |------------->|
3329// | | | |
3330// | | | SubDelReq 2 |
3331// | | |------------->|
3332// | | | |
3333// | SubDelResp 2 | |
3334// |<---------------------------| |
3335//
3336func TestRESTSubReqAndSubDelOkSameActionParallel(t *testing.T) {
3337 CaseBegin("TestRESTSubReqAndSubDelOkSameActionParallel")
3338
3339 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3340 Counter{cSubReqFromXapp, 2},
3341 Counter{cSubReqToE2, 2},
3342 Counter{cSubRespFromE2, 2},
3343 Counter{cSubRespToXapp, 2},
3344 Counter{cSubDelReqFromXapp, 2},
3345 Counter{cSubDelReqToE2, 2},
3346 Counter{cSubDelRespFromE2, 2},
3347 Counter{cSubDelRespToXapp, 2},
3348 })
3349
3350 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3351 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
3352 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3353
3354 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3355 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
3356
3357 xappConn1.ExpectRESTNotification(t, restSubId1)
3358 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3359 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
3360
3361 xappConn2.ExpectRESTNotification(t, restSubId2)
3362 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
3363 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
3364 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
3365
3366 // Del1
3367 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3368 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
3369 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3370 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
3371
3372 // Del2
3373 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
3374 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
3375 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
3376
3377 waitSubsCleanup(t, e2SubsId2, 10)
3378
3379 mainCtrl.VerifyCounterValues(t)
3380}
3381
3382//-----------------------------------------------------------------------------
3383// TestRESTSubReqAndSubDelNoAnswerSameActionParallel
3384//
3385// stub stub stub
3386// +-------+ +-------+ +---------+ +---------+
3387// | xapp2 | | xapp1 | | submgr | | e2term |
3388// +-------+ +-------+ +---------+ +---------+
3389// | | | |
3390// | | | |
3391// | | | |
3392// | | RESTSubReq1 | |
3393// | |---------------->| |
3394// | | | |
3395// | | RESTSubResp1 | |
3396// | |<----------------| |
3397// | | | SubReq1 |
3398// | | |------------->|
3399// | RESTSubReq2 | |
3400// |------------------------------>| |
3401// | | | |
3402// | RESTSubDelResp2 | |
3403// |<------------------------------| |
3404// | | | SubReq1 |
3405// | | |------------->|
3406// | | | |
3407// | | | |
3408// | | | SubDelReq |
3409// | | |------------->|
3410// | | | |
3411// | | | SubDelResp |
3412// | | |<-------------|
3413// | | RESTNotif1 | |
3414// | | unsuccess | |
3415// | |<----------------| |
3416// | RESTNotif2 | |
3417// | | unsuccess | |
3418// |<------------------------------| |
3419// | | | |
3420// | | RESTSubDelReq1 | |
3421// | |---------------->| |
3422// | | | |
3423// | | RESTSubDelResp1 | |
3424// | |<----------------| |
3425// | | | |
3426// | RESTSubDelReq2 | |
3427// |------------------------------>| |
3428// | | | |
3429// | RESTSubDelResp2 | |
3430// |<------------------------------| |
3431//
3432//-----------------------------------------------------------------------------
3433func TestRESTSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
3434 CaseBegin("TestRESTSubReqAndSubDelNoAnswerSameActionParallel")
3435
3436 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3437 Counter{cSubReqFromXapp, 2},
3438 Counter{cSubReqToE2, 1},
3439 Counter{cSubRespToXapp, 2},
3440 Counter{cSubDelReqFromXapp, 2},
3441 Counter{cSubDelReqToE2, 1},
3442 Counter{cSubDelRespFromE2, 1},
3443 Counter{cSubDelRespToXapp, 2},
3444 })
3445
3446 const subReqCount int = 1
3447 const parameterSet = 1
3448 const actionDefinitionPresent bool = true
3449 const actionParamCount int = 1
3450
3451 // Req1
3452 params1 := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3453 restSubId1 := xappConn1.SendRESTSubsReq(t, params1)
3454 crereq1, _ := e2termConn1.RecvSubsReq(t)
3455
3456 // Req2
3457 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
3458 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3459 params2.SetMeid("RAN_NAME_1")
3460 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
3461 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
3462
3463 //Req1 (retransmitted)
3464 e2termConn1.RecvSubsReq(t)
3465
3466 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Markku Virtanenda34eec2021-05-20 08:22:04 +00003467
3468 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
archaggeafbf95f2021-04-14 08:54:05 +03003469 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3470
Markku Virtanenda34eec2021-05-20 08:22:04 +00003471 e2SubsIdA := <-xappConn1.ListedRESTNotifications
3472 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
3473 e2SubsIdB := <-xappConn1.ListedRESTNotifications
3474 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
archaggeafbf95f2021-04-14 08:54:05 +03003475
3476 // Del1
3477 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3478
3479 // Del2
3480 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
3481
Markku Virtanenda34eec2021-05-20 08:22:04 +00003482 mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
3483
archaggeafbf95f2021-04-14 08:54:05 +03003484 //Wait that subs is cleaned
Markku Virtanenda34eec2021-05-20 08:22:04 +00003485 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
archaggeafbf95f2021-04-14 08:54:05 +03003486
3487 mainCtrl.VerifyCounterValues(t)
3488}
3489
3490//-----------------------------------------------------------------------------
3491// TestRESTSubReqAndSubDelNokSameActionParallel
3492//
3493// stub stub stub
3494// +-------+ +-------+ +---------+ +---------+
3495// | xapp2 | | xapp1 | | submgr | | e2term |
3496// +-------+ +-------+ +---------+ +---------+
3497// | | | |
3498// | | | |
3499// | | | |
3500// | | RESTSubReq1 | |
3501// | |---------------->| |
3502// | | | |
3503// | | RESTSubResp1 | |
3504// | |<----------------| |
3505// | | | SubReq1 |
3506// | | |------------->|
3507// | RESTSubReq2 | |
3508// |------------------------------>| |
3509// | | | |
3510// | RESTSubDelResp2 | |
3511// |<------------------------------| |
3512// | | | SubFail1 |
3513// | | |<-------------|
3514// | | | |
3515// | | RESTNotif1 | |
3516// | | unsuccess | |
3517// | |<----------------| |
3518// | RESTNotif2 | |
3519// | | unsuccess | |
3520// |<------------------------------| |
3521// | | | SubDelReq |
3522// | | |------------->|
3523// | | | SubDelResp |
3524// | | |<-------------|
3525// | | | |
3526// | | RESTSubDelReq1 | |
3527// | |---------------->| |
3528// | | | |
3529// | | RESTSubDelResp1 | |
3530// | |<----------------| |
3531// | | | |
3532// | RESTSubDelReq2 | |
3533// |------------------------------>| |
3534// | | | |
3535// | RESTSubDelResp2 | |
3536// |<------------------------------| |
3537//
3538//-----------------------------------------------------------------------------
3539func TestRESTSubReqAndSubDelNokSameActionParallel(t *testing.T) {
3540 CaseBegin("TestRESTSubReqAndSubDelNokSameActionParallel")
3541
3542 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3543 Counter{cSubReqFromXapp, 2},
3544 Counter{cSubReqToE2, 1},
3545 Counter{cSubFailFromE2, 1},
3546 Counter{cSubRespToXapp, 2},
3547 Counter{cSubDelReqFromXapp, 2},
3548 Counter{cSubDelReqToE2, 1},
3549 Counter{cSubDelRespFromE2, 1},
3550 Counter{cSubDelRespToXapp, 2},
3551 })
3552
3553 const subReqCount int = 1
3554 const parameterSet = 1
3555 const actionDefinitionPresent bool = true
3556 const actionParamCount int = 1
3557
3558 // Req1
3559 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3560 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
3561 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3562
3563 // Req2
3564 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
3565 params2 := xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3566 params2.SetMeid("RAN_NAME_1")
3567 restSubId2 := xappConn2.SendRESTSubsReq(t, params2)
3568 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
3569
3570 // E2t: send SubsFail (first)
3571 fparams1 := &teststube2ap.E2StubSubsFailParams{}
3572 fparams1.Set(crereq1)
3573 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
3574
3575 // E2t: internal delete
3576 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3577 xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
3578 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3579
3580 e2SubsIdA := <-xappConn1.ListedRESTNotifications
3581 xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
3582 e2SubsIdB := <-xappConn1.ListedRESTNotifications
3583 xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
3584
3585 // Del1
3586 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3587
3588 // Del2
3589 xappConn2.SendRESTSubsDelReq(t, &restSubId2)
3590
3591 //Wait that subs is cleaned
3592 waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
3593 waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
3594
3595 mainCtrl.VerifyCounterValues(t)
3596}
3597
3598func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
3599 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
3600
3601 // Init counter check
3602 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3603 Counter{cSubReqFromXapp, 1},
3604 Counter{cSubReqToE2, 1},
3605 Counter{cSubRespFromE2, 1},
3606 Counter{cSubRespToXapp, 1},
3607 Counter{cSubDelReqFromXapp, 1},
3608 Counter{cSubDelReqToE2, 1},
3609 Counter{cSubDelRespFromE2, 1},
3610 Counter{cSubDelRespToXapp, 1},
3611 })
3612
3613 const subReqCount int = 1
3614 const parameterSet = 1
3615 const actionDefinitionPresent bool = true
3616 const actionParamCount int = 1
3617
3618 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
3619 restSubId := xappConn1.SendRESTSubsReq(t, params)
3620 xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
3621
3622 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3623 xappConn1.ExpectRESTNotification(t, restSubId)
3624 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3625 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
3626 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
3627
3628 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3629 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3630 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3631
3632 // Wait that subs is cleaned
3633 waitSubsCleanup(t, e2SubsId, 10)
3634 mainCtrl.VerifyCounterValues(t)
3635}
3636
3637//-----------------------------------------------------------------------------
3638// TestRESTSubReqPolicyChangeAndSubDelOk
3639//
3640// stub stub
3641// +-------+ +---------+ +---------+
3642// | xapp | | submgr | | e2term |
3643// +-------+ +---------+ +---------+
3644// | | |
3645// | RESTSubReq | |
3646// |---------------->| |
3647// | | |
3648// | RESTSubResp | |
3649// |<----------------| |
3650// | | SubReq |
3651// | |------------->|
3652// | | |
3653// | | SubResp |
3654// | |<-------------|
3655// | | |
3656// | RESTNotif | |
3657// |<----------------| |
3658// | | |
3659// | RESTSubReq | |
3660// |---------------->| |
3661// | | |
3662// | RESTSubResp | |
3663// |<----------------| |
3664// | | SubReq |
3665// | |------------->|
3666// | | |
3667// | | SubResp |
3668// | |<-------------|
3669// | | |
3670// | RESTNotif | |
3671// |<----------------| |
3672// | | |
3673// | RESTSubDelReq | |
3674// |---------------->| |
3675// | | |
3676// | | SubDelReq |
3677// | |------------->|
3678// | | |
3679// | | SubDelResp |
3680// | |<-------------|
3681// | | |
3682// | RESTSubDelResp | |
3683// |<----------------| |
3684//
3685//-----------------------------------------------------------------------------
3686func TestRESTSubReqPolicyChangeAndSubDelOk(t *testing.T) {
3687 CaseBegin("TestRESTSubReqPolicyAndSubDelOk")
3688
3689 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3690 Counter{cSubReqFromXapp, 2},
3691 Counter{cSubReqToE2, 2},
3692 Counter{cSubRespFromE2, 2},
3693 Counter{cSubRespToXapp, 2},
3694 Counter{cSubDelReqFromXapp, 1},
3695 Counter{cSubDelReqToE2, 1},
3696 Counter{cSubDelRespFromE2, 1},
3697 Counter{cSubDelRespToXapp, 1},
3698 })
3699
3700 const subReqCount int = 1
3701 const parameterSet = 1
3702 const actionDefinitionPresent bool = true
3703 const policyParamCount int = 1
3704
3705 // Req
3706 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
3707 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3708
3709 // Policy change
3710 instanceId := int64(e2SubsId)
3711 // GetRESTSubsReqPolicyParams sets some coutners on tc side.
3712 params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
3713 params.SubsReqParams.SubscriptionDetails[0].InstanceID = &instanceId
3714 params.SetTimeToWait("w200ms")
3715 restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
3716
3717 // Del
3718 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3719
3720 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3721 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3722
3723 // Wait that subs is cleaned
3724 waitSubsCleanup(t, e2SubsId, 10)
3725 mainCtrl.VerifyCounterValues(t)
3726}
3727
3728//-----------------------------------------------------------------------------
3729// TestRESTSubReqAndSubDelOkTwoE2termParallel
3730//
3731// stub stub stub
3732// +-------+ +---------+ +---------+ +---------+
3733// | xapp | | submgr | | e2term1 | | e2term2 |
3734// +-------+ +---------+ +---------+ +---------+
3735// | | | |
3736// | | | |
3737// | | | |
3738// | RESTSubReq1 | | |
3739// |---------------->| | |
3740// | | | |
3741// | RESTSubResp1 | | |
3742// |<----------------| | |
3743// | | SubReq1 | |
3744// | |------------->| |
3745// | | | |
3746// | RESTSubReq2 | | |
3747// |---------------->| | |
3748// | | | |
3749// | RESTSubResp2 | | |
3750// |<----------------| | |
3751// | | SubReq2 | |
3752// | |---------------------------->|
3753// | | | |
3754// | | SubResp1 | |
3755// | |<-------------| |
3756// | RESTNotif1 | | |
3757// |<----------------| | |
3758// | | SubResp2 | |
3759// | |<----------------------------|
3760// | RESTNotif2 | | |
3761// |<----------------| | |
3762// | | | |
3763// | [SUBS 1 DELETE] | |
3764// | | | |
3765// | [SUBS 2 DELETE] | |
3766// | | | |
3767//
3768//-----------------------------------------------------------------------------
3769func TestRESTSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
3770 CaseBegin("TestRESTSubReqAndSubDelOkTwoE2termParallel")
3771
3772 // Init counter check
3773 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3774 Counter{cSubReqFromXapp, 2},
3775 Counter{cSubReqToE2, 2},
3776 Counter{cSubRespFromE2, 2},
3777 Counter{cSubRespToXapp, 2},
3778 Counter{cSubDelReqFromXapp, 2},
3779 Counter{cSubDelReqToE2, 2},
3780 Counter{cSubDelRespFromE2, 2},
3781 Counter{cSubDelRespToXapp, 2},
3782 })
3783
3784 const subReqCount int = 1
3785 const parameterSet = 1
3786 const actionDefinitionPresent bool = true
3787 const actionParamCount int = 1
3788
3789 // Req1
3790 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3791 restSubId1 := xappConn1.SendRESTSubsReq(t, params)
3792 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
3793
3794 // Req2
3795 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3796 params.SetMeid("RAN_NAME_11")
3797 // Here we use xappConn2 to simulate sending second request from same xapp as doing it from xappConn1
3798 // would not work as notification would not be received
3799 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
3800 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
3801
3802 // Resp1
3803 xappConn1.ExpectRESTNotification(t, restSubId1)
3804 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
3805 e2SubsId1 := xappConn1.WaitRESTNotification(t, restSubId1)
3806 xapp.Logger.Info("TEST: REST notification received e2SubsId1=%v", e2SubsId1)
3807
3808 // Resp2
3809 xappConn2.ExpectRESTNotification(t, restSubId2)
3810 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
3811 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
3812 xapp.Logger.Info("TEST: REST notification received e2SubsId2=%v", e2SubsId2)
3813
3814 // Delete1
3815 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
3816 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
3817 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
3818
3819 // Wait that subs is cleaned
3820 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
3821
3822 // Delete2
3823 xappConn1.SendRESTSubsDelReq(t, &restSubId2)
3824 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
3825 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
3826
3827 // Wait that subs is cleaned
3828 waitSubsCleanup(t, e2SubsId2, 10)
3829
3830 mainCtrl.VerifyCounterValues(t)
3831}
3832
3833//-----------------------------------------------------------------------------
3834// TestRESTSubReqAsn1EncodeFail
3835//
3836// In this case submgr send RICSubscriptionDeleteRequest after encode failure which should not happen!
3837// stub stub
3838// +-------+ +---------+ +---------+
3839// | xapp | | submgr | | e2term |
3840// +-------+ +---------+ +---------+
3841// | | |
3842// | RESTSubReq | |
3843// |---------------->| |
3844// | | |
3845// | RESTSubResp | |
3846// |<----------------| |
3847// | RESTSubDelReq | |
3848// |---------------->| |
3849// | RESTSubDelResp | |
3850// | unsuccess | |
3851// |<----------------| |
3852// | | |
3853//
3854//-----------------------------------------------------------------------------
3855func TestRESTSubReqAsn1EncodeFail(t *testing.T) {
3856 CaseBegin("TestRESTSubReqAsn1EncodeFail")
3857
3858 xapp.Logger.Info("Xapp-frame, v0.8.1 sufficient REST API validation")
3859
3860}
3861
3862//-----------------------------------------------------------------------------
3863// TestRESTSubReqInsertAndSubDelOk
3864//
3865// stub stub
3866// +-------+ +---------+ +---------+
3867// | xapp | | submgr | | e2term |
3868// +-------+ +---------+ +---------+
3869// | | |
3870// | RestSubReq | |
3871// |---------------->| |
3872// | | |
3873// | RESTSubResp | |
3874// |<----------------| |
3875// | | |
3876// | | SubReq |
3877// | |------------->|
3878// | | |
3879// | | SubResp |
3880// | |<-------------|
3881// | RESTNotif | |
3882// |<----------------| |
3883// | ... | ... |
3884// | | |
3885// | RESTSubDelReq | |
3886// |---------------->| |
3887// | | |
3888// | | SubDelReq |
3889// | |------------->|
3890// | | |
3891// | | SubDelResp |
3892// | |<-------------|
3893// | | |
3894// | RESTSubDelResp| |
3895// |<----------------| |
3896//
3897//-----------------------------------------------------------------------------
3898func TestRESTSubReqInsertAndSubDelOk(t *testing.T) {
3899 CaseBegin("TestRESTInsertSubReqAndSubDelOk")
3900
3901 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3902 Counter{cSubReqFromXapp, 1},
3903 Counter{cSubReqToE2, 1},
3904 Counter{cSubRespFromE2, 1},
3905 Counter{cSubRespToXapp, 1},
3906 Counter{cSubDelReqFromXapp, 1},
3907 Counter{cSubDelReqToE2, 1},
3908 Counter{cSubDelRespFromE2, 1},
3909 Counter{cSubDelRespToXapp, 1},
3910 })
3911
3912 const subReqCount int = 1
3913 const parameterSet int = 1
3914 const actionDefinitionPresent bool = true
3915 const actionParamCount int = 1
3916
3917 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3918 params.SetSubActionTypes("insert")
3919
3920 // Req
3921 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
3922
3923 // Del
3924 xappConn1.SendRESTSubsDelReq(t, &restSubId)
3925
3926 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3927 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3928
3929 // Wait that subs is cleaned
3930 waitSubsCleanup(t, e2SubsId, 10)
3931 mainCtrl.VerifyCounterValues(t)
3932}
3933
3934//-----------------------------------------------------------------------------
3935// TestRESTSubReqNokAndSubDelOkWithRestartInMiddle
3936//
3937// stub stub
3938// +-------+ +---------+ +---------+
3939// | xapp | | submgr | | e2term |
3940// +-------+ +---------+ +---------+
3941// | | |
3942// | RESTSubReq | |
3943// |------------->| |
3944// | | |
3945// | | SubReq |
3946// | |------------->|
3947// | | |
3948// | | SubResp |
3949// | <----|
3950// | |
3951// | Submgr restart |
3952// | |
3953// | | |
3954// | | SubDelReq |
3955// | |------------->|
3956// | | |
3957// | | SubDelResp |
3958// | |<-------------|
3959// | | |
3960//
3961//-----------------------------------------------------------------------------
3962func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
3963 CaseBegin("TestRESTSubReqNokAndSubDelOkWithRestartInMiddle")
3964
3965 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
3966 Counter{cSubReqFromXapp, 1},
3967 Counter{cSubReqToE2, 1},
3968 Counter{cSubDelReqFromXapp, 1},
3969 Counter{cSubDelReqToE2, 1},
3970 Counter{cSubDelRespFromE2, 1},
3971 })
3972
3973 const subReqCount int = 1
3974 const parameterSet = 1
3975 const actionDefinitionPresent bool = true
3976 const actionParamCount int = 1
3977
3978 // Remove possible existing subscription
3979 mainCtrl.removeExistingSubscriptions(t)
3980
3981 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
3982
3983 //Req
3984 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
3985 restSubId := xappConn1.SendRESTSubsReq(t, params)
3986 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
3987
3988 e2termConn1.RecvSubsReq(t)
3989
3990 mainCtrl.SetResetTestFlag(t, false)
3991
3992 mainCtrl.SimulateRestart(t)
3993 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
3994
3995 //Del
3996 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
3997 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
3998
3999 xappConn1.TestMsgChanEmpty(t)
4000 xappConn2.TestMsgChanEmpty(t)
4001 e2termConn1.TestMsgChanEmpty(t)
4002 mainCtrl.wait_registry_empty(t, 10)
4003
4004 mainCtrl.VerifyCounterValues(t)
4005}
4006
4007//-----------------------------------------------------------------------------
4008// TestRESTSubReqAndSubDelOkWithRestartInMiddle
4009//
4010// stub stub
4011// +-------+ +---------+ +---------+
4012// | xapp | | submgr | | e2term |
4013// +-------+ +---------+ +---------+
4014// | | |
4015// | RESTSubReq | |
4016// |---------------->| |
4017// | | |
4018// | RESTSubResp | |
4019// |<----------------| |
4020// | | SubReq |
4021// | |------------->|
4022// | | |
4023// | | SubResp |
4024// | |<-------------|
4025// | | |
4026// | RESTNotif | |
4027// |<----------------| |
4028// | | |
4029// | |
4030// | Submgr restart |
4031// | | |
4032// | RESTSubDelReq | |
4033// |---------------->| |
4034// | | |
4035// | | SubDelReq |
4036// | |------------->|
4037// | | |
4038// | | SubDelResp |
4039// | |<-------------|
4040// | | |
4041// | RESTSubDelResp | |
4042// |<----------------| |
4043//
4044//-----------------------------------------------------------------------------
4045func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
4046 CaseBegin("TestRESTSubReqAndSubDelOkWithRestartInMiddle")
4047
4048 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4049 Counter{cSubReqFromXapp, 1},
4050 Counter{cSubReqToE2, 1},
4051 Counter{cSubRespFromE2, 1},
4052 Counter{cSubRespToXapp, 1},
4053 Counter{cSubDelReqFromXapp, 1},
4054 Counter{cSubDelReqToE2, 1},
4055 Counter{cSubDelRespToXapp, 1},
4056 })
4057
4058 // Remove possible existing subscription
4059 mainCtrl.removeExistingSubscriptions(t)
4060
4061 var params *teststube2ap.RESTSubsReqParams = nil
4062
4063 // Create subscription
4064 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
4065 xapp.Logger.Info("Send REST subscriber request for subscriber : %v", restSubId)
4066
4067 // Check subscription
4068 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4069
4070 // When SDL support for the REST Interface is added
4071 // the submgr restart statement below should be removed
4072 // from the comment.
4073
4074 // mainCtrl.SimulateRestart(t)
4075 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4076
4077 // Check subscription
4078 queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
4079
4080 // Delete subscription
4081 deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
4082
4083 //Wait that subs is cleaned
4084 waitSubsCleanup(t, e2SubsId, 10)
4085
4086 mainCtrl.VerifyCounterValues(t)
4087}
4088
4089//-----------------------------------------------------------------------------
4090// TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle
4091//
4092// stub stub
4093// +-------+ +-------+ +---------+ +---------+
4094// | xapp2 | | xapp1 | | submgr | | e2term |
4095// +-------+ +-------+ +---------+ +---------+
4096// | | | |
4097// | | RESTSubReq1 | |
4098// | |---------------->| |
4099// | | | |
4100// | | RESTSubResp1 | |
4101// | |<----------------| |
4102// | | | |
4103// | | | SubReq1 |
4104// | | |------------->|
4105// | | | SubResp1 |
4106// | | |<-------------|
4107// | | RESTNotif1 | |
4108// | |<----------------| |
4109// | | | |
4110// | RESTSubReq2 | |
4111// |------------------------------>| |
4112// | | | |
4113// | RESTSubResp2 | |
4114// |<------------------------------| |
4115// | | | |
4116// | | RESTNotif2 | |
4117// |<------------------------------| |
4118// | | | |
4119// | | Submgr restart |
4120// | | | |
4121// | | RESTSubDelReq1 | |
4122// | |---------------->| |
4123// | | | |
4124// | | RESTSubDelResp1 | |
4125// | |<----------------| |
4126// | | | |
4127// | | Submgr restart |
4128// | | | |
4129// | RESTSubDelReq2 | |
4130// |------------------------------>| |
4131// | | | |
4132// | RESTSubDelResp2 | |
4133// |<------------------------------| |
4134// | | | |
4135// | | | SubDelReq2 |
4136// | | |------------->|
4137// | | | |
4138// | | | SubDelResp2 |
4139// | | |<-------------|
4140// | | | |
4141//
4142//-----------------------------------------------------------------------------
4143func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
4144 CaseBegin("TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle")
4145
4146 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4147 Counter{cSubReqFromXapp, 2},
4148 Counter{cSubReqToE2, 1},
4149 Counter{cSubRespFromE2, 1},
4150 Counter{cSubRespToXapp, 2},
4151 Counter{cMergedSubscriptions, 1},
4152 Counter{cUnmergedSubscriptions, 1},
4153 Counter{cSubDelReqFromXapp, 2},
4154 Counter{cSubDelReqToE2, 1},
4155 Counter{cSubDelRespFromE2, 1},
4156 Counter{cSubDelRespToXapp, 2},
4157 })
4158
4159 // Remove possible existing subscription
4160 mainCtrl.removeExistingSubscriptions(t)
4161
4162 var params *teststube2ap.RESTSubsReqParams = nil
4163
4164 // Create subscription 1
4165 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4166 xapp.Logger.Info("Send REST subscriber request for subscriber 1 : %v", restSubId1)
4167
4168 // Create subscription 2 with same action
4169 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4170 params.SetMeid("RAN_NAME_1")
4171 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
4172 xappConn2.WaitRESTNotificationForAnySubscriptionId(t)
4173 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4174 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4175 e2SubsId2 := <-xappConn2.RESTNotification
4176 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
4177
4178 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
4179
4180 // When SDL support for the REST Interface is added
4181 // the submgr restart statement below should be removed
4182 // from the comment.
4183
4184 // mainCtrl.SimulateRestart(t)
4185 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
4186
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004187 // Delete subscription 1, and wait until it has removed the first endpoint
4188 subepcnt := mainCtrl.get_subs_entrypoint_cnt(t, e2SubsId1)
archaggeafbf95f2021-04-14 08:54:05 +03004189 xappConn1.SendRESTSubsDelReq(t, &restSubId1)
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004190 mainCtrl.wait_subs_entrypoint_cnt_change(t, e2SubsId1, subepcnt, 10)
archaggeafbf95f2021-04-14 08:54:05 +03004191
4192 // When SDL support for the REST Interface is added
4193 // the submgr restart statement below should be removed
4194 // from the comment.
4195
4196 // mainCtrl.SimulateRestart(t)
4197 // xapp.Logger.Debug("mainCtrl.SimulateRestart done")
archaggeafbf95f2021-04-14 08:54:05 +03004198 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
4199
4200 // Delete subscription 2
4201 deleteXapp2Subscription(t, &restSubId2)
4202
4203 //Wait that subs is cleaned
4204 waitSubsCleanup(t, e2SubsId2, 10)
4205
4206 mainCtrl.VerifyCounterValues(t)
4207}
4208
4209//-----------------------------------------------------------------------------
4210// TestRESTReportSubReqAndSubDelOk
4211//
4212// stub stub
4213// +-------+ +---------+ +---------+
4214// | xapp | | submgr | | e2term |
4215// +-------+ +---------+ +---------+
4216// | | |
4217// | RestSubReq | |
4218// |---------------->| |
4219// | | |
4220// | RESTSubResp | |
4221// |<----------------| |
4222// | | |
4223// | | SubReq |
4224// | |------------->|
4225// | | |
4226// | | SubResp |
4227// | |<-------------|
4228// | RESTNotif | |
4229// |<----------------| |
4230// | | SubReq |
4231// | |------------->|
4232// | | |
4233// | | SubResp |
4234// | |<-------------|
4235// | RESTNotif | |
4236// |<----------------| |
4237// | ... | ... |
4238// | | |
4239// | | |
4240// | RESTSubDelReq | |
4241// |---------------->| |
4242// | | |
4243// | | SubDelReq |
4244// | |------------->|
4245// | | |
4246// | | SubDelResp |
4247// | |<-------------|
4248// | | |
4249// | RESTSubDelResp| |
4250// |<----------------| |
4251//
4252//-----------------------------------------------------------------------------
4253func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
4254 CaseBegin("TestRESTReportSubReqAndSubDelOk")
4255 subReqCount := 1
4256 parameterSet := 1 // E2SM-gNB-X2
4257 actionDefinitionPresent := true
4258 actionParamCount := 1
4259 testIndex := 1
4260 RESTReportSubReqAndSubDelOk(t, subReqCount, parameterSet, actionDefinitionPresent, actionParamCount, testIndex)
4261}
4262
4263func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, parameterSet int, actionDefinitionPresent bool, actionParamCount int, testIndex int) {
4264 xapp.Logger.Info("TEST: TestRESTReportSubReqAndSubDelOk with parameter set %v", testIndex)
4265
4266 // Req
4267 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4268 restSubId := xappConn1.SendRESTSubsReq(t, params)
4269
4270 var e2SubsId []uint32
4271 for i := 0; i < subReqCount; i++ {
4272 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4273 xappConn1.ExpectRESTNotification(t, restSubId)
4274
4275 e2termConn1.SendSubsResp(t, crereq, cremsg)
4276 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
4277 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
4278 e2SubsId = append(e2SubsId, instanceId)
4279 resp, _ := xapp.Subscription.QuerySubscriptions()
4280 assert.Equal(t, resp[i].SubscriptionID, (int64)(instanceId))
4281 assert.Equal(t, resp[i].Meid, "RAN_NAME_1")
4282 assert.Equal(t, resp[i].ClientEndpoint, []string{"localhost:13560"})
4283
4284 }
4285
4286 // Del
4287 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4288
4289 for i := 0; i < subReqCount; i++ {
4290 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4291 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4292 }
4293
4294 // Wait that subs is cleaned
4295 for i := 0; i < subReqCount; i++ {
4296 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
4297 }
4298
4299 xappConn1.TestMsgChanEmpty(t)
4300 e2termConn1.TestMsgChanEmpty(t)
4301 mainCtrl.wait_registry_empty(t, 10)
4302}
4303
4304/*
4305func TestRESTPolicySubReqAndSubDelOk(t *testing.T) {
4306 CaseBegin("TestRESTPolicySubReqAndSubDelOk")
4307
4308 subReqCount := 2
4309 actionDefinitionPresent := true
4310 policyParamCount := 1
4311 testIndex := 1
4312 RESTPolicySubReqAndSubDelOk(t, subReqCount, actionDefinitionPresent, policyParamCount, testIndex)
4313
4314 subReqCount = 19
4315 actionDefinitionPresent = false
4316 policyParamCount = 0
4317 testIndex = 2
4318 RESTPolicySubReqAndSubDelOk(t, subReqCount, actionDefinitionPresent, policyParamCount, testIndex)
4319}
4320*/
4321func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, actionDefinitionPresent bool, policyParamCount int, testIndex int) {
4322 xapp.Logger.Info("TEST: TestRESTPolicySubReqAndSubDelOk with parameter set %v", testIndex)
4323
4324 // Req
4325 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
4326 restSubId := xappConn1.SendRESTSubsReq(t, params)
4327 //params := xappConn1.GetRESTSubsReqPolicyParams1(subReqCount, actionDefinitionPresent, policyParamCount)
4328 //restSubId := xappConn1.SendRESTPolicySubsReq(t, params)
4329
4330 var e2SubsId []uint32
4331 for i := 0; i < subReqCount; i++ {
4332 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4333 xappConn1.ExpectRESTNotification(t, restSubId)
4334 e2termConn1.SendSubsResp(t, crereq, cremsg)
4335 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
4336 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
4337 e2SubsId = append(e2SubsId, instanceId)
4338 }
4339
4340 // Del
4341 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4342
4343 for i := 0; i < subReqCount; i++ {
4344 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4345 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4346 }
4347
4348 // Wait that subs is cleaned
4349 for i := 0; i < subReqCount; i++ {
4350 mainCtrl.wait_subs_clean(t, e2SubsId[i], 10)
4351 }
4352 xappConn1.TestMsgChanEmpty(t)
4353 e2termConn1.TestMsgChanEmpty(t)
4354 mainCtrl.wait_registry_empty(t, 10)
4355}
4356
archaggeafbf95f2021-04-14 08:54:05 +03004357func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
4358
4359 subReqCount := 2
4360
4361 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4362 Counter{cSubReqFromXapp, 1},
4363 Counter{cSubReqToE2, 2},
4364 Counter{cSubRespFromE2, 2},
4365 Counter{cSubRespToXapp, 2},
4366 Counter{cSubDelReqFromXapp, 1},
4367 Counter{cSubDelReqToE2, 2},
4368 Counter{cSubDelRespFromE2, 2},
4369 Counter{cSubDelRespToXapp, 1},
4370 })
4371
4372 // Req
4373 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
4374 restSubId := xappConn1.SendRESTSubsReq(t, params)
4375 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4376
4377 assert.Equal(t, len(e2SubsIds), 2)
4378
4379 // Del
4380 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4381 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4382
4383 xappConn1.TestMsgChanEmpty(t)
4384 e2termConn1.TestMsgChanEmpty(t)
4385 mainCtrl.wait_registry_empty(t, 10)
4386
4387 mainCtrl.VerifyCounterValues(t)
4388}
archaggeafbf95f2021-04-14 08:54:05 +03004389func TestRESTPolicySubReqAndSubDelOkFullAmount(t *testing.T) {
4390
4391 subReqCount := 19
4392
4393 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4394 Counter{cSubReqFromXapp, 1},
4395 Counter{cSubReqToE2, 19},
4396 Counter{cSubRespFromE2, 19},
4397 Counter{cSubRespToXapp, 19},
4398 Counter{cSubDelReqFromXapp, 1},
4399 Counter{cSubDelReqToE2, 19},
4400 Counter{cSubDelRespFromE2, 19},
4401 Counter{cSubDelRespToXapp, 1},
4402 })
4403
4404 // Req
4405 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
4406 restSubId := xappConn1.SendRESTSubsReq(t, params)
4407 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4408
4409 assert.Equal(t, len(e2SubsIds), 19)
4410
4411 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4412 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4413
4414 xappConn1.TestMsgChanEmpty(t)
4415 e2termConn1.TestMsgChanEmpty(t)
4416 mainCtrl.wait_registry_empty(t, 10)
4417
4418 mainCtrl.VerifyCounterValues(t)
4419}
archaggeafbf95f2021-04-14 08:54:05 +03004420func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
4421
4422 subReqCount := 2
4423 parameterSet := 1
4424 actionDefinitionPresent := true
4425 actionParamCount := 1
4426
4427 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4428 Counter{cSubReqFromXapp, 1},
4429 Counter{cSubReqToE2, uint64(subReqCount)},
4430 Counter{cSubRespFromE2, uint64(subReqCount)},
4431 Counter{cSubRespToXapp, uint64(subReqCount)},
4432 Counter{cSubDelReqFromXapp, 1},
4433 Counter{cSubDelReqToE2, uint64(subReqCount)},
4434 Counter{cSubDelRespFromE2, uint64(subReqCount)},
4435 Counter{cSubDelRespToXapp, 1},
4436 })
4437
4438 // Req
4439 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4440 restSubId := xappConn1.SendRESTSubsReq(t, params)
4441 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4442
4443 assert.Equal(t, len(e2SubsIds), subReqCount)
4444
4445 // Del
4446 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4447 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4448
4449 xappConn1.TestMsgChanEmpty(t)
4450 e2termConn1.TestMsgChanEmpty(t)
4451 mainCtrl.wait_registry_empty(t, 10)
4452
4453 mainCtrl.VerifyCounterValues(t)
4454}
Markku Virtanenda34eec2021-05-20 08:22:04 +00004455
archaggeafbf95f2021-04-14 08:54:05 +03004456func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
4457
4458 subReqCount := 2
4459 parameterSet := 1
4460 actionDefinitionPresent := false
4461 actionParamCount := 0
4462
4463 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4464 Counter{cSubReqFromXapp, 1},
4465 Counter{cSubReqToE2, uint64(subReqCount)},
4466 Counter{cSubRespFromE2, uint64(subReqCount)},
4467 Counter{cSubRespToXapp, uint64(subReqCount)},
4468 Counter{cSubDelReqFromXapp, 1},
4469 Counter{cSubDelReqToE2, uint64(subReqCount)},
4470 Counter{cSubDelRespFromE2, uint64(subReqCount)},
4471 Counter{cSubDelRespToXapp, 1},
4472 })
4473
4474 // Req
4475 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4476 restSubId := xappConn1.SendRESTSubsReq(t, params)
4477 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4478
4479 assert.Equal(t, len(e2SubsIds), subReqCount)
4480
4481 // Del
4482 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4483 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4484
4485 xappConn1.TestMsgChanEmpty(t)
4486 e2termConn1.TestMsgChanEmpty(t)
4487 mainCtrl.wait_registry_empty(t, 10)
4488
4489 mainCtrl.VerifyCounterValues(t)
4490}
Markku Virtanenfe2cdab2021-05-21 10:59:29 +00004491
archaggeafbf95f2021-04-14 08:54:05 +03004492func TestRESTFullAmountReportSubReqAndSubDelOk(t *testing.T) {
4493
4494 subReqCount := 19
4495 parameterSet := 1
4496 actionDefinitionPresent := false
4497 actionParamCount := 0
4498
4499 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4500 Counter{cSubReqFromXapp, 1},
4501 Counter{cSubReqToE2, uint64(subReqCount)},
4502 Counter{cSubRespFromE2, uint64(subReqCount)},
4503 Counter{cSubRespToXapp, uint64(subReqCount)},
4504 Counter{cSubDelReqFromXapp, 1},
4505 Counter{cSubDelReqToE2, uint64(subReqCount)},
4506 Counter{cSubDelRespFromE2, uint64(subReqCount)},
4507 Counter{cSubDelRespToXapp, 1},
4508 })
4509
4510 // Req
4511 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4512 restSubId := xappConn1.SendRESTSubsReq(t, params)
4513 e2SubsIds := sendAndReceiveMultipleE2SubReqs(t, subReqCount, xappConn1, e2termConn1, restSubId)
4514
4515 assert.Equal(t, len(e2SubsIds), subReqCount)
4516
4517 // Del
4518 xappConn1.SendRESTSubsDelReq(t, &restSubId)
4519 sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
4520
4521 xappConn1.TestMsgChanEmpty(t)
4522 e2termConn1.TestMsgChanEmpty(t)
4523 mainCtrl.wait_registry_empty(t, 10)
4524
4525 mainCtrl.VerifyCounterValues(t)
4526}
Konstantinos Archangelof39d94ea2021-05-21 09:36:45 +00004527
4528func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
4529 CaseBegin("TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen")
4530
4531 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4532 Counter{cSubReqFromXapp, 2},
4533 Counter{cSubReqToE2, 2},
4534 Counter{cSubRespFromE2, 2},
4535 Counter{cSubRespToXapp, 2},
4536 Counter{cSubDelReqFromXapp, 2},
4537 Counter{cSubDelReqToE2, 2},
4538 Counter{cSubDelRespFromE2, 2},
4539 Counter{cSubDelRespToXapp, 2},
4540 })
4541
4542 // Req1
4543 var params *teststube2ap.RESTSubsReqParams = nil
4544
4545 //Subs Create
4546 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4547 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4548
4549 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4550
4551 // Req2
4552 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4553 params.SetMeid("RAN_NAME_1")
4554 eventTriggerDefinition := "1234"
4555 params.SetSubEventTriggerDefinition(eventTriggerDefinition)
4556
4557 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4558 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4559 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4560 xappConn2.ExpectRESTNotification(t, restSubId2)
4561 e2termConn1.SendSubsResp(t, crereq, cremsg)
4562 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4563
4564 deleteXapp1Subscription(t, &restSubId1)
4565 deleteXapp2Subscription(t, &restSubId2)
4566
4567 waitSubsCleanup(t, e2SubsId1, 10)
4568 waitSubsCleanup(t, e2SubsId2, 10)
4569
4570 mainCtrl.VerifyCounterValues(t)
4571
4572}
4573
4574func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
4575 CaseBegin("TestRESTSubReqReportSameActionDiffActionListLen")
4576
4577 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4578 Counter{cSubReqFromXapp, 2},
4579 Counter{cSubReqToE2, 2},
4580 Counter{cSubRespFromE2, 2},
4581 Counter{cSubRespToXapp, 2},
4582 Counter{cSubDelReqFromXapp, 2},
4583 Counter{cSubDelReqToE2, 2},
4584 Counter{cSubDelRespFromE2, 2},
4585 Counter{cSubDelRespToXapp, 2},
4586 })
4587
4588 // Req1
4589 var params *teststube2ap.RESTSubsReqParams = nil
4590
4591 //Subs Create
4592 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4593 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4594
4595 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4596
4597 // Req2
4598 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4599 params.SetMeid("RAN_NAME_1")
4600
4601 actionId := int64(1)
4602 actionType := "report"
4603 actionDefinition := "56781"
4604 subsequestActionType := "continue"
4605 timeToWait := "w10ms"
4606 params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
4607
4608 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4609 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4610 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4611 xappConn2.ExpectRESTNotification(t, restSubId2)
4612 e2termConn1.SendSubsResp(t, crereq, cremsg)
4613 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4614
4615 deleteXapp1Subscription(t, &restSubId1)
4616 deleteXapp2Subscription(t, &restSubId2)
4617
4618 waitSubsCleanup(t, e2SubsId1, 10)
4619 waitSubsCleanup(t, e2SubsId2, 10)
4620
4621 mainCtrl.VerifyCounterValues(t)
4622
4623}
4624
4625func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
4626 CaseBegin("TestRESTSubReqReportSameActionDiffActionID")
4627
4628 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4629 Counter{cSubReqFromXapp, 2},
4630 Counter{cSubReqToE2, 2},
4631 Counter{cSubRespFromE2, 2},
4632 Counter{cSubRespToXapp, 2},
4633 Counter{cSubDelReqFromXapp, 2},
4634 Counter{cSubDelReqToE2, 2},
4635 Counter{cSubDelRespFromE2, 2},
4636 Counter{cSubDelRespToXapp, 2},
4637 })
4638
4639 // Req1
4640 var params *teststube2ap.RESTSubsReqParams = nil
4641
4642 //Subs Create
4643 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4644 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4645
4646 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4647
4648 // Req2
4649 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4650 params.SetMeid("RAN_NAME_1")
4651 params.SetSubActionIDs(int64(2))
4652
4653 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4654 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4655 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4656 xappConn2.ExpectRESTNotification(t, restSubId2)
4657 e2termConn1.SendSubsResp(t, crereq, cremsg)
4658 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4659
4660 deleteXapp1Subscription(t, &restSubId1)
4661 deleteXapp2Subscription(t, &restSubId2)
4662
4663 waitSubsCleanup(t, e2SubsId1, 10)
4664 waitSubsCleanup(t, e2SubsId2, 10)
4665
4666 mainCtrl.VerifyCounterValues(t)
4667
4668}
4669
4670func TestRESTSubReqDiffActionType(t *testing.T) {
4671 CaseBegin("TestRESTSubReqDiffActionType")
4672
4673 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4674 Counter{cSubReqFromXapp, 2},
4675 Counter{cSubReqToE2, 2},
4676 Counter{cSubRespFromE2, 2},
4677 Counter{cSubRespToXapp, 2},
4678 Counter{cSubDelReqFromXapp, 2},
4679 Counter{cSubDelReqToE2, 2},
4680 Counter{cSubDelRespFromE2, 2},
4681 Counter{cSubDelRespToXapp, 2},
4682 })
4683
4684 // Req1
4685 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
4686
4687 //Subs Create
4688 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4689 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4690
4691 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4692
4693 // Req2
4694 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4695 params.SetMeid("RAN_NAME_1")
4696
4697 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4698 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4699 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4700 xappConn2.ExpectRESTNotification(t, restSubId2)
4701 e2termConn1.SendSubsResp(t, crereq, cremsg)
4702 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4703
4704 deleteXapp1Subscription(t, &restSubId1)
4705 deleteXapp2Subscription(t, &restSubId2)
4706
4707 waitSubsCleanup(t, e2SubsId1, 10)
4708 waitSubsCleanup(t, e2SubsId2, 10)
4709
4710 mainCtrl.VerifyCounterValues(t)
4711
4712}
4713
4714func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
4715 CaseBegin("TestRESTSubReqPolicyAndSubDelOkSameAction")
4716
4717 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4718 Counter{cSubReqFromXapp, 2},
4719 Counter{cSubReqToE2, 2},
4720 Counter{cSubRespFromE2, 2},
4721 Counter{cSubRespToXapp, 2},
4722 Counter{cSubDelReqFromXapp, 2},
4723 Counter{cSubDelReqToE2, 2},
4724 Counter{cSubDelRespFromE2, 2},
4725 Counter{cSubDelRespToXapp, 2},
4726 })
4727
4728 // Req1
4729 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
4730
4731 //Subs Create
4732 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4733 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4734
4735 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4736
4737 // Req2
4738 params = xappConn2.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
4739 params.SetMeid("RAN_NAME_1")
4740
4741 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4742 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4743 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4744 xappConn2.ExpectRESTNotification(t, restSubId2)
4745 e2termConn1.SendSubsResp(t, crereq, cremsg)
4746 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4747
4748 deleteXapp1Subscription(t, &restSubId1)
4749 deleteXapp2Subscription(t, &restSubId2)
4750
4751 waitSubsCleanup(t, e2SubsId1, 10)
4752 waitSubsCleanup(t, e2SubsId2, 10)
4753
4754 mainCtrl.VerifyCounterValues(t)
4755
4756}
4757
4758func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
4759 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionLen")
4760
4761 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4762 Counter{cSubReqFromXapp, 2},
4763 Counter{cSubReqToE2, 2},
4764 Counter{cSubRespFromE2, 2},
4765 Counter{cSubRespToXapp, 2},
4766 Counter{cSubDelReqFromXapp, 2},
4767 Counter{cSubDelReqToE2, 2},
4768 Counter{cSubDelRespFromE2, 2},
4769 Counter{cSubDelRespToXapp, 2},
4770 })
4771
4772 // Req1
4773 var params *teststube2ap.RESTSubsReqParams = nil
4774
4775 //Subs Create
4776 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4777 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4778
4779 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4780
4781 // Req2
4782 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4783 params.SetMeid("RAN_NAME_1")
4784 actionDefinition := "5678"
4785 params.SetSubActionDefinition(actionDefinition)
4786
4787 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4788 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4789 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4790 xappConn2.ExpectRESTNotification(t, restSubId2)
4791 e2termConn1.SendSubsResp(t, crereq, cremsg)
4792 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4793
4794 deleteXapp1Subscription(t, &restSubId1)
4795 deleteXapp2Subscription(t, &restSubId2)
4796
4797 waitSubsCleanup(t, e2SubsId1, 10)
4798 waitSubsCleanup(t, e2SubsId2, 10)
4799
4800 mainCtrl.VerifyCounterValues(t)
4801
4802}
4803
4804func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
4805 CaseBegin("TestRESTSubReqReportSameActionDiffActionDefinitionContents")
4806
4807 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4808 Counter{cSubReqFromXapp, 2},
4809 Counter{cSubReqToE2, 2},
4810 Counter{cSubRespFromE2, 2},
4811 Counter{cSubRespToXapp, 2},
4812 Counter{cSubDelReqFromXapp, 2},
4813 Counter{cSubDelReqToE2, 2},
4814 Counter{cSubDelRespFromE2, 2},
4815 Counter{cSubDelRespToXapp, 2},
4816 })
4817
4818 // Req1
4819 var params *teststube2ap.RESTSubsReqParams = nil
4820
4821 //Subs Create
4822 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4823 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4824
4825 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4826
4827 // Req2
4828 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4829 params.SetMeid("RAN_NAME_1")
4830 actionDefinition := "56782"
4831 params.SetSubActionDefinition(actionDefinition)
4832
4833 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4834 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4835 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4836 xappConn2.ExpectRESTNotification(t, restSubId2)
4837 e2termConn1.SendSubsResp(t, crereq, cremsg)
4838 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4839
4840 deleteXapp1Subscription(t, &restSubId1)
4841 deleteXapp2Subscription(t, &restSubId2)
4842
4843 waitSubsCleanup(t, e2SubsId1, 10)
4844 waitSubsCleanup(t, e2SubsId2, 10)
4845
4846 mainCtrl.VerifyCounterValues(t)
4847
4848}
4849
4850func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
4851 CaseBegin("TestRESTSubReqReportSameActionDiffSubsAction")
4852
4853 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
4854 Counter{cSubReqFromXapp, 2},
4855 Counter{cSubReqToE2, 2},
4856 Counter{cSubRespFromE2, 2},
4857 Counter{cSubRespToXapp, 2},
4858 Counter{cSubDelReqFromXapp, 2},
4859 Counter{cSubDelReqToE2, 2},
4860 Counter{cSubDelRespFromE2, 2},
4861 Counter{cSubDelRespToXapp, 2},
4862 })
4863
4864 // Req1
4865 var params *teststube2ap.RESTSubsReqParams = nil
4866
4867 //Subs Create
4868 restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
4869 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId1)
4870
4871 queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560"})
4872
4873 // Req2
4874 params = xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4875 params.SetMeid("RAN_NAME_1")
4876 params.SetTimeToWait("w200ms")
4877 restSubId2 := xappConn2.SendRESTSubsReq(t, params)
4878 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
4879 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4880 xappConn2.ExpectRESTNotification(t, restSubId2)
4881 e2termConn1.SendSubsResp(t, crereq, cremsg)
4882 e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2)
4883
4884 deleteXapp1Subscription(t, &restSubId1)
4885 deleteXapp2Subscription(t, &restSubId2)
4886
4887 waitSubsCleanup(t, e2SubsId1, 10)
4888 waitSubsCleanup(t, e2SubsId2, 10)
4889
4890 mainCtrl.VerifyCounterValues(t)
4891
4892}
4893
Anssi Mannila51122392021-05-25 11:51:31 +03004894//-----------------------------------------------------------------------------
4895// TestRESTUnpackSubscriptionResponseDecodeFail
4896//
4897// stub stub
4898// +-------+ +---------+ +---------+
4899// | xapp | | submgr | | e2term |
4900// +-------+ +---------+ +---------+
4901// | | |
4902// | RestSubReq | |
4903// |---------------->| |
4904// | | |
4905// | RESTSubResp | |
4906// |<----------------| |
4907// | | |
4908// | | SubReq |
4909// | |------------->|
4910// | | |
4911// | | SubResp | ASN.1 decode fails
4912// | |<-------------|
4913// | | |
4914// | | SubReq |
4915// | |------------->|
4916// | | |
4917// | | SubFail | Duplicated action
4918// | |<-------------|
4919// | RESTNotif (fail)| |
4920// |<----------------| |
4921// | | SubDelReq |
4922// | |------------->|
4923// | | |
4924// | | SubDelResp |
4925// | |<-------------|
4926//
4927//-----------------------------------------------------------------------------
4928func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
4929 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseDecodeFail")
4930 subReqCount := 1
4931 parameterSet := 1 // E2SM-gNB-X2
4932 actionDefinitionPresent := true
4933 actionParamCount := 1
4934
4935 // Req
4936 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
4937 restSubId := xappConn1.SendRESTSubsReq(t, params)
4938
4939 crereq, cremsg := e2termConn1.RecvSubsReq(t)
4940 // Decode of this response fails which will result resending original request
4941 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_RESP)
4942
4943 _, cremsg = e2termConn1.RecvSubsReq(t)
4944
4945 xappConn1.ExpectRESTNotification(t, restSubId)
4946
4947 // Subscription already created in E2 Node.
4948 fparams := &teststube2ap.E2StubSubsFailParams{}
4949 fparams.Set(crereq)
4950 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
4951 e2termConn1.SendSubsFail(t, fparams, cremsg)
4952
4953 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
4954 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
4955
4956 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
4957 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
4958
4959 // Wait that subs is cleaned
4960 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
4961
4962 xappConn1.TestMsgChanEmpty(t)
4963 e2termConn1.TestMsgChanEmpty(t)
4964 mainCtrl.wait_registry_empty(t, 10)
4965}
4966
4967//-----------------------------------------------------------------------------
4968// TestRESTUnpackSubscriptionResponseUnknownInstanceId
4969//
4970// stub stub
4971// +-------+ +---------+ +---------+
4972// | xapp | | submgr | | e2term |
4973// +-------+ +---------+ +---------+
4974// | | |
4975// | RestSubReq | |
4976// |---------------->| |
4977// | | |
4978// | RESTSubResp | |
4979// |<----------------| |
4980// | | |
4981// | | SubReq |
4982// | |------------->|
4983// | | |
4984// | | SubResp | Unknown instanceId
4985// | |<-------------|
4986// | | |
4987// | | SubReq |
4988// | |------------->|
4989// | | |
4990// | | SubFail | Duplicated action
4991// | |<-------------|
4992// | RESTNotif (fail)| |
4993// |<----------------| |
4994// | | SubDelReq |
4995// | |------------->|
4996// | | |
4997// | | SubDelResp |
4998// | |<-------------|
4999//
5000//-----------------------------------------------------------------------------
5001func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
5002 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId")
5003 subReqCount := 1
5004 parameterSet := 1 // E2SM-gNB-X2
5005 actionDefinitionPresent := true
5006 actionParamCount := 1
5007
5008 // Req
5009 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
5010 restSubId := xappConn1.SendRESTSubsReq(t, params)
5011
5012 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5013
5014 // Unknown instanceId in this response which will result resending original request
5015 orgInstanceId := crereq.RequestId.InstanceId
5016 crereq.RequestId.InstanceId = 0
5017 e2termConn1.SendSubsResp(t, crereq, cremsg)
5018
5019 _, cremsg = e2termConn1.RecvSubsReq(t)
5020
5021 xappConn1.ExpectRESTNotification(t, restSubId)
5022
5023 // Subscription already created in E2 Node.
5024 fparams := &teststube2ap.E2StubSubsFailParams{}
5025 fparams.Set(crereq)
5026 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5027 e2termConn1.SendSubsFail(t, fparams, cremsg)
5028
5029 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5030 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5031
5032 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5033 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5034
5035 // Wait that subs is cleaned
5036 mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
5037
5038 xappConn1.TestMsgChanEmpty(t)
5039 e2termConn1.TestMsgChanEmpty(t)
5040 mainCtrl.wait_registry_empty(t, 10)
5041}
5042
5043//-----------------------------------------------------------------------------
5044// TestRESTUnpackSubscriptionResponseNoTransaction
5045//
5046// stub stub
5047// +-------+ +---------+ +---------+
5048// | xapp | | submgr | | e2term |
5049// +-------+ +---------+ +---------+
5050// | | |
5051// | RestSubReq | |
5052// |---------------->| |
5053// | | |
5054// | RESTSubResp | |
5055// |<----------------| |
5056// | | |
5057// | | SubReq |
5058// | |------------->|
5059// | | |
5060// | | SubResp | No transaction for the response
5061// | |<-------------|
5062// | | |
5063// | | SubReq |
5064// | |------------->|
5065// | | |
5066// | | SubFail | Duplicated action
5067// | |<-------------|
5068// | RESTNotif (fail)| |
5069// |<----------------| |
5070// | | SubDelReq |
5071// | |------------->|
5072// | | |
5073// | | SubDelResp |
5074// | |<-------------|
5075// | | |
5076// | | SubDelReq |
5077// | |------------->|
5078// | | |
5079// | | SubDelResp |
5080// | |<-------------|
5081//
5082//-----------------------------------------------------------------------------
5083func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
5084 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseNoTransaction")
5085 subReqCount := 1
5086 parameterSet := 1 // E2SM-gNB-X2
5087 actionDefinitionPresent := true
5088 actionParamCount := 1
5089
5090 // Req
5091 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
5092 restSubId := xappConn1.SendRESTSubsReq(t, params)
5093
5094 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5095
5096 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
5097 // No transaction exist for this response which will result resending original request
5098 e2termConn1.SendSubsResp(t, crereq, cremsg)
5099
5100 _, cremsg = e2termConn1.RecvSubsReq(t)
5101
5102 xappConn1.ExpectRESTNotification(t, restSubId)
5103
5104 // Subscription already created in E2 Node.
5105 fparams := &teststube2ap.E2StubSubsFailParams{}
5106 fparams.Set(crereq)
5107 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5108 e2termConn1.SendSubsFail(t, fparams, cremsg)
5109
5110 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5111 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5112
5113 // Resending happens because there no transaction
5114 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5115 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5116
5117 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5118 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5119
5120 // Wait that subs is cleaned
5121 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5122
5123 xappConn1.TestMsgChanEmpty(t)
5124 e2termConn1.TestMsgChanEmpty(t)
5125 mainCtrl.wait_registry_empty(t, 10)
5126
5127}
5128
5129//-----------------------------------------------------------------------------
5130// TestRESTUnpackSubscriptionFailureDecodeFail
5131//
5132// stub stub
5133// +-------+ +---------+ +---------+
5134// | xapp | | submgr | | e2term |
5135// +-------+ +---------+ +---------+
5136// | | |
5137// | RestSubReq | |
5138// |---------------->| |
5139// | | |
5140// | RESTSubResp | |
5141// |<----------------| |
5142// | | |
5143// | | SubReq |
5144// | |------------->|
5145// | | |
5146// | | SubFail | ASN.1 decode fails
5147// | |<-------------|
5148// | | |
5149// | | SubReq |
5150// | |------------->|
5151// | | |
5152// | | SubFail | Duplicated action
5153// | |<-------------|
5154// | RESTNotif (fail)| |
5155// |<----------------| |
5156// | | SubDelReq |
5157// | |------------->|
5158// | | |
5159// | | SubDelResp |
5160// | |<-------------|
5161//
5162//-----------------------------------------------------------------------------
5163func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
5164 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureDecodeFail")
5165 subReqCount := 1
5166 parameterSet := 1 // E2SM-gNB-X2
5167 actionDefinitionPresent := true
5168 actionParamCount := 1
5169
5170 // Req
5171 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
5172 restSubId := xappConn1.SendRESTSubsReq(t, params)
5173
5174 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5175
5176 // Decode of this response fails which will result resending original request
5177 e2termConn1.SendInvalidE2Asn1Resp(t, cremsg, xapp.RIC_SUB_FAILURE)
5178
5179 _, cremsg = e2termConn1.RecvSubsReq(t)
5180
5181 xappConn1.ExpectRESTNotification(t, restSubId)
5182
5183 // Subscription already created in E2 Node.
5184 fparams := &teststube2ap.E2StubSubsFailParams{}
5185 fparams.Set(crereq)
5186 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5187 e2termConn1.SendSubsFail(t, fparams, cremsg)
5188
5189 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5190 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5191
5192 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5193 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5194
5195 // Wait that subs is cleaned
5196 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5197
5198 xappConn1.TestMsgChanEmpty(t)
5199 e2termConn1.TestMsgChanEmpty(t)
5200 mainCtrl.wait_registry_empty(t, 10)
5201}
5202
5203//-----------------------------------------------------------------------------
5204// TestRESTUnpackSubscriptionResponseUnknownInstanceId
5205//
5206// stub stub
5207// +-------+ +---------+ +---------+
5208// | xapp | | submgr | | e2term |
5209// +-------+ +---------+ +---------+
5210// | | |
5211// | RestSubReq | |
5212// |---------------->| |
5213// | | |
5214// | RESTSubResp | |
5215// |<----------------| |
5216// | | |
5217// | | SubReq |
5218// | |------------->|
5219// | | |
5220// | | SubFail | Unknown instanceId
5221// | |<-------------|
5222// | | |
5223// | | SubReq |
5224// | |------------->|
5225// | | |
5226// | | SubFail | Duplicated action
5227// | |<-------------|
5228// | RESTNotif (fail)| |
5229// |<----------------| |
5230// | | SubDelReq |
5231// | |------------->|
5232// | | |
5233// | | SubDelResp |
5234// | |<-------------|
5235//
5236//-----------------------------------------------------------------------------
5237func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
5238 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureUnknownInstanceId")
5239 subReqCount := 1
5240 parameterSet := 1 // E2SM-gNB-X2
5241 actionDefinitionPresent := true
5242 actionParamCount := 1
5243
5244 // Req
5245 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
5246 restSubId := xappConn1.SendRESTSubsReq(t, params)
5247
5248 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5249
5250 // Unknown instanceId in this response which will result resending original request
5251 fparams := &teststube2ap.E2StubSubsFailParams{}
5252 fparams.Set(crereq)
5253 fparams.Fail.RequestId.InstanceId = 0
5254 e2termConn1.SendSubsFail(t, fparams, cremsg)
5255
5256 _, cremsg = e2termConn1.RecvSubsReq(t)
5257
5258 xappConn1.ExpectRESTNotification(t, restSubId)
5259
5260 // Subscription already created in E2 Node.
5261 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5262 e2termConn1.SendSubsFail(t, fparams, cremsg)
5263
5264 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5265 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5266
5267 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5268 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5269
5270 // Wait that subs is cleaned
5271 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5272
5273 xappConn1.TestMsgChanEmpty(t)
5274 e2termConn1.TestMsgChanEmpty(t)
5275 mainCtrl.wait_registry_empty(t, 10)
5276}
5277
5278//-----------------------------------------------------------------------------
5279// TestRESTUnpackSubscriptionFailureNoTransaction
5280//
5281// stub stub
5282// +-------+ +---------+ +---------+
5283// | xapp | | submgr | | e2term |
5284// +-------+ +---------+ +---------+
5285// | | |
5286// | RestSubReq | |
5287// |---------------->| |
5288// | | |
5289// | RESTSubResp | |
5290// |<----------------| |
5291// | | |
5292// | | SubReq |
5293// | |------------->|
5294// | | |
5295// | | SubFail | No transaction for the response
5296// | |<-------------|
5297// | | |
5298// | | SubReq |
5299// | |------------->|
5300// | | |
5301// | | SubFail | Duplicated action
5302// | |<-------------|
5303// | RESTNotif (fail)| |
5304// |<----------------| |
5305// | | SubDelReq |
5306// | |------------->|
5307// | | |
5308// | | SubDelResp |
5309// | |<-------------|
5310//
5311//-----------------------------------------------------------------------------
5312func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
5313 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionFailureNoTransaction")
5314 subReqCount := 1
5315 parameterSet := 1 // E2SM-gNB-X2
5316 actionDefinitionPresent := true
5317 actionParamCount := 1
5318
5319 // Req
5320 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
5321 restSubId := xappConn1.SendRESTSubsReq(t, params)
5322
5323 crereq, cremsg := e2termConn1.RecvSubsReq(t)
5324
5325 mainCtrl.MakeTransactionNil(t, crereq.RequestId.InstanceId)
5326
5327 // No transaction exist for this response which will result resending original request
5328 fparams := &teststube2ap.E2StubSubsFailParams{}
5329 fparams.Set(crereq)
5330 e2termConn1.SendSubsFail(t, fparams, cremsg)
5331
5332 _, cremsg = e2termConn1.RecvSubsReq(t)
5333
5334 xappConn1.ExpectRESTNotification(t, restSubId)
5335
5336 // Subscription already created in E2 Node.
5337 fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
5338 e2termConn1.SendSubsFail(t, fparams, cremsg)
5339
5340 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5341 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5342
5343 // Resending happens because there no transaction
5344 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5345 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5346
5347 instanceId := xappConn1.WaitRESTNotification(t, restSubId)
5348 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", instanceId)
5349
5350 // Wait that subs is cleaned
5351 mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
5352
5353 xappConn1.TestMsgChanEmpty(t)
5354 e2termConn1.TestMsgChanEmpty(t)
5355 mainCtrl.wait_registry_empty(t, 10)
5356}
5357
5358//-----------------------------------------------------------------------------
5359// TestRESTUnpackSubscriptionDeleteResponseDecodeFail
5360//
5361// stub stub
5362// +-------+ +---------+ +---------+
5363// | xapp | | submgr | | e2term |
5364// +-------+ +---------+ +---------+
5365// | | |
5366// | [SUBS CREATE] |
5367// | | |
5368// | | |
5369// | RESTSubDelReq | |
5370// |---------------->| |
5371// | | |
5372// | RESTSubDelResp | |
5373// |<----------------| |
5374// | | |
5375// | | SubDelReq |
5376// | |------------->|
5377// | | |
5378// | | SubDelResp | ASN.1 decode fails
5379// | |<-------------|
5380// | | |
5381// | | SubDelReq |
5382// | |------------->|
5383// | | |
5384// | | SubDelFail | Subscription does exist any more
5385// | |<-------------|
5386// | | |
5387//
5388//-----------------------------------------------------------------------------
5389func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
5390 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseDecodeFail")
5391
5392 // Req
5393 var params *teststube2ap.RESTSubsReqParams = nil
5394 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5395
5396 // Del
5397 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5398
5399 // E2t: Receive 1st SubsDelReq
5400 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5401
5402 // Decode of this response fails which will result resending original request
5403 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_REQ)
5404
5405 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
5406 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5407
5408 // Subscription does not exist in in E2 Node.
5409 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5410
5411 // Wait that subs is cleaned
5412 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5413
5414 xappConn1.TestMsgChanEmpty(t)
5415 e2termConn1.TestMsgChanEmpty(t)
5416 mainCtrl.wait_registry_empty(t, 10)
5417}
5418
5419//-----------------------------------------------------------------------------
5420// TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId
5421//
5422// stub stub
5423// +-------+ +---------+ +---------+
5424// | xapp | | submgr | | e2term |
5425// +-------+ +---------+ +---------+
5426// | | |
5427// | [SUBS CREATE] |
5428// | | |
5429// | | |
5430// | RESTSubDelReq | |
5431// |---------------->| |
5432// | | |
5433// | RESTSubDelResp | |
5434// |<----------------| |
5435// | | |
5436// | | SubDelReq |
5437// | |------------->|
5438// | | |
5439// | | SubDelResp | Unknown instanceId
5440// | |<-------------|
5441// | | |
5442// | | SubDelReq |
5443// | |------------->|
5444// | | |
5445// | | SubDelFail | Subscription does exist any more
5446// | |<-------------|
5447//
5448//-----------------------------------------------------------------------------
5449func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
5450 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId")
5451
5452 // Req
5453 var params *teststube2ap.RESTSubsReqParams = nil
5454 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5455
5456 // Del
5457 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5458
5459 // E2t: Receive 1st SubsDelReq
5460 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5461
5462 // Unknown instanceId in this response which will result resending original request
5463 delreq.RequestId.InstanceId = 0
5464 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5465
5466 // E2t: Receive 2nd SubsDelReq
5467 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5468
5469 // Subscription does not exist in in E2 Node.
5470 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5471
5472 // Wait that subs is cleaned
5473 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5474
5475 xappConn1.TestMsgChanEmpty(t)
5476 e2termConn1.TestMsgChanEmpty(t)
5477 mainCtrl.wait_registry_empty(t, 10)
5478}
5479
5480//-----------------------------------------------------------------------------
5481// TestRESTUnpackSubscriptionDeleteResponseNoTransaction
5482//
5483// stub stub
5484// +-------+ +---------+ +---------+
5485// | xapp | | submgr | | e2term |
5486// +-------+ +---------+ +---------+
5487// | | |
5488// | [SUBS CREATE] |
5489// | | |
5490// | | |
5491// | RESTSubDelReq | |
5492// |---------------->| |
5493// | | |
5494// | RESTSubDelResp | |
5495// |<----------------| |
5496// | | |
5497// | | SubDelReq |
5498// | |------------->|
5499// | | |
5500// | | SubDelResp | No transaction for the response
5501// | |<-------------|
5502// | | |
5503// | | SubDelReq |
5504// | |------------->|
5505// | | |
5506// | | SubDelFail | Subscription does exist any more
5507// | |<-------------|
5508//
5509//-----------------------------------------------------------------------------
5510func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
5511 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteResponseNoTransaction")
5512
5513 // Req
5514 var params *teststube2ap.RESTSubsReqParams = nil
5515 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5516
5517 // Del
5518 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5519
5520 // E2t: Receive 1st SubsDelReq
5521 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5522
5523 mainCtrl.MakeTransactionNil(t, e2SubsId)
5524
5525 // No transaction exist for this response which will result resending original request
5526 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5527
5528 // E2t: Receive 2nd SubsDelReq
5529 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5530
5531 // Subscription does not exist in in E2 Node.
5532 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5533
5534 // Wait that subs is cleaned
5535 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5536
5537 xappConn1.TestMsgChanEmpty(t)
5538 e2termConn1.TestMsgChanEmpty(t)
5539 mainCtrl.wait_registry_empty(t, 10)
5540}
5541
5542//-----------------------------------------------------------------------------
5543// TestRESTUnpackSubscriptionDeleteFailureDecodeFail
5544//
5545// stub stub
5546// +-------+ +---------+ +---------+
5547// | xapp | | submgr | | e2term |
5548// +-------+ +---------+ +---------+
5549// | | |
5550// | [SUBS CREATE] |
5551// | | |
5552// | | |
5553// | RESTSubDelReq | |
5554// |---------------->| |
5555// | | |
5556// | RESTSubDelResp | |
5557// |<----------------| |
5558// | | |
5559// | | SubDelReq |
5560// | |------------->|
5561// | | |
5562// | | SubDelFail | ASN.1 decode fails
5563// | |<-------------|
5564// | | |
5565// | | SubDelReq |
5566// | |------------->|
5567// | | |
5568// | | SubDelFail | Subscription does exist any more
5569// | |<-------------|
5570//
5571//-----------------------------------------------------------------------------
5572func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
5573 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteFailureDecodeFail")
5574
5575 // Req
5576 var params *teststube2ap.RESTSubsReqParams = nil
5577 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5578
5579 // Del
5580 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5581
5582 // E2t: Receive 1st SubsDelReq
5583 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5584
5585 // Decode of this response fails which will result resending original request
5586 e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_FAILURE)
5587
5588 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
5589 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5590
5591 // Subscription does not exist in in E2 Node.
5592 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5593
5594 // Wait that subs is cleaned
5595 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5596
5597 xappConn1.TestMsgChanEmpty(t)
5598 e2termConn1.TestMsgChanEmpty(t)
5599 mainCtrl.wait_registry_empty(t, 10)
5600}
5601
5602//-----------------------------------------------------------------------------
5603// TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId
5604//
5605// stub stub
5606// +-------+ +---------+ +---------+
5607// | xapp | | submgr | | e2term |
5608// +-------+ +---------+ +---------+
5609// | | |
5610// | [SUBS CREATE] |
5611// | | |
5612// | | |
5613// | RESTSubDelReq | |
5614// |---------------->| |
5615// | | |
5616// | RESTSubDelResp | |
5617// |<----------------| |
5618// | | |
5619// | | SubDelReq |
5620// | |------------->|
5621// | | |
5622// | | SubDelFail | Unknown instanceId
5623// | |<-------------|
5624// | | |
5625// | | SubDelReq |
5626// | |------------->|
5627// | | |
5628// | | SubDelFail | Subscription does exist any more
5629// | |<-------------|
5630//
5631//-----------------------------------------------------------------------------
5632func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
5633 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId")
5634
5635 // Req
5636 var params *teststube2ap.RESTSubsReqParams = nil
5637 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5638
5639 // Del
5640 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5641
5642 // E2t: Receive 1st SubsDelReq
5643 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5644
5645 // Unknown instanceId in this response which will result resending original request
5646 delreq.RequestId.InstanceId = 0
5647 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5648
5649 // E2t: Receive 2nd SubsDelReq
5650 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5651
5652 // Subscription does not exist in in E2 Node.
5653 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5654
5655 // Wait that subs is cleaned
5656 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5657
5658 xappConn1.TestMsgChanEmpty(t)
5659 e2termConn1.TestMsgChanEmpty(t)
5660 mainCtrl.wait_registry_empty(t, 10)
5661}
5662
5663//-----------------------------------------------------------------------------
5664// TestRESTUnpackSubscriptionDeleteFailureNoTransaction
5665//
5666// stub stub
5667// +-------+ +---------+ +---------+
5668// | xapp | | submgr | | e2term |
5669// +-------+ +---------+ +---------+
5670// | | |
5671// | [SUBS CREATE] |
5672// | | |
5673// | | |
5674// | RESTSubDelReq | |
5675// |---------------->| |
5676// | | |
5677// | RESTSubDelResp | |
5678// |<----------------| |
5679// | | |
5680// | | SubDelReq |
5681// | |------------->|
5682// | | |
5683// | | SubDelFail | No transaction for the response
5684// | |<-------------|
5685// | | |
5686// | | SubDelReq |
5687// | |------------->|
5688// | | |
5689// | | SubDelFail | Subscription does exist any more
5690// | |<-------------|
5691//
5692//-----------------------------------------------------------------------------
5693func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
5694 xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionDeleteFailureNoTransaction")
5695
5696 // Req
5697 var params *teststube2ap.RESTSubsReqParams = nil
5698 restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
5699
5700 // Del
5701 xappConn1.SendRESTSubsDelReq(t, &restSubId)
5702
5703 // E2t: Receive 1st SubsDelReq
5704 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5705
5706 mainCtrl.MakeTransactionNil(t, e2SubsId)
5707
5708 // No transaction exist for this response which will result resending original request
5709 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5710
5711 // E2t: Receive 2nd SubsDelReq
5712 delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
5713
5714 // Subscription does not exist in in E2 Node.
5715 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5716
5717 // Wait that subs is cleaned
5718 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
5719
5720 xappConn1.TestMsgChanEmpty(t)
5721 e2termConn1.TestMsgChanEmpty(t)
5722 mainCtrl.wait_registry_empty(t, 10)
5723}
5724
Konstantinos Archangelofb3277dc2021-05-25 14:21:51 +00005725//-----------------------------------------------------------------------------
5726// TestRESTSubReqFailAsn1PackSubReqError
5727//
5728// stub stub
5729// +-------+ +---------+ +---------+
5730// | xapp | | submgr | | e2term |
5731// +-------+ +---------+ +---------+
5732// | | |
5733// | RESTSubReq | |
5734// |---------------->| |
5735// | | |
5736// | RESTSubResp | |
5737// |<----------------| |
5738// | | |
5739// | ASN.1 encode fails |
5740// | | |
5741// | | SubDelReq |
5742// | |------------->|
5743// | | |
5744// | | SubDelFail |
5745// | |<-------------|
5746// | | |
5747// | RESTNotif | |
5748// | unsuccess | |
5749// |<----------------| |
5750// | | |
5751// | [SUBS DELETE] |
5752// | | |
5753//
5754//-----------------------------------------------------------------------------
5755func TestRESTSubReqFailAsn1PackSubReqError(t *testing.T) {
5756
5757 mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
5758 Counter{cSubReqFromXapp, 1},
5759 Counter{cSubDelReqToE2, 1},
5760 Counter{cSubDelFailFromE2, 1},
5761 Counter{cSubRespToXapp, 1},
5762 })
5763
5764 subReqCount := 1
5765 parameterSet := 1 // E2SM-gNB-X2
5766 actionDefinitionPresent := true
5767 actionParamCount := 1
5768
5769 var params *teststube2ap.RESTSubsReqParams = nil
5770 params = xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
5771 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, false)
5772
5773 // Req
5774 restSubId := xappConn1.SendRESTSubsReq(t, params)
5775 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
5776
5777 // E2t: Receive SubsDelReq
5778 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5779 xappConn1.ExpectRESTNotification(t, restSubId)
5780
5781 // Subscription does not exist in in E2 Node.
5782 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
5783
5784 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
5785 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
5786
5787 e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
5788 // Wait that subs is cleaned
5789 waitSubsCleanup(t, e2SubsId, 10)
5790 mainCtrl.VerifyCounterValues(t)
5791}
5792
archaggeafbf95f2021-04-14 08:54:05 +03005793////////////////////////////////////////////////////////////////////////////////////
5794// Services for UT cases
5795////////////////////////////////////////////////////////////////////////////////////
5796const subReqCount int = 1
5797const parameterSet = 1
5798const actionDefinitionPresent bool = true
5799const actionParamCount int = 1
5800const policyParamCount int = 1
5801const host string = "localhost"
5802
5803func createSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, params *teststube2ap.RESTSubsReqParams) (string, uint32) {
5804 if params == nil {
5805 params = fromXappConn.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
5806 }
5807 restSubId := fromXappConn.SendRESTSubsReq(t, params)
5808 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
5809
5810 crereq1, cremsg1 := toE2termConn.RecvSubsReq(t)
5811 fromXappConn.ExpectRESTNotification(t, restSubId)
5812 toE2termConn.SendSubsResp(t, crereq1, cremsg1)
5813 e2SubsId := fromXappConn.WaitRESTNotification(t, restSubId)
5814 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
5815
5816 return restSubId, e2SubsId
5817}
5818
5819func createXapp2MergedSubscription(t *testing.T, meid string) (string, uint32) {
5820
5821 params := xappConn2.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
5822 if meid != "" {
5823 params.SetMeid(meid)
5824 }
5825 xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
5826 restSubId := xappConn2.SendRESTSubsReq(t, params)
5827 xappConn2.ExpectRESTNotification(t, restSubId)
5828 xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId)
5829 e2SubsId := xappConn2.WaitRESTNotification(t, restSubId)
5830 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
5831
5832 return restSubId, e2SubsId
5833}
5834
5835func createXapp1PolicySubscription(t *testing.T) (string, uint32) {
5836 params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount, actionDefinitionPresent, policyParamCount)
5837 restSubId := xappConn1.SendRESTSubsReq(t, params)
5838 xapp.Logger.Info("Send REST Policy subscriber request for subscriberId : %v", restSubId)
5839
5840 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5841 xappConn1.ExpectRESTNotification(t, restSubId)
5842 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
5843 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
5844 xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId)
5845
5846 return restSubId, e2SubsId
5847}
5848
5849func createXapp1ReportSubscriptionE2Fail(t *testing.T) (string, uint32) {
5850 params := xappConn1.GetRESTSubsReqReportParams(subReqCount, parameterSet, actionDefinitionPresent, actionParamCount)
5851 restSubId := xappConn1.SendRESTSubsReq(t, params)
5852
5853 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
5854 fparams1 := &teststube2ap.E2StubSubsFailParams{}
5855 fparams1.Set(crereq1)
5856 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
5857
5858 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
5859 xappConn1.ExpectRESTNotification(t, restSubId)
5860 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
5861 e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
5862 xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
5863
5864 return restSubId, e2SubsId
5865}
5866
5867func deleteSubscription(t *testing.T, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId *string) {
5868 fromXappConn.SendRESTSubsDelReq(t, restSubId)
5869 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
5870 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
5871}
5872
5873func deleteXapp1Subscription(t *testing.T, restSubId *string) {
5874 xappConn1.SendRESTSubsDelReq(t, restSubId)
5875 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5876 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5877}
5878
5879func deleteXapp2Subscription(t *testing.T, restSubId *string) {
5880 xappConn2.SendRESTSubsDelReq(t, restSubId)
5881 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
5882 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
5883}
5884
5885func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
5886 resp, _ := xapp.Subscription.QuerySubscriptions()
5887 assert.Equal(t, resp[0].SubscriptionID, e2SubsId)
5888 assert.Equal(t, resp[0].Meid, meid)
5889 assert.Equal(t, resp[0].ClientEndpoint, endpoint)
5890}
5891
5892func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {
5893 //Wait that subs is cleaned
5894 mainCtrl.wait_subs_clean(t, e2SubsId, timeout)
5895
5896 xappConn1.TestMsgChanEmpty(t)
5897 xappConn2.TestMsgChanEmpty(t)
5898 e2termConn1.TestMsgChanEmpty(t)
5899 mainCtrl.wait_registry_empty(t, timeout)
5900}
5901
5902func sendAndReceiveMultipleE2SubReqs(t *testing.T, count int, fromXappConn *teststube2ap.E2Stub, toE2termConn *teststube2ap.E2Stub, restSubId string) []uint32 {
5903
5904 var e2SubsId []uint32
5905
5906 for i := 0; i < count; i++ {
5907 xapp.Logger.Info("TEST: %d ===================================== BEGIN CRE ============================================", i+1)
5908 crereq, cremsg := toE2termConn.RecvSubsReq(t)
5909 fromXappConn.ExpectRESTNotification(t, restSubId)
5910 toE2termConn.SendSubsResp(t, crereq, cremsg)
5911 instanceId := fromXappConn.WaitRESTNotification(t, restSubId)
5912 e2SubsId = append(e2SubsId, instanceId)
5913 xapp.Logger.Info("TEST: %v", e2SubsId)
5914 xapp.Logger.Info("TEST: %d ===================================== END CRE ============================================", i+1)
5915 <-time.After(100 * time.Millisecond)
5916 }
5917 return e2SubsId
5918}
5919
5920func sendAndReceiveMultipleE2DelReqs(t *testing.T, e2SubsIds []uint32, toE2termConn *teststube2ap.E2Stub) {
5921
5922 for i := 0; i < len(e2SubsIds); i++ {
5923 xapp.Logger.Info("TEST: %d ===================================== BEGIN DEL ============================================", i+1)
5924 delreq, delmsg := toE2termConn.RecvSubsDelReq(t)
5925 toE2termConn.SendSubsDelResp(t, delreq, delmsg)
5926 <-time.After(1 * time.Second)
5927 xapp.Logger.Info("TEST: %d ===================================== END DEL ============================================", i+1)
5928 <-time.After(100 * time.Millisecond)
5929 }
5930
5931 // Wait that subs is cleaned
5932 for i := 0; i < len(e2SubsIds); i++ {
5933 mainCtrl.wait_subs_clean(t, e2SubsIds[i], 10)
5934 }
5935
5936}