package control
import (
+ //"os"
"strings"
"testing"
"time"
"gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap"
"gerrit.o-ran-sc.org/r/ric-plt/e2ap/pkg/e2ap_wrapper"
+ "gerrit.o-ran-sc.org/r/ric-plt/nodeb-rnib.git/entities"
"gerrit.o-ran-sc.org/r/ric-plt/submgr/pkg/teststube2ap"
"gerrit.o-ran-sc.org/r/ric-plt/xapp-frame/pkg/xapp"
"github.com/stretchr/testify/assert"
)
func TestSuiteSetup(t *testing.T) {
- // The effect of this call shall endure thgough the UT suite!
- // If this causes any issues, the previout interface can be restored
+ // The effect of this call shall endure though the UT suite!
+ // If this causes any issues, the previous interface can be restored
// like this:git log
// SetPackerIf(e2ap_wrapper.NewAsn1E2APPacker())
+ mainCtrl.InitAllCounterMap()
SetPackerIf(e2ap_wrapper.NewUtAsn1E2APPacker())
-
mainCtrl.c.restDuplicateCtrl.Init()
}
+func TestRanStatusChangeViaSDLNotification(t *testing.T) {
+
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cE2StateChangedToUp, 3},
+ })
+
+ // Current UT test cases use these ran names
+ xappRnibMock.CreateGnb("RAN_NAME_1", entities.ConnectionStatus_DISCONNECTED)
+ xappRnibMock.CreateGnb("RAN_NAME_11", entities.ConnectionStatus_DISCONNECTED)
+ xappRnibMock.CreateGnb("RAN_NAME_2", entities.ConnectionStatus_DISCONNECTED)
+
+ mainCtrl.c.e2IfState.ReadE2ConfigurationFromRnib()
+ mainCtrl.c.e2IfState.SubscribeChannels()
+
+ mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
+ mainCtrl.SetE2State(t, "RAN_NAME_2_CONNECTED")
+ mainCtrl.SetE2State(t, "RAN_NAME_11_CONNECTED")
+
+ mainCtrl.VerifyCounterValues(t)
+}
+
+//-----------------------------------------------------------------------------
+// TestRESTSubReqAfterE2ConnBreak
+//
+// stub stub
+// +-------+ +---------+ +---------+
+// | xapp | | submgr | | e2term |
+// +-------+ +---------+ +---------+
+// | | |
+// | [E2 Conn. DOWN] |
+// | | |
+// | RESTSubReq | |
+// |---------------->| |
+// | RESTSubFail | |
+// |<----------------| |
+// | | |
+//
+//-----------------------------------------------------------------------------
+
+func TestRESTSubReqAfterE2ConnBreak(t *testing.T) {
+ CaseBegin("TestRESTSubReqAfterE2ConnBreak")
+
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cRestSubReqFromXapp, 1},
+ Counter{cRestReqRejDueE2Down, 1},
+ Counter{cE2StateChangedToDown, 1},
+ Counter{cE2StateChangedToUp, 1},
+ })
+
+ // E2 disconnect after E2term has received response
+ mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
+ // Req
+ const subReqCount int = 1
+ params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
+ xappConn1.SendRESTSubsReq(t, params)
+
+ // Restore E2 connection for following test cases
+ mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
+
+ mainCtrl.VerifyAllClean(t)
+ mainCtrl.VerifyCounterValues(t)
+ //os.Exit(0)
+}
+
+//-----------------------------------------------------------------------------
+// TestRESTSubReqE2ConnBreak
+//
+// stub stub
+// +-------+ +---------+ +---------+
+// | xapp | | submgr | | e2term |
+// +-------+ +---------+ +---------+
+// | | |
+// | RESTSubReq | |
+// |---------------->| |
+// | RESTSubResp | |
+// |<----------------| |
+// | | SubReq |
+// | |------------->|
+// | | SubResp |
+// | |<-------------|
+// | | |
+// | [E2 Conn. DOWN] |
+// | [Int. SUBS DELETE] |
+// | | |
+// | RESTNotif(unsuccessful) |
+// |<----------------| |
+// | | |
+// | | |
+//
+//-----------------------------------------------------------------------------
+func TestRESTSubReqE2ConnBreak(t *testing.T) {
+ CaseBegin("TestRESTSubReqE2ConnBreak")
+
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cRestSubReqFromXapp, 1},
+ Counter{cRestSubRespToXapp, 1},
+ Counter{cSubReqToE2, 1},
+ Counter{cSubRespFromE2, 1},
+ Counter{cRestSubFailNotifToXapp, 1},
+ Counter{cE2StateChangedToDown, 1},
+ Counter{cE2StateChangedToUp, 1},
+ })
+
+ // Req
+ const subReqCount int = 1
+ params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
+ restSubId := xappConn1.SendRESTSubsReq(t, params)
+
+ crereq, cremsg := e2termConn1.RecvSubsReq(t)
+ xappConn1.ExpectRESTNotification(t, restSubId)
+
+ // E2 disconnect after E2term has received response
+ mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
+
+ e2termConn1.SendSubsResp(t, crereq, cremsg)
+ e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
+
+ <-time.After(time.Second * 1)
+ assert.Equal(t, 0, len(mainCtrl.c.registry.register))
+ assert.Equal(t, 0, len(mainCtrl.c.registry.restSubscriptions))
+
+ subIds, register, err := mainCtrl.c.ReadAllSubscriptionsFromSdl()
+ if err != nil {
+ xapp.Logger.Error("%v", err)
+ } else {
+ assert.Equal(t, 65534, len(subIds)) // range 1-65535 , FFFF = 65535
+ assert.Equal(t, 0, len(register))
+ }
+
+ restSubscriptions, err := mainCtrl.c.ReadAllRESTSubscriptionsFromSdl()
+ if err != nil {
+ xapp.Logger.Error("%v", err)
+ } else {
+ assert.Equal(t, 0, len(restSubscriptions))
+ }
+
+ // Restore E2 connection for following test cases
+ mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
+
+ // Wait that subs is cleaned
+ waitSubsCleanup(t, e2SubsId, 10)
+ mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
+}
+
+//-----------------------------------------------------------------------------
+// TestRESTSubscriptionDeleteAfterE2ConnectionBreak
+//
+// stub stub
+// +-------+ +---------+ +---------+
+// | xapp | | submgr | | e2term |
+// +-------+ +---------+ +---------+
+// | | |
+// | [SUBS CREATE] |
+// | | |
+// | [E2 Conn. DOWN] |
+// | | |
+// | RESTSubDelReq | |
+// |---------------->| |
+// | | |
+// | RESTSubDelResp | |
+// |<----------------| |
+// | | |
+// | [No valid subscription found] |
+// | | |
+//
+//-----------------------------------------------------------------------------
+func TestRESTSubscriptionDeleteAfterE2ConnectionBreak(t *testing.T) {
+ xapp.Logger.Debug("TEST: TestRESTSubscriptionDeleteAfterE2ConnectionBreak")
+
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cRestSubReqFromXapp, 1},
+ Counter{cRestSubRespToXapp, 1},
+ Counter{cSubReqToE2, 1},
+ Counter{cSubRespFromE2, 1},
+ Counter{cRestSubNotifToXapp, 1},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cRestSubDelRespToXapp, 1},
+ Counter{cE2StateChangedToDown, 1},
+ Counter{cE2StateChangedToUp, 1},
+ })
+
+ // Req
+ var params *teststube2ap.RESTSubsReqParams = nil
+ restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
+
+ // E2 disconnect after E2term has received response
+ mainCtrl.SetE2State(t, "RAN_NAME_1_DISCONNECTED")
+
+ // Del
+ xappConn1.SendRESTSubsDelReq(t, &restSubId)
+
+ <-time.After(time.Second * 1)
+ assert.Equal(t, 0, len(mainCtrl.c.registry.register))
+ assert.Equal(t, 0, len(mainCtrl.c.registry.restSubscriptions))
+
+ subIds, register, err := mainCtrl.c.ReadAllSubscriptionsFromSdl()
+ if err != nil {
+ xapp.Logger.Error("%v", err)
+ } else {
+ assert.Equal(t, 65534, len(subIds)) // range 1-65535 , FFFF = 65535
+ assert.Equal(t, 0, len(register))
+ }
+
+ restSubscriptions, err := mainCtrl.c.ReadAllRESTSubscriptionsFromSdl()
+ if err != nil {
+ xapp.Logger.Error("%v", err)
+ } else {
+ assert.Equal(t, 0, len(restSubscriptions))
+ }
+
+ // Restore E2 connection for following test cases
+ mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
+
+ // Wait that subs is cleaned
+ mainCtrl.wait_subs_clean(t, e2SubsId, 10)
+
+ xappConn1.TestMsgChanEmpty(t)
+ e2termConn1.TestMsgChanEmpty(t)
+ mainCtrl.wait_registry_empty(t, 10)
+ mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
+}
+
+//-----------------------------------------------------------------------------
+// TestRESTOtherE2ConnectionChanges
+//
+
+// stub stub
+// +-------+ +---------+ +---------+
+// | xapp | | submgr | | e2term |
+// +-------+ +---------+ +---------+
+// | | |
+// | [SUBS CREATE] |
+// | | |
+// | [E2 CONNECTED_SETUP_FAILED] |
+// | [E2 CONNECTING] |
+// | [E2 SHUTTING_DOWN] |
+// | [E2 SHUT_DOWN] |
+// | | |
+// | [SUBS DELETE] |
+// | | |
+//
+//-----------------------------------------------------------------------------
+func TestRESTOtherE2ConnectionChanges(t *testing.T) {
+ xapp.Logger.Debug("TEST: TestRESTOtherE2ConnectionChanges")
+
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cRestSubReqFromXapp, 1},
+ Counter{cRestSubRespToXapp, 1},
+ Counter{cSubReqToE2, 1},
+ Counter{cSubRespFromE2, 1},
+ Counter{cRestSubNotifToXapp, 1},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cSubDelReqToE2, 1},
+ Counter{cSubDelRespFromE2, 1},
+ Counter{cRestSubDelRespToXapp, 1},
+ Counter{cE2StateChangedToUp, 1},
+ })
+
+ // Req
+ params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
+ restSubId := xappConn1.SendRESTSubsReq(t, params)
+
+ crereq, cremsg := e2termConn1.RecvSubsReq(t)
+ xappConn1.ExpectRESTNotification(t, restSubId)
+ e2termConn1.SendSubsResp(t, crereq, cremsg)
+ e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
+
+ // Submgr should not react to any other connection state changes than CONNECTED and DISCONNECTED
+ mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED_SETUP_FAILED")
+ mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTING")
+ mainCtrl.SetE2State(t, "RAN_NAME_1_SHUTTING_DOWN")
+ mainCtrl.SetE2State(t, "RAN_NAME_1_SHUT_DOWN")
+
+ // Del
+ xappConn1.SendRESTSubsDelReq(t, &restSubId)
+ delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
+ e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+
+ // Restore E2 connection for following test cases
+ mainCtrl.SetE2State(t, "RAN_NAME_1_CONNECTED")
+
+ // Wait that subs is cleaned
+ waitSubsCleanup(t, e2SubsId, 10)
+ mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
+}
//-----------------------------------------------------------------------------
// TestRESTSubReqAndDeleteOkWithE2apUtWrapper
deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
waitSubsCleanup(t, e2SubsId, 10)
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_REQ, true)
waitSubsCleanup(t, e2SubsId, 10)
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
defer e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_DEL_RESP, true)
waitSubsCleanup(t, e2SubsId, 10)
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
xappConn2.TestMsgChanEmpty(t)
e2termConn1.TestMsgChanEmpty(t)
mainCtrl.wait_registry_empty(t, 10)
-
mainCtrl.VerifyCounterValues(t)
}
// Init counter check
mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Counter{cSubReqFromXapp, 2},
+ Counter{cMergedSubscriptions, 1},
Counter{cSubReqToE2, 1},
Counter{cSubRespFromE2, 1},
Counter{cSubRespToXapp, 2},
Counter{cSubDelReqToE2, 1},
Counter{cSubDelRespFromE2, 1},
Counter{cSubDelRespToXapp, 2},
+ Counter{cUnmergedSubscriptions, 1},
})
//Req1
mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Counter{cSubReqFromXapp, 1},
Counter{cSubReqToE2, 1},
+ Counter{cSubReqTimerExpiry, 1},
Counter{cSubReReqToE2, 1},
Counter{cSubRespFromE2, 1},
Counter{cSubRespToXapp, 1},
// | | SubFail |
// | |<-------------|
// | | |
-// | | SubDelReq |
-// | |------------->|
-// | | |
-// | | SubDelResp |
-// | |<-------------|
-// | | |
// | SubFail | |
// |<-------------| |
// | | |
fparams1.Set(crereq1)
e2termConn1.SendSubsFail(t, fparams1, cremsg1)
- // E2t: Receive SubsDelReq and send SubsDelResp (internal first)
- delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
- e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
-
// Xapp: Receive SubsFail
e2SubsId := xappConn1.RecvSubsFail(t, cretrans)
rparams2 := &teststube2ap.E2StubSubsReqParams{}
rparams2.Init()
cretrans2 := xappConn2.SendSubsReq(t, rparams2, nil)
- //crereq2, cremsg2 := e2termConn1.RecvSubsReq(t)
- //e2termConn1.SendSubsResp(t, crereq2, cremsg2)
e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
resp, _ := xapp.Subscription.QuerySubscriptions()
//Del1
deltrans1 := xappConn1.SendSubsDelReq(t, nil, e2SubsId1)
- //e2termConn1.RecvSubsDelReq(t)
- //e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
xappConn1.RecvSubsDelResp(t, deltrans1)
- //Wait that subs is cleaned
- //mainCtrl.wait_subs_clean(t, e2SubsId1, 10)
//Del2
deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
// | | | SubFail1 |
// | | |<-------------|
// | | | |
-// | | | SubDelReq |
-// | | |------------->|
-// | | | SubDelResp |
-// | | |<-------------|
-// | | | |
// | | SubFail1 | |
// | |<-------------| |
// | | | |
fparams1.Set(crereq1)
e2termConn1.SendSubsFail(t, fparams1, cremsg1)
- // E2t: internal delete
- delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
- e2termConn1.SendSubsDelResp(t, delreq, delmsg)
-
//Fail1
e2SubsId1 := xappConn1.RecvSubsFail(t, cretrans1)
//Fail2
func TestSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
CaseBegin("TestSubReqNokAndSubDelOkWithRestartInMiddle")
- // Remove possible existing subscrition
- mainCtrl.removeExistingSubscriptions(t)
-
mainCtrl.SetResetTestFlag(t, true) // subs.DoNotWaitSubResp will be set TRUE for the subscription
xappConn1.SendSubsReq(t, nil, nil)
e2termConn1.RecvSubsReq(t)
mainCtrl.SimulateRestart(t)
xapp.Logger.Debug("mainCtrl.SimulateRestart done")
+ // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
+ // That needs to be completed before successful subscription query is possible
+ <-time.After(time.Second * 1)
+
// Check that subscription is restored correctly after restart
resp, _ = xapp.Subscription.QuerySubscriptions()
assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId))
e2SubsId2 := xappConn2.RecvSubsResp(t, cretrans2)
// Check subscription
- resp, _ := xapp.Subscription.QuerySubscriptions() ////////////////////////////////
+ resp, _ := xapp.Subscription.QuerySubscriptions()
assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
assert.Equal(t, resp[0].Meid, "RAN_NAME_1")
assert.Equal(t, resp[0].ClientEndpoint, []string{"localhost:13560", "localhost:13660"})
mainCtrl.SimulateRestart(t)
xapp.Logger.Debug("mainCtrl.SimulateRestart done")
+ // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
+ // That needs to be completed before successful subscription query is possible
+ <-time.After(time.Second * 1)
+
// Check that subscription is restored correctly after restart
resp, _ = xapp.Subscription.QuerySubscriptions()
assert.Equal(t, resp[0].SubscriptionID, int64(e2SubsId1))
mainCtrl.SimulateRestart(t)
xapp.Logger.Debug("mainCtrl.SimulateRestart done")
+ // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
+ // Submgr need be ready before successful subscription deletion is possible
+ <-time.After(time.Second * 1)
+
//Del2
deltrans2 := xappConn2.SendSubsDelReq(t, nil, e2SubsId2)
delreq2, delmsg2 := e2termConn1.RecvSubsDelReq(t)
mainCtrl.wait_subs_clean(t, newSubsId, 10)
waitSubsCleanup(t, e2SubsId, 10)
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
func TestRESTSubReqAndRouteUpdateNok(t *testing.T) {
Counter{cRestSubNotifToXapp, 1},
Counter{cRestSubFailNotifToXapp, 1},
Counter{cRouteCreateUpdateFail, 1},
- Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cRestSubDelReqFromXapp, 2},
Counter{cSubDelReqToE2, 1},
Counter{cSubDelRespFromE2, 1},
- Counter{cRestSubDelRespToXapp, 1},
+ Counter{cRestSubDelRespToXapp, 2},
})
var params *teststube2ap.RESTSubsReqParams = nil
xapp.Logger.Debug("Send REST subscriber request for second subscriber : %v", restSubId2)
xappConn2.ExpectRESTNotificationNok(t, restSubId2, "allFail")
waiter.WaitResult(t)
- // e2SubsId2 := xappConn2.WaitRESTNotification(t, restSubId2) - TOD: missing delete
xappConn2.WaitRESTNotification(t, restSubId2)
queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
+ xappConn2.SendRESTSubsDelReq(t, &restSubId2)
mainCtrl.wait_subs_clean(t, newSubsId, 10)
//Wait that subs is cleaned
waitSubsCleanup(t, e2SubsId, 10)
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
func TestRESTSubDelReqAndRouteDeleteNok(t *testing.T) {
waiter.WaitResult(t)
waitSubsCleanup(t, e2SubsId, 10)
-
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
func TestRESTSubMergeDelAndRouteUpdateNok(t *testing.T) {
mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Counter{cRestSubReqFromXapp, 2},
+ Counter{cMergedSubscriptions, 1},
Counter{cRestSubRespToXapp, 2},
Counter{cSubReqToE2, 1},
Counter{cSubRespFromE2, 1},
Counter{cSubDelReqToE2, 1},
Counter{cSubDelRespFromE2, 1},
Counter{cRestSubDelRespToXapp, 2},
+ Counter{cUnmergedSubscriptions, 1},
})
var params *teststube2ap.RESTSubsReqParams = nil
deleteXapp2Subscription(t, &restSubId2)
waitSubsCleanup(t, e2SubsId2, 10)
-
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
// 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)
+ restSubId := xappConn1.SendRESTSubsReq(t, params)
- waiter.WaitResult(t)
+ xappConn1.SendRESTSubsReq(t, params)
+ <-time.After(time.Second * 1)
- xappConn1.WaitListedRestNotifications(t, []string{restSubId1})
+ xappConn1.WaitListedRestNotifications(t, []string{restSubId})
// Depending one goroutine scheduling order, we cannot say for sure which xapp reaches e2term first. Thus
- // the order is not significant he6re.
+ // the order is not significant here.
crereq, cremsg := e2termConn1.RecvSubsReq(t)
e2termConn1.SendSubsResp(t, crereq, cremsg)
- e2SubsIdA := <-xappConn1.ListedRESTNotifications
- xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
+ e2SubsId := <-xappConn1.ListedRESTNotifications
+
+ xapp.Logger.Debug("TEST: XAPP notification received e2SubsId=%v", e2SubsId)
// Del1
- xappConn1.SendRESTSubsDelReq(t, &restSubId1)
+ xappConn1.SendRESTSubsDelReq(t, &restSubId)
delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
- mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsIdA.E2SubsId}, 10)
+ mainCtrl.wait_multi_subs_clean(t, []uint32{e2SubsId.E2SubsId}, 10)
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Counter{cRestSubReqFromXapp, 3},
+ Counter{cDuplicateE2SubReq, 2},
Counter{cRestSubRespToXapp, 3},
Counter{cSubReqToE2, 1},
Counter{cSubRespFromE2, 1},
queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
+ mainCtrl.WaitOngoingRequestMapEmpty()
+
//1.st resend
restSubId_resend := xappConn1.SendRESTSubsReq(t, params)
assert.Equal(t, restSubId_resend, restSubId)
- <-time.After(100 * time.Millisecond)
+ mainCtrl.WaitOngoingRequestMapEmpty()
//2.nd resend
restSubId_resend2 := xappConn1.SendRESTSubsReq(t, params)
assert.Equal(t, restSubId_resend2, restSubId)
- <-time.After(100 * time.Millisecond)
+ mainCtrl.WaitOngoingRequestMapEmpty()
deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
waitSubsCleanup(t, e2SubsId, 10)
-
- //Wait that subs is cleaned
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Counter{cRestSubReqFromXapp, 3},
+ Counter{cDuplicateE2SubReq, 2},
Counter{cRestSubRespToXapp, 3},
Counter{cSubReqToE2, 1},
Counter{cSubRespFromE2, 1},
queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
- <-time.After(100 * time.Millisecond)
+ mainCtrl.WaitOngoingRequestMapEmpty()
//1.st resend with subscription ID
params.SetSubscriptionID(&restSubId)
assert.Equal(t, restSubId_resend, restSubId)
- <-time.After(100 * time.Millisecond)
+ mainCtrl.WaitOngoingRequestMapEmpty()
//2.nd resend without subscription ID (faking app restart)
params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
assert.Equal(t, restSubId_resend2, restSubId)
- <-time.After(100 * time.Millisecond)
+ mainCtrl.WaitOngoingRequestMapEmpty()
deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
waitSubsCleanup(t, e2SubsId, 10)
-
- //Wait that subs is cleaned
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Counter{cRestSubReqFromXapp, 3},
+ Counter{cDuplicateE2SubReq, 2},
Counter{cRestSubRespToXapp, 3},
Counter{cSubReqToE2, 2},
Counter{cSubRespFromE2, 2},
restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
- <-time.After(100 * time.Millisecond)
+ mainCtrl.WaitOngoingRequestMapEmpty()
// Send modified requst, this time with e2 subscriptions.
params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
assert.NotEqual(t, e2SubsId2, 0)
- <-time.After(100 * time.Millisecond)
+ mainCtrl.WaitOngoingRequestMapEmpty()
xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
assert.Equal(t, e2SubsId, e2SubsId1)
+ mainCtrl.WaitOngoingRequestMapEmpty()
+
// 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)
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Counter{cRestSubReqFromXapp, 3},
+ Counter{cDuplicateE2SubReq, 2},
Counter{cRestSubRespToXapp, 3},
Counter{cSubReqToE2, 2},
Counter{cSubRespFromE2, 2},
restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
- <-time.After(100 * time.Millisecond)
+ mainCtrl.WaitOngoingRequestMapEmpty()
- // Send modified requst, this time with e2 subscriptions.
+ // Send modified request, this time with e2 subscriptions.
params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
params2.SetSubscriptionID(&restSubId)
e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
assert.NotEqual(t, e2SubsId2, 0)
- <-time.After(100 * time.Millisecond)
+ mainCtrl.WaitOngoingRequestMapEmpty()
xapp.Subscription.SetResponseCB(xappConn1.SubscriptionRespHandler)
params = xappConn1.GetRESTSubsReqReportParams(subReqCount)
e2SubsId1 = xappConn1.WaitAnyRESTNotification(t)
assert.Equal(t, e2SubsId, e2SubsId1)
+ mainCtrl.WaitOngoingRequestMapEmpty()
+
// 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)
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Counter{cRestSubReqFromXapp, 3},
+ Counter{cDuplicateE2SubReq, 1},
Counter{cRestSubRespToXapp, 3},
Counter{cSubReqToE2, 3},
Counter{cSubRespFromE2, 3},
restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
- <-time.After(100 * time.Millisecond)
+ mainCtrl.WaitOngoingRequestMapEmpty()
// Send modified requst, this time with e2 subscriptions.
params2 := xappConn1.GetRESTSubsReqReportParams(subReqCount + 1)
e2SubsId2 := xappConn1.WaitRESTNotification(t, restSubId_resend)
assert.NotEqual(t, e2SubsId2, 0)
- <-time.After(100 * time.Millisecond)
+ mainCtrl.WaitOngoingRequestMapEmpty()
// Delete both e2 subscriptions
xappConn1.SendRESTSubsDelReq(t, &restSubId)
// fresh create.
restSubId, e2SubsId = createSubscription(t, xappConn1, e2termConn1, params)
- <-time.After(100 * time.Millisecond)
+ mainCtrl.WaitOngoingRequestMapEmpty()
deleteSubscription(t, xappConn1, e2termConn1, &restSubId)
waitSubsCleanup(t, e2SubsId, 10)
-
- //Wait that subs is cleaned
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
func TestRESTSubDelReqRetransmission(t *testing.T) {
Counter{cRestSubDelReqFromXapp, 2},
Counter{cSubDelReqToE2, 1},
Counter{cSubDelRespFromE2, 1},
- Counter{cRestSubDelRespToXapp, 1},
+ Counter{cRestSubDelRespToXapp, 2},
})
var params *teststube2ap.RESTSubsReqParams = nil
e2termConn1.SendSubsDelResp(t, delreq, delmsg)
waitSubsCleanup(t, e2SubsId, 10)
-
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
Counter{cSubRespFromE2, 1},
Counter{cRestSubNotifToXapp, 1},
Counter{cRestSubDelReqFromXapp, 2},
+ Counter{cRestSubDelFailToXapp, 1},
Counter{cSubDelReqToE2, 1},
Counter{cSubDelRespFromE2, 1},
Counter{cRestSubDelRespToXapp, 1},
// Wait that subs is cleaned
waitSubsCleanup(t, e2SubsId, 10)
mainCtrl.VerifyCounterValues(t)
-
+ mainCtrl.VerifyAllClean(t)
}
func TestRESTSubDelReqCollision(t *testing.T) {
waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
mainCtrl.VerifyCounterValues(t)
-
+ mainCtrl.VerifyAllClean(t)
}
func TestRESTSameSubsDiffRan(t *testing.T) {
waitSubsCleanup(t, e2SubsId2, 10)
mainCtrl.VerifyCounterValues(t)
-
+ mainCtrl.VerifyAllClean(t)
}
func TestRESTSubReqRetryInSubmgr(t *testing.T) {
Counter{cRestSubReqFromXapp, 1},
Counter{cRestSubRespToXapp, 1},
Counter{cSubReqToE2, 1},
+ Counter{cSubReqTimerExpiry, 1},
Counter{cSubReReqToE2, 1},
Counter{cSubRespFromE2, 1},
Counter{cRestSubNotifToXapp, 1},
waitSubsCleanup(t, e2SubsId, 10)
mainCtrl.VerifyCounterValues(t)
-
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
Counter{cSubReqToE2, 1},
Counter{cSubReReqToE2, 1},
Counter{cSubReqTimerExpiry, 2},
+ Counter{cRestSubFailNotifToXapp, 1},
Counter{cSubDelReqToE2, 1},
Counter{cSubDelRespFromE2, 1},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cRestSubDelRespToXapp, 1},
})
params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
e2termConn1.SendSubsDelResp(t, delreq, delmsg)
xappConn1.WaitRESTNotification(t, restSubId)
+ xappConn1.SendRESTSubsDelReq(t, &restSubId)
+
// Wait that subs is cleaned
waitSubsCleanup(t, delreq.RequestId.InstanceId, 10)
-
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
func TestREST2eTermNotRespondingToSubReq(t *testing.T) {
Counter{cSubReqToE2, 1},
Counter{cSubReReqToE2, 1},
Counter{cSubReqTimerExpiry, 2},
+ Counter{cSubDelReReqToE2, 1},
+ Counter{cRestSubFailNotifToXapp, 1},
Counter{cSubDelReqToE2, 1},
Counter{cSubDelReqTimerExpiry, 2},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cRestSubDelRespToXapp, 1},
})
params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
- waitSubsCleanup(t, e2SubsId, 10)
+ xappConn1.SendRESTSubsDelReq(t, &restSubId)
+ waitSubsCleanup(t, e2SubsId, 10)
mainCtrl.VerifyCounterValues(t)
-
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
Counter{cSubReqToE2, 1},
Counter{cSubReReqToE2, 1},
Counter{cSubReqTimerExpiry, 2},
+ Counter{cRestSubFailNotifToXapp, 1},
Counter{cSubDelReqToE2, 1},
Counter{cSubDelReReqToE2, 1},
Counter{cSubDelReqTimerExpiry, 2},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cRestSubDelRespToXapp, 1},
})
params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
- waitSubsCleanup(t, e2SubsId, 10)
+ xappConn1.SendRESTSubsDelReq(t, &restSubId)
+ waitSubsCleanup(t, e2SubsId, 10)
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
// | | SubFail |
// | |<-------------|
// | | |
-// | | SubDelReq |
-// | |------------->|
-// | | |
-// | | SubDelResp |
-// | |<-------------|
-// | | |
// | RESTNotif | |
// | unsuccess | |
// |<----------------| |
Counter{cSubFailFromE2, 1},
Counter{cRestSubFailNotifToXapp, 1},
Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cRestSubDelRespToXapp, 1},
})
const subReqCount int = 1
crereq1, cremsg1 := e2termConn1.RecvSubsReq(t)
fparams1 := &teststube2ap.E2StubSubsFailParams{}
fparams1.Set(crereq1)
+ xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
e2termConn1.SendSubsFail(t, fparams1, cremsg1)
- delreq1, delmsg1 := e2termConn1.RecvSubsDelReq(t)
- xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
- e2termConn1.SendSubsDelResp(t, delreq1, delmsg1)
e2SubsId := xappConn1.WaitRESTNotification(t, restSubId)
xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
waitSubsCleanup(t, e2SubsId, 10)
mainCtrl.VerifyCounterValues(t)
-
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
Counter{cRestSubNotifToXapp, 1},
Counter{cRestSubDelReqFromXapp, 1},
Counter{cSubDelReqToE2, 1},
+ Counter{cSubDelReqTimerExpiry, 1},
Counter{cSubDelReReqToE2, 1},
Counter{cSubDelRespFromE2, 1},
Counter{cRestSubDelRespToXapp, 1},
waitSubsCleanup(t, e2SubsId, 10)
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
Counter{cRestSubNotifToXapp, 1},
Counter{cRestSubDelReqFromXapp, 1},
Counter{cSubDelReqToE2, 1},
+ Counter{cSubDelReqTimerExpiry, 1},
Counter{cSubDelReReqToE2, 1},
Counter{cSubDelRespFromE2, 1},
Counter{cRestSubDelRespToXapp, 1},
waitSubsCleanup(t, e2SubsId, 10)
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
waitSubsCleanup(t, e2SubsId, 10)
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
//Wait that subs is cleaned
waitSubsCleanup(t, e2SubsId2, 10)
-
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
e2termConn1.SendSubsDelResp(t, delreq2, delmsg2)
waitSubsCleanup(t, e2SubsId2, 10)
-
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
// | RESTSubReq2 | |
// |------------------------------>| |
// | | | |
-// | RESTSubDelResp2 | |
+// | RESTSubResp2 | |
// |<------------------------------| |
// | | | SubReq1 |
// | | |------------->|
mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Counter{cRestSubReqFromXapp, 2},
+ Counter{cMergedSubscriptions, 1},
Counter{cRestSubRespToXapp, 2},
Counter{cSubReqToE2, 1},
+ Counter{cSubReqTimerExpiry, 2},
+ Counter{cSubReReqToE2, 1},
Counter{cRestSubFailNotifToXapp, 2},
+ Counter{cUnmergedSubscriptions, 1},
Counter{cRestSubDelReqFromXapp, 2},
Counter{cSubDelReqToE2, 1},
Counter{cSubDelRespFromE2, 1},
Counter{cRestSubDelRespToXapp, 2},
})
-
const subReqCount int = 1
// Req1
//Wait that subs is cleaned
waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
-
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
// | RESTNotif2 | |
// | | unsuccess | |
// |<------------------------------| |
-// | | | SubDelReq |
-// | | |------------->|
-// | | | SubDelResp |
-// | | |<-------------|
// | | | |
-// | | RESTSubDelReq1 | |
+// | | RESTSubDelReq1 | | There is no need for xApp to send delete for failed subscriptions but some xApp might do so.
// | |---------------->| |
// | | | |
// | | RESTSubDelResp1 | |
mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
Counter{cRestSubReqFromXapp, 2},
+ Counter{cMergedSubscriptions, 1},
Counter{cRestSubRespToXapp, 2},
Counter{cSubReqToE2, 1},
Counter{cSubFailFromE2, 1},
Counter{cRestSubFailNotifToXapp, 2},
+ Counter{cUnmergedSubscriptions, 1},
Counter{cRestSubDelReqFromXapp, 2},
- Counter{cSubDelReqToE2, 1},
- Counter{cSubDelRespFromE2, 1},
Counter{cRestSubDelRespToXapp, 2},
})
fparams1.Set(crereq1)
e2termConn1.SendSubsFail(t, fparams1, cremsg1)
- // E2t: internal delete
- delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
xappConn1.WaitListedRestNotifications(t, []string{restSubId1, restSubId2})
- e2termConn1.SendSubsDelResp(t, delreq, delmsg)
-
e2SubsIdA := <-xappConn1.ListedRESTNotifications
xapp.Logger.Debug("TEST: 1.st XAPP notification received e2SubsId=%v", e2SubsIdA)
e2SubsIdB := <-xappConn1.ListedRESTNotifications
//Wait that subs is cleaned
waitSubsCleanup(t, e2SubsIdA.E2SubsId, 10)
waitSubsCleanup(t, e2SubsIdB.E2SubsId, 10)
-
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
func TestRESTSubReqPolicyAndSubDelOk(t *testing.T) {
// Wait that subs is cleaned
waitSubsCleanup(t, e2SubsId, 10)
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
// Wait that subs is cleaned
waitSubsCleanup(t, e2SubsId, 10)
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
// Wait that subs is cleaned
waitSubsCleanup(t, e2SubsId, 10)
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
waitSubsCleanup(t, e2SubsId2, 10)
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
// Wait that subs is cleaned
waitSubsCleanup(t, e2SubsId, 10)
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
// | RESTSubReq | |
// |------------->| |
// | | |
+// | RESTSubResp | |
+// |<-------------| |
// | | SubReq |
// | |------------->|
// | | |
// | | SubDelResp |
// | |<-------------|
// | | |
+// | RESTNotif | |
+// | unsuccess | |
+// |<-------------| |
+// | | |
+// | RESTSubDelReq| |
+// |------------->| |
+// | | |
+// |RESTSubDelResp| |
+// |<-------------| |
//
//-----------------------------------------------------------------------------
func TestRESTSubReqNokAndSubDelOkWithRestartInMiddle(t *testing.T) {
Counter{cSubDelReqFromXapp, 1},
Counter{cSubDelReqToE2, 1},
Counter{cSubDelRespFromE2, 1},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cRestSubDelRespToXapp, 1},
})
const subReqCount int = 1
- // Remove possible existing subscription
- mainCtrl.removeExistingSubscriptions(t)
-
params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
//Req
mainCtrl.SimulateRestart(t)
xapp.Logger.Debug("mainCtrl.SimulateRestart done")
- //Del
+ // Deleletion of uncompleted subscription
delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
e2termConn1.SendSubsDelResp(t, delreq, delmsg)
+ //Del
+ xappConn1.SendRESTSubsDelReq(t, &restSubId)
+
xappConn1.TestMsgChanEmpty(t)
- xappConn2.TestMsgChanEmpty(t)
e2termConn1.TestMsgChanEmpty(t)
mainCtrl.wait_registry_empty(t, 10)
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
Counter{cRestSubNotifToXapp, 1},
Counter{cRestSubDelReqFromXapp, 1},
Counter{cSubDelReqToE2, 1},
+ Counter{cSubDelRespFromE2, 1},
Counter{cRestSubDelRespToXapp, 1},
})
- // Remove possible existing subscription
- mainCtrl.removeExistingSubscriptions(t)
-
- var params *teststube2ap.RESTSubsReqParams = nil
-
// Create subscription
+ var params *teststube2ap.RESTSubsReqParams = nil
restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
xapp.Logger.Debug("Send REST subscriber request for subscriber : %v", restSubId)
mainCtrl.SimulateRestart(t)
xapp.Logger.Debug("mainCtrl.SimulateRestart done")
+ // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
+ // That needs to be completed before successful subscription query is possible
+ <-time.After(time.Second * 1)
+
// Check subscription
queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
waitSubsCleanup(t, e2SubsId, 10)
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
// | | | |
//
//-----------------------------------------------------------------------------
-
func TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle(t *testing.T) {
CaseBegin("TestRESTSubReqAndSubDelOkSameActionWithRestartsInMiddle")
Counter{cRestSubDelRespToXapp, 2},
})
- // Remove possible existing subscription
- mainCtrl.removeExistingSubscriptions(t)
-
- var params *teststube2ap.RESTSubsReqParams = nil
-
// Create subscription 1
+ var params *teststube2ap.RESTSubsReqParams = nil
restSubId1, e2SubsId1 := createSubscription(t, xappConn1, e2termConn1, params)
xapp.Logger.Debug("Send REST subscriber request for subscriber 1 : %v", restSubId1)
queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13560", "localhost:13660"})
mainCtrl.SimulateRestart(t)
- xapp.Logger.Debug("mainCtrl.SimulateRestart done")
+ xapp.Logger.Debug("mainCtrl.SimulateRestart done 1")
+
+ // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
+ // That needs to be completed before successful subscription delete is possible
+ <-time.After(time.Second * 1)
// Delete subscription 1, and wait until it has removed the first endpoint
- subepcnt := mainCtrl.get_subs_entrypoint_cnt(t, e2SubsId1)
xappConn1.SendRESTSubsDelReq(t, &restSubId1)
- mainCtrl.wait_subs_entrypoint_cnt_change(t, e2SubsId1, subepcnt, 10)
+ mainCtrl.WaitRESTSubscriptionDelete(restSubId1)
+ // Above wait does not work correctly anymore as this delay makes this test case work
mainCtrl.SimulateRestart(t)
- xapp.Logger.Debug("mainCtrl.SimulateRestart done")
+ xapp.Logger.Debug("mainCtrl.SimulateRestart done 2")
+
+ // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
+ // That needs to be completed before successful subscription query is possible
+ <-time.After(time.Second * 1)
+
queryXappSubscription(t, int64(e2SubsId1), "RAN_NAME_1", []string{"localhost:13660"})
// Delete subscription 2
waitSubsCleanup(t, e2SubsId2, 10)
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
// | RESTSubDelReq | |
// |---------------->| |
// | | |
+// | RESTSubDelResp| |
+// |<----------------| |
// | | SubDelReq |
// | |------------->|
// | | |
// | | SubDelResp |
// | |<-------------|
// | | |
-// | RESTSubDelResp| |
-// |<----------------| |
//
//-----------------------------------------------------------------------------
func RESTReportSubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
xapp.Logger.Debug("TEST: TestRESTReportSubReqAndSubDelOk with testIndex %v", testIndex)
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cRestSubReqFromXapp, 1},
+ Counter{cRestSubRespToXapp, 1},
+ Counter{cSubReqToE2, uint64(subReqCount)},
+ Counter{cSubRespFromE2, uint64(subReqCount)},
+ Counter{cRestSubNotifToXapp, 1},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cRestSubDelRespToXapp, 1},
+ Counter{cSubDelReqToE2, uint64(subReqCount)},
+ Counter{cSubDelRespFromE2, uint64(subReqCount)},
+ })
+
// Req
params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
restSubId := xappConn1.SendRESTSubsReq(t, params)
xappConn1.TestMsgChanEmpty(t)
e2termConn1.TestMsgChanEmpty(t)
mainCtrl.wait_registry_empty(t, 10)
+ mainCtrl.VerifyAllClean(t)
+ mainCtrl.VerifyCounterValues(t)
}
/*
-func TestRESTPolicySubReqAndSubDelOk(t *testing.T) {
+func TestRESTPolicySubReqAndSubDelOk(t *testing.T) { //Was in comments already. Next case is not run!
CaseBegin("TestRESTPolicySubReqAndSubDelOk")
subReqCount := 2
func RESTPolicySubReqAndSubDelOk(t *testing.T, subReqCount int, testIndex int) {
xapp.Logger.Debug("TEST: TestRESTPolicySubReqAndSubDelOk with testIndex %v", testIndex)
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cRestSubReqFromXapp, 1},
+ Counter{cRestSubRespToXapp, 1},
+ Counter{cSubReqToE2, uint64(subReqCount)},
+ Counter{cSubRespFromE2, uint64(subReqCount)},
+ Counter{cRestSubNotifToXapp, 1},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cRestSubDelRespToXapp, 1},
+ Counter{cSubDelReqToE2, uint64(subReqCount)},
+ Counter{cSubDelRespFromE2, uint64(subReqCount)},
+ })
+
// Req
params := xappConn1.GetRESTSubsReqPolicyParams(subReqCount)
restSubId := xappConn1.SendRESTSubsReq(t, params)
xappConn1.TestMsgChanEmpty(t)
e2termConn1.TestMsgChanEmpty(t)
mainCtrl.wait_registry_empty(t, 10)
+ mainCtrl.VerifyAllClean(t)
+ mainCtrl.VerifyCounterValues(t)
}
func TestRESTTwoPolicySubReqAndSubDelOk(t *testing.T) {
mainCtrl.wait_registry_empty(t, 10)
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
func TestRESTPolicySubReqAndSubDelOkFullAmount(t *testing.T) {
mainCtrl.wait_registry_empty(t, 10)
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
func TestRESTTwoReportSubReqAndSubDelOk(t *testing.T) {
mainCtrl.wait_registry_empty(t, 10)
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
func TestRESTTwoReportSubReqAndSubDelOkNoActParams(t *testing.T) {
mainCtrl.wait_registry_empty(t, 10)
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
func TestRESTFullAmountReportSubReqAndSubDelOk(t *testing.T) {
mainCtrl.wait_registry_empty(t, 10)
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
func TestRESTSubReqReportSameActionDiffEventTriggerDefinitionLen(t *testing.T) {
waitSubsCleanup(t, e2SubsId2, 10)
mainCtrl.VerifyCounterValues(t)
-
+ mainCtrl.VerifyAllClean(t)
}
func TestRESTSubReqReportSameActionDiffActionListLen(t *testing.T) {
waitSubsCleanup(t, e2SubsId2, 10)
mainCtrl.VerifyCounterValues(t)
-
+ mainCtrl.VerifyAllClean(t)
}
func TestRESTSubReqReportSameActionDiffActionID(t *testing.T) {
waitSubsCleanup(t, e2SubsId2, 10)
mainCtrl.VerifyCounterValues(t)
-
+ mainCtrl.VerifyAllClean(t)
}
func TestRESTSubReqDiffActionType(t *testing.T) {
waitSubsCleanup(t, e2SubsId2, 10)
mainCtrl.VerifyCounterValues(t)
-
+ mainCtrl.VerifyAllClean(t)
}
func TestRESTSubReqPolicyAndSubDelOkSameAction(t *testing.T) {
waitSubsCleanup(t, e2SubsId2, 10)
mainCtrl.VerifyCounterValues(t)
-
+ mainCtrl.VerifyAllClean(t)
}
func TestRESTSubReqReportSameActionDiffActionDefinitionLen(t *testing.T) {
waitSubsCleanup(t, e2SubsId2, 10)
mainCtrl.VerifyCounterValues(t)
-
+ mainCtrl.VerifyAllClean(t)
}
func TestRESTSubReqReportSameActionDiffActionDefinitionContents(t *testing.T) {
waitSubsCleanup(t, e2SubsId2, 10)
mainCtrl.VerifyCounterValues(t)
-
+ mainCtrl.VerifyAllClean(t)
}
func TestRESTSubReqReportSameActionDiffSubsAction(t *testing.T) {
waitSubsCleanup(t, e2SubsId2, 10)
mainCtrl.VerifyCounterValues(t)
-
+ mainCtrl.VerifyAllClean(t)
}
//-----------------------------------------------------------------------------
// | |------------->|
// | | |
// | | SubResp | ASN.1 decode fails
-// | |<-------------|
+// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
// | | |
// | | SubReq |
// | |------------->|
// | |<-------------|
// | RESTNotif (fail)| |
// |<----------------| |
-// | | SubDelReq |
-// | |------------->|
// | | |
-// | | SubDelResp |
-// | |<-------------|
+// | [SUBS DELETE] |
+// | | |
//
//-----------------------------------------------------------------------------
func TestRESTUnpackSubscriptionResponseDecodeFail(t *testing.T) {
xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseDecodeFail")
+
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cRestSubReqFromXapp, 1},
+ Counter{cRestSubRespToXapp, 1},
+ Counter{cSubReqToE2, 1},
+ Counter{cSubReqTimerExpiry, 1},
+ Counter{cSubReReqToE2, 1},
+ Counter{cSubRespFromE2, 1},
+ Counter{cSubFailFromE2, 1},
+ Counter{cRestSubFailNotifToXapp, 1},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cRestSubDelRespToXapp, 1},
+ })
+
const subReqCount int = 1
// Req
fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
e2termConn1.SendSubsFail(t, fparams, cremsg)
- delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
- e2termConn1.SendSubsDelResp(t, delreq, delmsg)
-
instanceId := xappConn1.WaitRESTNotification(t, restSubId)
xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
+ xappConn1.SendRESTSubsDelReq(t, &restSubId)
+
// Wait that subs is cleaned
mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
xappConn1.TestMsgChanEmpty(t)
e2termConn1.TestMsgChanEmpty(t)
mainCtrl.wait_registry_empty(t, 10)
+ mainCtrl.VerifyAllClean(t)
+ mainCtrl.VerifyCounterValues(t)
}
//-----------------------------------------------------------------------------
// | |------------->|
// | | |
// | | SubResp | Unknown instanceId
-// | |<-------------|
+// | |<-------------| No valid subscription found with subIds [0]
// | | |
// | | SubReq |
// | |------------->|
// | | |
// | | SubFail | Duplicated action
-// | |<-------------|
+// | |<-------------| No valid subscription found with subIds [0]
// | RESTNotif (fail)| |
// |<----------------| |
// | | SubDelReq |
// | | |
// | | SubDelResp |
// | |<-------------|
+// | | |
+// | [SUBS DELETE] |
+// | | |
//
//-----------------------------------------------------------------------------
func TestRESTUnpackSubscriptionResponseUnknownInstanceId(t *testing.T) {
xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseUnknownInstanceId")
+
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cRestSubReqFromXapp, 1},
+ Counter{cRestSubRespToXapp, 1},
+ Counter{cSubReqToE2, 1},
+ Counter{cSubReqTimerExpiry, 2},
+ Counter{cSubReReqToE2, 1},
+ Counter{cSubRespFromE2, 1},
+ Counter{cSubFailFromE2, 1},
+ Counter{cRestSubFailNotifToXapp, 1},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cRestSubDelRespToXapp, 1},
+ Counter{cSubDelReqToE2, 1},
+ Counter{cSubDelRespFromE2, 1},
+ })
+
const subReqCount int = 1
// Req
crereq, cremsg := e2termConn1.RecvSubsReq(t)
- // Unknown instanceId in this response which will result resending original request
+ // Unknown instanceId 0 in this response which will result resending original request
orgInstanceId := crereq.RequestId.InstanceId
crereq.RequestId.InstanceId = 0
e2termConn1.SendSubsResp(t, crereq, cremsg)
xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
- // Subscription already created in E2 Node.
+ // Subscription already created in E2 Node. E2 Node responds with failure but there is also same unknown instanceId 0
fparams := &teststube2ap.E2StubSubsFailParams{}
fparams.Set(crereq)
fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
instanceId := xappConn1.WaitRESTNotification(t, restSubId)
xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
+ xappConn1.SendRESTSubsDelReq(t, &restSubId)
+
// Wait that subs is cleaned
mainCtrl.wait_subs_clean(t, orgInstanceId, 10)
xappConn1.TestMsgChanEmpty(t)
e2termConn1.TestMsgChanEmpty(t)
mainCtrl.wait_registry_empty(t, 10)
+ mainCtrl.VerifyAllClean(t)
+ mainCtrl.VerifyCounterValues(t)
}
//-----------------------------------------------------------------------------
// | |------------->|
// | | |
// | | SubResp | No transaction for the response
-// | |<-------------|
+// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
// | | |
// | | SubReq |
// | |------------->|
// | | |
// | | SubFail | Duplicated action
-// | |<-------------|
+// | |<-------------|Ongoing transaction not found. This will result timer expiry and sending delete
// | RESTNotif (fail)| |
// |<----------------| |
// | | SubDelReq |
// | |------------->|
// | | |
// | | SubDelResp |
-// | |<-------------|
+// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
// | | |
// | | SubDelReq |
// | |------------->|
// | | |
// | | SubDelResp |
-// | |<-------------|
+// | |<-------------| Ongoing transaction not found.
+// | | |
+// | [SUBS DELETE] |
+// | | |
//
//-----------------------------------------------------------------------------
func TestRESTUnpackSubscriptionResponseNoTransaction(t *testing.T) {
xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionResponseNoTransaction")
+
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cRestSubReqFromXapp, 1},
+ Counter{cRestSubRespToXapp, 1},
+ Counter{cSubReqToE2, 1},
+ Counter{cSubReqTimerExpiry, 2},
+ Counter{cSubReReqToE2, 1},
+ Counter{cSubRespFromE2, 1},
+ Counter{cSubFailFromE2, 1},
+ Counter{cRestSubFailNotifToXapp, 1},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cRestSubDelRespToXapp, 1},
+ Counter{cSubDelReqToE2, 1},
+ Counter{cSubDelReqTimerExpiry, 2},
+ Counter{cSubDelReReqToE2, 1},
+ Counter{cSubDelRespFromE2, 2},
+ })
+
const subReqCount int = 1
// Req
instanceId := xappConn1.WaitRESTNotification(t, restSubId)
xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
+ xappConn1.SendRESTSubsDelReq(t, &restSubId)
+
// Wait that subs is cleaned
mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
xappConn1.TestMsgChanEmpty(t)
e2termConn1.TestMsgChanEmpty(t)
mainCtrl.wait_registry_empty(t, 10)
-
+ mainCtrl.VerifyAllClean(t)
+ mainCtrl.VerifyCounterValues(t)
}
//-----------------------------------------------------------------------------
// | |------------->|
// | | |
// | | SubFail | ASN.1 decode fails
-// | |<-------------|
+// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
// | | |
// | | SubReq |
// | |------------->|
// | |<-------------|
// | RESTNotif (fail)| |
// |<----------------| |
-// | | SubDelReq |
-// | |------------->|
// | | |
-// | | SubDelResp |
-// | |<-------------|
+// | [SUBS DELETE] |
+// | | |
//
//-----------------------------------------------------------------------------
func TestRESTUnpackSubscriptionFailureDecodeFail(t *testing.T) {
xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureDecodeFail")
+
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cRestSubReqFromXapp, 1},
+ Counter{cRestSubRespToXapp, 1},
+ Counter{cSubReqToE2, 1},
+ Counter{cSubReqTimerExpiry, 1},
+ Counter{cSubReReqToE2, 1},
+ Counter{cSubFailFromE2, 2},
+ Counter{cRestSubFailNotifToXapp, 1},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cRestSubDelRespToXapp, 1},
+ })
+
const subReqCount int = 1
// Req
fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
e2termConn1.SendSubsFail(t, fparams, cremsg)
- delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
- e2termConn1.SendSubsDelResp(t, delreq, delmsg)
-
instanceId := xappConn1.WaitRESTNotification(t, restSubId)
xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
+ xappConn1.SendRESTSubsDelReq(t, &restSubId)
+
// Wait that subs is cleaned
mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
xappConn1.TestMsgChanEmpty(t)
e2termConn1.TestMsgChanEmpty(t)
mainCtrl.wait_registry_empty(t, 10)
+ mainCtrl.VerifyAllClean(t)
+ mainCtrl.VerifyCounterValues(t)
}
//-----------------------------------------------------------------------------
// | |------------->|
// | | |
// | | SubFail | Unknown instanceId
-// | |<-------------|
+// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
// | | |
// | | SubReq |
// | |------------->|
// | | |
// | | SubFail | Duplicated action
-// | |<-------------|
+// | |<-------------|No valid subscription found with subIds [0]. This will result timer expiry and sending delete
// | RESTNotif (fail)| |
// |<----------------| |
// | | SubDelReq |
// | | |
// | | SubDelResp |
// | |<-------------|
+// | | |
+// | [SUBS DELETE] |
+// | | |
//
//-----------------------------------------------------------------------------
func TestRESTUnpackSubscriptionFailureUnknownInstanceId(t *testing.T) {
xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureUnknownInstanceId")
const subReqCount int = 1
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cRestSubReqFromXapp, 1},
+ Counter{cRestSubRespToXapp, 1},
+ Counter{cSubReqToE2, 1},
+ Counter{cSubReqTimerExpiry, 2},
+ Counter{cSubReReqToE2, 1},
+ Counter{cSubFailFromE2, 2},
+ Counter{cRestSubFailNotifToXapp, 1},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cRestSubDelRespToXapp, 1},
+ Counter{cSubDelReqToE2, 1},
+ Counter{cSubDelRespFromE2, 1},
+ })
+
// Req
params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
restSubId := xappConn1.SendRESTSubsReq(t, params)
crereq, cremsg := e2termConn1.RecvSubsReq(t)
- // Unknown instanceId in this response which will result resending original request
+ // Unknown instanceId 0 in this response which will result resending original request
fparams := &teststube2ap.E2StubSubsFailParams{}
fparams.Set(crereq)
fparams.Fail.RequestId.InstanceId = 0
xappConn1.ExpectRESTNotificationNok(t, restSubId, "allFail")
- // Subscription already created in E2 Node.
+ // Subscription already created in E2 Node. E2 Node responds with failure but there is also same unknown instanceId 0
fparams.SetCauseVal(0, 1, 3) // CauseRIC / duplicate-action
e2termConn1.SendSubsFail(t, fparams, cremsg)
instanceId := xappConn1.WaitRESTNotification(t, restSubId)
xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
+ xappConn1.SendRESTSubsDelReq(t, &restSubId)
+
// Wait that subs is cleaned
mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
xappConn1.TestMsgChanEmpty(t)
e2termConn1.TestMsgChanEmpty(t)
mainCtrl.wait_registry_empty(t, 10)
+ mainCtrl.VerifyAllClean(t)
+ mainCtrl.VerifyCounterValues(t)
}
//-----------------------------------------------------------------------------
// | |------------->|
// | | |
// | | SubFail | No transaction for the response
-// | |<-------------|
+// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
// | | |
// | | SubReq |
// | |------------->|
// | | |
// | | SubFail | Duplicated action
-// | |<-------------|
+// | |<-------------| Ongoing transaction not found. This will result timer expiry and sending delete
// | RESTNotif (fail)| |
// |<----------------| |
// | | SubDelReq |
// | |------------->|
// | | |
// | | SubDelResp |
-// | |<-------------|
+// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
+// | | |
+// | | SubDelReq |
+// | |------------->|
+// | | |
+// | | SubDelResp |
+// | |<-------------| Ongoing transaction not found.
+// | | |
+// | [SUBS DELETE] |
+// | | |
//
//-----------------------------------------------------------------------------
func TestRESTUnpackSubscriptionFailureNoTransaction(t *testing.T) {
xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionFailureNoTransaction")
const subReqCount int = 1
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cRestSubReqFromXapp, 1},
+ Counter{cRestSubRespToXapp, 1},
+ Counter{cSubReqToE2, 1},
+ Counter{cSubReqTimerExpiry, 2},
+ Counter{cSubReReqToE2, 1},
+ Counter{cSubFailFromE2, 2},
+ Counter{cRestSubFailNotifToXapp, 1},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cRestSubDelRespToXapp, 1},
+ Counter{cSubDelReqToE2, 1},
+ Counter{cSubDelReqTimerExpiry, 2},
+ Counter{cSubDelReReqToE2, 1},
+ Counter{cSubDelRespFromE2, 2},
+ })
+
// Req
params := xappConn1.GetRESTSubsReqReportParams(subReqCount)
restSubId := xappConn1.SendRESTSubsReq(t, params)
instanceId := xappConn1.WaitRESTNotification(t, restSubId)
xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", instanceId)
+ xappConn1.SendRESTSubsDelReq(t, &restSubId)
+
// Wait that subs is cleaned
mainCtrl.wait_subs_clean(t, crereq.RequestId.InstanceId, 10)
xappConn1.TestMsgChanEmpty(t)
e2termConn1.TestMsgChanEmpty(t)
mainCtrl.wait_registry_empty(t, 10)
+ mainCtrl.VerifyAllClean(t)
+ mainCtrl.VerifyCounterValues(t)
}
//-----------------------------------------------------------------------------
// | | SubDelReq |
// | |------------->|
// | | |
-// | | SubDelResp | ASN.1 decode fails
-// | |<-------------|
+// | | SubDelResp | ASN.1 decode fails.
+// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
// | | |
// | | SubDelReq |
// | |------------->|
// | | |
-// | | SubDelFail | Subscription does exist any more
+// | | SubDelFail | Subscription does exist any more in E2 node
// | |<-------------|
// | | |
+// | [SUBS DELETE] |
+// | | |
//
//-----------------------------------------------------------------------------
func TestRESTUnpackSubscriptionDeleteResponseDecodeFail(t *testing.T) {
xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseDecodeFail")
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cRestSubReqFromXapp, 1},
+ Counter{cRestSubRespToXapp, 1},
+ Counter{cSubReqToE2, 1},
+ Counter{cSubRespFromE2, 1},
+ Counter{cRestSubNotifToXapp, 1},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cRestSubDelRespToXapp, 1},
+ Counter{cSubDelReqToE2, 1},
+ Counter{cSubDelReqTimerExpiry, 1},
+ Counter{cSubDelReReqToE2, 1},
+ Counter{cSubDelFailFromE2, 1},
+ Counter{cSubDelRespFromE2, 1},
+ })
+
// Req
var params *teststube2ap.RESTSubsReqParams = nil
restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
// Decode of this response fails which will result resending original request
- e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_REQ)
+ e2termConn1.SendInvalidE2Asn1Resp(t, delmsg, xapp.RIC_SUB_DEL_RESP)
// E2t: Receive 2nd SubsDelReq and send SubsDelResp
delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
xappConn1.TestMsgChanEmpty(t)
e2termConn1.TestMsgChanEmpty(t)
mainCtrl.wait_registry_empty(t, 10)
+ mainCtrl.VerifyAllClean(t)
+ mainCtrl.VerifyCounterValues(t)
}
//-----------------------------------------------------------------------------
// | |------------->|
// | | |
// | | SubDelResp | Unknown instanceId
-// | |<-------------|
+// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
// | | |
// | | SubDelReq |
// | |------------->|
// | | |
-// | | SubDelFail | Subscription does exist any more
+// | | SubDelFail | Subscription does exist any more in E2 node
// | |<-------------|
-//
+// | | |
+// | [SUBS DELETE] |
+// | | |
//-----------------------------------------------------------------------------
func TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId(t *testing.T) {
xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseUnknownInstanceId")
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cRestSubReqFromXapp, 1},
+ Counter{cRestSubRespToXapp, 1},
+ Counter{cSubReqToE2, 1},
+ Counter{cSubRespFromE2, 1},
+ Counter{cRestSubNotifToXapp, 1},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cRestSubDelRespToXapp, 1},
+ Counter{cSubDelReqToE2, 1},
+ Counter{cSubDelReqTimerExpiry, 1},
+ Counter{cSubDelReReqToE2, 1},
+ Counter{cSubDelRespFromE2, 1},
+ Counter{cSubDelFailFromE2, 1},
+ })
+
// Req
var params *teststube2ap.RESTSubsReqParams = nil
restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
xappConn1.TestMsgChanEmpty(t)
e2termConn1.TestMsgChanEmpty(t)
mainCtrl.wait_registry_empty(t, 10)
+ mainCtrl.VerifyAllClean(t)
+ mainCtrl.VerifyCounterValues(t)
}
//-----------------------------------------------------------------------------
// | |------------->|
// | | |
// | | SubDelResp | No transaction for the response
-// | |<-------------|
+// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
// | | |
// | | SubDelReq |
// | |------------->|
// | | |
-// | | SubDelFail | Subscription does exist any more
-// | |<-------------|
-//
+// | | SubDelFail | Subscription does exist any more in E2 node
+// | |<-------------| Ongoing transaction not found. This will result timer expiry
+// | | |
+// | [SUBS DELETE] |
+// | | |
//-----------------------------------------------------------------------------
func TestRESTUnpackSubscriptionDeleteResponseNoTransaction(t *testing.T) {
xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteResponseNoTransaction")
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cRestSubReqFromXapp, 1},
+ Counter{cRestSubRespToXapp, 1},
+ Counter{cSubReqToE2, 1},
+ Counter{cSubRespFromE2, 1},
+ Counter{cRestSubNotifToXapp, 1},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cRestSubDelRespToXapp, 1},
+ Counter{cSubDelReqToE2, 1},
+ Counter{cSubDelReqTimerExpiry, 2},
+ Counter{cSubDelReReqToE2, 1},
+ Counter{cSubDelRespFromE2, 1},
+ Counter{cSubDelFailFromE2, 1},
+ })
+
// Req
var params *teststube2ap.RESTSubsReqParams = nil
restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
xappConn1.TestMsgChanEmpty(t)
e2termConn1.TestMsgChanEmpty(t)
mainCtrl.wait_registry_empty(t, 10)
+ mainCtrl.VerifyAllClean(t)
+ mainCtrl.VerifyCounterValues(t)
}
//-----------------------------------------------------------------------------
// | |------------->|
// | | |
// | | SubDelFail | ASN.1 decode fails
-// | |<-------------|
+// | |<-------------| Decode failed. More data needed. This will result timer expiry and resending
// | | |
// | | SubDelReq |
// | |------------->|
// | | |
-// | | SubDelFail | Subscription does exist any more
+// | | SubDelFail | Subscription does exist any more in E2 node
// | |<-------------|
-//
+// | | |
+// | [SUBS DELETE] |
+// | | |
//-----------------------------------------------------------------------------
func TestRESTUnpackSubscriptionDeleteFailureDecodeFail(t *testing.T) {
xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteFailureDecodeFail")
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cRestSubReqFromXapp, 1},
+ Counter{cRestSubRespToXapp, 1},
+ Counter{cSubReqToE2, 1},
+ Counter{cSubRespFromE2, 1},
+ Counter{cRestSubNotifToXapp, 1},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cRestSubDelRespToXapp, 1},
+ Counter{cSubDelReqToE2, 1},
+ Counter{cSubDelReqTimerExpiry, 1},
+ Counter{cSubDelReReqToE2, 1},
+ Counter{cSubDelFailFromE2, 2},
+ })
+
// Req
var params *teststube2ap.RESTSubsReqParams = nil
restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
xappConn1.TestMsgChanEmpty(t)
e2termConn1.TestMsgChanEmpty(t)
mainCtrl.wait_registry_empty(t, 10)
+ mainCtrl.VerifyAllClean(t)
+ mainCtrl.VerifyCounterValues(t)
}
//-----------------------------------------------------------------------------
// | |------------->|
// | | |
// | | SubDelFail | Unknown instanceId
-// | |<-------------|
+// | |<-------------| No valid subscription found with subIds [0]. This will result timer expiry and resending
// | | |
// | | SubDelReq |
// | |------------->|
// | | |
-// | | SubDelFail | Subscription does exist any more
-// | |<-------------|
-//
+// | | SubDelFail | Subscription does exist any more in E2 node
+// | |<-------------| No valid subscription found with subIds [0].
+// | | |
+// | [SUBS DELETE] |
+// | | |
//-----------------------------------------------------------------------------
func TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId(t *testing.T) {
xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteailureUnknownInstanceId")
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cRestSubReqFromXapp, 1},
+ Counter{cRestSubRespToXapp, 1},
+ Counter{cSubReqToE2, 1},
+ Counter{cSubRespFromE2, 1},
+ Counter{cRestSubNotifToXapp, 1},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cRestSubDelRespToXapp, 1},
+ Counter{cSubDelReqToE2, 1},
+ Counter{cSubDelReqTimerExpiry, 1},
+ Counter{cSubDelReReqToE2, 1},
+ Counter{cSubDelFailFromE2, 2},
+ })
+
// Req
var params *teststube2ap.RESTSubsReqParams = nil
restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
// E2t: Receive 1st SubsDelReq
delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
- // Unknown instanceId in this response which will result resending original request
+ // Unknown instanceId 0 in this response which will result resending original request
delreq.RequestId.InstanceId = 0
e2termConn1.SendSubsDelFail(t, delreq, delmsg)
// E2t: Receive 2nd SubsDelReq
delreq, delmsg = e2termConn1.RecvSubsDelReq(t)
- // Subscription does not exist in in E2 Node.
+ // Subscription does not exist in in E2 Node. E2 Node responds with failure but there is also same unknown instanceId 0
e2termConn1.SendSubsDelFail(t, delreq, delmsg)
// Wait that subs is cleaned
xappConn1.TestMsgChanEmpty(t)
e2termConn1.TestMsgChanEmpty(t)
mainCtrl.wait_registry_empty(t, 10)
+ mainCtrl.VerifyAllClean(t)
+ mainCtrl.VerifyCounterValues(t)
}
//-----------------------------------------------------------------------------
// | |------------->|
// | | |
// | | SubDelFail | No transaction for the response
-// | |<-------------|
+// | |<-------------| Ongoing transaction not found. This will result timer expiry and resending
// | | |
// | | SubDelReq |
// | |------------->|
// | | |
-// | | SubDelFail | Subscription does exist any more
-// | |<-------------|
-//
+// | | SubDelFail | Subscription does exist any more in E2 node
+// | |<-------------| Ongoing transaction not found. This will result timer expiry
+// | | |
+// | [SUBS DELETE] |
+// | | |
//-----------------------------------------------------------------------------
func TestRESTUnpackSubscriptionDeleteFailureNoTransaction(t *testing.T) {
xapp.Logger.Debug("TEST: TestRESTUnpackSubscriptionDeleteFailureNoTransaction")
+ mainCtrl.CounterValuesToBeVeriefied(t, CountersToBeAdded{
+ Counter{cRestSubReqFromXapp, 1},
+ Counter{cRestSubRespToXapp, 1},
+ Counter{cSubReqToE2, 1},
+ Counter{cSubRespFromE2, 1},
+ Counter{cRestSubNotifToXapp, 1},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cRestSubDelRespToXapp, 1},
+ Counter{cSubDelReqToE2, 1},
+ Counter{cSubDelReqTimerExpiry, 2},
+ Counter{cSubDelReReqToE2, 1},
+ Counter{cSubDelFailFromE2, 2},
+ })
+
// Req
var params *teststube2ap.RESTSubsReqParams = nil
restSubId, e2SubsId := createSubscription(t, xappConn1, e2termConn1, params)
xappConn1.TestMsgChanEmpty(t)
e2termConn1.TestMsgChanEmpty(t)
mainCtrl.wait_registry_empty(t, 10)
+ mainCtrl.VerifyAllClean(t)
+ mainCtrl.VerifyCounterValues(t)
}
//-----------------------------------------------------------------------------
Counter{cRestSubReqFromXapp, 1},
Counter{cRestSubRespToXapp, 1},
Counter{cRestSubFailNotifToXapp, 1},
+ Counter{cRestSubDelReqFromXapp, 1},
+ Counter{cRestSubDelRespToXapp, 1},
})
const subReqCount int = 1
xapp.Logger.Debug("TEST: REST notification received e2SubsId=%v", e2SubsId)
e2ap_wrapper.AllowE2apToProcess(e2ap_wrapper.SUB_REQ, true)
+
+ xappConn1.SendRESTSubsDelReq(t, &restSubId)
+
// Wait that subs is cleaned
waitSubsCleanup(t, e2SubsId, 10)
+ mainCtrl.VerifyAllClean(t)
mainCtrl.VerifyCounterValues(t)
}
Counter{cRestSubReqFromXapp, 2},
Counter{cRestSubRespToXapp, 2},
Counter{cSubReqToE2, 2},
+ Counter{cSubReqTimerExpiry, 1},
Counter{cSubRespFromE2, 1},
Counter{cRestSubNotifToXapp, 1},
Counter{cRestSubFailNotifToXapp, 1},
e2termConn1.SendSubsDelResp(t, delreq, delmsg)
waitSubsCleanup(t, e2SubsId, 10)
-
+ mainCtrl.VerifyAllClean(t)
mainCtrl.VerifyCounterValues(t)
}
Counter{cSubReqToE2, 2},
Counter{cSubRespFromE2, 1},
Counter{cRestSubNotifToXapp, 1},
- Counter{cRestSubNotifToXapp, 1},
Counter{cRestSubDelReqFromXapp, 1},
Counter{cSubDelReqToE2, 1},
+ Counter{cSubDelRespFromE2, 1},
Counter{cRestSubDelRespToXapp, 1},
})
- // Remove possible existing subscription
- mainCtrl.removeExistingSubscriptions(t)
-
const e2Timeout int64 = 1
const e2RetryCount int64 = 0
const routingNeeded bool = false
mainCtrl.SimulateRestart(t)
xapp.Logger.Debug("mainCtrl.SimulateRestart done")
+ // ReadE2Subscriptions() for testing is running in own go routine (go mainCtrl.c.ReadE2Subscriptions())
+ // That needs to be completed before successful subscription query is possible
+ <-time.After(time.Second * 1)
+
// Check subscription
queryXappSubscription(t, int64(e2SubsId), "RAN_NAME_1", []string{"localhost:13560"})
- xapp.Logger.Debug("Here 1")
- //<-time.After(3 * time.Second)
- xapp.Logger.Debug("Here 2")
-
// Delete subscription
xappConn1.SendRESTSubsDelReq(t, &restSubId)
delreq, delmsg := e2termConn1.RecvSubsDelReq(t)
waitSubsCleanup(t, e2SubsId, 10)
mainCtrl.VerifyCounterValues(t)
+ mainCtrl.VerifyAllClean(t)
}
////////////////////////////////////////////////////////////////////////////////////
func queryXappSubscription(t *testing.T, e2SubsId int64, meid string, endpoint []string) {
resp, _ := xapp.Subscription.QuerySubscriptions()
- assert.Equal(t, resp[0].SubscriptionID, e2SubsId)
- assert.Equal(t, resp[0].Meid, meid)
- assert.Equal(t, resp[0].ClientEndpoint, endpoint)
+ assert.Equal(t, e2SubsId, resp[0].SubscriptionID)
+ assert.Equal(t, meid, resp[0].Meid)
+ assert.Equal(t, endpoint, resp[0].ClientEndpoint)
}
func waitSubsCleanup(t *testing.T, e2SubsId uint32, timeout int) {