blob: 5b5112616cb7e68ddff010308060d0b23203f766 [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 Mannila9bcb0a42020-02-11 11:30:44 +020023 "gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020024 "gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststube2ap"
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +020025 "gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
26 "github.com/stretchr/testify/assert"
Juha Hyttinenfa015662020-01-24 10:05:18 +020027 "testing"
Juha Hyttinen1683f912020-04-17 10:39:57 +030028 "time"
Juha Hyttinenfa015662020-01-24 10:05:18 +020029)
30
31//-----------------------------------------------------------------------------
32// TestSubReqAndRouteNok
33//
34// stub stub
35// +-------+ +---------+ +---------+
36// | xapp | | submgr | | rtmgr |
37// +-------+ +---------+ +---------+
38// | | |
39// | SubReq | |
40// |------------->| |
41// | | |
42// | | RouteCreate |
43// | |------------->|
44// | | |
45// | | RouteCreate |
46// | | status:400 |
47// | |<-------------|
48// | | |
49// | [SUBS INT DELETE] |
50// | | |
51//
52//-----------------------------------------------------------------------------
53
54func TestSubReqAndRouteNok(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020055 CaseBegin("TestSubReqAndRouteNok")
Juha Hyttinenfa015662020-01-24 10:05:18 +020056
57 waiter := rtmgrHttp.AllocNextEvent(false)
Juha Hyttinen1683f912020-04-17 10:39:57 +030058 newSubsId := mainCtrl.get_registry_next_subid(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020059 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +020060 waiter.WaitResult(t)
61
62 //Wait that subs is cleaned
Juha Hyttinen83ada002020-01-30 10:36:33 +020063 mainCtrl.wait_subs_clean(t, newSubsId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +020064
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +020065 xappConn1.TestMsgChanEmpty(t)
66 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +020067 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +020068 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +020069}
70
71//-----------------------------------------------------------------------------
72// TestSubReqAndSubDelOk
73//
74// stub stub
75// +-------+ +---------+ +---------+
76// | xapp | | submgr | | e2term |
77// +-------+ +---------+ +---------+
78// | | |
79// | SubReq | |
80// |------------->| |
81// | | |
82// | | SubReq |
83// | |------------->|
84// | | |
85// | | SubResp |
86// | |<-------------|
87// | | |
88// | SubResp | |
89// |<-------------| |
90// | | |
91// | | |
92// | SubDelReq | |
93// |------------->| |
94// | | |
95// | | SubDelReq |
96// | |------------->|
97// | | |
98// | | SubDelResp |
99// | |<-------------|
100// | | |
101// | SubDelResp | |
102// |<-------------| |
103//
104//-----------------------------------------------------------------------------
105func TestSubReqAndSubDelOk(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200106 CaseBegin("TestSubReqAndSubDelOk")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200107
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200108 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200109
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200110 crereq, cremsg := e2termConn1.RecvSubsReq(t)
111 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200112 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200113
114 resp, _ := xapp.Subscription.QuerySubscriptions()
115 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
116 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
117 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560"})
118
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200119 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200120 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200121
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200122 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200123 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200124
125 //Wait that subs is cleaned
126 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
127
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200128 xappConn1.TestMsgChanEmpty(t)
129 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200130 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200131 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200132}
133
134//-----------------------------------------------------------------------------
135// TestSubReqRetransmission
136//
137// stub stub
138// +-------+ +---------+ +---------+
139// | xapp | | submgr | | e2term |
140// +-------+ +---------+ +---------+
141// | | |
142// | SubReq | |
143// |------------->| |
144// | | |
145// | | SubReq |
146// | |------------->|
147// | | |
148// | SubReq | |
149// | (retrans) | |
150// |------------->| |
151// | | |
152// | | SubResp |
153// | |<-------------|
154// | | |
155// | SubResp | |
156// |<-------------| |
157// | | |
158// | [SUBS DELETE] |
159// | | |
160//
161//-----------------------------------------------------------------------------
162func TestSubReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200163 CaseBegin("TestSubReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200164
165 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200166 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200167 crereq, cremsg := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200168
169 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200170 xappConn1.SendSubsReq(t, nil, cretrans) //Retransmitted SubReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200171 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
172
Juha Hyttinen1683f912020-04-17 10:39:57 +0300173 // hack as there is no real way to see has message be handled.
174 // Previuos counter check just tells that is has been received by submgr
175 // --> artificial delay
176 <-time.After(1 * time.Second)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200177 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200178 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200179
180 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200181 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200182 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
183 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200184 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200185
186 //Wait that subs is cleaned
187 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
188
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200189 xappConn1.TestMsgChanEmpty(t)
190 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200191 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200192 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200193}
194
195//-----------------------------------------------------------------------------
196// TestSubDelReqRetransmission
197//
198// stub stub
199// +-------+ +---------+ +---------+
200// | xapp | | submgr | | e2term |
201// +-------+ +---------+ +---------+
202// | | |
203// | [SUBS CREATE] |
204// | | |
205// | | |
206// | SubDelReq | |
207// |------------->| |
208// | | |
209// | | SubDelReq |
210// | |------------->|
211// | | |
212// | SubDelReq | |
213// | (same sub) | |
214// | (same xid) | |
215// |------------->| |
216// | | |
217// | | SubDelResp |
218// | |<-------------|
219// | | |
220// | SubDelResp | |
221// |<-------------| |
222//
223//-----------------------------------------------------------------------------
224func TestSubDelReqRetransmission(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200225 CaseBegin("TestSubDelReqRetransmission")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200226
227 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200228 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200229 crereq, cremsg := e2termConn1.RecvSubsReq(t)
230 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200231 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200232
233 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200234 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200235 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200236
237 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200238 xappConn1.SendSubsDelReq(t, deltrans, e2SubsId) //Retransmitted SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200239 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
240
Juha Hyttinen1683f912020-04-17 10:39:57 +0300241 // hack as there is no real way to see has message be handled.
242 // Previuos counter check just tells that is has been received by submgr
243 // --> artificial delay
244 <-time.After(1 * time.Second)
245
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200246 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200247 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200248
249 //Wait that subs is cleaned
250 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
251
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200252 xappConn1.TestMsgChanEmpty(t)
253 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200254 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200255 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200256}
257
258//-----------------------------------------------------------------------------
259// TestSubDelReqCollision
260//
261// stub stub
262// +-------+ +---------+ +---------+
263// | xapp | | submgr | | e2term |
264// +-------+ +---------+ +---------+
265// | | |
266// | [SUBS CREATE] |
267// | | |
268// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200269// | SubDelReq 1 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200270// |------------->| |
271// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200272// | | SubDelReq 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200273// | |------------->|
274// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200275// | SubDelReq 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200276// | (same sub) | |
277// | (diff xid) | |
278// |------------->| |
279// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200280// | | SubDelResp 1 |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200281// | |<-------------|
282// | | |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200283// | SubDelResp 1 | |
284// |<-------------| |
285// | | |
286// | SubDelResp 2 | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200287// |<-------------| |
288//
289//-----------------------------------------------------------------------------
Juha Hyttinen3944a222020-01-24 11:51:46 +0200290
Juha Hyttinenfa015662020-01-24 10:05:18 +0200291func TestSubDelReqCollision(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200292 CaseBegin("TestSubDelReqCollision")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200293
294 //Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200295 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200296 crereq, cremsg := e2termConn1.RecvSubsReq(t)
297 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200298 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200299
300 //Subs Delete
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200301 xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200302 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200303
Juha Hyttinen3944a222020-01-24 11:51:46 +0200304 // Subs Delete colliding
Juha Hyttinenfa015662020-01-24 10:05:18 +0200305 seqBef := mainCtrl.get_msgcounter(t)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200306 deltranscol2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
307 xappConn1.SendSubsDelReq(t, deltranscol2, e2SubsId) //Colliding SubDelReq
Juha Hyttinenfa015662020-01-24 10:05:18 +0200308 mainCtrl.wait_msgcounter_change(t, seqBef, 10)
309
Juha Hyttinen1683f912020-04-17 10:39:57 +0300310 // hack as there is no real way to see has message be handled.
311 // Previuos counter check just tells that is has been received by submgr
312 // --> artificial delay
313 <-time.After(1 * time.Second)
314
Juha Hyttinen3944a222020-01-24 11:51:46 +0200315 // Del resp for first and second
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200316 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200317
318 // don't care in which order responses are received
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200319 xappConn1.RecvSubsDelResp(t, nil)
320 xappConn1.RecvSubsDelResp(t, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200321
322 //Wait that subs is cleaned
323 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
324
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200325 xappConn1.TestMsgChanEmpty(t)
326 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200327 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200328 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200329}
330
331//-----------------------------------------------------------------------------
332// TestSubReqAndSubDelOkTwoParallel
333//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200334// stub stub stub
335// +-------+ +-------+ +---------+ +---------+
336// | xapp | | xapp | | submgr | | e2term |
337// +-------+ +-------+ +---------+ +---------+
338// | | | |
339// | | | |
340// | | | |
341// | | SubReq1 | |
342// | |------------->| |
343// | | | |
344// | | | SubReq1 |
345// | | |------------->|
346// | | | |
347// | SubReq2 | |
348// |------------------------>| |
349// | | | |
350// | | | SubReq2 |
351// | | |------------->|
352// | | | |
353// | | | SubResp1 |
354// | | |<-------------|
355// | | SubResp1 | |
356// | |<-------------| |
357// | | | |
358// | | | SubResp2 |
359// | | |<-------------|
360// | SubResp2 | |
361// |<------------------------| |
362// | | | |
363// | | [SUBS 1 DELETE] |
364// | | | |
365// | | [SUBS 2 DELETE] |
366// | | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200367//
368//-----------------------------------------------------------------------------
369func TestSubReqAndSubDelOkTwoParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200370 CaseBegin("TestSubReqAndSubDelOkTwoParallel")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200371
372 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200373 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +0200374 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200375 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200376 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200377
378 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200379 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +0200380 rparams2.Init()
Juha Hyttinencdc35bf2020-07-11 13:32:57 +0300381
382 rparams2.Req.EventTriggerDefinition.Data.Length = 1
383 rparams2.Req.EventTriggerDefinition.Data.Data = make([]uint8, rparams2.Req.EventTriggerDefinition.Data.Length)
384 rparams2.Req.EventTriggerDefinition.Data.Data[0] = 2
385
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200386 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200387 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200388
389 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200390 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200391 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200392
393 //Resp2
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200394 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200395 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200396
397 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200398 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200399 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
400 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200401 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200402 //Wait that subs is cleaned
403 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
404
405 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200406 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200407 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
408 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200409 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200410 //Wait that subs is cleaned
411 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
412
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200413 xappConn1.TestMsgChanEmpty(t)
414 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200415 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200416 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200417}
418
419//-----------------------------------------------------------------------------
420// TestSameSubsDiffRan
421// Same subscription to different RANs
422//
423// stub stub
424// +-------+ +---------+ +---------+
425// | xapp | | submgr | | e2term |
426// +-------+ +---------+ +---------+
427// | | |
428// | | |
429// | | |
430// | SubReq(r1) | |
431// |------------->| |
432// | | |
433// | | SubReq(r1) |
434// | |------------->|
435// | | |
436// | | SubResp(r1) |
437// | |<-------------|
438// | | |
439// | SubResp(r1) | |
440// |<-------------| |
441// | | |
442// | SubReq(r2) | |
443// |------------->| |
444// | | |
445// | | SubReq(r2) |
446// | |------------->|
447// | | |
448// | | SubResp(r2) |
449// | |<-------------|
450// | | |
451// | SubResp(r2) | |
452// |<-------------| |
453// | | |
454// | [SUBS r1 DELETE] |
455// | | |
456// | [SUBS r2 DELETE] |
457// | | |
458//
459//-----------------------------------------------------------------------------
460func TestSameSubsDiffRan(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200461 CaseBegin("TestSameSubsDiffRan")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200462
463 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200464 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
465 xappConn1.SendSubsReq(t, nil, cretrans1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200466 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
467 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200468 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200469
470 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200471 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
472 xappConn1.SendSubsReq(t, nil, cretrans2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200473 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
474 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200475 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200476
477 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200478 deltrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
479 xappConn1.SendSubsDelReq(t, deltrans1, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200480 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
481 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200482 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200483 //Wait that subs is cleaned
484 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
485
486 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200487 deltrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_2")
488 xappConn1.SendSubsDelReq(t, deltrans2, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200489 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
490 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200491 xappConn1.RecvSubsDelResp(t, deltrans2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200492 //Wait that subs is cleaned
493 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
494
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200495 xappConn1.TestMsgChanEmpty(t)
496 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200497 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200498 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200499}
500
501//-----------------------------------------------------------------------------
502// TestSubReqRetryInSubmgr
503//
504// stub stub
505// +-------+ +---------+ +---------+
506// | xapp | | submgr | | e2term |
507// +-------+ +---------+ +---------+
508// | | |
509// | SubReq | |
510// |------------->| |
511// | | |
512// | | SubReq |
513// | |------------->|
514// | | |
515// | | |
516// | | SubReq |
517// | |------------->|
518// | | |
519// | | SubResp |
520// | |<-------------|
521// | | |
522// | SubResp | |
523// |<-------------| |
524// | | |
525// | [SUBS DELETE] |
526// | | |
527//
528//-----------------------------------------------------------------------------
529
530func TestSubReqRetryInSubmgr(t *testing.T) {
531
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200532 CaseBegin("TestSubReqRetryInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200533
534 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200535 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200536
537 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200538 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200539
540 // E2t: Receive 2nd SubsReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200541 crereq, cremsg := e2termConn1.RecvSubsReq(t)
542 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200543
544 // Xapp: Receive SubsResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200545 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200546
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200547 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200548 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
549 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200550 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200551
552 // Wait that subs is cleaned
553 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
554
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200555 xappConn1.TestMsgChanEmpty(t)
556 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200557 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200558 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200559}
560
561//-----------------------------------------------------------------------------
562// TestSubReqTwoRetriesNoRespSubDelRespInSubmgr
563//
564// stub stub
565// +-------+ +---------+ +---------+
566// | xapp | | submgr | | e2term |
567// +-------+ +---------+ +---------+
568// | | |
569// | SubReq | |
570// |------------->| |
571// | | |
572// | | SubReq |
573// | |------------->|
574// | | |
575// | | |
576// | | SubReq |
577// | |------------->|
578// | | |
579// | | SubDelReq |
580// | |------------->|
581// | | |
582// | | |
583// | | SubDelReq |
584// | |------------->|
585// | | |
586// | | |
587// | | SubDelResp |
588// | |<-------------|
589// | | |
590//
591//-----------------------------------------------------------------------------
592
593func TestSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
594
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200595 CaseBegin("TestSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200596
597 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200598 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200599
600 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200601 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200602
603 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200604 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200605
606 // E2t: Send receive SubsDelReq and send SubsResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200607 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
608 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200609
610 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +0300611 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200612
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200613 xappConn1.TestMsgChanEmpty(t)
614 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200615 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200616 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200617}
618
619//-----------------------------------------------------------------------------
620// TestSubReqTwoRetriesNoRespAtAllInSubmgr
621//
622// stub stub
623// +-------+ +---------+ +---------+
624// | xapp | | submgr | | e2term |
625// +-------+ +---------+ +---------+
626// | | |
627// | SubReq | |
628// |------------->| |
629// | | |
630// | | SubReq |
631// | |------------->|
632// | | |
633// | | |
634// | | SubReq |
635// | |------------->|
636// | | |
637// | | SubDelReq |
638// | |------------->|
639// | | |
640// | | |
641// | | SubDelReq |
642// | |------------->|
643// | | |
644// | | |
645//
646//-----------------------------------------------------------------------------
647
648func TestSubReqTwoRetriesNoRespAtAllInSubmgr(t *testing.T) {
649
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200650 CaseBegin("TestSubReqTwoRetriesNoRespAtAllInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200651
652 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200653 xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200654
655 // E2t: Receive 1st SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200656 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200657
658 // E2t: Receive 2nd SubsReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200659 e2termConn1.RecvSubsReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200660
661 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200662 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200663
664 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200665 delreq, _ := e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200666
667 // Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +0300668 mainCtrl.wait_subs_clean(t, delreq.RequestId.InstanceId, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200669
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200670 xappConn1.TestMsgChanEmpty(t)
671 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200672 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200673 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200674}
675
676//-----------------------------------------------------------------------------
677// TestSubReqSubFailRespInSubmgr
678//
679// stub stub
680// +-------+ +---------+ +---------+
681// | xapp | | submgr | | e2term |
682// +-------+ +---------+ +---------+
683// | | |
684// | SubReq | |
685// |------------->| |
686// | | |
687// | | SubReq |
688// | |------------->|
689// | | |
690// | | SubFail |
691// | |<-------------|
692// | | |
Juha Hyttinenf28853b2020-03-09 14:02:50 +0200693// | | SubDelReq |
694// | |------------->|
695// | | |
696// | | SubDelResp |
697// | |<-------------|
698// | | |
Juha Hyttinenfa015662020-01-24 10:05:18 +0200699// | SubFail | |
700// |<-------------| |
701// | | |
702//
703//-----------------------------------------------------------------------------
704
705func TestSubReqSubFailRespInSubmgr(t *testing.T) {
706
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200707 CaseBegin("TestSubReqSubFailRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200708
709 // Xapp: Send SubsReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200710 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200711
Juha Hyttinenf28853b2020-03-09 14:02:50 +0200712 // E2t: Receive SubsReq and send SubsFail (first)
713 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
714 fparams1 := &teststube2ap.E2StubSubsFailParams{}
715 fparams1.Set(crereq1)
716 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
717
718 // E2t: Receive SubsDelReq and send SubsDelResp (internal first)
719 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
720 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
721
722 // Xapp: Receive SubsFail
723 e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
724
725 // Wait that subs is cleaned
726 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
727
728 xappConn1.TestMsgChanEmpty(t)
729 xappConn2.TestMsgChanEmpty(t)
730 e2termConn1.TestMsgChanEmpty(t)
731 mainCtrl.wait_registry_empty(t, 10)
732}
733
734//-----------------------------------------------------------------------------
Juha Hyttinenfa015662020-01-24 10:05:18 +0200735// TestSubDelReqRetryInSubmgr
736//
737// stub stub
738// +-------+ +---------+ +---------+
739// | xapp | | submgr | | e2term |
740// +-------+ +---------+ +---------+
741// | | |
742// | [SUBS CREATE] |
743// | | |
744// | | |
745// | SubDelReq | |
746// |------------->| |
747// | | |
748// | | SubDelReq |
749// | |------------->|
750// | | |
751// | | SubDelReq |
752// | |------------->|
753// | | |
754// | | SubDelResp |
755// | |<-------------|
756// | | |
757// | SubDelResp | |
758// |<-------------| |
759//
760//-----------------------------------------------------------------------------
761
762func TestSubDelReqRetryInSubmgr(t *testing.T) {
763
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200764 CaseBegin("TestSubDelReqRetryInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200765
766 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200767 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200768 crereq, cremsg := e2termConn1.RecvSubsReq(t)
769 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200770 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200771
772 // Subs Delete
773 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200774 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200775
776 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200777 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200778
779 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200780 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
781 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200782
783 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200784 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200785
786 // Wait that subs is cleaned
787 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
788
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200789 xappConn1.TestMsgChanEmpty(t)
790 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200791 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200792 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200793}
794
795//-----------------------------------------------------------------------------
796// TestSubDelReqTwoRetriesNoRespInSubmgr
797//
798// stub stub
799// +-------+ +---------+ +---------+
800// | xapp | | submgr | | e2term |
801// +-------+ +---------+ +---------+
802// | | |
803// | [SUBS CREATE] |
804// | | |
805// | | |
806// | SubDelReq | |
807// |------------->| |
808// | | |
809// | | SubDelReq |
810// | |------------->|
811// | | |
812// | | SubDelReq |
813// | |------------->|
814// | | |
815// | | |
816// | SubDelResp | |
817// |<-------------| |
818//
819//-----------------------------------------------------------------------------
820
821func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
822
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200823 CaseBegin("TestSubDelReTwoRetriesNoRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200824
825 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200826 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200827 crereq, cremsg := e2termConn1.RecvSubsReq(t)
828 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200829 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200830
831 // Subs Delete
832 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200833 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200834
835 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200836 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200837
838 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200839 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200840
841 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200842 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200843
844 // Wait that subs is cleaned
845 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
846
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200847 xappConn1.TestMsgChanEmpty(t)
848 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200849 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200850 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200851}
852
853//-----------------------------------------------------------------------------
854// TestSubDelReqSubDelFailRespInSubmgr
855//
856// stub stub
857// +-------+ +---------+ +---------+
858// | xapp | | submgr | | e2term |
859// +-------+ +---------+ +---------+
860// | | |
861// | [SUBS CREATE] |
862// | | |
863// | | |
864// | SubDelReq | |
865// |------------->| |
866// | | |
867// | | SubDelReq |
868// | |------------->|
869// | | |
870// | | SubDelFail |
871// | |<-------------|
872// | | |
873// | SubDelResp | |
874// |<-------------| |
875// | | |
876//
877//-----------------------------------------------------------------------------
878
879func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
880
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200881 CaseBegin("TestSubReqSubDelFailRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200882
883 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200884 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200885 crereq, cremsg := e2termConn1.RecvSubsReq(t)
886 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200887 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200888
889 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200890 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200891
892 // E2t: Send receive SubsDelReq and send SubsDelFail
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200893 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
894 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200895
896 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200897 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200898
899 // Wait that subs is cleaned
900 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
901
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200902 xappConn1.TestMsgChanEmpty(t)
903 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200904 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200905 mainCtrl.wait_registry_empty(t, 10)
906}
907
908//-----------------------------------------------------------------------------
909// TestSubReqAndSubDelOkSameAction
910//
911// stub stub
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200912// +-------+ +-------+ +---------+ +---------+
913// | xapp2 | | xapp1 | | submgr | | e2term |
914// +-------+ +-------+ +---------+ +---------+
915// | | | |
916// | | | |
917// | | | |
918// | | SubReq1 | |
919// | |------------->| |
920// | | | |
921// | | | SubReq1 |
922// | | |------------->|
923// | | | SubResp1 |
924// | | |<-------------|
925// | | SubResp1 | |
926// | |<-------------| |
927// | | | |
928// | SubReq2 | |
929// |--------------------------->| |
930// | | | |
931// | SubResp2 | |
932// |<---------------------------| |
933// | | | |
934// | | SubDelReq 1 | |
935// | |------------->| |
936// | | | |
937// | | SubDelResp 1 | |
938// | |<-------------| |
939// | | | |
940// | SubDelReq 2 | |
941// |--------------------------->| |
942// | | | |
943// | | | SubDelReq 2 |
944// | | |------------->|
945// | | | |
946// | | | SubDelReq 2 |
947// | | |------------->|
948// | | | |
949// | SubDelResp 2 | |
950// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +0200951//
952//-----------------------------------------------------------------------------
953func TestSubReqAndSubDelOkSameAction(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200954 CaseBegin("TestSubReqAndSubDelOkSameAction")
Juha Hyttinen3944a222020-01-24 11:51:46 +0200955
956 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200957 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +0200958 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200959 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200960 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
961 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200962 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200963
964 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200965 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +0200966 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200967 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200968 //crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
969 //e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200970 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200971
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +0200972 resp, _ := xapp.Subscription.QuerySubscriptions()
973 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
974 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
975 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560", "localhost:13660"})
976
Juha Hyttinen3944a222020-01-24 11:51:46 +0200977 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200978 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200979 //e2termConn1.RecvSubsDelReq(t)
980 //e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200981 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200982 //Wait that subs is cleaned
983 //mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
984
985 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200986 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200987 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
988 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200989 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200990 //Wait that subs is cleaned
991 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
992
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200993 xappConn1.TestMsgChanEmpty(t)
994 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200995 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200996 mainCtrl.wait_registry_empty(t, 10)
997}
998
999//-----------------------------------------------------------------------------
1000// TestSubReqAndSubDelOkSameActionParallel
1001//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001002// stub stub stub
1003// +-------+ +-------+ +---------+ +---------+
1004// | xapp2 | | xapp1 | | submgr | | e2term |
1005// +-------+ +-------+ +---------+ +---------+
1006// | | | |
1007// | | | |
1008// | | | |
1009// | | SubReq1 | |
1010// | |------------->| |
1011// | | | |
1012// | | | SubReq1 |
1013// | | |------------->|
1014// | SubReq2 | |
1015// |--------------------------->| |
1016// | | | SubResp1 |
1017// | | |<-------------|
1018// | | SubResp1 | |
1019// | |<-------------| |
1020// | | | |
1021// | SubResp2 | |
1022// |<---------------------------| |
1023// | | | |
1024// | | SubDelReq 1 | |
1025// | |------------->| |
1026// | | | |
1027// | | SubDelResp 1 | |
1028// | |<-------------| |
1029// | | | |
1030// | SubDelReq 2 | |
1031// |--------------------------->| |
1032// | | | |
1033// | | | SubDelReq 2 |
1034// | | |------------->|
1035// | | | |
1036// | | | SubDelReq 2 |
1037// | | |------------->|
1038// | | | |
1039// | SubDelResp 2 | |
1040// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001041//
1042//-----------------------------------------------------------------------------
1043func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001044 CaseBegin("TestSubReqAndSubDelOkSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001045
1046 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001047 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001048 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001049 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001050 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001051
1052 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001053 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001054 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001055 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001056
1057 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001058 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001059 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001060
1061 //Resp2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001062 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001063
1064 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001065 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1066 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001067
1068 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001069 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001070 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1071 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001072 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001073
1074 //Wait that subs is cleaned
1075 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1076
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001077 xappConn1.TestMsgChanEmpty(t)
1078 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001079 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001080 mainCtrl.wait_registry_empty(t, 10)
1081}
1082
1083//-----------------------------------------------------------------------------
1084// TestSubReqAndSubDelNokSameActionParallel
1085//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001086// stub stub stub
1087// +-------+ +-------+ +---------+ +---------+
1088// | xapp2 | | xapp1 | | submgr | | e2term |
1089// +-------+ +-------+ +---------+ +---------+
1090// | | | |
1091// | | | |
1092// | | | |
1093// | | SubReq1 | |
1094// | |------------->| |
1095// | | | |
1096// | | | SubReq1 |
1097// | | |------------->|
1098// | SubReq2 | |
1099// |--------------------------->| |
1100// | | | SubFail1 |
1101// | | |<-------------|
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001102// | | | |
1103// | | | SubDelReq |
1104// | | |------------->|
1105// | | | SubDelResp |
1106// | | |<-------------|
1107// | | | |
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001108// | | SubFail1 | |
1109// | |<-------------| |
1110// | | | |
1111// | SubFail2 | |
1112// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001113//
1114//-----------------------------------------------------------------------------
1115func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001116 CaseBegin("TestSubReqAndSubDelNokSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001117
1118 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001119 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001120 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001121 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001122
1123 // E2t: Receive SubsReq (first)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001124 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001125
1126 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001127 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001128 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001129 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001130 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001131 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001132
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001133 // E2t: send SubsFail (first)
1134 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1135 fparams1.Set(crereq1)
1136 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1137
1138 // E2t: internal delete
1139 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1140 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001141
1142 //Fail1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001143 e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001144 //Fail2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001145 xappConn2.RecvSubsFail(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001146
1147 //Wait that subs is cleaned
1148 mainCtrl.wait_subs_clean(t, e2SubsId1, 15)
1149
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001150 xappConn1.TestMsgChanEmpty(t)
1151 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001152 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001153 mainCtrl.wait_registry_empty(t, 10)
1154}
1155
1156//-----------------------------------------------------------------------------
1157// TestSubReqAndSubDelNoAnswerSameActionParallel
1158//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001159// stub stub stub
1160// +-------+ +-------+ +---------+ +---------+
1161// | xapp2 | | xapp1 | | submgr | | e2term |
1162// +-------+ +-------+ +---------+ +---------+
1163// | | | |
1164// | | | |
1165// | | | |
1166// | | SubReq1 | |
1167// | |------------->| |
1168// | | | |
1169// | | | SubReq1 |
1170// | | |------------->|
1171// | | SubReq2 | |
1172// |--------------------------->| |
1173// | | | |
1174// | | | SubReq1 |
1175// | | |------------->|
1176// | | | |
1177// | | | |
1178// | | | SubDelReq |
1179// | | |------------->|
1180// | | | |
1181// | | | SubDelResp |
1182// | | |<-------------|
Juha Hyttinen3944a222020-01-24 11:51:46 +02001183//
1184//-----------------------------------------------------------------------------
1185func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001186 CaseBegin("TestSubReqAndSubDelNoAnswerSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001187
1188 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001189 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001190 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001191 xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001192
Juha Hyttinen1683f912020-04-17 10:39:57 +03001193 crereq1, _ := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001194
1195 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001196 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001197 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001198 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001199 xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001200 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001201
1202 //Req1 (retransmitted)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001203 e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001204
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001205 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1206 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001207
1208 //Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001209 mainCtrl.wait_subs_clean(t, delreq1.RequestId.InstanceId, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001210
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001211 xappConn1.TestMsgChanEmpty(t)
1212 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001213 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001214 mainCtrl.wait_registry_empty(t, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001215}
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001216
1217//----------------------------- Policy cases ---------------------------------
1218//-----------------------------------------------------------------------------
1219// TestSubReqPolicyAndSubDelOk
1220//
1221// stub stub
1222// +-------+ +---------+ +---------+
1223// | xapp | | submgr | | e2term |
1224// +-------+ +---------+ +---------+
1225// | | |
1226// | SubReq | |
1227// |------------->| |
1228// | | |
1229// | | SubReq |
1230// | |------------->|
1231// | | |
1232// | | SubResp |
1233// | |<-------------|
1234// | | |
1235// | SubResp | |
1236// |<-------------| |
1237// | | |
1238// | | |
1239// | SubDelReq | |
1240// |------------->| |
1241// | | |
1242// | | SubDelReq |
1243// | |------------->|
1244// | | |
1245// | | SubDelResp |
1246// | |<-------------|
1247// | | |
1248// | SubDelResp | |
1249// |<-------------| |
1250//
1251//-----------------------------------------------------------------------------
1252func TestSubReqPolicyAndSubDelOk(t *testing.T) {
1253 CaseBegin("TestSubReqAndSubDelOk")
1254
1255 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1256 rparams1.Init()
1257 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
1258 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
1259
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001260 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1261 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001262 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1263 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001264 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001265
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001266 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001267 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001268
1269 //Wait that subs is cleaned
1270 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1271
1272 xappConn1.TestMsgChanEmpty(t)
1273 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001274 e2termConn1.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001275 mainCtrl.wait_registry_empty(t, 10)
1276}
1277
1278//-----------------------------------------------------------------------------
1279// TestSubReqPolicyChangeAndSubDelOk
1280//
1281// stub stub
1282// +-------+ +---------+ +---------+
1283// | xapp | | submgr | | e2term |
1284// +-------+ +---------+ +---------+
1285// | | |
1286// | SubReq | |
1287// |------------->| |
1288// | | |
1289// | | SubReq |
1290// | |------------->|
1291// | | |
1292// | | SubResp |
1293// | |<-------------|
1294// | | |
1295// | SubResp | |
1296// |<-------------| |
1297// | | |
1298// | SubReq | |
1299// |------------->| |
1300// | | |
1301// | | SubReq |
1302// | |------------->|
1303// | | |
1304// | | SubResp |
1305// | |<-------------|
1306// | | |
1307// | SubResp | |
1308// |<-------------| |
1309// | | |
1310// | SubDelReq | |
1311// |------------->| |
1312// | | |
1313// | | SubDelReq |
1314// | |------------->|
1315// | | |
1316// | | SubDelResp |
1317// | |<-------------|
1318// | | |
1319// | SubDelResp | |
1320// |<-------------| |
1321//
1322//-----------------------------------------------------------------------------
1323
1324func TestSubReqPolicyChangeAndSubDelOk(t *testing.T) {
1325 CaseBegin("TestSubReqAndSubDelOk")
1326
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001327 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1328 rparams1.Init()
1329 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
1330 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001331
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001332 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1333 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001334 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1335
1336 //Policy change
Juha Hyttinenaada6452020-04-07 08:47:58 +03001337 rparams1.Req.RequestId.InstanceId = e2SubsId
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001338 rparams1.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW200ms
1339 xappConn1.SendSubsReq(t, rparams1, cretrans)
1340
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001341 crereq, cremsg = e2termConn1.RecvSubsReq(t)
1342 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001343 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
1344 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001345 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001346
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001347 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001348 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001349
1350 //Wait that subs is cleaned
1351 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1352
1353 xappConn1.TestMsgChanEmpty(t)
1354 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001355 e2termConn1.TestMsgChanEmpty(t)
1356 mainCtrl.wait_registry_empty(t, 10)
1357}
1358
1359//-----------------------------------------------------------------------------
1360// TestSubReqAndSubDelOkTwoE2termParallel
1361//
1362// stub stub stub
1363// +-------+ +---------+ +---------+ +---------+
1364// | xapp | | submgr | | e2term1 | | e2term2 |
1365// +-------+ +---------+ +---------+ +---------+
1366// | | | |
1367// | | | |
1368// | | | |
1369// | SubReq1 | | |
1370// |------------->| | |
1371// | | | |
1372// | | SubReq1 | |
1373// | |------------->| |
1374// | | | |
1375// | SubReq2 | | |
1376// |------------->| | |
1377// | | | |
1378// | | SubReq2 | |
1379// | |---------------------------->|
1380// | | | |
1381// | | SubResp1 | |
1382// | |<-------------| |
1383// | SubResp1 | | |
1384// |<-------------| | |
1385// | | SubResp2 | |
1386// | |<----------------------------|
1387// | SubResp2 | | |
1388// |<-------------| | |
1389// | | | |
1390// | [SUBS 1 DELETE] | |
1391// | | | |
1392// | [SUBS 2 DELETE] | |
1393// | | | |
1394//
1395//-----------------------------------------------------------------------------
1396func TestSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
1397 CaseBegin("TestSubReqAndSubDelOkTwoE2termParallel")
1398
1399 //Req1
1400 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1401 xappConn1.SendSubsReq(t, nil, cretrans1)
1402 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1403
1404 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_11")
1405 xappConn1.SendSubsReq(t, nil, cretrans2)
1406 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
1407
1408 //Resp1
1409 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
1410 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
1411
1412 //Resp2
1413 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
1414 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
1415
1416 //Del1
1417 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1418 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1419 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
1420 xappConn1.RecvSubsDelResp(t, deltrans1)
1421 //Wait that subs is cleaned
1422 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1423
1424 //Del2
1425 deltrans2 := xappConn1.SendSubsDelReq(t, nil, e2SubsId2)
1426 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
1427 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
1428 xappConn1.RecvSubsDelResp(t, deltrans2)
1429 //Wait that subs is cleaned
1430 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1431
1432 xappConn1.TestMsgChanEmpty(t)
1433 xappConn2.TestMsgChanEmpty(t)
1434 e2termConn1.TestMsgChanEmpty(t)
1435 e2termConn2.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001436 mainCtrl.wait_registry_empty(t, 10)
1437}
Anssi Mannilaf0d95262020-08-17 13:00:20 +03001438
1439//-----------------------------------------------------------------------------
1440// TestSubReqInsertAndSubDelOk
1441//
1442// stub stub
1443// +-------+ +---------+ +---------+
1444// | xapp | | submgr | | e2term |
1445// +-------+ +---------+ +---------+
1446// | | |
1447// | SubReq | |
1448// |------------->| |
1449// | | |
1450// | | SubReq |
1451// | |------------->|
1452// | | |
1453// | | SubResp |
1454// | |<-------------|
1455// | | |
1456// | SubResp | |
1457// |<-------------| |
1458// | | |
1459// | | |
1460// | SubDelReq | |
1461// |------------->| |
1462// | | |
1463// | | SubDelReq |
1464// | |------------->|
1465// | | |
1466// | | SubDelResp |
1467// | |<-------------|
1468// | | |
1469// | SubDelResp | |
1470// |<-------------| |
1471//
1472//-----------------------------------------------------------------------------
1473func TestSubReqInsertAndSubDelOk(t *testing.T) {
1474 CaseBegin("TestInsertSubReqAndSubDelOk")
1475
1476 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1477 rparams1.Init()
1478 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeInsert
1479 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
1480
1481 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1482 e2termConn1.SendSubsResp(t, crereq, cremsg)
1483 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1484 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
1485 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1486
1487 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1488 xappConn1.RecvSubsDelResp(t, deltrans)
1489
1490 //Wait that subs is cleaned
1491 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1492
1493 xappConn1.TestMsgChanEmpty(t)
1494 xappConn2.TestMsgChanEmpty(t)
1495 e2termConn1.TestMsgChanEmpty(t)
1496 mainCtrl.wait_registry_empty(t, 10)
1497}
Anssi Mannila2f26fb22020-12-07 08:32:13 +02001498
1499//-----------------------------------------------------------------------------
1500// TestSubReqRetransmissionWithSameSubIdDiffXid
1501//
1502// This case simulates case where xApp restarts and starts sending same
1503// subscription requests which have already subscribed successfully
1504
1505// stub stub
1506// +-------+ +---------+ +---------+
1507// | xapp | | submgr | | e2term |
1508// +-------+ +---------+ +---------+
1509// | | |
1510// | SubReq | |
1511// |------------->| |
1512// | | |
1513// | | SubReq |
1514// | |------------->|
1515// | | |
1516// | | SubResp |
1517// | |<-------------|
1518// | | |
1519// | SubResp | |
1520// |<-------------| |
1521// | | |
1522// | xApp restart | |
1523// | | |
1524// | SubReq | |
1525// | (retrans with same xApp generated subid but diff xid)
1526// |------------->| |
1527// | | |
1528// | SubResp | |
1529// |<-------------| |
1530// | | |
1531// | [SUBS DELETE] |
1532// | | |
1533//
1534//-----------------------------------------------------------------------------
1535func TestSubReqRetransmissionWithSameSubIdDiffXid(t *testing.T) {
1536 CaseBegin("TestSubReqRetransmissionWithSameSubIdDiffXid")
1537
1538 //Subs Create
1539 cretrans := xappConn1.SendSubsReq(t, nil, nil)
1540 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1541 e2termConn1.SendSubsResp(t, crereq, cremsg)
1542 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1543
1544 // xApp restart here
1545 // --> artificial delay
1546 <-time.After(1 * time.Second)
1547
1548 //Subs Create
1549 cretrans = xappConn1.SendSubsReq(t, nil, nil) //Retransmitted SubReq
1550 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
1551
1552 //Subs Delete
1553 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
1554 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1555 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1556 xappConn1.RecvSubsDelResp(t, deltrans)
1557
1558 //Wait that subs is cleaned
1559 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1560
1561 xappConn1.TestMsgChanEmpty(t)
1562 xappConn2.TestMsgChanEmpty(t)
1563 e2termConn1.TestMsgChanEmpty(t)
1564 mainCtrl.wait_registry_empty(t, 10)
1565}
Anssi Mannilac92b4212020-12-07 14:59:34 +02001566
1567//-----------------------------------------------------------------------------
1568// TestSubReqNokAndSubDelOkWithRestartInMiddle
1569//
1570// stub stub
1571// +-------+ +---------+ +---------+
1572// | xapp | | submgr | | e2term |
1573// +-------+ +---------+ +---------+
1574// | | |
1575// | SubReq | |
1576// |------------->| |
1577// | | |
1578// | | SubReq |
1579// | |------------->|
1580// | | |
1581// | | SubResp |
1582// | <----|
1583// | |
1584// | Submgr restart |
1585// | |
1586// | | |
1587// | | SubDelReq |
1588// | |------------->|
1589// | | |
1590// | | SubDelResp |
1591// | |<-------------|
1592// | | |
1593//
1594//-----------------------------------------------------------------------------
1595
1596func TestSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
1597 CaseBegin("TestSubReqNokAndSubDelOkWithRestartInMiddle")
1598
1599 // Remove possible existing subscrition
1600 mainCtrl.removeExistingSubscriptions(t)
1601
1602 mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
1603 xappConn1.SendSubsReq(t, nil, nil)
1604 e2termConn1.RecvSubsReq(t)
1605 mainCtrl.SetResetTestFlag(t, false)
1606
1607 resp, _ := xapp.Subscription.QuerySubscriptions()
1608 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
1609 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560"})
1610 e2SubsId := uint32(resp[0].SubscriptionID)
1611 t.Logf("e2SubsId = %v", e2SubsId)
1612
1613 mainCtrl.SimulateRestart(t) // This will trigger sending of SubDelReq
1614
1615 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1616 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1617
1618 // Wait that subs is cleaned
1619 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1620
1621 xappConn1.TestMsgChanEmpty(t)
1622 xappConn2.TestMsgChanEmpty(t)
1623 e2termConn1.TestMsgChanEmpty(t)
1624 mainCtrl.wait_registry_empty(t, 10)
1625}
1626
1627//-----------------------------------------------------------------------------
1628// TestSubReqAndSubDelOkWithRestartInMiddle
1629//
1630// stub stub
1631// +-------+ +---------+ +---------+
1632// | xapp | | submgr | | e2term |
1633// +-------+ +---------+ +---------+
1634// | | |
1635// | SubReq | |
1636// |------------->| |
1637// | | |
1638// | | SubReq |
1639// | |------------->|
1640// | | |
1641// | | SubResp |
1642// | |<-------------|
1643// | | |
1644// | SubResp | |
1645// |<-------------| |
1646// | | |
1647// | |
1648// | Submgr restart |
1649// | |
1650// | SubDelReq | |
1651// |------------->| |
1652// | | |
1653// | | SubDelReq |
1654// | |------------->|
1655// | | |
1656// | | SubDelResp |
1657// | |<-------------|
1658// | | |
1659// | SubDelResp | |
1660// |<-------------| |
1661//
1662//-----------------------------------------------------------------------------
1663
1664func TestSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
1665 CaseBegin("TestSubReqAndSubDelOkWithRestartInMiddle")
1666
1667 cretrans := xappConn1.SendSubsReq(t, nil, nil)
1668 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1669 e2termConn1.SendSubsResp(t, crereq, cremsg)
1670 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1671
1672 // Check subscription
1673 resp, _ := xapp.Subscription.QuerySubscriptions()
1674 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
1675 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
1676 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560"})
1677
1678 mainCtrl.SimulateRestart(t)
1679
1680 // Check that subscription is restored correctly after restart
1681 resp, _ = xapp.Subscription.QuerySubscriptions()
1682 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
1683 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
1684 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560"})
1685
1686 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
1687 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1688 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1689 xappConn1.RecvSubsDelResp(t, deltrans)
1690
1691 //Wait that subs is cleaned
1692 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1693
1694 xappConn1.TestMsgChanEmpty(t)
1695 xappConn2.TestMsgChanEmpty(t)
1696 e2termConn1.TestMsgChanEmpty(t)
1697 mainCtrl.wait_registry_empty(t, 10)
1698}
1699
1700//-----------------------------------------------------------------------------
1701// TestSubReqAndSubDelOkSameActionWithRestartsInMiddle
1702//
1703// stub stub
1704// +-------+ +-------+ +---------+ +---------+
1705// | xapp2 | | xapp1 | | submgr | | e2term |
1706// +-------+ +-------+ +---------+ +---------+
1707// | | | |
1708// | | | |
1709// | | | |
1710// | | SubReq1 | |
1711// | |------------->| |
1712// | | | |
1713// | | | SubReq1 |
1714// | | |------------->|
1715// | | | SubResp1 |
1716// | | |<-------------|
1717// | | SubResp1 | |
1718// | |<-------------| |
1719// | | | |
1720// | |
1721// | submgr restart |
1722// | |
1723// | | | |
1724// | | | |
1725// | SubReq2 | |
1726// |--------------------------->| |
1727// | | | |
1728// | SubResp2 | |
1729// |<---------------------------| |
1730// | | | |
1731// | | SubDelReq 1 | |
1732// | |------------->| |
1733// | | | |
1734// | | SubDelResp 1 | |
1735// | |<-------------| |
1736// | | | |
1737// | | | |
1738// | |
1739// | submgr restart |
1740// | |
1741// | | | |
1742// | SubDelReq 2 | |
1743// |--------------------------->| |
1744// | | | |
1745// | | | SubDelReq 2 |
1746// | | |------------->|
1747// | | | |
1748// | | | SubDelReq 2 |
1749// | | |------------->|
1750// | | | |
1751// | SubDelResp 2 | |
1752// |<---------------------------| |
1753//
1754//-----------------------------------------------------------------------------
1755
1756func TestSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
1757 CaseBegin("TestSubReqAndSubDelOkSameActionWithRestartsInMiddle")
1758
1759 //Req1
1760 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1761 rparams1.Init()
1762 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
1763 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1764 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
1765 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
1766
1767 //Req2
1768 rparams2 := &teststube2ap.E2StubSubsReqParams{}
1769 rparams2.Init()
1770 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
1771 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
1772
1773 // Check subscription
1774 resp, _ := xapp.Subscription.QuerySubscriptions() ////////////////////////////////
1775 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
1776 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
1777 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560", "localhost:13660"})
1778
1779 mainCtrl.SimulateRestart(t)
1780
1781 // Check that subscription is restored correctly after restart
1782 resp, _ = xapp.Subscription.QuerySubscriptions()
1783 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
1784 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
1785 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560", "localhost:13660"})
1786
1787 //Del1
1788 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1789 xapp.Logger.Debug("xappConn1.RecvSubsDelResp")
1790 xappConn1.RecvSubsDelResp(t, deltrans1)
1791 xapp.Logger.Debug("xappConn1.RecvSubsDelResp received")
1792
1793 mainCtrl.SimulateRestart(t)
1794 xapp.Logger.Debug("mainCtrl.SimulateRestart done")
1795
1796 //Del2
1797 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
1798 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1799
1800 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
1801 xappConn2.RecvSubsDelResp(t, deltrans2)
1802
1803 //Wait that subs is cleaned
1804 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1805
1806 xappConn1.TestMsgChanEmpty(t)
1807 xappConn2.TestMsgChanEmpty(t)
1808 e2termConn1.TestMsgChanEmpty(t)
1809 mainCtrl.wait_registry_empty(t, 10)
1810}