package control
import (
+ "strings"
"testing"
"time"
// SetPackerIf(e2ap_wrapper.NewAsn1E2APPacker())
SetPackerIf(e2ap_wrapper.NewUtAsn1E2APPacker())
+
+ restDuplicateCtrl.Init()
+
}
//-----------------------------------------------------------------------------
// Req
params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
restSubId := xappConn1.SendRESTSubsReq(t, params)
- xappConn1.ExpectRESTNotification(t, restSubId)
+ xappConn1.ExpectRESTNotificationNok(t, restSubId, "failAll")
waiter.WaitResult(t)
e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
params.SetMeid("RAN_NAME_1")
restSubId2 := xappConn2.SendRESTSubsReq(t, params)
xapp.Logger.Info("Send REST subscriber request for second subscriber : %v", restSubId2)
- xappConn2.ExpectRESTNotification(t, restSubId2)
+ xappConn2.ExpectRESTNotificationNok(t, restSubId2, "allFail")
waiter.WaitResult(t)
// e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2) - TOD: missing delete
xappConn2.WaitRESTNotification(t, restSubId2)
Counter{cRestSubDelRespToXapp, 2},
})
- var params *teststube2ap.RESTSubsReqParams = nil
+ var params *teststube2ap.RESTSubsReqParams = nil
+
+ //Subs Create
+ restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
+
+ queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
+ restSubId2, e2SubsId2 := createXapp2MergedSubscription(t, "RAN_NAME_1")
+
+ queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
+
+ //Del1, this shall fail on rtmgr side
+ waiter := rtmgrHttp.AllocNextEvent(false)
+ xappConn1.SendRESTSubsDelReq(t, &restSubId)
+ waiter.WaitResult(t)
+
+ queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13660"})
+
+ //Del2
+ deleteXapp2Subscription(t, &restSubId2)
+
+ waitSubsCleanup(t, e2SubsId2, 10)
+
+ mainCtrl.VerifyCounterValues(t)
+}
+
+//-----------------------------------------------------------------------------
+// TestRESTSubReqRetransmission
+//
+// stub stub
+// +-------+ +---------+ +---------+
+// | xapp | | submgr | | e2term |
+// +-------+ +---------+ +---------+
+// | | |
+// | RESTSubReq1 | |
+// |---------------->| |
+// | | |
+// | RESTSubResp | |
+// |<----------------| |
+// | | SubReq1 |
+// | |------------->|
+// | | |
+// | RESTSubReq2 | |
+// | (retrans) | |
+// |---------------->| |
+// | RESTSubResp(201)| |
+// |<----------------| |
+// | | |
+// | | SubResp1 |
+// | |<-------------|
+// | RESTNotif1 | |
+// |<----------------| |
+// | | |
+// | [SUBS DELETE] |
+// | | |
+//
+//-----------------------------------------------------------------------------
+
+func TestRESTSubReqRetransmission(t *testing.T) {
+ CaseBegin("TestRESTSubReqRetransmission")
+
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cRestSubReqFromXapp, 2},
+ Counter{cRestSubRespToXapp, 2},
+ Counter{cSubReqToE2, 1},
+ Counter{cSubRespFromE2, 1},
+ Counter{cRestSubNotifToXapp, 1},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cSubDelReqToE2, 1},
+ Counter{cSubDelRespFromE2, 1},
+ Counter{cRestSubDelRespToXapp, 1},
+ })
+ // Retry/duplicate will get the same way as the first request.
+ // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending
+ // second request from same xapp as doing it from xappConn1 would not work as notification would not be received
+
+ // Subs Create
+ const subReqCount int = 1
+
+ // In order to force both XAPP's to create their own subscriptions, force rtmgr to block a while so that 2nd create
+ // gets into execution before the rtmgrg responds for the first one.
+ waiter := rtmgrHttp.AllocNextSleep(10, true)
+ params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
+ restSubId1 := xappConn1.SendRESTSubsReq(t, params)
+ xappConn2.SendRESTSubsReq(t, params)
+
+ waiter.WaitResult(t)
+
+ xappConn1.WaitListedRestNotifications(t, []string{restSubId1})
+
+ // Depending one goroutine scheduling order, we cannot say for sure which xapp reaches e2term first. Thus
+ // the order is not significant he6re.
+ crereq, cremsg := e2termConn1.RecvSubsReq(t)
+ e2termConn1.SendSubsResp(t, crereq, cremsg)
+
+ e2SubsIdA := <-xappConn1.ListedRESTNotifications
+ xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
+
+ // Del1
+ xappConn1.SendRESTSubsDelReq(t, &restSubId1)
+ delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
+ e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
+
+ mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId}, 10)
+
+ mainCtrl.VerifyCounterValues(t)
+}
+
+//-----------------------------------------------------------------------------
+// stub stub stub
+// +-------+ +---------+ +---------+ +---------+
+// | xapp | | submgr | | e2term | | rtmgr |
+// +-------+ +---------+ +---------+ +---------+
+// | | | |
+// | RESTSubReq | | |
+// |---------------->| | |
+// | RESTSubResp | | |
+// |<----------------| | |
+// | | RouteCreate | |
+// | |--------------------------->|
+// | | RouteResponse| |
+// | |<---------------------------| // The order of these events may vary
+// | | SubReq | |
+// | |------------->| | // The order of these events may vary
+// | | SubResp | |
+// | |<-------------| |
+// | RESTNotif1 | | |
+// |<----------------| | |
+// | RESTSubReq | | |
+// | [RETRANS1] | | |
+// |---------------->| | |
+// | RESTNotif1 | | |
+// |<----------------| | |
+// | RESTSubReq | | |
+// | [RETRANS2] | | |
+// |---------------->| | |
+// | RESTNotif1 | | |
+// |<----------------| | |
+// | RESTSubDelReq | | |
+// |---------------->| | |
+// | | SubDelReq | |
+// | |------------->| |
+// | RESTSubDelResp| | |
+// |<----------------| | |
+// | | SubDelResp | |
+// | |<-------------| |
+// | | | |
+//
+//-----------------------------------------------------------------------------
+
+func TestRESTSubReqRetransmissionV2(t *testing.T) {
+ CaseBegin("TestRESTSubReqRetransmissionV2")
+
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cRestSubReqFromXapp, 3},
+ Counter{cRestSubRespToXapp, 3},
+ Counter{cSubReqToE2, 1},
+ Counter{cSubRespFromE2, 1},
+ Counter{cRestSubNotifToXapp, 3},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cSubDelReqToE2, 1},
+ Counter{cSubDelRespFromE2, 1},
+ Counter{cRestSubDelRespToXapp, 1},
+ })
+
+ params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
+
+ restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
+
+ queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
+
+ //1.st resend
+ restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
+
+ assert.Equal(t, restSubId_resend, restSubId)
+
+ <-time.After(100 * time.Millisecond)
+
+ //2.nd resend
+ restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
+
+ assert.Equal(t, restSubId_resend2, restSubId)
+
+ <-time.After(100 * time.Millisecond)
+
+ deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
+
+ waitSubsCleanup(t, e2SubsId, 10)
+
+ //Wait that subs is cleaned
+ mainCtrl.VerifyCounterValues(t)
+}
+
+//-----------------------------------------------------------------------------
+// stub stub stub
+// +-------+ +---------+ +---------+ +---------+
+// | xapp | | submgr | | e2term | | rtmgr |
+// +-------+ +---------+ +---------+ +---------+
+// | | | |
+// | RESTSubReq | | |
+// |---------------->| | |
+// | RESTSubResp | | |
+// |<----------------| | |
+// | | RouteCreate | |
+// | |--------------------------->|
+// | | RouteResponse| |
+// | |<---------------------------| // The order of these events may vary
+// | | SubReq | |
+// | |------------->| | // The order of these events may vary
+// | | SubResp | |
+// | |<-------------| |
+// | RESTNotif1 | | |
+// |<----------------| | |
+// | RESTSubReq | | |
+// | [RETRANS, with RESTsubsId] | |
+// |---------------->| | |
+// | RESTNotif1 | | |
+// |<----------------| | |
+// | RESTSubReq | | |
+// | [RETRANS, without RESTsubsId] | |
+// |---------------->| | |
+// | RESTNotif1 | | |
+// |<----------------| | |
+// | RESTSubDelReq | | |
+// |---------------->| | |
+// | | SubDelReq | |
+// | |------------->| |
+// | RESTSubDelResp| | |
+// |<----------------| | |
+// | | SubDelResp | |
+// | |<-------------| |
+// | | | |
+//
+//-----------------------------------------------------------------------------
+func TestRESTSubReqRetransmissionV3(t *testing.T) {
+ CaseBegin("TestRESTSubReqRetransmissionV3")
+
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cRestSubReqFromXapp, 3},
+ Counter{cRestSubRespToXapp, 3},
+ Counter{cSubReqToE2, 1},
+ Counter{cSubRespFromE2, 1},
+ Counter{cRestSubNotifToXapp, 3},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cSubDelReqToE2, 1},
+ Counter{cSubDelRespFromE2, 1},
+ Counter{cRestSubDelRespToXapp, 1},
+ })
+
+ params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
+
+ restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
+
+ queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
+
+ <-time.After(100 * time.Millisecond)
+
+ //1.st resend with subscription ID
+ params.SetSubscriptionID(&restSubId)
+ restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
+
+ assert.Equal(t, restSubId_resend, restSubId)
+
+ <-time.After(100 * time.Millisecond)
+
+ //2.nd resend without subscription ID (faking app restart)
+ params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
+ restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
+
+ assert.Equal(t, restSubId_resend2, restSubId)
+
+ <-time.After(100 * time.Millisecond)
+
+ deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
+
+ waitSubsCleanup(t, e2SubsId, 10)
+
+ //Wait that subs is cleaned
+ mainCtrl.VerifyCounterValues(t)
+}
+
+//-----------------------------------------------------------------------------
+// stub stub stub
+// +-------+ +---------+ +---------+ +---------+
+// | xapp | | submgr | | e2term | | rtmgr |
+// +-------+ +---------+ +---------+ +---------+
+// | | | |
+// | RESTSubReq | | |
+// |---------------->| | |
+// | RESTSubResp | | |
+// |<----------------| | |
+// | | RouteCreate | |
+// | |--------------------------->|
+// | | RouteResponse| |
+// | |<---------------------------|
+// | | SubReq | |
+// | |------------->| |
+// | | SubResp | |
+// | |<-------------| |
+// | RESTNotif1 | | |
+// |<----------------| | |
+// | RESTSubReq | | |
+// | [with RestSUbsId + one additional e2 subDetail]
+// |---------------->| | |
+// | RESTNotif1 | | |
+// | [for initial e2 subDetail] | |
+// |<----------------| | |
+// | | RouteCreate | |
+// | |--------------------------->|
+// | | RouteResponse| |
+// | |<---------------------------|
+// | | SubReq | |
+// | |------------->| |
+// | | SubResp | |
+// | |<-------------| |
+// | RESTNotif1 | | |
+// |<----------------| | |
+// | RESTSubReq | | |
+// | [with RESTsubsId initial request] |
+// |---------------->| | |
+// | RESTNotif1 | | |
+// |<----------------| | |
+// | RESTSubDelReq | | |
+// |---------------->| | |
+// | RESTSubDelResp| | |
+// |<----------------| | |
+// | | SubDelReq | |
+// | |------------->| |
+// | | SubDelResp | |
+// | |<-------------| |
+// | | SubDelReq | |
+// | |------------->| |
+// | | SubDelResp | |
+// | |<-------------| |
+// | | | |
+//
+//-----------------------------------------------------------------------------
+
+func TestRESTSubReqRetransmissionV4(t *testing.T) {
+ CaseBegin("TestRESTSubReqRetransmissionV4")
+
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cRestSubReqFromXapp, 3},
+ Counter{cRestSubRespToXapp, 3},
+ Counter{cSubReqToE2, 2},
+ Counter{cSubRespFromE2, 2},
+ Counter{cRestSubNotifToXapp, 4},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cSubDelReqToE2, 2},
+ Counter{cSubDelRespFromE2, 2},
+ Counter{cRestSubDelRespToXapp, 1},
+ })
+
+ params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
+
+ restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
+
+ <-time.After(100 * time.Millisecond)
+
+ // Send modified requst, this time with e2 subscriptions.
+ params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
+ params2.SetSubscriptionID(&restSubId)
+
+ xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
+ xappConn1.ExpectAnyNotification(t)
+ // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
+ restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
+ e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
+ assert.Equal(t, e2SubsId, e2SubsId1)
+
+ crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
+
+ xappConn1.DecrementRequestCount()
+ xappConn1.ExpectRESTNotification(t, restSubId_resend)
+ e2termConn1.SendSubsResp(t, crereq2, cremsg2)
+ e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
+ assert.NotEqual(t, e2SubsId2, 0)
+
+ <-time.After(100 * time.Millisecond)
+
+ xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
+ params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
+ params.SetSubscriptionID(&restSubId)
+ xappConn1.ExpectAnyNotification(t)
+ // Resend the original request again with only one e2 subscription (detail), this time with restsubsid
+ restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
+ assert.Equal(t, restSubId_resend, restSubId_resend2)
+
+ e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
+ assert.Equal(t, e2SubsId, e2SubsId1)
+
+ // Delete both e2 subscriptions
+ xappConn1.SendRESTSubsDelReq(t, &restSubId)
+ e2SubsIds := []uint32{e2SubsId, e2SubsId2}
+ sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
+
+ waitSubsCleanup(t, e2SubsId, 10)
+
+ //Wait that subs is cleaned
+ mainCtrl.VerifyCounterValues(t)
+}
+
+//-----------------------------------------------------------------------------
+// stub stub stub
+// +-------+ +---------+ +---------+ +---------+
+// | xapp | | submgr | | e2term | | rtmgr |
+// +-------+ +---------+ +---------+ +---------+
+// | | | |
+// | RESTSubReq | | |
+// |---------------->| | |
+// | RESTSubResp | | |
+// |<----------------| | |
+// | | RouteCreate | |
+// | |--------------------------->|
+// | | RouteResponse| |
+// | |<---------------------------|
+// | | SubReq | |
+// | |------------->| |
+// | | SubResp | |
+// | |<-------------| |
+// | RESTNotif1 | | |
+// |<----------------| | |
+// | RESTSubReq | | |
+// | [with RestSUbsId + one additional e2 subDetail]
+// |---------------->| | |
+// | RESTNotif1 | | |
+// | [for initial e2 subDetail] | |
+// |<----------------| | |
+// | | RouteCreate | |
+// | |--------------------------->|
+// | | RouteResponse| |
+// | |<---------------------------|
+// | | SubReq | |
+// | |------------->| |
+// | | SubResp | |
+// | |<-------------| |
+// | RESTNotif1 | | |
+// |<----------------| | |
+// | RESTSubReq | | |
+// | [without RESTsubsId initial request] |
+// |---------------->| | |
+// | RESTNotif1 | | |
+// |<----------------| | |
+// | RESTSubDelReq | | |
+// |---------------->| | |
+// | RESTSubDelResp| | |
+// |<----------------| | |
+// | | SubDelReq | |
+// | |------------->| |
+// | | SubDelResp | |
+// | |<-------------| |
+// | | SubDelReq | |
+// | |------------->| |
+// | | SubDelResp | |
+// | |<-------------| |
+// | | | |
+//
+//-----------------------------------------------------------------------------
+
+func TestRESTSubReqRetransmissionV5(t *testing.T) {
+ CaseBegin("TestRESTSubReqRetransmissionV5")
+
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cRestSubReqFromXapp, 3},
+ Counter{cRestSubRespToXapp, 3},
+ Counter{cSubReqToE2, 2},
+ Counter{cSubRespFromE2, 2},
+ Counter{cRestSubNotifToXapp, 4},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cSubDelReqToE2, 2},
+ Counter{cSubDelRespFromE2, 2},
+ Counter{cRestSubDelRespToXapp, 1},
+ })
+
+ params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
+
+ restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
+
+ <-time.After(100 * time.Millisecond)
+
+ // Send modified requst, this time with e2 subscriptions.
+ params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
+ params2.SetSubscriptionID(&restSubId)
+
+ xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
+ xappConn1.ExpectAnyNotification(t)
+ // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
+ restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
- //Subs Create
- restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
+ e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
+ assert.Equal(t, e2SubsId, e2SubsId1)
+ // The first E2 subscription returns immediately, manually decrement expected request count for the remaining request handling
+ xappConn1.DecrementRequestCount()
- queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
- restSubId2, e2SubsId2 := createXapp2MergedSubscription(t, "RAN_NAME_1")
+ crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
- queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
+ xappConn1.ExpectRESTNotification(t, restSubId_resend)
+ e2termConn1.SendSubsResp(t, crereq2, cremsg2)
+ e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
+ assert.NotEqual(t, e2SubsId2, 0)
- //Del1, this shall fail on rtmgr side
- waiter := rtmgrHttp.AllocNextEvent(false)
- xappConn1.SendRESTSubsDelReq(t, &restSubId)
- waiter.WaitResult(t)
+ <-time.After(100 * time.Millisecond)
- queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13660"})
+ xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
+ params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
+ xappConn1.ExpectAnyNotification(t)
+ // Resend the original request again with only one e2 subscription (detail), WITHOUT restsubsid
+ // md5sum shall find the original request
+ restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
+ assert.Equal(t, restSubId_resend, restSubId_resend2)
- //Del2
- deleteXapp2Subscription(t, &restSubId2)
+ e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
+ assert.Equal(t, e2SubsId, e2SubsId1)
- waitSubsCleanup(t, e2SubsId2, 10)
+ // Delete both e2 subscriptions
+ xappConn1.SendRESTSubsDelReq(t, &restSubId)
+ e2SubsIds := []uint32{e2SubsId, e2SubsId2}
+ sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
+
+ waitSubsCleanup(t, e2SubsId, 10)
+ //Wait that subs is cleaned
mainCtrl.VerifyCounterValues(t)
}
//-----------------------------------------------------------------------------
-// TestRESTSubReqRetransmission
-//
-// stub stub
-// +-------+ +---------+ +---------+
-// | xapp | | submgr | | e2term |
-// +-------+ +---------+ +---------+
-// | | |
-// | RESTSubReq1 | |
-// |---------------->| |
-// | | |
-// | RESTSubResp | |
-// |<----------------| |
-// | | SubReq1 |
-// | |------------->|
-// | | |
-// | RESTSubReq2 | |
-// | (retrans) | |
-// |---------------->| |
-// | | |
-// | | SubReq2 |
-// | |------------->|
-// | RESTSubResp2 | |
-// |<----------------| |
-// | | SubResp1 |
-// | |<-------------|
-// | RESTNotif1 | |
-// |<----------------| |
-// | | SubResp1 |
-// | |<-------------|
-// | RESTNotif2 | |
-// |<----------------| |
-// | | |
-// | [SUBS DELETE] |
-// | | |
+// stub stub stub
+// +-------+ +---------+ +---------+ +---------+
+// | xapp | | submgr | | e2term | | rtmgr |
+// +-------+ +---------+ +---------+ +---------+
+// | | | |
+// | RESTSubReq | | |
+// |---------------->| | |
+// | RESTSubResp | | |
+// |<----------------| | |
+// | | RouteCreate | |
+// | |--------------------------->|
+// | | RouteResponse| |
+// | |<---------------------------|
+// | | SubReq | |
+// | |------------->| |
+// | | SubResp | |
+// | |<-------------| |
+// | RESTNotif1 | | |
+// |<----------------| | |
+// | RESTSubReq | | |
+// | [with RestSUbsId + one additional e2 subDetail]
+// |---------------->| | |
+// | RESTNotif1 | | |
+// | [for initial e2 subDetail] | |
+// |<----------------| | |
+// | | RouteCreate | |
+// | |--------------------------->|
+// | | RouteResponse| |
+// | |<---------------------------|
+// | | SubReq | |
+// | |------------->| |
+// | | SubResp | |
+// | |<-------------| |
+// | RESTNotif1 | | |
+// |<----------------| | |
+// | RESTSubDelReq | | |
+// |---------------->| | |
+// | RESTSubDelResp| | |
+// |<----------------| | |
+// | | SubDelReq | |
+// | |------------->| |
+// | | SubDelResp | |
+// | |<-------------| |
+// | | SubDelReq | |
+// | |------------->| |
+// | | SubDelResp | |
+// | |<-------------| |
+// | RESTSubReq | | |
+// | [with RESTsubsId initial request] |
+// |---------------->| | |
+// | RESTSubResp | | |
+// |<----------------| | |
+// | | RouteCreate | |
+// | |--------------------------->|
+// | | RouteResponse| |
+// | |<---------------------------|
+// | | SubReq | |
+// | |------------->| |
+// | | SubResp | |
+// | |<-------------| |
+// | RESTNotif1 | | |
+// |<----------------| | |
+// | | | |
//
//-----------------------------------------------------------------------------
-
-func TestRESTSubReqRetransmission(t *testing.T) {
- CaseBegin("TestRESTSubReqRetransmission")
+func TestRESTSubReqRetransmissionV6(t *testing.T) {
+ CaseBegin("TestRESTSubReqRetransmissionV6")
mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
- Counter{cRestSubReqFromXapp, 2},
- Counter{cRestSubRespToXapp, 2},
- Counter{cSubReqToE2, 2},
- Counter{cSubRespFromE2, 2},
- Counter{cRestSubNotifToXapp, 2},
+ Counter{cRestSubReqFromXapp, 3},
+ Counter{cRestSubRespToXapp, 3},
+ Counter{cSubReqToE2, 3},
+ Counter{cSubRespFromE2, 3},
+ Counter{cRestSubNotifToXapp, 4},
Counter{cRestSubDelReqFromXapp, 2},
- Counter{cSubDelReqToE2, 2},
- Counter{cSubDelRespFromE2, 2},
+ Counter{cSubDelReqToE2, 3},
+ Counter{cSubDelRespFromE2, 3},
Counter{cRestSubDelRespToXapp, 2},
})
- // Retry/duplicate will get the same way as the first request. Submgr cannot detect duplicate RESTRequests
- // Contianed duplicate messages from same xapp will not be merged. Here we use xappConn2 to simulate sending
- // second request from same xapp as doing it from xappConn1 would not work as notification would not be received
-
- // Subs Create
- const subReqCount int = 1
- // In order to force both XAPP's to create their own subscriptions, force rtmgr to block a while so that 2nd create
- // gets into execution before the rtmgrg responds for the first one.
- waiter := rtmgrHttp.AllocNextSleep(10, true)
params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
- restSubId1 := xappConn1.SendRESTSubsReq(t, params)
- restSubId2 := xappConn2.SendRESTSubsReq(t, params)
- waiter.WaitResult(t)
+ restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
- xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
+ <-time.After(100 * time.Millisecond)
- // Depending one goroutine scheduling order, we cannot say for sure which xapp reaches e2term first. Thus
- // the order is not significant he6re.
- crereq, cremsg := e2termConn1.RecvSubsReq(t)
- e2termConn1.SendSubsResp(t, crereq, cremsg)
- crereq, cremsg = e2termConn1.RecvSubsReq(t)
- e2termConn1.SendSubsResp(t, crereq, cremsg)
+ // Send modified requst, this time with e2 subscriptions.
+ params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
+ params2.SetSubscriptionID(&restSubId)
- e2SubsIdA := <-xappConn1.ListedRESTNotifications
- xapp.Logger.Info("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
- e2SubsIdB := <-xappConn1.ListedRESTNotifications
- xapp.Logger.Info("TEST: 2.nd XAPP notification received e2SubsId=%v", e2SubsIdB)
+ xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
+ xappConn1.ExpectAnyNotification(t)
+ // Resend the original request with an additional e2 subscription (detail), this time with restsubsid
+ restSubId_resend := xappConn1.SendRESTSubsReq(t, params2)
- // Del1
- xappConn1.SendRESTSubsDelReq(t, &restSubId1)
- delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
- e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
+ e2SubsId1 := xappConn1.WaitAnyRESTNotification(t)
+ assert.Equal(t, e2SubsId, e2SubsId1)
- // Del2
- xappConn2.SendRESTSubsDelReq(t, &restSubId2)
- delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
- e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
+ crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
- mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId, e2SubsIdB.E2SubsId}, 10)
+ xappConn1.ExpectRESTNotification(t, restSubId_resend)
+ e2termConn1.SendSubsResp(t, crereq2, cremsg2)
+ e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
+ assert.NotEqual(t, e2SubsId2, 0)
- waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
+ <-time.After(100 * time.Millisecond)
+
+ // Delete both e2 subscriptions
+ xappConn1.SendRESTSubsDelReq(t, &restSubId)
+ e2SubsIds := []uint32{e2SubsId, e2SubsId2}
+ sendAndReceiveMultipleE2DelReqs(t, e2SubsIds, e2termConn1)
+
+ waitSubsCleanup(t, e2SubsId, 10)
+
+ // Resend the original request, we shall find it's previous md5sum/restsubs
+ // but the restsubscription has been already removed. This shall trigger a
+ // fresh create.
+ restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
+
+ <-time.After(100 * time.Millisecond)
+
+ deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
+ waitSubsCleanup(t, e2SubsId, 10)
+
+ //Wait that subs is cleaned
mainCtrl.VerifyCounterValues(t)
}
// | | |
//
//-----------------------------------------------------------------------------
+
func TestRESTSubReqRetryNoRespSubDelRespInSubmgr(t *testing.T) {
CaseBegin("TestRESTSubReqTwoRetriesNoRespSubDelRespInSubmgr start")
xapp.Logger.Info("Ignore 2nd REST subscriber request for subscriber : %v", restSubId)
delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
- xappConn1.ExpectRESTNotification(t, restSubId)
+ xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
e2termConn1.SendSubsDelResp(t, delreq, delmsg)
- // e2SubsId := xappConn1.WaitRESTNotification(t, restSubId) - TODO: Should we delete this?
xappConn1.WaitRESTNotification(t, restSubId)
// Wait that subs is cleaned
e2termConn1.RecvSubsDelReq(t)
xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
- xappConn1.ExpectRESTNotification(t, restSubId)
+ xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
e2termConn1.RecvSubsDelReq(t)
xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
e2termConn1.RecvSubsDelReq(t)
xapp.Logger.Info("Ignore 1st INTERNAL delete request for subscriber : %v", restSubId)
- xappConn1.ExpectRESTNotification(t, restSubId)
+ xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
e2termConn1.RecvSubsDelReq(t)
xapp.Logger.Info("Ignore 2nd INTERNAL delete request for subscriber : %v", restSubId)
e2termConn1.SendSubsFail(t, fparams1, cremsg1)
delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
- xappConn1.ExpectRESTNotification(t, restSubId)
+ xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
xapp.Logger.Info("TEST: REST notification received e2SubsId=%v", e2SubsId)
params.SetMeid("RAN_NAME_1")
xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
- xappConn2.WaitRESTNotificationForAnySubscriptionId(t)
+ xappConn2.ExpectAnyNotification(t)
waiter := rtmgrHttp.AllocNextSleep(10, true)
restSubId2 := xappConn2.SendRESTSubsReq(t, params)
waiter.WaitResult(t)
xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
- e2SubsId2 := <-xappConn2.RESTNotification
+ e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
// Policy change
- instanceId := int64(e2SubsId)
// GetRESTSubsReqPolicyParams sets some coutners on tc side.
+
params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
- params.SubsReqParams.SubscriptionDetails[0].InstanceID = &instanceId
+ params.SetSubscriptionID(&restSubId)
params.SetTimeToWait("w200ms")
restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
mainCtrl.VerifyCounterValues(t)
}
+//-----------------------------------------------------------------------------
+// TestRESTSubReqPolicyChangeNOk
+//
+// stub stub
+// +-------+ +---------+ +---------+
+// | xapp | | submgr | | e2term |
+// +-------+ +---------+ +---------+
+// | | |
+// | RESTSubReq | |
+// |---------------->| |
+// | | |
+// | RESTSubResp | |
+// |<----------------| |
+// | | SubReq |
+// | |------------->|
+// | | |
+// | | SubResp |
+// | |<-------------|
+// | | |
+// | RESTNotif | |
+// |<----------------| |
+// | | |
+// | RESTSubReq | |
+// |---------------->| |
+// | | |
+// | RESTSubUpdateFail |
+// | | |
+// | RESTSubDelReq | |
+// |---------------->| |
+// | | |
+// | | SubDelReq |
+// | |------------->|
+// | | |
+// | | SubDelResp |
+// | |<-------------|
+// | | |
+// | RESTSubDelResp | |
+// |<----------------| |
+//
+//-----------------------------------------------------------------------------
+func TestRESTSubReqPolicyChangeNOk(t *testing.T) {
+ CaseBegin("TestRESTSubReqPolicyChangeNOk")
+
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cRestSubReqFromXapp, 2},
+ Counter{cRestSubRespToXapp, 1},
+ Counter{cSubReqToE2, 1},
+ Counter{cSubRespFromE2, 1},
+ Counter{cRestSubNotifToXapp, 1},
+ Counter{cRestSubFailToXapp, 1},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cSubDelReqToE2, 1},
+ Counter{cSubDelRespFromE2, 1},
+ Counter{cRestSubDelRespToXapp, 1},
+ })
+
+ const subReqCount int = 1
+
+ // Req
+ params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
+ restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
+
+ // Policy change
+
+ params = xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
+
+ restSubIdUpd := strings.ToUpper(restSubId)
+ params.SetSubscriptionID(&restSubIdUpd)
+ params.SetTimeToWait("w200ms")
+
+ restSubId2 := xappConn1.SendRESTSubsReq(t, params)
+ assert.Equal(t, restSubId2, "")
+
+ // Del
+ xappConn1.SendRESTSubsDelReq(t, &restSubId)
+
+ delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+ e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+
+ // Wait that subs is cleaned
+ waitSubsCleanup(t, e2SubsId, 10)
+ mainCtrl.VerifyCounterValues(t)
+}
+
//-----------------------------------------------------------------------------
// TestRESTSubReqAndSubDelOkTwoE2termParallel
//
// |<----------------| |
//
//-----------------------------------------------------------------------------
+
func TestRESTSubReqAndSubDelOkWithRestartInMiddle(t *testing.T) {
CaseBegin("TestRESTSubReqAndSubDelOkWithRestartInMiddle")
// | | | |
//
//-----------------------------------------------------------------------------
+
func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
CaseBegin("TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle")
params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
params.SetMeid("RAN_NAME_1")
xapp.Subscription.SetResponseCB(xappConn2.SubscriptionRespHandler)
- xappConn2.WaitRESTNotificationForAnySubscriptionId(t)
+ xappConn2.ExpectAnyNotification(t)
restSubId2 := xappConn2.SendRESTSubsReq(t, params)
xapp.Logger.Info("Send REST subscriber request for subscriberId : %v", restSubId2)
- e2SubsId2 := <-xappConn2.RESTNotification
+ e2SubsId2 := xappConn2.WaitAnyRESTNotification(t)
xapp.Logger.Info("REST notification received e2SubsId=%v", e2SubsId2)
queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
// |<----------------| |
//
//-----------------------------------------------------------------------------
+
func TestRESTReportSubReqAndSubDelOk(t *testing.T) {
CaseBegin("TestRESTReportSubReqAndSubDelOk")
subReqCount := 1
// Req2
params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
params.SetMeid("RAN_NAME_1")
- eventTriggerDefinition := "1234"
+ eventTriggerDefinition := []int64{1234, 1}
params.SetSubEventTriggerDefinition(eventTriggerDefinition)
restSubId2 := xappConn2.SendRESTSubsReq(t, params)
actionId := int64(1)
actionType := "report"
- actionDefinition := "56781"
+ actionDefinition := []int64{5678, 1}
subsequestActionType := "continue"
timeToWait := "w10ms"
params.AppendActionToActionToBeSetupList(actionId, actionType, actionDefinition, subsequestActionType, timeToWait)
// Req2
params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
params.SetMeid("RAN_NAME_1")
- actionDefinition := "5678"
+ actionDefinition := []int64{5678, 1}
params.SetSubActionDefinition(actionDefinition)
restSubId2 := xappConn2.SendRESTSubsReq(t, params)
// Req2
params = xappConn2.GetRESTSubsReqReportParams(subReqCount)
params.SetMeid("RAN_NAME_1")
- actionDefinition := "56782"
+ actionDefinition := []int64{56782}
params.SetSubActionDefinition(actionDefinition)
restSubId2 := xappConn2.SendRESTSubsReq(t, params)
// | |<-------------|
//
//-----------------------------------------------------------------------------
+
func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseDecodeFail")
subReqCount := 1
_, cremsg = e2termConn1.RecvSubsReq(t)
- xappConn1.ExpectRESTNotification(t, restSubId)
+ xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
// Subscription already created in E2 Node.
fparams := &teststube2ap.E2StubSubsFailParams{}
// | |<-------------|
//
//-----------------------------------------------------------------------------
+
func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
xapp.Logger.Info("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId")
subReqCount := 1
_, cremsg = e2termConn1.RecvSubsReq(t)
- xappConn1.ExpectRESTNotification(t, restSubId)
+ xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
// Subscription already created in E2 Node.
fparams := &teststube2ap.E2StubSubsFailParams{}
_, cremsg = e2termConn1.RecvSubsReq(t)
- xappConn1.ExpectRESTNotification(t, restSubId)
+ xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
// Subscription already created in E2 Node.
fparams := &teststube2ap.E2StubSubsFailParams{}
_, cremsg = e2termConn1.RecvSubsReq(t)
- xappConn1.ExpectRESTNotification(t, restSubId)
+ xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
// Subscription already created in E2 Node.
fparams := &teststube2ap.E2StubSubsFailParams{}
_, cremsg = e2termConn1.RecvSubsReq(t)
- xappConn1.ExpectRESTNotification(t, restSubId)
+ xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
// Subscription already created in E2 Node.
fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
_, cremsg = e2termConn1.RecvSubsReq(t)
- xappConn1.ExpectRESTNotification(t, restSubId)
+ xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
// Subscription already created in E2 Node.
fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
// E2t: Receive SubsDelReq
delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
- xappConn1.ExpectRESTNotification(t, restSubId)
+ xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
// Subscription does not exist in in E2 Node.
e2termConn1.SendSubsDelFail(t, delreq, delmsg)