RIC-851: Updated rtmgr to create xapp routes
[ric-plt/rtmgr.git] / pkg / sbi / sbi_test.go
index feba821..aa12d60 100644 (file)
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
+
+   This source code is part of the near-RT RIC (RAN Intelligent Controller)
+   platform project (RICP).
+
 ==================================================================================
 */
 /*
 ==================================================================================
 */
 /*
@@ -26,20 +30,21 @@ package sbi
 import (
        "errors"
        "reflect"
 import (
        "errors"
        "reflect"
+       "routing-manager/pkg/rtmgr"
        "testing"
 )
 
 func TestGetSbi(t *testing.T) {
        var errtype = errors.New("")
        "testing"
 )
 
 func TestGetSbi(t *testing.T) {
        var errtype = errors.New("")
-       var sbitype = new(NngPush)
-       var invalids = []string{"nngpus", ""}
+       var sbitype = new(RmrPush)
+       var invalids = []string{"rmrpus", ""}
 
 
-       sbii, err := GetSbi("nngpush")
+       sbii, err := GetSbi("rmrpush")
        if err != nil {
        if err != nil {
-               t.Errorf("GetSbi(nngpub) was incorrect, got: %v, want: %v.", reflect.TypeOf(err), nil)
+               t.Errorf("GetSbi(rmrpub) was incorrect, got: %v, want: %v.", reflect.TypeOf(err), nil)
        }
        if reflect.TypeOf(sbii) != reflect.TypeOf(sbitype) {
        }
        if reflect.TypeOf(sbii) != reflect.TypeOf(sbitype) {
-               t.Errorf("GetSbi(nngpub) was incorrect, got: %v, want: %v.", reflect.TypeOf(sbii), reflect.TypeOf(sbitype))
+               t.Errorf("GetSbi(rmrpub) was incorrect, got: %v, want: %v.", reflect.TypeOf(sbii), reflect.TypeOf(sbitype))
        }
 
        for _, arg := range invalids {
        }
 
        for _, arg := range invalids {
@@ -49,3 +54,42 @@ func TestGetSbi(t *testing.T) {
                }
        }
 }
                }
        }
 }
+
+func TestUpdateE2TendPoint(t *testing.T) {
+       var err error
+       var sbi = Sbi{}
+       sbii, err := GetSbi("rmrpush")
+
+       var EP = make(map[string]*rtmgr.Endpoint)
+       EP["127.0.0.2"] = &rtmgr.Endpoint{Uuid: "127.0.0.2", Name: "E2TERM", XAppType: "app1", Ip: "127.0.0.2", Port: 4562, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: true, Keepalive: false}
+       rtmgr.Eps = EP
+
+       var rmrpush = RmrPush{}
+       rmrpush.AddEndpoint(rtmgr.Eps["127.0.0.2"])
+
+       var E2map = make(map[string]rtmgr.E2TInstance)
+
+       E2map["127.0.0.2:4562"] = rtmgr.E2TInstance{
+               Name:    "E2Tinstance1",
+               Fqdn:    "127.0.0.2:4562",
+               Ranlist: []string{"1", "2"},
+       }
+
+       sbi.updateE2TEndpoints(&E2map, sbii)
+       t.Log(err)
+}
+
+func TestPruneEndpointList(t *testing.T) {
+       var sbi = Sbi{}
+       var err error
+       sbii, err := GetSbi("rmrpush")
+       var EP = make(map[string]*rtmgr.Endpoint)
+       EP["127.0.0.2"] = &rtmgr.Endpoint{Uuid: "127.0.0.2", Name: "E2TERM", XAppType: "app1", Ip: "127.0.0.1", Port: 4562, TxMessages: []string{"", ""}, RxMessages: []string{"", ""}, Socket: nil, IsReady: true, Keepalive: false}
+       rtmgr.Eps = EP
+
+       var rmrpush = RmrPush{}
+       rmrpush.AddEndpoint(rtmgr.Eps["127.0.0.2"])
+
+       sbi.pruneEndpointList(sbii)
+       t.Log(err)
+}