blob: 6068d666731f13dce1d829bd8944521dd6c1b500 [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//-----------------------------------------------------------------------------
735// TestSubReqSubFailRespInSubmgrWithDuplicate
736//
737// stub stub
738// +-------+ +---------+ +---------+
739// | xapp | | submgr | | e2term |
740// +-------+ +---------+ +---------+
741// | | |
742// | SubReq | |
743// |------------->| |
744// | | |
745// | | SubReq |
746// | |------------->|
747// | | |
748// | | SubFail |
749// | |<-------------|
750// | | |
751// | | SubDelReq |
752// | |------------->|
753// | | |
754// | | SubDelResp |
755// | |<-------------|
756// | | |
757// | | SubReq |
758// | |------------->|
759// | | |
760// | | SubResp |
761// | |<-------------|
762// | | |
763// | SubResp | |
764// |<-------------| |
765// | | |
766// | [SUBS DELETE] |
767// | | |
768//
769//-----------------------------------------------------------------------------
770
771func TestSubReqSubFailRespInSubmgrWithDuplicate(t *testing.T) {
772
773 CaseBegin("TestSubReqSubFailRespInSubmgrWithDuplicate start")
774
775 // Xapp: Send SubsReq
776 cretrans := xappConn1.SendSubsReq(t, nil, nil)
777
778 // E2t: Receive SubsReq and send SubsFail (first)
779 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
780 fparams1 := &teststube2ap.E2StubSubsFailParams{}
781 fparams1.Set(crereq1)
782 fparams1.SetCauseVal(-1, 5, 3)
783 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
784
785 // E2t: Receive SubsDelReq and send SubsDelResp (internal)
786 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
787 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
788
789 // E2t: Receive SubsReq and send SubsResp (second)
790 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
791 e2termConn1.SendSubsResp(t, crereq2, cremsg2)
792
793 // XAPP: Receive SubsResp
794 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
795
796 // Delete
797 deltrans2 := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
798 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
799 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
800 xappConn1.RecvSubsDelResp(t, deltrans2)
801
802 // Wait that subs is cleaned
803 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
804
805 xappConn1.TestMsgChanEmpty(t)
806 xappConn2.TestMsgChanEmpty(t)
807 e2termConn1.TestMsgChanEmpty(t)
808 mainCtrl.wait_registry_empty(t, 10)
809}
810
811//-----------------------------------------------------------------------------
812// TestSubReqSubFailRespInSubmgrWithDuplicateFail
813//
814// stub stub
815// +-------+ +---------+ +---------+
816// | xapp | | submgr | | e2term |
817// +-------+ +---------+ +---------+
818// | | |
819// | SubReq | |
820// |------------->| |
821// | | |
822// | | SubReq |
823// | |------------->|
824// | | |
825// | | SubFail |
826// | |<-------------|
827// | | |
828// | | SubDelReq |
829// | |------------->|
830// | | |
831// | | SubDelResp |
832// | |<-------------|
833// | | |
834// | | SubReq |
835// | |------------->|
836// | | |
837// | | SubFail |
838// | |<-------------|
839// | | |
840// | | SubDelReq |
841// | |------------->|
842// | | |
843// | | SubDelResp |
844// | |<-------------|
845// | SubFail | |
846// |<-------------| |
847// | | |
848//
849//-----------------------------------------------------------------------------
850
851func TestSubReqSubFailRespInSubmgrWithDuplicateFail(t *testing.T) {
852
853 CaseBegin("TestSubReqSubFailRespInSubmgrWithDuplicateFail start")
854
855 // Xapp: Send SubsReq
856 cretrans := xappConn1.SendSubsReq(t, nil, nil)
857
858 // E2t: Receive SubsReq and send SubsFail (first)
859 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
860 fparams1 := &teststube2ap.E2StubSubsFailParams{}
861 fparams1.Set(crereq1)
862 fparams1.SetCauseVal(-1, 5, 3)
863 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
864
865 // E2t: Receive SubsDelReq and send SubsDelResp (internal first)
866 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
867 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
868
869 // E2t: Receive SubsReq and send SubsFail (second)
870 crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
871 fparams2 := &teststube2ap.E2StubSubsFailParams{}
872 fparams2.Set(crereq2)
873 fparams2.SetCauseVal(-1, 5, 3)
874 e2termConn1.SendSubsFail(t, fparams2, cremsg2)
875
876 // E2t: Receive SubsDelReq and send SubsDelResp (internal second)
877 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
878 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200879
880 // Xapp: Receive SubsFail
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200881 e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200882
883 // Wait that subs is cleaned
884 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
885
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200886 xappConn1.TestMsgChanEmpty(t)
887 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200888 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200889 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200890}
891
892//-----------------------------------------------------------------------------
893// TestSubDelReqRetryInSubmgr
894//
895// stub stub
896// +-------+ +---------+ +---------+
897// | xapp | | submgr | | e2term |
898// +-------+ +---------+ +---------+
899// | | |
900// | [SUBS CREATE] |
901// | | |
902// | | |
903// | SubDelReq | |
904// |------------->| |
905// | | |
906// | | SubDelReq |
907// | |------------->|
908// | | |
909// | | SubDelReq |
910// | |------------->|
911// | | |
912// | | SubDelResp |
913// | |<-------------|
914// | | |
915// | SubDelResp | |
916// |<-------------| |
917//
918//-----------------------------------------------------------------------------
919
920func TestSubDelReqRetryInSubmgr(t *testing.T) {
921
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200922 CaseBegin("TestSubDelReqRetryInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200923
924 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200925 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200926 crereq, cremsg := e2termConn1.RecvSubsReq(t)
927 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200928 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200929
930 // Subs Delete
931 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200932 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200933
934 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200935 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200936
937 // E2t: Receive 2nd SubsDelReq and send SubsDelResp
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200938 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
939 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200940
941 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200942 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200943
944 // Wait that subs is cleaned
945 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
946
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200947 xappConn1.TestMsgChanEmpty(t)
948 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200949 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +0200950 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200951}
952
953//-----------------------------------------------------------------------------
954// TestSubDelReqTwoRetriesNoRespInSubmgr
955//
956// stub stub
957// +-------+ +---------+ +---------+
958// | xapp | | submgr | | e2term |
959// +-------+ +---------+ +---------+
960// | | |
961// | [SUBS CREATE] |
962// | | |
963// | | |
964// | SubDelReq | |
965// |------------->| |
966// | | |
967// | | SubDelReq |
968// | |------------->|
969// | | |
970// | | SubDelReq |
971// | |------------->|
972// | | |
973// | | |
974// | SubDelResp | |
975// |<-------------| |
976//
977//-----------------------------------------------------------------------------
978
979func TestSubDelReqTwoRetriesNoRespInSubmgr(t *testing.T) {
980
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200981 CaseBegin("TestSubDelReTwoRetriesNoRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +0200982
983 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200984 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200985 crereq, cremsg := e2termConn1.RecvSubsReq(t)
986 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200987 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200988
989 // Subs Delete
990 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +0200991 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200992
993 // E2t: Receive 1st SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200994 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200995
996 // E2t: Receive 2nd SubsDelReq
Juha Hyttinen896c3ac2020-02-24 12:49:20 +0200997 e2termConn1.RecvSubsDelReq(t)
Juha Hyttinenfa015662020-01-24 10:05:18 +0200998
999 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001000 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001001
1002 // Wait that subs is cleaned
1003 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1004
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001005 xappConn1.TestMsgChanEmpty(t)
1006 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001007 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001008 mainCtrl.wait_registry_empty(t, 10)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001009}
1010
1011//-----------------------------------------------------------------------------
1012// TestSubDelReqSubDelFailRespInSubmgr
1013//
1014// stub stub
1015// +-------+ +---------+ +---------+
1016// | xapp | | submgr | | e2term |
1017// +-------+ +---------+ +---------+
1018// | | |
1019// | [SUBS CREATE] |
1020// | | |
1021// | | |
1022// | SubDelReq | |
1023// |------------->| |
1024// | | |
1025// | | SubDelReq |
1026// | |------------->|
1027// | | |
1028// | | SubDelFail |
1029// | |<-------------|
1030// | | |
1031// | SubDelResp | |
1032// |<-------------| |
1033// | | |
1034//
1035//-----------------------------------------------------------------------------
1036
1037func TestSubDelReqSubDelFailRespInSubmgr(t *testing.T) {
1038
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001039 CaseBegin("TestSubReqSubDelFailRespInSubmgr start")
Juha Hyttinenfa015662020-01-24 10:05:18 +02001040
1041 // Subs Create
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001042 cretrans := xappConn1.SendSubsReq(t, nil, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001043 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1044 e2termConn1.SendSubsResp(t, crereq, cremsg)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001045 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001046
1047 // Xapp: Send SubsDelReq
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001048 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001049
1050 // E2t: Send receive SubsDelReq and send SubsDelFail
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001051 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1052 e2termConn1.SendSubsDelFail(t, delreq, delmsg)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001053
1054 // Xapp: Receive SubsDelResp
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001055 xappConn1.RecvSubsDelResp(t, deltrans)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001056
1057 // Wait that subs is cleaned
1058 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1059
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001060 xappConn1.TestMsgChanEmpty(t)
1061 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001062 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001063 mainCtrl.wait_registry_empty(t, 10)
1064}
1065
1066//-----------------------------------------------------------------------------
1067// TestSubReqAndSubDelOkSameAction
1068//
1069// stub stub
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001070// +-------+ +-------+ +---------+ +---------+
1071// | xapp2 | | xapp1 | | submgr | | e2term |
1072// +-------+ +-------+ +---------+ +---------+
1073// | | | |
1074// | | | |
1075// | | | |
1076// | | SubReq1 | |
1077// | |------------->| |
1078// | | | |
1079// | | | SubReq1 |
1080// | | |------------->|
1081// | | | SubResp1 |
1082// | | |<-------------|
1083// | | SubResp1 | |
1084// | |<-------------| |
1085// | | | |
1086// | SubReq2 | |
1087// |--------------------------->| |
1088// | | | |
1089// | SubResp2 | |
1090// |<---------------------------| |
1091// | | | |
1092// | | SubDelReq 1 | |
1093// | |------------->| |
1094// | | | |
1095// | | SubDelResp 1 | |
1096// | |<-------------| |
1097// | | | |
1098// | SubDelReq 2 | |
1099// |--------------------------->| |
1100// | | | |
1101// | | | SubDelReq 2 |
1102// | | |------------->|
1103// | | | |
1104// | | | SubDelReq 2 |
1105// | | |------------->|
1106// | | | |
1107// | SubDelResp 2 | |
1108// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001109//
1110//-----------------------------------------------------------------------------
1111func TestSubReqAndSubDelOkSameAction(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001112 CaseBegin("TestSubReqAndSubDelOkSameAction")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001113
1114 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001115 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001116 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001117 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001118 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1119 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001120 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001121
1122 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001123 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001124 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001125 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001126 //crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
1127 //e2termConn1.SendSubsResp(t, crereq2, cremsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001128 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001129
Juha Hyttinenc9eb08a2020-02-28 08:53:33 +02001130 resp, _ := xapp.Subscription.QuerySubscriptions()
1131 assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
1132 assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
1133 assert.Equal(t, resp[0].Endpoint, []string{"localhost:13560", "localhost:13660"})
1134
Juha Hyttinen3944a222020-01-24 11:51:46 +02001135 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001136 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001137 //e2termConn1.RecvSubsDelReq(t)
1138 //e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001139 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001140 //Wait that subs is cleaned
1141 //mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1142
1143 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001144 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001145 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1146 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001147 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001148 //Wait that subs is cleaned
1149 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1150
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001151 xappConn1.TestMsgChanEmpty(t)
1152 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001153 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001154 mainCtrl.wait_registry_empty(t, 10)
1155}
1156
1157//-----------------------------------------------------------------------------
1158// TestSubReqAndSubDelOkSameActionParallel
1159//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001160// stub stub stub
1161// +-------+ +-------+ +---------+ +---------+
1162// | xapp2 | | xapp1 | | submgr | | e2term |
1163// +-------+ +-------+ +---------+ +---------+
1164// | | | |
1165// | | | |
1166// | | | |
1167// | | SubReq1 | |
1168// | |------------->| |
1169// | | | |
1170// | | | SubReq1 |
1171// | | |------------->|
1172// | SubReq2 | |
1173// |--------------------------->| |
1174// | | | SubResp1 |
1175// | | |<-------------|
1176// | | SubResp1 | |
1177// | |<-------------| |
1178// | | | |
1179// | SubResp2 | |
1180// |<---------------------------| |
1181// | | | |
1182// | | SubDelReq 1 | |
1183// | |------------->| |
1184// | | | |
1185// | | SubDelResp 1 | |
1186// | |<-------------| |
1187// | | | |
1188// | SubDelReq 2 | |
1189// |--------------------------->| |
1190// | | | |
1191// | | | SubDelReq 2 |
1192// | | |------------->|
1193// | | | |
1194// | | | SubDelReq 2 |
1195// | | |------------->|
1196// | | | |
1197// | SubDelResp 2 | |
1198// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001199//
1200//-----------------------------------------------------------------------------
1201func TestSubReqAndSubDelOkSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001202 CaseBegin("TestSubReqAndSubDelOkSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001203
1204 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001205 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001206 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001207 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001208 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001209
1210 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001211 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001212 rparams2.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001213 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001214
1215 //Resp1
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001216 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001217 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001218
1219 //Resp2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001220 e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001221
1222 //Del1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001223 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1224 xappConn1.RecvSubsDelResp(t, deltrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001225
1226 //Del2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001227 deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001228 delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
1229 e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001230 xappConn2.RecvSubsDelResp(t, deltrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001231
1232 //Wait that subs is cleaned
1233 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1234
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001235 xappConn1.TestMsgChanEmpty(t)
1236 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001237 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001238 mainCtrl.wait_registry_empty(t, 10)
1239}
1240
1241//-----------------------------------------------------------------------------
1242// TestSubReqAndSubDelNokSameActionParallel
1243//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001244// stub stub stub
1245// +-------+ +-------+ +---------+ +---------+
1246// | xapp2 | | xapp1 | | submgr | | e2term |
1247// +-------+ +-------+ +---------+ +---------+
1248// | | | |
1249// | | | |
1250// | | | |
1251// | | SubReq1 | |
1252// | |------------->| |
1253// | | | |
1254// | | | SubReq1 |
1255// | | |------------->|
1256// | SubReq2 | |
1257// |--------------------------->| |
1258// | | | SubFail1 |
1259// | | |<-------------|
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001260// | | | |
1261// | | | SubDelReq |
1262// | | |------------->|
1263// | | | SubDelResp |
1264// | | |<-------------|
1265// | | | |
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001266// | | SubFail1 | |
1267// | |<-------------| |
1268// | | | |
1269// | SubFail2 | |
1270// |<---------------------------| |
Juha Hyttinen3944a222020-01-24 11:51:46 +02001271//
1272//-----------------------------------------------------------------------------
1273func TestSubReqAndSubDelNokSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001274 CaseBegin("TestSubReqAndSubDelNokSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001275
1276 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001277 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001278 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001279 cretrans1 := xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001280
1281 // E2t: Receive SubsReq (first)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001282 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001283
1284 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001285 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001286 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001287 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001288 cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001289 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001290
Juha Hyttinenf28853b2020-03-09 14:02:50 +02001291 // E2t: send SubsFail (first)
1292 fparams1 := &teststube2ap.E2StubSubsFailParams{}
1293 fparams1.Set(crereq1)
1294 e2termConn1.SendSubsFail(t, fparams1, cremsg1)
1295
1296 // E2t: internal delete
1297 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1298 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001299
1300 //Fail1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001301 e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001302 //Fail2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001303 xappConn2.RecvSubsFail(t, cretrans2)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001304
1305 //Wait that subs is cleaned
1306 mainCtrl.wait_subs_clean(t, e2SubsId1, 15)
1307
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001308 xappConn1.TestMsgChanEmpty(t)
1309 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001310 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001311 mainCtrl.wait_registry_empty(t, 10)
1312}
1313
1314//-----------------------------------------------------------------------------
1315// TestSubReqAndSubDelNoAnswerSameActionParallel
1316//
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001317// stub stub stub
1318// +-------+ +-------+ +---------+ +---------+
1319// | xapp2 | | xapp1 | | submgr | | e2term |
1320// +-------+ +-------+ +---------+ +---------+
1321// | | | |
1322// | | | |
1323// | | | |
1324// | | SubReq1 | |
1325// | |------------->| |
1326// | | | |
1327// | | | SubReq1 |
1328// | | |------------->|
1329// | | SubReq2 | |
1330// |--------------------------->| |
1331// | | | |
1332// | | | SubReq1 |
1333// | | |------------->|
1334// | | | |
1335// | | | |
1336// | | | SubDelReq |
1337// | | |------------->|
1338// | | | |
1339// | | | SubDelResp |
1340// | | |<-------------|
Juha Hyttinen3944a222020-01-24 11:51:46 +02001341//
1342//-----------------------------------------------------------------------------
1343func TestSubReqAndSubDelNoAnswerSameActionParallel(t *testing.T) {
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001344 CaseBegin("TestSubReqAndSubDelNoAnswerSameActionParallel")
Juha Hyttinen3944a222020-01-24 11:51:46 +02001345
1346 //Req1
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001347 rparams1 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001348 rparams1.Init()
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001349 xappConn1.SendSubsReq(t, rparams1, nil)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001350
Juha Hyttinen1683f912020-04-17 10:39:57 +03001351 crereq1, _ := e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001352
1353 //Req2
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001354 rparams2 := &teststube2ap.E2StubSubsReqParams{}
Juha Hyttinen3944a222020-01-24 11:51:46 +02001355 rparams2.Init()
Juha Hyttinen1683f912020-04-17 10:39:57 +03001356 subepcnt2 := mainCtrl.get_subs_entrypoint_cnt(t, crereq1.RequestId.InstanceId)
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001357 xappConn2.SendSubsReq(t, rparams2, nil)
Juha Hyttinen1683f912020-04-17 10:39:57 +03001358 mainCtrl.wait_subs_entrypoint_cnt_change(t, crereq1.RequestId.InstanceId, subepcnt2, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001359
1360 //Req1 (retransmitted)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001361 e2termConn1.RecvSubsReq(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001362
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001363 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1364 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001365
1366 //Wait that subs is cleaned
Juha Hyttinenaada6452020-04-07 08:47:58 +03001367 mainCtrl.wait_subs_clean(t, delreq1.RequestId.InstanceId, 10)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001368
Juha Hyttinen5f8ffa02020-02-06 15:28:59 +02001369 xappConn1.TestMsgChanEmpty(t)
1370 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001371 e2termConn1.TestMsgChanEmpty(t)
Juha Hyttinen3944a222020-01-24 11:51:46 +02001372 mainCtrl.wait_registry_empty(t, 15)
Juha Hyttinenfa015662020-01-24 10:05:18 +02001373}
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001374
1375//----------------------------- Policy cases ---------------------------------
1376//-----------------------------------------------------------------------------
1377// TestSubReqPolicyAndSubDelOk
1378//
1379// stub stub
1380// +-------+ +---------+ +---------+
1381// | xapp | | submgr | | e2term |
1382// +-------+ +---------+ +---------+
1383// | | |
1384// | SubReq | |
1385// |------------->| |
1386// | | |
1387// | | SubReq |
1388// | |------------->|
1389// | | |
1390// | | SubResp |
1391// | |<-------------|
1392// | | |
1393// | SubResp | |
1394// |<-------------| |
1395// | | |
1396// | | |
1397// | SubDelReq | |
1398// |------------->| |
1399// | | |
1400// | | SubDelReq |
1401// | |------------->|
1402// | | |
1403// | | SubDelResp |
1404// | |<-------------|
1405// | | |
1406// | SubDelResp | |
1407// |<-------------| |
1408//
1409//-----------------------------------------------------------------------------
1410func TestSubReqPolicyAndSubDelOk(t *testing.T) {
1411 CaseBegin("TestSubReqAndSubDelOk")
1412
1413 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1414 rparams1.Init()
1415 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
1416 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
1417
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001418 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1419 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001420 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1421 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001422 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001423
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001424 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001425 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001426
1427 //Wait that subs is cleaned
1428 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1429
1430 xappConn1.TestMsgChanEmpty(t)
1431 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001432 e2termConn1.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001433 mainCtrl.wait_registry_empty(t, 10)
1434}
1435
1436//-----------------------------------------------------------------------------
1437// TestSubReqPolicyChangeAndSubDelOk
1438//
1439// stub stub
1440// +-------+ +---------+ +---------+
1441// | xapp | | submgr | | e2term |
1442// +-------+ +---------+ +---------+
1443// | | |
1444// | SubReq | |
1445// |------------->| |
1446// | | |
1447// | | SubReq |
1448// | |------------->|
1449// | | |
1450// | | SubResp |
1451// | |<-------------|
1452// | | |
1453// | SubResp | |
1454// |<-------------| |
1455// | | |
1456// | SubReq | |
1457// |------------->| |
1458// | | |
1459// | | SubReq |
1460// | |------------->|
1461// | | |
1462// | | SubResp |
1463// | |<-------------|
1464// | | |
1465// | SubResp | |
1466// |<-------------| |
1467// | | |
1468// | SubDelReq | |
1469// |------------->| |
1470// | | |
1471// | | SubDelReq |
1472// | |------------->|
1473// | | |
1474// | | SubDelResp |
1475// | |<-------------|
1476// | | |
1477// | SubDelResp | |
1478// |<-------------| |
1479//
1480//-----------------------------------------------------------------------------
1481
1482func TestSubReqPolicyChangeAndSubDelOk(t *testing.T) {
1483 CaseBegin("TestSubReqAndSubDelOk")
1484
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001485 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1486 rparams1.Init()
1487 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypePolicy
1488 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001489
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001490 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1491 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001492 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1493
1494 //Policy change
Juha Hyttinenaada6452020-04-07 08:47:58 +03001495 rparams1.Req.RequestId.InstanceId = e2SubsId
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001496 rparams1.Req.ActionSetups[0].SubsequentAction.TimetoWait = e2ap.E2AP_TimeToWaitW200ms
1497 xappConn1.SendSubsReq(t, rparams1, cretrans)
1498
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001499 crereq, cremsg = e2termConn1.RecvSubsReq(t)
1500 e2termConn1.SendSubsResp(t, crereq, cremsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001501 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
1502 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001503 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001504
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001505 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001506 xappConn1.RecvSubsDelResp(t, deltrans)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001507
1508 //Wait that subs is cleaned
1509 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1510
1511 xappConn1.TestMsgChanEmpty(t)
1512 xappConn2.TestMsgChanEmpty(t)
Juha Hyttinen896c3ac2020-02-24 12:49:20 +02001513 e2termConn1.TestMsgChanEmpty(t)
1514 mainCtrl.wait_registry_empty(t, 10)
1515}
1516
1517//-----------------------------------------------------------------------------
1518// TestSubReqAndSubDelOkTwoE2termParallel
1519//
1520// stub stub stub
1521// +-------+ +---------+ +---------+ +---------+
1522// | xapp | | submgr | | e2term1 | | e2term2 |
1523// +-------+ +---------+ +---------+ +---------+
1524// | | | |
1525// | | | |
1526// | | | |
1527// | SubReq1 | | |
1528// |------------->| | |
1529// | | | |
1530// | | SubReq1 | |
1531// | |------------->| |
1532// | | | |
1533// | SubReq2 | | |
1534// |------------->| | |
1535// | | | |
1536// | | SubReq2 | |
1537// | |---------------------------->|
1538// | | | |
1539// | | SubResp1 | |
1540// | |<-------------| |
1541// | SubResp1 | | |
1542// |<-------------| | |
1543// | | SubResp2 | |
1544// | |<----------------------------|
1545// | SubResp2 | | |
1546// |<-------------| | |
1547// | | | |
1548// | [SUBS 1 DELETE] | |
1549// | | | |
1550// | [SUBS 2 DELETE] | |
1551// | | | |
1552//
1553//-----------------------------------------------------------------------------
1554func TestSubReqAndSubDelOkTwoE2termParallel(t *testing.T) {
1555 CaseBegin("TestSubReqAndSubDelOkTwoE2termParallel")
1556
1557 //Req1
1558 cretrans1 := xappConn1.NewRmrTransactionId("", "RAN_NAME_1")
1559 xappConn1.SendSubsReq(t, nil, cretrans1)
1560 crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
1561
1562 cretrans2 := xappConn1.NewRmrTransactionId("", "RAN_NAME_11")
1563 xappConn1.SendSubsReq(t, nil, cretrans2)
1564 crereq2, cremsg2 := e2termConn2.RecvSubsReq(t)
1565
1566 //Resp1
1567 e2termConn1.SendSubsResp(t, crereq1, cremsg1)
1568 e2SubsId1 := xappConn1.RecvSubsResp(t, cretrans1)
1569
1570 //Resp2
1571 e2termConn2.SendSubsResp(t, crereq2, cremsg2)
1572 e2SubsId2 := xappConn1.RecvSubsResp(t, cretrans2)
1573
1574 //Del1
1575 deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
1576 delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
1577 e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
1578 xappConn1.RecvSubsDelResp(t, deltrans1)
1579 //Wait that subs is cleaned
1580 mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
1581
1582 //Del2
1583 deltrans2 := xappConn1.SendSubsDelReq(t, nil, e2SubsId2)
1584 delreq2, delmsg2 := e2termConn2.RecvSubsDelReq(t)
1585 e2termConn2.SendSubsDelResp(t, delreq2, delmsg2)
1586 xappConn1.RecvSubsDelResp(t, deltrans2)
1587 //Wait that subs is cleaned
1588 mainCtrl.wait_subs_clean(t, e2SubsId2, 10)
1589
1590 xappConn1.TestMsgChanEmpty(t)
1591 xappConn2.TestMsgChanEmpty(t)
1592 e2termConn1.TestMsgChanEmpty(t)
1593 e2termConn2.TestMsgChanEmpty(t)
Anssi Mannila9bcb0a42020-02-11 11:30:44 +02001594 mainCtrl.wait_registry_empty(t, 10)
1595}
Anssi Mannilaf0d95262020-08-17 13:00:20 +03001596
1597//-----------------------------------------------------------------------------
1598// TestSubReqInsertAndSubDelOk
1599//
1600// stub stub
1601// +-------+ +---------+ +---------+
1602// | xapp | | submgr | | e2term |
1603// +-------+ +---------+ +---------+
1604// | | |
1605// | SubReq | |
1606// |------------->| |
1607// | | |
1608// | | SubReq |
1609// | |------------->|
1610// | | |
1611// | | SubResp |
1612// | |<-------------|
1613// | | |
1614// | SubResp | |
1615// |<-------------| |
1616// | | |
1617// | | |
1618// | SubDelReq | |
1619// |------------->| |
1620// | | |
1621// | | SubDelReq |
1622// | |------------->|
1623// | | |
1624// | | SubDelResp |
1625// | |<-------------|
1626// | | |
1627// | SubDelResp | |
1628// |<-------------| |
1629//
1630//-----------------------------------------------------------------------------
1631func TestSubReqInsertAndSubDelOk(t *testing.T) {
1632 CaseBegin("TestInsertSubReqAndSubDelOk")
1633
1634 rparams1 := &teststube2ap.E2StubSubsReqParams{}
1635 rparams1.Init()
1636 rparams1.Req.ActionSetups[0].ActionType = e2ap.E2AP_ActionTypeInsert
1637 cretrans := xappConn1.SendSubsReq(t, rparams1, nil)
1638
1639 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1640 e2termConn1.SendSubsResp(t, crereq, cremsg)
1641 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1642 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
1643 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1644
1645 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1646 xappConn1.RecvSubsDelResp(t, deltrans)
1647
1648 //Wait that subs is cleaned
1649 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1650
1651 xappConn1.TestMsgChanEmpty(t)
1652 xappConn2.TestMsgChanEmpty(t)
1653 e2termConn1.TestMsgChanEmpty(t)
1654 mainCtrl.wait_registry_empty(t, 10)
1655}
Anssi Mannila2f26fb22020-12-07 08:32:13 +02001656
1657//-----------------------------------------------------------------------------
1658// TestSubReqRetransmissionWithSameSubIdDiffXid
1659//
1660// This case simulates case where xApp restarts and starts sending same
1661// subscription requests which have already subscribed successfully
1662
1663// stub stub
1664// +-------+ +---------+ +---------+
1665// | xapp | | submgr | | e2term |
1666// +-------+ +---------+ +---------+
1667// | | |
1668// | SubReq | |
1669// |------------->| |
1670// | | |
1671// | | SubReq |
1672// | |------------->|
1673// | | |
1674// | | SubResp |
1675// | |<-------------|
1676// | | |
1677// | SubResp | |
1678// |<-------------| |
1679// | | |
1680// | xApp restart | |
1681// | | |
1682// | SubReq | |
1683// | (retrans with same xApp generated subid but diff xid)
1684// |------------->| |
1685// | | |
1686// | SubResp | |
1687// |<-------------| |
1688// | | |
1689// | [SUBS DELETE] |
1690// | | |
1691//
1692//-----------------------------------------------------------------------------
1693func TestSubReqRetransmissionWithSameSubIdDiffXid(t *testing.T) {
1694 CaseBegin("TestSubReqRetransmissionWithSameSubIdDiffXid")
1695
1696 //Subs Create
1697 cretrans := xappConn1.SendSubsReq(t, nil, nil)
1698 crereq, cremsg := e2termConn1.RecvSubsReq(t)
1699 e2termConn1.SendSubsResp(t, crereq, cremsg)
1700 e2SubsId := xappConn1.RecvSubsResp(t, cretrans)
1701
1702 // xApp restart here
1703 // --> artificial delay
1704 <-time.After(1 * time.Second)
1705
1706 //Subs Create
1707 cretrans = xappConn1.SendSubsReq(t, nil, nil) //Retransmitted SubReq
1708 e2SubsId = xappConn1.RecvSubsResp(t, cretrans)
1709
1710 //Subs Delete
1711 deltrans := xappConn1.SendSubsDelReq(t, nil, e2SubsId)
1712 delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
1713 e2termConn1.SendSubsDelResp(t, delreq, delmsg)
1714 xappConn1.RecvSubsDelResp(t, deltrans)
1715
1716 //Wait that subs is cleaned
1717 mainCtrl.wait_subs_clean(t, e2SubsId, 10)
1718
1719 xappConn1.TestMsgChanEmpty(t)
1720 xappConn2.TestMsgChanEmpty(t)
1721 e2termConn1.TestMsgChanEmpty(t)
1722 mainCtrl.wait_registry_empty(t, 10)
1723}