X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fteststube2ap%2FstubE2.go;h=98c98f42bc7a117acc7bbf192529c932451720a6;hb=268d715e3bceab8f7955d89945141efdb2c3b368;hp=8fbfd448f5395a14dedd86a9cc0f09b324c7da5d;hpb=e93b00fe97d7f1f4a0a687df1403494ad06b8c9a;p=ric-plt%2Fsubmgr.git diff --git a/pkg/teststube2ap/stubE2.go b/pkg/teststube2ap/stubE2.go index 8fbfd44..98c98f4 100644 --- a/pkg/teststube2ap/stubE2.go +++ b/pkg/teststube2ap/stubE2.go @@ -48,6 +48,7 @@ type RmrTransactionId struct { type E2RestIds struct { RestSubsId string E2SubsId uint32 + ErrorCause string } func (trans *RmrTransactionId) String() string { @@ -680,7 +681,20 @@ func (tc *E2Stub) SubscriptionRespHandler(resp *clientmodel.SubscriptionResponse //----------------------------------------------------------------------------- // //----------------------------------------------------------------------------- + func (tc *E2Stub) ExpectRESTNotification(t *testing.T, restSubsId string) { + tc.expectNotification(t, restSubsId, "") +} + +func (tc *E2Stub) ExpectRESTNotificationOk(t *testing.T, restSubsId string) { + tc.expectNotification(t, restSubsId, "allOk") +} + +func (tc *E2Stub) ExpectRESTNotificationNok(t *testing.T, restSubsId string, expectError string) { + tc.expectNotification(t, restSubsId, expectError) +} + +func (tc *E2Stub) expectNotification(t *testing.T, restSubsId string, expectError string) { tc.Info("### Started to wait REST notification for %v on port %v f(RMR port %v), %v responses expected", restSubsId, *tc.clientEndpoint.HTTPPort, *tc.clientEndpoint.RMRPort, tc.requestCount) tc.restSubsIdList = []string{restSubsId} @@ -695,6 +709,10 @@ func (tc *E2Stub) ExpectRESTNotification(t *testing.T, restSubsId string) { tc.TestError(t, "### REST notification count unexpectedly ZERO for %s (%v)", restSubsId, tc) } else if e2Ids.RestSubsId != restSubsId { tc.TestError(t, "### Unexpected REST notifications received |%s:%s| (%v)", e2Ids.RestSubsId, restSubsId, tc) + } else if e2Ids.ErrorCause == "" && expectError == "allFail" { + tc.TestError(t, "### Unexpected ok cause received from REST notifications |%s:%s| (%v)", e2Ids.RestSubsId, restSubsId, tc) + } else if e2Ids.ErrorCause != "" && expectError == "allOk" { + tc.TestError(t, "### Unexpected error cause (%s) received from REST notifications |%s:%s| (%v)", e2Ids.ErrorCause, e2Ids.RestSubsId, restSubsId, tc) } else { tc.requestCount-- if tc.requestCount == 0 { @@ -702,6 +720,9 @@ func (tc *E2Stub) ExpectRESTNotification(t *testing.T, restSubsId string) { } else { tc.Info("### Expected REST notifications received for %s, (%v)", e2Ids.RestSubsId, tc) } + if e2Ids.ErrorCause != "" && expectError == "allFail" { + tc.Info("### REST Notification: %s, ErrorCause: %v", e2Ids.RestSubsId, e2Ids.ErrorCause) + } tc.Info("### REST Notification received Notif for %s : %v", e2Ids.RestSubsId, e2Ids.E2SubsId) tc.ListedRESTNotifications <- e2Ids } @@ -758,7 +779,11 @@ func (tc *E2Stub) ListedRestNotifHandler(resp *clientmodel.SubscriptionResponse) tc.restSubsIdList = append(tc.restSubsIdList[:i], tc.restSubsIdList[i+1:]...) //tc.Info("Removed %s from Listed REST notifications, %v entries left", *resp.SubscriptionID, len(tc.restSubsIdList)) - tc.CallBackListedNotifications <- E2RestIds{*resp.SubscriptionID, uint32(*resp.SubscriptionInstances[0].E2EventInstanceID)} + if resp.SubscriptionInstances[0].ErrorCause != nil { + tc.CallBackListedNotifications <- E2RestIds{*resp.SubscriptionID, uint32(*resp.SubscriptionInstances[0].E2EventInstanceID), *resp.SubscriptionInstances[0].ErrorCause} + } else { + tc.CallBackListedNotifications <- E2RestIds{*resp.SubscriptionID, uint32(*resp.SubscriptionInstances[0].E2EventInstanceID), ""} + } if len(tc.restSubsIdList) == 0 { //tc.Info("All listed REST notifications received for endpoint=%s", tc.clientEndpoint) @@ -858,15 +883,15 @@ func (p *RESTSubsReqParams) GetRESTSubsReqReportParams(subReqCount int, clientEn reqId := int64(requestCount) + 1 subscriptionDetail := &clientmodel.SubscriptionDetail{ XappEventInstanceID: &reqId, - EventTriggers: &clientmodel.EventTriggerDefinition{ - OctetString: "1234" + strconv.Itoa(requestCount), + EventTriggers: clientmodel.EventTriggerDefinition{ + int64(1234 + requestCount), }, ActionToBeSetupList: clientmodel.ActionsToBeSetup{ &clientmodel.ActionToBeSetup{ ActionID: &actionId, ActionType: &actionType, - ActionDefinition: &clientmodel.ActionDefinition{ - OctetString: "5678" + strconv.Itoa(requestCount), + ActionDefinition: clientmodel.ActionDefinition{ + int64(5678 + requestCount), }, SubsequentAction: &clientmodel.SubsequentAction{ SubsequentActionType: &subsequestActioType, @@ -938,34 +963,32 @@ func (p *RESTSubsReqParams) SetSubActionIDs(actionId int64) { } } -func (p *RESTSubsReqParams) SetSubActionDefinition(actionDefinition string) { +func (p *RESTSubsReqParams) SetSubActionDefinition(actionDefinition []int64) { for _, subDetail := range p.SubsReqParams.SubscriptionDetails { for _, action := range subDetail.ActionToBeSetupList { if action != nil { - action.ActionDefinition.OctetString = actionDefinition + action.ActionDefinition = actionDefinition } } } } -func (p *RESTSubsReqParams) SetSubEventTriggerDefinition(eventTriggerDefinition string) { +func (p *RESTSubsReqParams) SetSubEventTriggerDefinition(eventTriggerDefinition []int64) { for _, subDetail := range p.SubsReqParams.SubscriptionDetails { if subDetail != nil { - subDetail.EventTriggers.OctetString = eventTriggerDefinition + subDetail.EventTriggers = eventTriggerDefinition } } } -func (p *RESTSubsReqParams) AppendActionToActionToBeSetupList(actionId int64, actionType string, actionDefinition string, subsequentActionType string, timeToWait string) { +func (p *RESTSubsReqParams) AppendActionToActionToBeSetupList(actionId int64, actionType string, actionDefinition []int64, subsequentActionType string, timeToWait string) { actionToBeSetup := &clientmodel.ActionToBeSetup{ - ActionID: &actionId, - ActionType: &actionType, - ActionDefinition: &clientmodel.ActionDefinition{ - OctetString: actionDefinition, - }, + ActionID: &actionId, + ActionType: &actionType, + ActionDefinition: clientmodel.ActionDefinition(actionDefinition), SubsequentAction: &clientmodel.SubsequentAction{ SubsequentActionType: &subsequentActionType, TimeToWait: &timeToWait, @@ -1059,15 +1082,15 @@ func (p *RESTSubsReqParams) GetRESTSubsReqPolicyParams(subReqCount int, clientEn reqId := int64(requestCount) + 1 subscriptionDetail := &clientmodel.SubscriptionDetail{ XappEventInstanceID: &reqId, - EventTriggers: &clientmodel.EventTriggerDefinition{ - OctetString: "1234" + strconv.Itoa(requestCount), + EventTriggers: clientmodel.EventTriggerDefinition{ + int64(1234 + requestCount), }, ActionToBeSetupList: clientmodel.ActionsToBeSetup{ &clientmodel.ActionToBeSetup{ ActionID: &actionId, ActionType: &actionType, - ActionDefinition: &clientmodel.ActionDefinition{ - OctetString: "5678" + strconv.Itoa(requestCount), + ActionDefinition: clientmodel.ActionDefinition{ + int64(5678 + requestCount), }, SubsequentAction: &clientmodel.SubsequentAction{ SubsequentActionType: &subsequestActioType,